How to integrate Curve connector?

What is Curve? :thinking:
Curve is an AMM for stable coins and similarly priced assets. Users can exchange between similar types of assets, or deposit them to earn yield from trading fees.

How to interact with Curve from DSA wallet?
Currently on DSA Curve sUSDv2 And Curve sBTC pool are integrated.

Resources:
Curve sUSDv2 Connector docs: https://docs.instadapp.io/connectors/curve-susd/
Curve sBTC Connector docs: https://docs.instadapp.io/connectors/curve-sbtc/

Curve sUSDv2 Resolver docs: https://docs.instadapp.io/resolvers/curve_susd/
Curve sBTC Resolverdocs: https://docs.instadapp.io/resolvers/curve_sbtc/

Let’s swap to USDC from DAI.

let spells = dsa.Spell();

let daiAmt = 100; // 100 DAI
let daiAmtInWei = dsa.tokens.fromDecimal(daiAmt, "dai"); // 100 DAI in Wei
let slippage = 0.1; // 0.1% slippage.
let daiAddr = dsa.tokens.info.dai.address;
let usdcAddr = dsa.tokens.info.usdc.address;

// Resolver function to get `uintAmt` value. 
// You can use above resolver documentation for reference. 
let sellDetails = await dsa.curve_susd.getBuyAmount("USDC", "DAI", daiAmtInWei, slippage);

spells.add({
  connector: "curve-susd",
  method: "sell",
  args: [usdcAddr, daiAddr, daiAmtInWei, sellDetails.unitAmt, 0, 0]
});

// Note: Make sure you have set DSA instance.
// If not, follow this to setup: https://docs.instadapp.io/setup/
await dsa.cast(spells);
1 Like

Lending swap recipe between Compound And Curve below:

let spells = dsa.Spell();

let daiAmt = 100; // 100 DAI
let daiAmtInWei = dsa.tokens.fromDecimal(daiAmt, "dai"); // 100 DAI in Wei
let slippage = 0.1; // 0.1% slippage.
let daiAddr = dsa.tokens.info.dai.address;

// Resolver function to get `uintAmt` value. 
// You can use above resolver documentation for reference. 
let depositDetails = await dsa.curve_susd.getDepositAmount("DAI", daiAmtInWei, slippage);

let storeId = "8018367";

// Note: Make sure that DAI supplied to Compound is not been used as
// collateral for borrowed asset(s).
spells.add({
    connector: "compound",
    method: "withdraw",
    args: [daiAddr, daiAmtInWei, 0, storeId]
  });

spells.add({
  connector: "curve-susd",
  method: "deposit",
  args: [daiAddr, daiAmtInWei, depositDetails.unitAmt, storeId, 0]
});

// Note: Make sure you have set DSA instance.
// If not, follow this to setup: https://docs.instadapp.io/setup/
await dsa.cast(spells);
2 Likes