Module levana_perpswap_cosmos_msg::prelude
source · Expand description
Convenience prelude module.
This reexports commonly used identifiers for use by contracts and tools.
Re-exports
pub use crate::contracts::factory::entry::ExecuteMsg as FactoryExecuteMsg;
pub use crate::contracts::factory::entry::QueryMsg as FactoryQueryMsg;
pub use crate::contracts::market::entry::ExecuteMsg as MarketExecuteMsg;
pub use crate::contracts::market::entry::QueryMsg as MarketQueryMsg;
Modules
- This is a centralized location for cw_storage Item storage keys and Map namespaces
- Provides specialized types that define a ratio that must be within a specific range. This can be helpful when defining an interface that contains a ratio represented by a decimal but the ratio is logically constrained by specific bounds.
Macros
- Construct an ad-hoc error from a string or existing non-
anyhow
error value. - Makes it easy to create a Response where all the values are attributes, like a HashMap.
- Return early with an error.
- This version only logs if the given flag is in DEBUG_LOG_FLAGS (will not log if log_print feature is disabled, in that case it’s a no-op)
- This version will always log (except if log_print feature is not enabled, it’s a no-op)
- Generate a PerpError and then wrap it up in an anyhow error
- Like perp_anyhow but accepts optional extra data
- Return early with the given perp error
- Like perp_bail but takes extra optional data
- Ensure a condition is true, otherwise returns from the function with an error.
- Generate a PerpError value
- Generate a PerpError value with additional optional data
Structs
- A human readable address.
- Unsigned value
- Unsigned value
- A fixed-point decimal value with 18 fractional digits, i.e. Decimal256(1_000_000_000_000_000_000) == 1.0
- A duration of time measured in nanoseconds
- A full Cosmos SDK event.
- Unsigned value
- Item stores one typed item at the given key. This is an analog of Singleton. It functions the same way as Path does but doesn’t use a Vec and thus has a const fn constructor.
- The absolute leverage for a position, in terms of the base asset.
- Unsigned value
- Unsigned value
- Unsigned value
- An identifier for a market.
- Ensure that the inner value is never 0.
- Unsigned value
- An error message for the perps protocol
- The price of the pair as used internally by the protocol, given as
collateral / notional
. - The price of the currency pair, given as
quote / base
, e.g. “20,000 USD per BTC”. - PriceBaseInQuote converted to USD
- A modified version of a Price used as a key in a
Map
. - All prices in the protocol for a given point in time.
- Unsigned value
- A raw address passed in via JSON.
- Helper data type, following builder pattern, for constructing a [Response].
- Wrap up any UnsignedDecimal to provide negative values too.
- The user-specified leverage for a position, with direction expressed as the signed value
- Leverage calculated based on the protocol’s internal representation.
- Essentially a newtype wrapper for Timestamp providing additional impls.
- A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
- Unsigned value
Enums
- Check that an addr satisfies auth checks
Bound
is used to define the two ends of a range.None
means that we don’t limit that side of the range at all.Inclusive
means we use the given value as a limit and include anything at that exact key.Exclusive
means we use the given value as a limit and exclude anything at that exact key.- What was the user doing when they hit the congestion error message?
- Flags for gating debug_log
- Direction in terms of base
- Direction in terms of notional
- Source within the protocol for the error
- Unique identifier for an error within perps
- An error type for known market errors with potentially special error handling.
- Whether the collateral asset is the same as the quote or base asset.
- The max gains for a position.
- Like cosmwasm_std::Order but serialized as a string and with a schema export
- The take profit price for a position, as supplied by client messsages (in terms of BaseInQuote).
- Was the price provided by the trader too high or too low?
- What type of price trigger occurred?
Constants
- useful for placing an upper cap on query iterators as a safety measure to prevent exhausting resources on nodes that allow unbounded query gas
Traits
- Api are callbacks to system functions implemented outside of the wasm modules. Currently it just supports address conversion but we could add eg. crypto functions here.
- Provides the
context
method forResult
. - Extension trait to add methods to native cosmwasm events
- Format trait for an empty format,
{}
. - Parse a value from a string
- Makes it easy to call .query_result() on any Serialize and standardizes so query() entry points also return a ContractResult
- Storage provides read and write access to a persistent storage. If you only want to provide read access, provide
&Storage
- Generalizes any newtype wrapper around a Decimal256.
Functions
- Ensure that the given address passes the specified AuthCheck.
- Check if a cw_storage_plus::Map in an external contract has a specific key
- Extract contract address from an instantiation event
- get_contract_version can be use in migrate to read the previous version of this contract
- Load an cw_storage_plus::Item stored in an external contract
- Load a value from a cw_storage_plus::Map stored in an external contract
- Make a smart query, but do not parse the binary results as JSON.
Type Aliases
- A signed number type with high fidelity.
- A special case of NonZero which stores a big endian array of data.
Result<T, Error>