0.0.2 • Published 5 months ago
@tokemak/autopilot-swap-route-calc v0.0.2
Tokemak Autopilot Swap Route Calculator
Used to calculate the tokens that will be swapped out of during a redeem() call for a given share amount.
Usage
import { getLiquidations } from "@tokemak/autopilot-swap-route-calc"
const chainId = 1;
const systemRegistry = "";
const providerUrl = "https://eth-mainnet.g.alchemy.com/v2/....";
const autopool = "";
// Amount of shares being redeemed
const shareAmount = 600000000000000000000n;
// Bps to pad the token amounts by. Should be gt 0
const tokenPadBps = 70n;
const result = await getLiquidations(
chainId,
systemRegistry,
providerUrl,
autopool,
shareAmount,
tokenPadBps
);
// If using the Tokemak API to get the swap payloads
const { data } = await axios.post('https://...', {
chainId: 1,
systemName: "gen3",
slippageBps: 10,
tokensToLiquidate: result.liquidations
}, {
headers: {
'Content-Type': 'application/json'
}
})
// data.results is the `customRoutes` parameter in
// the redeemWithRoutes() router call