feat(contracts): add get_depositor_yield() view function to LendingPool#601
Conversation
ogazboiz
left a comment
There was a problem hiding this comment.
The get_depositor_yield function looks correct and the tests cover the key cases.
Two things before this can merge:
1. Remove .kiro/settings/lsp.json
This is an IDE settings file from the Kiro editor and should not be in the repo. Add .kiro/ to your .gitignore and remove the file:
git rm -r .kiro/
echo '.kiro/' >> .gitignore
git commit -m 'chore: remove Kiro IDE settings, add to gitignore'2. CI needs approval
The CI run is showing action_required which means it hasn't started yet. A maintainer will approve the CI run after you push the fix.
|
The codebase issues on main have been resolved and all CI checks are passing now. Please rebase your branch to pull in the latest changes before continuing. Thanks for your patience. |
|
@ogazboiz i have done that |
737ba5b to
ec569d1
Compare
|
@ogazboiz review |
|
All three feedback items addressed. The branch is clean now with just the contract changes. Same as #600 though, CI hasn't run on this branch. Push an empty commit to trigger it: git commit --allow-empty -m 'trigger CI' && git push |
|
@ogazboiz review |
|
heads up, a few important changes just landed on main that affect your PR:
please rebase on latest main: git fetch upstream
git rebase upstream/main
git push --force-with-lease |
Returns (shares, current_asset_value) for a provider so depositors can see their on-chain returns without external share-price math. Closes LabsCrypt#473
b0bc47e to
56a56fe
Compare
|
@ogazboiz rebase done |
ogazboiz
left a comment
There was a problem hiding this comment.
hey @Sundriveauto, code looks good. the get_depositor_yield view function is clean and the tests cover both the zero-deposit and accrued-interest cases. merging!
if you want to keep contributing or follow up on open issues, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0
Closes #458
Problem
The LendingPool contract had no on-chain way for depositors to query their current yield. They had to fetch share price externally and do manual math.
Solution
Added
get_depositor_yield(env, provider, token) -> (i128, i128)which returns:shares— LP shares held by the providerasset_value— current redemption value of those shares (principal + accrued yield)Net yield =
asset_value - original_deposit. Since original deposit amounts are not stored per-depositor, callers compareasset_valueagainst their own recorded cost basis.The implementation reuses existing private helpers (
read_shares,total_shares,read_pool_balance,calc_assets_to_redeem) with no new storage.Tests
Added 2 tests to
test.rs:test_get_depositor_yield_no_deposit— returns(0, 0)for a provider with no positiontest_get_depositor_yield_reflects_accrued_interest— verifies asset_value increases when interest is repaid into the pool without new shares being minted@ogazboiz Pls review Conflict