🔬
JediSwap
  • 👋Welcome to JediSwap
  • 🛠️Become a contributor
  • 🎁DeFi spring STRK incentives for v2
  • 🎁DeFi Spring STRK incentives for v1
  • FAQ
  • How to use JediSwap
    • How to set up a Starknet wallet
      • How to set up an Argent X wallet
      • How to set up an Argent Web Wallet
      • How to set up a Braavos wallet
    • How to bridge assets to Starknet
      • How to bridge to Starknet using Starkgate
      • How to bridge to Starknet using Orbiter Finance
      • How to bridge to Starknet using LayerSwap
    • How to make a swap
    • How to add liquidity
      • How to add liquidity V1
      • How to add liquidity V2
    • How to ZAP
      • How to ZAP from Ethereum L1 to Starknet
      • How to ZAP on Starknet
    • Points
      • LP Leaderboard
      • Volume Leaderboard
  • For Developers
    • Jediswap v2
      • Core
        • jediswap_v2_factory
        • jediswap_v2_pool
      • Periphery
        • jediswap_v2_nft_position_manager
        • jediswap_v2_swap_router
      • Contract Addresses
      • Deprecated Contract Addresses
    • Jediswap v1
      • Smart Contract integration
        • Implement a swap
        • Providing liquidity
        • Pair Addresses
      • Smart contract reference
        • Router
        • Pair
        • Factory
        • Pair (ERC 20)
  • Risks associated with JediSwap
Powered by GitBook
On this page
  • Functions
  • ABI
  1. For Developers
  2. Jediswap v2
  3. Periphery

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:

Name
Type
Description

params

ExactInputSingleParams

The parameters necessary for the swap

Return Values:

Type
Description

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:

Name
Type
Description

params

ExactInputParams

The parameters necessary for the multi-hop swap

Return Values:

Type
Description

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:

Name
Type
Description

params

ExactOutputSingleParams

The parameters necessary for the swap

Return Values:

Type
Description

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:

Name
Type
Description

params

ExactOutputParams

The parameters necessary for the multi-hop swap

Return Values:

Type
Description

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:

Name
Type
Description

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>);
}
Previousjediswap_v2_nft_position_managerNextContract Addresses

Last updated 1 year ago