Compare commits
4 Commits
a705443786
...
fe897cca84
| Author | SHA1 | Date | |
|---|---|---|---|
| fe897cca84 | |||
| 7eaa771eb4 | |||
| 72af514cf3 | |||
| 81ff6c4034 |
@ -27,6 +27,7 @@ const (
|
||||
ExternalSMSPrefix = "/api/v1/external"
|
||||
AliasUpdatePrefix = "/api/v1/internal/update"
|
||||
CreditSendPrefix = "/api/v1/credit-send"
|
||||
CreditSendReverseQuotePrefix = "/api/v1/pool/reverse-quote"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -59,6 +60,7 @@ var (
|
||||
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