jediswap_v2_factory

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 PoolCreated.

Parameters:

NameTypeDescription

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:

TypeDescription

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

Emits FeeAmountEnabled.

Parameters:

NameTypeDescription

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

Emits SetFeeProtocol.

Parameters:

NameTypeDescription

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

Emits OwnershipTransferred.

Parameters:

NameTypeDescription

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.

Emits OwnershipTransferred.

Parameters:

NameTypeDescription

fee_protocol

u8

New protocol fee

Events

PoolCreated

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

Parameters:

NameTypeDescription

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:

NameTypeDescription

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:

NameTypeDescription

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:

NameTypeDescription

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

Last updated