Skip to main content

TestExchange

Struct TestExchange 

Source
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: Converter

Implementations§

Source§

impl TestExchange

Source

pub async fn new() -> Self

Spins up the environment running the exchange implementation the SDK targets (state::Exchange::revision).

Source

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.

Source

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.

Source

pub fn chain(&self) -> Chain

Source

pub fn chain_with_perpetual_discovery(&self) -> Chain

Same chain with no perpetual contracts configured, so clients discover every listed contract on-chain instead.

Source

pub async fn account(&self, idx: usize, usd_balance: u64) -> TestAccount<'_>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn btc_perp(&self) -> TestPerp<'_>

Source

pub async fn eth_perp(&self) -> TestPerp<'_>

Source

pub async fn sol_perp(&self) -> TestPerp<'_>

Source

pub async fn trx_perp(&self) -> TestPerp<'_>

Trait Implementations§

Source§

impl Debug for TestExchange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more