util

package
v0.0.0-...-0939e29 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StringToTxTypeMap = map[string]TxType{
	"add":         TxAdd,
	"+":           TxAdd,
	"withdraw":    TxWithdraw,
	"wd":          TxWithdraw,
	"-":           TxWithdraw,
	"swap":        TxSwap,
	"s":           TxSwap,
	"=":           TxSwap,
	"limito":      TxLimitOrder,
	"lo":          TxLimitOrder,
	"out":         TxOutbound,
	"donate":      TxDonate,
	"d":           TxDonate,
	"bond":        TxBond,
	"unbond":      TxUnbond,
	"leave":       TxLeave,
	"yggdrasil+":  TxYggdrasilFund,
	"yggdrasil-":  TxYggdrasilReturn,
	"reserve":     TxReserve,
	"refund":      TxRefund,
	"migrate":     TxMigrate,
	"ragnarok":    TxRagnarok,
	"switch":      TxSwitch,
	"noop":        TxNoOp,
	"consolidate": TxConsolidate,
	"name":        TxTHORName,
	"n":           TxTHORName,
	"~":           TxTHORName,
	"$+":          TxLoanOpen,
	"loan+":       TxLoanOpen,
	"$-":          TxLoanRepayment,
	"loan-":       TxLoanRepayment,
	"trade+":      TxTradeAccountDeposit,
	"trade-":      TxTradeAccountWithdrawal,
}

Functions

func CheckMemoIsStreamingSwap

func CheckMemoIsStreamingSwap(memo string) bool

This function is used for identifying the old swap events without streaming_quantity attribute as streaming swap

func CheckUrlEmpty

func CheckUrlEmpty(urlParams url.Values) miderr.Err

func ConsumeUrlParam

func ConsumeUrlParam(urlParams *url.Values, key string) (value string)

func ConvertNativePoolToSynth

func ConvertNativePoolToSynth(poolName string) string

func ConvertSynthPoolToNative

func ConvertSynthPoolToNative(poolName string) string

func GetMedian

func GetMedian(vals []float64) float64

From THORNode code

func IntStr

func IntStr(v int64) string

func Max

func Max[T Number](x, y T) T

func MustParseInt64

func MustParseInt64(v string) int64

func ToLowerBytes

func ToLowerBytes(b []byte) []byte

It's like bytes.ToLower but returns nil for nil.

func WrapBoolean

func WrapBoolean(value bool) *bool

func WrapString

func WrapString(value string) *string

Types

type Asset

type Asset struct {
	Chain  string
	Ticker string
	Symbol string
	Synth  bool
	Trade  bool
}

func AssetFromString

func AssetFromString(s string) (asset Asset)

type NativeDecimalMap

type NativeDecimalMap map[string]NativeDecimalSingle

Chains work with integers which represent fixed point decimals. E.g. on BTC 1 is 1e-8 bitcoin, but on ETH 1 is 1e-18 ethereum. This information is not important for Midgard, all the values are converted to E8 by ThorNode before they are sent to Midgard. This information is gathered only for clients.

type NativeDecimalSingle

type NativeDecimalSingle struct {
	NativeDecimals int64    `json:"decimals"` // -1 means that only the asset name was observed without the decimal count.
	AssetSeen      []string `json:"asset_seen"`
	DecimalSource  []string `json:"decimal_source"`
}

type Number

type Number interface {
	int64 | float64
}

type TxType

type TxType string

From THORNode MEMO: TXTYPE:STATE1:STATE2:STATE3:FINALMEMO

const (
	TxUnknown                TxType = "unknown"
	TxAdd                    TxType = "add"
	TxWithdraw               TxType = "withdraw"
	TxSwap                   TxType = "swap"
	TxLimitOrder             TxType = "limitOrder"
	TxOutbound               TxType = "outbound"
	TxDonate                 TxType = "donate"
	TxBond                   TxType = "bond"
	TxUnbond                 TxType = "unbond"
	TxLeave                  TxType = "leave"
	TxYggdrasilFund          TxType = "yggdrasilFund"
	TxYggdrasilReturn        TxType = "yggdrasilReturn"
	TxReserve                TxType = "reserve"
	TxRefund                 TxType = "refund"
	TxMigrate                TxType = "migrate"
	TxRagnarok               TxType = "ragnarok"
	TxSwitch                 TxType = "switch"
	TxNoOp                   TxType = "noOp"
	TxConsolidate            TxType = "consolidate"
	TxTHORName               TxType = "thorname"
	TxLoanOpen               TxType = "loanOpen"
	TxLoanRepayment          TxType = "loanRepayment"
	TxTradeAccountDeposit    TxType = "tradeAccountDeposit"
	TxTradeAccountWithdrawal TxType = "tradeAccountWithdraw"
)

func TxTypeFromMemo

func TxTypeFromMemo(memo string) (txType TxType)

Directories

Path Synopsis
Reports averages and histograms.
Reports averages and histograms.

Jump to

Keyboard shortcuts

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