Skip to content

Instantly share code, notes, and snippets.

@leckylao
Last active Feb 21, 2021
Embed
What would you like to do?
await dsa.setInstance(237);
let withdrawAmount = 1000;
let withdrawAmtInWei = dsa.tokens.fromDecimal(withdrawAmount, "bat");
let slippage = 0.1; // 0.1% slippage.
let bat_address = dsa.tokens.info.bat.address
let usdc_address = dsa.tokens.info.usdc.address
let buyAmount = await dsa.kyber.getBuyAmount("USDC", "BAT", withdrawAmount, slippage);
let spells = dsa.Spell();
spells.add({
connector: "instapool",
method: "flashBorrow",
args: [usdc_address, buyAmount.buyAmtRaw, 0, 0]
});
spells.add({
connector: "compound",
method: "deposit",
args: [usdc_address, buyAmount.buyAmtRaw, 0, 0]
});
spells.add({
connector: "compound",
method: "withdraw",
args: [bat_address, withdrawAmtInWei, 0, 0]
});
spells.add({
connector: "kyber",
method: "sell",
args: [usdc_address, bat_address, withdrawAmtInWei, buyAmount.unitAmt, 0, 0]
});
spells.add({
connector: "instapool",
method: "flashPayback",
args: [usdc_address, 0, 0]
});
dsa.cast(spells).then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment