EOSDT JS
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
This object is used as optional argument in each method that sends actions to blockchain. Use it to manage transaction and action parameters.
This object has following properties:
Property | Type | Description |
---|
[permission] | string | Name of permission, active is used by default |
[blocksBehind] | number | Default value is 3 |
[expireSeconds] | number | Default value is 60 |
Classes
- ArmContract
Module to manage EOSDT arming operations
- BalanceGetter
Module to get account's balances of EOSDT, EOS, PBTC, PETH and NUT
- BasicPositionsContract
Module to manage EOSDT positions with non-EOS collateral
- BpManager
Class for EOSDT Governance actions, related to block producers management
- EosdtConnector
A connector object, used to build classes to work with EOSDT ecosystem contracts
- GovernanceContract
A class to work with EOSDT Governance contract (eosdtgovernc
)
- LiquidatorContract
A class to work with EOSDT Liquidator contract. Creates EOS liquidator by default
- PositionsContract
Module to manage EOS-collateral positions (on contract eosdtcntract
). It is inherited from
BasicPositionsContract
and includes all it's methods.
- SavingsRateContract
A wrapper class to invoke actions of Equilibrium Savings Rate contract
- TokenSwapContract
A wrapper class to invoke actions of Equilibrium Token Swap contract
ArmContract
Module to manage EOSDT arming operations
Kind: global class
armContract.armEos(accountName, amount, arm, [transactionParams]) ⇒ Promise
Creates EOSDT position with given EOS, then sells received EOSDT to buy more EOS and add it
to position. Contract would continue for 20 iterations or until given arm is reached
Kind: instance method of ArmContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
accountName | string | name of account that sends EOS and receives position |
amount | number | string | transferred amount of EOS |
arm | number | arm value. With arm = 2.1 and 100 EOS user will receive position with 210 EOS |
[transactionParams] | object | see ITrxParamsArgument |
armContract.armExistingEosPosition(owner, positionId, arm, [transactionParams]) ⇒ Promise
Gives EOS-EOSDT position to 'arm.eq' contract and it arms that position (see armEos
)
Kind: instance method of ArmContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
owner | string | name of position maker account |
positionId | number | |
arm | number | arm value. With arm = 2.1 and 100 EOS user will receive position with 210 EOS |
[transactionParams] | object | see ITrxParamsArgument |
armContract.dearmEosPosition(owner, positionId, debtTarget, [transactionParams]) ⇒ Promise
Reduces debt on position, selling it's collateral. Will stop, when position has LTV,
equal to critical LTV + arm safety margin. Excess EOSDT would be returned to maker acc
balance
Kind: instance method of ArmContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
owner | string | name of maker account |
positionId | number | |
debtTarget | number | approximate desired debt amount |
[transactionParams] | object | see ITrxParamsArgument |
armContract.getSettings() ⇒ Promise.<object>
Kind: instance method of ArmContract
Returns: Promise.<object>
-
Positions contract settings
BalanceGetter
Module to get account's balances of EOSDT, EOS, PBTC, PETH and NUT
Kind: global class
new BalanceGetter(connector)
Creates instance of BalanceGetter
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
balanceGetter.getEos(account) ⇒ Promise.<number>
Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
EOS balance of account
Param | Type | Description |
---|
account | string | Account name |
balanceGetter.getEosdt(account) ⇒ Promise.<number>
Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
EOSDT balance of account
Param | Type | Description |
---|
account | string | Account name |
balanceGetter.getNut(account) ⇒ Promise.<number>
Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
NUT balance of account
Param | Type | Description |
---|
account | string | Account name |
balanceGetter.getPbtc(account) ⇒ Promise.<number>
Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
PBTC balance of account
Param | Type | Description |
---|
account | string | Account name |
balanceGetter.getPeth(account) ⇒ Promise.<number>
Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
PETH balance of account
Param | Type | Description |
---|
account | string | Account name |
BasicPositionsContract
Module to manage EOSDT positions with non-EOS collateral
Kind: global class
- BasicPositionsContract
- new BasicPositionsContract(connector, tokenSymbol)
- .newPosition(accountName, collatAmount, eosdtAmount, [transactionParams]) ⇒
Promise
- .newEmptyPosition(maker, [transactionParams])
- .give(giverAccount, receiver, positionId, [transactionParams]) ⇒
Promise
- .addCollateral(senderName, amount, positionId, [transactionParams]) ⇒
Promise
- .deleteCollateral(senderName, amount, positionId, [transactionParams]) ⇒
Promise
- .generateDebt(senderName, amount, positionId, [transactionParams]) ⇒
Promise
- .burnbackDebt(senderName, amount, positionId, [transactionParams]) ⇒
Promise
- .addCollatAndDebt(senderName, addedCollatAmount, generatedDebtAmount, positionId, [transactionParams]) ⇒
Promise
- .pbtcDelCollatAndRedeem(senderName, amount, positionId, btcAddress, [transactionParams]) ⇒
Promise
- .marginCall(senderName, positionId, [transactionParams]) ⇒
Promise
- .del(creator, positionId, [transactionParams]) ⇒
Promise
- .paybackAndDelete(maker, debtAmount, positionId, [transactionParams]) ⇒
Promise
- .close(senderAccount, positionId, [transactionParams]) ⇒
Promise
- .getContractTokenBalance() ⇒
Promise.<number>
- .getRates() ⇒
Promise.<Array.<object>>
- .getRatesNew() ⇒
Promise.<Array.<object>>
- .getLtvRatiosTable() ⇒
Promise.<Array.<object>>
- .getPositionLtvRatio(id) ⇒
Promise.<(object|undefined)>
- .getPositionById(id) ⇒
Promise.<(object|undefined)>
- .getPositionByMaker(maker) ⇒
Promise.<(object|undefined)>
- .getAllUserPositions(maker) ⇒
Promise.<Array.<object>>
- .getAllPositions() ⇒
Promise.<Array.<object>>
- .getLatestUserPosition(accountName) ⇒
Promise.<(object|undefined)>
- .getParameters() ⇒
Promise.<object>
- .getSettings() ⇒
Promise.<object>
new BasicPositionsContract(connector, tokenSymbol)
Creates an instance of BasicPositionsContract
Param | Type | Description |
---|
connector | | EosdtConnector (see README section Usage ) |
tokenSymbol | string | "PBTC" or "PETH" |
basicPositionsContract.newPosition(accountName, collatAmount, eosdtAmount, [transactionParams]) ⇒ Promise
Creates new position, sending specified amount of collateral and issuing specified amount
of EOSDT to creator.
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
accountName | string | Creator's account name |
collatAmount | string | number | Amount of collateral tokens to transfer to position |
eosdtAmount | string | number | EOSDT amount to issue |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.newEmptyPosition(maker, [transactionParams])
Creates new position with 0 debt and collateral
Kind: instance method of BasicPositionsContract
Param | Type | Description |
---|
maker | string | Account to create position for |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.give(giverAccount, receiver, positionId, [transactionParams]) ⇒ Promise
Transfers position ownership to another account
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
giverAccount | string | Account name |
receiver | string | Account name |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.addCollateral(senderName, amount, positionId, [transactionParams]) ⇒ Promise
Sends collateral to position to increase it's collateralization.
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
amount | string | number | Amount of added collateral |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.deleteCollateral(senderName, amount, positionId, [transactionParams]) ⇒ Promise
Returns collateral from position, LTV must remain above critical for this action to work
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
amount | string | number | |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.generateDebt(senderName, amount, positionId, [transactionParams]) ⇒ Promise
Issues additional EOSDT if this does not bring position LTV below critical.
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
amount | string | number | Not more than 4 significant decimals |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.burnbackDebt(senderName, amount, positionId, [transactionParams]) ⇒ Promise
Transfers EOSDT to position to burn debt. Excess debt would be refunded to user account
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
amount | string | number | Not more than 4 significant decimals |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.addCollatAndDebt(senderName, addedCollatAmount, generatedDebtAmount, positionId, [transactionParams]) ⇒ Promise
Transfers collateral tokens to position and generates EOSDT debt
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
addedCollatAmount | string | number | |
generatedDebtAmount | string | number | |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.pbtcDelCollatAndRedeem(senderName, amount, positionId, btcAddress, [transactionParams]) ⇒ Promise
Withdraws specified amount of PBTC tokens from position and redeems that PBTCs
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
amount | string | number | |
positionId | number | |
btcAddress | string | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.marginCall(senderName, positionId, [transactionParams]) ⇒ Promise
Called on a position with critical LTV to perform a margin call
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | Account name |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.del(creator, positionId, [transactionParams]) ⇒ Promise
Deletes position that has 0 debt.
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
creator | string | Account name |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.paybackAndDelete(maker, debtAmount, positionId, [transactionParams]) ⇒ Promise
Burns debt on position and deletes it. Debt must be = 0 to delete position. Excess debt
would be refunded to user account
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
maker | string | Account name |
debtAmount | string | number | Must be > than position debt |
positionId | number | |
[transactionParams] | object | see ITrxParamsArgument |
basicPositionsContract.close(senderAccount, positionId, [transactionParams]) ⇒ Promise
Used to close a position in an event of global shutdown.
Kind: instance method of BasicPositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderAccount | string | Account name |
positionId | number | |
[transactionParams] | object | see 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
Param | Type | Description |
---|
id | number | Position id |
basicPositionsContract.getPositionById(id) ⇒ Promise.<(object|undefined)>
Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)>
-
A position object
Param | Type | Description |
---|
id | number | Position 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
Param | Type | Description |
---|
maker | string | Account 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
Param | Type | Description |
---|
maker | string | Account 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
Param | Type |
---|
accountName | string |
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
Class for EOSDT Governance actions, related to block producers management
Kind: global class
new BpManager(connector)
Creates instance of BpManager
Param | Description |
---|
connector | EosdtConnector (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
Registers a block producer in BP voting reward program via EOS transfer. Transferred EOS
is added to BP reward balance
Kind: instance method of BpManager
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
bpName | string | Account name |
depositedAmount | number | EOS amount to transfer |
[transactionParams] | object | see ITrxParamsArgument |
bpManager.changeBlockProducerReward(bpName, rewardAmount, [transactionParams]) ⇒ Promise
Changes amount of EOS reward payed by block producer
Kind: instance method of BpManager
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
bpName | string | Account name |
rewardAmount | number | |
[transactionParams] | object | see ITrxParamsArgument |
bpManager.unregisterBlockProducer(bpName, [transactionParams]) ⇒ Promise
Deactivates block producer
Kind: instance method of BpManager
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
bpName | string | Account name |
[transactionParams] | object | see ITrxParamsArgument |
bpManager.depositEos(fromAccount, bpName, eosAmount, [transactionParams]) ⇒ Promise
Deposit EOS into block producer Governance account to pay reward. Any account can deposit
EOS for a block producer
Kind: instance method of BpManager
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
fromAccount | string | Paying account name |
bpName | string | |
eosAmount | number | string | |
[transactionParams] | object | see ITrxParamsArgument |
EosdtConnector
A connector object, used to build classes to work with EOSDT ecosystem contracts
Kind: global class
new EosdtConnector(nodeAddress, privateKeys)
A connector object, used to build classes to work with EOSDT ecosystem contracts
Param | Type | Description |
---|
nodeAddress | string | URL of blockchain node, used to send transactions |
privateKeys | Array.<string> | Array of private keys used to sign transactions |
eosdtConnector.getBasicPositions(collateralToken) ⇒
Creates class to work with basic positions contract (non-EOS collateral)
Kind: instance method of EosdtConnector
Returns:
Instance of BasicPositionsContract
Param | Type | Description |
---|
collateralToken | string | "PBTC" or "PETH" |
eosdtConnector.getPositions()
Creates a class to work with EOS-collateral positions contract (eosdtcntract
)
Kind: instance method of EosdtConnector
eosdtConnector.getLiquidator([collateralToken]) ⇒
Creates a class to work with specified liquidator contract
Kind: instance method of EosdtConnector
Returns:
Instance of LiquidatorContract
Param | Type | Default | Description |
---|
[collateralToken] | string | "EOS" | "EOS", "PBTC" or "PETH" |
eosdtConnector.getSavingsRateCont() ⇒
Creates a wrapper for Savings Rate contract
Kind: instance method of EosdtConnector
Returns:
Instance of SavingsRateContract
eosdtConnector.getArmContract() ⇒
Creates a wrapper for 'arm.eq' contract
Kind: instance method of EosdtConnector
Returns:
Instance of ArmContract
eosdtConnector.getTokenSwapContract() ⇒
Creates a wrapper for 'tokenswap.eq' contract
Kind: instance method of EosdtConnector
Returns:
Instance of TokenSwapContract
eosdtConnector.getGovernance() ⇒
Instantiates GovernanceContract
- a wrapper to work with eosdtgovernc
Kind: instance method of EosdtConnector
Returns:
Instance of GovernanceContract
eosdtConnector.getBalances() ⇒
Instantiates a simple class to read blockchain balances
Kind: instance method of EosdtConnector
Returns:
Instance of BalanceGetter
GovernanceContract
A class to work with EOSDT Governance contract (eosdtgovernc
)
Kind: global class
- GovernanceContract
- new GovernanceContract(connector)
- .propose(proposal, senderName, [transactionParams]) ⇒
Promise
- .expire(proposalName, senderName, [transactionParams]) ⇒
Promise
- .applyChanges(proposalName, senderName, [transactionParams]) ⇒
Promise
- .cleanProposal(proposalName, deletedVotes, senderName, [transactionParams]) ⇒
Promise
- .stake(senderName, nutsAmount, [trxMemo], [transactionParams]) ⇒
Promise
- .unstake(nutAmount, voterName, [transactionParams]) ⇒
Promise
- .vote(proposalName, vote, voterName, voteJson, [transactionParams]) ⇒
Promise
- .unvote(proposalName, voterName, [transactionParams]) ⇒
Promise
- .voteForBlockProducers(voterName, producers, [transactionParams]) ⇒
Promise
- .stakeAndVoteForBlockProducers(voterName, nutAmount, producers, [transactionParams]) ⇒
Promise
- .getVoterInfo() ⇒
Promise.<(object|undefined)>
- .getVoterInfosTable() ⇒
Promise.<Array.<object>>
- .getVotes() ⇒
Promise.<Array.<object>>
- .getVotesForAccount() ⇒
Promise.<Array.<object>>
- .getProposals() ⇒
Promise.<Array.<object>>
- .getBpVotes() ⇒
Promise.<Array.<object>>
- .getProxyInfo() ⇒
Promise.<(object|undefined)>
- .getSettings() ⇒
Promise.<object>
- .getParameters() ⇒
Promise.<object>
new GovernanceContract(connector)
Creates an instance of GovernanceContract
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
governanceContract.propose(proposal, senderName, [transactionParams]) ⇒ Promise
Creates a proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposal | object | |
proposal.proposer | string | |
proposal.name | string | |
proposal.title | string | |
proposal.json | string | |
proposal.expiresAt | Date | |
proposal.type | number | |
senderName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.expire(proposalName, senderName, [transactionParams]) ⇒ Promise
Expires an active proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposalName | string | |
senderName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.applyChanges(proposalName, senderName, [transactionParams]) ⇒ Promise
Applies proposed changes. At least 51% of all issued NUT tokens must vote, at least 55%
of votes must be for proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposalName | string | |
senderName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.cleanProposal(proposalName, deletedVotes, senderName, [transactionParams]) ⇒ Promise
Removes specified amount of votes from an expired proposal. If 0 votes left, removes proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposalName | string | |
deletedVotes | number | |
senderName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.stake(senderName, nutsAmount, [trxMemo], [transactionParams]) ⇒ Promise
Sends NUT tokens to contract, staking them and allowing to vote for block producers and for
proposals
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
nutsAmount | string | number | |
[trxMemo] | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.unstake(nutAmount, voterName, [transactionParams]) ⇒ Promise
Unstakes NUT tokens to user's balance
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
nutAmount | string | number | |
voterName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.vote(proposalName, vote, voterName, voteJson, [transactionParams]) ⇒ Promise
Vote for or against a proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposalName | string | |
vote | number | Vote 1 as "yes", 0 or any other number as "no" |
voterName | string | |
voteJson | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.unvote(proposalName, voterName, [transactionParams]) ⇒ Promise
Removes all user votes from a proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
proposalName | string | |
voterName | string | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.voteForBlockProducers(voterName, producers, [transactionParams]) ⇒ Promise
Votes with staked NUTs for block producers
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
voterName | string | |
producers | Array.<string> | |
[transactionParams] | object | see ITrxParamsArgument |
governanceContract.stakeAndVoteForBlockProducers(voterName, nutAmount, producers, [transactionParams]) ⇒ Promise
Stakes NUTs and votes for BPs in one transaction
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
voterName | string | |
nutAmount | string | number | |
producers | Array.<string> | |
[transactionParams] | object | see 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
governanceContract.getParameters() ⇒ Promise.<object>
Kind: instance method of GovernanceContract
Returns: Promise.<object>
-
Governance contract parameters
LiquidatorContract
A class to work with EOSDT Liquidator contract. Creates EOS liquidator by default
Kind: global class
- LiquidatorContract
- new LiquidatorContract(connector)
- .marginCallAndBuyoutCollat(senderName, positionId, eosdtToTransfer, [trxMemo], [transactionParams]) ⇒
Promise
- .transferEosdt(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒
Promise
- .transferNut(senderName, nutAmount, trxMemo, [transactionParams]) ⇒
Promise
- .getSurplusDebt() ⇒
Promise.<string>
- .getBadDebt() ⇒
Promise.<string>
- .getCollatBalance() ⇒
Promise.<string>
- .getNutCollatBalance() ⇒
Promise.<string>
- .getParameters() ⇒
Promise.<object>
- .getSettings() ⇒
Promise.<object>
new LiquidatorContract(connector)
Instantiates LiquidatorContract
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
liquidatorContract.marginCallAndBuyoutCollat(senderName, positionId, eosdtToTransfer, [trxMemo], [transactionParams]) ⇒ Promise
Performs margin call on a position and transfers specified amount of EOSDT to liquidator
to buyout freed collateral
Kind: instance method of LiquidatorContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
positionId | number | |
eosdtToTransfer | string | number | |
[trxMemo] | string | |
[transactionParams] | object | see ITrxParamsArgument |
liquidatorContract.transferEosdt(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒ Promise
Sends EOSDT to liquidator contract. Used to cancel bad debt and buyout liquidator
collateral with discount
Kind: instance method of LiquidatorContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
eosdtAmount | string | number | |
[trxMemo] | string | |
[transactionParams] | object | see ITrxParamsArgument |
liquidatorContract.transferNut(senderName, nutAmount, trxMemo, [transactionParams]) ⇒ Promise
Sends NUT tokens to liquidator contract. Send token symbol in memo to buyout collateral
asset (liquidator parameter nut_collat_balance
). With memo "EOSDT" it is used to
buyout EOSDT (liquidator parameter surplus_debt
)
Kind: instance method of LiquidatorContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
nutAmount | string | number | |
trxMemo | string | |
[transactionParams] | object | see ITrxParamsArgument |
liquidatorContract.getSurplusDebt() ⇒ Promise.<string>
Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of system surplus debt
liquidatorContract.getBadDebt() ⇒ Promise.<string>
Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of system bad debt
liquidatorContract.getCollatBalance() ⇒ Promise.<string>
Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of collateral on liquidator contract balance
liquidatorContract.getNutCollatBalance() ⇒ Promise.<string>
Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of NUT collateral on liquidator
liquidatorContract.getParameters() ⇒ Promise.<object>
Kind: instance method of LiquidatorContract
Returns: Promise.<object>
-
Liquidator contract parameters object
liquidatorContract.getSettings() ⇒ Promise.<object>
Kind: instance method of LiquidatorContract
Returns: Promise.<object>
-
Liquidator contract settings object
PositionsContract
Module to manage EOS-collateral positions (on contract eosdtcntract
). It is inherited from
BasicPositionsContract
and includes all it's methods.
Kind: global class
new PositionsContract(connector)
Creates an instance of PositionsContract
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
positionsContract.newEmptyPositionWithRef(maker, referralId, [transactionParams])
Creates position that has a referral. Position would have 0 collateral and 0 debt
Kind: instance method of PositionsContract
Param | Type | Description |
---|
maker | string | Account to create position for |
referralId | number | Id of a referral |
[transactionParams] | object | see ITrxParamsArgument |
positionsContract.getPositionById(id) ⇒ Promise.<object>
Kind: instance method of PositionsContract
Returns: Promise.<object>
-
A position object
positionsContract.getPositionByMaker(maker) ⇒ Promise.<(object|undefined)>
Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
Position object - first position that belongs to
maker account
Param | Type | Description |
---|
maker | string | Account name |
positionsContract.getAllUserPositions(maker) ⇒ Promise.<Array.<object>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
Array of all positions objects, created by the maker
Param | Type | Description |
---|
maker | string | Account name |
positionsContract.getAllPositions() ⇒ Promise.<Array.<object>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
An array of all positions created on this contract
positionsContract.getLatestUserPosition() ⇒ Promise.<(object|undefined)>
Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
Position object - position of the account with
maximum id value
positionsContract.getParameters() ⇒ Promise.<Array.<object>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
Positions contract parameters
positionsContract.addReferral(senderName, nutAmount, [transactionParams]) ⇒ Promise
Creates new referral, staking given amount of NUT tokens. Rejects when amount is less then
referral_min_stake
in positions contract settings.
Kind: instance method of PositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
nutAmount | string | number | |
[transactionParams] | object | see ITrxParamsArgument |
positionsContract.deleteReferral(senderName, referralId, [transactionParams]) ⇒ Promise
Removes referral and unstakes that referral's NUTs
Kind: instance method of PositionsContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
referralId | number | |
[transactionParams] | object | see ITrxParamsArgument |
positionsContract.getReferralById(id) ⇒ Promise.<(object|undefined)>
Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
An object with information about referral
positionsContract.getAllReferrals() ⇒ Promise.<Array.<object>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
Table of existing referrals
positionsContract.getReferralByName(name) ⇒ Promise.<(object|undefined)>
Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
An object with information about referral
Param | Type | Description |
---|
name | string | Account name |
positionsContract.getPositionReferral(positionId) ⇒ Promise.<(object|undefined)>
Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
Returns referral information object if position
with given id has a referral
Param | Type |
---|
positionId | number |
positionsContract.getPositionReferralsTable() ⇒ Promise.<Array.<object>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
An array of objects, containing positions ids and those
positions referrals ids
positionsContract.getAllReferralPositionsIds() ⇒ Promise.<Array.<number>>
Kind: instance method of PositionsContract
Returns: Promise.<Array.<number>>
-
An array of position objects with given referral id
SavingsRateContract
A wrapper class to invoke actions of Equilibrium Savings Rate contract
Kind: global class
new SavingsRateContract(connector)
Instantiates SavingsRateContract
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
savingsRateContract.stake(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒ Promise
Transfers EOSDT from user to Savings Rate contract
Kind: instance method of SavingsRateContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
eosdtAmount | string | number | |
[trxMemo] | string | |
[transactionParams] | object | see ITrxParamsArgument |
savingsRateContract.unstake(toAccount, eosdtAmount, [transactionParams]) ⇒ Promise
Returns EOSDT from Savings Rate contract to account balance
Kind: instance method of SavingsRateContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
toAccount | string | |
eosdtAmount | string | number | |
[transactionParams] | object | see ITrxParamsArgument |
savingsRateContract.getAllPositions() ⇒ Promise.<Array.<object>>
Kind: instance method of SavingsRateContract
Returns: Promise.<Array.<object>>
-
An array of all positions on Savings Rate contract
savingsRateContract.getPositionById() ⇒ Promise.<(object|undefined)>
Kind: instance method of SavingsRateContract
Returns: Promise.<(object|undefined)>
-
A Savings Rate position object with given id
savingsRateContract.getUserPositions() ⇒ Promise.<Array.<object>>
Kind: instance method of SavingsRateContract
Returns: Promise.<Array.<object>>
-
Array of all positions objects, created by the maker
savingsRateContract.getParameters() ⇒ Promise.<object>
Kind: instance method of SavingsRateContract
Returns: Promise.<object>
-
Savings Rate contract parameters
savingsRateContract.getSettings() ⇒ Promise.<object>
Kind: instance method of SavingsRateContract
Returns: Promise.<object>
-
Savings Rate contract settings
TokenSwapContract
A wrapper class to invoke actions of Equilibrium Token Swap contract
Kind: global class
new TokenSwapContract(connector)
Instantiates TokenSwapContract
Param | Description |
---|
connector | EosdtConnector (see README section Usage ) |
tokenSwapContract.transferNut(senderName, nutAmount, ethereumAddress, [transactionParams]) ⇒ Promise
Sends NUT tokens to TokenSwap contract. Send Ethereum address
(available format with and without prefix "0x")
in memo to verify Ethereum signature
Kind: instance method of TokenSwapContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
senderName | string | |
nutAmount | string | number | |
ethereumAddress | string | |
[transactionParams] | object | see ITrxParamsArgument |
tokenSwapContract.claim(toAccount, positionId, ethereumSignature, [transactionParams]) ⇒ Promise
Returns NUT from TokenSwap contract to account balance
and verifies Ethereum signature (available format with and without prefix "0x")
Kind: instance method of TokenSwapContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|
toAccount | string | |
positionId | number | |
ethereumSignature | string | |
[transactionParams] | object | see ITrxParamsArgument |
tokenSwapContract.getParameters() ⇒ Promise.<object>
Kind: instance method of TokenSwapContract
Returns: Promise.<object>
-
TokenSwap contract parameters
tokenSwapContract.getSettings() ⇒ Promise.<object>
Kind: instance method of TokenSwapContract
Returns: Promise.<object>
-
TokenSwap contract settings
tokenSwapContract.getAllPositions() ⇒ Promise.<Array.<object>>
Kind: instance method of TokenSwapContract
Returns: Promise.<Array.<object>>
-
An array of all positions created on TokenSwap contract
© 2019-2021 Equilibrium