Uniswap

Uniswap Resolver to get buy and sell details. You can view details like source code, ABIs on Etherscan.

Get Buy amount.

Get buy token details like amount and unit amount.

Note: Price is depends on the route, so with direct route of two tokens you may not get the best price

dsa.uniswap.getBuyAmount(buyToken, sellToken, sellAmt, slippage);

Parameter

Type

Description

buyToken

address/string

The buy token address or symbol.

sellToken

address/string

The sell token address or symbol.

sellAmt

number

The amount of tokens to sells.

slippage

number

The slippage in percent eg - 1 means 1%, 10 means 10%, etc

Returns: Object of buy token details.

{
  buyAmt: 236.20778018242365,
  buyAmtRaw: "236207780182423627288",
  unitAmt: "236184159404405384925"
}

Return Parameter

Type

Description

buyAmt

number

Expected buy token amount.

buyAmtRaw

number

Expected buy token amount in decimal form.

unitAmt

number

The unit amount is the minimum amount of buy token expected per sell token. It is calculated with the help of slippage. The parameter is passed directly in the Uniswap connector.

Get Sell amount

Get sell token details like amount and unit amount.

Note: Price is depends on the route, so with direct route of two tokens you may not get the best price

dsa.uniswap.getSellAmount(buyToken, sellToken, buyAmt, slippage);

Parameter

Type

Description

buyToken

address/string

The buy token address or symbol.

sellToken

address/string

The sell token address or symbol.

buyAmt

number

The amount of tokens to buy.

slippage

number

The slippage in percent eg - 1 means 1%, 10 means 10%, etc

Returns: Object of buy token details

{
  sellAmt: 4.234905980688704,
  sellAmtRaw: "4234905980688704170",
  unitAmt: "4235329471286773"
}

Return Parameter

Type

Description

sellAmt

number

Expected sell token amount.

sellAmtRaw

number

Expected sell token amount in decimal form.

unitAmt

number

The unit amount is the minimum amount of buy token expected per sell token. It is calculated with the help of slippage. The parameter is passed directly in the Uniswap connector.

Get Deposit amount.

Get deposit token details like amount and unit amount.

dsa.uniswap.getDepositAmount(tokenA, tokenB, amtA);

Parameter

Type

Description

tokenA

address/string

The token A address/symbol

tokenB

address

The token B address/symbol.

amtA

number

The token A amount in decimals form.

Returns: Object of deposit token details

{
  amountA: 1000,
  amountB: 4.220445538525322,
  amountB_Raw: "4220445538525322000",
  unitAmt: "4220445538525322"
}

Return Parameter

Type

Description

amountA

number

The amount of token A to deposit.

amountB

number

The expected tokenB amount to deposit.

amountB_Raw

number

The expected tokenB amount to deposit in decimal form.

unitAmt

number

The amountB / amountA with slippage. The unit amount is the minimum amount of tokenB per tokenA to deposit.

Get Withdraw amount

Get withdraw token details like amount and unit amount

dsa.uniswap.getWithdrawAmount(tokenA, tokenB, uniAmt, slippage);

Parameter

Type

Description

tokenA

address/string

The token A address or symbol

tokenB

address/string

The token B address or symbol.

uniAmt

number

The uni token amount in decimals.

slippage

number

The slippage of trade.

Returns: Object of withdraw token details

{
  amountA: 15861.653879312871,
  amountB: 66.94324634857887,
  amountA_Raw: "15861653879312872303739",
  amountB_Raw: "66943246348578875300",
  unitAmtA: "15860067713924941017",
  unitAmtB: "66936552023944017"
}

Return Parameter

Type

Description

amountA

number

The expected amount of tokenA to withdraw.

amountB

number

The expected amount of tokenB to withdraw.

amountA_Raw

number

The expected tokenA amount to withdraw in decimal form.

amountB_Raw

number

The expected tokenB amount to withdraw in decimal form.

unitAmtA

number

The unit amount is the minimum amount of tokenA per uni token to withdraw.

unitAmtB

number

The unit amount is the minimum amount of tokenB per uni token to withdraw.

Get Position

Fetch the Uniswap position details of an address

dsa.uniswap.getPosition(address, tokenPair);

Parameter

Type

Description

address

address

The user address.

key

array

The token pair array. Eg: [{tokenA: _addrA, tokenB: _addrB}]

Returns: Object with all the Uniswap details

[
  {
      amountA: 18137.821372507322,
      amountB: 18451.728375,
      uniTokenAmount: 0.018134598864049847
  }
]

Return Parameter

Type

Description

amountA

number

The amount of token A.

amountB

number

The amount of token B.

uniTokenAmount

number

The uni token amount i.e. Uniswap token amount for a specific pool to determine the share in the pool.

Last updated