diff --git a/lib/dex-invariant/src/invariant_dex.rs b/lib/dex-invariant/src/invariant_dex.rs index d904965..aa4d2b8 100644 --- a/lib/dex-invariant/src/invariant_dex.rs +++ b/lib/dex-invariant/src/invariant_dex.rs @@ -10,10 +10,12 @@ use anchor_spl::{ }; use anyhow::{Context, Ok}; use async_trait::async_trait; +use decimal::*; use invariant_types::{ + decimals::Price, math::{calculate_price_sqrt, get_max_tick, get_min_tick}, structs::{Pool, Tick, Tickmap, TickmapView, TICK_CROSSES_PER_IX, TICK_LIMIT}, - ANCHOR_DISCRIMINATOR_SIZE, TICK_SEED, + ANCHOR_DISCRIMINATOR_SIZE, MAX_SQRT_PRICE, MIN_SQRT_PRICE, TICK_SEED, }; use router_feed_lib::router_rpc_client::{RouterRpcClient, RouterRpcClientTrait}; use router_lib::dex::{ @@ -355,9 +357,9 @@ impl DexInterface for InvariantDex { let x_to_y = id.x_to_y; let sqrt_price_limit = if x_to_y { - calculate_price_sqrt(get_min_tick(edge.pool.tick_spacing)?) + Price::new(MIN_SQRT_PRICE) } else { - calculate_price_sqrt(get_max_tick(edge.pool.tick_spacing)?) + Price::new(MAX_SQRT_PRICE) }; let simulation = edge @@ -431,9 +433,9 @@ impl DexInterface for InvariantDex { let x_to_y = id.x_to_y; let sqrt_price_limit = if x_to_y { - calculate_price_sqrt(get_min_tick(edge.pool.tick_spacing)?) + Price::new(MIN_SQRT_PRICE) } else { - calculate_price_sqrt(get_max_tick(edge.pool.tick_spacing)?) + Price::new(MAX_SQRT_PRICE) }; let simulation = edge diff --git a/lib/dex-invariant/src/invariant_ix_builder.rs b/lib/dex-invariant/src/invariant_ix_builder.rs index 6351642..247658f 100644 --- a/lib/dex-invariant/src/invariant_ix_builder.rs +++ b/lib/dex-invariant/src/invariant_ix_builder.rs @@ -2,7 +2,10 @@ use crate::internal::accounts::{InvariantSwapAccounts, InvariantSwapParams}; use crate::invariant_edge::{InvariantEdge, InvariantEdgeIdentifier, InvariantSimulationParams}; use anchor_spl::associated_token::get_associated_token_address_with_program_id; use anyhow::Context; +use invariant_types::decimals::Price; use invariant_types::math::{get_max_sqrt_price, get_min_sqrt_price}; +use invariant_types::{MAX_SQRT_PRICE, MIN_SQRT_PRICE}; +use decimal::*; use router_lib::dex::{AccountProviderView, DexEdgeIdentifier, SwapInstruction}; use sha2::{Digest, Sha256}; use solana_program::instruction::Instruction; @@ -37,9 +40,9 @@ pub fn build_swap_ix( ); let sqrt_price_limit = if id.x_to_y { - get_min_sqrt_price(edge.pool.tick_spacing)? + Price::new(MIN_SQRT_PRICE) } else { - get_max_sqrt_price(edge.pool.tick_spacing)? + Price::new(MAX_SQRT_PRICE) }; let invariant_swap_result = &edge