Skip to content

Feat/flexible fee destination routing (#593)#696

Open
Chucks1093 wants to merge 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/flexible-fee-destination-routing
Open

Feat/flexible fee destination routing (#593)#696
Chucks1093 wants to merge 2 commits intoJagadeeshftw:masterfrom
Chucks1093:feat/flexible-fee-destination-routing

Conversation

@Chucks1093
Copy link
Contributor

Closes #593

Changes

  • Flexible fee routing model added to bounty escrow

    • Added FeeRoutingConfig with:
      • treasury_recipient
      • treasury_bps
      • partner_recipient (optional)
      • partner_bps
    • Added storage key: DataKey::FeeRouting(u64) for per-bounty routing.
  • 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)
  • 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)
  • 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
  • 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
  • New events for full accounting visibility

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

Testing

  • Added new test module:

    • contracts/bounty_escrow/contracts/escrow/src/test_fee_routing.rs
  • New 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 ✅ (519 passed)

Notes

  • Implementation is scoped to the active bounty escrow contract:
    • 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 Feb 26, 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
Copy link
Owner

please resolve the conflicts

@Jagadeeshftw
Copy link
Owner

Did you mind resolving the conflicts? @Chucks1093

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