Skip to content

Commit

Permalink
responded to Matts comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Harvey committed Nov 9, 2023
1 parent cc3dcfe commit ebb7f04
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 46 deletions.
3 changes: 1 addition & 2 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity 0.8.18;
import { ERC20 } from '@openzeppelin/contracts/token/ERC20/ERC20.sol';
import { IERC20 } from '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import { EnumerableSet } from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import { Multicall } from '@openzeppelin/contracts/utils/Multicall.sol';
import { ReentrancyGuard } from '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import { SafeERC20 } from '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';

Expand Down Expand Up @@ -37,7 +36,7 @@ import { PositionNFTSVG } from './libraries/external/PositionNFTSVG.sol';
* - `redeem` positions for given buckets
* - `burn` positions `NFT`
*/
contract PositionManager is PermitERC721, IPositionManager, Multicall, ReentrancyGuard {
contract PositionManager is PermitERC721, IPositionManager, ReentrancyGuard {
using EnumerableSet for EnumerableSet.UintSet;
using SafeERC20 for ERC20;

Expand Down
88 changes: 44 additions & 44 deletions tests/forge/unit/ERC20Pool/ERC20PoolDebtExceedsDeposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
_addInitialLiquidity({
from: _lender,
amount: 1_000 * 1e18,
index: 4156
index: 4156 // 1.000000000000000000
});

}
Expand Down Expand Up @@ -194,17 +194,17 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
})
);

// _assertBucket({
// index: 3231,
// lpBalance: 100.0 * 1e18,
// collateral: 0 * 1e18,
// deposit: 100.000000000000000000 * 1e18,
// exchangeRate: 1.0 * 1e18
// });
_assertBucket({
index: 3231,
lpBalance: 100.0 * 1e18,
collateral: 0 * 1e18,
deposit: 100.000000000000000000 * 1e18,
exchangeRate: 1.0 * 1e18
});

// In a single block finish the attack:

// 2a. Call arbtake using 100.5 price bucket --> FIXME: 100.5 price bucket?
// 2a. Call arbtake using 100.5 price bucket
_arbTake({
from: _attacker,
borrower: _attacker,
Expand All @@ -218,21 +218,21 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
lpAwardKicker: 0.874178433715669284 * 1e18
});

// _assertBucket({
// index: 3231,
// lpBalance: 149.899452254309694969 * 1e18,
// collateral: 1.040000000000000000 * 1e18,
// deposit: 45.036425965937656883 * 1e18,
// exchangeRate: 1.000029118818786027 * 1e18
// });
_assertBucket({
index: 3231,
lpBalance: 148.152293372162818904 * 1e18,
collateral: 1.040000000000000000 * 1e18,
deposit: 43.289216208587901186 * 1e18,
exchangeRate: 1.000029118818786027 * 1e18
});

// _assertReserveAuction({
// reserves: 50.145162338400592903 * 1e18,
// claimableReserves : 50.145162193361255055 * 1e18,
// claimableReservesRemaining: 0,
// auctionPrice: 0,
// timeRemaining: 0
// });
_assertReserveAuction({
reserves: 50.145162338400592905 * 1e18,
claimableReserves : 49.678475742964129332 * 1e18,
claimableReservesRemaining: 0,
auctionPrice: 0,
timeRemaining: 0
});

// 2b. Call settle
_settle({
Expand All @@ -242,21 +242,21 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
settledDebt: 43.284951626362185652 * 1e18
});

// _assertBucket({
// index: 3232,
// lpBalance: 0 * 1e18,
// collateral: 0,
// deposit: 0 * 1e18,
// exchangeRate: 1 * 1e18
// });
_assertBucket({
index: 3232,
lpBalance: 0 * 1e18,
collateral: 0,
deposit: 0 * 1e18,
exchangeRate: 1 * 1e18
});

// _assertBucket({
// index: 3231,
// lpBalance: 149.899452254309694969 * 1e18,
// collateral: 1.040000000000000000 * 1e18,
// deposit: 0.002288055290450296 * 1e18,
// exchangeRate: 0.699600149710578699 * 1e18
// });
_assertBucket({
index: 3231,
lpBalance: 148.152293372162818904 * 1e18,
collateral: 1.040000000000000000 * 1e18,
deposit: 0.050319094592365857 * 1e18,
exchangeRate: 0.708174729461625128 * 1e18
});

// 2c. Withdraw the deposit remaing (should be about 50)
// the collateral moved (should be 1.04) from the 100 price bucket (all go to the attacker)
Expand All @@ -276,13 +276,13 @@ contract ERC20PoolBorrowTest is ERC20HelperContract {
lpRedeem: 148.081238740446971198 * 1e18
});

// _assertReserveAuction({
// reserves: 50.145162338400592902 * 1e18,
// claimableReserves : 50.145162238397681020 * 1e18,
// claimableReservesRemaining: 0,
// auctionPrice: 0,
// timeRemaining: 0
// });
_assertReserveAuction({
reserves: 50.097131299098677341 * 1e18,
claimableReserves : 49.846879387717917230 * 1e18,
claimableReservesRemaining: 0,
auctionPrice: 0,
timeRemaining: 0
});

// assert attacker's balances
// attacker does not profit in QT
Expand Down

0 comments on commit ebb7f04

Please sign in to comment.