npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@eosdt/eosdt-js

v1.3.6

Published

JS library to execute EOSDT contracts methods

Downloads

48

Readme

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

| 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

Kind: global class

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

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

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

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

Kind: global class

new BalanceGetter(connector)

| 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

Kind: global class

new BasicPositionsContract(connector, tokenSymbol)

| Param | Type | Description | | ----------- | ------------------- | -------------------------------------------------------------------------- | | connector | | EosdtConnector (see README section Usage) | | tokenSymbol | string | "PBTC" or "PETH" |

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

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])

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

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

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

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

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

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

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

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

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

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

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

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

Kind: global class

new BpManager(connector)

| 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

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

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

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

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

Kind: global class

new EosdtConnector(nodeAddress, privateKeys)

| 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) ⇒

Kind: instance method of EosdtConnector
Returns: Instance of BasicPositionsContract

| Param | Type | Description | | --------------- | ------------------- | ------------------------------------------- | | collateralToken | string | "PBTC" or "PETH" |

eosdtConnector.getPositions()

Kind: instance method of EosdtConnector

eosdtConnector.getLiquidator([collateralToken]) ⇒

Kind: instance method of EosdtConnector
Returns: Instance of LiquidatorContract

| Param | Type | Default | Description | | ----------------- | ------------------- | ---------------------------- | ------------------------------------------------------------ | | [collateralToken] | string | "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)

| Param | Description | | --------- | -------------------------------------------------------------------------- | | connector | EosdtConnector (see README section Usage) |

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

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

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

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

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

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

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

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

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

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

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
<a name="GovernanceContract+getParameters"