Skip to content

feat: implement flexible fee destination routing for programs (supersedes #696)#715

Merged
Jagadeeshftw merged 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/flexible-fee-destination-routing
Mar 5, 2026
Merged

feat: implement flexible fee destination routing for programs (supersedes #696)#715
Jagadeeshftw merged 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/flexible-fee-destination-routing

Conversation

@Chucks1093
Copy link
Contributor

Supersedes #696
Closes #593

Why a new PR

The previous PR (#696) was closed and cannot be reopened because the branch history was rewritten after conflict resolution/rebase (force-push).

Changes

Flexible fee routing model added to bounty escrow.

1) Fee routing configuration model

Added FeeRoutingConfig with:

  • treasury_recipient
  • treasury_bps
  • partner_recipient (optional)
  • partner_bps

Added storage key:

  • DataKey::FeeRouting(u64) for per-bounty routing.

2) New admin configuration entrypoints

  • set_fee_routing(bounty_id, treasury_recipient, treasury_bps, partner_recipient, partner_bps)
  • clear_fee_routing(bounty_id)
  • get_fee_routing(bounty_id)

3) Deterministic routing + validation

Routing config validation enforces:

  • treasury_bps >= 0
  • partner_bps >= 0
  • treasury_bps + partner_bps == 10_000
  • partner_bps > 0 requires partner_recipient
  • partner_bps == 0 requires no partner_recipient

Deterministic split behavior:

  • Treasury fee = total_fee * treasury_bps / 10_000 (floor)
  • Partner fee = total_fee - treasury_fee (remainder-safe, no drift)

4) Fee routing integrated into payout paths

Lock-side fee routing applied in:

  • lock_funds
  • batch_lock_funds

Release-side fee routing applied in:

  • release_funds
  • batch_release_funds
  • partial_release
  • release_with_capability
  • claim
  • claim_with_capability
  • claim_with_ticket

5) Backward-compatible default behavior

If no bounty-specific routing is configured, routing defaults to existing fee recipient:

  • 100% to FeeConfig.fee_recipient
  • 0% partner split

6) New events for full accounting visibility

  • FeeRoutingUpdated emitted when routing config changes
  • FeeRouted emitted on fee distribution with full split details

Testing

Added test module:

  • contracts/bounty_escrow/contracts/escrow/src/test_fee_routing.rs

Coverage includes:

  • Treasury + partner split routing on lock fees
  • Deterministic remainder handling on release fees
  • Default fallback routing to existing fee recipient
  • Rejection of invalid routing basis-point configs

Validation run:

  • cargo test --lib test_fee_routing -- --nocapture
  • cargo test --lib -- --nocapture in bounty escrow crate ✅

Notes

Implementation is scoped to:

  • contracts/bounty_escrow/contracts/escrow

Existing fee configuration APIs remain intact; routing extends behavior without breaking existing callers.

- Expanded traits.rs: added PauseInterface and FeeInterface with full
  doc comments referencing Grainlify internal spec
- BountyEscrowContract now formally implements all four traits
  (EscrowInterface, UpgradeInterface, PauseInterface, FeeInterface)
- soroban/contracts/escrow: added local EscrowInterface + UpgradeInterface
  trait definitions and implementations; added get_balance and
  get_escrow_info to satisfy standard surface
- grainlify-core: added local UpgradeInterface trait and impl for
  GrainlifyContract (feature-gated to match existing contract gate)
- contracts/view-facade: implemented ViewFacade contract with
  register/deregister/list/get_contract for cross-contract discovery
@vercel
Copy link

vercel bot commented Mar 5, 2026

@Chucks1093 is attempting to deploy a commit to the Jagadeesh B's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Jagadeeshftw Jagadeeshftw self-requested a review March 5, 2026 18:58
@Jagadeeshftw Jagadeeshftw merged commit 039102f into Jagadeeshftw:master Mar 5, 2026
1 of 4 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.

Implement Flexible Fee Destination Routing

2 participants