Compare commits
4 Commits
a705443786
...
fe897cca84
| Author | SHA1 | Date | |
|---|---|---|---|
| fe897cca84 | |||
| 7eaa771eb4 | |||
| 72af514cf3 | |||
| 81ff6c4034 |
@ -7,26 +7,27 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
createAccountPath = "/api/v2/account/create"
|
||||
trackStatusPath = "/api/track"
|
||||
balancePathPrefix = "/api/account"
|
||||
trackPath = "/api/v2/account/status"
|
||||
tokenTransferPrefix = "/api/v2/token/transfer"
|
||||
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||
voucherDataPathPrefix = "/api/v1/token"
|
||||
SendSMSPrefix = "api/v1/external/upsell"
|
||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||
poolSwapPrefix = "/api/v2/pool/swap"
|
||||
topPoolsPrefix = "/api/v1/pool/top"
|
||||
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||
poolSwappableVouchersPrefix = "/api/v1/pool"
|
||||
AliasRegistrationPrefix = "/api/v1/internal/register"
|
||||
AliasResolverPrefix = "/api/v1/resolve"
|
||||
ExternalSMSPrefix = "/api/v1/external"
|
||||
AliasUpdatePrefix = "/api/v1/internal/update"
|
||||
CreditSendPrefix = "/api/v1/credit-send"
|
||||
createAccountPath = "/api/v2/account/create"
|
||||
trackStatusPath = "/api/track"
|
||||
balancePathPrefix = "/api/account"
|
||||
trackPath = "/api/v2/account/status"
|
||||
tokenTransferPrefix = "/api/v2/token/transfer"
|
||||
voucherHoldingsPathPrefix = "/api/v1/holdings"
|
||||
voucherTransfersPathPrefix = "/api/v1/transfers/last10"
|
||||
voucherDataPathPrefix = "/api/v1/token"
|
||||
SendSMSPrefix = "api/v1/external/upsell"
|
||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||
poolSwapPrefix = "/api/v2/pool/swap"
|
||||
topPoolsPrefix = "/api/v1/pool/top"
|
||||
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||
poolSwappableVouchersPrefix = "/api/v1/pool"
|
||||
AliasRegistrationPrefix = "/api/v1/internal/register"
|
||||
AliasResolverPrefix = "/api/v1/resolve"
|
||||
ExternalSMSPrefix = "/api/v1/external"
|
||||
AliasUpdatePrefix = "/api/v1/internal/update"
|
||||
CreditSendPrefix = "/api/v1/credit-send"
|
||||
CreditSendReverseQuotePrefix = "/api/v1/pool/reverse-quote"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -39,26 +40,27 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
CreateAccountURL string
|
||||
TrackStatusURL string
|
||||
BalanceURL string
|
||||
TrackURL string
|
||||
TokenTransferURL string
|
||||
VoucherHoldingsURL string
|
||||
VoucherTransfersURL string
|
||||
VoucherDataURL string
|
||||
PoolDepositURL string
|
||||
PoolSwapQuoteURL string
|
||||
PoolSwapURL string
|
||||
TopPoolsURL string
|
||||
RetrievePoolDetailsURL string
|
||||
PoolSwappableVouchersURL string
|
||||
SendSMSURL string
|
||||
AliasRegistrationURL string
|
||||
AliasResolverURL string
|
||||
ExternalSMSURL string
|
||||
AliasUpdateURL string
|
||||
CreditSendURL string
|
||||
CreateAccountURL string
|
||||
TrackStatusURL string
|
||||
BalanceURL string
|
||||
TrackURL string
|
||||
TokenTransferURL string
|
||||
VoucherHoldingsURL string
|
||||
VoucherTransfersURL string
|
||||
VoucherDataURL string
|
||||
PoolDepositURL string
|
||||
PoolSwapQuoteURL string
|
||||
PoolSwapURL string
|
||||
TopPoolsURL string
|
||||
RetrievePoolDetailsURL string
|
||||
PoolSwappableVouchersURL string
|
||||
SendSMSURL string
|
||||
AliasRegistrationURL string
|
||||
AliasResolverURL string
|
||||
ExternalSMSURL string
|
||||
AliasUpdateURL string
|
||||
CreditSendURL string
|
||||
CreditSendReverseQuoteURL string
|
||||
)
|
||||
|
||||
func setBase() error {
|
||||
@ -108,6 +110,7 @@ func LoadConfig() error {
|
||||
ExternalSMSURL, _ = url.JoinPath(externalSMSBase, ExternalSMSPrefix)
|
||||
AliasUpdateURL, _ = url.JoinPath(aliasEnsURLBase, AliasUpdatePrefix)
|
||||
CreditSendURL, _ = url.JoinPath(dataURLBase, CreditSendPrefix)
|
||||
CreditSendReverseQuoteURL, _ = url.JoinPath(dataURLBase, CreditSendReverseQuotePrefix)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -914,3 +914,10 @@ func (das *DevAccountService) GetCreditSendMaxLimit(ctx context.Context, poolAdd
|
||||
MaxSAT: "3507692",
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (das *DevAccountService) GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error) {
|
||||
return &models.CreditSendReverseQouteResult{
|
||||
InputAmount: "3076923",
|
||||
OutputAmount: "40000000",
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -25,3 +25,8 @@ type CreditSendLimitsResult struct {
|
||||
MaxRAT string `json:"maxRAT"`
|
||||
MaxSAT string `json:"maxSAT"`
|
||||
}
|
||||
|
||||
type CreditSendReverseQouteResult struct {
|
||||
InputAmount string `json:"inputAmount"`
|
||||
OutputAmount string `json:"outputAmount"`
|
||||
}
|
||||
|
||||
@ -31,4 +31,5 @@ type AccountService interface {
|
||||
GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error)
|
||||
CheckTokenInPool(ctx context.Context, poolAddress, tokenAddress string) (*models.TokenInPoolResult, error)
|
||||
GetCreditSendMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.CreditSendLimitsResult, error)
|
||||
GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error)
|
||||
}
|
||||
|
||||
@ -762,6 +762,26 @@ func (as *HTTPAccountService) GetCreditSendMaxLimit(ctx context.Context, poolAdd
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
// GetCreditSendReverseQuote calls the API to getthe reverse quote for sending RAT amount
|
||||
func (as *HTTPAccountService) GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error) {
|
||||
var r models.CreditSendReverseQouteResult
|
||||
|
||||
ep, err := url.JoinPath(config.CreditSendReverseQuoteURL, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req, err := http.NewRequest("GET", ep, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = doRequest(ctx, req, &r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &r, nil
|
||||
}
|
||||
|
||||
// TODO: remove eth-custodial api dependency
|
||||
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
|
||||
var okResponse api.OKResponse
|
||||
|
||||
@ -125,3 +125,8 @@ func (m MockAccountService) GetCreditSendMaxLimit(ctx context.Context, poolAddre
|
||||
args := m.Called(poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
||||
return args.Get(0).(*models.CreditSendLimitsResult), args.Error(1)
|
||||
}
|
||||
|
||||
func (m MockAccountService) GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error) {
|
||||
args := m.Called(poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount)
|
||||
return args.Get(0).(*models.CreditSendReverseQouteResult), args.Error(1)
|
||||
}
|
||||
|
||||
@ -128,3 +128,7 @@ func (m TestAccountService) CheckTokenInPool(ctx context.Context, poolAddress, t
|
||||
func (m TestAccountService) GetCreditSendMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.CreditSendLimitsResult, error) {
|
||||
return &models.CreditSendLimitsResult{}, nil
|
||||
}
|
||||
|
||||
func (m TestAccountService) GetCreditSendReverseQuote(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, toTokenAMount string) (*models.CreditSendReverseQouteResult, error) {
|
||||
return &models.CreditSendReverseQouteResult{}, nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user