[OLD] Instadapp Docs
  • Introduction
  • DeFi Smart Account (DSA)
  • DSA SDK
    • Running Instadapp SDK
  • 💻Instadapp GUI
    • Integrated Protocols
      • Aave
      • Compound Finance
      • MakerDAO
    • Strategies
    • Multi-Protocol Refinancing
    • Authorities
    • Debt Collateral Ratio
  • 👩‍💻 DSA SDK
    • Casting Spells
    • Build a Connector
    • Connectors
      • Basic
      • Authority
      • Instapool
      • MakerDAO
      • Compound
      • Comp
      • Aave
      • dYdX
      • 1Inch
      • Uniswap
      • OasisDEX
      • Kyber
      • Curve sBTC
      • Curve sUSD
      • Curve yUSD
    • Resolvers
      • Accounts
      • Balances
      • Instapool
      • MakerDAO
      • Compound
      • Aave
      • dYdX
      • 1inch
      • Uniswap
      • OasisDex
      • Kyber
      • Curve sBTC
      • Curve sUSD
      • Curve yUSD
    • getId/setId
    • Example Use Cases
      • Long ETH
      • Short DAI
      • Debt Swap
      • Lending Bridge
      • Lending Swap
      • Debt Bridge
  • 👩‍🏫 Tutorials
    • Getting Started
    • Moving Assets into DSA
    • In-App Swaps
  • Additional Info
    • Contract Infomation
    • FAQs
    • Security Audits
    • Release History
  • 🌏Links
    • Homepage
    • DApp
    • Discord
    • Contact Us
Powered by GitBook
On this page
  • Buy
  • Sell
  • Deposit Liquidity
  • Withdraw Liquidity
  1. 👩‍💻 DSA SDK
  2. Connectors

Uniswap

Create DEX swaps using Uniswap

These connectors are used to buy and sell on Uniswap and to add or remove liquidity from the protocol. Uniswap is an AMM (Automated Market Marker) all swaps are conducted at market value, utilize slippage to prevent runaway price changes.

Buy

Buy tokens on Uniswap at market value

spells.add({
  connector: "uniswap",
  method: "buy",
  args: [buyAddr, sellAddr, buyAmt, unitAmt, getId, setId]
});

Parameter

Type

Description

buyAddr

address

The token address to buy.

sellAddr

address

The token address to sell.

buyAmt

number

The amount of tokens to buy.

unitAmt

number

The unit amount of sellAmt/buyAmt with slippage.

getId

number

ID fetches the buy amount of buy token.

setId

number

ID stores the sold amount of sell token.

Sell

Sell ETH or ERC20 on Uniswap at market value

spells.add({
  connector: "uniswap",
  method: "sell",
mad    args: [buyAddr, sellAddr, sellAmt, unitAmt, getId, setId]
});

Parameter

Type

Description

buyAddr

address

The token address to buy.

sellAddr

address

The token address to sell.

sellAmt

number

The amount of tokens to sell.

unitAmt

number

The unit amount of sellAmt/buyAmt with slippage.

getId

number

ID fetches the sell amount of sell token.

setId

number

ID stores the bought amount of buy token.

Deposit Liquidity

Deposit Liquidity into Uniswap

spells.add({
  connector: "uniswap",
  method: "deposit",
  args: [tokenA, tokenB, amtA, unitAmt, slippage, getId, setId]
});

Parameter

Type

Description

tokenA

address

The token A address.

tokenB

address

The token B address.

amtA

number

The amount of token A.

unitAmt

number

The unit amount of amtB/amtA with slippage.

slippage

number

The slippage amount.

getId

number

ID fetches the amount of token to deposit.

setId

number

ID stores the amount of token deposited.

Withdraw Liquidity

Withdraw Liquidity from Uniswap

spells.add({
  connector: "uniswap",
  method: "withdraw",
  args: [tokenA, tokenB, uniAmt, unitAmtA, unitAmtB, getId, setIds]
});

Parameter

Type

Description

tokenA

address

The token A address.

tokenB

address

The token B address

uniAmt

number

The uni token amount.

unitAmtA

number

The unit amount of amtA/uniAmt with slippage.

unitAmtB

number

unit amount of amtB/uniAmt with slippage.

getId

number

ID fetches the uni token amount to withdraw.

setIds

number array

ID stores the amount of tokenA and tokenB withdrawn. If not sure, pass `["0", "0"]`

Previous1InchNextOasisDEX

Last updated 4 years ago