blockchain-audit / recap-protocol

Rewrite of Cap Protocol using Function Requirements-Effects-Interactions + Protocol Invariants Pattern
0 stars 0 forks source link

Add Invariant test for the functions removeLiquidity + creditFee #43

Open malka8580 opened 3 months ago

henry-hz commented 3 months ago

@malka8580 make sure you have the last master version:

git add .
git commit -m "wip"
git fetch origin
git merge origin/master
malka8580 commented 3 months ago

The tests for the function removeLiquidity : (i have a problem with the github, i will fix it tomorrow)

function invariant_LiquidityRemovalValid() public { uint256 totalLiquidity = pool.getTotalLiquidity(); // Assuming there is a state variable removedLiquidity that tracks how much liquidity has been removed uint256 removedLiquidity = pool.getRemovedLiquidity(); assert(totalLiquidity >= removedLiquidity); }

function invariant_TotalLiquidityConsistent() public { uint256 totalLiquidity = pool.getTotalLiquidity(); uint256 sumOfIndividualPools = pool.getSumOfIndividualPools(); assert(totalLiquidity == sumOfIndividualPools); }