ReplicatingSolver

ChangeOracle

This event is emitted when the Pragma oracle address is changed.

pub struct ChangeOracle {
    pub oracle: ContractAddress,
}

SetMarketParams

This event is emitted when a solver market's parameters are updated by its owner. These market parameters are used to query the relevant oracle price feed from Pragma and transform this price into (virtual) bid and ask liquidity positions, against which incoming swaps are executed.

This file contains the core logic for transforming market parameters into virtual bid and ask positions.

SetMarketParams events should be indexed to track the active market parameters of a solver market and reconstruct the quote price for the solver market.

pub struct SetMarketParams {
    #[key]
    pub market_id: felt252,
    pub min_spread: u32,
    pub range: u32,
    pub max_delta: u32,
    pub max_skew: u16,
    pub base_currency_id: felt252,
    pub quote_currency_id: felt252,
    pub min_sources: u32,
    pub max_age: u64,
}
  • market_id is the unique id of the market (see CreateMarket above)

  • min_spread is the spread, denominated in limits (1.00001 or 0.001% tick) added to the oracle price to arrive at the bid upper or ask lower price

  • range is the range, denominated in limits, of the virtual liquidity position that the swap is executed over (we apply the same calculations as Uniswap liquidity positions). The bid lower price is calculated by as bid_upper - range, and the ask upper price is calculated as ask_lower + range

  • max_delta is a dynamic shift applied to the bid and ask prices in the event of a skew in the composition of the pool (e.g. if the pool is 90% ETH and 10% DAI, the price of ETH will be shifted by skew * max_delta to incentivise swappers to move the pool back to 50/50 ratio)

  • max_skew is a hard cap applied to the skew of the pool, above which swaps are rejected

  • base_currency_id is the Pragma ID of the base token

  • quote_currency_id is the Pragma ID of the quote token

  • min_sources is the minimum number of oracle sources for the oracle price to be considered valid, below which swaps are rejected

  • max_age is the maximum age of the oracle price, above which swaps are rejected

QueueMarketParams

Market parameter updates can be delayed through a queuing mechanism to prevent malicious updates by the contract owner. A set of queued market parameters can only be set after the configured delay (see SetDelay event below).

pub struct QueueMarketParams {
    #[key]
    pub market_id: felt252,
    pub min_spread: u32,
    pub range: u32,
    pub max_delta: u32,
    pub max_skew: u16,
    pub base_currency_id: felt252,
    pub quote_currency_id: felt252,
    pub min_sources: u32,
    pub max_age: u64,
}

SetDelay

Sets the required delay before queued market parameters can be set.

pub struct SetDelay {
    pub delay: u64,
}

Last updated