Skip to content

Feat/penalty fee distribution#213

Merged
Dydex merged 3 commits into
AstronLabs:mainfrom
dumbdevss:feat/penalty-fee-distribution
Jun 29, 2026
Merged

Feat/penalty fee distribution#213
Dydex merged 3 commits into
AstronLabs:mainfrom
dumbdevss:feat/penalty-fee-distribution

Conversation

@dumbdevss

Copy link
Copy Markdown
Contributor

feat(contracts): route early-exit penalty fees to the lending pool as yield

Closes #179

Early-withdrawal penalties were left idle in the escrow contract. They now flow
to the LendingPool and are distributed to active investors as yield.

Changes

  • lending-pool: new deposit_fees(from, amount) — pulls the fee tokens and
    books them as claimable liquidity plus pro-rata yield by incrementing the
    total-repaid-interest accumulator, the same mechanism used for loan-interest
    repayments. So every depositor's claim_yield rises in proportion to their
    share.
  • escrow: admin-only set_lending_pool / get_lending_pool. withdraw now
    forwards the penalty to the configured pool via deposit_fees, authorizing the
    nested token.transfer as the invoking contract
    (authorize_as_current_contract). With no pool configured, behavior is
    unchanged (penalty stays in escrow).
  • Fixes a pre-existing missing PoolError::LoanNotOverdue variant that prevented
    the lending-pool crate from compiling.

Tests

  • New end-to-end escrow↔pool test
    (test_early_withdrawal_penalty_routes_to_lending_pool): after an early exit,
    pool TVL and the sole investor's claimable yield both rise by exactly the
    penalty.
  • Full escrow suite green (52 passed).

Acceptance criteria

  • Escrow withdrawal penalties transfer to the lending pool
  • Yield increments distributed proportionally across active depositors
  • End-to-end integration test passes

Note: the lending-pool's own src/test.rs is a pre-existing broken stub
(placeholder comments, ~76 compile errors on main) and is out of scope here;
the new behavior is verified through the escrow integration test against the
real pool.

dumbdevss and others added 3 commits June 29, 2026 09:41
When a borrower withdraws early from escrow, the penalty was left idle in the
contract. It is now routed to the LendingPool and distributed to active
investors as yield.

- lending-pool: add deposit_fees(from, amount) which pulls the fee tokens and
  books them as claimable liquidity plus pro-rata yield via the
  total-repaid-interest accumulator (same mechanism as loan interest).
- escrow: add admin-only set_lending_pool/get_lending_pool; withdraw now
  forwards the penalty to the configured pool via deposit_fees, authorizing
  the nested token transfer as the invoking contract.
- Add an end-to-end escrow<->pool test asserting pool TVL and investor
  claimable yield both rise by exactly the penalty.
- Fix a pre-existing missing PoolError::LoanNotOverdue variant that blocked
  the lending-pool crate from compiling.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@dumbdevss 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! 🚀

Learn more about application limits

@Dydex Dydex merged commit cd0db2a into AstronLabs:main Jun 29, 2026
1 of 5 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.

feat(contracts): implement penalty fee distribution to lending pool investors

2 participants