Compare commits
No commits in common. "80c2493e803b75829196201214d47208ab427ca2" and "720fa94b56d858788f0dd379d6083e9d68ac8d56" have entirely different histories.
80c2493e80
...
720fa94b56
@ -19,9 +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"
|
topPoolsPrefix = "/api/v1/pool/top"
|
||||||
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
retrievePoolDetailsPrefix = "/api/v1/pool/reverse"
|
||||||
poolSwappableVouchersPrefix = "/api/v1/pool"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -31,21 +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
|
TopPoolsURL string
|
||||||
RetrievePoolDetailsURL string
|
RetrievePoolDetailsURL string
|
||||||
PoolSwappableVouchersURL string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func setBase() error {
|
func setBase() error {
|
||||||
@ -86,7 +84,6 @@ func LoadConfig() error {
|
|||||||
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
PoolSwapURL, _ = url.JoinPath(custodialURLBase, poolSwapPrefix)
|
||||||
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
TopPoolsURL, _ = url.JoinPath(dataURLBase, topPoolsPrefix)
|
||||||
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
RetrievePoolDetailsURL, _ = url.JoinPath(dataURLBase, retrievePoolDetailsPrefix)
|
||||||
PoolSwappableVouchersURL, _ = url.JoinPath(dataURLBase, poolSwappableVouchersPrefix)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -339,56 +339,13 @@ func (as *HTTPAccountService) GetPoolSwapQuote(ctx context.Context, amount, from
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
if as.UseApi {
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return as.getPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
return svc.GetPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
||||||
} else {
|
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
|
||||||
return svc.GetPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (as *HTTPAccountService) getPoolSwappableFromVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
|
||||||
var r struct {
|
|
||||||
PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
|
|
||||||
}
|
|
||||||
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "from", publicKey)
|
|
||||||
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.PoolSwappableVouchers, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
func (as *HTTPAccountService) GetPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
if as.UseApi {
|
return svc.GetPoolSwappableVouchers(ctx, poolAddress, publicKey)
|
||||||
return as.getPoolSwappableFromVouchers(ctx, poolAddress, publicKey)
|
|
||||||
} else {
|
|
||||||
return svc.GetPoolSwappableVouchers(ctx, poolAddress, publicKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (as HTTPAccountService) getPoolSwappableVouchers(ctx context.Context, poolAddress, publicKey string) ([]dataserviceapi.TokenHoldings, error) {
|
|
||||||
var r struct {
|
|
||||||
PoolSwappableVouchers []dataserviceapi.TokenHoldings `json:"filtered"`
|
|
||||||
}
|
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "to", publicKey)
|
|
||||||
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.PoolSwappableVouchers, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTokenAddress, poolAddress, toTokenAddress string) (*models.PoolSwapResult, error) {
|
||||||
@ -419,30 +376,8 @@ func (as *HTTPAccountService) PoolSwap(ctx context.Context, amount, from, fromTo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (as *HTTPAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
func (as *HTTPAccountService) GetSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokenAddress, publicKey string) (*models.MaxLimitResult, error) {
|
||||||
if as.UseApi {
|
svc := dev.NewDevAccountService(ctx, as.SS)
|
||||||
return as.getSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
return svc.GetSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
||||||
} else {
|
|
||||||
svc := dev.NewDevAccountService(ctx, as.SS)
|
|
||||||
return svc.GetSwapFromTokenMaxLimit(ctx, poolAddress, fromTokenAddress, toTokenAddress, publicKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (as *HTTPAccountService) getSwapFromTokenMaxLimit(ctx context.Context, poolAddress, fromTokenAddress, toTokeAddress, publicKey string) (*models.MaxLimitResult, error) {
|
|
||||||
var r struct {
|
|
||||||
MaxPoolLimitResult models.MaxLimitResult `json:"max"`
|
|
||||||
}
|
|
||||||
|
|
||||||
ep, err := url.JoinPath(config.PoolSwappableVouchersURL, poolAddress, "limit", fromTokenAddress, toTokeAddress, publicKey)
|
|
||||||
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.MaxPoolLimitResult, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use actual custodial api to request available alias
|
// TODO: Use actual custodial api to request available alias
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user