Starknet Router V2

Functions

constructor

#[constructor]
fn constructor(ref self: ContractState, _owner: ContractAddress)

Paramaters

Parameter nametypeDescription

_owner

ContractAddress

owner of router contract

swap

 #[external(v0)]
 fn swap(ref self: ContractState, route: RouteParam, swap_parameters: Array<SwapParams>)

Paramaters

RouteParam

Parameter nameTypeDescription

token_in

ContractAddress

contract address of token to sell

token_out

ContractAddress

contract address of token to buy

amount_in

u256

amount of token to sell

min_received

u256

minimum received amount of user get

destination

ContractAddress

The receiver address for the output token

SwapParams

Parameter nameTypeDescription

token_in

ContractAddress

contract address of token to sell

token_out

ContractAddress

contract address of token to buy

rate

u32

rate * 10**4 gives 4 precision points

protocol_id

u32

procotol id

extra_data

Array<felt252>

extra data for route

Events

Swap

#[derive(Drop, starknet::Event)]
struct Swap {
    sender: ContractAddress,
    token_in: ContractAddress,
    token_out: ContractAddress,
    amount_in: u256,
    amount_out: u256,
    to: ContractAddress
}
Parameter nameTypeDescription

sender

ContractAddress

address that execute the transaction.

token_in

ContractAddress

contract address of token to sell

token_out

CoıntractAddress

contract address of token to buy

amount_in

u256

amount of token to sold

amount_out

u256

amount of token to bought.

to

ContractAddress

receiver address for the output token

Last updated