0.49.3 • Published 3 years ago

mangata-sdk v0.49.3

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 years ago

Artwork

npm Issues Pull Request GitHub last commit Build Status npm type definitions

DO NOT USE. UNDER DEVELOPMENT

Getting Started

Mangata SDK is a first library, built in typescript that provides easy methods for buying and selling assets on Mangata DEX. The main purpose is to save time for builders of client applications, primarily for algorithmic traders and frontend interface builders.

Installation

// with npm
npm i mangata-sdk

// with yarn
yarn add mangata-sdk

Basic use case

Here is a quick example to get you started, all you need is Mangata instance:

const { Mangata } = require('mangata-sdk');

async function main () {
  // Connect to the local node (also testnet, mainnet)
  const mangata = Mangata.getInstance('ws://127.0.0.1:9944')

  // Retrieve the chainName, nodeName & nodeVersion information
  const [chain, nodeName, nodeVersion] = await Promise.all([
    mangata.getChain(),
    mangata.getNodeName(),
    mangata.getNodeVersion()
  ]);

  console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
  
  // you can also only call one method
  cont chain = await mangata.getChain()
  console.log(`You are connected to chain ${chain}`)
}

main().catch(console.error).finally(() => process.exit());

Available Methods

TxOptions Type (Optional)

InputType
nonceBN
signerSigner
statusCallbackfunction
extrinsicStatusfunction

getApi

If you need to retrieve underlying API

const mangata = Mangata.getInstance('ws://127.0.0.1:9944')
const api = await mangata.getApi()
console.log("Connected: ", api.isConnected)

getChain

If you need to retrieve the chain name

const mangata = Mangata.getInstance('ws://127.0.0.1:9944')
const chain = await mangata.getChain()
console.log('Chain: ', chain)

getNonce

Retrieve the current nonce

InputType
addressstring

createPool

Extrinsic to create pool

InputType
accountstring or KeyringPair
firstTokenIdstring
firstTokenAmountBN
secondTokenIdstring
secondTokenAmountBN
txOptionsTxOptions

sellAsset

Extrinsic to sell/swap

InputType
accountstring or KeyringPair
soldAssetIdstring
boughtAssetIdstring
amountBN
minAmountOutBN
txOptionsTxOptions

buyAsset

Extrinsic to buy/swap

InputType
accountstring or KeyringPair
soldAssetIdstring
boughtAssetIdstring
amountBN
maxAmountInBN
txOptionsTxOptions

mintLiquidity

Extrinsic to add liquidity to pool

InputType
accountstring or KeyringPair
firstTokenIdstring
secondTokenIdstring
firstTokenAmountBN
expectedSecondTokenAmountBN
txOptionsTxOptions

burnLiquidity

Extrinsic to remove liquidity from liquidity pool

InputType
accountstring or KeyringPair
firstTokenIdstring
secondTokenIdstring
liquidityTokenAmountBN
txOptionsTxOptions

calculateBuyPrice

Returns sell amount you need to pay in sold token id for bought token id in buy amount

InputType
inputReserveBN
outputReserveBN
buyAmountBN

calculateSellPrice

Returns bought asset amount returned by selling sold token id for bought token id in sell amount

InputType
inputReserveBN
outputReserveBN
buyAmountBN

calculateSellPriceId

Returns bought token amount returned by selling sold token id for bought token id in sell amount

InputType
soldTokenIdBN
boughtTokenIdBN
sellAmountBN

calculateBuyPriceId

Returns sell amount you need to pay in sold token id for bought token id in buy amount

InputType
soldTokenIdBN
boughtTokenIdBN
buyAmountBN

getAmountOfTokenIdInPool

Get amount of token id in pool

InputType
firstTokenIdBN
secondTokenIdBN

getLiquidityAssetId

Returns liquidity asset id

InputType
firstTokenIdBN
secondTokenIdBN

getLiquidityPool

Returns pool corresponding to specified liquidity asset ID in from of first and second token Id pair

InputType
liquidityAssetIdstring

getTreasury

Returns amount of token ID in Treasury

InputType
tokenIdstring

getTreasuryBurn

Returns amount of currtokenency ID in Treasury Burn

InputType
tokenIdstring

transferToken

Extrinsic that transfers Token Id in value amount from origin to destination

InputType
accountstring or KeyringPair
tokenIdstring
addressstring
amountBN
txOptionsTxOptions

transferTokenAll

Extrinsic that transfers all token Id from origin to destination

InputType
accountstring or KeyringPair
tokenIdstring
addressstring
txOptionsTxOptions

getTotalIssuance

Returns total issuance of Token Id

InputType
tokenIdstring

getTokenBalance

Returns token balance for address

InputType
tokenIdstring
addressstring

getTokenInfo

Returns token info

InputType
tokenIdstring

getBridgeTokens

0.43.0

3 years ago

0.48.0

3 years ago

0.48.1

3 years ago

0.44.0

3 years ago

0.49.1

3 years ago

0.49.2

3 years ago

0.49.0

3 years ago

0.45.0

3 years ago

0.49.3

3 years ago

0.49.4

3 years ago

0.41.0

3 years ago

0.46.0

3 years ago

0.42.0

3 years ago

0.47.0

3 years ago

0.40.2

3 years ago

0.40.0

3 years ago

0.40.1

3 years ago

0.31.2

3 years ago

0.31.1

3 years ago

0.31.0

3 years ago

0.20.0

3 years ago

0.19.0

3 years ago

0.19.1

3 years ago

0.19.2

3 years ago

0.19.3

3 years ago

0.19.4

3 years ago

0.19.5

3 years ago

0.19.6

3 years ago

0.30.2

3 years ago

0.30.1

3 years ago

0.30.0

3 years ago

0.18.1

3 years ago

0.18.2

3 years ago

0.18.3

3 years ago

0.18.4

3 years ago

0.18.5

3 years ago

0.18.6

3 years ago

0.18.7

3 years ago

0.18.8

3 years ago

0.18.0

3 years ago

0.17.5

3 years ago

0.17.6

3 years ago

0.17.7

3 years ago

0.17.8

3 years ago

0.17.2

3 years ago

0.15.4

3 years ago

0.17.3

3 years ago

0.15.5

3 years ago

0.17.4

3 years ago

0.11.0

4 years ago

0.13.0

4 years ago

0.15.0

3 years ago

0.15.1

3 years ago

0.17.0

3 years ago

0.15.2

3 years ago

0.17.1

3 years ago

0.15.3

3 years ago

0.9.0

4 years ago

0.16.3

3 years ago

0.16.4

3 years ago

0.16.5

3 years ago

0.10.1

4 years ago

0.12.0

4 years ago

0.14.0

3 years ago

0.16.0

3 years ago

0.16.1

3 years ago

0.16.2

3 years ago

0.10.0

4 years ago

0.8.9

4 years ago

0.8.8

4 years ago

0.8.5

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.4

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.5.9

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.0

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.5.2

4 years ago

0.4.3

4 years ago

0.5.1

4 years ago

0.4.2

4 years ago

0.3.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.1

4 years ago