Compare commits
2 Commits
06a7ddea6f
...
720fa94b56
| Author | SHA1 | Date | |
|---|---|---|---|
| 720fa94b56 | |||
| ee04552cbb |
@ -19,6 +19,8 @@ const (
|
|||||||
poolDepositPrefix = "/api/v2/pool/deposit"
|
poolDepositPrefix = "/api/v2/pool/deposit"
|
||||||
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
poolSwapQoutePrefix = "/api/v2/pool/quote"
|
||||||
poolSwapPrefix = "/api/v2/pool/swap"
|
poolSwapPrefix = "/api/v2/pool/swap"
|
||||||
|
topPoolsPrefix = "/api/v1/pool/top"
|
||||||
|
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -28,18 +30,20 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
CreateAccountURL string
|
CreateAccountURL string
|
||||||
TrackStatusURL string
|
TrackStatusURL string
|
||||||
BalanceURL string
|
BalanceURL string
|
||||||
TrackURL string
|
TrackURL string
|
||||||
TokenTransferURL string
|
TokenTransferURL string
|
||||||
VoucherHoldingsURL string
|
VoucherHoldingsURL string
|
||||||
VoucherTransfersURL string
|
VoucherTransfersURL string
|
||||||
VoucherDataURL string
|
VoucherDataURL string
|
||||||
CheckAliasURL string
|
CheckAliasURL string
|
||||||
PoolDepositURL string
|
PoolDepositURL string
|
||||||
PoolSwapQuoteURL string
|
PoolSwapQuoteURL string
|
||||||
PoolSwapURL string
|
PoolSwapURL string
|
||||||
|
TopPoolsURL string
|
||||||
|
RetrievePoolDetailsURL string
|
||||||
)
|
)
|
||||||
|
|
||||||
func setBase() error {
|
func setBase() error {
|
||||||
@ -78,6 +82,8 @@ func LoadConfig() error {
|
|||||||
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
PoolDepositURL, _ = url.JoinPath(custodialURLBase, poolDepositPrefix)
|
||||||
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
PoolSwapQuoteURL, _ = url.JoinPath(custodialURLBase, poolSwapQoutePrefix)
|
||||||
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
||||||
|
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
||||||
|
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -241,7 +241,48 @@ func resolveAliasAddress(ctx context.Context, alias string) (*models.AliasAddres
|
|||||||
|
|
||||||
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
func (as *HTTPAccountService) FetchTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return svc.FetchTopPools(ctx)
|
if as.UseApi {
|
||||||
|
return fetchCustodialTopPools(ctx)
|
||||||
|
} else {
|
||||||
|
return svc.FetchTopPools(ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func fetchCustodialTopPools(ctx context.Context) ([]dataserviceapi.PoolDetails, error) {
|
||||||
|
var r struct {
|
||||||
|
TopPools []dataserviceapi.PoolDetails `json:"topPools"`
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", config.TopPoolsURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
return r.TopPools, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (as *HTTPAccountService) RetrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
if as.UseApi {
|
||||||
|
return retrievePoolDetails(ctx, sym)
|
||||||
|
} else {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func retrievePoolDetails(ctx context.Context, sym string) (*dataserviceapi.PoolDetails, error) {
|
||||||
|
var r dataserviceapi.PoolDetails
|
||||||
|
|
||||||
|
ep, err := url.JoinPath(config.RetrievePoolDetailsURL, sym)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
req, err := http.NewRequest("GET", ep, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
_, err = doRequest(ctx, req, &r)
|
||||||
|
return &r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
func (as *HTTPAccountService) PoolDeposit(ctx context.Context, amount, from, poolAddress, tokenAddress string) (*models.PoolDepositResult, error) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user