feat(backend): fix #812 implement trigger payout endpoint with grace …#892
Merged
Conversation
…th grace period and yield calculation
|
@fhayvy 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! 🚀 |
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 #812
PR Description
This Pull Request implements the
POST /api/plans/payoutendpoint in the Axum backend to resolve the issue.How the Flow Works Now:
/api/plans/payoutreceives aPayoutRequestcontaining the plan owner's wallet address.signature_auth_middleware, which verifies the cryptographic signature (Ed25519) of the request body to ensure authenticity.FOR UPDATEto lock the row and prevent concurrent trigger requests.now >= last_ping + grace_period_seconds). If the owner is still active (within the grace period), the request is rejected with400 Bad Request.compute_projected_accrued_yieldand adds it to the principal to get the total payout amount.allocation_bps(basis points).payoutstable for each beneficiary, specifying the type (fiatorcrypto) and status (processing).fiat_anchor_infoset, the handler parses the details and triggers a fiat payout via the simulated Stellar Anchor off-ramp (state.anchor.create_payout).is_active = falseandstatus = 'PAID_OUT'.Changed
trigger_payouthandler to process payouts, calculate yields, insert payout records, and deactivate plans.parse_fiat_anchor_infohelper to parse anchor details for theAnchorPayoutRequest.test_trigger_payout_invalid_signatureto verify signature auth failure.test_trigger_payout_valid_signature_not_foundto verify successful signature auth and routing to the database handler.Testing
The changes were verified by running the backend integration test suite.
All 25 tests compiled and passed successfully: