SolverComponent

The following events are shared across all Solver implementations, which inherit from SolverComponent.

CreateMarket

This event is emitted when a new pool / market is created. Markets are identified by market_id.CreateMarket events should be indexed to track the active markets in a solver.

pub struct CreateMarket {
    #[key]
    pub market_id: felt252,
    pub base_token: ContractAddress,
    pub quote_token: ContractAddress,
    pub owner: ContractAddress,
    pub is_public: bool,
    pub vault_token: ContractAddress,
}
  • market_id is the Poseidon chain hash of the market parameters below (base_token, quote_token, owner, is_public, vault_token)

  • base_token is the address of the base token for the market

  • quote_token is the address of the quote token for the market

  • owner is the address of the market owner

  • is_public is a boolean indicating if the market is open to third party LPs / depositors

  • vault_token is the address of the token used to track LP shares in the market

Swap

This event is emitted when a swap is executed through a solver market. These events can be indexed along with Deposit and Withdraw events to track the total liquidity in a solver market.

pub struct Swap {
  #[key]
  pub market_id: felt252,
  #[key]
  pub caller: ContractAddress,
  pub is_buy: bool,
  pub exact_input: bool,
  pub amount_in: u256,
  pub amount_out: u256,
}
  • market_id is the unique id of the market (see CreateMarket above)

  • caller is the address of the user executing the swap

  • is_buy is a boolean indicating if the swap is a buy or sell

  • exact_input is a boolean indicating if the swap amount was specified as input or output

  • amount_in is the amount of the input token swapped in

  • amount_out is the amount of the output token swapped out

Deposit / Withdraw

These events are emitted whenever a user / LP deposits or withdraws liquidity from a solver market. These events can be indexed along with Swap events to track the total liquidity in a solver market.

pub struct Deposit {
    #[key]
    pub caller: ContractAddress,
    #[key]
    pub market_id: felt252,
    pub base_amount: u256,
    pub quote_amount: u256,
    pub shares: u256,
}

pub struct Withdraw {
    #[key]
    pub caller: ContractAddress,
    #[key]
    pub market_id: felt252,
    pub base_amount: u256,
    pub quote_amount: u256,
    pub shares: u256,
}
  • caller is the address of the user / LP depositing liquidity

  • market_id is the unique id of the market (see CreateMarket above)

  • base_amount is the amount of base tokens deposited

  • quote_amount is the amount of quote tokens deposited

  • shares is the amount of LP shares minted or burned

Pause / Unpause

These events are emitted when a market is paused and unpaused. Paused markets should not accrue rewards as they will reject incoming swaps. These events can be indexed to track the paused state of solver markets.

pub struct Pause {
    #[key]
    pub market_id: felt252,
}

pub struct Unpause {
    #[key]
    pub market_id: felt252,
}

Last updated