feat/currency rounding (#3041)

* feat(@desktop/wallet): added iso4217 library for fiat currency display decimals

* feat(@desktop/wallet): added token peg info and use numbers for token market values

* feat(@desktop/wallet): extend wallet api to fetch prices in multiple currencies

* chore(@desktop/wallet): rename token peg field for clarity
This commit is contained in:
dlipicar 2023-01-03 10:24:55 -03:00 committed by GitHub
parent 9137257638
commit 3d22f4a86d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 897 additions and 189 deletions

1
go.mod
View File

@ -80,6 +80,7 @@ require github.com/fogleman/gg v1.3.0
require (
github.com/gorilla/sessions v1.2.1
github.com/meirf/gopart v0.0.0-20180520194036-37e9492a85a8
github.com/rmg/iso4217 v1.0.0
github.com/waku-org/go-waku v0.2.3-test.0.20221212154545-7443daea4cd4
)

2
go.sum
View File

@ -1835,6 +1835,8 @@ github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJ
github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho=
github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
github.com/rmg/iso4217 v1.0.0 h1:qZP5nhSwHDKkgpuapOL6BDfHUbBgwXfiPTbPGcwZ92E=
github.com/rmg/iso4217 v1.0.0/go.mod h1:AbFI9wPu0EAO+Q6swPiMEfAtyz7T7EfNigAOKNNyiBE=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=

View File

@ -2,10 +2,13 @@ package wallet
import (
"context"
"errors"
"fmt"
"math/big"
"strings"
"github.com/rmg/iso4217"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/log"
@ -312,14 +315,14 @@ func (api *API) GetEthereumChains(ctx context.Context, onlyEnabled bool) ([]*par
return api.s.rpcClient.NetworkManager.Get(onlyEnabled)
}
func (api *API) FetchPrices(ctx context.Context, symbols []string, currency string) (map[string]float64, error) {
func (api *API) FetchPrices(ctx context.Context, symbols []string, currencies []string) (map[string]map[string]float64, error) {
log.Debug("call to FetchPrices")
return fetchCryptoComparePrices(symbols, currency)
return fetchCryptoComparePrices(symbols, currencies)
}
func (api *API) FetchMarketValues(ctx context.Context, symbols []string, currency string) (map[string]MarketCoinValues, error) {
func (api *API) FetchMarketValues(ctx context.Context, symbols []string, currencies []string) (map[string]map[string]MarketCoinValues, error) {
log.Debug("call to FetchMarketValues")
return fetchTokenMarketValues(symbols, currency)
return fetchTokenMarketValues(symbols, currencies)
}
func (api *API) GetHourlyMarketValues(ctx context.Context, symbol string, currency string, limit int, aggregate int) ([]TokenHistoricalPairs, error) {
@ -521,3 +524,19 @@ func (api *API) CreateMultiTransaction(ctx context.Context, multiTransaction *Mu
log.Debug("[WalletAPI:: CreateMultiTransaction] create multi transaction")
return api.s.transactionManager.createMultiTransaction(ctx, multiTransaction, data, api.router.bridges, password)
}
func (api *API) IsCurrencyFiat(name string) bool {
code, _ := iso4217.ByName(strings.ToUpper(name))
return (code != 0)
}
func (api *API) GetFiatCurrencyMinorUnit(name string) (int, error) {
code, minor := iso4217.ByName(strings.ToUpper(name))
if code == 0 {
return code, errors.New("Unknown currency: " + name)
}
return minor, nil
}

View File

@ -29,13 +29,13 @@ type Coin struct {
}
type MarketCoinValues struct {
MKTCAP string `json:"MKTCAP"`
HIGHDAY string `json:"HIGHDAY"`
LOWDAY string `json:"LOWDAY"`
CHANGEPCTHOUR string `json:"CHANGEPCTHOUR"`
CHANGEPCTDAY string `json:"CHANGEPCTDAY"`
CHANGEPCT24HOUR string `json:"CHANGEPCT24HOUR"`
CHANGE24HOUR string `json:"CHANGE24HOUR"`
MKTCAP float64 `json:"MKTCAP"`
HIGHDAY float64 `json:"HIGHDAY"`
LOWDAY float64 `json:"LOWDAY"`
CHANGEPCTHOUR float64 `json:"CHANGEPCTHOUR"`
CHANGEPCTDAY float64 `json:"CHANGEPCTDAY"`
CHANGEPCT24HOUR float64 `json:"CHANGEPCT24HOUR"`
CHANGE24HOUR float64 `json:"CHANGE24HOUR"`
}
type TokenHistoricalPairs struct {
@ -61,7 +61,7 @@ type CoinsContainer struct {
}
type MarketValuesContainer struct {
Display map[string]map[string]MarketCoinValues `json:"Display"`
Raw map[string]map[string]MarketCoinValues `json:"Raw"`
}
func renameSymbols(symbols []string) (renames []string) {
@ -94,13 +94,14 @@ func chunkSymbols(symbols []string) [][]string {
return chunks
}
func fetchCryptoComparePrices(symbols []string, currency string) (map[string]float64, error) {
func fetchCryptoComparePrices(symbols []string, currencies []string) (map[string]map[string]float64, error) {
chunks := chunkSymbols(symbols)
result := make(map[string]float64)
result := make(map[string]map[string]float64)
realCurrencies := renameSymbols(currencies)
for _, smbls := range chunks {
realSymbols := renameSymbols(smbls)
httpClient := http.Client{Timeout: time.Minute}
url := fmt.Sprintf("%s/data/pricemulti?fsyms=%s&tsyms=%s&extraParams=Status.im", cryptocompareURL, strings.Join(realSymbols, ","), currency)
url := fmt.Sprintf("%s/data/pricemulti?fsyms=%s&tsyms=%s&extraParams=Status.im", cryptocompareURL, strings.Join(realSymbols, ","), strings.Join(realCurrencies, ","))
resp, err := httpClient.Get(url)
if err != nil {
return nil, err
@ -119,7 +120,10 @@ func fetchCryptoComparePrices(symbols []string, currency string) (map[string]flo
}
for _, symbol := range smbls {
result[symbol] = prices[getRealSymbol(symbol)][strings.ToUpper(currency)]
result[symbol] = map[string]float64{}
for _, currency := range currencies {
result[symbol][currency] = prices[getRealSymbol(symbol)][getRealSymbol(currency)]
}
}
}
return result, nil
@ -155,12 +159,13 @@ func fetchCryptoCompareTokenDetails(symbols []string) (map[string]Coin, error) {
return coins, nil
}
func fetchTokenMarketValues(symbols []string, currency string) (map[string]MarketCoinValues, error) {
func fetchTokenMarketValues(symbols []string, currencies []string) (map[string]map[string]MarketCoinValues, error) {
realCurrencies := renameSymbols(currencies)
realSymbols := renameSymbols(symbols)
item := map[string]MarketCoinValues{}
item := map[string]map[string]MarketCoinValues{}
httpClient := http.Client{Timeout: time.Minute}
url := fmt.Sprintf("%s/data/pricemultifull?fsyms=%s&tsyms=%s&extraParams=Status.im", cryptocompareURL, strings.Join(realSymbols, ","), currency)
url := fmt.Sprintf("%s/data/pricemultifull?fsyms=%s&tsyms=%s&extraParams=Status.im", cryptocompareURL, strings.Join(realSymbols, ","), strings.Join(realCurrencies, ","))
resp, err := httpClient.Get(url)
if err != nil {
return item, err
@ -179,7 +184,10 @@ func fetchTokenMarketValues(symbols []string, currency string) (map[string]Marke
}
for _, symbol := range symbols {
item[symbol] = container.Display[getRealSymbol(symbol)][strings.ToUpper(currency)]
item[symbol] = map[string]MarketCoinValues{}
for _, currency := range currencies {
item[symbol][currency] = container.Raw[getRealSymbol(symbol)][getRealSymbol(currency)]
}
}
return item, nil

View File

@ -20,6 +20,10 @@ import (
// WalletTickReload emitted every 15mn to reload the wallet balance and history
const EventWalletTickReload walletevent.EventType = "wallet-tick-reload"
func getFixedCurrencies() []string {
return []string{"usd"}
}
func NewReader(rpcClient *rpc.Client, tokenManager *token.Manager, accountsDB *accounts.Database, walletFeed *event.Feed) *Reader {
return &Reader{rpcClient, tokenManager, accountsDB, walletFeed, nil}
}
@ -32,6 +36,17 @@ type Reader struct {
cancel context.CancelFunc
}
type TokenMarketValues struct {
MarketCap float64 `json:"marketCap"`
HighDay float64 `json:"highDay"`
LowDay float64 `json:"lowDay"`
ChangePctHour float64 `json:"changePctHour"`
ChangePctDay float64 `json:"changePctDay"`
ChangePct24hour float64 `json:"changePct24hour"`
Change24hour float64 `json:"change24hour"`
Price float64 `json:"price"`
}
type ChainBalance struct {
Balance *big.Float `json:"balance"`
Address common.Address `json:"address"`
@ -39,22 +54,16 @@ type ChainBalance struct {
}
type Token struct {
Name string `json:"name"`
Symbol string `json:"symbol"`
Color string `json:"color"`
Decimals uint `json:"decimals"`
BalancesPerChain map[uint64]ChainBalance `json:"balancesPerChain"`
Description string `json:"description"`
AssetWebsiteURL string `json:"assetWebsiteUrl"`
BuiltOn string `json:"builtOn"`
MarketCap string `json:"marketCap"`
HighDay string `json:"highDay"`
LowDay string `json:"lowDay"`
ChangePctHour string `json:"changePctHour"`
ChangePctDay string `json:"changePctDay"`
ChangePct24hour string `json:"changePct24hour"`
Change24hour string `json:"change24hour"`
CurrencyPrice float64 `json:"currencyPrice"`
Name string `json:"name"`
Symbol string `json:"symbol"`
Color string `json:"color"`
Decimals uint `json:"decimals"`
BalancesPerChain map[uint64]ChainBalance `json:"balancesPerChain"`
Description string `json:"description"`
AssetWebsiteURL string `json:"assetWebsiteUrl"`
BuiltOn string `json:"builtOn"`
MarketValuesPerCurrency map[string]TokenMarketValues `json:"marketValuesPerCurrency"`
PegSymbol string `json:"pegSymbol"`
}
func getTokenBySymbols(tokens []*token.Token) map[string][]*token.Token {
@ -130,10 +139,13 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
chainIDs = append(chainIDs, network.ChainID)
}
currencies := make([]string, 0)
currency, err := r.accountsDB.GetCurrency()
if err != nil {
return nil, err
}
currencies = append(currencies, currency)
currencies = append(currencies, getFixedCurrencies()...)
allTokens, err := r.tokenManager.GetAllTokens()
if err != nil {
@ -148,14 +160,14 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
var (
group = async.NewAtomicGroup(ctx)
prices = map[string]float64{}
prices = map[string]map[string]float64{}
tokenDetails = map[string]Coin{}
tokenMarketValues = map[string]MarketCoinValues{}
tokenMarketValues = map[string]map[string]MarketCoinValues{}
balances = map[uint64]map[common.Address]map[common.Address]*hexutil.Big{}
)
group.Add(func(parent context.Context) error {
prices, err = fetchCryptoComparePrices(tokenSymbols, currency)
prices, err = fetchCryptoComparePrices(tokenSymbols, currencies)
if err != nil {
return err
}
@ -171,7 +183,7 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
})
group.Add(func(parent context.Context) error {
tokenMarketValues, err = fetchTokenMarketValues(tokenSymbols, currency)
tokenMarketValues, err = fetchTokenMarketValues(tokenSymbols, currencies)
if err != nil {
return err
}
@ -221,23 +233,31 @@ func (r *Reader) GetWalletToken(ctx context.Context, addresses []common.Address)
}
}
marketValuesPerCurrency := make(map[string]TokenMarketValues)
for _, currency := range currencies {
marketValuesPerCurrency[currency] = TokenMarketValues{
MarketCap: tokenMarketValues[symbol][currency].MKTCAP,
HighDay: tokenMarketValues[symbol][currency].HIGHDAY,
LowDay: tokenMarketValues[symbol][currency].LOWDAY,
ChangePctHour: tokenMarketValues[symbol][currency].CHANGEPCTHOUR,
ChangePctDay: tokenMarketValues[symbol][currency].CHANGEPCTDAY,
ChangePct24hour: tokenMarketValues[symbol][currency].CHANGEPCT24HOUR,
Change24hour: tokenMarketValues[symbol][currency].CHANGE24HOUR,
Price: prices[symbol][currency],
}
}
walletToken := Token{
Name: tokens[0].Name,
Color: tokens[0].Color,
Symbol: symbol,
BalancesPerChain: balancesPerChain,
Decimals: decimals,
Description: tokenDetails[symbol].Description,
AssetWebsiteURL: tokenDetails[symbol].AssetWebsiteURL,
BuiltOn: tokenDetails[symbol].BuiltOn,
MarketCap: tokenMarketValues[symbol].MKTCAP,
HighDay: tokenMarketValues[symbol].HIGHDAY,
LowDay: tokenMarketValues[symbol].LOWDAY,
ChangePctHour: tokenMarketValues[symbol].CHANGEPCTHOUR,
ChangePctDay: tokenMarketValues[symbol].CHANGEPCTDAY,
ChangePct24hour: tokenMarketValues[symbol].CHANGEPCT24HOUR,
Change24hour: tokenMarketValues[symbol].CHANGE24HOUR,
CurrencyPrice: prices[symbol],
Name: tokens[0].Name,
Color: tokens[0].Color,
Symbol: symbol,
BalancesPerChain: balancesPerChain,
Decimals: decimals,
Description: tokenDetails[symbol].Description,
AssetWebsiteURL: tokenDetails[symbol].AssetWebsiteURL,
BuiltOn: tokenDetails[symbol].BuiltOn,
MarketValuesPerCurrency: marketValuesPerCurrency,
PegSymbol: tokens[0].PegSymbol,
}
result[address] = append(result[address], walletToken)

View File

@ -399,10 +399,14 @@ func (r *Router) suggestedRoutes(
return nil, err
}
prices, err := fetchCryptoComparePrices([]string{"ETH", tokenSymbol}, "USD")
pricesMap, err := fetchCryptoComparePrices([]string{"ETH", tokenSymbol}, []string{"USD"})
if err != nil {
return nil, err
}
prices := make(map[string]float64, 0)
for symbol, pricePerCurrency := range pricesMap {
prices[symbol] = pricePerCurrency["USD"]
}
var (
group = async.NewAtomicGroup(ctx)

View File

@ -34,6 +34,10 @@ type Token struct {
// to be traded.
Decimals uint `json:"decimals"`
ChainID uint64 `json:"chainId"`
// PegSymbol indicates that the token is pegged to some fiat currency, using the
// ISO 4217 alphabetic code. For example, an empty string means it is not
// pegged, while "USD" means it's pegged to the United States Dollar.
PegSymbol string `json:"pegSymbol"`
}
func (t *Token) IsNative() bool {

View File

@ -5,20 +5,22 @@ import "github.com/ethereum/go-ethereum/common"
var tokenStore = map[uint64]map[common.Address]*Token{
1: {
common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f"): &Token{
Address: common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f"),
Name: "Dai Stablecoin",
Symbol: "DAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f"),
Name: "Dai Stablecoin",
Symbol: "DAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"): &Token{
Address: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
Name: "Sai Stablecoin v1.0",
Symbol: "SAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"),
Name: "Sai Stablecoin v1.0",
Symbol: "SAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"): &Token{
Address: common.HexToAddress("0x9f8f72aa9304c8b593d555f12ef6589cc3a579a2"),
@ -725,12 +727,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"): &Token{
Address: common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
Address: common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0x58b6a8a3302369daec383334672404ee733ab239"): &Token{
Address: common.HexToAddress("0x58b6a8a3302369daec383334672404ee733ab239"),
@ -861,12 +864,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x8E870D67F660D95d5be530380D0eC0bd388289E1"): &Token{
Address: common.HexToAddress("0x8E870D67F660D95d5be530380D0eC0bd388289E1"),
Name: "Pax Dollar",
Symbol: "USDP",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x8E870D67F660D95d5be530380D0eC0bd388289E1"),
Name: "Pax Dollar",
Symbol: "USDP",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0xEA26c4aC16D4a5A106820BC8AEE85fd0b7b2b664"): &Token{
Address: common.HexToAddress("0xEA26c4aC16D4a5A106820BC8AEE85fd0b7b2b664"),
@ -877,12 +881,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x45804880De22913dAFE09f4980848ECE6EcbAf78"): &Token{
Address: common.HexToAddress("0x45804880De22913dAFE09f4980848ECE6EcbAf78"),
Name: "Paxos Gold",
Symbol: "PAXG",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x45804880De22913dAFE09f4980848ECE6EcbAf78"),
Name: "Paxos Gold",
Symbol: "PAXG",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "XAU",
},
common.HexToAddress("0x865ec58b06bF6305B886793AA20A2da31D034E68"): &Token{
Address: common.HexToAddress("0x865ec58b06bF6305B886793AA20A2da31D034E68"),
@ -933,12 +938,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x00000100F2A2bd000715001920eB70D229700085"): &Token{
Address: common.HexToAddress("0x00000100F2A2bd000715001920eB70D229700085"),
Name: "TrueCAD",
Symbol: "TCAD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x00000100F2A2bd000715001920eB70D229700085"),
Name: "TrueCAD",
Symbol: "TCAD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "CAD",
},
common.HexToAddress("0x6710c63432A2De02954fc0f851db07146a6c0312"): &Token{
Address: common.HexToAddress("0x6710c63432A2De02954fc0f851db07146a6c0312"),
@ -973,12 +979,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x0000000000085d4780B73119b644AE5ecd22b376"): &Token{
Address: common.HexToAddress("0x0000000000085d4780B73119b644AE5ecd22b376"),
Name: "TrueUSD",
Symbol: "TUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x0000000000085d4780B73119b644AE5ecd22b376"),
Name: "TrueUSD",
Symbol: "TUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0xD0a4b8946Cb52f0661273bfbC6fD0E0C75Fc6433"): &Token{
Address: common.HexToAddress("0xD0a4b8946Cb52f0661273bfbC6fD0E0C75Fc6433"),
@ -997,12 +1004,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x00000000441378008EA67F4284A57932B1c000a5"): &Token{
Address: common.HexToAddress("0x00000000441378008EA67F4284A57932B1c000a5"),
Name: "TrueGBP",
Symbol: "TGBP",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x00000000441378008EA67F4284A57932B1c000a5"),
Name: "TrueGBP",
Symbol: "TGBP",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "GBP",
},
common.HexToAddress("0xbf2179859fc6D5BEE9Bf9158632Dc51678a4100e"): &Token{
Address: common.HexToAddress("0xbf2179859fc6D5BEE9Bf9158632Dc51678a4100e"),
@ -1037,12 +1045,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"): &Token{
Address: common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
Name: "Tether USD",
Symbol: "USDT",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
Address: common.HexToAddress("0xdAC17F958D2ee523a2206206994597C13D831ec7"),
Name: "Tether USD",
Symbol: "USDT",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0xa3d58c4E56fedCae3a7c43A725aeE9A71F0ece4e"): &Token{
Address: common.HexToAddress("0xa3d58c4E56fedCae3a7c43A725aeE9A71F0ece4e"),
@ -1077,12 +1086,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x00006100F7090010005F1bd7aE6122c3C2CF0090"): &Token{
Address: common.HexToAddress("0x00006100F7090010005F1bd7aE6122c3C2CF0090"),
Name: "TrueAUD",
Symbol: "TAUD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x00006100F7090010005F1bd7aE6122c3C2CF0090"),
Name: "TrueAUD",
Symbol: "TAUD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "AUD",
},
common.HexToAddress("0x66497A283E0a007bA3974e837784C6AE323447de"): &Token{
Address: common.HexToAddress("0x66497A283E0a007bA3974e837784C6AE323447de"),
@ -1165,12 +1175,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0xA4Bdb11dc0a2bEC88d24A3aa1E6Bb17201112eBe"): &Token{
Address: common.HexToAddress("0xA4Bdb11dc0a2bEC88d24A3aa1E6Bb17201112eBe"),
Name: "StableUSD",
Symbol: "USDS",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
Address: common.HexToAddress("0xA4Bdb11dc0a2bEC88d24A3aa1E6Bb17201112eBe"),
Name: "StableUSD",
Symbol: "USDS",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0xB98d4C97425d9908E66E53A6fDf673ACcA0BE986"): &Token{
Address: common.HexToAddress("0xB98d4C97425d9908E66E53A6fDf673ACcA0BE986"),
@ -1229,12 +1240,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"): &Token{
Address: common.HexToAddress("0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"),
Name: "Synth sUSD",
Symbol: "sUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
Address: common.HexToAddress("0x57Ab1ec28D129707052df4dF418D58a2D46d5f51"),
Name: "Synth sUSD",
Symbol: "sUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"): &Token{
Address: common.HexToAddress("0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643"),
@ -1293,12 +1305,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 1,
},
common.HexToAddress("0x9ba00d6856a4edf4665bca2c2309936572473b7e"): &Token{
Address: common.HexToAddress("0x9ba00d6856a4edf4665bca2c2309936572473b7e"),
Name: "Aave Interest bearing USDC",
Symbol: "aUSDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
Address: common.HexToAddress("0x9ba00d6856a4edf4665bca2c2309936572473b7e"),
Name: "Aave Interest bearing USDC",
Symbol: "aUSDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 1,
PegSymbol: "USD",
},
common.HexToAddress("0xc944e90c64b2c07662a292be6244bdf05cda44a7"): &Token{
Address: common.HexToAddress("0xc944e90c64b2c07662a292be6244bdf05cda44a7"),
@ -1451,12 +1464,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 5,
},
common.HexToAddress("0x98339d8c260052b7ad81c28c16c0b98420f2b46a"): &Token{
Address: common.HexToAddress("0x98339d8c260052b7ad81c28c16c0b98420f2b46a"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 5,
Address: common.HexToAddress("0x98339d8c260052b7ad81c28c16c0b98420f2b46a"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 5,
PegSymbol: "USD",
},
common.HexToAddress("0x022e292b44b5a146f2e8ee36ff44d3dd863c915c"): &Token{
Address: common.HexToAddress("0x022e292b44b5a146f2e8ee36ff44d3dd863c915c"),
@ -1485,12 +1499,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
},
10: {
common.HexToAddress("0x7f5c764cbc14f9669b88837ca1490cca17c31607"): &Token{
Address: common.HexToAddress("0x7f5c764cbc14f9669b88837ca1490cca17c31607"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 10,
Address: common.HexToAddress("0x7f5c764cbc14f9669b88837ca1490cca17c31607"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 10,
PegSymbol: "USD",
},
},
100: {
@ -1505,38 +1520,42 @@ var tokenStore = map[uint64]map[common.Address]*Token{
},
420: {
common.HexToAddress("0xcb4ceefce514b2d910d3ac529076d18e3add3775"): &Token{
Address: common.HexToAddress("0xcb4ceefce514b2d910d3ac529076d18e3add3775"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 420,
Address: common.HexToAddress("0xcb4ceefce514b2d910d3ac529076d18e3add3775"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 420,
PegSymbol: "USD",
},
},
42161: {
common.HexToAddress("0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"): &Token{
Address: common.HexToAddress("0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"),
Name: "Tether USD",
Symbol: "USDT",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
Address: common.HexToAddress("0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"),
Name: "Tether USD",
Symbol: "USDT",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
PegSymbol: "USD",
},
common.HexToAddress("0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"): &Token{
Address: common.HexToAddress("0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 42161,
Address: common.HexToAddress("0xff970a61a04b1ca14834a43f5de4533ebddb5cc8"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 42161,
PegSymbol: "USD",
},
common.HexToAddress("0xda10009cbd5d07dd0cecc66161fc93d7c9000da1"): &Token{
Address: common.HexToAddress("0xda10009cbd5d07dd0cecc66161fc93d7c9000da1"),
Name: "DAI Stablecoin",
Symbol: "DAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
Address: common.HexToAddress("0xda10009cbd5d07dd0cecc66161fc93d7c9000da1"),
Name: "DAI Stablecoin",
Symbol: "DAI",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
PegSymbol: "USD",
},
common.HexToAddress("0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f"): &Token{
Address: common.HexToAddress("0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f"),
@ -1571,12 +1590,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 42161,
},
common.HexToAddress("0x4d15a3a2286d883af0aa1b3f21367843fac63e07"): &Token{
Address: common.HexToAddress("0x4d15a3a2286d883af0aa1b3f21367843fac63e07"),
Name: "True USD",
Symbol: "TUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
Address: common.HexToAddress("0x4d15a3a2286d883af0aa1b3f21367843fac63e07"),
Name: "True USD",
Symbol: "TUSD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
PegSymbol: "USD",
},
common.HexToAddress("0x23a941036ae778ac51ab04cea08ed6e2fe103614"): &Token{
Address: common.HexToAddress("0x23a941036ae778ac51ab04cea08ed6e2fe103614"),
@ -1587,12 +1607,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
ChainID: 42161,
},
common.HexToAddress("0x680447595e8b7b3aa1b43beb9f6098c79ac2ab3f"): &Token{
Address: common.HexToAddress("0x680447595e8b7b3aa1b43beb9f6098c79ac2ab3f"),
Name: "Decentralized USD",
Symbol: "USDD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
Address: common.HexToAddress("0x680447595e8b7b3aa1b43beb9f6098c79ac2ab3f"),
Name: "Decentralized USD",
Symbol: "USDD",
Color: "#f8f8f8",
Decimals: 18,
ChainID: 42161,
PegSymbol: "USD",
},
common.HexToAddress("0x11cdb42b0eb46d95f990bedd4695a6e3fa034978"): &Token{
Address: common.HexToAddress("0x11cdb42b0eb46d95f990bedd4695a6e3fa034978"),
@ -1605,12 +1626,13 @@ var tokenStore = map[uint64]map[common.Address]*Token{
},
421613: {
common.HexToAddress("0x17078F231AA8dc256557b49a8f2F72814A71f633"): &Token{
Address: common.HexToAddress("0x17078F231AA8dc256557b49a8f2F72814A71f633"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 421613,
Address: common.HexToAddress("0x17078F231AA8dc256557b49a8f2F72814A71f633"),
Name: "USD Coin",
Symbol: "USDC",
Color: "#f8f8f8",
Decimals: 6,
ChainID: 421613,
PegSymbol: "USD",
},
},
}

23
vendor/github.com/rmg/iso4217/.gitignore generated vendored Normal file
View File

@ -0,0 +1,23 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test

21
vendor/github.com/rmg/iso4217/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Ryan Graham
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

5
vendor/github.com/rmg/iso4217/Makefile generated vendored Normal file
View File

@ -0,0 +1,5 @@
test: constants.go
go test -v
constants.go: src/iso4217-table.xml src/update.go
go run src/update.go < src/iso4217-table.xml | gofmt > $@

6
vendor/github.com/rmg/iso4217/README.md generated vendored Normal file
View File

@ -0,0 +1,6 @@
iso4217
=======
[![Go Reference](https://pkg.go.dev/badge/github.com/rmg/iso4217.svg)](https://pkg.go.dev/github.com/rmg/iso4217)
Golang convenience library containing ISO 4217 currency codes

570
vendor/github.com/rmg/iso4217/constants.go generated vendored Normal file
View File

@ -0,0 +1,570 @@
// Package iso4217 is a convenience library containing ISO 4217 currency codes
package iso4217
var names = map[int]string{
0: "",
8: "ALL",
12: "DZD",
32: "ARS",
36: "AUD",
44: "BSD",
48: "BHD",
50: "BDT",
51: "AMD",
52: "BBD",
60: "BMD",
64: "BTN",
68: "BOB",
72: "BWP",
84: "BZD",
90: "SBD",
96: "BND",
104: "MMK",
108: "BIF",
116: "KHR",
124: "CAD",
132: "CVE",
136: "KYD",
144: "LKR",
152: "CLP",
156: "CNY",
170: "COP",
174: "KMF",
188: "CRC",
191: "HRK",
192: "CUP",
203: "CZK",
208: "DKK",
214: "DOP",
222: "SVC",
230: "ETB",
232: "ERN",
238: "FKP",
242: "FJD",
262: "DJF",
270: "GMD",
292: "GIP",
320: "GTQ",
324: "GNF",
328: "GYD",
332: "HTG",
340: "HNL",
344: "HKD",
348: "HUF",
352: "ISK",
356: "INR",
360: "IDR",
364: "IRR",
368: "IQD",
376: "ILS",
388: "JMD",
392: "JPY",
398: "KZT",
400: "JOD",
404: "KES",
408: "KPW",
410: "KRW",
414: "KWD",
417: "KGS",
418: "LAK",
422: "LBP",
426: "LSL",
430: "LRD",
434: "LYD",
446: "MOP",
454: "MWK",
458: "MYR",
462: "MVR",
480: "MUR",
484: "MXN",
496: "MNT",
498: "MDL",
504: "MAD",
512: "OMR",
516: "NAD",
524: "NPR",
532: "ANG",
533: "AWG",
548: "VUV",
554: "NZD",
558: "NIO",
566: "NGN",
578: "NOK",
586: "PKR",
590: "PAB",
598: "PGK",
600: "PYG",
604: "PEN",
608: "PHP",
634: "QAR",
643: "RUB",
646: "RWF",
654: "SHP",
682: "SAR",
690: "SCR",
694: "SLL",
702: "SGD",
704: "VND",
706: "SOS",
710: "ZAR",
728: "SSP",
748: "SZL",
752: "SEK",
756: "CHF",
760: "SYP",
764: "THB",
776: "TOP",
780: "TTD",
784: "AED",
788: "TND",
800: "UGX",
807: "MKD",
818: "EGP",
826: "GBP",
834: "TZS",
840: "USD",
858: "UYU",
860: "UZS",
882: "WST",
886: "YER",
901: "TWD",
925: "SLE",
926: "VED",
927: "UYW",
928: "VES",
929: "MRU",
930: "STN",
931: "CUC",
932: "ZWL",
933: "BYN",
934: "TMT",
936: "GHS",
938: "SDG",
940: "UYI",
941: "RSD",
943: "MZN",
944: "AZN",
946: "RON",
947: "CHE",
948: "CHW",
949: "TRY",
950: "XAF",
951: "XCD",
952: "XOF",
953: "XPF",
955: "XBA",
956: "XBB",
957: "XBC",
958: "XBD",
959: "XAU",
960: "XDR",
961: "XAG",
962: "XPT",
963: "XTS",
964: "XPD",
965: "XUA",
967: "ZMW",
968: "SRD",
969: "MGA",
970: "COU",
971: "AFN",
972: "TJS",
973: "AOA",
975: "BGN",
976: "CDF",
977: "BAM",
978: "EUR",
979: "MXV",
980: "UAH",
981: "GEL",
984: "BOV",
985: "PLN",
986: "BRL",
990: "CLF",
994: "XSU",
997: "USN",
999: "XXX",
}
var codes = map[string]int{
"": 0,
"ALL": 8,
"DZD": 12,
"ARS": 32,
"AUD": 36,
"BSD": 44,
"BHD": 48,
"BDT": 50,
"AMD": 51,
"BBD": 52,
"BMD": 60,
"BTN": 64,
"BOB": 68,
"BWP": 72,
"BZD": 84,
"SBD": 90,
"BND": 96,
"MMK": 104,
"BIF": 108,
"KHR": 116,
"CAD": 124,
"CVE": 132,
"KYD": 136,
"LKR": 144,
"CLP": 152,
"CNY": 156,
"COP": 170,
"KMF": 174,
"CRC": 188,
"HRK": 191,
"CUP": 192,
"CZK": 203,
"DKK": 208,
"DOP": 214,
"SVC": 222,
"ETB": 230,
"ERN": 232,
"FKP": 238,
"FJD": 242,
"DJF": 262,
"GMD": 270,
"GIP": 292,
"GTQ": 320,
"GNF": 324,
"GYD": 328,
"HTG": 332,
"HNL": 340,
"HKD": 344,
"HUF": 348,
"ISK": 352,
"INR": 356,
"IDR": 360,
"IRR": 364,
"IQD": 368,
"ILS": 376,
"JMD": 388,
"JPY": 392,
"KZT": 398,
"JOD": 400,
"KES": 404,
"KPW": 408,
"KRW": 410,
"KWD": 414,
"KGS": 417,
"LAK": 418,
"LBP": 422,
"LSL": 426,
"LRD": 430,
"LYD": 434,
"MOP": 446,
"MWK": 454,
"MYR": 458,
"MVR": 462,
"MUR": 480,
"MXN": 484,
"MNT": 496,
"MDL": 498,
"MAD": 504,
"OMR": 512,
"NAD": 516,
"NPR": 524,
"ANG": 532,
"AWG": 533,
"VUV": 548,
"NZD": 554,
"NIO": 558,
"NGN": 566,
"NOK": 578,
"PKR": 586,
"PAB": 590,
"PGK": 598,
"PYG": 600,
"PEN": 604,
"PHP": 608,
"QAR": 634,
"RUB": 643,
"RWF": 646,
"SHP": 654,
"SAR": 682,
"SCR": 690,
"SLL": 694,
"SGD": 702,
"VND": 704,
"SOS": 706,
"ZAR": 710,
"SSP": 728,
"SZL": 748,
"SEK": 752,
"CHF": 756,
"SYP": 760,
"THB": 764,
"TOP": 776,
"TTD": 780,
"AED": 784,
"TND": 788,
"UGX": 800,
"MKD": 807,
"EGP": 818,
"GBP": 826,
"TZS": 834,
"USD": 840,
"UYU": 858,
"UZS": 860,
"WST": 882,
"YER": 886,
"TWD": 901,
"SLE": 925,
"VED": 926,
"UYW": 927,
"VES": 928,
"MRU": 929,
"STN": 930,
"CUC": 931,
"ZWL": 932,
"BYN": 933,
"TMT": 934,
"GHS": 936,
"SDG": 938,
"UYI": 940,
"RSD": 941,
"MZN": 943,
"AZN": 944,
"RON": 946,
"CHE": 947,
"CHW": 948,
"TRY": 949,
"XAF": 950,
"XCD": 951,
"XOF": 952,
"XPF": 953,
"XBA": 955,
"XBB": 956,
"XBC": 957,
"XBD": 958,
"XAU": 959,
"XDR": 960,
"XAG": 961,
"XPT": 962,
"XTS": 963,
"XPD": 964,
"XUA": 965,
"ZMW": 967,
"SRD": 968,
"MGA": 969,
"COU": 970,
"AFN": 971,
"TJS": 972,
"AOA": 973,
"BGN": 975,
"CDF": 976,
"BAM": 977,
"EUR": 978,
"MXV": 979,
"UAH": 980,
"GEL": 981,
"BOV": 984,
"PLN": 985,
"BRL": 986,
"CLF": 990,
"XSU": 994,
"USN": 997,
"XXX": 999,
}
var minorUnits = map[int]int{
0: 0,
8: 2,
12: 2,
32: 2,
36: 2,
44: 2,
48: 3,
50: 2,
51: 2,
52: 2,
60: 2,
64: 2,
68: 2,
72: 2,
84: 2,
90: 2,
96: 2,
104: 2,
108: 0,
116: 2,
124: 2,
132: 2,
136: 2,
144: 2,
152: 0,
156: 2,
170: 2,
174: 0,
188: 2,
191: 2,
192: 2,
203: 2,
208: 2,
214: 2,
222: 2,
230: 2,
232: 2,
238: 2,
242: 2,
262: 0,
270: 2,
292: 2,
320: 2,
324: 0,
328: 2,
332: 2,
340: 2,
344: 2,
348: 2,
352: 0,
356: 2,
360: 2,
364: 2,
368: 3,
376: 2,
388: 2,
392: 0,
398: 2,
400: 3,
404: 2,
408: 2,
410: 0,
414: 3,
417: 2,
418: 2,
422: 2,
426: 2,
430: 2,
434: 3,
446: 2,
454: 2,
458: 2,
462: 2,
480: 2,
484: 2,
496: 2,
498: 2,
504: 2,
512: 3,
516: 2,
524: 2,
532: 2,
533: 2,
548: 0,
554: 2,
558: 2,
566: 2,
578: 2,
586: 2,
590: 2,
598: 2,
600: 0,
604: 2,
608: 2,
634: 2,
643: 2,
646: 0,
654: 2,
682: 2,
690: 2,
694: 2,
702: 2,
704: 0,
706: 2,
710: 2,
728: 2,
748: 2,
752: 2,
756: 2,
760: 2,
764: 2,
776: 2,
780: 2,
784: 2,
788: 3,
800: 0,
807: 2,
818: 2,
826: 2,
834: 2,
840: 2,
858: 2,
860: 2,
882: 2,
886: 2,
901: 2,
925: 2,
926: 2,
927: 4,
928: 2,
929: 2,
930: 2,
931: 2,
932: 2,
933: 2,
934: 2,
936: 2,
938: 2,
940: 0,
941: 2,
943: 2,
944: 2,
946: 2,
947: 2,
948: 2,
949: 2,
950: 0,
951: 2,
952: 0,
953: 0,
955: 0,
956: 0,
957: 0,
958: 0,
959: 0,
960: 0,
961: 0,
962: 0,
963: 0,
964: 0,
965: 0,
967: 2,
968: 2,
969: 2,
970: 2,
971: 2,
972: 2,
973: 2,
975: 2,
976: 2,
977: 2,
978: 2,
979: 2,
980: 2,
981: 2,
984: 2,
985: 2,
986: 2,
990: 4,
994: 0,
997: 2,
999: 0,
}
// ByCode resolves the given code to the 3 character string and the number of
// minor unit digits to display for the given currency.
func ByCode(n int) (string, int) {
return names[n], minorUnits[n]
}
// ByName resolves the given name to the numeric code and the number of minor
// unit digits to display for the given currency.
func ByName(s string) (int, int) {
code := codes[s]
return code, minorUnits[code]
}

3
vendor/modules.txt vendored
View File

@ -865,6 +865,9 @@ github.com/rivo/uniseg
# github.com/rjeczalik/notify v0.9.2
## explicit
github.com/rjeczalik/notify
# github.com/rmg/iso4217 v1.0.0
## explicit; go 1.12
github.com/rmg/iso4217
# github.com/rs/cors v1.7.0
## explicit
github.com/rs/cors