Skip to content

Commit

Permalink
Revert "pkg/exchange: replace /sapi/v1/margin/transfer to /sapi/v1/as…
Browse files Browse the repository at this point in the history
…set/transfer"

This reverts commit b6717f2.
  • Loading branch information
bailantaotao committed Feb 15, 2024
1 parent d34a410 commit a351203
Show file tree
Hide file tree
Showing 7 changed files with 292 additions and 135 deletions.
20 changes: 0 additions & 20 deletions pkg/exchange/binance/binanceapi/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,6 @@ func TestClient_setTimeOffsetFromServer(t *testing.T) {
assert.NoError(t, err)
}

func TestClient_NewTransferAssetRequest(t *testing.T) {
client := getTestClientOrSkip(t)
ctx := context.Background()

err := client.SetTimeOffsetFromServer(ctx)
assert.NoError(t, err)

req := client.NewTransferAssetRequest()
req.Asset("BTC")
req.FromSymbol("BTCUSDT")
req.ToSymbol("BTCUSDT")
req.Amount("0.01")
req.TransferType(TransferAssetTypeIsolatedMarginToMain)
res, err := req.Do(ctx)
assert.NoError(t, err)
assert.NotNil(t, res)
assert.NotEmpty(t, res)
t.Logf("result: %+v", res)
}

func TestClient_GetMarginBorrowRepayHistoryRequest(t *testing.T) {
client := getTestClientOrSkip(t)
ctx := context.Background()
Expand Down
36 changes: 0 additions & 36 deletions pkg/exchange/binance/binanceapi/transfer_asset_request.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package binanceapi

import (
"github.com/c9s/requestgen"
)

type TransferResponse struct {
TranId int `json:"tranId"`
}

//go:generate requestgen -method POST -url "/sapi/v1/margin/transfer" -type TransferCrossMarginAccountRequest -responseType .TransferResponse
type TransferCrossMarginAccountRequest struct {
client requestgen.AuthenticatedAPIClient

asset string `param:"asset"`

// transferType:
// 1: transfer from main account to cross margin account
// 2: transfer from cross margin account to main account
transferType int `param:"type"`

amount string `param:"amount"`
}

func (c *RestClient) NewTransferCrossMarginAccountRequest() *TransferCrossMarginAccountRequest {
return &TransferCrossMarginAccountRequest{client: c}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package binanceapi

import (
"github.com/c9s/requestgen"
)

type AccountType string

const (
AccountTypeSpot AccountType = "SPOT"
AccountTypeIsolatedMargin AccountType = "ISOLATED_MARGIN"
)

//go:generate requestgen -method POST -url "/sapi/v1/margin/isolated/transfer" -type TransferIsolatedMarginAccountRequest -responseType .TransferResponse
type TransferIsolatedMarginAccountRequest struct {
client requestgen.AuthenticatedAPIClient

asset string `param:"asset"`
symbol string `param:"symbol"`

// transFrom: "SPOT", "ISOLATED_MARGIN"
transFrom AccountType `param:"transFrom"`

// transTo: "SPOT", "ISOLATED_MARGIN"
transTo AccountType `param:"transTo"`

amount string `param:"amount"`
}

func (c *RestClient) NewTransferIsolatedMarginAccountRequest() *TransferIsolatedMarginAccountRequest {
return &TransferIsolatedMarginAccountRequest{client: c}
}
Loading

0 comments on commit a351203

Please sign in to comment.