types

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2025 License: Apache-2.0, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SdkIntDecodeHook

func SdkIntDecodeHook(from reflect.Type, to reflect.Type, data interface{}) (interface{}, error)

DecodeHook for SdkInt

func ValidateConfig

func ValidateConfig(cfg Config) error

ValidateConfig checks if the configuration is valid.

Types

type AstroportConfig

type AstroportConfig struct {
	ContractAddress string `json:"contract_address" mapstructure:"contract_address"`
	OfferAsset      string `json:"offer_asset" mapstructure:"offer_asset"`
	AskAsset        string `json:"ask_asset" mapstructure:"ask_asset"`
	Exponent        int    `json:"exponent" mapstructure:"exponent"`
	PoolType        string `json:"pool_type mapstructure:pooltype"`
}

type BinanceConfig

type BinanceConfig struct {
	APIKey    string `toml:"binance_api_key" mapstructure:"binance_api_key"`
	SecretKey string `toml:"binance_secret_key" mapstructure:"binance_secret_key"`
	Symbol    string `toml:"symbol" mapstructure:"symbol"`
	Token0    string `toml:"token0" mapstructure:"token0"` // Token0 is the base token in the pair
	Token1    string `toml:"token1" mapstructure:"token1"` // Token1 is the quote token in the pair
}

type Chain

type Chain struct {
	Prefix            string   `toml:"prefix" mapstructure:"prefix"`
	ChainID           string   `toml:"chain_id" mapstructure:"chain_id"`
	Fees              *string  `toml:"fees" mapstructure:"fees"`
	Gas               *string  `toml:"gas" mapstructure:"gas"`
	GasAdjustment     *float64 `toml:"gas_adjustment" mapstructure:"gas_adjustment"`
	GasPrices         *string  `toml:"gas_prices" mapstructure:"gas_prices"`
	GasDenom          string   `toml:"gas_denom" mapstructure:"gas_denom"`
	GRPCServerAddress string   `toml:"grpc_server_address" mapstructure:"grpc_server_address"`
	GRPCTLS           bool     `toml:"grpc_tls" mapstructure:"grpc_tls"`
	RPCServerAddress  string   `toml:"rpc_server_address" mapstructure:"rpc_server_address"`
}

type CoinGeckoConfig

type CoinGeckoConfig struct {
	URL      string `toml:"coingecko_url" mapstructure:"coingecko_url"`         // URL for the CoinGecko API
	APIKey   string `toml:"coingecko_api_key" mapstructure:"coingecko_api_key"` // Coingecko API key
	TokenID0 string `toml:"token_id_0" mapstructure:"token_id_0"`               // Base token
	TokenID1 string `toml:"token_id_1" mapstructure:"token_id_1"`               // Quote token
	Currency string `toml:"currency" mapstructure:"currency"`                   // Currency to show the price in
}

type CoinHedgeStrategyConfig

type CoinHedgeStrategyConfig struct {
	Kill              bool         `toml:"kill" mapstructure:"kill"`                   // will kill the strategy, not for production use
	FundContract      string       `toml:"fund_contract" mapstructure:"fund_contract"` // Fund contract address, if not prop trading
	ChainID           string       `toml:"chain_id" mapstructure:"chain_id"`
	Name              string       `toml:"name" mapstructure:"name"` // some human intelligible name for the strategy, e.g. "ATOM Hedge Hydro"
	ExecutionInterval int          `toml:"execution_interval" mapstructure:"execution_interval"`
	PerpDex           PerpDex      `toml:"perp_dex" mapstructure:"perp_dex"`
	Hedge             HedgeConfig  `toml:"hedge_config" mapstructure:"hedge_config"`
	Skip              SkipConfig   `toml:"skip_config" mapstructure:"skip_config"`
	Slinky            SlinkyConfig `toml:"slinky_config" mapstructure:"slinky_config"`
	DB                DBConfig     `toml:"db_config" mapstructure:"db_config"`

	// Vault contracts
	Vault LocustVault `toml:"vault" mapstructure:"vault"`

	// Eventually I think we should just have a single chain config and then a list of chains
	Neutron Chain `toml:"neutron" mapstructure:"neutron"`
	Dydx    Chain `toml:"dydx" mapstructure:"dydx"`
	Noble   Chain `toml:"noble" mapstructure:"noble"`
}

type Config

type Config struct {
	Chain         Chain            `toml:"chain"`
	Key           SigningKey       `toml:"key"`
	Memo          string           `toml:"memo"`
	WebsocketPath string           `toml:"websocket_path"`
	SignerAccount string           `toml:"signer_account"`
	Strategies    []StrategyConfig `toml:"strategy"`
	TxRetryCount  int              `toml:"tx_retry_count"`
	TxRetryDelay  time.Duration    `toml:"tx_retry_delay_ms"`
	DryRun        bool             `toml:"dry_run"`
	PropTrade     bool             `toml:"prop_trade"`
}

type DBConfig

type DBConfig struct {
	Dsn string `json:"dsn" mapstructure:"dsn"` // database connection details
}

type DexArbitrageStrategyConfig

type DexArbitrageStrategyConfig struct {
	Granter       string          `toml:"granter" mapstructure:"granter"`
	Frequency     int             `toml:"frequency" mapstructure:"frequency"`
	MinTradeSize  SdkInt          `toml:"min_trade_size" mapstructure:"min_trade_size"`
	Slippage      float64         `toml:"slippage" mapstructure:"slippage"`
	ArbThreshold  float64         `toml:"arb_threshold" mapstructure:"arb_threshold"`
	AstroportBuy  AstroportConfig `toml:"astroport_buy" mapstructure:"astroport_buy"`
	AstroportSell AstroportConfig `toml:"astroport_sell" mapstructure:"astroport_sell"`
	DexBuy        DexConfig       `toml:"dex_buy" mapstructure:"dex_buy"`
	DexSell       DexConfig       `toml:"dex_sell" mapstructure:"dex_sell"`
}

type DexConfig

type DexConfig struct {
	TokenIn  string `json:"token_in" mapstructure:"token_in"`
	TokenOut string `json:"token_out" mapstructure:"token_out"`
}

func (*DexConfig) GetPairID

func (p *DexConfig) GetPairID() string

type Drop

type Drop struct {
	Chain Chain      `toml:"chain" mapstructure:"chain"`
	Info  UnbondDrop `toml:"info" mapstructure:"info"`
}

type DropConfig

type DropConfig struct {
	CoreContractAddress              string `json:"core_contract_address" mapstructure:"core_contract_address"`
	WithdrawalVoucherContractAddress string `json:"withdrawal_voucher_contract_address" mapstructure:"withdrawal_voucher_contract_address"`
	WithdrawalManagerContractAddress string `json:"withdrawal_manager_contract_address" mapstructure:"withdrawal_manager_contract_address"`
}

type DropRedemptionStrategyConfig

type DropRedemptionStrategyConfig struct {
	Granter          string          `toml:"granter" mapstructure:"granter"`
	FundContract     string          `toml:"fund_contract" mapstructure:"fund_contract"`
	StrategyContract string          `toml:"strategy_contract" mapstructure:"strategy_contract"`
	Frequency        int             `toml:"frequency" mapstructure:"frequency"`
	Jitter           int             `toml:"jitter" mapstructure:"jitter"`
	Astroport        AstroportConfig `toml:"astroport" mapstructure:"astroport"`
	Drop             DropConfig      `toml:"drop" mapstructure:"drop"`
	DryRun           bool            `toml:"dry_run" mapstructure:"dry_run"`
	PropTrade        bool            `toml:"prop_trade" mapstructure:"prop_trade"`
	ArbThreshold     float64         `toml:"arb_threshold" mapstructure:"arb_threshold"`
	MinBuySize       SdkInt          `toml:"min_buy_size" mapstructure:"min_buy_size"`
}

type DydxConfig

type DydxConfig struct {
	Market               string `json:"market" mapstructure:"market"`
	IndexerURL           string `json:"indexer_url" mapstructure:"indexer_url"`
	MarketID             uint32 `json:"market_id" mapstructure:"market_id"`
	SubaccountID         uint32 `json:"subaccount_id" mapstructure:"subaccount_id"`
	QuantumConversionExp int64  `json:"quantum_conversion_exp" mapstructure:"quantum_conversion_exp"`
	SubticksPerTick      uint64 `json:"subticks_per_tick" mapstructure:"subticks_per_tick"`
	StepBaseQuantums     uint64 `json:"step_base" mapstructure:"step_base_quantums"`
	AtomicResolution     int64  `json:"atomic_resolution" mapstructure:"atomic_resolution"`
	Denom                string `json:"denom" mapstructure:"denom"`
	MinEquity            SdkInt `json:"min_equity" mapstructure:"min_equity"` // minimum equity required to maintain a position
}

type Grid

type Grid struct {
	Levels     int     `toml:"levels" mapstructure:"levels"`
	LowerBound float64 `toml:"lower_bound" mapstructure:"lower_bound"`
	UpperBound float64 `toml:"upper_bound" mapstructure:"upper_bound"`
}

type HedgeConfig

type HedgeConfig struct {
	TargetAmount      SdkInt  `json:"target_amount" mapstructure:"target_amount"`             // total amount to be hedged
	MaxTradeAmount    SdkInt  `json:"max_trade_amount" mapstructure:"max_trade_amount"`       // maximum amount to be traded in a single trade
	MaxPriceImpact    float64 `json:"max_price_impact" mapstructure:"max_price_impact"`       // maximum slippage allowed, 1 = 1%, 0.5 = 0.5%
	TargetMarginRatio float64 `json:"target_margin_ratio" mapstructure:"target_margin_ratio"` // target margin ratio
	TokenIn           string  `json:"token_in" mapstructure:"token_in"`                       // token to be hedged
	TokenOut          string  `json:"token_out" mapstructure:"token_out"`                     // token to hedge against
	TokenInDecimals   int     `json:"token_in_decimals" mapstructure:"token_in_decimals"`     // decimals of token_in
	TokenOutDecimals  int     `json:"token_out_decimals" mapstructure:"token_out_decimals"`   // decimals of token_out
	MarginThreshold   int64   `json:"margin_threshold" mapstructure:"margin_threshold"`       // BPS proximity to liquidation price we accept prior to adding more margin
	Expiration        string  `json:"expiration" mapstructure:"expiration"`                   // expiration of hedge as date `YYYY-MM-DD HH:MM:SS`
}

type LevanaCCStrategyConfig

type LevanaCCStrategyConfig struct {
	DB                db.Config `toml:"db" mapsturcture:"db"`
	Granter           string    `toml:"granter" mapstructure:"granter"`
	Frequency         int       `toml:"frequency" mapstructure:"frequency"`
	FactoryContract   string    `toml:"factory_contract" mapstructure:"factory_contract"`
	LevanaAPIURL      string    `toml:"levana_api_url" mapstructure:"levana_api_url"`
	BaseDenom         string    `toml:"base_denom" mapstructure:"base_denom"`
	BaseDenomExponent int       `toml:"base_denom_exponent" mapstructure:"base_denom_exponent"`
	PoolID            uint64    `toml:"pool_id" mapstructure:"pool_id"`
	TradeSize         int64     `toml:"trade_size" mapstructure:"trade_size"`
	Leverage          int64     `toml:"leverage" mapstructure:"leverage"`
	Shutdown          bool      `toml:"shutdown" mapstructure:"shutdown"`
	Slippage          string    `toml:"slippage" mapstructure:"slippage"`
	MaxPriceDeviation string    `toml:"max_price_deviation" mapstructure:"max_price_deviation"`
	MinFundingRate    string    `toml:"min_funding_rate" mapstructure:"min_funding_rate"`
	MinOpenInterest   string    `toml:"min_open_interest" mapstructure:"min_open_interest"`
	MaxPositions      int       `toml:"max_positions" mapstructure:"max_positions"`
	TargetMarkets     []string  `toml:"target_markets" mapstructure:"target_markets"`
	FundContract      string    `toml:"fund_contract" mapstructure:"fund_contract"`
	StrategyContract  string    `toml:"strategy_contract" mapstructure:"strategy_contract"`
}

type LimitMmStrategyConfig

type LimitMmStrategyConfig struct {
	Granter          string        `toml:"granter" mapstructure:"granter"`
	Frequency        int           `toml:"frequency" mapstructure:"frequency"`
	OrderExpiry      int64         `toml:"order_expiry" mapstructure:"order_expiry"`
	Token0           string        `toml:"token0" mapstructure:"token0"` // Token0 is the first token in the pair
	Token0Exponent   int           `toml:"token0" mapstructure:"token0_exponent"`
	Token1           string        `toml:"token1" mapstructure:"token1"` // Token1 is the second token in the pair
	Token1Exponent   int           `toml:"token0" mapstructure:"token1_exponent"`
	Spread           int64         `toml:"spread" mapstructure:"spread"`                     // The spread BPS the we target with balanced inventory
	OrderWidth       int64         `toml:"order_width" mapstructure:"order_width"`           // The increment BPS we increment prices by
	OrderNumber      int64         `toml:"order_number" mapstructure:"order_number"`         // The number of orders we create on each side
	MinTradeAmount   int64         `toml:"min_trade_amount" mapstructure:"min_trade_amount"` // The smallest amount of the token we will trade
	Sensitivity      string        `toml:"sensitivity" mapstructure:"sensitivity"`           // Sensitivity to the change in price
	Binance          BinanceConfig `toml:"binance" mapstructure:"binance"`
	Drop             DropConfig    `toml:"drop" mapstructure:"drop"`
	FundContract     string        `toml:"fund_contract" mapstructure:"fund_contract"`
	StrategyContract string        `toml:"strategy_contract" mapstructure:"strategy_contract"`
}

func (*LimitMmStrategyConfig) GetPairID

func (p *LimitMmStrategyConfig) GetPairID() string

Method to get the pair ID

type LocustVault

type LocustVault struct {
	Fund     string `toml:"fund" mapstructure:"fund"`
	Strategy string `toml:"strategy" mapstructure:"strategy"`
}

type MarsConfig

type MarsConfig struct {
	CreditAccount uint64 `json:"credit_account" mapstructure:"credit_account"`
	CreditManager string `json:"credit_manager" mapstructure:"credit_manager"`
	RedBank       string `json:"red_bank" mapstructure:"red_bank"`
	Oracle        string `json:"oracle" mapstructure:"oracle"`
	Perps         string `json:"perps" mapstructure:"perps"`
	OracleDenom   string `json:"oracle_denom" mapstructure:"oracle_denom"` // Denom of the oracle price, e.g. untrn or ibc/xyz...
	Market        string `json:"market" mapstructure:"market"`
}

type NeutronDexStrategyConfig

type NeutronDexStrategyConfig struct {
	Granter          string        `toml:"granter" mapstructure:"granter"`
	Frequency        int           `toml:"frequency" mapstructure:"frequency"`
	FundContract     string        `toml:"fund_contract" mapstructure:"fund_contract"`
	StrategyContract string        `toml:"strategy_contract" mapstructure:"strategy_contract"`
	Binance          BinanceConfig `toml:"binance" mapstructure:"binance"`
	Pair             PairConfig    `toml:"pair" mapstructure:"pair"`
	WithdrawAll      bool          `toml:"withdraw_all" mapstructure:"withdraw_all"`
	DepositFactor    float64       `toml:"deposit_factor" mapstructure:"deposit_factor"`
	Fees             []uint64      `toml:"fees" mapstructure:"fees"`
	AdjustmentFactor float64       `toml:"adjustment_factor" mapstructure:"adjustment_factor"`
}

type NeutronGridStrategyConfig

type NeutronGridStrategyConfig struct {
	Token0               string          `toml:"token0" mapstructure:"token0"` // Token0 is the first token in the pair
	Token1               string          `toml:"token1" mapstructure:"token1"` // Token1 is the second token in the pair
	ChainID              string          `toml:"chain_id" mapstructure:"chain_id"`
	Levels               int             `toml:"levels" mapstructure:"levels"`
	LowerBound           float64         `toml:"lower_bound" mapstructure:"lower_bound"`
	UpperBound           float64         `toml:"upper_bound" mapstructure:"upper_bound"`
	DepositFactor        float64         `toml:"deposit_factor" mapstructure:"deposit_factor"`
	InvertBase           bool            `toml:"invert_base" mapstructure:"invert_base"`
	CoinGecko            CoinGeckoConfig `toml:"coingecko" mapstructure:"coingecko"` // CoinGecko configuration
	Frequency            int             `toml:"frequency" mapstructure:"frequency"`
	Granter              string          `toml:"granter" mapstructure:"granter"`
	CancelAllLimitOrders bool            `toml:"cancel_all_limit_orders" mapstructure:"cancel_all_limit_orders"`
}

func (*NeutronGridStrategyConfig) GetPairID

func (p *NeutronGridStrategyConfig) GetPairID() string

type NeutronXemmStrategyConfig

type NeutronXemmStrategyConfig struct {
	Granter     string `toml:"granter" mapstructure:"granter"`
	OrderExpiry int64  `toml:"order_expiry" mapstructure:"order_expiry"`

	Token0         string        `toml:"token0" mapstructure:"token0"`                     // Token0 is the first token in the pair
	Token1         string        `toml:"token1" mapstructure:"token1"`                     // Token1 is the second token in the pair
	Spread         int64         `toml:"spread" mapstructure:"spread"`                     // The spread BPS the we target with balanced inventory
	OrderWidth     int64         `toml:"order_width" mapstructure:"order_width"`           // The increment BPS we increment prices by
	OrderNumber    int64         `toml:"order_number" mapstructure:"order_number"`         // The number of orders we create on each side
	MinTradeAmount int64         `toml:"min_trade_amount" mapstructure:"min_trade_amount"` // The smallest amount of the token we will trade
	Sensitivity    string        `toml:"sensitivity" mapstructure:"sensitivity"`           // Sensitivity to the change in price
	Binance        BinanceConfig `toml:"binance" mapstructure:"binance"`
	ActiveTaker    bool          `toml:"active_taker" mapstructure:"active_taker"` // if active is true then we will make trades on taker market
}

func (*NeutronXemmStrategyConfig) GetPairID

func (p *NeutronXemmStrategyConfig) GetPairID() string

Method to get the pair ID

type PairConfig

type PairConfig struct {
	Token0          string  `toml:"token0" mapstructure:"token0"`
	Token1          string  `toml:"token0" mapstructure:"token1"`
	InvertBase      bool    `toml:"invert_base" mapstructure:"invert_base"`
	Price           string  `toml:"price" mapstructure:"price"`
	Ticks           int     `toml:"ticks" mapstructure:"ticks"`
	Fees            []int   `toml:"fees" mapstructure:"fees"`
	RebalanceFactor float64 `toml:"rebalance_factor" mapstructure:"rebalance_factor"`
	DepositFactor   float64 `toml:"deposit_factor" mapstructure:"deposit_factor"`
	SwapFactor      float64 `toml:"swap_factor" mapstructure:"swap_factor"`
	SwapAccuracy    float64 `toml:"swap_accuracy" mapstructure:"swap_accuracy"`
	DepositAccuracy float64 `toml:"deposit_accuracy" mapstructure:"deposit_accuracy"`
	Amplitude1      float64 `toml:"amplitude1" mapstructure:"amplitude1"`
	Period1         float64 `toml:"period1" mapstructure:"period1"`
	Amplitude2      float64 `toml:"amplitude2" mapstructure:"amplitude2"`
	Period2         float64 `toml:"period2" mapstructure:"period2"`
}

func (*PairConfig) GetPairID

func (p *PairConfig) GetPairID() string

Method to get the pair ID

type PerpDex

type PerpDex struct {
	Provider   string      `json:"provider" mapstructure:"provider"`
	MarsConfig *MarsConfig `json:"mars_config" mapstructure:"mars_config"`
	DydxConfig *DydxConfig `json:"dydx_config" mapstructure:"dydx_config"`
}

type Pool

type Pool struct {
	ID         uint64 `toml:"id" mapstructure:"id"`
	BaseDenom  string `toml:"base_denom" mapstructure:"base_denom"`
	QuoteDenom string `toml:"quote_denom" mapstructure:"quote_denom"`
}

type Position

type Position struct {
	AskSpread           int64     `toml:"ask_spread" mapstructure:"ask_spread"` // The spread BPS for asks
	AskLiquidityProfile []float64 `toml:"ask_liquidity_profile" mapstructure:"ask_liquidity_profile"`
	BidSpread           int64     `toml:"bid_spread" mapstructure:"bid_spread"` // The spread BPS for bids
	BidLiquidityProfile []float64 `toml:"bid_liquidity_profile" mapstructure:"bid_liquidity_profile"`
	Discount            int64     `toml:"discount" mapstructure:"discount"`       // Discount applied to external price BPS
	MaxSpread           int64     `toml:"max_spread" mapstructure:"max_spread"`   // Max spread BPS allowed between best prices
	Sensitivity         int64     `toml:"sensitivity" mapstructure:"sensitivity"` // Sensitivity to price changes BPS
}

type SdkInt

type SdkInt struct {
	Value sdkmath.Int
}

SdkInt is a wrapper around sdkmath.Int to handle TOML unmarshalling

func (SdkInt) MarshalText

func (s SdkInt) MarshalText() ([]byte, error)

MarshalText implements TOML marshalling for SdkInt

func (*SdkInt) UnmarshalTOML

func (s *SdkInt) UnmarshalTOML(data []byte) error

UnmarshalTOML implements TOML unmarshalling for SdkInt

func (*SdkInt) UnmarshalText

func (s *SdkInt) UnmarshalText(text []byte) error

UnmarshalText implements TOML unmarshalling for SdkInt

type SigningKey

type SigningKey struct {
	AppName string `toml:"app_name"`
	Backend string `toml:"backend"`
	RootDir string `toml:"root_dir"`
}

type SkipConfig

type SkipConfig struct {
	URL            string `json:"url" mapstructure:"url"`                           // url of skip api
	SwapEntryPoint string `json:"swap_entry_point" mapstructure:"swap_entry_point"` // swap entry point contract for the chain
}

type SlinkyConfig

type SlinkyConfig struct {
	Base  string `toml:"base" mapstructure:"base"`   // base token in the pair
	Quote string `toml:"quote" mapstructure:"quote"` // quote token in the pair
}

type StrategyConfig

type StrategyConfig struct {
	Name   string
	Config interface{}
}

type UmeeConfig added in v0.0.6

type UmeeConfig struct {
	Denom    string `json:"denom" mapstructure:"denom"` // Denom of the market on Umee
	Decimals uint64 `json:"decimals" mapstructure:"decimals"`
}

type UnbondDrop

type UnbondDrop struct {
	Denom                            string `toml:"denom" mapstructure:"denom"`
	CoreContractAddress              string `json:"core_contract_address" mapstructure:"core_contract_address"`
	WithdrawalVoucherContractAddress string `json:"withdrawal_voucher_contract_address" mapstructure:"withdrawal_voucher_contract_address"`
	WithdrawalManagerContractAddress string `json:"withdrawal_manager_contract_address" mapstructure:"withdrawal_manager_contract_address"`
}

type Zone

type Zone struct {
	RedemptionRate     string `json:"redemption_rate"`
	LastRedemptionRate string `json:"last_redemption_rate"`
}

type ZoneResponse

type ZoneResponse struct {
	Zone *Zone `json:"zone"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL