exchanges/engine: Add multichain deposit/withdrawal support (#794)

* Add exchange multichain support

* Start tidying up

* Add multichain transfer support for Bitfinex and fix poloniex bug

* Add Coinbene multichain support

* Start adjusting the deposit address manager

* Fix deposit tests and further enhancements

* Cleanup

* Add bypass flag, expand tests plus error coverage for Huobi

Adjust helpers

* Address nitterinos

* BFX wd changes

* Address nitterinos

* Minor fixes rebasing on master

* Fix BFX acceptableMethods test

* Add some TO-DOs for 2 tests WRT races

* Fix acceptableMethods test round 2

* Address nitterinos
This commit is contained in:
Adrian Gallagher
2021-10-15 15:55:38 +11:00
committed by GitHub
parent b093a7df19
commit 0c00b7e1df
145 changed files with 46329 additions and 5507 deletions

View File

@@ -483,7 +483,7 @@ func ExchangeOrderSubmit(args ...objects.Object) (objects.Object, error) {
// ExchangeDepositAddress returns deposit address (if supported by exchange)
func ExchangeDepositAddress(args ...objects.Object) (objects.Object, error) {
if len(args) != 2 {
if len(args) != 3 {
return nil, objects.ErrWrongNumArguments
}
@@ -495,15 +495,24 @@ func ExchangeDepositAddress(args ...objects.Object) (objects.Object, error) {
if !ok {
return nil, fmt.Errorf(ErrParameterConvertFailed, currencyCode)
}
chain, ok := objects.ToString(args[2])
if !ok {
return nil, fmt.Errorf(ErrParameterConvertFailed, chain)
}
currCode := currency.NewCode(currencyCode)
rtn, err := wrappers.GetWrapper().DepositAddress(exchangeName, currCode)
rtn, err := wrappers.GetWrapper().DepositAddress(exchangeName, chain, currCode)
if err != nil {
return nil, err
}
return &objects.String{Value: rtn}, nil
data := make(map[string]objects.Object, 2)
data["address"] = &objects.String{Value: rtn.Address}
data["tag"] = &objects.String{Value: rtn.Tag}
return &objects.Map{
Value: data,
}, nil
}
// ExchangeWithdrawCrypto submit request to withdraw crypto assets

View File

@@ -245,12 +245,13 @@ func TestExchangeDepositAddress(t *testing.T) {
}
currCode := &objects.String{Value: "BTC"}
_, err = ExchangeDepositAddress(exch, currCode)
chain := &objects.String{Value: ""}
_, err = ExchangeDepositAddress(exch, currCode, chain)
if err != nil {
t.Error(err)
}
_, err = ExchangeDepositAddress(exchError, currCode)
_, err = ExchangeDepositAddress(exchError, currCode, chain)
if err != nil && !errors.Is(err, errTestFailed) {
t.Error(err)
}

View File

@@ -7,6 +7,7 @@ import (
"github.com/thrasher-corp/gocryptotrader/currency"
"github.com/thrasher-corp/gocryptotrader/exchanges/account"
"github.com/thrasher-corp/gocryptotrader/exchanges/asset"
"github.com/thrasher-corp/gocryptotrader/exchanges/deposit"
"github.com/thrasher-corp/gocryptotrader/exchanges/kline"
"github.com/thrasher-corp/gocryptotrader/exchanges/order"
"github.com/thrasher-corp/gocryptotrader/exchanges/orderbook"
@@ -40,7 +41,7 @@ type Exchange interface {
SubmitOrder(ctx context.Context, submit *order.Submit) (*order.SubmitResponse, error)
CancelOrder(ctx context.Context, exch, orderid string, pair currency.Pair, item asset.Item) (bool, error)
AccountInformation(ctx context.Context, exch string, assetType asset.Item) (account.Holdings, error)
DepositAddress(exch string, currencyCode currency.Code) (string, error)
DepositAddress(exch, chain string, currencyCode currency.Code) (*deposit.Address, error)
WithdrawalFiatFunds(ctx context.Context, bankAccountID string, request *withdraw.Request) (out string, err error)
WithdrawalCryptoFunds(ctx context.Context, request *withdraw.Request) (out string, err error)
OHLCV(ctx context.Context, exch string, pair currency.Pair, item asset.Item, start, end time.Time, interval kline.Interval) (kline.Item, error)