Skip to content

fix: set symbol param only when isIsolated is true#813

Open
taobig wants to merge 2 commits into
ccxt:masterfrom
taobig:fix/0528
Open

fix: set symbol param only when isIsolated is true#813
taobig wants to merge 2 commits into
ccxt:masterfrom
taobig:fix/0528

Conversation

@taobig
Copy link
Copy Markdown
Contributor

@taobig taobig commented May 28, 2026

fix: stop sending symbol="" when isIsolated=false as backend upgrade now rejects it

<APIError> code=-1022, msg=Signature for this request is not valid.

@carlosmiei
Copy link
Copy Markdown
Collaborator

@taobig thanks for your fix we will merge it soon

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the v2 margin borrow/repay request builder to stop sending symbol= when isIsolated=false, addressing a backend change that now rejects requests when an empty symbol parameter is present (causing -1022 signature errors).

Changes:

  • Make symbol conditional on isIsolated for /sapi/v1/margin/borrow-repay.
  • Update unit tests to reflect the absence of symbol for cross margin requests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
v2/margin_service.go Stops including symbol in form params for cross margin borrow/repay requests.
v2/margin_service_test.go Adjusts expected form params for borrow/repay tests to no longer include symbol when cross margin.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread v2/margin_service.go
Comment on lines 242 to 251
m := params{
"asset": s.asset,
"isIsolated": s.isIsolated,
"symbol": s.symbol,
"amount": s.amount,
"type": string(s._type),
//"symbol": s.symbol,
"amount": s.amount,
"type": string(s._type),
}
if s.isIsolated {
m["symbol"] = s.symbol // set symbol param only when isIsolated is true
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taobig can you check this comment plz?

Comment thread v2/margin_service_test.go
Comment on lines 105 to 111
e := newSignedRequest().setFormParams(params{
"asset": asset,
"amount": amount,
"isIsolated": false,
"symbol": "",
"type": string(_type),
//"symbol": "",
"type": string(_type),
})
Comment thread v2/margin_service_test.go
Comment on lines 135 to 142
s.assertReq(func(r *request) {
e := newSignedRequest().setFormParams(params{
"asset": asset,
"amount": amount,
"isIsolated": false,
"symbol": "",
"type": string(_type),
//"symbol": "",
"type": string(_type),
})
Comment thread v2/margin_service_test.go
Comment on lines 95 to 113
func (s *marginTestSuite) TestBorrowRepayBorrow() {
data := []byte(`{
"tranId": 100000001
}`)
s.mockDo(data, nil)
defer s.assertDo()
asset := "BTC"
amount := "1.000"
_type := MarginAccountBorrow
s.assertReq(func(r *request) {
e := newSignedRequest().setFormParams(params{
"asset": asset,
"amount": amount,
"isIsolated": false,
"symbol": "",
"type": string(_type),
//"symbol": "",
"type": string(_type),
})
s.assertRequestEqual(e, r)
})
@taobig taobig requested a review from Copilot June 7, 2026 08:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread v2/margin_service.go
Comment on lines +248 to +250
if s.isIsolated {
m["symbol"] = s.symbol // set symbol param only when isIsolated is true
}
Comment thread v2/margin_service_test.go
Comment on lines 106 to 110
"asset": asset,
"amount": amount,
"isIsolated": false,
"symbol": "",
"type": string(_type),
})
@taobig taobig force-pushed the fix/0528 branch 3 times, most recently from cb72bd0 to 792c694 Compare June 7, 2026 09:25
@taobig taobig requested a review from Copilot June 7, 2026 09:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread v2/margin_service.go
Comment on lines 242 to +250
m := params{
"asset": s.asset,
"isIsolated": s.isIsolated,
"symbol": s.symbol,
"amount": s.amount,
"type": string(s._type),
}
if s.isIsolated && s.symbol != "" {
m["symbol"] = s.symbol // Only set symbol param when isIsolated is true
}
Comment thread v2/margin_service_test.go Outdated
Comment on lines +189 to +213
func (s *marginTestSuite) TestBorrowRepayBorrowIsolatedWithoutSymbol() {
data := []byte(`{
"tranId": 100000001
}`)
s.mockDo(data, nil)
defer s.assertDo()
asset := "BTC"
amount := "1.000"
_type := MarginAccountBorrow
s.assertReq(func(r *request) {
e := newSignedRequest().setFormParams(params{
"asset": asset,
"amount": amount,
"isIsolated": true,
"type": string(_type),
})
s.assertRequestEqual(e, r)
})
res, err := s.client.NewMarginBorrowRepayService().
Asset(asset).
Amount(amount).
IsIsolated(true).
Type(_type).
Do(newContext())
s.r().NoError(err)
Comment thread v2/margin_service.go Outdated
Comment on lines +248 to +250
if s.isIsolated && s.symbol != "" {
m["symbol"] = s.symbol // Only set symbol param when isIsolated is true
}
@taobig taobig requested a review from Copilot June 7, 2026 09:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread v2/margin_service.go
Comment on lines 243 to +254
m := params{
"asset": s.asset,
"isIsolated": s.isIsolated,
"symbol": s.symbol,
"amount": s.amount,
"type": string(s._type),
}
if s.isIsolated {
if s.symbol == "" {
return nil, fmt.Errorf("symbol is required for isolated margin borrow/repay")
}
m["symbol"] = s.symbol // Only set symbol param when isIsolated is true
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pass

Comment thread v2/margin_service.go
import (
"context"
"encoding/json"
"fmt"
Comment thread v2/margin_service.go
}
if s.isIsolated {
if s.symbol == "" {
return nil, fmt.Errorf("symbol is required for isolated margin borrow/repay")
Comment thread v2/margin_service_test.go
Type(_type).
Do(newContext())
s.r().Error(err)
s.r().EqualError(err, "symbol is required for isolated margin borrow/repay")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants