@routexio/sdk
v0.3.0
Published
## Install
Downloads
55
Readme
Routex SDK
Install
npm install @routexio/sdkDemo
import { Routex, Network, getDefaultClient, FA_ADDRESSES } from "@routexio/sdk";
// init aptos client
const client = getDefaultClient(Network.Porto);
// init routex
const routex = new Routex({ client, network: Network.Porto });
// 1. swap with routing from fa to fa
// get all supported fungible assets
const fas = await routex.getFungibleAssets();
// get routing from fa to fa
const fasAddresses = FA_ADDRESSES[Network.Porto]!;
const USDT = fasAddresses.USDT.toString();
const WBTC = fasAddresses.WBTC.toString();
const routingFromUSDTToWBTC = await routex.getRouting(USDT, WBTC, 1000000n);
// swap with routing
const txnPayload = await routex.swapWithRouting(routingFromUSDTToWBTC, 5);
// send txn with this payload
const txn = await client.signAndSubmitTransaction(txnPayload);
// 2. swap with routing from coin to fa
// get all supported coins
const coins = await routex.getCoins();
// get routing from coin to fa
const moveCoin = "0x1::aptos_coin::AptosCoin";
const routingFromMoveCoinToUSDT = await routex.getRouting(
moveCoin,
USDT,
1000000n,
);
// swap with routing
const txnPayload2 = await routex.swapWithRouting(routingFromMoveCoinToUSDT, 5);
// send txn with this payload
const txn2 = await client.signAndSubmitTransaction(txnPayload2);