Documentation ¶
Index ¶
- Variables
- func CreateExplorerTXLink(blockchain money.Blockchain, networkID, txID string) (string, error)
- func CreatePaymentLink(addr string, currency money.CryptoCurrency, amount money.Money, isTest bool) (string, error)
- func DefaultSetup(s *CurrencyResolver) error
- func NormalizeTicker(ticker string) string
- type BSCFee
- type Broadcaster
- type Conversion
- type ConversionType
- type Convertor
- type CurrencyResolver
- func (r *CurrencyResolver) GetCurrencyByBlockchainAndContract(bc money.Blockchain, networkID, addr string) (money.CryptoCurrency, error)
- func (r *CurrencyResolver) GetCurrencyByTicker(ticker string) (money.CryptoCurrency, error)
- func (r *CurrencyResolver) GetMinimalWithdrawalByTicker(ticker string) (money.Money, error)
- func (r *CurrencyResolver) GetNativeCoin(chain money.Blockchain) (money.CryptoCurrency, error)
- func (r *CurrencyResolver) GetUSDMinimalInternalTransferByTicker(ticker string) (money.Money, error)
- func (r *CurrencyResolver) ListBlockchainCurrencies(blockchain money.Blockchain) []money.CryptoCurrency
- func (r *CurrencyResolver) ListSupportedBlockchains() []money.Blockchain
- func (r *CurrencyResolver) ListSupportedCurrencies(withDeprecated bool) []money.CryptoCurrency
- type EthFee
- type ExchangeRate
- type Fee
- type FeeCalculator
- type MaticFee
- type Providers
- type Resolver
- type Service
- func (s *Service) BroadcastTransaction(ctx context.Context, blockchain money.Blockchain, rawTX string, isTest bool) (string, error)
- func (s *Service) CalculateFee(ctx context.Context, baseCurrency, currency money.CryptoCurrency, isTest bool) (Fee, error)
- func (s *Service) CalculateWithdrawalFeeUSD(ctx context.Context, baseCurrency, currency money.CryptoCurrency, isTest bool) (money.Money, error)
- func (s *Service) Convert(ctx context.Context, from, to, amount string) (Conversion, error)
- func (s *Service) CryptoToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error)
- func (s *Service) FiatToCrypto(ctx context.Context, from money.Money, to money.CryptoCurrency) (Conversion, error)
- func (s *Service) FiatToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error)
- func (s *Service) GetExchangeRate(ctx context.Context, from, to string) (ExchangeRate, error)
- func (s *Service) GetTransactionReceipt(ctx context.Context, blockchain money.Blockchain, transactionID string, ...) (*TransactionReceipt, error)
- type TransactionReceipt
- type TronFee
Constants ¶
This section is empty.
Variables ¶
var ( ErrValidation = errors.New("invalid data provided") ErrCurrencyNotFound = errors.New("currency not found") ErrNoTokenAddress = errors.New("token should have contract address filled") ErrParseMoney = errors.New("unable to parse money value") ErrInsufficientFunds = errors.New("wallet has insufficient funds") ErrInvalidTransaction = errors.New("transaction is invalid") )
Functions ¶
func CreateExplorerTXLink ¶
func CreateExplorerTXLink(blockchain money.Blockchain, networkID, txID string) (string, error)
func CreatePaymentLink ¶
func DefaultSetup ¶
func DefaultSetup(s *CurrencyResolver) error
nolint:gocritic DefaultSetup applied coins & tokens that are supported within Oxygen.
func NormalizeTicker ¶ added in v0.2.0
NormalizeTicker normalizes fiat / crypto ticker for further usage in external services (e.g. Tatum).
Types ¶
type Broadcaster ¶
type Conversion ¶
type ConversionType ¶
type ConversionType string
const ( ConversionTypeFiatToFiat ConversionType = "fiatToFiat" ConversionTypeFiatToCrypto ConversionType = "fiatToCrypto" ConversionTypeCryptoToFiat ConversionType = "cryptoToFiat" )
type Convertor ¶
type Convertor interface { GetExchangeRate(ctx context.Context, from, to string) (ExchangeRate, error) Convert(ctx context.Context, from, to, amount string) (Conversion, error) FiatToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error) FiatToCrypto(ctx context.Context, from money.Money, to money.CryptoCurrency) (Conversion, error) CryptoToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error) }
type CurrencyResolver ¶
type CurrencyResolver struct {
// contains filtered or unexported fields
}
func NewCurrencies ¶
func NewCurrencies() *CurrencyResolver
func (*CurrencyResolver) GetCurrencyByBlockchainAndContract ¶
func (r *CurrencyResolver) GetCurrencyByBlockchainAndContract(bc money.Blockchain, networkID, addr string) (money.CryptoCurrency, error)
GetCurrencyByBlockchainAndContract searches currency by blockchain and contract address across both mainnet & testnet.
func (*CurrencyResolver) GetCurrencyByTicker ¶
func (r *CurrencyResolver) GetCurrencyByTicker(ticker string) (money.CryptoCurrency, error)
func (*CurrencyResolver) GetMinimalWithdrawalByTicker ¶
func (r *CurrencyResolver) GetMinimalWithdrawalByTicker(ticker string) (money.Money, error)
GetMinimalWithdrawalByTicker returns minimal withdrawal amount in USD for selected ticker.
func (*CurrencyResolver) GetNativeCoin ¶ added in v0.3.0
func (r *CurrencyResolver) GetNativeCoin(chain money.Blockchain) (money.CryptoCurrency, error)
GetNativeCoin returns native coin by blockchain. Example: ETH -> ETH; BSC -> BNB.
func (*CurrencyResolver) GetUSDMinimalInternalTransferByTicker ¶
func (r *CurrencyResolver) GetUSDMinimalInternalTransferByTicker(ticker string) (money.Money, error)
GetUSDMinimalInternalTransferByTicker returns minimal internal transfer amount in USD for selected ticker. internal transfer is a transfer from inbound to outbound O2pay wallet.
func (*CurrencyResolver) ListBlockchainCurrencies ¶
func (r *CurrencyResolver) ListBlockchainCurrencies(blockchain money.Blockchain) []money.CryptoCurrency
func (*CurrencyResolver) ListSupportedBlockchains ¶
func (r *CurrencyResolver) ListSupportedBlockchains() []money.Blockchain
func (*CurrencyResolver) ListSupportedCurrencies ¶
func (r *CurrencyResolver) ListSupportedCurrencies(withDeprecated bool) []money.CryptoCurrency
type ExchangeRate ¶
type Fee ¶
type Fee struct { CalculatedAt time.Time Currency money.CryptoCurrency IsTest bool // contains filtered or unexported fields }
func (*Fee) ToMaticFee ¶
type FeeCalculator ¶
type MaticFee ¶
type MaticFee struct { GasUnits uint `json:"gasUnits"` GasPrice string `json:"gasPrice"` PriorityFee string `json:"priorityFee"` TotalCostWEI string `json:"totalCostWei"` TotalCostMATIC string `json:"totalCostMatic"` TotalCostUSD string `json:"totalCostUsd"` // contains filtered or unexported fields }
type Resolver ¶
type Resolver interface { ListSupportedCurrencies(withDeprecated bool) []money.CryptoCurrency ListBlockchainCurrencies(blockchain money.Blockchain) []money.CryptoCurrency GetCurrencyByTicker(ticker string) (money.CryptoCurrency, error) GetNativeCoin(blockchain money.Blockchain) (money.CryptoCurrency, error) GetCurrencyByBlockchainAndContract(bc money.Blockchain, networkID, addr string) (money.CryptoCurrency, error) GetMinimalWithdrawalByTicker(ticker string) (money.Money, error) GetUSDMinimalInternalTransferByTicker(ticker string) (money.Money, error) }
type Service ¶
type Service struct { *CurrencyResolver // contains filtered or unexported fields }
func (*Service) BroadcastTransaction ¶
func (*Service) CalculateFee ¶
func (s *Service) CalculateFee(ctx context.Context, baseCurrency, currency money.CryptoCurrency, isTest bool) (Fee, error)
CalculateFee calculates blockchain transaction fee for selected currency.
func (*Service) CalculateWithdrawalFeeUSD ¶
func (s *Service) CalculateWithdrawalFeeUSD( ctx context.Context, baseCurrency, currency money.CryptoCurrency, isTest bool, ) (money.Money, error)
CalculateWithdrawalFeeUSD withdrawal fees are tied to network fee but calculated in USD Example: usdFee, err := CalculateWithdrawalFeeUSD(ctx, eth, ethUSD, false)
func (*Service) Convert ¶
Convert Converts currencies according to automatically resolved ConversionType. This method parses amount as float64, please don't use it internally as output would contain huge error rate when dealing with 18 eth decimals. Suitable for API responses.
func (*Service) CryptoToFiat ¶
func (s *Service) CryptoToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error)
func (*Service) FiatToCrypto ¶
func (s *Service) FiatToCrypto(ctx context.Context, from money.Money, to money.CryptoCurrency) (Conversion, error)
func (*Service) FiatToFiat ¶
func (s *Service) FiatToFiat(ctx context.Context, from money.Money, to money.FiatCurrency) (Conversion, error)
func (*Service) GetExchangeRate ¶
func (*Service) GetTransactionReceipt ¶
func (s *Service) GetTransactionReceipt( ctx context.Context, blockchain money.Blockchain, transactionID string, isTest bool, ) (*TransactionReceipt, error)