From e71c0029f82ec436f935267d323cb855f44a5902 Mon Sep 17 00:00:00 2001 From: codinghistorian Date: Thu, 1 Feb 2024 14:22:07 +0400 Subject: [PATCH] prod-oxorio-upgrade-2024Feb1 returning bookKeeper.whitelist fn --- contracts/main/flash-mint/FlashMintModule.sol | 2 +- contracts/main/interfaces/IBookKeeper.sol | 2 +- contracts/main/managers/PositionHandler.sol | 2 +- .../FathomStablecoinProxyActions.sol | 10 ++++---- contracts/main/stablecoin-core/BookKeeper.sol | 2 +- .../mocks/BookKeeperFlashMintArbitrager.sol | 4 ++-- contracts/tests/mocks/MockBookKeeper.sol | 2 +- contracts/tests/mocks/MockFlashMintModule.sol | 2 +- scripts/migrations/deployment/4_add-roles.js | 2 +- .../integration/LiquidationEngine.test.js | 6 ++--- .../integration/PositionPermissions.test.js | 4 ++-- scripts/tests/integration/ShowStopper.test.js | 4 ++-- .../unit/flash-mint/FlashMintModule.test.js | 2 +- .../unit/managers/PositionManager.test.js | 2 +- .../unit/stablecoin-core/BookKeeper.test.js | 24 +++++++++---------- .../stablecoin-core/StableSwapModule.test.js | 2 +- .../StableSwapModuleWrapper.test.js | 2 +- 17 files changed, 37 insertions(+), 37 deletions(-) diff --git a/contracts/main/flash-mint/FlashMintModule.sol b/contracts/main/flash-mint/FlashMintModule.sol index 4cd34579..01d5f28a 100644 --- a/contracts/main/flash-mint/FlashMintModule.sol +++ b/contracts/main/flash-mint/FlashMintModule.sol @@ -83,7 +83,7 @@ contract FlashMintModule is CommonMath, PausableUpgradeable, IERC3156FlashLender require(_systemDebtEngine != address(0), "FlashMintModule/bad-system-debt-engine-address"); systemDebtEngine = _systemDebtEngine; - bookKeeper.addToWhitelist(_stablecoinAdapter); + bookKeeper.whitelist(_stablecoinAdapter); address(stablecoin).safeApprove(_stablecoinAdapter, type(uint256).max); } diff --git a/contracts/main/interfaces/IBookKeeper.sol b/contracts/main/interfaces/IBookKeeper.sol index 78cdb6cc..9f694ea6 100644 --- a/contracts/main/interfaces/IBookKeeper.sol +++ b/contracts/main/interfaces/IBookKeeper.sol @@ -60,7 +60,7 @@ interface IBookKeeper { function settleSystemBadDebt(uint256 _value) external; // [rad] - function addToWhitelist(address _toBeWhitelistedAddress) external; + function whitelist(address _toBeWhitelistedAddress) external; function removeFromWhitelist(address _toBeRemovedAddress) external; diff --git a/contracts/main/managers/PositionHandler.sol b/contracts/main/managers/PositionHandler.sol index 47217988..bf1195d7 100644 --- a/contracts/main/managers/PositionHandler.sol +++ b/contracts/main/managers/PositionHandler.sol @@ -5,6 +5,6 @@ import "../interfaces/IBookKeeper.sol"; contract PositionHandler { constructor(address _bookKeeper) { - IBookKeeper(_bookKeeper).addToWhitelist(msg.sender); + IBookKeeper(_bookKeeper).whitelist(msg.sender); } } diff --git a/contracts/main/proxy-actions/FathomStablecoinProxyActions.sol b/contracts/main/proxy-actions/FathomStablecoinProxyActions.sol index a1f2b8c5..95fe490d 100644 --- a/contracts/main/proxy-actions/FathomStablecoinProxyActions.sol +++ b/contracts/main/proxy-actions/FathomStablecoinProxyActions.sol @@ -29,8 +29,8 @@ contract FathomStablecoinProxyActions is CommonMath { _; } - function addToWhitelist(address _bookKeeper, address _usr) external onlyDelegateCall { - IBookKeeper(_bookKeeper).addToWhitelist(_usr); + function whitelist(address _bookKeeper, address _usr) external onlyDelegateCall { + IBookKeeper(_bookKeeper).whitelist(_usr); } function removeFromWhitelist(address _bookKeeper, address _usr) external onlyDelegateCall { @@ -92,7 +92,7 @@ contract FathomStablecoinProxyActions is CommonMath { // Allows adapter to access to proxy's Fathom Stablecoin balance in the bookKeeper if (IBookKeeper(_bookKeeper).positionWhitelist(address(this), address(_stablecoinAdapter)) == 0) { - IBookKeeper(_bookKeeper).addToWhitelist(_stablecoinAdapter); + IBookKeeper(_bookKeeper).whitelist(_stablecoinAdapter); } IStablecoinAdapter(_stablecoinAdapter).withdraw(msg.sender, _amount, _data); // Withdraws Fathom Stablecoin to the user's wallet as a token @@ -306,7 +306,7 @@ contract FathomStablecoinProxyActions is CommonMath { moveStablecoin(_manager, _positionId, address(this), toRad(_stablecoinAmount)); // Allows adapter to access to proxy's Fathom Stablecoin balance in the bookKeeper if (IBookKeeper(_bookKeeper).positionWhitelist(address(this), address(_stablecoinAdapter)) == 0) { - IBookKeeper(_bookKeeper).addToWhitelist(_stablecoinAdapter); + IBookKeeper(_bookKeeper).whitelist(_stablecoinAdapter); } // Withdraws Fathom Stablecoin to the user's wallet as a token IStablecoinAdapter(_stablecoinAdapter).withdraw(msg.sender, _stablecoinAmount, _data); @@ -343,7 +343,7 @@ contract FathomStablecoinProxyActions is CommonMath { moveStablecoin(address(_manager), _positionId, address(this), toRad(_stablecoinAmount)); // Allows adapter to access to proxy's Fathom Stablecoin balance in the bookKeeper if (IBookKeeper(_manager.bookKeeper()).positionWhitelist(address(this), address(_stablecoinAdapter)) == 0) { - IBookKeeper(_manager.bookKeeper()).addToWhitelist(_stablecoinAdapter); + IBookKeeper(_manager.bookKeeper()).whitelist(_stablecoinAdapter); } // Withdraws FXD to the user's wallet as a token IStablecoinAdapter(_stablecoinAdapter).withdraw(msg.sender, _stablecoinAmount, _data); diff --git a/contracts/main/stablecoin-core/BookKeeper.sol b/contracts/main/stablecoin-core/BookKeeper.sol index 93d261fa..4c6dfd3b 100644 --- a/contracts/main/stablecoin-core/BookKeeper.sol +++ b/contracts/main/stablecoin-core/BookKeeper.sol @@ -198,7 +198,7 @@ contract BookKeeper is IBookKeeper, ICagable, IPausable, CommonMath, PausableUpg /// @notice This function can only be called when the BookKeeper contract is not paused. /// @param _toBeWhitelistedAddress The address that is granted permission to adjust the position address of the caller. /// @dev Emits no events. - function addToWhitelist(address _toBeWhitelistedAddress) external override whenNotPaused { + function whitelist(address _toBeWhitelistedAddress) external override whenNotPaused { positionWhitelist[msg.sender][_toBeWhitelistedAddress] = 1; emit LogAddToWhitelist(_toBeWhitelistedAddress); } diff --git a/contracts/tests/mocks/BookKeeperFlashMintArbitrager.sol b/contracts/tests/mocks/BookKeeperFlashMintArbitrager.sol index e73cd528..cc506ea5 100644 --- a/contracts/tests/mocks/BookKeeperFlashMintArbitrager.sol +++ b/contracts/tests/mocks/BookKeeperFlashMintArbitrager.sol @@ -46,8 +46,8 @@ contract BookKeeperFlashMintArbitrager is OwnableUpgradeable, IBookKeeperFlashBo uint256 loanAmount = _loanValue / RAY; // 1. Swap FXD to USDT at a DEX - vars.stableSwapModule.bookKeeper().addToWhitelist(address(IStablecoinAdapterGetter(msg.sender).stablecoinAdapter())); - //above is actually callling bookKeeper.addToWhiteList(stablecoinAdapterAddress); + vars.stableSwapModule.bookKeeper().whitelist(address(IStablecoinAdapterGetter(msg.sender).stablecoinAdapter())); + //above is actually callling bookKeeper.whitelist(stablecoinAdapterAddress); IStablecoinAdapterGetter(msg.sender).stablecoinAdapter().withdraw(address(this), loanAmount, abi.encode(0)); uint256 balanceBefore = vars.stableSwapToken.myBalance(); diff --git a/contracts/tests/mocks/MockBookKeeper.sol b/contracts/tests/mocks/MockBookKeeper.sol index e577c517..0081633f 100644 --- a/contracts/tests/mocks/MockBookKeeper.sol +++ b/contracts/tests/mocks/MockBookKeeper.sol @@ -194,7 +194,7 @@ contract MockBookKeeper is IBookKeeper, ICagable, IPausable, CommonMath, Pausabl /// @notice This function can only be called when the BookKeeper contract is not paused. /// @param _toBeWhitelistedAddress The address that is granted permission to adjust the position address of the caller. /// @dev Emits no events. - function addToWhitelist(address _toBeWhitelistedAddress) external override whenNotPaused { + function whitelist(address _toBeWhitelistedAddress) external override whenNotPaused { positionWhitelist[msg.sender][_toBeWhitelistedAddress] = 1; emit LogAddToWhitelist(_toBeWhitelistedAddress); } diff --git a/contracts/tests/mocks/MockFlashMintModule.sol b/contracts/tests/mocks/MockFlashMintModule.sol index 4d8e3f77..2a24dc4a 100644 --- a/contracts/tests/mocks/MockFlashMintModule.sol +++ b/contracts/tests/mocks/MockFlashMintModule.sol @@ -79,7 +79,7 @@ contract MockFlashMintModule is CommonMath, PausableUpgradeable, IERC3156FlashLe require(_systemDebtEngine != address(0), "FlashMintModule/bad-system-debt-engine-address"); systemDebtEngine = _systemDebtEngine; - bookKeeper.addToWhitelist(_stablecoinAdapter); + bookKeeper.whitelist(_stablecoinAdapter); address(stablecoin).safeApprove(_stablecoinAdapter, type(uint256).max); } diff --git a/scripts/migrations/deployment/4_add-roles.js b/scripts/migrations/deployment/4_add-roles.js index 9ba73a59..db9006a7 100644 --- a/scripts/migrations/deployment/4_add-roles.js +++ b/scripts/migrations/deployment/4_add-roles.js @@ -51,7 +51,7 @@ module.exports = async function (deployer) { await accessControlConfig.grantRole(await accessControlConfig.GOV_ROLE(), adminControls.address) - await bookKeeper.addToWhitelist(stablecoinAdapter.address, { gasLimit: 1000000 }); + await bookKeeper.whitelist(stablecoinAdapter.address, { gasLimit: 1000000 }); await collateralTokenAdapter.addToWhitelist(positionManager.address, { gasLimit: 1000000 }); await collateralTokenAdapter.addToWhitelist(fixedSpreadLiquidationStrategy.address, { gasLimit: 1000000 }); diff --git a/scripts/tests/integration/LiquidationEngine.test.js b/scripts/tests/integration/LiquidationEngine.test.js index 4aee2364..5ceb54ec 100644 --- a/scripts/tests/integration/LiquidationEngine.test.js +++ b/scripts/tests/integration/LiquidationEngine.test.js @@ -57,8 +57,8 @@ const setup = async () => { await collateralPoolConfig.setCloseFactorBps(pools.XDC, CLOSE_FACTOR_BPS, { gasLimit: 1000000 }); await collateralPoolConfig.setTreasuryFeesBps(pools.XDC, TREASURY_FEE_BPS, { gasLimit: 1000000 }); - await bookKeeper.addToWhitelist(liquidationEngine.address, { from: BobAddress, gasLimit: 3000000 }) - await bookKeeper.addToWhitelist(fixedSpreadLiquidationStrategy.address, { from: BobAddress, gasLimit: 3000000 }) + await bookKeeper.whitelist(liquidationEngine.address, { from: BobAddress, gasLimit: 3000000 }) + await bookKeeper.whitelist(fixedSpreadLiquidationStrategy.address, { from: BobAddress, gasLimit: 3000000 }) await liquidationEngineAsAdmin.addToWhitelist(BobAddress); return { @@ -157,7 +157,7 @@ describe("LiquidationEngine", () => { // 4. Bob liquidate Alice's position up to full close factor successfully const debtShareToRepay = parseEther("0.5") - await bookKeeper.addToWhitelist(liquidationEngine.address, { gasLimit: 1000000 }) + await bookKeeper.whitelist(liquidationEngine.address, { gasLimit: 1000000 }) await expect( liquidationEngine["liquidate(bytes32,address,uint256,uint256,address,bytes)"]( diff --git a/scripts/tests/integration/PositionPermissions.test.js b/scripts/tests/integration/PositionPermissions.test.js index f6e79a80..a43c15bc 100644 --- a/scripts/tests/integration/PositionPermissions.test.js +++ b/scripts/tests/integration/PositionPermissions.test.js @@ -1925,7 +1925,7 @@ describe("PositionPermissions", () => { ) // 5. allow bob to window - await bookKeeper.addToWhitelist(stablecoinAdapter.address, { from: BobAddress }) + await bookKeeper.whitelist(stablecoinAdapter.address, { from: BobAddress }) // 6. mint FXD await stablecoinAdapter.withdraw( @@ -2365,7 +2365,7 @@ describe("PositionPermissions", () => { expect(await positionManager.ownerWhitelist(aliceProxyWallet.address, 1, AliceAddress)).to.be.equal(true) // 3. alice allow positionManage - await bookKeeper.addToWhitelist(positionManager.address, { from: AliceAddress }) + await bookKeeper.whitelist(positionManager.address, { from: AliceAddress }) // 4. alice allow migration await positionManager.allowMigratePosition(aliceProxyWallet.address, true, { from: AliceAddress }) diff --git a/scripts/tests/integration/ShowStopper.test.js b/scripts/tests/integration/ShowStopper.test.js index 116a4d53..2dcab67c 100644 --- a/scripts/tests/integration/ShowStopper.test.js +++ b/scripts/tests/integration/ShowStopper.test.js @@ -375,7 +375,7 @@ describe("ShowStopper", () => { { from: AliceAddress, gasLimit: 1000000 } ) - await bookKeeper.addToWhitelist(showStopper.address, { from: AliceAddress }) + await bookKeeper.whitelist(showStopper.address, { from: AliceAddress }) await showStopper.accumulateStablecoin(WeiPerWad.mul(5), { from: AliceAddress }) @@ -496,7 +496,7 @@ describe("ShowStopper", () => { { from: AliceAddress, gasLimit: 1000000 } ) - await bookKeeper.addToWhitelist(showStopper.address, { from: AliceAddress }) + await bookKeeper.whitelist(showStopper.address, { from: AliceAddress }) await showStopper.accumulateStablecoin(WeiPerWad.mul(5), { from: AliceAddress }) diff --git a/scripts/tests/unit/flash-mint/FlashMintModule.test.js b/scripts/tests/unit/flash-mint/FlashMintModule.test.js index d5ec2fc0..2b6aaa78 100644 --- a/scripts/tests/unit/flash-mint/FlashMintModule.test.js +++ b/scripts/tests/unit/flash-mint/FlashMintModule.test.js @@ -25,7 +25,7 @@ const loadFixtureHandler = async () => { await mockStablecoinAdapter.mock.bookKeeper.returns(mockBookKeeper.address) await mockStablecoinAdapter.mock.stablecoin.returns(mockFathomStablecoin.address) await mockFathomStablecoin.mock.approve.returns(true) - await mockBookKeeper.mock.addToWhitelist.returns() + await mockBookKeeper.mock.whitelist.returns() await mockedAccessControlConfig.mock.hasRole.returns(true) await mockedAccessControlConfig.mock.OWNER_ROLE.returns(formatBytes32String("OWNER_ROLE")) await mockedAccessControlConfig.mock.GOV_ROLE.returns(formatBytes32String("GOV_ROLE")) diff --git a/scripts/tests/unit/managers/PositionManager.test.js b/scripts/tests/unit/managers/PositionManager.test.js index 4b356543..616e6f2d 100644 --- a/scripts/tests/unit/managers/PositionManager.test.js +++ b/scripts/tests/unit/managers/PositionManager.test.js @@ -25,7 +25,7 @@ const loadFixtureHandler = async () => { await mockedShowStopper.mock.live.returns(1); await mockedBookKeeper.mock.totalStablecoinIssued.returns(0); - await mockedBookKeeper.mock.addToWhitelist.returns(); + await mockedBookKeeper.mock.whitelist.returns(); await mockedBookKeeper.mock.accessControlConfig.returns(mockedAccessControlConfig.address); await mockedPriceOracle.mock.setPrice.returns() await mockedPriceOracle.mock.stableCoinReferencePrice.returns(WeiPerRay) diff --git a/scripts/tests/unit/stablecoin-core/BookKeeper.test.js b/scripts/tests/unit/stablecoin-core/BookKeeper.test.js index f14efc57..2631b49b 100644 --- a/scripts/tests/unit/stablecoin-core/BookKeeper.test.js +++ b/scripts/tests/unit/stablecoin-core/BookKeeper.test.js @@ -167,7 +167,7 @@ describe("BookKeeper", () => { expect(collateralTokenBobBefore).to.be.equal(0) // alice allow bob to move collateral - await bookKeeperAsAlice.addToWhitelist(BobAddress) + await bookKeeperAsAlice.whitelist(BobAddress) // bob call move collateral from alice to bob await bookKeeperAsBob.moveCollateral(COLLATERAL_POOL_ID, AliceAddress, BobAddress, WeiPerWad, { gasLimit: 1000000 }) @@ -224,7 +224,7 @@ describe("BookKeeper", () => { await bookKeeper.mintUnbackedStablecoin(DeployerAddress, AliceAddress, WeiPerRad, { gasLimit: 1000000 }); // alice allow bob to move stablecoin, so the test focuses solely on the zero amount - await bookKeeperAsAlice.addToWhitelist(BobAddress); + await bookKeeperAsAlice.whitelist(BobAddress); // Try moving 0 stablecoin from Alice to Bob await expect( @@ -269,7 +269,7 @@ describe("BookKeeper", () => { expect(stablecoinBobBefore).to.be.equal(0) // alice allow bob to move stablecoin - await bookKeeperAsAlice.addToWhitelist(BobAddress) + await bookKeeperAsAlice.whitelist(BobAddress) // bob call move stablecoin from alice to bob await expect(bookKeeperAsBob.moveStablecoin(AliceAddress, BobAddress, WeiPerRad, { gasLimit: 1000000 })) @@ -411,7 +411,7 @@ describe("BookKeeper", () => { await mockedCollateralPoolConfig.mock.setTotalDebtShare.returns() // alice allow bob to move stablecoin - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.adjustPosition( @@ -451,7 +451,7 @@ describe("BookKeeper", () => { await bookKeeper.addCollateral(COLLATERAL_POOL_ID, BobAddress, WeiPerWad.mul(10), { gasLimit: 1000000 }) // alice allow bob to move stablecoin - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) const positionBefore = await bookKeeper.positions(COLLATERAL_POOL_ID, AliceAddress) expect(positionBefore.lockedCollateral).to.be.equal(0) @@ -923,7 +923,7 @@ describe("BookKeeper", () => { expect(stablecoinAliceBefore).to.be.equal(0) // bob allow alice - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) // alice draw await bookKeeperAsAlice.adjustPosition( @@ -1288,7 +1288,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.movePosition( @@ -1337,7 +1337,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.movePosition( @@ -1386,7 +1386,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.movePosition( @@ -1435,7 +1435,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.movePosition( @@ -1497,7 +1497,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) await expect( bookKeeperAsAlice.movePosition( @@ -1546,7 +1546,7 @@ describe("BookKeeper", () => { ) // bob allow alice to manage a position - await bookKeeperAsBob.addToWhitelist(AliceAddress) + await bookKeeperAsBob.whitelist(AliceAddress) const positionAliceBefore = await bookKeeper.positions(COLLATERAL_POOL_ID, AliceAddress) expect(positionAliceBefore.lockedCollateral).to.be.equal(WeiPerWad.mul(10)) diff --git a/scripts/tests/unit/stablecoin-core/StableSwapModule.test.js b/scripts/tests/unit/stablecoin-core/StableSwapModule.test.js index 779a8ada..91abe033 100644 --- a/scripts/tests/unit/stablecoin-core/StableSwapModule.test.js +++ b/scripts/tests/unit/stablecoin-core/StableSwapModule.test.js @@ -31,7 +31,7 @@ const loadFixtureHandler = async () => { await mockedAccessControlConfig.mock.hasRole.returns(true) await mockFathomStablecoin.mock.approve.returns(true) - await mockBookKeeper.mock.addToWhitelist.returns() + await mockBookKeeper.mock.whitelist.returns() await mockFathomStablecoin.mock.transferFrom.returns(true) await mockFathomStablecoin.mock.transfer.returns(true) await mockUSD.mock.transferFrom.returns(true) diff --git a/scripts/tests/unit/stablecoin-core/StableSwapModuleWrapper.test.js b/scripts/tests/unit/stablecoin-core/StableSwapModuleWrapper.test.js index b0b9c7de..f9b25cbd 100644 --- a/scripts/tests/unit/stablecoin-core/StableSwapModuleWrapper.test.js +++ b/scripts/tests/unit/stablecoin-core/StableSwapModuleWrapper.test.js @@ -31,7 +31,7 @@ const loadFixtureHandler = async () => { await mockedAccessControlConfig.mock.hasRole.returns(true) await mockFathomStablecoin.mock.approve.returns(true) - await mockBookKeeper.mock.addToWhitelist.returns() + await mockBookKeeper.mock.whitelist.returns() await mockFathomStablecoin.mock.transferFrom.returns(true) await mockFathomStablecoin.mock.transfer.returns(true) await mockUSD.mock.transferFrom.returns(true)