diff --git a/contracts/FeeVault.sol b/contracts/FeeVault.sol index a79a2509..9c4a3b27 100644 --- a/contracts/FeeVault.sol +++ b/contracts/FeeVault.sol @@ -12,7 +12,7 @@ contract FeeVault { modifier onlyPoolAdmin() { require( - msg.sender == IPool(pool).manager(), + msg.sender == IPool(pool).admin(), "FeeVault: caller not pool admin" ); _; diff --git a/contracts/Loan.sol b/contracts/Loan.sol index fa3c9961..89486cb1 100644 --- a/contracts/Loan.sol +++ b/contracts/Loan.sol @@ -68,7 +68,7 @@ contract Loan is ILoan { modifier onlyPoolAdmin() { require( - msg.sender == IPool(_pool).manager(), + msg.sender == IPool(_pool).admin(), "Loan: caller is not pool admin" ); _; @@ -180,7 +180,7 @@ contract Loan is ILoan { returns (ILoanLifeCycleState) { require( - msg.sender == _borrower || msg.sender == IPool(_pool).manager(), + msg.sender == _borrower || msg.sender == IPool(_pool).admin(), "Loan: invalid caller" ); require( @@ -209,7 +209,7 @@ contract Loan is ILoan { (_state == ILoanLifeCycleState.Canceled && msg.sender == _borrower) || (_state == ILoanLifeCycleState.Defaulted && - msg.sender == IPool(_pool).manager()) || + msg.sender == IPool(_pool).admin()) || (_state == ILoanLifeCycleState.Matured && msg.sender == _borrower), "Loan: unable to claim collateral" diff --git a/contracts/Pool.sol b/contracts/Pool.sol index 20d6af42..ede73260 100644 --- a/contracts/Pool.sol +++ b/contracts/Pool.sol @@ -23,7 +23,7 @@ contract Pool is IPool, ERC20 { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; - address private _manager; + address private _admin; address private immutable _factory; IServiceConfiguration private _serviceConfiguration; IERC20 private _liquidityAsset; @@ -57,12 +57,12 @@ contract Pool is IPool, ERC20 { } /** - * @dev Modifier that checks that the caller is the pool's manager. + * @dev Modifier that checks that the caller is the pool's admin. */ - modifier onlyManager() { + modifier onlyAdmin() { require( - _manager != address(0) && msg.sender == _manager, - "Pool: caller is not manager" + _admin != address(0) && msg.sender == _admin, + "Pool: caller is not admin" ); _; } @@ -125,7 +125,7 @@ contract Pool is IPool, ERC20 { /** * @dev Constructor for Pool * @param liquidityAsset asset held by the poo - * @param poolManager manager of the pool + * @param poolAdmin admin of the pool * @param poolSettings configurable settings for the pool * @param serviceConfiguration address of global service configuration * @param tokenName Name used for issued pool tokens @@ -134,7 +134,7 @@ contract Pool is IPool, ERC20 { constructor( address factory, address liquidityAsset, - address poolManager, + address poolAdmin, address serviceConfiguration, IPoolConfigurableSettings memory poolSettings, string memory tokenName, @@ -143,7 +143,7 @@ contract Pool is IPool, ERC20 { _factory = factory; _liquidityAsset = IERC20(liquidityAsset); _poolSettings = poolSettings; - _manager = poolManager; + _admin = poolAdmin; _serviceConfiguration = IServiceConfiguration(serviceConfiguration); _firstLossVault = new FirstLossVault(address(this), liquidityAsset); _feeVault = new FeeVault(address(this)); @@ -192,12 +192,12 @@ contract Pool is IPool, ERC20 { } /** - * @dev Allow the current pool manager to update the pool fees + * @dev Allow the current pool admin to update the pool fees * before the pool has been activated. */ function setRequestFee(uint256 feeBps) external - onlyManager + onlyAdmin atState(IPoolLifeCycleState.Initialized) { _poolSettings.requestFeeBps = feeBps; @@ -219,12 +219,12 @@ contract Pool is IPool, ERC20 { } /** - * @dev Allow the current pool manager to update the withdraw gate at any + * @dev Allow the current pool admin to update the withdraw gate at any * time if the pool is Initialized or Active */ function setWithdrawGate(uint256 _withdrawGateBps) external - onlyManager + onlyAdmin atInitializedOrActiveState { _poolSettings.withdrawGateBps = _withdrawGateBps; @@ -242,10 +242,10 @@ contract Pool is IPool, ERC20 { } /** - * @dev The manager of the pool + * @dev The admin of the pool */ - function manager() external view override returns (address) { - return _manager; + function admin() external view override returns (address) { + return _admin; } /** @@ -284,11 +284,11 @@ contract Pool is IPool, ERC20 { } /** - * @dev Supplies first-loss to the pool. Can only be called by the Pool Manager. + * @dev Supplies first-loss to the pool. Can only be called by the Pool Admin. */ function depositFirstLoss(uint256 amount, address spender) external - onlyManager + onlyAdmin atInitializedOrActiveState { IPoolLifeCycleState poolLifeCycleState = PoolLib @@ -309,7 +309,7 @@ contract Pool is IPool, ERC20 { */ function withdrawFirstLoss(uint256 amount, address receiver) external - onlyManager + onlyAdmin atState(IPoolLifeCycleState.Closed) returns (uint256) { @@ -325,7 +325,7 @@ contract Pool is IPool, ERC20 { /** * @inheritdoc IPool */ - function updatePoolCapacity(uint256 newCapacity) external onlyManager { + function updatePoolCapacity(uint256 newCapacity) external onlyAdmin { require(newCapacity >= totalAssets(), "Pool: invalid capacity"); _poolSettings.maxCapacity = newCapacity; emit PoolSettingsUpdated(); @@ -334,16 +334,16 @@ contract Pool is IPool, ERC20 { /** * @inheritdoc IPool */ - function updatePoolEndDate(uint256 endDate) external onlyManager { + function updatePoolEndDate(uint256 endDate) external onlyAdmin { PoolLib.executeUpdateEndDate(endDate, _poolSettings); } /** - * @dev Called by the pool manager, this transfers liquidity from the pool to a given loan. + * @dev Called by the pool admin, this transfers liquidity from the pool to a given loan. */ function fundLoan(address addr) external - onlyManager + onlyAdmin atState(IPoolLifeCycleState.Active) isPoolLoan(addr) { @@ -365,7 +365,7 @@ contract Pool is IPool, ERC20 { /** * @inheritdoc IPool */ - function defaultLoan(address loan) external onlyManager { + function defaultLoan(address loan) external onlyAdmin { require(loan != address(0), "Pool: 0 address"); IPoolLifeCycleState state = lifeCycleState(); require( @@ -419,7 +419,7 @@ contract Pool is IPool, ERC20 { ); } - function claimFixedFee() external onlyManager { + function claimFixedFee() external onlyAdmin { require( _accountings.fixedFeeDueDate < block.timestamp, "Pool: fixed fee not due" diff --git a/contracts/interfaces/IPool.sol b/contracts/interfaces/IPool.sol index 1a510dc8..68e9b96d 100644 --- a/contracts/interfaces/IPool.sol +++ b/contracts/interfaces/IPool.sol @@ -130,9 +130,9 @@ interface IPool is IERC4626 { function withdrawGate() external view returns (uint256); /** - * @dev The manager for the pool. + * @dev The admin for the pool. */ - function manager() external view returns (address); + function admin() external view returns (address); /** * @dev The amount of first loss available to the pool. @@ -165,24 +165,24 @@ interface IPool is IERC4626 { function poolFeePercentOfInterest() external view returns (uint256); /** - * @dev Deposits first-loss to the pool. Can only be called by the Pool Manager. + * @dev Deposits first-loss to the pool. Can only be called by the Pool Admin. */ function depositFirstLoss(uint256 amount, address spender) external; /** - * @dev Withdraws first-loss from the pool. Can only be called by the Pool Manager. + * @dev Withdraws first-loss from the pool. Can only be called by the Pool Admin. */ function withdrawFirstLoss(uint256 amount, address receiver) external returns (uint256); /** - * @dev Updates the pool capacity. Can only be called by the Pool Manager. + * @dev Updates the pool capacity. Can only be called by the Pool Admin. */ function updatePoolCapacity(uint256) external; /** - * @dev Updates the pool end date. Can only be called by the Pool Manager. + * @dev Updates the pool end date. Can only be called by the Pool Admin. */ function updatePoolEndDate(uint256) external; @@ -208,7 +208,7 @@ interface IPool is IERC4626 { function liquidityPoolAssets() external view returns (uint256); /** - * @dev Called by the pool manager, this transfers liquidity from the pool to a given loan. + * @dev Called by the pool admin, this transfers liquidity from the pool to a given loan. */ function fundLoan(address) external; @@ -219,13 +219,13 @@ interface IPool is IERC4626 { function notifyLoanPrincipalReturned() external; /** - * @dev Called by the pool manager, this marks a loan as in default, triggering liquiditation + * @dev Called by the pool admin, this marks a loan as in default, triggering liquiditation * proceedings and updating pool accounting. */ function defaultLoan(address) external; /** - * @dev Called by the pool manager, this claims a fixed fee from the pool. Fee can only be + * @dev Called by the pool admin, this claims a fixed fee from the pool. Fee can only be * claimed once every interval, as set on the pool. */ function claimFixedFee() external; diff --git a/contracts/libraries/PoolLib.sol b/contracts/libraries/PoolLib.sol index 83795007..dfc58e46 100644 --- a/contracts/libraries/PoolLib.sol +++ b/contracts/libraries/PoolLib.sol @@ -155,7 +155,7 @@ library PoolLib { } /** - * @dev Withdraws first loss capital. Can only be called by the Pool manager under certain conditions. + * @dev Withdraws first loss capital. Can only be called by the Pool admin under certain conditions. * @param amount Amount of first loss being withdrawn * @param withdrawReceiver Where the liquidity should be withdrawn to * @param firstLossVault Vault holding first loss diff --git a/contracts/permissioned/PermissionedPool.sol b/contracts/permissioned/PermissionedPool.sol index a1fe9b97..3e135820 100644 --- a/contracts/permissioned/PermissionedPool.sol +++ b/contracts/permissioned/PermissionedPool.sol @@ -44,7 +44,7 @@ contract PermissionedPool is Pool { constructor( address factory, address liquidityAsset, - address poolManager, + address poolAdmin, address serviceConfiguration, IPoolConfigurableSettings memory poolSettings, string memory tokenName, @@ -53,7 +53,7 @@ contract PermissionedPool is Pool { Pool( factory, liquidityAsset, - poolManager, + poolAdmin, serviceConfiguration, poolSettings, tokenName, diff --git a/contracts/permissioned/PermissionedPoolFactory.sol b/contracts/permissioned/PermissionedPoolFactory.sol index 508ef866..c9d20f42 100644 --- a/contracts/permissioned/PermissionedPoolFactory.sol +++ b/contracts/permissioned/PermissionedPoolFactory.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import "./interfaces/IPoolManagerAccessControl.sol"; +import "./interfaces/IPoolAdminAccessControl.sol"; import "./interfaces/IPermissionedServiceConfiguration.sol"; import "../interfaces/IPoolWithdrawManagerFactory.sol"; import "../PoolFactory.sol"; @@ -25,14 +25,14 @@ contract PermissionedPoolFactory is PoolFactory { } /** - * @dev Check that `msg.sender` is a PoolManager. + * @dev Check that `msg.sender` is a PoolAdmin. */ - modifier onlyVerifiedPoolManager() { + modifier onlyVerifiedPoolAdmin() { require( - _serviceConfiguration.poolManagerAccessControl().isAllowed( + _serviceConfiguration.poolAdminAccessControl().isAllowed( msg.sender ), - "caller is not allowed pool manager" + "caller is not allowed pool admin" ); _; } @@ -44,7 +44,7 @@ contract PermissionedPoolFactory is PoolFactory { address liquidityAsset, address poolWithdrawManagerFactory, IPoolConfigurableSettings calldata settings - ) public override onlyVerifiedPoolManager returns (address poolAddress) { + ) public override onlyVerifiedPoolAdmin returns (address poolAddress) { require( settings.withdrawRequestPeriodDuration > 0, "PoolFactory: Invalid duration" diff --git a/contracts/permissioned/PermissionedServiceConfiguration.sol b/contracts/permissioned/PermissionedServiceConfiguration.sol index e8f90ddc..fe96ac8c 100644 --- a/contracts/permissioned/PermissionedServiceConfiguration.sol +++ b/contracts/permissioned/PermissionedServiceConfiguration.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import "./interfaces/IPoolManagerAccessControl.sol"; +import "./interfaces/IPoolAdminAccessControl.sol"; import "../ServiceConfiguration.sol"; /** @@ -9,21 +9,21 @@ import "../ServiceConfiguration.sol"; */ contract PermissionedServiceConfiguration is ServiceConfiguration { /** - * @dev Access Control logic for the Pool Manager role + * @dev Access Control logic for the Pool Admin role */ - IPoolManagerAccessControl public poolManagerAccessControl; + IPoolAdminAccessControl public poolAdminAccessControl; /** - * @dev Set the PoolManagerAccessControl contract. + * @dev Set the PoolAdminAccessControl contract. * @dev Emits `AddressSet` event. */ - function setPoolManagerAccessControl( - IPoolManagerAccessControl _poolManagerAccessControl + function setPoolAdminAccessControl( + IPoolAdminAccessControl _poolAdminAccessControl ) public onlyOperator { - poolManagerAccessControl = _poolManagerAccessControl; + poolAdminAccessControl = _poolAdminAccessControl; emit AddressSet( - "POOL_MANAGER_PERMISSION", - address(poolManagerAccessControl) + "POOL_ADMIN_PERMISSION", + address(poolAdminAccessControl) ); } } diff --git a/contracts/permissioned/PoolAccessControl.sol b/contracts/permissioned/PoolAccessControl.sol index 63642c31..5d1eacea 100644 --- a/contracts/permissioned/PoolAccessControl.sol +++ b/contracts/permissioned/PoolAccessControl.sol @@ -13,7 +13,7 @@ import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol"; * @dev Implementation of the {IPoolAccessControl} interface. * * This implementation implements a basic Allow-List of addresses, which can - * be managed only by the Pool Manager. + * be managed only by the Pool Admin. */ contract PoolAccessControl is IPoolAccessControl, @@ -85,10 +85,10 @@ contract PoolAccessControl is event CredentialSchemaRemoved(string schema); /** - * @dev Modifier that checks that the caller is the pool's manager. + * @dev Modifier that checks that the caller is the pool's admin. */ modifier onlyPoolAdmin() { - require(msg.sender == _pool.manager(), "Pool: caller is not manager"); + require(msg.sender == _pool.admin(), "Pool: caller is not admin"); _; } diff --git a/contracts/permissioned/PoolManagerAccessControl.sol b/contracts/permissioned/PoolAdminAccessControl.sol similarity index 89% rename from contracts/permissioned/PoolManagerAccessControl.sol rename to contracts/permissioned/PoolAdminAccessControl.sol index 74646ad3..824f4917 100644 --- a/contracts/permissioned/PoolManagerAccessControl.sol +++ b/contracts/permissioned/PoolAdminAccessControl.sol @@ -1,18 +1,18 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import "./interfaces/IPoolManagerAccessControl.sol"; +import "./interfaces/IPoolAdminAccessControl.sol"; import "./interfaces/IPermissionedServiceConfiguration.sol"; import "./interfaces/IToSAcceptanceRegistry.sol"; /** - * @title The PoolManagerAccessControl contract - * @dev Implementation of the {IPoolManagerAccessControl} interface. + * @title The PoolAdminAccessControl contract + * @dev Implementation of the {IPoolAdminAccessControl} interface. * * This implementation implements a basic Allow-List of addresses, which can * be managed only by the contract owner. */ -contract PoolManagerAccessControl is IPoolManagerAccessControl { +contract PoolAdminAccessControl is IPoolAdminAccessControl { /** * @dev Reference to the PermissionedServiceConfiguration contract */ @@ -24,7 +24,7 @@ contract PoolManagerAccessControl is IPoolManagerAccessControl { IToSAcceptanceRegistry private _tosRegistry; /** - * @dev A mapping of addresses to whether they are allowed as a Pool Manager + * @dev A mapping of addresses to whether they are allowed as a Pool Admin */ mapping(address => bool) private _allowList; @@ -63,7 +63,7 @@ contract PoolManagerAccessControl is IPoolManagerAccessControl { /** * @dev Checks against an allowList to see if the given address is allowed. - * @inheritdoc IPoolManagerAccessControl + * @inheritdoc IPoolAdminAccessControl */ function isAllowed(address addr) external view returns (bool) { return _allowList[addr]; diff --git a/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol b/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol index d8e3b11e..1c6b57e9 100644 --- a/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol +++ b/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.16; -import "./IPoolManagerAccessControl.sol"; +import "./IPoolAdminAccessControl.sol"; import "../../interfaces/IServiceConfiguration.sol"; /** @@ -11,8 +11,8 @@ interface IPermissionedServiceConfiguration is IServiceConfiguration { /** * @dev Determine whether the subject address has a verification record that is not expired */ - function poolManagerAccessControl() + function poolAdminAccessControl() external view - returns (IPoolManagerAccessControl); + returns (IPoolAdminAccessControl); } diff --git a/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol b/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol new file mode 100644 index 00000000..9516290f --- /dev/null +++ b/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity ^0.8.16; + +/** + * @title The interface for controlling permissions for Pool Admins + */ +interface IPoolAdminAccessControl { + /** + * @dev Check if an address is allowed as a Pool Admin + * @param addr The address to verify + * @return whether the address is allowed as a Pool Admin + */ + function isAllowed(address addr) external view returns (bool); +} diff --git a/contracts/permissioned/interfaces/IPoolManagerAccessControl.sol b/contracts/permissioned/interfaces/IPoolManagerAccessControl.sol deleted file mode 100644 index 828e7fc1..00000000 --- a/contracts/permissioned/interfaces/IPoolManagerAccessControl.sol +++ /dev/null @@ -1,14 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.16; - -/** - * @title The interface for controlling permissions for Pool Managers - */ -interface IPoolManagerAccessControl { - /** - * @dev Check if an address is allowed as a Pool Manager - * @param addr The address to verify - * @return whether the address is allowed as a Pool Manager - */ - function isAllowed(address addr) external view returns (bool); -} diff --git a/test/FeeVault.test.ts b/test/FeeVault.test.ts index 25c8d338..3fd07308 100644 --- a/test/FeeVault.test.ts +++ b/test/FeeVault.test.ts @@ -38,7 +38,7 @@ describe("FeeVault", () => { }); describe("withdraw()", async () => { - it("pool manager can withdraw amounts", async () => { + it("pool admin can withdraw amounts", async () => { const { feeVault, asset, pool, poolAdmin } = await loadFixture( deployFixture ); diff --git a/test/FirstLossVault.test.ts b/test/FirstLossVault.test.ts index f39776fe..4f993267 100644 --- a/test/FirstLossVault.test.ts +++ b/test/FirstLossVault.test.ts @@ -47,7 +47,7 @@ describe("FirstLossVault", () => { }); describe("withdraw()", async () => { - it("pool manager can withdrawn amounts", async () => { + it("pool admin can withdrawn amounts", async () => { const { firstLossVault, liquidityAsset, pool } = await loadFixture( deployFixture ); @@ -69,7 +69,7 @@ describe("FirstLossVault", () => { }); describe("Permissions", async () => { - it("only pool manager can withdraw", async () => { + it("only pool admin can withdraw", async () => { const { firstLossVault, pool, otherAccount } = await loadFixture( deployFixture ); diff --git a/test/Loan.test.ts b/test/Loan.test.ts index 8dfb0683..b901072d 100644 --- a/test/Loan.test.ts +++ b/test/Loan.test.ts @@ -26,17 +26,17 @@ describe("Loan", () => { }) ) { // Contracts are deployed using the first signer/account by default - const [operator, poolManager, borrower, lender, other] = + const [operator, poolAdmin, borrower, lender, other] = await ethers.getSigners(); // Create a pool const { pool, liquidityAsset, serviceConfiguration } = await deployPool({ operator, - poolAdmin: poolManager, + poolAdmin: poolAdmin, settings: poolSettings }); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const LoanLib = await ethers.getContractFactory("LoanLib"); const loanLib = await LoanLib.deploy(); @@ -93,7 +93,7 @@ describe("Loan", () => { loan, loanFactory, operator, - poolManager, + poolAdmin, borrower, collateralAsset, liquidityAsset, @@ -245,7 +245,7 @@ describe("Loan", () => { describe("cancelFunded", () => { it("reverts if not in Funded state", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); expect(await loan.state()).to.equal(0); // Requested @@ -259,14 +259,14 @@ describe("Loan", () => { "Loan: FunctionInvalidAtThisILoanLifeCycleState" ); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); expect(await loan.state()).to.equal(6); // Active await expect(loan.connect(borrower).cancelFunded()).to.be.revertedWith( "Loan: FunctionInvalidAtThisILoanLifeCycleState" ); - await pool.connect(poolManager).defaultLoan(loan.address); + await pool.connect(poolAdmin).defaultLoan(loan.address); expect(await loan.state()).to.equal(3); // Defaulted await expect(loan.connect(borrower).cancelFunded()).to.be.revertedWith( "Loan: FunctionInvalidAtThisILoanLifeCycleState" @@ -274,11 +274,11 @@ describe("Loan", () => { }); it("reverts if not called by borrower or PM", async () => { - const { borrower, liquidityAsset, other, loan, pool, poolManager } = + const { borrower, liquidityAsset, other, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await time.increaseTo(await loan.dropDeadTimestamp()); await expect(loan.connect(other).cancelFunded()).to.be.revertedWith( @@ -287,11 +287,11 @@ describe("Loan", () => { }); it("reverts if dropdead hasn't been met", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await expect(loan.connect(borrower).cancelFunded()).to.be.revertedWith( "Loan: Drop dead date not met" ); @@ -302,11 +302,11 @@ describe("Loan", () => { }); it("returns principal to the pool ", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); const principal = await loan.principal(); await time.increaseTo(await loan.dropDeadTimestamp()); @@ -325,11 +325,11 @@ describe("Loan", () => { }); it("emits an event", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await time.increaseTo(await loan.dropDeadTimestamp()); const principal = await loan.principal(); await expect(loan.connect(borrower).cancelFunded()) @@ -338,31 +338,31 @@ describe("Loan", () => { }); it("can be called by PM", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await time.increaseTo(await loan.dropDeadTimestamp()); - await expect(loan.connect(poolManager).cancelFunded()).not.to.be.reverted; + await expect(loan.connect(poolAdmin).cancelFunded()).not.to.be.reverted; }); it("can be called by borrower", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await time.increaseTo(await loan.dropDeadTimestamp()); await expect(loan.connect(borrower).cancelFunded()).not.to.be.reverted; }); it("transitions loan to canceled state", async () => { - const { borrower, liquidityAsset, loan, pool, poolManager } = + const { borrower, liquidityAsset, loan, pool, poolAdmin } = await loadFixture(deployFixture); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await time.increaseTo(await loan.dropDeadTimestamp()); expect(await loan.connect(borrower).cancelFunded()); @@ -374,14 +374,14 @@ describe("Loan", () => { describe("Permissions", () => { describe("Loan is Requested", () => { it("reverts if called by PM or borrower", async () => { - const { loan, borrower, poolManager } = await loadFixture( + const { loan, borrower, poolAdmin } = await loadFixture( deployFixture ); expect(await loan.state()).to.equal(0); // Requested await expect( - loan.connect(poolManager).claimCollateral([], []) + loan.connect(poolAdmin).claimCollateral([], []) ).to.be.revertedWith("Loan: unable to claim collateral"); await expect( @@ -392,7 +392,7 @@ describe("Loan", () => { describe("Loan is Collateralized", () => { it("reverts if called by PM or borrower", async () => { - const { loan, poolManager, collateralAsset, borrower } = + const { loan, poolAdmin, collateralAsset, borrower } = await loadFixture(deployFixture); // Post collateral @@ -400,7 +400,7 @@ describe("Loan", () => { expect(await loan.state()).to.equal(1); // Collateralized await expect( - loan.connect(poolManager).claimCollateral([], []) + loan.connect(poolAdmin).claimCollateral([], []) ).to.be.revertedWith("Loan: unable to claim collateral"); await expect( @@ -411,7 +411,7 @@ describe("Loan", () => { describe("Loan is Canceled", () => { it("reverts if called by PM", async () => { - const { loan, poolManager, borrower } = await loadFixture( + const { loan, poolAdmin, borrower } = await loadFixture( deployFixture ); @@ -420,7 +420,7 @@ describe("Loan", () => { expect(await loan.state()).to.equal(2); // canceled await expect( - loan.connect(poolManager).claimCollateral([], []) + loan.connect(poolAdmin).claimCollateral([], []) ).to.be.revertedWith("Loan: unable to claim collateral"); }); @@ -438,16 +438,16 @@ describe("Loan", () => { describe("Loan is funded", () => { it("reverts if called by PM or borrower", async () => { - const { loan, poolManager, pool, borrower, collateralAsset } = + const { loan, poolAdmin, pool, borrower, collateralAsset } = await loadFixture(deployFixture); // collateralize and fund loan await collateralizeLoan(loan, borrower, collateralAsset); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); expect(await loan.state()).to.equal(4); // funded await expect( - loan.connect(poolManager).claimCollateral([], []) + loan.connect(poolAdmin).claimCollateral([], []) ).to.be.revertedWith("Loan: unable to claim collateral"); await expect( @@ -458,14 +458,14 @@ describe("Loan", () => { describe("Loan is Defaulted", () => { it("reverts if called by the borrower", async () => { - const { loan, poolManager, pool, borrower, collateralAsset } = + const { loan, poolAdmin, pool, borrower, collateralAsset } = await loadFixture(deployFixture); // fund loan and default it await collateralizeLoan(loan, borrower, collateralAsset); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); - await pool.connect(poolManager).defaultLoan(loan.address); + await pool.connect(poolAdmin).defaultLoan(loan.address); expect(await loan.state()).to.equal(3); // defaulted await expect( @@ -474,17 +474,17 @@ describe("Loan", () => { }); it("PM can attempt claim", async () => { - const { loan, poolManager, pool, borrower, collateralAsset } = + const { loan, poolAdmin, pool, borrower, collateralAsset } = await loadFixture(deployFixture); // fund loan and default it await collateralizeLoan(loan, borrower, collateralAsset); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); - await pool.connect(poolManager).defaultLoan(loan.address); + await pool.connect(poolAdmin).defaultLoan(loan.address); expect(await loan.state()).to.equal(3); // defaulted - await expect(loan.connect(poolManager).claimCollateral([], [])).to.not + await expect(loan.connect(poolAdmin).claimCollateral([], [])).to.not .be.reverted; }); }); @@ -493,7 +493,7 @@ describe("Loan", () => { it("Reverts if called by PM", async () => { const { loan, - poolManager, + poolAdmin, liquidityAsset, pool, borrower, @@ -502,20 +502,20 @@ describe("Loan", () => { // fund and mature loan await collateralizeLoan(loan, borrower, collateralAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); await matureLoan(loan, borrower, liquidityAsset); expect(await loan.state()).to.equal(5); // matured await expect( - loan.connect(poolManager).claimCollateral([], []) + loan.connect(poolAdmin).claimCollateral([], []) ).to.be.revertedWith("Loan: unable to claim collateral"); }); it("Allows borrower to claim collateral", async () => { const { loan, - poolManager, + poolAdmin, liquidityAsset, pool, borrower, @@ -524,7 +524,7 @@ describe("Loan", () => { // fund and mature loan await collateralizeLoan(loan, borrower, collateralAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); await matureLoan(loan, borrower, liquidityAsset); expect(await loan.state()).to.equal(5); // matured @@ -730,7 +730,7 @@ describe("Loan", () => { it("transitions Loan to Funded state", async () => { const fixture = await loadFixture(deployFixture); let { loan } = fixture; - const { borrower, collateralAsset, liquidityAsset, pool, poolManager } = + const { borrower, collateralAsset, liquidityAsset, pool, poolAdmin } = fixture; // Connect as borrower @@ -741,7 +741,7 @@ describe("Loan", () => { await expect(loan.postFungibleCollateral(collateralAsset.address, 100)) .not.to.be.reverted; expect(await loan.state()).to.equal(1); - const fundTx = pool.connect(poolManager).fundLoan(loan.address); + const fundTx = pool.connect(poolAdmin).fundLoan(loan.address); await expect(fundTx).not.to.be.reverted; await expect(fundTx) .to.emit(loan, "LoanFunded") @@ -761,11 +761,11 @@ describe("Loan", () => { }); it("reverts if not in the collateralized state", async () => { - const { pool, poolManager, loan } = await loadFixture(deployFixture); + const { pool, poolAdmin, loan } = await loadFixture(deployFixture); expect(await loan.state()).to.equal(0); await expect( - pool.connect(poolManager).fundLoan(loan.address) + pool.connect(poolAdmin).fundLoan(loan.address) ).to.be.revertedWith("Loan: FunctionInvalidAtThisILoanLifeCycleState"); expect(await loan.state()).to.equal(0); }); @@ -799,7 +799,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup and fund loan @@ -809,7 +809,7 @@ describe("Loan", () => { .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100) ).not.to.be.reverted; - await expect(pool.connect(poolManager).fundLoan(loan.address)).not.to.be + await expect(pool.connect(poolAdmin).fundLoan(loan.address)).not.to.be .reverted; expect(await loan.state()).to.equal(4); @@ -859,9 +859,9 @@ describe("Loan", () => { it("transitions state only if defaulted while in an Active state", async () => { const fixture = await loadFixture(deployFixture); - const { borrower, collateralAsset, poolManager } = fixture; + const { borrower, collateralAsset, poolAdmin } = fixture; const loan = fixture.loan.connect(borrower); - const pool = fixture.pool.connect(poolManager); + const pool = fixture.pool.connect(poolAdmin); // Check Loan is in requested state; defaults should revert expect(await loan.state()).to.equal(0); @@ -915,7 +915,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -923,7 +923,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); // Make payment @@ -949,7 +949,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -957,7 +957,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); // Advance time to drop dead timestamp @@ -987,7 +987,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -995,7 +995,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); // Mint additional tokens to cover the interest payments @@ -1032,7 +1032,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -1040,7 +1040,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); // Mint additional tokens to cover the interest payments @@ -1070,7 +1070,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -1078,7 +1078,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); expect(await pool.poolFeePercentOfInterest()).to.equal(100); @@ -1107,7 +1107,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -1115,7 +1115,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); expect(await loan.originationFee()).to.equal(416); @@ -1144,12 +1144,12 @@ describe("Loan", () => { describe("callbacks", () => { it("can be called back by pool admin", async () => { const fixture = await loadFixture(deployFixture); - const { poolManager, loan } = fixture; + const { poolAdmin, loan } = fixture; // Callback timestamp defaults to 0 expect(await loan.callbackTimestamp()).to.equal(0); - const tx = loan.connect(poolManager).markCallback(); + const tx = loan.connect(poolAdmin).markCallback(); await expect(tx).not.to.be.reverted; // Callback timestamp should be set to latest block timestamp @@ -1177,7 +1177,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup and fund loan @@ -1187,7 +1187,7 @@ describe("Loan", () => { .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100) ).not.to.be.reverted; - await expect(pool.connect(poolManager).fundLoan(loan.address)).not.to.be + await expect(pool.connect(poolAdmin).fundLoan(loan.address)).not.to.be .reverted; expect(await loan.state()).to.equal(4); @@ -1225,7 +1225,7 @@ describe("Loan", () => { liquidityAsset, loan, pool, - poolManager + poolAdmin } = fixture; // Setup @@ -1233,7 +1233,7 @@ describe("Loan", () => { await loan .connect(borrower) .postFungibleCollateral(collateralAsset.address, 100); - await pool.connect(poolManager).fundLoan(loan.address); + await pool.connect(poolAdmin).fundLoan(loan.address); await loan.connect(borrower).drawdown(await loan.principal()); // Funding vault will now have no tokens. @@ -1304,9 +1304,9 @@ describe("Loan", () => { prepaidPrincipal ); - // Pool Manager can then reclaim the funds + // Pool Admin can then reclaim the funds const reclaimFundsTx = loan - .connect(poolManager) + .connect(poolAdmin) .reclaimFunds(prepaidPrincipal); await expect(reclaimFundsTx).to.not.be.reverted; await expect(reclaimFundsTx).to.changeTokenBalance( diff --git a/test/Pool.test.ts b/test/Pool.test.ts index 205bf4be..2b0a5e8b 100644 --- a/test/Pool.test.ts +++ b/test/Pool.test.ts @@ -11,11 +11,11 @@ import { deployLoan, collateralizeLoan, fundLoan } from "./support/loan"; describe("Pool", () => { async function loadPoolFixture() { - const [operator, poolManager, borrower, otherAccount, ...otherAccounts] = + const [operator, poolAdmin, borrower, otherAccount, ...otherAccounts] = await ethers.getSigners(); const { pool, liquidityAsset, serviceConfiguration } = await deployPool({ operator, - poolAdmin: poolManager + poolAdmin: poolAdmin }); const CollateralAsset = await ethers.getContractFactory("MockERC20"); @@ -33,7 +33,7 @@ describe("Pool", () => { pool, collateralAsset, liquidityAsset, - poolManager, + poolAdmin, borrower, otherAccount, loan, @@ -42,13 +42,13 @@ describe("Pool", () => { } async function loadPoolFixtureWithFees() { - const [operator, poolManager, otherAccount] = await ethers.getSigners(); + const [operator, poolAdmin, otherAccount] = await ethers.getSigners(); const settings = Object.assign({}, DEFAULT_POOL_SETTINGS); settings.fixedFee = 100; settings.fixedFeeInterval = 30; const { pool, liquidityAsset, serviceConfiguration } = await deployPool({ operator, - poolAdmin: poolManager, + poolAdmin: poolAdmin, settings }); @@ -59,20 +59,20 @@ describe("Pool", () => { serviceConfiguration ); - return { pool, liquidityAsset, poolManager, otherAccount, loan }; + return { pool, liquidityAsset, poolAdmin, otherAccount, loan }; } async function loanPoolFixtureWithMaturedLoan() { - const { pool, otherAccount, borrower, liquidityAsset, poolManager, loan } = + const { pool, otherAccount, borrower, liquidityAsset, poolAdmin, loan } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await liquidityAsset.connect(otherAccount).approve(pool.address, 1_000_000); await depositToPool(pool, otherAccount, liquidityAsset, 1_000_000); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); await liquidityAsset.connect(borrower).approve(loan.address, 2_000_000); @@ -98,18 +98,18 @@ describe("Pool", () => { describe("setRequestFee()", () => { it("sets the request fee in Bps", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); const originalSettings = await pool.settings(); expect(originalSettings.requestFeeBps).to.equal(500); - await pool.connect(poolManager).setRequestFee(1000); + await pool.connect(poolAdmin).setRequestFee(1000); const settings = await pool.settings(); expect(settings.requestFeeBps).to.equal(1000); }); - it("does not let anyone except the manager to set the fee", async () => { + it("does not let anyone except the admin to set the fee", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); const originalSettings = await pool.settings(); @@ -117,42 +117,42 @@ describe("Pool", () => { await expect( pool.connect(otherAccount).setRequestFee(10) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); it("does not allow setting the request fee once the pool is active", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); const originalSettings = await pool.settings(); expect(originalSettings.requestFeeBps).to.equal(500); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await expect( - pool.connect(poolManager).setRequestFee(10) + pool.connect(poolAdmin).setRequestFee(10) ).to.be.revertedWith("Pool: FunctionInvalidAtThisLifeCycleState"); }); }); describe("setWithdrawGate()", () => { it("sets the withdraw gate in Bps", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const originalSettings = await pool.settings(); expect(originalSettings.withdrawGateBps).to.equal(10_000); - await pool.connect(poolManager).setWithdrawGate(10); + await pool.connect(poolAdmin).setWithdrawGate(10); const settings = await pool.settings(); expect(settings.withdrawGateBps).to.equal(10); }); - it("does not let anyone except the manager to set the withdraw gate", async () => { + it("does not let anyone except the admin to set the withdraw gate", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); const originalSettings = await pool.settings(); @@ -160,7 +160,7 @@ describe("Pool", () => { await expect( pool.connect(otherAccount).setWithdrawGate(10) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); it("does not allow setting the request fee if the pool is paused", async () => { @@ -176,9 +176,9 @@ describe("Pool", () => { }); it("returns 100% if the pool is closed", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); - await pool.connect(poolManager).setWithdrawGate(0); + await pool.connect(poolAdmin).setWithdrawGate(0); expect(await pool.withdrawGate()).to.equal(0); // TODO: Close Pool @@ -188,7 +188,7 @@ describe("Pool", () => { describe("depositFirstLoss()", async () => { it("first loss can be deposited and transitions lifecycle state", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); @@ -197,14 +197,14 @@ describe("Pool", () => { // Grant allowance await liquidityAsset - .connect(poolManager) + .connect(poolAdmin) .approve(pool.address, firstLossAmount); // Contribute first loss expect( await pool - .connect(poolManager) - .depositFirstLoss(firstLossAmount, poolManager.address) + .connect(poolAdmin) + .depositFirstLoss(firstLossAmount, poolAdmin.address) ).to.emit(pool.address, "FirstLossDeposited"); // Check balance @@ -217,24 +217,18 @@ describe("Pool", () => { describe("withdrawFirstLoss()", async () => { it("reverts if pool is not closed", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); await expect( - pool.connect(poolManager).withdrawFirstLoss(10, poolManager.address) + pool.connect(poolAdmin).withdrawFirstLoss(10, poolAdmin.address) ).to.be.revertedWith("Pool: FunctionInvalidAtThisLifeCycleState"); }); it("reverts if pool is closed, but there are still active loans", async () => { - const { - pool, - poolManager, - borrower, - loan, - otherAccount, - liquidityAsset - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, borrower, loan, otherAccount, liquidityAsset } = + await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool( pool, otherAccount, @@ -242,7 +236,7 @@ describe("Pool", () => { await loan.principal() ); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); // Fast forward past pool close @@ -250,21 +244,15 @@ describe("Pool", () => { expect(await pool.lifeCycleState()).to.equal(3); // Closed await expect( - pool.connect(poolManager).withdrawFirstLoss(10, poolManager.address) + pool.connect(poolAdmin).withdrawFirstLoss(10, poolAdmin.address) ).to.be.revertedWith("Pool: loans still active"); }); it("can withdraw first loss to a receiver", async () => { - const { - pool, - poolManager, - borrower, - loan, - otherAccount, - liquidityAsset - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, borrower, loan, otherAccount, liquidityAsset } = + await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool( pool, otherAccount, @@ -272,7 +260,7 @@ describe("Pool", () => { await loan.principal() ); await collateralizeLoan(loan, borrower, liquidityAsset); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); // Pay down loan @@ -291,17 +279,17 @@ describe("Pool", () => { const firstLossAmt = await pool.firstLoss(); const firstLossVault = await pool.firstLossVault(); const txn = await pool - .connect(poolManager) - .withdrawFirstLoss(firstLossAmt, poolManager.address); + .connect(poolAdmin) + .withdrawFirstLoss(firstLossAmt, poolAdmin.address); await txn.wait(); expect(txn) .to.emit(pool, "FirstLossWithdrawn") - .withArgs(poolManager.address, poolManager.address, firstLossAmt); + .withArgs(poolAdmin.address, poolAdmin.address, firstLossAmt); await expect(txn).to.changeTokenBalance( liquidityAsset, - poolManager.address, + poolAdmin.address, +firstLossAmt ); await expect(txn).to.changeTokenBalance( @@ -324,22 +312,22 @@ describe("Pool", () => { }); it("depositing mints shares to receiver", async () => { - const { pool, otherAccount, liquidityAsset, poolManager } = + const { pool, otherAccount, liquidityAsset, poolAdmin } = await loadFixture(loadPoolFixture); const { firstLossInitialMinimum } = await pool.settings(); // First loss must be provided for deposits to open await liquidityAsset - .connect(poolManager) + .connect(poolAdmin) .approve(pool.address, firstLossInitialMinimum); // Contribute first loss await pool - .connect(poolManager) + .connect(poolAdmin) .depositFirstLoss( DEFAULT_POOL_SETTINGS.firstLossInitialMinimum, - poolManager.address + poolAdmin.address ); // Provide capital to lender @@ -375,22 +363,22 @@ describe("Pool", () => { }); it("minting mints shares to receiver", async () => { - const { pool, otherAccount, liquidityAsset, poolManager } = + const { pool, otherAccount, liquidityAsset, poolAdmin } = await loadFixture(loadPoolFixture); const { firstLossInitialMinimum } = await pool.settings(); // First loss must be provided for deposits to open await liquidityAsset - .connect(poolManager) + .connect(poolAdmin) .approve(pool.address, firstLossInitialMinimum); // Contribute first loss await pool - .connect(poolManager) + .connect(poolAdmin) .depositFirstLoss( DEFAULT_POOL_SETTINGS.firstLossInitialMinimum, - poolManager.address + poolAdmin.address ); // Provide capital to lender @@ -416,19 +404,19 @@ describe("Pool", () => { describe("defaultLoan()", () => { it("reverts if Pool state is initialized", async () => { - const { pool, poolManager, loan } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, loan } = await loadFixture(loadPoolFixture); await expect( - pool.connect(poolManager).defaultLoan(loan.address) + pool.connect(poolAdmin).defaultLoan(loan.address) ).to.be.revertedWith("Pool: FunctionInvalidAtThisLifeCycleState"); }); it("reverts if loan if Pool hasn't funded loan yet", async () => { - const { pool, poolManager, liquidityAsset, loan } = await loadFixture( + const { pool, poolAdmin, liquidityAsset, loan } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await expect( - pool.connect(poolManager).defaultLoan(loan.address) + pool.connect(poolAdmin).defaultLoan(loan.address) ).to.be.revertedWith("Pool: unfunded loan"); }); @@ -436,13 +424,13 @@ describe("Pool", () => { const { collateralAsset, pool, - poolManager, + poolAdmin, liquidityAsset, loan, borrower, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); // Collateralize loan await collateralizeLoan(loan, borrower, collateralAsset); @@ -450,7 +438,7 @@ describe("Pool", () => { // Deposit to pool and fund loan const loanPrincipal = await loan.principal(); await depositToPool(pool, otherAccount, liquidityAsset, loanPrincipal); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); // Confirm that pool liquidity reserve is now empty @@ -473,7 +461,7 @@ describe("Pool", () => { // Trigger default // Since first-loss is not enough to cover oustanding debt, all of it is used - await expect(pool.connect(poolManager).defaultLoan(loan.address)) + await expect(pool.connect(poolAdmin).defaultLoan(loan.address)) .to.emit(pool, "LoanDefaulted") .withArgs(loan.address) .to.emit(pool, "FirstLossApplied") @@ -502,14 +490,14 @@ describe("Pool", () => { const { collateralAsset, pool, - poolManager, + poolAdmin, liquidityAsset, loan, borrower, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await collateralizeLoan(loan, borrower, collateralAsset); await depositToPool( pool, @@ -517,7 +505,7 @@ describe("Pool", () => { liquidityAsset, await loan.principal() ); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); // Fast forward to pool end date @@ -525,8 +513,8 @@ describe("Pool", () => { expect(await pool.lifeCycleState()).to.equal(3); // Closed // Default should proceed - await expect(pool.connect(poolManager).defaultLoan(loan.address)).not.to - .be.reverted; + await expect(pool.connect(poolAdmin).defaultLoan(loan.address)).not.to.be + .reverted; }); }); @@ -536,13 +524,13 @@ describe("Pool", () => { const { collateralAsset, pool, - poolManager, + poolAdmin, liquidityAsset, loan, borrower } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await collateralizeLoan(loan, borrower, collateralAsset); // setup lender @@ -561,7 +549,7 @@ describe("Pool", () => { // Deposit and fund / drawdown loan await depositToPool(pool, lender, liquidityAsset, loanAmount); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(await loan.principal()); const drawdownTime = await time.latest(); @@ -584,23 +572,23 @@ describe("Pool", () => { describe("updatePoolCapacity()", () => { it("prevents setting capacity to less than current pool size", async () => { - const { pool, otherAccount, poolManager, liquidityAsset } = + const { pool, otherAccount, poolAdmin, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await expect( - pool.connect(poolManager).updatePoolCapacity(1) + pool.connect(poolAdmin).updatePoolCapacity(1) ).to.be.revertedWith("Pool: invalid capacity"); }); it("allows setting pool capacity", async () => { - const { pool, otherAccount, poolManager, liquidityAsset } = + const { pool, otherAccount, poolAdmin, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); - await expect(pool.connect(poolManager).updatePoolCapacity(101)).to.emit( + await expect(pool.connect(poolAdmin).updatePoolCapacity(101)).to.emit( pool, "PoolSettingsUpdated" ); @@ -673,32 +661,32 @@ describe("Pool", () => { describe("updatePoolEndDate()", () => { it("reverts if trying to move up end date", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); const newEndDate = (await pool.settings()).endDate.add(1); await expect( - pool.connect(poolManager).updatePoolEndDate(newEndDate) + pool.connect(poolAdmin).updatePoolEndDate(newEndDate) ).to.be.revertedWith("Pool: can't move end date up"); }); it("reverts if trying to set end date to be in the past", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); const now = time.latest(); await expect( - pool.connect(poolManager).updatePoolEndDate(now) + pool.connect(poolAdmin).updatePoolEndDate(now) ).to.be.revertedWith("Pool: can't move end date into the past"); }); it("allows moving up the pool end date", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); const newEndDate = (await pool.settings()).endDate.sub(1); await expect( - pool.connect(poolManager).updatePoolEndDate(newEndDate) + pool.connect(poolAdmin).updatePoolEndDate(newEndDate) ).to.emit(pool, "PoolSettingsUpdated"); expect((await pool.settings()).endDate).to.equal(newEndDate); }); @@ -706,139 +694,139 @@ describe("Pool", () => { describe("Permissions", () => { describe("updatePoolCapacity()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool.connect(otherAccount).updatePoolCapacity(1) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); }); describe("updatePoolEndDate()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool.connect(otherAccount).updatePoolEndDate(1) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); }); describe("fundLoan()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool.connect(otherAccount).fundLoan(otherAccount.address) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); it("reverts if pool is not active", async () => { - const { pool, otherAccount, poolManager } = await loadFixture( + const { pool, otherAccount, poolAdmin } = await loadFixture( loadPoolFixture ); expect(await pool.lifeCycleState()).to.equal(0); // initialized await expect( - pool.connect(poolManager).fundLoan(otherAccount.address) + pool.connect(poolAdmin).fundLoan(otherAccount.address) ).to.be.revertedWith("Pool: FunctionInvalidAtThisLifeCycleState"); }); it("reverts if loan address is not recognized", async () => { - const { pool, liquidityAsset, otherAccount, poolManager } = + const { pool, liquidityAsset, otherAccount, poolAdmin } = await loadFixture(loadPoolFixture); expect(await pool.lifeCycleState()).to.equal(0); // initialized - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); - await expect(pool.connect(poolManager).fundLoan(otherAccount.address)) - .to.be.reverted; + await expect(pool.connect(poolAdmin).fundLoan(otherAccount.address)).to + .be.reverted; }); }); describe("defaultLoan()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool.connect(otherAccount).defaultLoan(otherAccount.address) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); }); describe("depositFirstLoss()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool.connect(otherAccount).depositFirstLoss(100, otherAccount.address) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); }); describe("withdrawFirstLoss()", () => { - it("reverts if not called by Pool Manager", async () => { + it("reverts if not called by Pool Admin", async () => { const { pool, otherAccount } = await loadFixture(loadPoolFixture); await expect( pool .connect(otherAccount) .withdrawFirstLoss(100, otherAccount.address) - ).to.be.revertedWith("Pool: caller is not manager"); + ).to.be.revertedWith("Pool: caller is not admin"); }); }); }); describe("transfer()", async () => { it("transfers are disabled", async () => { - const { pool, poolManager, otherAccount } = await loadFixture( + const { pool, poolAdmin, otherAccount } = await loadFixture( loadPoolFixture ); - pool.mint(10, poolManager.address); + pool.mint(10, poolAdmin.address); await expect( - pool.connect(poolManager).transfer(otherAccount.address, 10) + pool.connect(poolAdmin).transfer(otherAccount.address, 10) ).to.be.revertedWith("Pool: transfers disabled"); }); it("transfer to zero address is denied", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); - pool.mint(10, poolManager.address); + pool.mint(10, poolAdmin.address); await expect( - pool.connect(poolManager).transfer(ethers.constants.AddressZero, 10) + pool.connect(poolAdmin).transfer(ethers.constants.AddressZero, 10) ).to.be.revertedWith("ERC20: transfer to the zero address"); }); }); describe("transferFrom()", async () => { it("transfers are disabled", async () => { - const { pool, poolManager, otherAccount } = await loadFixture( + const { pool, poolAdmin, otherAccount } = await loadFixture( loadPoolFixture ); - pool.mint(10, poolManager.address); - pool.connect(poolManager).approve(otherAccount.address, 10); + pool.mint(10, poolAdmin.address); + pool.connect(poolAdmin).approve(otherAccount.address, 10); await expect( pool .connect(otherAccount) - .transferFrom(poolManager.address, otherAccount.address, 10) + .transferFrom(poolAdmin.address, otherAccount.address, 10) ).to.be.revertedWith("Pool: transfers disabled"); }); it("transfer to zero address is denied", async () => { - const { pool, poolManager, otherAccount } = await loadFixture( + const { pool, poolAdmin, otherAccount } = await loadFixture( loadPoolFixture ); - pool.mint(10, poolManager.address); - pool.connect(poolManager).approve(otherAccount.address, 10); + pool.mint(10, poolAdmin.address); + pool.connect(poolAdmin).approve(otherAccount.address, 10); await expect( pool .connect(otherAccount) - .transferFrom(poolManager.address, ethers.constants.AddressZero, 10) + .transferFrom(poolAdmin.address, ethers.constants.AddressZero, 10) ).to.be.revertedWith("ERC20: transfer to the zero address"); }); }); @@ -852,19 +840,19 @@ describe("Pool", () => { }); it("returns the first period when the pool is activated", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); expect(await pool.withdrawPeriod()).to.equal(0); }); it("returns the second period when the first period has ended", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const { withdrawRequestPeriodDuration } = await pool.settings(); await time.increase(withdrawRequestPeriodDuration); @@ -875,9 +863,9 @@ describe("Pool", () => { describe("requestFee()", () => { it("returns the number of shares that will be charged to make this request", async () => { - const { pool, poolManager } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin } = await loadFixture(loadPoolFixture); - await pool.connect(poolManager).setRequestFee(500); // 5% + await pool.connect(poolAdmin).setRequestFee(500); // 5% expect(await pool.requestFee(1_000)).to.equal(50); }); @@ -885,9 +873,9 @@ describe("Pool", () => { describe("maxRedeemRequest()", () => { it("returns the current number of shares minus fees if no requests have been made", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); expect( @@ -898,9 +886,9 @@ describe("Pool", () => { }); it("returns the current number of shares minus existing requests and fees if any", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(51); @@ -913,9 +901,9 @@ describe("Pool", () => { }); it("returns 0 if the requested balance is > what is available", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); const max = await pool.maxRedeemRequest(otherAccount.address); @@ -929,9 +917,9 @@ describe("Pool", () => { }); it("allows calling this method to check another lender", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(51); @@ -942,11 +930,11 @@ describe("Pool", () => { describe("previewRedeemRequest", () => { it("returns the number of assets, minus fees, rounded down, that would be transferred in this redeem request, regardless of caller balance", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await pool.connect(poolManager).setRequestFee(1000); // 10% - await activatePool(pool, poolManager, liquidityAsset); + await pool.connect(poolAdmin).setRequestFee(1000); // 10% + await activatePool(pool, poolAdmin, liquidityAsset); // TODO: Show a non 1:1 share value expect(await pool.previewRedeemRequest(27)).to.equal(24); @@ -963,10 +951,10 @@ describe("Pool", () => { }); it("reverts if the lender has a zero balance", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await expect(pool.requestRedeem(100)).to.be.revertedWith( "Pool: caller is not a lender" @@ -974,9 +962,9 @@ describe("Pool", () => { }); it("reverts if the lender is requesting to redeem more than their balance", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -988,9 +976,9 @@ describe("Pool", () => { }); it("performs a redeem request, paying the fee", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1003,9 +991,9 @@ describe("Pool", () => { }); it("emits a RedeemRequested event if the lender requests a valid amount", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); const max = await pool.maxRedeemRequest(otherAccount.address); @@ -1018,9 +1006,9 @@ describe("Pool", () => { describe("maxWithdrawRequest(address)", () => { it("returns the current number of assets minus fees if no requests have been made", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); expect( @@ -1031,9 +1019,9 @@ describe("Pool", () => { }); it("returns the current number of assets minus existing requests and fees if any", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestWithdraw(51); @@ -1046,9 +1034,9 @@ describe("Pool", () => { }); it("returns 0 if the requested balance is > what is available", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); const max = await pool.maxWithdrawRequest(otherAccount.address); @@ -1062,9 +1050,9 @@ describe("Pool", () => { }); it("allows calling this method to check another lender", async () => { - const { pool, poolManager, otherAccount, liquidityAsset } = + const { pool, poolAdmin, otherAccount, liquidityAsset } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestWithdraw(51); @@ -1077,11 +1065,11 @@ describe("Pool", () => { describe("previewWithdrawRequest(assets)", () => { it("returns the share value of the provided assets, minus fees, regardless of caller balance", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await pool.connect(poolManager).setRequestFee(1000); // 10% - await activatePool(pool, poolManager, liquidityAsset); + await pool.connect(poolAdmin).setRequestFee(1000); // 10% + await activatePool(pool, poolAdmin, liquidityAsset); // TODO: Show a non 1:1 share value expect(await pool.previewWithdrawRequest(27)).to.equal(30); @@ -1098,10 +1086,10 @@ describe("Pool", () => { }); it("reverts if the lender has a zero balance", async () => { - const { pool, poolManager, liquidityAsset } = await loadFixture( + const { pool, poolAdmin, liquidityAsset } = await loadFixture( loadPoolFixture ); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await expect(pool.requestWithdraw(100)).to.be.revertedWith( "Pool: caller is not a lender" @@ -1109,9 +1097,9 @@ describe("Pool", () => { }); it("reverts if the lender is requesting to withdraw more than their balance", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1121,9 +1109,9 @@ describe("Pool", () => { }); it("performs a withdraw request, paying the fee", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1136,9 +1124,9 @@ describe("Pool", () => { }); it("emits a WithdrawRequested event if the lender requests a valid amount", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); const max = await pool.maxWithdrawRequest(otherAccount.address); @@ -1151,9 +1139,9 @@ describe("Pool", () => { describe("interestBearingBalanceOf()", () => { it("returns the number of shares minus the amount of redeemable shares", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1165,7 +1153,7 @@ describe("Pool", () => { const { withdrawRequestPeriodDuration } = await pool.settings(); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); const balance = await pool.balanceOf(otherAccount.address); const redeemable = await pool.maxRedeem(otherAccount.address); @@ -1181,9 +1169,9 @@ describe("Pool", () => { describe("requestedBalanceOf()", () => { it("returns the requested, but not yet eligible number of shares for a given lender", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(50); @@ -1196,16 +1184,11 @@ describe("Pool", () => { describe("totalRequestedBalance()", () => { it("returns the requested, but not yet eligible number of shares in this pool", async () => { - const { - pool, - poolManager, - liquidityAsset, - otherAccount, - otherAccounts - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = + await loadFixture(loadPoolFixture); const bob = otherAccounts[0]; - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await depositToPool(pool, bob, liquidityAsset, 200); @@ -1218,10 +1201,10 @@ describe("Pool", () => { describe("eligibleBalanceOf()", () => { it("returns the eligible number of shares for a given lender", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(50); @@ -1236,16 +1219,11 @@ describe("Pool", () => { describe("totalEligibleBalance()", () => { it("returns the eligible number of shares in this pool", async () => { - const { - pool, - poolManager, - liquidityAsset, - otherAccount, - otherAccounts - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = + await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); const bob = otherAccounts[0]; - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await depositToPool(pool, bob, liquidityAsset, 200); @@ -1262,16 +1240,16 @@ describe("Pool", () => { describe("maxRedeem()", () => { it("returns the redeemable number of shares for a given lender", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(10); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); expect(await pool.maxRedeem(otherAccount.address)).to.equal(10); }); @@ -1279,15 +1257,10 @@ describe("Pool", () => { describe("totalRedeemableShares()", () => { it("returns the redeemable number of shares in this pool", async () => { - const { - pool, - poolManager, - liquidityAsset, - otherAccount, - otherAccounts - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = + await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1299,7 +1272,7 @@ describe("Pool", () => { expect(await pool.connect(bob).totalRedeemableShares()).to.equal(0); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); expect(await pool.totalRedeemableShares()).to.equal(40); // 30 + 10 @@ -1316,16 +1289,16 @@ describe("Pool", () => { describe("maxWithdraw()", () => { it("returns the withdrawable number of shares for a given lender", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 100); await pool.connect(otherAccount).requestRedeem(10); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); expect(await pool.maxWithdraw(otherAccount.address)).to.equal(10); }); @@ -1333,15 +1306,10 @@ describe("Pool", () => { describe("totalWithdrawableAssets()", () => { it("returns the withdrawable number of shares in this pool", async () => { - const { - pool, - poolManager, - liquidityAsset, - otherAccount, - otherAccounts - } = await loadFixture(loadPoolFixture); + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = + await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1350,7 +1318,7 @@ describe("Pool", () => { await pool.connect(bob).requestRedeem(30); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); expect(await pool.totalWithdrawableAssets()).to.equal(40); @@ -1368,9 +1336,9 @@ describe("Pool", () => { describe("previewRedeem()", () => { it("returns the number of assets that will be returned if the requested shares were available on the current block", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); expect(await pool.connect(otherAccount).previewRedeem(100)).to.equal(100); }); @@ -1378,10 +1346,10 @@ describe("Pool", () => { describe("redeem()", () => { it("burns shares and transfers assets", async () => { - const { pool, poolManager, liquidityAsset, otherAccount, otherAccounts } = + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1390,7 +1358,7 @@ describe("Pool", () => { await pool.connect(bob).requestRedeem(30); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); const startingShares = await pool.balanceOf(otherAccount.address); const startingAssets = await liquidityAsset.balanceOf( @@ -1411,10 +1379,10 @@ describe("Pool", () => { }); it("reverts if the number of shares is too large", async () => { - const { pool, poolManager, liquidityAsset, otherAccount, otherAccounts } = + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1423,7 +1391,7 @@ describe("Pool", () => { await pool.connect(bob).requestRedeem(30); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); const max = await pool.maxRedeem(otherAccount.address); @@ -1461,10 +1429,10 @@ describe("Pool", () => { }); it("redeems the maxReedable amount", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixture); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); await depositToPool(pool, otherAccount, liquidityAsset, 1000); // Check that lender now has 1000 pool tokens and no USDC @@ -1499,10 +1467,10 @@ describe("Pool", () => { describe("withdraw()", () => { it("burns shares and transfers assets", async () => { - const { pool, poolManager, liquidityAsset, otherAccount, otherAccounts } = + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1511,7 +1479,7 @@ describe("Pool", () => { await pool.connect(bob).requestRedeem(30); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); const startingShares = await pool.balanceOf(otherAccount.address); const startingAssets = await liquidityAsset.balanceOf( @@ -1532,10 +1500,10 @@ describe("Pool", () => { }); it("reverts if the number of shares is too large", async () => { - const { pool, poolManager, liquidityAsset, otherAccount, otherAccounts } = + const { pool, poolAdmin, liquidityAsset, otherAccount, otherAccounts } = await loadFixture(loadPoolFixture); const { withdrawRequestPeriodDuration } = await pool.settings(); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); const bob = otherAccounts[0]; await depositToPool(pool, otherAccount, liquidityAsset, 100); @@ -1544,7 +1512,7 @@ describe("Pool", () => { await pool.connect(bob).requestRedeem(30); await time.increase(withdrawRequestPeriodDuration); - await pool.connect(poolManager).crank(); + await pool.connect(poolAdmin).crank(); const max = await pool.maxWithdraw(otherAccount.address); @@ -1584,26 +1552,26 @@ describe("Pool", () => { describe("fixed fees", () => { it("claiming fees is only available to the pool admin", async () => { - const { pool, poolManager, otherAccount } = await loadFixture( + const { pool, poolAdmin, otherAccount } = await loadFixture( loadPoolFixtureWithFees ); const tx = pool.connect(otherAccount).claimFixedFee(); - await expect(tx).to.be.revertedWith("Pool: caller is not manager"); + await expect(tx).to.be.revertedWith("Pool: caller is not admin"); }); it("cannot claim fees until they're due", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixtureWithFees); - await activatePool(pool, poolManager, liquidityAsset); - const tx = pool.connect(poolManager).claimFixedFee(); + await activatePool(pool, poolAdmin, liquidityAsset); + const tx = pool.connect(poolAdmin).claimFixedFee(); await expect(tx).to.revertedWith("Pool: fixed fee not due"); }); it("can claim fees when they're due", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixtureWithFees); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); // Mint tokens to the liquidity reserve await liquidityAsset.mint(pool.address, 500_000); @@ -1612,18 +1580,18 @@ describe("Pool", () => { await time.increase(30 * 96_400); // Claim Fees - const tx = pool.connect(poolManager).claimFixedFee(); - await expect(tx).to.changeTokenBalance(liquidityAsset, poolManager, 100); + const tx = pool.connect(poolAdmin).claimFixedFee(); + await expect(tx).to.changeTokenBalance(liquidityAsset, poolAdmin, 100); // Trying again will fail - const tx2 = pool.connect(poolManager).claimFixedFee(); + const tx2 = pool.connect(poolAdmin).claimFixedFee(); await expect(tx2).to.be.revertedWith("Pool: fixed fee not due"); }); it("can cumulatively claim fees when they're due", async () => { - const { pool, poolManager, liquidityAsset, otherAccount } = + const { pool, poolAdmin, liquidityAsset, otherAccount } = await loadFixture(loadPoolFixtureWithFees); - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); // Mint tokens to the liquidity reserve await liquidityAsset.mint(pool.address, 500_000); @@ -1632,11 +1600,11 @@ describe("Pool", () => { await time.increase(60 * 96_400); // Claim Fees - const tx = pool.connect(poolManager).claimFixedFee(); - await expect(tx).to.changeTokenBalance(liquidityAsset, poolManager, 100); + const tx = pool.connect(poolAdmin).claimFixedFee(); + await expect(tx).to.changeTokenBalance(liquidityAsset, poolAdmin, 100); - const tx2 = pool.connect(poolManager).claimFixedFee(); - await expect(tx2).to.changeTokenBalance(liquidityAsset, poolManager, 100); + const tx2 = pool.connect(poolAdmin).claimFixedFee(); + await expect(tx2).to.changeTokenBalance(liquidityAsset, poolAdmin, 100); }); }); }); diff --git a/test/permissioned/PermissionedPool.test.ts b/test/permissioned/PermissionedPool.test.ts index a991abaa..c4399306 100644 --- a/test/permissioned/PermissionedPool.test.ts +++ b/test/permissioned/PermissionedPool.test.ts @@ -5,14 +5,14 @@ import { deployPermissionedPool } from "../support/pool"; describe("PermissionedPool", () => { async function loadPoolFixture() { - const [operator, poolManager, otherAccount, thirdAccount] = + const [operator, poolAdmin, otherAccount, thirdAccount] = await ethers.getSigners(); const { pool, liquidityAsset } = await deployPermissionedPool({ operator, - poolAdmin: poolManager + poolAdmin: poolAdmin }); - return { pool, liquidityAsset, poolManager, otherAccount, thirdAccount }; + return { pool, liquidityAsset, poolAdmin, otherAccount, thirdAccount }; } describe("maxMint()", async () => { diff --git a/test/permissioned/PermissionedPoolFactory.test.ts b/test/permissioned/PermissionedPoolFactory.test.ts index a468b5ca..dd8c01e9 100644 --- a/test/permissioned/PermissionedPoolFactory.test.ts +++ b/test/permissioned/PermissionedPoolFactory.test.ts @@ -35,14 +35,14 @@ describe("PermissionedPoolFactory", () => { .connect(operator) .updateTermsOfService("https://terms.example"); - // Deploy the PoolManagerAccessControl contract - const PoolManagerAccessControl = await ethers.getContractFactory( - "PoolManagerAccessControl" + // Deploy the PoolAdminAccessControl contract + const PoolAdminAccessControl = await ethers.getContractFactory( + "PoolAdminAccessControl" ); - const poolManagerAccessControl = await PoolManagerAccessControl.deploy( + const poolAdminAccessControl = await PoolAdminAccessControl.deploy( permissionedServiceConfiguration.address ); - await poolManagerAccessControl.deployed(); + await poolAdminAccessControl.deployed(); // Deploy library for linking const PoolLib = await ethers.getContractFactory("PoolLib"); @@ -63,10 +63,9 @@ describe("PermissionedPoolFactory", () => { await poolFactory.deployed(); // Initialize ServiceConfiguration - const tx = - await permissionedServiceConfiguration.setPoolManagerAccessControl( - poolManagerAccessControl.address - ); + const tx = await permissionedServiceConfiguration.setPoolAdminAccessControl( + poolAdminAccessControl.address + ); await tx.wait(); const PoolWithdrawManagerFactory = await ethers.getContractFactory( @@ -84,7 +83,7 @@ describe("PermissionedPoolFactory", () => { return { poolFactory, - poolManagerAccessControl, + poolAdminAccessControl, operator, otherAccount, liquidityAsset, @@ -96,7 +95,7 @@ describe("PermissionedPoolFactory", () => { it("emits PoolCreated", async () => { const { poolFactory, - poolManagerAccessControl, + poolAdminAccessControl, otherAccount, liquidityAsset, tosAcceptanceRegistry, @@ -104,7 +103,7 @@ describe("PermissionedPoolFactory", () => { } = await loadFixture(deployFixture); await tosAcceptanceRegistry.connect(otherAccount).acceptTermsOfService(); - await poolManagerAccessControl.allow(otherAccount.getAddress()); + await poolAdminAccessControl.allow(otherAccount.getAddress()); await expect( poolFactory @@ -117,10 +116,10 @@ describe("PermissionedPoolFactory", () => { ).to.emit(poolFactory, "PoolCreated"); }); - it("reverts if not called by a Pool Manager", async () => { + it("reverts if not called by a Pool Admin", async () => { const { poolFactory, - poolManagerAccessControl, + poolAdminAccessControl, otherAccount, liquidityAsset, tosAcceptanceRegistry, @@ -128,7 +127,7 @@ describe("PermissionedPoolFactory", () => { } = await loadFixture(deployFixture); await tosAcceptanceRegistry.connect(otherAccount).acceptTermsOfService(); - await poolManagerAccessControl.allow(otherAccount.getAddress()); + await poolAdminAccessControl.allow(otherAccount.getAddress()); await expect( poolFactory.createPool( @@ -136,16 +135,16 @@ describe("PermissionedPoolFactory", () => { poolWithdrawManagerFactory.address, DEFAULT_POOL_SETTINGS ) - ).to.be.revertedWith("caller is not allowed pool manager"); + ).to.be.revertedWith("caller is not allowed pool admin"); }); it("access control reverts if PM hasn't accepted ToS", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); await expect( - poolManagerAccessControl.allow(otherAccount.getAddress()) + poolAdminAccessControl.allow(otherAccount.getAddress()) ).to.be.revertedWith("Pool: no ToS acceptance recorded"); }); }); diff --git a/test/permissioned/PoolManagerAccessControl.test.ts b/test/permissioned/PoolAdminAccessControl.test.ts similarity index 62% rename from test/permissioned/PoolManagerAccessControl.test.ts rename to test/permissioned/PoolAdminAccessControl.test.ts index de6eea68..d296d5eb 100644 --- a/test/permissioned/PoolManagerAccessControl.test.ts +++ b/test/permissioned/PoolAdminAccessControl.test.ts @@ -3,7 +3,7 @@ import { expect } from "chai"; import { ethers } from "hardhat"; import { deployToSAcceptanceRegistry } from "../support/tosacceptanceregistry"; -describe("PoolManagerAccessControl", () => { +describe("PoolAdminAccessControl", () => { // We define a fixture to reuse the same setup in every test. // We use loadFixture to run this setup once, snapshot that state, // and reset Hardhat Network to that snapshot in every test. @@ -27,17 +27,17 @@ describe("PoolManagerAccessControl", () => { tosAcceptanceRegistry.address ); - // Deploy the PoolManagerAccessControl contract - const PoolManagerAccessControl = await ethers.getContractFactory( - "PoolManagerAccessControl" + // Deploy the PoolAdminAccessControl contract + const PoolAdminAccessControl = await ethers.getContractFactory( + "PoolAdminAccessControl" ); - const poolManagerAccessControl = await PoolManagerAccessControl.deploy( + const poolAdminAccessControl = await PoolAdminAccessControl.deploy( serviceConfiguration.address ); - await poolManagerAccessControl.deployed(); + await poolAdminAccessControl.deployed(); return { - poolManagerAccessControl, + poolAdminAccessControl, otherAccount, tosAcceptanceRegistry }; @@ -45,31 +45,31 @@ describe("PoolManagerAccessControl", () => { describe("isAllowed()", () => { it("returns false if the address is not in the allow list", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(false); }); it("returns true if the address is on the allow list", async () => { - const { poolManagerAccessControl, otherAccount, tosAcceptanceRegistry } = + const { poolAdminAccessControl, otherAccount, tosAcceptanceRegistry } = await loadFixture(deployFixture); await tosAcceptanceRegistry.connect(otherAccount).acceptTermsOfService(); - await poolManagerAccessControl.allow(otherAccount.address); + await poolAdminAccessControl.allow(otherAccount.address); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(true); }); }); describe("allow()", () => { it("reverts when adding an address to the allowList if they haven't accepted ToS", async () => { - const { poolManagerAccessControl, otherAccount, tosAcceptanceRegistry } = + const { poolAdminAccessControl, otherAccount, tosAcceptanceRegistry } = await loadFixture(deployFixture); // No ToS acceptance @@ -77,46 +77,46 @@ describe("PoolManagerAccessControl", () => { .be.false; await expect( - poolManagerAccessControl.allow(otherAccount.address) + poolAdminAccessControl.allow(otherAccount.address) ).to.be.revertedWith("Pool: no ToS acceptance recorded"); }); it("adds an address to the allowList if they have accepted the ToS", async () => { - const { poolManagerAccessControl, otherAccount, tosAcceptanceRegistry } = + const { poolAdminAccessControl, otherAccount, tosAcceptanceRegistry } = await loadFixture(deployFixture); await tosAcceptanceRegistry.connect(otherAccount).acceptTermsOfService(); expect(await tosAcceptanceRegistry.hasAccepted(otherAccount.address)).to .be.true; - await poolManagerAccessControl.allow(otherAccount.address); + await poolAdminAccessControl.allow(otherAccount.address); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(true); }); it("succeeds if the address is already in the allowList", async () => { - const { poolManagerAccessControl, otherAccount, tosAcceptanceRegistry } = + const { poolAdminAccessControl, otherAccount, tosAcceptanceRegistry } = await loadFixture(deployFixture); await tosAcceptanceRegistry.connect(otherAccount).acceptTermsOfService(); - await poolManagerAccessControl.allow(otherAccount.address); - await poolManagerAccessControl.allow(otherAccount.address); + await poolAdminAccessControl.allow(otherAccount.address); + await poolAdminAccessControl.allow(otherAccount.address); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(true); }); describe("permissions", () => { it("reverts if not called by the ServiceConfiguration Operator role", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); await expect( - poolManagerAccessControl + poolAdminAccessControl .connect(otherAccount) .allow(otherAccount.getAddress()) ).to.be.revertedWith("caller is not an operator"); @@ -125,17 +125,14 @@ describe("PoolManagerAccessControl", () => { describe("events", () => { it("emits an AllowListUpdated event upon adding an address", async () => { - const { - poolManagerAccessControl, - otherAccount, - tosAcceptanceRegistry - } = await loadFixture(deployFixture); + const { poolAdminAccessControl, otherAccount, tosAcceptanceRegistry } = + await loadFixture(deployFixture); await tosAcceptanceRegistry .connect(otherAccount) .acceptTermsOfService(); - expect(await poolManagerAccessControl.allow(otherAccount.address)) - .to.emit(poolManagerAccessControl, "AllowListUpdated") + expect(await poolAdminAccessControl.allow(otherAccount.address)) + .to.emit(poolAdminAccessControl, "AllowListUpdated") .withArgs(otherAccount.address, true); }); }); @@ -143,38 +140,38 @@ describe("PoolManagerAccessControl", () => { describe("remove()", () => { it("removes an address from the allowList", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); - await poolManagerAccessControl.remove(otherAccount.address); - await poolManagerAccessControl.remove(otherAccount.address); + await poolAdminAccessControl.remove(otherAccount.address); + await poolAdminAccessControl.remove(otherAccount.address); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(false); }); it("returns false if the address is not in the allowList", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); - await poolManagerAccessControl.remove(otherAccount.address); + await poolAdminAccessControl.remove(otherAccount.address); expect( - await poolManagerAccessControl.isAllowed(otherAccount.address) + await poolAdminAccessControl.isAllowed(otherAccount.address) ).to.equal(false); }); describe("permissions", () => { it("reverts if not called by the ServiceConfiguration Operator role", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); await expect( - poolManagerAccessControl + poolAdminAccessControl .connect(otherAccount) .remove(otherAccount.getAddress()) ).to.be.revertedWith("caller is not an operator"); @@ -183,14 +180,14 @@ describe("PoolManagerAccessControl", () => { describe("events", () => { it("emits an AllowListUpdated event upon removing an address", async () => { - const { poolManagerAccessControl, otherAccount } = await loadFixture( + const { poolAdminAccessControl, otherAccount } = await loadFixture( deployFixture ); - await poolManagerAccessControl.remove(otherAccount.address); + await poolAdminAccessControl.remove(otherAccount.address); - await expect(poolManagerAccessControl.remove(otherAccount.address)) - .to.emit(poolManagerAccessControl, "AllowListUpdated") + await expect(poolAdminAccessControl.remove(otherAccount.address)) + .to.emit(poolAdminAccessControl, "AllowListUpdated") .withArgs(otherAccount.address, false); }); }); diff --git a/test/scenarios/business/1.test.ts b/test/scenarios/business/1.test.ts index afc02aa5..1c08a488 100644 --- a/test/scenarios/business/1.test.ts +++ b/test/scenarios/business/1.test.ts @@ -51,7 +51,7 @@ describe("Business Scenario 1", () => { } async function loadFixtures() { - const [operator, poolManager, lenderA, lenderB, borrowerOne, borrowerTwo] = + const [operator, poolAdmin, lenderA, lenderB, borrowerOne, borrowerTwo] = await ethers.getSigners(); const startTime = await time.latest(); @@ -67,7 +67,7 @@ describe("Business Scenario 1", () => { ); const { pool, serviceConfiguration } = await deployPool({ operator, - poolAdmin: poolManager, + poolAdmin: poolAdmin, settings: poolSettings, liquidityAsset: mockUSDC }); @@ -76,7 +76,7 @@ describe("Business Scenario 1", () => { expect(await serviceConfiguration.firstLossFeeBps()).to.equal(500); // activate pool - await activatePool(pool, poolManager, mockUSDC); + await activatePool(pool, poolAdmin, mockUSDC); // Mint for lenders await mockUSDC.mint(lenderA.address, INPUTS.lenderADepositAmount); @@ -121,7 +121,7 @@ describe("Business Scenario 1", () => { lenderA, lenderB, mockUSDC, - poolManager, + poolAdmin, borrowerOne, borrowerTwo, loanOne, @@ -136,7 +136,7 @@ describe("Business Scenario 1", () => { lenderA, lenderB, mockUSDC, - poolManager, + poolAdmin, borrowerOne, borrowerTwo, loanOne, @@ -147,7 +147,7 @@ describe("Business Scenario 1", () => { // check that FL is zero expect(await pool.firstLoss()).to.equal(0); // Check that PM has no USDC balance - expect(await mockUSDC.balanceOf(poolManager.address)).to.equal(0); + expect(await mockUSDC.balanceOf(poolAdmin.address)).to.equal(0); // +3 days, lenderA deposits await advanceToDay(startTime, 3); @@ -164,7 +164,7 @@ describe("Business Scenario 1", () => { // +4 days, loanOne is funded await advanceToDay(startTime, 4); - await fundLoan(loanOne, pool, poolManager); + await fundLoan(loanOne, pool, poolAdmin); await loanOne.connect(borrowerOne).drawdown(INPUTS.loanOne.principal); // +8 days, lenderB deposits @@ -180,7 +180,7 @@ describe("Business Scenario 1", () => { // +9 days, loanTwo funded await advanceToDay(startTime, 9); - await fundLoan(loanTwo, pool, poolManager); + await fundLoan(loanTwo, pool, poolAdmin); await loanTwo.connect(borrowerTwo).drawdown(INPUTS.loanTwo.principal); // +11 days, loan one matures diff --git a/test/scenarios/business/2.test.ts b/test/scenarios/business/2.test.ts index b679d852..79cd295a 100644 --- a/test/scenarios/business/2.test.ts +++ b/test/scenarios/business/2.test.ts @@ -39,7 +39,7 @@ describe("Business Scenario 2", () => { } async function fixtures() { - const [operator, poolManager, lenderA, lenderB, borrower] = + const [operator, poolAdmin, lenderA, lenderB, borrower] = await ethers.getSigners(); const endTime = (await time.latest()) + 5_184_000; // 60 days. const poolSettings = { @@ -53,7 +53,7 @@ describe("Business Scenario 2", () => { ); const { pool, serviceConfiguration } = await deployPool({ operator, - poolAdmin: poolManager, + poolAdmin: poolAdmin, settings: poolSettings, liquidityAsset: mockUSDC }); @@ -62,7 +62,7 @@ describe("Business Scenario 2", () => { expect(await serviceConfiguration.firstLossFeeBps()).to.equal(500); // activate pool - await activatePool(pool, poolManager, mockUSDC); + await activatePool(pool, poolAdmin, mockUSDC); const startTime = (await pool.poolActivatedAt()).toNumber(); // Mint for lenders @@ -97,7 +97,7 @@ describe("Business Scenario 2", () => { lenderA, lenderB, mockUSDC, - poolManager, + poolAdmin, borrower, loan }; @@ -110,7 +110,7 @@ describe("Business Scenario 2", () => { lenderA, lenderB, mockUSDC, - poolManager, + poolAdmin, borrower, loan } = await loadFixture(fixtures); @@ -119,7 +119,7 @@ describe("Business Scenario 2", () => { // check that FL is zero expect(await pool.firstLoss()).to.equal(0); // Check that PM has no USDC balance - expect(await mockUSDC.balanceOf(poolManager.address)).to.equal(0); + expect(await mockUSDC.balanceOf(poolAdmin.address)).to.equal(0); // +2 days, lenderA deposits await advanceToDay(startTime, 2); @@ -149,7 +149,7 @@ describe("Business Scenario 2", () => { // +4 days, loan is funded await advanceToDay(startTime, 4); - await fundLoan(loan, pool, poolManager); + await fundLoan(loan, pool, poolAdmin); await loan.connect(borrower).drawdown(INPUTS.loan.principal); // +7 days, lenderA requests 200k PT redemption diff --git a/test/scenarios/pool/withdraw-request.test.ts b/test/scenarios/pool/withdraw-request.test.ts index 9b5d257a..ff8e6b60 100644 --- a/test/scenarios/pool/withdraw-request.test.ts +++ b/test/scenarios/pool/withdraw-request.test.ts @@ -5,21 +5,21 @@ import { deployPool, depositToPool, activatePool } from "../../support/pool"; describe("Withdraw Requests", () => { async function loadPoolFixture() { - const [operator, poolManager, aliceLender, bobLender] = + const [operator, poolAdmin, aliceLender, bobLender] = await ethers.getSigners(); const { pool, liquidityAsset } = await deployPool({ operator, - poolAdmin: poolManager + poolAdmin: poolAdmin }); // Set the request fee to 10% - await pool.connect(poolManager).setRequestFee(1000); + await pool.connect(poolAdmin).setRequestFee(1000); // Set the withdraw gate to 25% - await pool.connect(poolManager).setWithdrawGate(2500); + await pool.connect(poolAdmin).setWithdrawGate(2500); // activate the pool - await activatePool(pool, poolManager, liquidityAsset); + await activatePool(pool, poolAdmin, liquidityAsset); // deposit 100 tokens from Alice await depositToPool(pool, aliceLender, liquidityAsset, 100); @@ -30,7 +30,7 @@ describe("Withdraw Requests", () => { return { pool, liquidityAsset, - poolManager, + poolAdmin, aliceLender, bobLender }; diff --git a/test/support/pool.ts b/test/support/pool.ts index 992ff70d..0c735e52 100644 --- a/test/support/pool.ts +++ b/test/support/pool.ts @@ -116,11 +116,11 @@ export async function deployPermissionedPool({ const { serviceConfiguration, tosAcceptanceRegistry, - poolManagerAccessControl + poolAdminAccessControl } = await deployPermissionedServiceConfiguration(operator); await tosAcceptanceRegistry.connect(poolAdmin).acceptTermsOfService(); - await poolManagerAccessControl.connect(operator).allow(poolAdmin.address); + await poolAdminAccessControl.connect(operator).allow(poolAdmin.address); const PoolLib = await ethers.getContractFactory("PoolLib"); const poolLib = await PoolLib.deploy(); @@ -181,7 +181,7 @@ export async function deployPermissionedPool({ serviceConfiguration, poolWithdrawManager, tosAcceptanceRegistry, - poolManagerAccessControl + poolAdminAccessControl }; } @@ -190,19 +190,19 @@ export async function deployPermissionedPool({ */ export async function activatePool( pool: Pool, - poolManager: any, + poolAdmin: any, liquidityAsset: MockERC20 ) { const { firstLossInitialMinimum } = await pool.settings(); // Grant allowance await liquidityAsset - .connect(poolManager) + .connect(poolAdmin) .approve(pool.address, firstLossInitialMinimum); await pool - .connect(poolManager) - .depositFirstLoss(firstLossInitialMinimum, poolManager.address); + .connect(poolAdmin) + .depositFirstLoss(firstLossInitialMinimum, poolAdmin.address); return { pool, liquidityAsset }; } diff --git a/test/support/serviceconfiguration.ts b/test/support/serviceconfiguration.ts index 7623307f..3d8cc596 100644 --- a/test/support/serviceconfiguration.ts +++ b/test/support/serviceconfiguration.ts @@ -39,21 +39,21 @@ export async function deployPermissionedServiceConfiguration(operator: any) { .connect(operator) .setToSAcceptanceRegistry(tosAcceptanceRegistry.address); - const PoolManagerAccessControl = await ethers.getContractFactory( - "PoolManagerAccessControl" + const PoolAdminAccessControl = await ethers.getContractFactory( + "PoolAdminAccessControl" ); - const poolManagerAccessControl = await PoolManagerAccessControl.deploy( + const poolAdminAccessControl = await PoolAdminAccessControl.deploy( serviceConfiguration.address ); - await poolManagerAccessControl.deployed(); + await poolAdminAccessControl.deployed(); await serviceConfiguration .connect(operator) - .setPoolManagerAccessControl(poolManagerAccessControl.address); + .setPoolAdminAccessControl(poolAdminAccessControl.address); return { serviceConfiguration, tosAcceptanceRegistry, - poolManagerAccessControl + poolAdminAccessControl }; }