Skip to content

Commit

Permalink
Rename kickWithDeposit to lenderKickAuction
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy committed Jun 16, 2023
1 parent cf9459e commit 8843778
Show file tree
Hide file tree
Showing 26 changed files with 389 additions and 399 deletions.
89 changes: 42 additions & 47 deletions docs/Functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,27 @@

### transferLP
external libraries call:
- LenderActions.transferLP()
- LPActions.transferLP()

write state:
- LenderActions.transferLP():
- LPActions.transferLP():
- delete allowance mapping
- increment new lender.lps accumulator and lender.depositTime state
- delete old lender from bucket -> lender mapping

reverts on:
- LenderActions.transferLP():
- LPActions.transferLP():
- invalid index InvalidIndex()
- no allowance NoAllowance()

emit events:
- LenderActions.transferLP():
- LPActions.transferLP():
- TransferLP

### kick
external libraries call:
- PoolCommons.accrueInterest()
- Auctions.kick()
- KickerActions.kick()
- PoolCommons.updateInterestRate()

write state:
Expand All @@ -143,7 +143,7 @@
- Deposits.mult() (scale Fenwick tree with new interest accrued):
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- Auctions.kick():
- KickerActions.kick():
- _kick():
- _recordAuction():
- borrower -> liquidation mapping update
Expand All @@ -164,20 +164,20 @@
- pool inflator and inflatorUpdate state

reverts on:
- Auctions.kick():
- KickerActions.kick():
- borrower collateralized BorrowerOk()
- auction active AuctionActive()

emit events:
- Auctions.kick():
- KickerActions.kick():
- Kick
- PoolCommons.updateInterestRate():
- UpdateInterestRate

### kickWithDeposit
### lenderKickAuction
external libraries call:
- PoolCommons.accrueInterest()
- Auctions.kickWithDeposit()
- KickerActions.lenderKickAuction()
- PoolCommons.updateInterestRate()

write state:
Expand All @@ -186,7 +186,7 @@
- Deposits.mult() (scale Fenwick tree with new interest accrued):
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- Auctions.kickWithDeposit():
- KickerActions.lenderKickAuction():
- _kick():
- _recordAuction():
- borrower -> liquidation mapping update
Expand All @@ -198,10 +198,6 @@
- Loans.remove():
- delete borrower from indices => borrower address mapping
- remove loan from loans array
- Deposits.unscaledRemove() (remove amount in Fenwick tree, from index):
- update values array state
- decrement lender.lps accumulator
- decrement bucket.lps accumulator
- increment poolBalances.t0DebtInAuction and poolBalances.t0Debt accumulators
- _updateInterestState():
- PoolCommons.updateInterestRate():
Expand All @@ -210,15 +206,14 @@
- pool inflator and inflatorUpdate state

reverts on:
- Auctions.kickWithDeposit():
- auction active AuctionActive()
- KickerActions.lenderKickAuction():
- bucket price below current pool LUP PriceBelowLUP()
- borrower collateralized BorrowerOk()
- insuficient amount InsufficientLiquidity()

emit events:
- Auctions.kickWithDeposit():
- KickerActions.lenderKickAuction():
- Kick
- RemoveQuoteToken
- PoolCommons.updateInterestRate():
- UpdateInterestRate

Expand All @@ -235,41 +230,41 @@

### kickReserveAuction
external libraries call:
- Auctions.kickReserveAuction()
- KickerActions.kickReserveAuction()

write state:
- Auctions.kickReserveAuction():
- KickerActions.kickReserveAuction():
- update reserveAuction.unclaimed accumulator
- update reserveAuction.kicked timestamp state
- increment latestBurnEpoch counter
- update reserveAuction.latestBurnEventEpoch and burn event timestamp state

reverts on:
- 2 weeks not passed ReserveAuctionTooSoon()
- Auctions.kickReserveAuction():
- KickerActions.kickReserveAuction():
- no reserves to claim NoReserves()

emit events:
- Auctions.kickReserveAuction():
- KickerActions.kickReserveAuction():
- KickReserveAuction


### takeReserves
external libraries call:
- Auctions.takeReserves()
- TakerActions.takeReserves()

write state:
- Auctions.takeReserves():
- TakerActions.takeReserves():
- decrement reserveAuction.unclaimed accumulator
- increment reserveAuction.totalAjnaBurned accumulator
- update burn event totalInterest and totalBurned accumulators

reverts on:
- Auctions.takeReserves():
- TakerActions.takeReserves():
- not kicked or 72 hours didn't pass NoReservesAuction()

emit events:
- Auctions.takeReserves():
- TakerActions.takeReserves():
- ReserveAuction

### stampLoan
Expand Down Expand Up @@ -387,7 +382,7 @@
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- BorrowerActions.drawDebt():
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
Expand Down Expand Up @@ -417,7 +412,7 @@

emit events:
- BorrowerActions.drawDebt():
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- AuctionNFTSettle or AuctionSettle
- DrawDebt
- PoolCommons.updateInterestRate():
Expand All @@ -436,7 +431,7 @@
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- BorrowerActions.repayDebt():
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
Expand Down Expand Up @@ -466,7 +461,7 @@

emit events:
- BorrowerActions.repayDebt():
- Auctions._settleAuction:
- SettlerActions._settleAuction:
- AuctionNFTSettle or AuctionSettle
- RepayDebt
- PoolCommons.updateInterestRate():
Expand All @@ -475,7 +470,7 @@
### settle
external libraries call:
- PoolCommons.accrueInterest()
- Auctions.settlePoolDebt()
- SettlerActions.settlePoolDebt()
- PoolCommons.updateInterestRate()

write state:
Expand All @@ -484,14 +479,14 @@
- Deposits.mult() (scale Fenwick tree with new interest accrued):
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- Auctions.settlePoolDebt():
- SettlerActions.settlePoolDebt():
- Deposits.unscaledRemove() (remove amount in Fenwick tree, from index):
- update values array state
- Buckets.addCollateral():
- increment bucket.collateral and bucket.lps accumulator
- addLenderLP():
- increment lender.lps accumulator and lender.depositTime state
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
Expand All @@ -508,14 +503,14 @@
- pool inflator and inflatorUpdate state

reverts on:
- Auctions.settlePoolDebt():
- SettlerActions.settlePoolDebt():
- loan not kicked NoAuction()
- 72 hours didn't pass and auction still has collateral AuctionNotClearable()

emit events:
- Auctions.settlePoolDebt():
- SettlerActions.settlePoolDebt():
- Settle
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- AuctionNFTSettle or AuctionSettle
- BucketBankruptcy
- PoolCommons.updateInterestRate():
Expand All @@ -524,7 +519,7 @@
### take
external libraries call:
- PoolCommons.accrueInterest()
- Auctions.take()
- TakerActions.take()
- PoolCommons.updateInterestRate()

write state:
Expand All @@ -533,7 +528,7 @@
- Deposits.mult (scale Fenwick tree with new interest accrued):
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- Auctions.take():
- TakerActions.take():
- _take():
- _prepareTake():
- update liquidation.alreadyTaken state
Expand All @@ -542,7 +537,7 @@
- update kicker's locked balance accumulator
- update auctions.totalBondEscrowed accumulator
- _takeLoan():
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
Expand All @@ -564,7 +559,7 @@
- pool inflator and inflatorUpdate state

reverts on:
- Auctions.take():
- TakerActions.take():
- insufficient collateral InsufficientCollateral()
- _prepareTake():
- loan is not in auction NoAuction()
Expand All @@ -573,15 +568,15 @@
- borrower debt less than pool min debt AmountLTMinDebt()

emit events:
- Auctions.take():
- TakerActions.take():
- Take
- PoolCommons.updateInterestRate():
- UpdateInterestRate

### bucketTake
external libraries call:
- PoolCommons.accrueInterest()
- Auctions.bucketTake()
- TakerActions.bucketTake()
- PoolCommons.updateInterestRate()

write state:
Expand All @@ -590,7 +585,7 @@
- Deposits.mult (scale Fenwick tree with new interest accrued):
- update scaling array state
- increment reserveAuction.totalInterestEarned accumulator
- Auctions.bucketTake():
- TakerActions.bucketTake():
- _takeBucket():
- _prepareTake():
- update liquidation.alreadyTaken state
Expand All @@ -605,7 +600,7 @@
- update values array state
- increment bucket.collateral and bucket.lps accumulator
- _takeLoan():
- Auctions._settleAuction():
- SettlerActions._settleAuction():
- _removeAuction():
- decrement kicker locked accumulator, increment kicker claimable accumumlator
- decrement auctions count accumulator
Expand All @@ -627,7 +622,7 @@
- pool inflator and inflatorUpdate state

reverts on:
- Auctions.bucketTake():
- TakerActions.bucketTake():
- insufficient collateral InsufficientCollateral()
- _prepareTake():
- loan is not in auction NoAuction()
Expand All @@ -636,7 +631,7 @@
- borrower debt less than pool min debt AmountLTMinDebt()

emit events:
- Auctions.bucketTake():
- TakerActions.bucketTake():
- _rewardBucketTake():
- BucketTakeLPAwarded
- BucketTake
Expand Down
4 changes: 2 additions & 2 deletions src/base/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,14 @@ abstract contract Pool is Clone, ReentrancyGuard, Multicall, IPool {
* @dev increment `poolBalances.t0DebtInAuction` and `poolBalances.t0Debt` accumulators
* @dev update `t0Debt2ToCollateral` ratio, debt and collateral post action are considered 0
*/
function kickWithDeposit(
function lenderKickAuction(
uint256 index_,
uint256 npLimitIndex_
) external override nonReentrant {
PoolState memory poolState = _accruePoolInterest();

// kick auctions
KickResult memory result = KickerActions.kickWithDeposit(
KickResult memory result = KickerActions.lenderKickAuction(
auctions,
deposits,
buckets,
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/pool/commons/IPoolKickerActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ interface IPoolKickerActions {
) external;

/**
* @notice Called by lenders to liquidate the top loan using their deposits.
* @notice Called by lenders to liquidate the top loan.
* @param index_ The deposit index to use for kicking the top loan.
* @param npLimitIndex_ Index of the lower bound of `NP` tolerated when kicking the auction.
*/
function kickWithDeposit(
function lenderKickAuction(
uint256 index_,
uint256 npLimitIndex_
) external;
Expand Down
13 changes: 4 additions & 9 deletions src/libraries/external/KickerActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ library KickerActions {
uint256 kickPenalty; // [WAD] current debt added as kick penalty
}

/// @dev Struct used for `kickWithDeposit` function local vars.
struct KickWithDepositLocalVars {
/// @dev Struct used for `lenderKickAuction` function local vars.
struct LenderKickLocalVars {
uint256 bucketDeposit; // [WAD] amount of quote tokens in bucket
uint256 bucketPrice; // [WAD] bucket price
uint256 entitledAmount; // [WAD] amount that lender is entitled to remove at specified index
Expand Down Expand Up @@ -130,17 +130,12 @@ library KickerActions {

/**
* @notice See `IPoolKickerActions` for descriptions.
* @dev === Write state ===
* @dev - `Deposits.unscaledRemove` (remove amount in `Fenwick` tree, from index): update `values` array state
* @dev - decrement `lender.lps` accumulator
* @dev - decrement `bucket.lps` accumulator
* @dev === Reverts on ===
* @dev bucket price below current pool `LUP` `PriceBelowLUP()`
* @dev insufficient deposit to kick auction `InsufficientLiquidity()`
* @dev no `LP` redeemed to kick auction `InsufficientLP()`
* @return kickResult_ The `KickResult` struct result of the kick action.
*/
function kickWithDeposit(
function lenderKickAuction(
AuctionsState storage auctions_,
DepositsState storage deposits_,
mapping(uint256 => Bucket) storage buckets_,
Expand All @@ -151,7 +146,7 @@ library KickerActions {
) external returns (
KickResult memory kickResult_
) {
KickWithDepositLocalVars memory vars;
LenderKickLocalVars memory vars;

vars.bucketPrice = _priceAt(index_);

Expand Down
Loading

0 comments on commit 8843778

Please sign in to comment.