Calculates on-chain trades, sorted by output amount.
const blockchain = BLOCKCHAIN_NAME.ETHEREUM;
// ETH
const fromTokenAddress = '0x0000000000000000000000000000000000000000';
const fromAmount = 1;
// USDT
const toTokenAddress = '0xdac17f958d2ee523a2206206994597c13d831ec7';
const trades = await sdk.onChainManager.calculateTrade(
{ blockchain, address: fromTokenAddress },
fromAmount,
toTokenAddress
);
const bestTrade = trades[0];
trades.forEach(trade => {
if (trade instanceof OnChainTrade) {
console.log(trade.type, `to amount: ${trade.to.tokenAmount.toFormat(3)}`)
}
})
List of calculated on-chain trades.
Token to sell.
Amount to sell.
Token to get.
Optional
options: OnChainManagerCalculationOptionsAdditional options.
Optional
options: OnChainManagerCalculationOptionsStatic
getGenerated using TypeDoc
Contains methods to calculate on-chain trades.