feat: implement referral fees for Stonfi swapper#11841
feat: implement referral fees for Stonfi swapper#11841gomesalexandre merged 6 commits intodevelopfrom
Conversation
Adds support for ShapeShift affiliate fees when swapping via Stonfi/Omniston on TON chain. Changes: - Add DAO_TREASURY_TON constant (placeholder address to be updated) - Add TonMainnet to treasury chain IDs and mapping - Update Stonfi swapper to pass referrer parameters to Omniston SDK - Add helper functions for TON address conversion and affiliate fee parsing - Enable flexible referrer fee for better rate optimization - Update both getTradeQuote and getTradeRate to support affiliate fees Fee implementation follows Stonfi documentation: - Fees range from 0.01% to 1% (1-100 basis points) - flexibleReferrerFee allows protocol to optimize fees for better rates - Referrer parameters always passed (even when 0) for consistency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
📝 WalkthroughWalkthroughThis PR adds affiliate/referrer fee support to the Stonfi swapper's trade quote and rate APIs. It introduces new helper functions for affiliate fee conversion and TON address mapping, and extends treasury configuration to support Ton mainnet lookups. Changes
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly Related PRs
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
4be12cd to
5893a4d
Compare
Description
Implements ShapeShift affiliate/referral fees for the Stonfi swapper on TON chain, allowing the DAO to earn fees from TON swaps.
This implementation follows the Stonfi Omniston referral fees documentation:
flexibleReferrerFee: trueto allow the protocol to optimize fees for better swap ratesIssue (if applicable)
N/A - Feature implementation
Risk
Low Risk
Testing
Engineering
Setup:
DAO_TREASURY_TONwith actual ShapeShift DAO TON treasury addressaffiliateBpsis configured in swap requests (inherited fromCommonTradeQuoteInput)Test Cases:
Quote with affiliate fees:
affiliateBpsset (e.g., "30" for 0.3%)stonfiSpecificreferrerFeeUnitsis populatedQuote without affiliate fees:
affiliateBpsundefined or "0"referrerFeeBps: 0Rate endpoint:
getTradeRatewith and without affiliate feesTreasury address resolution:
getTreasuryAddressFromChainId(KnownChainIds.TonMainnet)returns TON treasury addressFiles Changed:
packages/utils/src/treasury.ts- Added TON treasury address and chain IDpackages/swapper/src/swappers/utils/helpers/helpers.ts- Added TON to treasury mappingpackages/swapper/src/swappers/StonfiSwapper/utils/helpers.ts- Added conversion helperspackages/swapper/src/swappers/StonfiSwapper/swapperApi/getTradeQuote.ts- Implemented referral feespackages/swapper/src/swappers/StonfiSwapper/swapperApi/getTradeRate.ts- Implemented referral feesOperations
Feature Flag: This implementation is automatically enabled when TON chain and Stonfi swapper are enabled. The existing TON/Stonfi feature flags control visibility.
Once Enabled:
Screenshots (if applicable)
https://tonscan.org/tx/65b02c611f58b9130241aca3e2191ec8e151eb4cc151a5c77b6fb1c02a48c33a
Done a swap from TON to USDC, got the referral fees in
N/A - Backend-only changes
🤖 Generated with Claude Code
Summary by CodeRabbit