Documentation ¶
Index ¶
- Constants
- Variables
- func CurrencyPairString(base, quote string) string
- func IsLegacyAssetString(asset string) bool
- func SplitDefiAssetString(defiString string) (token, address, chainID string, err error)
- func ValidateDefiAssetString(asset string) error
- func ValidateLegacyAssetString(asset string) error
- type CurrencyPair
- func (*CurrencyPair) Descriptor() ([]byte, []int)
- func (cp *CurrencyPair) Equal(other CurrencyPair) bool
- func (m *CurrencyPair) GetBase() string
- func (m *CurrencyPair) GetQuote() string
- func (cp *CurrencyPair) Invert() CurrencyPair
- func (cp *CurrencyPair) LegacyDecimals() int
- func (cp *CurrencyPair) LegacyValidateBasic() error
- func (m *CurrencyPair) Marshal() (dAtA []byte, err error)
- func (m *CurrencyPair) MarshalTo(dAtA []byte) (int, error)
- func (m *CurrencyPair) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*CurrencyPair) ProtoMessage()
- func (m *CurrencyPair) Reset()
- func (m *CurrencyPair) Size() (n int)
- func (cp CurrencyPair) String() string
- func (m *CurrencyPair) Unmarshal(dAtA []byte) error
- func (cp *CurrencyPair) ValidateBasic() error
- func (m *CurrencyPair) XXX_DiscardUnknown()
- func (m *CurrencyPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *CurrencyPair) XXX_Merge(src proto.Message)
- func (m *CurrencyPair) XXX_Size() int
- func (m *CurrencyPair) XXX_Unmarshal(b []byte) error
Constants ¶
const (
MaxCPFieldLength = 256
)
Variables ¶
Functions ¶
func CurrencyPairString ¶
CurrencyPairString constructs and returns the string representation of a currency pair.
func IsLegacyAssetString ¶
IsLegacyAssetString returns true if the asset string is of the following format: - contains no instances of fieldSeparator.
func SplitDefiAssetString ¶
SplitDefiAssetString splits a defi asset by the fieldSeparator and checks that it is the proper length. returns the split string as (token, address, chainID).
func ValidateDefiAssetString ¶
ValidateDefiAssetString checks that the asset string is formatted properly as a defi asset (tokenName,tokenAddress,chainID) - check that the length of fields separated by fieldSeparator is expectedSplitLength - check that the first split (tokenName) is formatted properly as a LegacyAssetString.
NOTE: this function assumes that coreValidate() has already been run.
func ValidateLegacyAssetString ¶
ValidateLegacyAssetString checks if the asset string is formatted correctly, i.e. - asset string is fully uppercase - asset string does not contain the `fieldSeparator`
NOTE: this function assumes that coreValidate() has already been run.
Types ¶
type CurrencyPair ¶
type CurrencyPair struct { Base string `protobuf:"bytes,1,opt,name=Base,proto3" json:"Base,omitempty"` Quote string `protobuf:"bytes,2,opt,name=Quote,proto3" json:"Quote,omitempty"` }
CurrencyPair is the standard representation of a pair of assets, where one (Base) is priced in terms of the other (Quote)
func CurrencyPairFromString ¶
func CurrencyPairFromString(s string) (CurrencyPair, error)
CurrencyPairFromString creates a currency pair from a string. Non-capitalized inputs are sanitized and the resulting currency pair is validated.
func NewCurrencyPair ¶
func NewCurrencyPair(base, quote string) CurrencyPair
NewCurrencyPair returns a new CurrencyPair with the given base and quote strings.
func (*CurrencyPair) Descriptor ¶
func (*CurrencyPair) Descriptor() ([]byte, []int)
func (*CurrencyPair) Equal ¶
func (cp *CurrencyPair) Equal(other CurrencyPair) bool
Equal returns true iff the CurrencyPair is equal to the given CurrencyPair.
func (*CurrencyPair) GetBase ¶
func (m *CurrencyPair) GetBase() string
func (*CurrencyPair) GetQuote ¶
func (m *CurrencyPair) GetQuote() string
func (*CurrencyPair) Invert ¶
func (cp *CurrencyPair) Invert() CurrencyPair
Invert returns an inverted version of cp (where the Base and Quote are swapped).
func (*CurrencyPair) LegacyDecimals ¶
func (cp *CurrencyPair) LegacyDecimals() int
LegacyDecimals returns the number of decimals that the quote will be reported to. If the quote is Ethereum, then the number of decimals is 18. Otherwise, the decimals will be reported as 8.
func (*CurrencyPair) LegacyValidateBasic ¶
func (cp *CurrencyPair) LegacyValidateBasic() error
LegacyValidateBasic checks that the Base / Quote strings in the CurrencyPair are formatted correctly, i.e. Base + Quote are non-empty, and are in upper-case.
func (*CurrencyPair) Marshal ¶
func (m *CurrencyPair) Marshal() (dAtA []byte, err error)
func (*CurrencyPair) MarshalToSizedBuffer ¶
func (m *CurrencyPair) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*CurrencyPair) ProtoMessage ¶
func (*CurrencyPair) ProtoMessage()
func (*CurrencyPair) Reset ¶
func (m *CurrencyPair) Reset()
func (*CurrencyPair) Size ¶
func (m *CurrencyPair) Size() (n int)
func (CurrencyPair) String ¶
func (cp CurrencyPair) String() string
String returns a string representation of the CurrencyPair, in the following form "ETH/BTC".
func (*CurrencyPair) Unmarshal ¶
func (m *CurrencyPair) Unmarshal(dAtA []byte) error
func (*CurrencyPair) ValidateBasic ¶
func (cp *CurrencyPair) ValidateBasic() error
ValidateBasic checks that the Base / Quote strings in the CurrencyPair are formatted correctly, i.e. For base and quote asset: check if the asset is formatted in the legacy validation form:
- if so, check that fields are not empty and all upper case
- else, check that the format is in the following form: tokenName,tokenAddress,chainID
func (*CurrencyPair) XXX_DiscardUnknown ¶
func (m *CurrencyPair) XXX_DiscardUnknown()
func (*CurrencyPair) XXX_Marshal ¶
func (m *CurrencyPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*CurrencyPair) XXX_Merge ¶
func (m *CurrencyPair) XXX_Merge(src proto.Message)
func (*CurrencyPair) XXX_Size ¶
func (m *CurrencyPair) XXX_Size() int
func (*CurrencyPair) XXX_Unmarshal ¶
func (m *CurrencyPair) XXX_Unmarshal(b []byte) error