π¬ Want to contribute? Join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
Problem
The LendingPool contract tracks deposits using raw token amounts per depositor. When yield is distributed via distribute_yield(), the total pool balance increases but individual depositor balances don't change until they withdraw.
This creates several issues:
- Late depositors dilute early depositors β a new deposit after yield distribution gets proportional withdrawal rights without having earned the yield
- Yield is socialized incorrectly β the test
test_subsequent_depositor_does_not_dilute_existing_holders exists but the contract may not correctly handle all edge cases
- No share price tracking β no way for the frontend to show accurate portfolio value including accrued yield
Expected Behavior
Implement share-based accounting (like ERC-4626 vault pattern):
- Deposits mint shares based on current share price
- Withdrawals burn shares and return proportional pool value
- Share price increases as yield accumulates
Files to Change
contracts/lending_pool/src/lib.rs β implement share-based deposit/withdraw
contracts/lending_pool/src/test.rs β update tests for share accounting
Acceptance Criteria
Problem
The LendingPool contract tracks deposits using raw token amounts per depositor. When yield is distributed via
distribute_yield(), the total pool balance increases but individual depositor balances don't change until they withdraw.This creates several issues:
test_subsequent_depositor_does_not_dilute_existing_holdersexists but the contract may not correctly handle all edge casesExpected Behavior
Implement share-based accounting (like ERC-4626 vault pattern):
Files to Change
contracts/lending_pool/src/lib.rsβ implement share-based deposit/withdrawcontracts/lending_pool/src/test.rsβ update tests for share accountingAcceptance Criteria
deposit()mints shares based onamount / share_pricewithdraw()burns shares and returnsshares * share_priceget_share_price()query function returns current priceget_shares(provider)returns share balance