status-go/services/wallet/onramp/provider_mercuryo.go

158 lines
24 KiB
Go

package onramp
import (
"context"
"crypto/sha512"
"errors"
"fmt"
"strings"
"sync"
"time"
"github.com/ethereum/go-ethereum/common"
walletCommon "github.com/status-im/status-go/services/wallet/common"
"github.com/status-im/status-go/services/wallet/thirdparty/mercuryo"
"github.com/status-im/status-go/services/wallet/token"
)
const mercuryoID = "mercuryo"
const mercuryioNoFeesBaseURL = "https://exchange.mercuryo.io/?type=buy&networks=ETHEREUM,ARBITRUM,OPTIMISM&currency=ETH"
const supportedAssetsUpdateInterval = 24 * time.Hour
type MercuryoProvider struct {
supportedTokens []*token.Token
supportedTokensTimestamp time.Time
supportedTokensLock sync.RWMutex
httpClient *mercuryo.Client
tokenManager token.ManagerInterface
}
func NewMercuryoProvider(tokenManager token.ManagerInterface) *MercuryoProvider {
return &MercuryoProvider{
httpClient: mercuryo.NewClient(),
tokenManager: tokenManager,
}
}
func (p *MercuryoProvider) ID() string {
return mercuryoID
}
func (p *MercuryoProvider) GetCryptoOnRamp(ctx context.Context) (CryptoOnRamp, error) {
const (
logoMercuryo = "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gKgSUNDX1BST0ZJTEUAAQEAAAKQbGNtcwQwAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwQVBQTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLWxjbXMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAtkZXNjAAABCAAAADhjcHJ0AAABQAAAAE53dHB0AAABkAAAABRjaGFkAAABpAAAACxyWFlaAAAB0AAAABRiWFlaAAAB5AAAABRnWFlaAAAB+AAAABRyVFJDAAACDAAAACBnVFJDAAACLAAAACBiVFJDAAACTAAAACBjaHJtAAACbAAAACRtbHVjAAAAAAAAAAEAAAAMZW5VUwAAABwAAAAcAHMAUgBHAEIAIABiAHUAaQBsAHQALQ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Uz0JMK25nDXVGpOPYKpj1Nj9S2ShdJJIjQY0JriKCZObtIHUn34qRO/+Zyn4KZh7AwX1r24o2axNzl2l2He88HIswYYAMAHXF50Si7mpiNgYHaynK3qE7X+p0Y/xHjMDwJhB0p8vJL6hADNy1bsaY4sJQLz2aj7PBcAwZfUIf5ThTDofMEE+TicuXXJMXkb9Ay/ccySVE4TCG0xE93ADXGFQDTr5kQuQIT/AOO//9k="
)
provider := CryptoOnRamp{
ID: mercuryoID,
Name: "Mercuryo",
Description: "Buy crypto within 15 seconds",
Fees: "4.5%",
LogoURL: logoMercuryo,
Hostname: "mercuryo.io",
SupportsSinglePurchase: true,
SupportsRecurrentPurchase: true,
SupportedChainIDs: []uint64{walletCommon.EthereumMainnet, walletCommon.ArbitrumMainnet, walletCommon.OptimismMainnet},
URLsNeedParameters: true,
SiteURL: mercuryioNoFeesBaseURL,
RecurrentSiteURL: mercuryioNoFeesBaseURL + "&widget_flow=recurrent",
}
var err error
provider.SupportedTokens, err = p.getSupportedCurrencies(ctx)
return provider, err
}
func (p *MercuryoProvider) getSupportedCurrencies(ctx context.Context) ([]*token.Token, error) {
p.supportedTokensLock.Lock()
defer p.supportedTokensLock.Unlock()
if time.Since(p.supportedTokensTimestamp) < supportedAssetsUpdateInterval {
return p.supportedTokens, nil
}
newSupportedCurrencies, err := p.httpClient.FetchCurrencies(ctx)
if err != nil {
return p.supportedTokens, err
}
newSupportedTokens := make([]*token.Token, 0, len(newSupportedCurrencies))
for _, currency := range newSupportedCurrencies {
chainID := mercuryo.NetworkToCommonChainID(currency.Network)
if chainID == walletCommon.UnknownChainID {
continue
}
token, isNative := p.tokenManager.LookupToken(&chainID, currency.Symbol)
if token == nil {
continue
}
if !isNative {
contractAddress := common.HexToAddress(currency.Contract)
if contractAddress != token.Address {
continue
}
}
newSupportedTokens = append(newSupportedTokens, token)
}
p.supportedTokens = newSupportedTokens
p.supportedTokensTimestamp = time.Now()
return p.supportedTokens, nil
}
// Should generate the SHA512 hash of the string "AddressKey"
func getMercuryoSignature(address common.Address, key string) string {
addressString := address.Hex()
hash := sha512.New()
hash.Write([]byte(addressString[:] + key))
return fmt.Sprintf("%x", hash.Sum(nil))
}
func getMercuryoCurrency(symbol string) string {
return strings.ToUpper(symbol)
}
func (p *MercuryoProvider) GetURL(ctx context.Context, parameters Parameters) (string, error) {
const (
baseURL = "https://exchange.mercuryo.io/?type=buy"
widgetID = "6a7eb330-2b09-49b7-8fd3-1c77cfb6cd47"
widgetSecret = "AZ5fmxmrgyrXH3zre6yHU2Vw9fPqEw82" // #nosec G101
)
if parameters.DestAddress == nil || *parameters.DestAddress == walletCommon.ZeroAddress() {
return "", errors.New("destination address is required")
}
if parameters.ChainID == nil || *parameters.ChainID == walletCommon.UnknownChainID {
return "", errors.New("chainID is required")
}
if parameters.Symbol == nil || *parameters.Symbol == "" {
return "", errors.New("symbol is required")
}
network := mercuryo.CommonChainIDToNetwork(*parameters.ChainID)
if network == "" {
return "", errors.New("unsupported chainID")
}
currency := getMercuryoCurrency(*parameters.Symbol)
if currency == "" {
return "", errors.New("unsupported symbol")
}
// TODO #16005: Move signature generation to proxy server
signature := getMercuryoSignature(*parameters.DestAddress, widgetSecret)
url := fmt.Sprintf("%s&network=%s&currency=%s&address=%s&hide_address=false&fix_address=true&signature=%s&widget_id=%s",
baseURL, network, currency, parameters.DestAddress.Hex(), signature, widgetID)
if parameters.IsRecurrent {
url = url + "&widget_flow=recurrent"
}
return url, nil
}