Skip to content

[Contracts] LendingPool share accounting uses live token balance, making it manipulable by direct transfers and loan flows #2

@grantfox-oss

Description

@grantfox-oss

Telegram (ask questions / claim the issue here first): https://t.me/+DOylgFv1jyJlNzM0

Why this matters

lending_pool/src/lib.rs computes total_assets for both minting (total_assets_before in deposit) and redemption (calc_assets_to_redeem in redeem_shares/get_deposit/get_share_price) from read_pool_balance, the raw TokenClient::balance of the contract. loan_manager approve_loan transfers tokens out of the pool and repayments/seized collateral transfer them back in, so the share price swings with outstanding loans and anyone can inflate it by transferring tokens to the pool address, decoupling shares from tracked TotalDeposits.

Acceptance criteria

  • Define and document whether share value should track tracked principal+realized yield or raw balance, and make minting and redemption use one consistent accounting source
  • Ensure direct token transfers to the contract cannot arbitrarily change existing holders' redeemable value
  • Add tests covering deposit/redeem while loans are outstanding and after an unsolicited direct transfer
  • Reconcile TotalDeposits adjustments in redeem_shares (currently subtracts assets_to_return, which can drift from principal)

Files to touch

  • lending_pool/src/lib.rs

Out of scope

  • Adding an oracle for token pricing
  • Multi-asset rebalancing

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official CampaignbugSomething isn't workingenhancementNew feature or requesthardAdvanced / high-difficulty issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions