ReplicatingSolver
ChangeOracle
ChangeOracleThis event is emitted when the Pragma oracle address is changed.
pub struct ChangeOracle {
pub oracle: ContractAddress,
}SetMarketParams
SetMarketParamsThis 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_idis the unique id of the market (seeCreateMarketabove)min_spreadis 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 pricerangeis 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 asbid_upper - range, and the ask upper price is calculated asask_lower + rangemax_deltais 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 byskew * max_deltato incentivise swappers to move the pool back to 50/50 ratio)max_skewis a hard cap applied to the skew of the pool, above which swaps are rejectedbase_currency_idis the Pragma ID of the base tokenquote_currency_idis the Pragma ID of the quote tokenmin_sourcesis the minimum number of oracle sources for the oracle price to be considered valid, below which swaps are rejectedmax_ageis the maximum age of the oracle price, above which swaps are rejected
QueueMarketParams
QueueMarketParamsMarket 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
SetDelaySets the required delay before queued market parameters can be set.
pub struct SetDelay {
pub delay: u64,
}Last updated