Feat/penalty fee distribution#213
Merged
Merged
Conversation
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>
|
@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! 🚀 |
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.
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
deposit_fees(from, amount)— pulls the fee tokens andbooks them as claimable liquidity plus pro-rata yield by incrementing the
total-repaid-interestaccumulator, the same mechanism used for loan-interestrepayments. So every depositor's
claim_yieldrises in proportion to theirshare.
set_lending_pool/get_lending_pool.withdrawnowforwards the penalty to the configured pool via
deposit_fees, authorizing thenested
token.transferas the invoking contract(
authorize_as_current_contract). With no pool configured, behavior isunchanged (penalty stays in escrow).
PoolError::LoanNotOverduevariant that preventedthe lending-pool crate from compiling.
Tests
(
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.
Acceptance criteria