---
# System prepended metadata

title: NOT_CREATED PCL stage audit
tags: [sublime]

---

# NOT_CREATED PCL stage audit

###### tags: `sublime`

Once all the stored data has been deleted for a terminated PCL it behaves just like a NOT_CREATED PCL.

- For TERMINATED condition, all balances are withdrawn to the admin (collateral + remaining borrowAsset). The admin then handles redistribution

## PooledCreditLine

### Callbacks from LenderPool

- [ ] accept
- [ ] liquidate
- [ ] cancelRequestOnLowCollection

### Admin calls

- [ ] updateBorrowLimitLimits
- [ ] updateIdealCollateralRatioLimits
- [ ] updateBorrowRateLimits
- [ ] updateCollectionPeriodLimits
- [ ] updateDurationLimits
- [ ] updateDefaultGracePeriodLimits
- [ ] updateGracePenaltyRateLimits
- [ ] updateProtocolFeeFraction
- [ ] updateProtocolFeeCollector

### State changing

- [ ] initialize
- [x] ✅ request
- [ ] depositCollateral
- [ ] withdrawCollateral [only borower]
    - reverts at `onlyCreditLineBorrower`
    - TODO: price oracle should revert on both num and den address 0
    - TODO: check if cToken is address(0) or not. this method is callable but will throw error at `getTokensForShares` [link](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/PooledCreditLine.sol#L885)
    - TODO: better to be explicit about revert for Chainlink price feeds
    - TODO: test if the `depositedCollateralInShares[_id]` value is 0 for terminated state check this [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/PooledCreditLine.sol#L863)
- [ ] withdrawCollateral [only borower]
    - reverts at `onlyCreditLineBorrower`
- [ ] borrow [only borrower]
    - ~~TODO: has a round about check at this [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/PooledCreditLine.sol#L947) a more verbose direct check is suggested~~
- [ ] repay
- [ ] close [only borrower]
- [ ] cancelRequest [only borrower]
- [x] ✅ terminate [only admin]
    - will fail with error at [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/PooledCreditLine.sol#L885)
    - TODO: better to be explicit about the revert.
    - TODO: Need to make this non-callable
- [x] ✅ getStatusAndUpdate

### View [todo: specify view modifier]

- [ ] withdrawableCollateral
- [ ] calculateTotalCollateralTokens
- [ ] getRequiredCollateral
- [ ] calculateBorrowableAmount
- [ ] calculateInterestAccrued
- [ ] calculateCurrentDebt
- [ ] collateralTokensToLiquidate
- [ ] calculateCurrentCollateralRatio
- [ ] getPrincipal
- [ ] getBorrowerAddress
- [ ] getEndsAt

## Lender Pool

### Callbacks from PooledCreditLine

- [x] ✅ create
- [ ] borrowed
- [ ] repaid
- [ ] requestCancelled
- [ ] terminate

### State changing

- [ ] lend
- [ ] start
- [x] ✅ withdrawInterest
    - TODO: move [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/LenderPool.sol#L433) just below checking lender balance
    - TODO: for a terminated PCL this will throw error at [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/LenderPool.sol#L496) better to use a explicit require
    - TODO: should not be callable in NOT_CREATED
- [ ] withdrawLiquidity
    - will revert at [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/LenderPool.sol#L583)
- [ ] liquidate
    - this will revert in the PCL callback function `liquidate`
- [x] ✅ withdrawLiquidation
    - for a terminated PCL this will revert in `_withdrawLiquidity` function of lender pool
    - TODO: this should not be callable in NOT_CREATED
- [x] ✅ Token transfer
    - this will fail in `_withdrawInterest` method at [line](https://github.com/sublime-finance/sublime-v1-private/blob/c5d0c2b0dcb7c9ebba26589c4ca55f8a9eb5e1f9/contracts/PooledCreditLine/LenderPool.sol#L496)
    - TODO: check if there can be a explicit check
    - TODO: this should not be callable in NOT_CREATED

### View

- [ ] getLenderInterest
- [ ] calculatePrincipalWithdrawable
- [ ] getLenderInfo