1.3.6 • Published 3 years ago

@eosdt/eosdt-js v1.3.6

Weekly downloads
10
License
MIT
Repository
github
Last release
3 years ago

EOSDT JS

view on npm

A JavaScript library to execute EOSDT contracts methods.

Usage

Install the module using NPM:

$ npm install @eosdt/eosdt-js

Use service module Connector to initiate one of functional modules. Connector uses EOS node address and an array of private keys. Transactions would be signed with given keys and sent to blockchain through given node.

const { EosdtConnector } = require("@eosdt/eosdt-js")

const nodeAddress = "http://node-address.example.com:80"

const connector = new EosdtConnector(nodeAddress, ["private-key-1", "private-key-2"])

const eosPositions = connector.getPositions()
const eosLiquidator = connector.getLiquidator()

const pbtcPositions = connector.getBasicPositions("PBTC")
const pbtcLiquidator = connector.getLiquidator("PBTC")

const pethPositions = connector.getBasicPositions("PETH")
const pethLiquidator = connector.getLiquidator("PETH")

const governance = connector.getGovernance()
const balances = connector.getBalances()
const savings = connector.getSavingsRate()

Fore more code examples, checkout examples folder.

Modules documentation

ITrxParamsArgument

PropertyTypeDescription
permissionstringName of permission, active is used by default
blocksBehindnumberDefault value is 3
expireSecondsnumberDefault value is 60

Classes

ArmContract

Kind: global class

armContract.armEos(accountName, amount, arm, transactionParams) ⇒ Promise

Kind: instance method of ArmContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
accountNamestringname of account that sends EOS and receives position
amountnumber | stringtransferred amount of EOS
armnumberarm value. With arm = 2.1 and 100 EOS user will receive position with 210 EOS
transactionParamsobjectsee ITrxParamsArgument

armContract.armExistingEosPosition(owner, positionId, arm, transactionParams) ⇒ Promise

Kind: instance method of ArmContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
ownerstringname of position maker account
positionIdnumber
armnumberarm value. With arm = 2.1 and 100 EOS user will receive position with 210 EOS
transactionParamsobjectsee ITrxParamsArgument

armContract.dearmEosPosition(owner, positionId, debtTarget, transactionParams) ⇒ Promise

Kind: instance method of ArmContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
ownerstringname of maker account
positionIdnumber
debtTargetnumberapproximate desired debt amount
transactionParamsobjectsee ITrxParamsArgument

armContract.getSettings() ⇒ Promise.<object>

Kind: instance method of ArmContract
Returns: Promise.<object> - Positions contract settings

BalanceGetter

Kind: global class

new BalanceGetter(connector)

ParamDescription
connectorEosdtConnector (see README section Usage)

balanceGetter.getEos(account) ⇒ Promise.<number>

Kind: instance method of BalanceGetter
Returns: Promise.<number> - EOS balance of account

ParamTypeDescription
accountstringAccount name

balanceGetter.getEosdt(account) ⇒ Promise.<number>

Kind: instance method of BalanceGetter
Returns: Promise.<number> - EOSDT balance of account

ParamTypeDescription
accountstringAccount name

balanceGetter.getNut(account) ⇒ Promise.<number>

Kind: instance method of BalanceGetter
Returns: Promise.<number> - NUT balance of account

ParamTypeDescription
accountstringAccount name

balanceGetter.getPbtc(account) ⇒ Promise.<number>

Kind: instance method of BalanceGetter
Returns: Promise.<number> - PBTC balance of account

ParamTypeDescription
accountstringAccount name

balanceGetter.getPeth(account) ⇒ Promise.<number>

Kind: instance method of BalanceGetter
Returns: Promise.<number> - PETH balance of account

ParamTypeDescription
accountstringAccount name

BasicPositionsContract

Kind: global class

new BasicPositionsContract(connector, tokenSymbol)

ParamTypeDescription
connectorEosdtConnector (see README section Usage)
tokenSymbolstring"PBTC" or "PETH"

basicPositionsContract.newPosition(accountName, collatAmount, eosdtAmount, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
accountNamestringCreator's account name
collatAmountstring | numberAmount of collateral tokens to transfer to position
eosdtAmountstring | numberEOSDT amount to issue
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.newEmptyPosition(maker, transactionParams)

Kind: instance method of BasicPositionsContract

ParamTypeDescription
makerstringAccount to create position for
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.give(giverAccount, receiver, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
giverAccountstringAccount name
receiverstringAccount name
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.addCollateral(senderName, amount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
amountstring | numberAmount of added collateral
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.deleteCollateral(senderName, amount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
amountstring | number
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.generateDebt(senderName, amount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
amountstring | numberNot more than 4 significant decimals
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.burnbackDebt(senderName, amount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
amountstring | numberNot more than 4 significant decimals
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.addCollatAndDebt(senderName, addedCollatAmount, generatedDebtAmount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
addedCollatAmountstring | number
generatedDebtAmountstring | number
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.pbtcDelCollatAndRedeem(senderName, amount, positionId, btcAddress, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
amountstring | number
positionIdnumber
btcAddressstring
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.marginCall(senderName, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestringAccount name
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.del(creator, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
creatorstringAccount name
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.paybackAndDelete(maker, debtAmount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
makerstringAccount name
debtAmountstring | numberMust be > than position debt
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.close(senderAccount, positionId, transactionParams) ⇒ Promise

Kind: instance method of BasicPositionsContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderAccountstringAccount name
positionIdnumber
transactionParamsobjectsee ITrxParamsArgument

basicPositionsContract.getContractTokenBalance() ⇒ Promise.<number>

Kind: instance method of BasicPositionsContract
Returns: Promise.<number> - Contract's collateral asset balance.

basicPositionsContract.getRates() ⇒ Promise.<Array.<object>>

Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>> - Table of current system token prices (contract 'pricefeed.eq' - table 'oraclerates'). These are valid rates, except fields 'backend_price' and 'backend_update' are missing

basicPositionsContract.getRatesNew() ⇒ Promise.<Array.<object>>

Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>> - Table of current system token prices (contract 'pricefeed.eq' - table 'newrates'). These are valid rates including all rates data

basicPositionsContract.getLtvRatiosTable() ⇒ Promise.<Array.<object>>

Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>> - Table of current LTV ratios for all positions.

basicPositionsContract.getPositionLtvRatio(id) ⇒ Promise.<(object|undefined)>

Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)> - Current LTV ratio for position by id

ParamTypeDescription
idnumberPosition id

basicPositionsContract.getPositionById(id) ⇒ Promise.<(object|undefined)>

Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)> - A position object

ParamTypeDescription
idnumberPosition id

basicPositionsContract.getPositionByMaker(maker) ⇒ Promise.<(object|undefined)>

Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)> - Position object - first position that belongs to maker account

ParamTypeDescription
makerstringAccount name

basicPositionsContract.getAllUserPositions(maker) ⇒ Promise.<Array.<object>>

Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>> - Array of all positions objects, created by the maker

ParamTypeDescription
makerstringAccount name

basicPositionsContract.getAllPositions() ⇒ Promise.<Array.<object>>

Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>> - An array of all positions created on this contract

basicPositionsContract.getLatestUserPosition(accountName) ⇒ Promise.<(object|undefined)>

Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)> - Position object - position of the account with maximum id value

ParamType
accountNamestring

basicPositionsContract.getParameters() ⇒ Promise.<object>

Kind: instance method of BasicPositionsContract
Returns: Promise.<object> - Positions contract parameters

basicPositionsContract.getSettings() ⇒ Promise.<object>

Kind: instance method of BasicPositionsContract
Returns: Promise.<object> - Positions contract settings

BpManager

Kind: global class

new BpManager(connector)

ParamDescription
connectorEosdtConnector (see README section Usage)

bpManager.getAllBpPositions() ⇒ Promise.<Array.<object>>

Kind: instance method of BpManager
Returns: Promise.<Array.<object>> - An array of objects, that contain information about registered block producers

bpManager.getBpPosition() ⇒ Promise.<(object|undefined)>

Kind: instance method of BpManager
Returns: Promise.<(object|undefined)> - Object with information about a registered block producer

bpManager.registerBlockProducer(bpName, depositedAmount, transactionParams) ⇒ Promise

Kind: instance method of BpManager
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
bpNamestringAccount name
depositedAmountnumberEOS amount to transfer
transactionParamsobjectsee ITrxParamsArgument

bpManager.changeBlockProducerReward(bpName, rewardAmount, transactionParams) ⇒ Promise

Kind: instance method of BpManager
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
bpNamestringAccount name
rewardAmountnumber
transactionParamsobjectsee ITrxParamsArgument

bpManager.unregisterBlockProducer(bpName, transactionParams) ⇒ Promise

Kind: instance method of BpManager
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
bpNamestringAccount name
transactionParamsobjectsee ITrxParamsArgument

bpManager.depositEos(fromAccount, bpName, eosAmount, transactionParams) ⇒ Promise

Kind: instance method of BpManager
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
fromAccountstringPaying account name
bpNamestring
eosAmountnumber | string
transactionParamsobjectsee ITrxParamsArgument

EosdtConnector

Kind: global class

new EosdtConnector(nodeAddress, privateKeys)

ParamTypeDescription
nodeAddressstringURL of blockchain node, used to send transactions
privateKeysArray.<string>Array of private keys used to sign transactions

eosdtConnector.getBasicPositions(collateralToken) ⇒

Kind: instance method of EosdtConnector
Returns: Instance of BasicPositionsContract

ParamTypeDescription
collateralTokenstring"PBTC" or "PETH"

eosdtConnector.getPositions()

Kind: instance method of EosdtConnector

eosdtConnector.getLiquidator(collateralToken) ⇒

Kind: instance method of EosdtConnector
Returns: Instance of LiquidatorContract

ParamTypeDefaultDescription
collateralTokenstring"EOS""EOS", "PBTC" or "PETH"

eosdtConnector.getSavingsRateCont() ⇒

Kind: instance method of EosdtConnector
Returns: Instance of SavingsRateContract

eosdtConnector.getArmContract() ⇒

Kind: instance method of EosdtConnector
Returns: Instance of ArmContract

eosdtConnector.getTokenSwapContract() ⇒

Kind: instance method of EosdtConnector
Returns: Instance of TokenSwapContract

eosdtConnector.getGovernance() ⇒

Kind: instance method of EosdtConnector
Returns: Instance of GovernanceContract

eosdtConnector.getBalances() ⇒

Kind: instance method of EosdtConnector
Returns: Instance of BalanceGetter

GovernanceContract

Kind: global class

new GovernanceContract(connector)

ParamDescription
connectorEosdtConnector (see README section Usage)

governanceContract.propose(proposal, senderName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalobject
proposal.proposerstring
proposal.namestring
proposal.titlestring
proposal.jsonstring
proposal.expiresAtDate
proposal.typenumber
senderNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.expire(proposalName, senderName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalNamestring
senderNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.applyChanges(proposalName, senderName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalNamestring
senderNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.cleanProposal(proposalName, deletedVotes, senderName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalNamestring
deletedVotesnumber
senderNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.stake(senderName, nutsAmount, trxMemo, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
senderNamestring
nutsAmountstring | number
trxMemostring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.unstake(nutAmount, voterName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
nutAmountstring | number
voterNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.vote(proposalName, vote, voterName, voteJson, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalNamestring
votenumberVote 1 as "yes", 0 or any other number as "no"
voterNamestring
voteJsonstring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.unvote(proposalName, voterName, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
proposalNamestring
voterNamestring
transactionParamsobjectsee ITrxParamsArgument

governanceContract.voteForBlockProducers(voterName, producers, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
voterNamestring
producersArray.<string>
transactionParamsobjectsee ITrxParamsArgument

governanceContract.stakeAndVoteForBlockProducers(voterName, nutAmount, producers, transactionParams) ⇒ Promise

Kind: instance method of GovernanceContract
Returns: Promise - Promise of transaction receipt

ParamTypeDescription
voterNamestring
nutAmountstring | number
producersArray.<string>
transactionParamsobjectsee ITrxParamsArgument

governanceContract.getVoterInfo() ⇒ Promise.<(object|undefined)>

Kind: instance method of GovernanceContract
Returns: Promise.<(object|undefined)> - Amount of NUTs staked by account in Governance contract and their unstake date

governanceContract.getVoterInfosTable() ⇒ Promise.<Array.<object>>

Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>> - Table of information on accounts that staked NUT

governanceContract.getVotes() ⇒ Promise.<Array.<object>>

Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>> - An array with all Governance contract votes (up to 10000)

governanceContract.getVotesForAccount() ⇒ Promise.<Array.<object>>

Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>> - All account votes

governanceContract.getProposals() ⇒ Promise.<Array.<object>>

Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>> - An array with all Governance contract proposals (up to 10000)

governanceContract.getBpVotes() ⇒ Promise.<Array.<object>>

Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>> - Array of objects, containing block producers names and amount of NUT votes for them

governanceContract.getProxyInfo() ⇒ Promise.<(object|undefined)>

Kind: instance method of GovernanceContract
Returns: Promise.<(object|undefined)> - Voter info for eosdtbpproxy

governanceContract.getSettings() ⇒ Promise.<object>

Kind: instance method of GovernanceContract
Returns: Promise.<object> - Governance contract settings
<a name="GovernanceContract+getParameters"

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago

0.8.0

4 years ago

0.7.23

4 years ago

0.7.21

4 years ago

0.7.2

4 years ago

0.7.0

4 years ago

0.6.38

4 years ago

0.6.37

4 years ago

0.6.36

4 years ago

0.6.35

5 years ago

0.6.31

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.0

5 years ago

0.4.41

5 years ago

0.4.4

5 years ago

0.4.31

5 years ago

0.4.30

5 years ago

0.4.25

5 years ago

0.4.23

5 years ago

0.4.22

5 years ago

0.4.21

5 years ago

0.4.2

5 years ago

0.4.0

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago