jediswap_v2_swap_router
Router for stateless execution of swaps against JediSwap V2
Functions
exact_input_single
fn exact_input_single(ref self: ContractState, params: ExactInputSingleParams) -> u256
Swaps amount_in
of one token for as much as possible of another token
Parameters:
params
ExactInputSingleParams
The parameters necessary for the swap
Return Values:
u256
The amount of the received token
exact_input
fn exact_input(ref self: ContractState, params: ExactInputParams) -> u256
Swaps amount_in
of one token for as much as possible of another along the specified path
Parameters:
params
ExactInputParams
The parameters necessary for the multi-hop swap
Return Values:
u256
The amount of the received token
exact_output_single
fn exact_output_single(ref self: ContractState, params: ExactOutputSingleParams) -> u256
Swaps as little as possible of one token for amount_out
of another token
Parameters:
params
ExactOutputSingleParams
The parameters necessary for the swap
Return Values:
u256
The amount of the input token
exact_output
fn exact_output(ref self: ContractState, params: ExactOutputParams) -> u256
Swaps as little as possible of one token for amount_out
of another along the specified path (reversed)
path array will be in format [token_out, token_in, fee] if used for single hop (recommend using exact_output_single)
for multihop going from token_in to token_out via token_mid, path will be [token_out, token_mid, fee_out_mid, token_mid, token_in, fee_mid_in]
Parameters:
params
ExactOutputParams
The parameters necessary for the multi-hop swap
Return Values:
u256
The amount of the input token
jediswap_v2_swap_callback
fn jediswap_v2_swap_callback(ref self: ContractState, amount0_delta: i256, amount1_delta: i256, callback_data_span: Span<felt252>)
Parameters:
amount0_delta
i256
amount1_delta
i256
callback_data_span
Span<felt252>
ABI
//sign true for negative numbers
struct i256 {
mag: u256,
sign: bool,
}
struct ExactInputSingleParams {
token_in: ContractAddress,
token_out: ContractAddress,
fee: u32,
recipient: ContractAddress,
deadline: u64,
amount_in: u256,
amount_out_minimum: u256,
sqrt_price_limit_X96: u256
}
struct ExactInputParams {
path: Array<felt252>,
recipient: ContractAddress,
deadline: u64,
amount_in: u256,
amount_out_minimum: u256
}
struct ExactOutputSingleParams {
token_in: ContractAddress,
token_out: ContractAddress,
fee: u32,
recipient: ContractAddress,
deadline: u64,
amount_out: u256,
amount_in_maximum: u256,
sqrt_price_limit_X96: u256
}
struct ExactOutputParams {
path: Array::<felt252>,
recipient: ContractAddress,
deadline: u64,
amount_out: u256,
amount_in_maximum: u256
}
#[starknet::interface]
trait IJediSwapV2SwapRouter<TContractState> {
fn get_factory(self: @TContractState) -> ContractAddress;
fn exact_input_single(ref self: TContractState, params: ExactInputSingleParams) -> u256;
fn exact_input(ref self: TContractState, params: ExactInputParams) -> u256;
fn exact_output_single(ref self: TContractState, params: ExactOutputSingleParams) -> u256;
fn exact_output(ref self: TContractState, params: ExactOutputParams) -> u256;
fn jediswap_v2_swap_callback(ref self: TContractState, amount0_delta: i256, amount1_delta: i256, callback_data_span: Span<felt252>);
}
Last updated