Documentation
¶
Index ¶
- type AddMargin
- type AllMarketsRequest
- type AllMarketsResponse
- type BasePriceRequest
- type BasePriceResponse
- type BindingMsg
- type BindingQuery
- type ClosePosition
- type CreateMarket
- type DepthShift
- type DonateToInsuranceFund
- type EditOracleParams
- type InsuranceFundWithdraw
- type LiquidationArgs
- type Market
- type MarketConfig
- type MarketParams
- type Metrics
- type MetricsRequest
- type MetricsResponse
- type ModuleAccountWithBalance
- type ModuleAccountsRequest
- type ModuleAccountsResponse
- type MultiLiquidate
- type OpenPosition
- type PegShift
- type PerpParams
- type PerpParamsRequest
- type PerpParamsResponse
- type Position
- type PositionRequest
- type PositionResponse
- type PositionsRequest
- type PositionsResponse
- type PremiumFractionRequest
- type PremiumFractionResponse
- type RemoveMargin
- type ReservesRequest
- type ReservesResponse
- type SetMarketEnabled
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AllMarketsRequest ¶
type AllMarketsRequest struct {
}
type AllMarketsResponse ¶
type BasePriceRequest ¶
type BasePriceResponse ¶
type BindingMsg ¶
type BindingMsg struct {
// bindings-perp ExecuteMsg enum types
OpenPosition *OpenPosition `json:"open_position,omitempty"`
ClosePosition *ClosePosition `json:"close_position,omitempty"`
//MultiLiquidate *MultiLiquidate `json:"multi_liquidate,omitempty"` // TODO
AddMargin *AddMargin `json:"add_margin,omitempty"`
RemoveMargin *RemoveMargin `json:"remove_margin,omitempty"`
DonateToInsuranceFund *DonateToInsuranceFund `json:"donate_to_insurance_fund,omitempty"` // TODO
InsuranceFundWithdraw *InsuranceFundWithdraw `json:"insurance_fund_withdraw,omitempty"`
PegShift *PegShift `json:"peg_shift,omitempty"`
DepthShift *DepthShift `json:"depth_shift,omitempty"`
SetMarketEnabled *SetMarketEnabled `json:"set_market_enabled,omitempty"`
CreateMarket *CreateMarket `json:"create_market,omitempty"`
EditOracleParams *EditOracleParams `json:"edit_oracle_params,omitempty"`
}
BindingMsg corresponds to the 'ExecuteMsg' enum in the CosmWasm binding contracts (Rust). It specifies which wasm execute messages can be called with Nibiru bindings and specifies the JSON schema that connects app ⇔ Wasm.
type BindingQuery ¶
type BindingQuery struct {
// bindings-perp NibiruQuery enum types
Reserves *ReservesRequest `json:"reserves,omitempty"`
AllMarkets *AllMarketsRequest `json:"all_markets,omitempty"`
BasePrice *BasePriceRequest `json:"base_price,omitempty"`
Positions *PositionsRequest `json:"positions,omitempty"`
Position *PositionRequest `json:"position,omitempty"`
PremiumFraction *PremiumFractionRequest `json:"premium_fraction,omitempty"`
Metrics *MetricsRequest `json:"metrics,omitempty"`
ModuleAccounts *ModuleAccountsRequest `json:"module_accounts,omitempty"`
PerpParams *PerpParamsRequest `json:"module_params,omitempty"`
}
BindingQuery corresponds to the NibiruQuery enum in CosmWasm binding contracts (Rust). It specifies which queries can be called with Nibiru bindings and specifies the JSON schema that connects app ⇔ Wasm.
### Note
- The JSON field names must match the ones on the smart contract
- You use a pointer so that each field can be nil, which will be missing in the input or output json. What's actually sent from the contract will be an instance of the parent type, but the message body will be on one of these nullable fields. This is part of the reason we need the "omitempty" struct tags
type ClosePosition ¶
type ClosePosition struct {
Pair string `json:"pair"`
}
type CreateMarket ¶
type DepthShift ¶
type DonateToInsuranceFund ¶
type EditOracleParams ¶
type EditOracleParams struct {
VotePeriod *sdkmath.Int `json:"vote_period,omitempty"`
VoteThreshold *sdk.Dec `json:"vote_threshold,omitempty"`
RewardBand *sdk.Dec `json:"reward_band,omitempty"`
Whitelist []string `json:"whitelist,omitempty"`
SlashFraction *sdk.Dec `json:"slash_fraction,omitempty"`
SlashWindow *sdkmath.Int `json:"slash_window,omitempty"`
MinValidPerWindow *sdk.Dec `json:"min_valid_per_window,omitempty"`
TwapLookbackWindow *sdkmath.Int `json:"twap_lookback_window,omitempty"`
MinVoters *sdkmath.Int `json:"min_voters,omitempty"`
ValidatorFeeRatio *sdk.Dec `json:"validator_fee_ratio,omitempty"`
}
type InsuranceFundWithdraw ¶
type LiquidationArgs ¶
type Market ¶
type Market struct {
Pair string `json:"pair"`
BaseReserve sdk.Dec `json:"base_reserve"`
QuoteReserve sdk.Dec `json:"quote_reserve"`
SqrtDepth sdk.Dec `json:"sqrt_depth"`
Depth sdkmath.Int `json:"depth"`
TotalLong sdk.Dec `json:"total_long"`
TotalShort sdk.Dec `json:"total_short"`
PegMult sdk.Dec `json:"peg_mult"`
Config *MarketConfig `json:"config,omitempty"`
MarkPrice sdk.Dec `json:"mark_price"`
IndexPrice string `json:"index_price"`
TwapMark string `json:"twap_mark"`
BlockNumber sdkmath.Int `json:"block_number"`
}
func NewMarket ¶
func NewMarket(appMarket perpv2types.Market, appAmm perpv2types.AMM, indexPrice, twapMark string, blockNumber int64) Market
func (Market) ToAppMarket ¶
func (m Market) ToAppMarket() (appMarket perpv2types.Market, err error)
Converts the JSON market, which comes in from Rust, to its corresponding protobuf (Golang) type in the app: perpv2types.Market.
type MarketConfig ¶
type MarketParams ¶
type MarketParams struct {
Pair string
Enabled bool `json:"enabled,omitempty"`
// the minimum margin ratio which a user must maintain on this market
MaintenanceMarginRatio sdk.Dec `json:"maintenance_margin_ratio"`
// the maximum leverage a user is able to be taken on this market
MaxLeverage sdk.Dec `json:"max_leverage"`
// Latest cumulative premium fraction for a given pair.
// Calculated once per funding rate interval.
// A premium fraction is the difference between mark and index, divided by the
// number of payments per day. (mark - index) / # payments in a day
LatestCumulativePremiumFraction sdk.Dec `json:"latest_cumulative_premium_fraction"`
// the percentage of the notional given to the exchange when trading
ExchangeFeeRatio sdk.Dec `json:"exchange_fee_ratio"`
// the percentage of the notional transferred to the ecosystem fund when
// trading
EcosystemFundFeeRatio sdk.Dec `json:"ecosystem_fund_fee_ratio"`
// the percentage of liquidated position that will be
// given to out as a reward. Half of the liquidation fee is given to the
// liquidator, and the other half is given to the ecosystem fund.
LiquidationFeeRatio sdk.Dec `json:"liquidation_fee_ratio"`
// the portion of the position size we try to liquidate if the available
// margin is higher than liquidation fee
PartialLiquidationRatio sdk.Dec `json:"partial_liquidation_ratio"`
// specifies the interval on which the funding rate is updated
FundingRateEpochId string `json:"funding_rate_epoch_id,omitempty"`
// amount of time to look back for TWAP calculations
TwapLookbackWindow sdkmath.Int `json:"twap_lookback_window"`
}
type MetricsRequest ¶
type MetricsRequest struct {
Pair string `json:"pair"`
}
type MetricsResponse ¶
type MetricsResponse struct {
Metrics Metrics `json:"metrics"`
}
type ModuleAccountWithBalance ¶
type ModuleAccountWithBalance struct {
Name string `json:"name"`
Addr sdk.AccAddress `json:"addr"`
Balance []sdk.Coin `json:"balance"`
}
type ModuleAccountsRequest ¶
type ModuleAccountsRequest struct {
}
type ModuleAccountsResponse ¶
type ModuleAccountsResponse struct {
ModuleAccounts map[string]ModuleAccountWithBalance `json:"module_accounts"`
}
type MultiLiquidate ¶
type MultiLiquidate struct {
Liquidations []LiquidationArgs `json:"liquidations"`
}
type OpenPosition ¶
type PerpParams ¶
type PerpParams struct {
Stopped bool `json:"stopped"`
FeePoolFeeRatio sdkmath.LegacyDec `json:"fee_pool_fee_ratio"`
EcosystemFundFeeRatio sdkmath.LegacyDec `json:"ecosystem_fund_fee_ratio"`
LiquidationFeeRatio sdkmath.LegacyDec `json:"liquidation_fee_ratio"`
PartialLiquidationRatio sdkmath.LegacyDec `json:"partial_liquidation_ratio"`
FundingRateInterval string `json:"funding_rate_interval"`
TwapLookbackWindow sdkmath.Int `json:"twap_lookback_window"`
WhitelistedLiquidators []string `json:"whitelisted_liquidators"`
}
type PerpParamsRequest ¶
type PerpParamsRequest struct {
}
type PerpParamsResponse ¶
type PerpParamsResponse struct {
ModuleParams PerpParams `json:"module_params"`
}
type PositionRequest ¶
type PositionResponse ¶
type PositionsRequest ¶
type PositionsRequest struct {
Trader string `json:"trader"`
}
type PositionsResponse ¶
type PremiumFractionRequest ¶
type PremiumFractionRequest struct {
Pair string `json:"pair"`
}
type PremiumFractionResponse ¶
type RemoveMargin ¶
type ReservesRequest ¶
type ReservesRequest struct {
Pair string `json:"pair"`
}
type ReservesResponse ¶
type SetMarketEnabled ¶
Click to show internal directories.
Click to hide internal directories.