client

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const ADMIN_KEY_NAME = "admin"
View Source
const ALICE_KEY_NAME = "alice"
View Source
const BOB_KEY_NAME = "bob"
View Source
const CHAIN_ID = "sei-chain"
View Source
const KEY_SERVER = "http://localhost:8088"
View Source
const NODE_URI = "tcp://localhost:26657"
View Source
const ORACLE_HASH = "abc"
View Source
const VOTE_WAIT_SECONDS = 5

Variables

This section is empty.

Functions

func GetAddress

func GetAddress(accountName string) string

func GetEventAttributeValue

func GetEventAttributeValue(response sdk.TxResponse, eventType string, attributeKey string) string

func GetKey

func GetKey(accountName string) cryptotypes.PrivKey

func SanitizeFilename

func SanitizeFilename(filename string) string

func ToOrderPlacementExecuteMsg

func ToOrderPlacementExecuteMsg(fundedOrder FundedOrder) []byte

func ToSeiCancelOrderPlacement

func ToSeiCancelOrderPlacement(cancelOrder CancelOrder) dextypes.Cancellation

func ToSeiOrderPlacement

func ToSeiOrderPlacement(fundedOrder FundedOrder) dextypes.Order

func ToUpdateMultiCollateralWhitelistExecuteMsg

func ToUpdateMultiCollateralWhitelistExecuteMsg(whitelistedAccounts []string) []byte

Types

type Balance

type Balance struct {
	Account  string `json:"account"`
	Denom    string `json:"denom"`
	Amount   string `json:"amount"`
	Negative bool   `json:"negative"`
}

type BankBalanceExpectation

type BankBalanceExpectation struct {
	Account string  `json:"account"`
	Denom   string  `json:"denom"`
	Delta   sdk.Int `json:"delta"`
}

type CancelOrder

type CancelOrder struct {
	Account string            `json:"account"`
	Moniker string            `json:"moniker"`
	Order   OrderCancellation `json:"order"`
}

func ParseCancelOrder

func ParseCancelOrder(raw json.RawMessage) CancelOrder

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	key cryptotypes.PrivKey,
	txConfig *TxConfig,
	encodingConfig *EncodingConfig,
) *Client

func NewClientWithDefaultConfig

func NewClientWithDefaultConfig(key cryptotypes.PrivKey) *Client

func (*Client) ExecuteContract

func (c *Client) ExecuteContract(contractAddr string, code uint64, executeMsg string, fund string) (*sdk.TxResponse, error)

This function takes custom executeMsg and call designated cosmwasm contract execute endpoint it returns the instantiated contract address if succeeds Input fund example: "1000usei". Empty string can be passed if this execution doesn't intend to attach any fund.

func (*Client) GetBankBalance

func (c *Client) GetBankBalance(account string, denom string) sdk.Coin

func (*Client) GetCurrentEpoch

func (c *Client) GetCurrentEpoch() uint64

func (*Client) GetOracleWhitelist

func (c *Client) GetOracleWhitelist() oracletypes.DenomList

func (*Client) GetTxConfig

func (c *Client) GetTxConfig() *TxConfig

func (*Client) InstantiateContract

func (c *Client) InstantiateContract(code uint64, instantiateMsg string) (*sdk.TxResponse, error)

This function takes custom instantiateMsg and instantiates cosmwasm contract it returns the instantiated contract address if succeeds

func (*Client) IsProposalHandled

func (c *Client) IsProposalHandled(proposalId string) bool

func (*Client) QueryContract

func (c *Client) QueryContract(queryMsg string, contractAddr string) (*wasmdtypes.QuerySmartContractStateResponse, error)

This function takes custom queryMsg and get the corresponding state from the contract

func (*Client) RegisterOracleDenom

func (c *Client) RegisterOracleDenom(title string, denoms []string) string

func (*Client) RegisterOracleDenomAndWaitForApproval

func (c *Client) RegisterOracleDenomAndWaitForApproval(filename string)

func (*Client) RegisterPair

func (c *Client) RegisterPair(
	title string,
	contractAddr string,
	pairs []*dextypes.Pair,
) (*sdk.TxResponse, error)

func (*Client) RegisterPairAndWaitForApproval

func (c *Client) RegisterPairAndWaitForApproval(
	title string,
	contractAddr string,
	pairs []*dextypes.Pair,
) error

func (*Client) SendCancel

func (c *Client) SendCancel(
	order CancelOrder,
	contractAddr string,
) error

func (*Client) SendOracleDenomProposal

func (c *Client) SendOracleDenomProposal(title string, denoms []string) string

func (*Client) SendOraclePrice

func (c *Client) SendOraclePrice(coins sdk.DecCoins) error

func (*Client) SendOrder

func (c *Client) SendOrder(order FundedOrder, contractAddr string) (dextypes.MsgPlaceOrdersResponse, error)

func (*Client) SendRegisterContract

func (c *Client) SendRegisterContract(contractAddr string, codeId uint64, needHook bool) (*sdk.TxResponse, error)

func (*Client) SubmitFraudChallenge

func (c *Client) SubmitFraudChallenge(
	startSlot uint64,
	endSlot uint64,
	fraudStatePubKey string,
	merkleProof *types.MerkleProof,
	accountStates []*types.Account,
	programs []*types.Account,
	sysvarAccounts []*types.Account,
	gasLimit uint64,
	gasWanted sdk.Coin,
) (*sdk.TxResponse, error)

func (*Client) Vote

func (c *Client) Vote(proposalId string) error

type ContractBalance

type ContractBalance struct {
	Amount ContractSignedDecimal `json:"amount"`
}

contract types below

func ParseContractBalance

func ParseContractBalance(balanceBytes []byte) ContractBalance

type ContractGetOrderResponse

type ContractGetOrderResponse struct {
	Orders []ContractOrder `json:"orders"`
}

func ParseContractGetOrderResponse

func ParseContractGetOrderResponse(orderBytes []byte) ContractGetOrderResponse

type ContractOrder

type ContractOrder struct {
	Id                uint64                `json:"id"`
	Account           string                `json:"account"`
	PriceDenom        string                `json:"price_denom"`
	AssetDenom        string                `json:"asset_denom"`
	Price             ContractSignedDecimal `json:"price"`
	Quantity          ContractSignedDecimal `json:"quantity"`
	RemainingQuantity ContractSignedDecimal `json:"remaining_quantity"`
	Direction         string                `json:"direction"`
	Effect            string                `json:"effect"`
	Leverage          ContractSignedDecimal `json:"leverage"`
	OrderType         string                `json:"order_type"`
}

type ContractPosition

type ContractPosition struct {
	LongPosition                        ContractSignedDecimal `json:"long_position"`
	LongPositionMarginDebt              ContractSignedDecimal `json:"long_position_margin_debt"`
	LongPositioLastFundingPaymentEpoch  int64                 `json:"long_position_last_funding_payment_epoch"`
	ShortPosition                       ContractSignedDecimal `json:"short_position"`
	ShortPositionMarginDebt             ContractSignedDecimal `json:"short_position_margin_debt"`
	ShortPositioLastFundingPaymentEpoch int64                 `json:"short_position_last_funding_payment_epoch"`
}

func ParseContractPosition

func ParseContractPosition(positionBytes []byte) ContractPosition

type ContractSignedDecimal

type ContractSignedDecimal struct {
	Decimal  string `json:"decimal"`
	Negative bool   `json:"negative"`
}

func (*ContractSignedDecimal) Multiply

func (c *ContractSignedDecimal) Multiply(multiplier float64) ContractSignedDecimal

type Deposit

type Deposit struct {
	Account string `json:"account"`
	Fund    string `json:"fund"`
}

func ParseDeposit

func ParseDeposit(raw json.RawMessage) Deposit

type EncodingConfig

type EncodingConfig struct {
	InterfaceRegistry types.InterfaceRegistry
	// NOTE: this field will be renamed to Codec
	Marshaler codec.Codec
	TxConfig  client.TxConfig
	Amino     *codec.LegacyAmino
}

func NewDefaultEncodingConfig

func NewDefaultEncodingConfig() *EncodingConfig

type Expectations

type Expectations struct {
	Balances       []Balance                `json:"balances"`
	Positions      []Position               `json:"positions"`
	Orders         []Order                  `json:"orders"`
	PortfolioSpecs []PortfolioSpecs         `json:"portfolio_specs"`
	BankBalances   []BankBalanceExpectation `json:"bank_balances"`
}

type FundedOrder

type FundedOrder struct {
	Moniker string         `json:"moniker"`
	Account string         `json:"account"`
	Order   OrderPlacement `json:"order"`
	Fund    string         `json:"fund"`
}

func ParseFundedOrder

func ParseFundedOrder(raw json.RawMessage) FundedOrder

type Input

type Input struct {
	InputType string          `json:"type"`
	Details   json.RawMessage `json:"details"`
}

type LiquidationRequest

type LiquidationRequest struct {
	AccountToBeLiquidated string `json:"account"`
	Fund                  string `json:"fund"`
}

func ParseLiquidation

func ParseLiquidation(raw json.RawMessage) LiquidationRequest

type MultiCollateralAccounts

type MultiCollateralAccounts struct {
	Accounts []string `json:"accounts"`
}

func ParseMultiCollateralAccounts

func ParseMultiCollateralAccounts(raw json.RawMessage) MultiCollateralAccounts

type OracleUpdate

type OracleUpdate struct {
	ExchangeRates sdk.DecCoins `json:"exchange_rates"`
}

func ParseOracleUpdate

func ParseOracleUpdate(raw json.RawMessage) OracleUpdate

type Order

type Order struct {
	Account    string `json:"account"`
	PriceDenom string `json:"price_denom"`
	AssetDenom string `json:"asset_denom"`

	ExpectedOrders []OrderDetails `json:"expected_orders"`
}

type OrderCancellation

type OrderCancellation struct {
	Id                string `json:"id"`
	PositionDirection string `json:"position_direction"`
	Price             string `json:"price"`
	PriceDenom        string `json:"price_denom"`
	AssetDenom        string `json:"asset_denom"`
}

type OrderData

type OrderData struct {
	PositionEffect string `json:"position_effect"`
	Leverage       string `json:"leverage"`
}

type OrderDetails

type OrderDetails struct {
	Price             ContractSignedDecimal `json:"price"`
	Quantity          ContractSignedDecimal `json:"quantity"`
	RemainingQuantity ContractSignedDecimal `json:"remaining_quantity"`
	Direction         string                `json:"direction"`
	Effect            string                `json:"effect"`
	Leverage          ContractSignedDecimal `json:"leverage"`
	OrderType         string                `json:"order_type"`
}

type OrderPlacement

type OrderPlacement struct {
	PositionDirection string `json:"position_direction"`
	Price             string `json:"price"`
	Quantity          string `json:"quantity"`
	PriceDenom        string `json:"price_denom"`
	AssetDenom        string `json:"asset_denom"`
	PositionEffect    string `json:"position_effect"`
	OrderType         string `json:"order_type"`
	Leverage          string `json:"leverage"`
}

type Pair

type Pair struct {
	PriceDenom string  `json:"price_denom"`
	AssetDenom string  `json:"asset_denom"`
	Ticksize   sdk.Dec `json:"ticksize"`
	Contract   string  `json:"contract"`
}

type PortfolioSpecs

type PortfolioSpecs struct {
	Account            string                `json:"account"`
	Equity             ContractSignedDecimal `json:"equity"`
	TotalPositionValue ContractSignedDecimal `json:"total_position_value"`
	BuyingPower        ContractSignedDecimal `json:"buying_power"`
	UnrealizedPnl      ContractSignedDecimal `json:"unrealized_pnl"`
	Leverage           ContractSignedDecimal `json:"leverage"`
}

func ParsePortfolioSpecs

func ParsePortfolioSpecs(specsBytes []byte) PortfolioSpecs

type Position

type Position struct {
	Account    string `json:"account"`
	PriceDenom string `json:"price_denom"`
	AssetDenom string `json:"asset_denom"`

	LongPosition                        ContractSignedDecimal `json:"long_position"`
	LongPositionMarginDebt              ContractSignedDecimal `json:"long_position_margin_debt"`
	LongPositioLastFundingPaymentEpoch  int64                 `json:"long_position_last_funding_payment_epoch"`
	ShortPosition                       ContractSignedDecimal `json:"short_position"`
	ShortPositionMarginDebt             ContractSignedDecimal `json:"short_position_margin_debt"`
	ShortPositioLastFundingPaymentEpoch int64                 `json:"short_position_last_funding_payment_epoch"`
}

type Sleep

type Sleep struct {
	TillNextEpoch bool `json:"till_next_epoch"`
}

func ParseSleep

func ParseSleep(raw json.RawMessage) Sleep

type StartingBalance

type StartingBalance struct {
	Account string `json:"account"`
	Denom   string `json:"denom"`
}

func ParseStartingBalance

func ParseStartingBalance(raw json.RawMessage) StartingBalance

type SwapMulticollateralToBase

type SwapMulticollateralToBase struct {
	Orders []dextypes.Order `json:"orders"`
}

type SwapMulticollateralToBaseMsg

type SwapMulticollateralToBaseMsg struct {
	SwapMulticollateralToBase SwapMulticollateralToBase `json:"swap_multicollateral_to_base"`
}

type Test

type Test struct {
	Pairs        []Pair       `json:"pairs"`
	Inputs       []Input      `json:"inputs"`
	Expectations Expectations `json:"expectations"`
}

func ParseTestFile

func ParseTestFile(filename string) Test

type TxConfig

type TxConfig struct {
	// contains filtered or unexported fields
}

func NewTxConfig

func NewTxConfig(
	nodeURI string,
	keyServer string,
	chainId string,
	gasLimit uint64,
	gasFee sdk.Coin,
	grpcConn *grpc.ClientConn,
) *TxConfig

func (*TxConfig) GetGasFee

func (t *TxConfig) GetGasFee() sdk.Coin

func (*TxConfig) GetGasLimit

func (t *TxConfig) GetGasLimit() uint64

type UpdateMultiCollateralWhitelist

type UpdateMultiCollateralWhitelist struct {
	Whitelist       []string `json:"whitelist"`
	WhitelistEnable bool     `json:"whitelist_enable"`
}

type UpdateMultiCollateralWhitelistMsg

type UpdateMultiCollateralWhitelistMsg struct {
	UpdateMultiCollateralWhitelist UpdateMultiCollateralWhitelist `json:"update_multi_collateral_whitelist"`
}

Jump to

Keyboard shortcuts

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