Skip to content

fix: approve margin + fees for taker positions#37

Merged
koko1123 merged 1 commit intomainfrom
koko/fix-taker-approval-amount
Feb 10, 2026
Merged

fix: approve margin + fees for taker positions#37
koko1123 merged 1 commit intomainfrom
koko/fix-taker-approval-amount

Conversation

@koko1123
Copy link
Contributor

Summary

  • The contract's openPos for taker positions transfers margin + insuranceFee + lpFee + creatorFee + protocolFee via safeTransferFrom, but the SDK was only approving the margin amount. This caused TransferFromFailed reverts on every taker position opening.
  • Now fetches fee rates from the perp data and protocol fee from the contract, computes the total fees as a proportion of notional, and approves margin + totalFees.
  • Bumped version to 0.4.2.

Test plan

  • SDK build passes
  • SDK unit tests pass (187/187)
  • SDK type check passes
  • SDK lint passes
  • Manual: open a taker position on testnet without TransferFromFailed

The contract transfers margin + all fees (creator, insurance, LP,
protocol) from the user via safeTransferFrom, but the SDK was only
approving the margin amount. This caused TransferFromFailed reverts.

Now computes the total fee amount from notional value and includes
it in the USDC approval.
@koko1123 koko1123 merged commit 9bda5e0 into main Feb 10, 2026
3 checks passed
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.

1 participant