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, |
[blocksBehind] | number |
Default value is |
[expireSeconds] | number |
Default value is |
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 fromBasicPositionsContract
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
-
.armExistingEosPosition(owner, positionId, arm, [transactionParams]) ⇒
Promise
-
.dearmEosPosition(owner, positionId, debtTarget, [transactionParams]) ⇒
Promise
-
.getSettings() ⇒
Promise.<object>
-
.armEos(accountName, amount, arm, [transactionParams]) ⇒
Promise
armContract.armEos(accountName, amount, arm, [transactionParams]) ⇒ 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 |
Promise
armContract.armExistingEosPosition(owner, positionId, arm, [transactionParams]) ⇒ 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 |
Promise
armContract.dearmEosPosition(owner, positionId, debtTarget, [transactionParams]) ⇒ 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 |
Promise.<object>
armContract.getSettings() ⇒ 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
-
BalanceGetter
- new BalanceGetter(connector)
-
.getEos(account) ⇒
Promise.<number>
-
.getEosdt(account) ⇒
Promise.<number>
-
.getNut(account) ⇒
Promise.<number>
-
.getPbtc(account) ⇒
Promise.<number>
-
.getPeth(account) ⇒
Promise.<number>
new BalanceGetter(connector)
Creates instance of BalanceGetter
Param | Description |
---|---|
connector | EosdtConnector (see |
Promise.<number>
balanceGetter.getEos(account) ⇒ Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
EOS balance of account
Param | Type | Description |
---|---|---|
account | string |
Account name |
Promise.<number>
balanceGetter.getEosdt(account) ⇒ Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
EOSDT balance of account
Param | Type | Description |
---|---|---|
account | string |
Account name |
Promise.<number>
balanceGetter.getNut(account) ⇒ Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
NUT balance of account
Param | Type | Description |
---|---|---|
account | string |
Account name |
Promise.<number>
balanceGetter.getPbtc(account) ⇒ Kind: instance method of BalanceGetter
Returns: Promise.<number>
-
PBTC balance of account
Param | Type | Description |
---|---|---|
account | string |
Account name |
Promise.<number>
balanceGetter.getPeth(account) ⇒ 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 |
|
tokenSymbol | string |
"PBTC" or "PETH" |
Promise
basicPositionsContract.newPosition(accountName, collatAmount, eosdtAmount, [transactionParams]) ⇒ 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 |
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 |
Promise
basicPositionsContract.give(giverAccount, receiver, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.addCollateral(senderName, amount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.deleteCollateral(senderName, amount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.generateDebt(senderName, amount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.burnbackDebt(senderName, amount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.addCollatAndDebt(senderName, addedCollatAmount, generatedDebtAmount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.pbtcDelCollatAndRedeem(senderName, amount, positionId, btcAddress, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.marginCall(senderName, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.del(creator, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.paybackAndDelete(maker, debtAmount, positionId, [transactionParams]) ⇒ 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 |
Promise
basicPositionsContract.close(senderAccount, positionId, [transactionParams]) ⇒ 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 |
Promise.<number>
basicPositionsContract.getContractTokenBalance() ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<number>
-
Contract's collateral asset balance.
Promise.<Array.<object>>
basicPositionsContract.getRates() ⇒ 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
Promise.<Array.<object>>
basicPositionsContract.getRatesNew() ⇒ 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
Promise.<Array.<object>>
basicPositionsContract.getLtvRatiosTable() ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>>
-
Table of current LTV ratios for all positions.
Promise.<(object|undefined)>
basicPositionsContract.getPositionLtvRatio(id) ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)>
-
Current LTV ratio for position by id
Param | Type | Description |
---|---|---|
id | number |
Position id |
Promise.<(object|undefined)>
basicPositionsContract.getPositionById(id) ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)>
-
A position object
Param | Type | Description |
---|---|---|
id | number |
Position id |
Promise.<(object|undefined)>
basicPositionsContract.getPositionByMaker(maker) ⇒ 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 |
Promise.<Array.<object>>
basicPositionsContract.getAllUserPositions(maker) ⇒ 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 |
Promise.<Array.<object>>
basicPositionsContract.getAllPositions() ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<Array.<object>>
-
An array of all positions created on this contract
Promise.<(object|undefined)>
basicPositionsContract.getLatestUserPosition(accountName) ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<(object|undefined)>
-
Position object - position of the account with maximum id value
Param | Type |
---|---|
accountName | string |
Promise.<object>
basicPositionsContract.getParameters() ⇒ Kind: instance method of BasicPositionsContract
Returns: Promise.<object>
-
Positions contract parameters
Promise.<object>
basicPositionsContract.getSettings() ⇒ 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
-
BpManager
- new BpManager(connector)
-
.getAllBpPositions() ⇒
Promise.<Array.<object>>
-
.getBpPosition() ⇒
Promise.<(object|undefined)>
-
.registerBlockProducer(bpName, depositedAmount, [transactionParams]) ⇒
Promise
-
.changeBlockProducerReward(bpName, rewardAmount, [transactionParams]) ⇒
Promise
-
.unregisterBlockProducer(bpName, [transactionParams]) ⇒
Promise
-
.depositEos(fromAccount, bpName, eosAmount, [transactionParams]) ⇒
Promise
new BpManager(connector)
Creates instance of BpManager
Param | Description |
---|---|
connector | EosdtConnector (see |
Promise.<Array.<object>>
bpManager.getAllBpPositions() ⇒ Kind: instance method of BpManager
Returns: Promise.<Array.<object>>
-
An array of objects, that contain information about registered block producers
Promise.<(object|undefined)>
bpManager.getBpPosition() ⇒ Kind: instance method of BpManager
Returns: Promise.<(object|undefined)>
-
Object with information about a registered block producer
Promise
bpManager.registerBlockProducer(bpName, depositedAmount, [transactionParams]) ⇒ 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 |
Promise
bpManager.changeBlockProducerReward(bpName, rewardAmount, [transactionParams]) ⇒ 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 |
Promise
bpManager.unregisterBlockProducer(bpName, [transactionParams]) ⇒ Deactivates block producer
Kind: instance method of BpManager
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|---|---|
bpName | string |
Account name |
[transactionParams] | object |
Promise
bpManager.depositEos(fromAccount, bpName, eosAmount, [transactionParams]) ⇒ 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 |
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 |
Promise
governanceContract.propose(proposal, senderName, [transactionParams]) ⇒ 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 |
Promise
governanceContract.expire(proposalName, senderName, [transactionParams]) ⇒ Expires an active proposal
Kind: instance method of GovernanceContract
Returns: Promise
-
Promise of transaction receipt
Param | Type | Description |
---|---|---|
proposalName | string |
|
senderName | string |
|
[transactionParams] | object |
Promise
governanceContract.applyChanges(proposalName, senderName, [transactionParams]) ⇒ 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 |
Promise
governanceContract.cleanProposal(proposalName, deletedVotes, senderName, [transactionParams]) ⇒ 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 |
Promise
governanceContract.stake(senderName, nutsAmount, [trxMemo], [transactionParams]) ⇒ 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 |
Promise
governanceContract.unstake(nutAmount, voterName, [transactionParams]) ⇒ 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 |
Promise
governanceContract.vote(proposalName, vote, voterName, voteJson, [transactionParams]) ⇒ 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 |
voterName | string |
|
voteJson | string |
|
[transactionParams] | object |
Promise
governanceContract.unvote(proposalName, voterName, [transactionParams]) ⇒ 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 |
Promise
governanceContract.voteForBlockProducers(voterName, producers, [transactionParams]) ⇒ 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 |
Promise
governanceContract.stakeAndVoteForBlockProducers(voterName, nutAmount, producers, [transactionParams]) ⇒ 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 |
Promise.<(object|undefined)>
governanceContract.getVoterInfo() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<(object|undefined)>
-
Amount of NUTs staked by account in Governance contract and their unstake date
Promise.<Array.<object>>
governanceContract.getVoterInfosTable() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>>
-
Table of information on accounts that staked NUT
Promise.<Array.<object>>
governanceContract.getVotes() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>>
-
An array with all Governance contract votes (up to 10000)
Promise.<Array.<object>>
governanceContract.getVotesForAccount() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>>
-
All account votes
Promise.<Array.<object>>
governanceContract.getProposals() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>>
-
An array with all Governance contract proposals (up to 10000)
Promise.<Array.<object>>
governanceContract.getBpVotes() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<Array.<object>>
-
Array of objects, containing block producers names and amount of NUT votes for them
Promise.<(object|undefined)>
governanceContract.getProxyInfo() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<(object|undefined)>
-
Voter info for eosdtbpproxy
Promise.<object>
governanceContract.getSettings() ⇒ Kind: instance method of GovernanceContract
Returns: Promise.<object>
-
Governance contract settings
Promise.<object>
governanceContract.getParameters() ⇒ 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 |
Promise
liquidatorContract.marginCallAndBuyoutCollat(senderName, positionId, eosdtToTransfer, [trxMemo], [transactionParams]) ⇒ 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 |
Promise
liquidatorContract.transferEosdt(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒ 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 |
Promise
liquidatorContract.transferNut(senderName, nutAmount, trxMemo, [transactionParams]) ⇒ 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 |
Promise.<string>
liquidatorContract.getSurplusDebt() ⇒ Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of system surplus debt
Promise.<string>
liquidatorContract.getBadDebt() ⇒ Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of system bad debt
Promise.<string>
liquidatorContract.getCollatBalance() ⇒ Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of collateral on liquidator contract balance
Promise.<string>
liquidatorContract.getNutCollatBalance() ⇒ Kind: instance method of LiquidatorContract
Returns: Promise.<string>
-
Amount of NUT collateral on liquidator
Promise.<object>
liquidatorContract.getParameters() ⇒ Kind: instance method of LiquidatorContract
Returns: Promise.<object>
-
Liquidator contract parameters object
Promise.<object>
liquidatorContract.getSettings() ⇒ 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
-
PositionsContract
- new PositionsContract(connector)
- .newEmptyPositionWithRef(maker, referralId, [transactionParams])
-
.getPositionById(id) ⇒
Promise.<object>
-
.getPositionByMaker(maker) ⇒
Promise.<(object|undefined)>
-
.getAllUserPositions(maker) ⇒
Promise.<Array.<object>>
-
.getAllPositions() ⇒
Promise.<Array.<object>>
-
.getLatestUserPosition() ⇒
Promise.<(object|undefined)>
-
.getParameters() ⇒
Promise.<Array.<object>>
-
.addReferral(senderName, nutAmount, [transactionParams]) ⇒
Promise
-
.deleteReferral(senderName, referralId, [transactionParams]) ⇒
Promise
-
.getReferralById(id) ⇒
Promise.<(object|undefined)>
-
.getAllReferrals() ⇒
Promise.<Array.<object>>
-
.getReferralByName(name) ⇒
Promise.<(object|undefined)>
-
.getPositionReferral(positionId) ⇒
Promise.<(object|undefined)>
-
.getPositionReferralsTable() ⇒
Promise.<Array.<object>>
-
.getAllReferralPositionsIds() ⇒
Promise.<Array.<number>>
new PositionsContract(connector)
Creates an instance of PositionsContract
Param | Description |
---|---|
connector | EosdtConnector (see |
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 |
Promise.<object>
positionsContract.getPositionById(id) ⇒ Kind: instance method of PositionsContract
Returns: Promise.<object>
-
A position object
Param | Type |
---|---|
id | number |
Promise.<(object|undefined)>
positionsContract.getPositionByMaker(maker) ⇒ 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 |
Promise.<Array.<object>>
positionsContract.getAllUserPositions(maker) ⇒ 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 |
Promise.<Array.<object>>
positionsContract.getAllPositions() ⇒ Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
An array of all positions created on this contract
Promise.<(object|undefined)>
positionsContract.getLatestUserPosition() ⇒ Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
Position object - position of the account with maximum id value
Promise.<Array.<object>>
positionsContract.getParameters() ⇒ Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
Positions contract parameters
Promise
positionsContract.addReferral(senderName, nutAmount, [transactionParams]) ⇒ 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 |
Promise
positionsContract.deleteReferral(senderName, referralId, [transactionParams]) ⇒ 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 |
Promise.<(object|undefined)>
positionsContract.getReferralById(id) ⇒ Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
An object with information about referral
Param | Type |
---|---|
id | number |
Promise.<Array.<object>>
positionsContract.getAllReferrals() ⇒ Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
Table of existing referrals
Promise.<(object|undefined)>
positionsContract.getReferralByName(name) ⇒ Kind: instance method of PositionsContract
Returns: Promise.<(object|undefined)>
-
An object with information about referral
Param | Type | Description |
---|---|---|
name | string |
Account name |
Promise.<(object|undefined)>
positionsContract.getPositionReferral(positionId) ⇒ 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 |
Promise.<Array.<object>>
positionsContract.getPositionReferralsTable() ⇒ Kind: instance method of PositionsContract
Returns: Promise.<Array.<object>>
-
An array of objects, containing positions ids and those positions referrals ids
Promise.<Array.<number>>
positionsContract.getAllReferralPositionsIds() ⇒ 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
-
SavingsRateContract
- new SavingsRateContract(connector)
-
.stake(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒
Promise
-
.unstake(toAccount, eosdtAmount, [transactionParams]) ⇒
Promise
-
.getAllPositions() ⇒
Promise.<Array.<object>>
-
.getPositionById() ⇒
Promise.<(object|undefined)>
-
.getUserPositions() ⇒
Promise.<Array.<object>>
-
.getParameters() ⇒
Promise.<object>
-
.getSettings() ⇒
Promise.<object>
new SavingsRateContract(connector)
Instantiates SavingsRateContract
Param | Description |
---|---|
connector | EosdtConnector (see |
Promise
savingsRateContract.stake(senderName, eosdtAmount, [trxMemo], [transactionParams]) ⇒ 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 |
Promise
savingsRateContract.unstake(toAccount, eosdtAmount, [transactionParams]) ⇒ 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 |
Promise.<Array.<object>>
savingsRateContract.getAllPositions() ⇒ Kind: instance method of SavingsRateContract
Returns: Promise.<Array.<object>>
-
An array of all positions on Savings Rate contract
Promise.<(object|undefined)>
savingsRateContract.getPositionById() ⇒ Kind: instance method of SavingsRateContract
Returns: Promise.<(object|undefined)>
-
A Savings Rate position object with given id
Promise.<Array.<object>>
savingsRateContract.getUserPositions() ⇒ Kind: instance method of SavingsRateContract
Returns: Promise.<Array.<object>>
-
Array of all positions objects, created by the maker
Promise.<object>
savingsRateContract.getParameters() ⇒ Kind: instance method of SavingsRateContract
Returns: Promise.<object>
-
Savings Rate contract parameters
Promise.<object>
savingsRateContract.getSettings() ⇒ 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
-
TokenSwapContract
- new TokenSwapContract(connector)
-
.transferNut(senderName, nutAmount, ethereumAddress, [transactionParams]) ⇒
Promise
-
.claim(toAccount, positionId, ethereumSignature, [transactionParams]) ⇒
Promise
-
.getParameters() ⇒
Promise.<object>
-
.getSettings() ⇒
Promise.<object>
-
.getAllPositions() ⇒
Promise.<Array.<object>>
new TokenSwapContract(connector)
Instantiates TokenSwapContract
Param | Description |
---|---|
connector | EosdtConnector (see |
Promise
tokenSwapContract.transferNut(senderName, nutAmount, ethereumAddress, [transactionParams]) ⇒ 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 |
Promise
tokenSwapContract.claim(toAccount, positionId, ethereumSignature, [transactionParams]) ⇒ 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 |
Promise.<object>
tokenSwapContract.getParameters() ⇒ Kind: instance method of TokenSwapContract
Returns: Promise.<object>
-
TokenSwap contract parameters
Promise.<object>
tokenSwapContract.getSettings() ⇒ Kind: instance method of TokenSwapContract
Returns: Promise.<object>
-
TokenSwap contract settings
Promise.<Array.<object>>
tokenSwapContract.getAllPositions() ⇒ Kind: instance method of TokenSwapContract
Returns: Promise.<Array.<object>>
-
An array of all positions created on TokenSwap contract
© 2019-2021 Equilibrium