stableex / sx.newdex

SX NewDex

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SX.NewDex

C++ interface and data structures for interacting with NewDex smart contract newdexpublic

Quickstart

#include <sx.newdex/newdex.hpp>

// user input
const asset quantity = asset{10000, symbol{"EOS", 4}};
const uint64_t mid = 470; // EOS/USN pair
const symbol out_sym = symbol{"USDT", 4};

// get newdex info
const auto [out, order] = newdex::get_amount_out( mid, quantity, out_sym );

// => [ "4.6500 USDT", "sell-market" ]

Table of Content

STATIC get_amount_out

Get amount to receive when market selling quantity to out_sym

params

  • {uint64_t} mid - market id
  • {asset} quantity - quantity to convert
  • {symbol} out_sym - symbol to convert to

returns

  • {pair<asset, string>} - return amount, type of order (sell_market or buy_market)

example

#include <sx.newdex/newdex.hpp>

// user input
const asset quantity = asset{10000, symbol{"EOS", 4}};
const uint64_t mid = 470; // EOS/USN pair
const symbol out_sym = symbol{"USDT", 4};

// get newdex info
const auto [out, order] = newdex::get_amount_out( mid, quantity, out_sym );

// => [ "4.6500 USDT", "sell-market" ]

STATIC get_fee

Get NewDex total fee

params

returns

  • {uint8_t} - total fee (trade + protocol)

example

const uint8_t fee = newdex::get_fee();
// => 15

About

SX NewDex

License:GNU General Public License v3.0


Languages

Language:C++ 86.7%Language:Shell 13.3%