---
# System prepended metadata

title: Untitled
tags: [sherlock, audits]

---

###### tags: `sherlock` `audits`

## Audit findings
* `Onchain price manipulation:` ICHI vault token prices can be manipulated upto 5% to liquidate the leveraged user. 



## Potential Bugs
#### `Contract: IchilpOracle.sol`
1. `getPrice()`: 
    * Looks suspicious because the price is calculated using pool total supply and pool balances. Can pool balances for the token be manipulated using flash loans?
    * Is there a place where `totalReserve` decimals is not ie18? Because they use fixed value ie18 when calculating price of a token.
#### `Contract: IchiVault.sol`
1. `deposit()`: 
    * Hysteresis is 5% so spot price can be manipulated up to 5% to make it 5% cheaper--should check this manip yourselves?
    * The hysteresis requires also makes it so you can grief users by manipulating spot price over that 5% and their deposit will revert.
    * Ooooo you can really mess stuff up with MMEV. They allow spot manipulation >5% if the change took place in the last block.

## Suspicious
* They use `roughlyNear` helper function for tests with 10% tolerance, is there anything they may have messed up their calculations in the contract by upto 10% that would result in exploit? Same thing with `near` but 0.1% tolerance for that.

## Notes
1. Positions are sent to liquidation at -85% to -90% PNL depending on collateral volatile (85%) stabel (90%)
2. Max allowed leverage is 6x
3. 

## Novice questions 
1. Is there a way the user can use leverage more than 6x
2. Is there a way that the user can escape the liquidation?
3. Is there a way that the lenders will never recieve their lended amounts?
4. How is bad debt resolved? 
5. Is there a way in which the price of collateral can be manipulated through flash loans and empty the vault?
6. How is contract supposed to react when different types of bank status are there? Is it working as intended when there's different types of status? Can I take the benefit or exploit the contract in different status phases?
7. What's the difference between hard vault and soft vault?
8. What's the purpose of `BasicSpell` Contract?

## Entry points to look at

#### `Contract: BlueberryBank.sol`
* `liquidate()`:  
    * requirement: 
        * Liquidate a position if it's underwater. Pay debt for it's owner and take away the colleteral.
    * code execution:
        * checks for ``

* `execute()`: 
    * requirement: 
        * Execute the action with supplied data.
    * code execution:
        * ?

* `lend()`:  
    * requirement: 
        * Lend tokens to bank as isolated collateral.
    * code execution:
        * ?
* `takeCollateral()`: Take some collateral back from the user's deposit. 
    * Doubts: 
        * Is there a way user can take away all collateral despite having a loan against it?




