Skip to content

Commit

Permalink
prod-oxorio-upgrade-2024Feb1 returning bookKeeper.whitelist fn
Browse files Browse the repository at this point in the history
  • Loading branch information
codinghistorian committed Feb 1, 2024
1 parent f7aa507 commit e71c002
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 37 deletions.
2 changes: 1 addition & 1 deletion contracts/main/flash-mint/FlashMintModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/main/interfaces/IBookKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion contracts/main/managers/PositionHandler.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import "../interfaces/IBookKeeper.sol";

contract PositionHandler {
constructor(address _bookKeeper) {
IBookKeeper(_bookKeeper).addToWhitelist(msg.sender);
IBookKeeper(_bookKeeper).whitelist(msg.sender);
}
}
10 changes: 5 additions & 5 deletions contracts/main/proxy-actions/FathomStablecoinProxyActions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion contracts/main/stablecoin-core/BookKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/tests/mocks/BookKeeperFlashMintArbitrager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/mocks/MockBookKeeper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/tests/mocks/MockFlashMintModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion scripts/migrations/deployment/4_add-roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
6 changes: 3 additions & 3 deletions scripts/tests/integration/LiquidationEngine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)"](
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/integration/PositionPermissions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 })
Expand Down
4 changes: 2 additions & 2 deletions scripts/tests/integration/ShowStopper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })

Expand Down Expand Up @@ -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 })

Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/unit/flash-mint/FlashMintModule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests/unit/managers/PositionManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 12 additions & 12 deletions scripts/tests/unit/stablecoin-core/BookKeeper.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 }))
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e71c002

Please sign in to comment.