Router
Code
Address
Router is deployed at:
Starknet Alpha Testnet: 0x02bcc885342ebbcbcd170ae6cafa8a4bed22bb993479f49806e72d96af94c965
Starknet Alpha Mainnet: 0x041fd22b238fa21cfcf5dd45a8548974d8263b3a531a60388411c5e230f97023
View Functions
factory
func factory() -> (address: felt):Returns Factory address.
sort_tokensβ
func sort_tokens(tokenA: felt, tokenB: felt) -> (token0: felt, token1: felt):Sort tokens by address.
quoteβ
Given some asset amount and reserves, returns an amount of the other asset representing equivalent value.
Useful for calculating optimal token amounts before calling mint.
get_amount_outβ
Given an input asset amount, returns the maximum output amount of the other asset (accounting for fees) given reserves.
get_amount_inβ
Returns the minimum input asset amount required to buy the given output asset amount (accounting for fees) given reserves.
get_amounts_outβ
Given an input asset amount and an array of token addresses, calculates all subsequent maximum output token amounts by calling get_reserves for each pair of token addresses in the path in turn, and using these to call get_amount_out.
Useful for calculating optimal token amounts before calling swap.
get_amounts_inβ
Given an output asset amount and an array of token addresses, calculates all preceding minimum input token amounts by calling get_reserves for each pair of token addresses in the path in turn, and using these to call get_amount_in.
Useful for calculating optimal token amounts before calling swap.
State-Changing Functions
addLiquidityβ
Adds liquidity to an ERC-20βERC-20 pool.
To cover all possible scenarios,οΏ½ οΏ½calle r should have already given the router an allowance of at least amountADesired/amountBDesired on tokenA/tokenB.
Always adds assets at the ideal ratio, according to the price when the transaction is executed.
remove_liquidity
Removes liquidity from an ERC-20βERC-20 pool.
caller should have already given the router an allowance of at least liquidity on the pool.
swap_exact_tokens_for_tokensβ
Swaps an exact amount of input tokens for as many output tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist).
caller should have already given the router an allowance of at least amountIn on the input token.
swap_tokens_for_exact_tokensβ
Receive an exact amount of output tokens for as few input tokens as possible, along the route determined by the path. The first element of path is the input token, the last is the output token, and any intermediate elements represent intermediate tokens to trade through (if, for example, a direct pair does not exist).
caller should have already given the router an allowance of at least amountInMax on the input token.
Interface
ABI
Last updated