Router

contracts/wombat-core/libraries/WombatRouter.sol

Title: WombatRouter

Notice: Allows routing on different wombat pools

Details: Owner is allowed and required to approve token spending by pools via approveSpendingByPool function. With great thanks to the uniswap team for your contribution to the opensource community reference: https://github.com/Uniswap/v2-periphery/blob/master/contracts/UniswapV2Router02.sol

constructor

constructor(_wNative)

Arguments

name

type

description

_wNative

address

event OwnershipTransferred

***WombatRouter.OwnershipTransferred(previousOwner, newOwner) ***

Arguments

name

type

description

previousOwner

address

indexed

newOwner

address

indexed

function addLiquidityNative

WombatRouter.addLiquidityNative(pool, minimumLiquidity, to, deadline, shouldStake) payable

Arguments

name

type

description

pool

address

minimumLiquidity

uint256

to

address

deadline

uint256

shouldStake

bool

Outputs

name

type

description

liquidity

uint256

function approveSpendingByPool

***WombatRouter.approveSpendingByPool(tokens, pool) ***

Notice: approve spending of router tokens by pool

Details: needs to be done after asset deployment for router to be able to support the tokens

Arguments

name

type

description

tokens

address[]

array of tokens to be approved

pool

address

to be approved to spend

function getAmountIn

WombatRouter.getAmountIn(tokenPath, poolPath, amountOut) view

Notice: Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees and slippage) Note: This function should be used as estimation only. The actual swap amount might be different due to precision error (the error is typically under 1e-6)

Arguments

name

type

description

tokenPath

address[]

The token swap path

poolPath

address[]

The token pool path

amountOut

uint256

The to amount

Outputs

name

type

description

amountIn

uint256

The potential final amount user would receive

haircuts

uint256[]

function getAmountOut

WombatRouter.getAmountOut(tokenPath, poolPath, amountIn) view

Notice: Given an input asset amount and an array of token addresses, calculates the maximum output token amount (accounting for fees and slippage).

Arguments

name

type

description

tokenPath

address[]

The token swap path

poolPath

address[]

The token pool path

amountIn

int256

The from amount

Outputs

name

type

description

amountOut

uint256

The potential final amount user would receive

haircuts

uint256[]

function owner

WombatRouter.owner() view

Details: Returns the address of the current owner.

Outputs

name

type

description

address

function removeLiquidityFromOtherAssetAsNative

***WombatRouter.removeLiquidityFromOtherAssetAsNative(pool, fromToken, liquidity, minimumAmount, to, deadline) ***

Arguments

name

type

description

pool

address

fromToken

address

liquidity

uint256

minimumAmount

uint256

to

address

deadline

uint256

Outputs

name

type

description

amount

uint256

function removeLiquidityNative

***WombatRouter.removeLiquidityNative(pool, liquidity, minimumAmount, to, deadline) ***

Arguments

name

type

description

pool

address

liquidity

uint256

minimumAmount

uint256

to

address

deadline

uint256

Outputs

name

type

description

amount

uint256

function renounceOwnership

***WombatRouter.renounceOwnership() ***

Details: Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

function swapExactNativeForTokens

WombatRouter.swapExactNativeForTokens(tokenPath, poolPath, minimumamountOut, to, deadline) payable

Arguments

name

type

description

tokenPath

address[]

poolPath

address[]

minimumamountOut

uint256

to

address

deadline

uint256

Outputs

name

type

description

amountOut

uint256

function swapExactTokensForNative

***WombatRouter.swapExactTokensForNative(tokenPath, poolPath, amountIn, minimumamountOut, to, deadline) ***

Arguments

name

type

description

tokenPath

address[]

poolPath

address[]

amountIn

uint256

minimumamountOut

uint256

to

address

deadline

uint256

Outputs

name

type

description

amountOut

uint256

function swapExactTokensForTokens

***WombatRouter.swapExactTokensForTokens(tokenPath, poolPath, amountIn, minimumamountOut, to, deadline) ***

Notice: Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path

Arguments

name

type

description

tokenPath

address[]

The first element of the path is the input token, the last element is the output token.

poolPath

address[]

An array of pool addresses. The pools where the pathTokens are contained in order.

amountIn

uint256

the amount in

minimumamountOut

uint256

the minimum amount to get for user

to

address

the user to send the tokens to

deadline

uint256

the deadline to respect

Outputs

name

type

description

amountOut

uint256

received by user

function transferOwnership

***WombatRouter.transferOwnership(newOwner) ***

Details: Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Arguments

name

type

description

newOwner

address

function wNative

WombatRouter.wNative() view

Outputs

name

type

description

address

Last updated