feat(soroban): on-chain contribution router with slippage enforcement…#75
Open
cybermax4200 wants to merge 18 commits into
Open
feat(soroban): on-chain contribution router with slippage enforcement…#75cybermax4200 wants to merge 18 commits into
cybermax4200 wants to merge 18 commits into
Conversation
…Savitura#60) - contracts/soroban/contracts/router/src/lib.rs: RouterContract - route_contribution() validates send_max <= dest_amount*(1+slippage_bps/10000) - atomically splits dest_amount: (1-fee_bps/10000) to campaign, fee_bps/10000 to platform - emits ContributionRouted event (sender, campaign, dest_amount, source_amount, fee_amount) - 4 unit tests: happy path, slippage rejection, zero fee, zero dest_amount - sorobanService.js: add routeContribution() wrapper - stellarService.js: prepareSignedContributionPathPayment() routes through contract when ROUTER_CONTRACT_ID is set; falls back to classic path payment otherwise - backend/.env.example: add ROUTER_CONTRACT_ID, XLM_SAC_ADDRESS, USDC_SAC_ADDRESS
|
@cybermax4200 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
…t closer in stellarService
…ing else brace in contributions.js
…licate txHash declaration in contributions.js
…ECRET_KEY in test environment
…stination_key, and valid password in test fixtures
…ery string matchers
…on, missing fields, query mocks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #60
What changed
contracts/soroban/contracts/router/ (new)
route_contribution(sender, send_asset, send_max, dest_asset, dest_amount, path, campaign_wallet, platform_wallet, fee_bps, max_slippage_bps)send_max <= dest_amount * (10_000 + max_slippage_bps) / 10_000— panics if exceededdest_amount * (10_000 - fee_bps) / 10_000,platform receives
fee_amount— both in the same contract callContributionRoutedevent: sender, campaign, dest_amount, source_amount, fee_amountbackend/src/services/sorobanService.js
routeContribution()— encodes args as ScVals and callsinvokeContractbackend/src/services/stellarService.js
prepareSignedContributionPathPayment()checksROUTER_CONTRACT_ID:backend/.env.example
ROUTER_CONTRACT_ID,XLM_SAC_ADDRESS,USDC_SAC_ADDRESS