Functions

constructor

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

Paramaters

nametypeDescription
_ownerContractAddressThe owner of the router contract

swap

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

Paramaters

RouteParam

@notice RouteParam is a struct that contains the parameters needed to execute a swap

nametypedescription
token_inContractAddresscontract address of token to sell
token_outContractAddresscontract address of token to buy
amount_inu256amount of token to sell
min_receivedu256minimum received amount of user get
destinationContractAddressThe receiver address for the output token

SwapParams

@notice SwapParams is a struct that contains the parameters needed to execute a swap

nametypedescription
token_inContractAddresscontract address of token to sell
token_outContractAddresscontract address of token to buy
rateu32rate * 10**4 gives 4 precision points
protocol_idu32procotol id
extra_dataArray(felt252)extra data fro 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
}
nametypedescription
senderContractAddressaddress that execute the swap
token_inContractAddresscontract address of token to sold
token_outContractAddresscontract address of token to bought
amount_inu256amount of token to sold
amount_outu256amount of token to bought
toContractAddressThe receiver address for the output token