Struct levana_perpswap_cosmos::contracts::market::config::Config

source ·
pub struct Config {
Show 35 fields pub trading_fee_notional_size: Decimal256, pub trading_fee_counter_collateral: Decimal256, pub crank_execs: u32, pub max_leverage: Number, pub funding_rate_sensitivity: Decimal256, pub funding_rate_max_annualized: Decimal256, pub borrow_fee_rate_min_annualized: NumberGtZero, pub borrow_fee_rate_max_annualized: NumberGtZero, pub carry_leverage: Decimal256, pub mute_events: bool, pub liquifunding_delay_seconds: u32, pub protocol_tax: Decimal256, pub unstake_period_seconds: u32, pub target_utilization: NonZero<Decimal256>, pub borrow_fee_sensitivity: NumberGtZero, pub max_xlp_rewards_multiplier: NumberGtZero, pub min_xlp_rewards_multiplier: NumberGtZero, pub delta_neutrality_fee_sensitivity: NumberGtZero, pub delta_neutrality_fee_cap: NumberGtZero, pub delta_neutrality_fee_tax: Decimal256, pub crank_fee_charged: Usd, pub crank_fee_surcharge: Usd, pub crank_fee_reward: Usd, pub minimum_deposit_usd: Usd, pub liquifunding_delay_fuzz_seconds: u32, pub max_liquidity: MaxLiquidity, pub disable_position_nft_exec: bool, pub liquidity_cooldown_seconds: u32, pub exposure_margin_ratio: Decimal256, pub referral_reward_ratio: Decimal256, pub spot_price: SpotPriceConfig, pub _unused1: Option<u32>, pub _unused2: Option<u32>, pub _unused3: Option<Collateral>, pub _unused4: Option<u32>,
}
Expand description

Configuration info for the vAMM Set by admin-only Since this tends to cross the message boundary all the numeric types are u32 or lower helper functions are available where more bits are needed

Fields§

§trading_fee_notional_size: Decimal256

The fee to open a position, as a percentage of the notional size

§trading_fee_counter_collateral: Decimal256

The fee to open a position, as a percentage of the counter-side collateral

§crank_execs: u32

default number of crank exeuctions to do when none specified

§max_leverage: Number

The maximum allowed leverage when opening a position

§funding_rate_sensitivity: Decimal256

Impacts how much the funding rate changes in response to net notional changes.

§funding_rate_max_annualized: Decimal256

The maximum annualized rate for a funding payment

§borrow_fee_rate_min_annualized: NumberGtZero

The minimum annualized rate for borrow fee payments

§borrow_fee_rate_max_annualized: NumberGtZero

The maximum annualized rate for borrow fee payments

§carry_leverage: Decimal256

Needed to ensure financial model is balanced

Must be at most 1 less than the Config::max_leverage

§mute_events: bool

Do not emit events (default is false, events will be emitted)

§liquifunding_delay_seconds: u32

Delay between liquifundings, in seconds

§protocol_tax: Decimal256

The percentage of fees that are taken for the protocol

§unstake_period_seconds: u32

How long it takes to unstake xLP tokens into LP tokens, in seconds

§target_utilization: NonZero<Decimal256>

Target utilization ratio liquidity, given as a ratio. (Must be between 0 and 1).

§borrow_fee_sensitivity: NumberGtZero

Borrow fee sensitivity parameter.

See section 5.5 of the whitepaper.

§max_xlp_rewards_multiplier: NumberGtZero

Maximum multiplier for xLP versus LP borrow fee shares.

For example, if this number is 5, then as liquidity in the protocol approaches 100% in LP and 0% in xLP, any xLP token will receive 5x the rewards of an LP token.

§min_xlp_rewards_multiplier: NumberGtZero

Minimum counterpoint to Config::max_xlp_rewards_multiplier

§delta_neutrality_fee_sensitivity: NumberGtZero

Delta neutrality fee sensitivity parameter.

Higher values indicate markets with greater depth of liquidity, and allow for larger divergence for delta neutrality in the markets.

This value is specified in the notional asset.

§delta_neutrality_fee_cap: NumberGtZero

Delta neutrality fee cap parameter, given as a percentage

§delta_neutrality_fee_tax: Decimal256

Proportion of delta neutrality inflows that are sent to the protocol.

§crank_fee_charged: Usd

The crank fee to be paid into the system, in collateral

§crank_fee_surcharge: Usd

The crank surcharge charged for every 10 items in the deferred execution queue.

This is intended to create backpressure in times of high congestion.

For every 10 items in the deferred execution queue, this amount is added to the crank fee charged on performing a deferred execution message.

This is only charged while adding new items to the queue, not when performing ongoing tasks like liquifunding or liquidations.

§crank_fee_reward: Usd

The crank fee to be sent to crankers, in collateral

§minimum_deposit_usd: Usd

Minimum deposit collateral, given in USD

§liquifunding_delay_fuzz_seconds: u32

The liquifunding delay fuzz factor, in seconds.

Up to how many seconds will we perform a liquifunding early. This will be part of a semi-randomly generated value and will allow us to schedule liquifundings arbitrarily to smooth out spikes in traffic.

§max_liquidity: MaxLiquidity

The maximum amount of liquidity that can be deposited into the market.

§disable_position_nft_exec: bool

Disable the ability to proxy CW721 execution messages for positions. Even if this is true, queries will still work as usual.

§liquidity_cooldown_seconds: u32

The liquidity cooldown period.

After depositing new funds into the market, liquidity providers will have a period of time where they cannot withdraw their funds. This is intended to prevent an MEV attack where someone can reorder transactions to extract fees from traders without taking on any impairment risk.

This protection is only triggered by deposit of new funds; reinvesting existing yield does not introduce a cooldown.

While the cooldown is in place, providers are prevented from either withdrawing liquidity or transferring their LP and xLP tokens.

For migration purposes, this value defaults to 0, meaning no cooldown period.

§exposure_margin_ratio: Decimal256

Ratio of notional size used for the exposure component of the liquidation margin.

§referral_reward_ratio: Decimal256

Portion of trading fees given as rewards to referrers.

§spot_price: SpotPriceConfig

The spot price config for this market

§_unused1: Option<u32>

Just for historical reasons/migrations

§_unused2: Option<u32>

Just for historical reasons/migrations

§_unused3: Option<Collateral>

Just for historical reasons/migrations

§_unused4: Option<u32>

Just for historical reasons/migrations

Implementations§

source§

impl Config

source

pub fn new(spot_price: SpotPriceConfig) -> Self

create a new config with default values and a given spot price config

source

pub fn validate(&self) -> Result<()>

Ensure that the settings within this Config are valid.

source§

impl Config

source

pub fn calculate_trade_fee( &self, old_notional_size_in_collateral: Signed<Collateral>, new_notional_size_in_collateral: Signed<Collateral>, old_counter_collateral: Collateral, new_counter_collateral: Collateral, ) -> Result<Collateral>

Calculate the trade fee based on the given old and new position parameters.

When opening a new position, you can use Config::calculate_trade_fee_open.

source

pub fn calculate_trade_fee_open( &self, notional_size_in_collateral: Signed<Collateral>, counter_collateral: Collateral, ) -> Result<Collateral>

Same as Config::calculate_trade_fee but for opening a new position.

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Config

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<Config> for ConfigUpdate

source§

fn from(src: Config) -> Self

Converts to this type from the input type.
source§

impl JsonSchema for Config

source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
source§

impl PartialEq for Config

source§

fn eq(&self, other: &Config) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Config

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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
§

impl<U> As for U

§

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

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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> QueryResultExt for T
where T: Serialize,

source§

fn query_result(&self) -> Result<Binary, Error>

Convert the value to its JSON representation
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
§

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

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,