🔬
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
  • Events
  • ABI
  1. For Developers
  2. Jediswap v2
  3. Core

jediswap_v2_factory

PreviousCoreNextjediswap_v2_pool

Last updated 1 year ago

Deploys JediSwap V2 pools and manages ownership and control over protocol fees

Functions

create_pool

fn create_pool(ref self: ContractState, token_a: ContractAddress, token_b: ContractAddress, fee: u32) -> ContractAddress

Creates a pool for the given two tokens and fee

token_a and token_b may be passed in either order: token0/token1 or token1/token0. tick_spacing is retrieved from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments are invalid.

Emits .

Parameters:

Name
Type
Description

token_a

ContractAddress

One of the two tokens in the desired pool

token_b

ContractAddress

The other of the two tokens in the desired pool

fee

u32

The desired fee for the pool

Return Values:

Type
Description

ContractAddress

The address of the newly created pool

enable_fee_amount

fn enable_fee_amount(ref self: ContractState, fee: u32, tick_spacing: u32)

Enables a fee amount with the given tick_spacing

Fee amounts may never be removed once enabled

Caller is the owner

Parameters:

Name
Type
Description

fee

u32

The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)

tick_spacing

u32

The spacing between ticks to be enforced for all pools created with the given fee amount

set_fee_protocol

fn set_fee_protocol(ref self: ContractState, fee_protocol: u8)

Sets the denominator of the protocol's share of the fees

Caller is the owner

Parameters:

Name
Type
Description

fee_protocol

u8

New protocol fee

transfer_ownership

fn transfer_ownership(ref self: ComponentState<TContractState>, new_owner: ContractAddress)

Transfers ownership of the contract to a new address

Caller it the owner

Parameters:

Name
Type
Description

new_owner

ContractAddress

The new owner of the contract

renounce_ownership

fn renounce_ownership(ref self: ComponentState<TContractState>)

Leaves the contract without the owner. It will not be possible to call the owner only functions anymore. It can only be called by the current owner.

Parameters:

Name
Type
Description

fee_protocol

u8

New protocol fee

Events

PoolCreated

struct PoolCreated {
    token0: ContractAddress,
    token1: ContractAddress,
    fee: u32,
    tick_spacing: u32,
    pool: ContractAddress
}

Parameters:

Name
Type
Description

token0

ContractAddress

The first token of the pool by address sort order

token1

ContractAddress

The second token of the pool by address sort order

fee

u32

The fee collected upon every swap in the pool, denominated in hundredths of a bip

tick_spacing

u32

The minimum number of ticks between initialized ticks

pool

ContractAddress

The address of the created pool

FeeAmountEnabled

struct FeeAmountEnabled {
    fee: u32,
    tick_spacing: u32
}

Parameters:

Name
Type
Description

fee

u32

The enabled fee, denominated in hundredths of a bip

tick_spacing

u32

The minimum number of ticks between initialized ticks for pools created with the given fee

SetFeeProtocol

struct SetFeeProtocol {
    old_fee_protocol: u8,
    new_fee_protocol: u8
}

Parameters:

Name
Type
Description

old_fee_protocol

u8

The previous value of the protocol fee

new_fee_protocol

u8

The updated value of the protocol fee

OwnershipTransferred

struct OwnershipTransferred {
    previous_owner: ContractAddress,
    new_owner: ContractAddress,
}

Parameters:

Name
Type
Description

previous_owner

ContractAddress

The previous owner of the contract

new_owner

ContractAddress

The new owner of the contract. Can be 0 while renouncing.

ABI

#[starknet::interface]
trait IJediSwapV2Factory<TContractState> {
    fn fee_amount_tick_spacing(self: @TContractState, fee: u32) -> u32;
    fn get_pool(self: @TContractState, token_a: ContractAddress, token_b: ContractAddress, fee: u32) -> ContractAddress;
    fn get_fee_protocol(self: @TContractState) -> u8;
    
    fn create_pool(ref self: TContractState, token_a: ContractAddress, token_b: ContractAddress, fee: u32) -> ContractAddress;
    fn enable_fee_amount(ref self: TContractState, fee: u32, tick_spacing: u32);
    fn set_fee_protocol(ref self: TContractState, fee_protocol: u8);
}

#[starknet::interface]
trait IOwnable<TState> {
    fn owner(self: @TState) -> ContractAddress;
    fn transfer_ownership(ref self: TState, new_owner: ContractAddress);
    fn renounce_ownership(ref self: TState);
}

Emits .

Emits .

Emits .

Emits .

PoolCreated
FeeAmountEnabled
SetFeeProtocol
OwnershipTransferred
OwnershipTransferred