Repository navigation
feat(usdc-pool): support partial withdrawals and cap yield rate changes - #454
Open
comandanto wants to merge 1 commit into
Open
comandanto wants to merge 1 commit into
comandanto wants to merge 1 commit into
Conversation
Closes thisisouvik#421 withdraw now takes an amount of principal. The requested principal and all accrued yield are paid out, the remainder stays deposited and keeps earning from the current yield index. Withdrawing the full principal closes the position as before. set_yield_rate now rejects updates that move annual_yield_bps by more than 500 bps in a single call.
|
@comandanto is attempting to deploy a commit to the thisisouvik's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
This branch has not been deployed
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.
Description
UsdcLendingPoolContract::withdrawcould only close a depositor's whole position, andset_yield_ratelet the admin changeannual_yield_bpsby any amount in one call.withdrawnow takes anamountof principal, so a depositor can withdraw part of the position and keep the rest earning.set_yield_ratenow limits a single update to 500 bps.Related Issue
Closes #421
Motivation and Context
Liquidity providers had to exit completely to access part of their funds, and the admin could shock the yield rate with no notice.
Changes:
contracts/usdc_lending_pool/src/lib.rs:withdraw(env, depositor, amount). It paysamountprincipal plus all accrued yield. Remaining principal is stored with the current yield index, so it keeps accruing and no yield is paid twice. Full withdrawal still removes the record. Panics: "amount must be > 0", "amount exceeds deposited principal".set_yield_ratepanics with "yield rate change exceeds max step" when the change is aboveMAX_YIELD_RATE_CHANGE_BPS(500).contracts/usdc_lending_pool/src/test.rs: existing withdraw tests pass the full principal; added tests for partial withdrawal (balances, pool totals, continued accrual, backing), partial then full close, zero and over-principal amounts, and the rate step limit (max step up/down, over the step in both directions).lib/contracts/usdc-lending-pool.ts:withdrawwrapper takesamountStroops.Note: the
withdrawsignature change is breaking for callers of the contract ABI.How Has This Been Tested?
Run on Windows (stable Rust, wasm32-unknown-unknown installed), from
contracts/:cargo fmt -p usdc_lending_pool --checkreports 9 diffs, the same count as on unmodifiedmain, so they are pre-existing and I did not reformat unrelated code. I did not run the TypeScript build; the TS change is a one-line signature update of the wrapper, which has no callers in the repo.Screenshots (if appropriate):
n/a
Types of changes
withdrawnow requires anamountargument)Checklist: