pub struct TestExchange {
pub chain_id: u64,
pub rpc_url: String,
pub provider: DynProvider,
pub exchange: ExchangeInstance<DynProvider>,
pub token: TestTokenInstance<DynProvider>,
pub owner: Address,
pub owner_pk: String,
pub admin: Address,
pub admin_pk: String,
pub price_admin: Address,
pub price_admin_pk: String,
pub collateral_converter: Converter,
/* private fields */
}Fields§
§chain_id: u64§rpc_url: String§provider: DynProvider§exchange: ExchangeInstance<DynProvider>§token: TestTokenInstance<DynProvider>§owner: Address§owner_pk: String§admin: Address§admin_pk: String§price_admin: Address§price_admin_pk: String§collateral_converter: ConverterImplementations§
Source§impl TestExchange
impl TestExchange
Sourcepub async fn new() -> Self
pub async fn new() -> Self
Spins up the environment running the exchange implementation the SDK
targets (state::Exchange::revision).
Sourcepub async fn new_at_previous_version() -> Self
pub async fn new_at_previous_version() -> Self
Spins up the environment running the previous contract generation (v1.1.7.3b: V2 information getters, but no version getter, keyed fee schedules, builder attribution or existence bitmap) - the generation deployed on mainnet before the v1.1.7.4 upgrade.
Use with Self::upgrade to exercise the SDK across the upgrade
itself.
Sourcepub async fn upgrade(&self, taker_fees: [UD64; 8], maker_fees: [UD64; 8])
pub async fn upgrade(&self, taker_fees: [UD64; 8], maker_fees: [UD64; 8])
Upgrades the proxy to the implementation the SDK targets, seeding the exchange-wide fee schedules and repointing every listed perpetual contract at the default one.
Runs initializeV3 in the upgrade transaction, exactly as the real
upgrade does, so the log sequence a live indexer observes is the real
one.
pub fn chain(&self) -> Chain
Sourcepub fn chain_with_perpetual_discovery(&self) -> Chain
pub fn chain_with_perpetual_discovery(&self) -> Chain
Same chain with no perpetual contracts configured, so clients discover every listed contract on-chain instead.
pub async fn account(&self, idx: usize, usd_balance: u64) -> TestAccount<'_>
Sourcepub async fn set_fee_schedule(
&self,
taker_fees: [UD64; 8],
maker_fees: [UD64; 8],
)
pub async fn set_fee_schedule( &self, taker_fees: [UD64; 8], maker_fees: [UD64; 8], )
Sets the exchange-wide default fee schedule, eight (taker, maker)
rates indexed by an account’s fee tier. Every perpetual contract
that has not been repointed resolves its fees from this schedule.
Sourcepub async fn set_rwa_fee_schedule(
&self,
taker_fees: [UD64; 8],
maker_fees: [UD64; 8],
)
pub async fn set_rwa_fee_schedule( &self, taker_fees: [UD64; 8], maker_fees: [UD64; 8], )
Sets the exchange-wide RWA default fee schedule, see
Self::set_fee_schedule.
Sourcepub async fn set_account_fee_tiers(&self, tiers: Vec<(AccountId, FeeTier)>)
pub async fn set_account_fee_tiers(&self, tiers: Vec<(AccountId, FeeTier)>)
Assigns fee tiers to accounts, indexing the fee schedule of every perpetual contract they trade.
Sourcepub async fn perp(
&self,
name: &str,
perp_id: PerpetualId,
base_price: UD64,
price_decimals: u8,
size_decimals: u8,
initial_margin: UD64,
maintenance_margin: UD64,
) -> TestPerp<'_>
pub async fn perp( &self, name: &str, perp_id: PerpetualId, base_price: UD64, price_decimals: u8, size_decimals: u8, initial_margin: UD64, maintenance_margin: UD64, ) -> TestPerp<'_>
Adds a perpetual contract, placed on the exchange-wide default fee schedule.
Fees are not a listing parameter: the schedule is seeded once at
deployment, and addContract retains its fee arguments for ABI
stability while ignoring them (v1.1.7.4). Use
Self::set_fee_schedule to retune the shared schedule, or
TestPerp::set_fee_schedule to give this contract its own.
pub async fn btc_perp(&self) -> TestPerp<'_>
pub async fn eth_perp(&self) -> TestPerp<'_>
pub async fn sol_perp(&self) -> TestPerp<'_>
pub async fn trx_perp(&self) -> TestPerp<'_>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for TestExchange
impl !RefUnwindSafe for TestExchange
impl !UnwindSafe for TestExchange
impl Send for TestExchange
impl Sync for TestExchange
impl Unpin for TestExchange
impl UnsafeUnpin for TestExchange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more