From 1ffbd83302e887c1ad548ddd8dbf4947a3c40b3e Mon Sep 17 00:00:00 2001 From: Adrian Soghoian Date: Mon, 25 Sep 2023 10:22:17 -0400 Subject: [PATCH 1/2] Update license to Apache 2.0 --- LICENSE | 195 +++++++++++++-- contracts/Loan.sol | 47 ++-- contracts/Pool.sol | 224 ++++++++---------- contracts/ServiceConfiguration.sol | 51 ++-- contracts/Vault.sol | 24 +- contracts/controllers/PoolController.sol | 128 +++++----- contracts/controllers/WithdrawController.sol | 159 ++++++------- .../interfaces/IPoolController.sol | 23 +- .../interfaces/IWithdrawController.sol | 41 +++- contracts/factories/LoanFactory.sol | 16 +- contracts/factories/PoolControllerFactory.sol | 16 +- contracts/factories/PoolFactory.sol | 16 +- contracts/factories/VaultFactory.sol | 16 +- .../factories/WithdrawControllerFactory.sol | 24 +- .../factories/interfaces/ILoanFactory.sol | 16 +- .../interfaces/IPoolControllerFactory.sol | 16 +- .../factories/interfaces/IPoolFactory.sol | 23 +- .../factories/interfaces/IVaultFactory.sol | 16 +- .../interfaces/IWithdrawControllerFactory.sol | 16 +- contracts/interfaces/IERC4626.sol | 23 +- contracts/interfaces/ILoan.sol | 37 ++- contracts/interfaces/IPool.sol | 28 ++- contracts/interfaces/IRequestWithdrawable.sol | 77 +++--- .../interfaces/IServiceConfiguration.sol | 16 +- contracts/interfaces/IVault.sol | 16 +- contracts/libraries/LoanLib.sol | 36 ++- contracts/libraries/PoolLib.sol | 53 +++-- contracts/mocks/MockERC20.sol | 16 +- contracts/mocks/MockERC721.sol | 16 +- contracts/mocks/MockLoan.sol | 16 +- contracts/mocks/MockVeriteAccessControl.sol | 16 +- contracts/mocks/PoolLibTestWrapper.sol | 33 ++- contracts/mocks/upgrades/LoanMockV2.sol | 16 +- .../upgrades/MockBeaconImplementation.sol | 16 +- .../mocks/upgrades/MockBeaconProxyFactory.sol | 16 +- .../upgrades/MockDeployerUUPSUpgradeable.sol | 16 +- contracts/mocks/upgrades/MockUpgrade.sol | 16 +- .../upgrades/PoolAccessControlMockV2.sol | 16 +- .../upgrades/PoolAdminAccessControlMockV2.sol | 16 +- .../mocks/upgrades/PoolControllerMockV2.sol | 16 +- contracts/mocks/upgrades/PoolMockV2.sol | 16 +- .../upgrades/ServiceConfigurationMockV2.sol | 16 +- .../upgrades/ToSAcceptanceRegistryMockV2.sol | 16 +- contracts/mocks/upgrades/VaultMockV2.sol | 16 +- .../upgrades/WithdrawControllerMockV2.sol | 16 +- contracts/permissioned/PermissionedLoan.sol | 16 +- contracts/permissioned/PermissionedPool.sol | 43 ++-- .../PermissionedServiceConfiguration.sol | 16 +- contracts/permissioned/PoolAccessControl.sol | 56 +++-- .../permissioned/PoolAdminAccessControl.sol | 16 +- .../permissioned/ToSAcceptanceRegistry.sol | 24 +- .../permissioned/VeriteAccessControl.sol | 48 ++-- .../PermissionedPoolController.sol | 16 +- .../factories/PermissionedLoanFactory.sol | 23 +- .../factories/PermissionedPoolFactory.sol | 16 +- .../factories/PoolAccessControlFactory.sol | 16 +- .../interfaces/IPoolAccessControlFactory.sol | 16 +- .../IPermissionedServiceConfiguration.sol | 16 +- .../interfaces/IPoolAccessControl.sol | 16 +- .../interfaces/IPoolAdminAccessControl.sol | 16 +- .../interfaces/IToSAcceptanceRegistry.sol | 16 +- .../interfaces/IVeriteAccessControl.sol | 16 +- contracts/upgrades/BeaconImplementation.sol | 16 +- contracts/upgrades/BeaconProxyFactory.sol | 23 +- .../upgrades/DeployerUUPSUpgradeable.sol | 16 +- contracts/upgrades/interfaces/IBeacon.sol | 16 +- scripts/deploy-permissionless.ts | 15 ++ scripts/deploy.ts | 15 ++ scripts/verify-pool-admin.ts | 15 ++ scripts/verite-verify.ts | 16 ++ tasks/serviceConfiguration.ts | 15 ++ tasks/tosAcceptanceRegistry.ts | 15 ++ test/Loan.test.ts | 25 +- test/Pool.test.ts | 15 ++ test/ServiceConfiguration.test.ts | 15 ++ test/Vault.test.ts | 15 ++ test/controllers/PoolController.test.ts | 15 ++ test/controllers/WithdrawController.test.ts | 15 ++ test/factories/LoanFactory.test.ts | 15 ++ test/factories/PoolFactory.test.ts | 15 ++ test/factories/VaultFactory.test.ts | 15 ++ test/libraries/PoolLib.test.ts | 15 ++ test/permissioned/PermissionedLoan.test.ts | 15 ++ test/permissioned/PermissionedPool.test.ts | 15 ++ .../PermissionedPoolController.test.ts | 15 ++ test/permissioned/PoolAccessControl.test.ts | 15 ++ .../PoolAdminAccessControl.test.ts | 15 ++ test/permissioned/ToSConsentRegistry.test.ts | 15 ++ test/permissioned/VeriteAccessControl.test.ts | 15 ++ .../factories/PermissionedLoanFactory.test.ts | 15 ++ .../factories/PermissionedPoolFactory.test.ts | 15 ++ test/scenarios/business/1.test.ts | 15 ++ test/scenarios/business/2.test.ts | 15 ++ test/scenarios/business/3.test.ts | 15 ++ test/scenarios/business/4.test.ts | 15 ++ .../scenarios/business/permissioned/1.test.ts | 15 ++ .../scenarios/business/permissioned/2.test.ts | 15 ++ .../scenarios/business/permissioned/3.test.ts | 15 ++ .../scenarios/business/permissioned/4.test.ts | 15 ++ test/scenarios/pool/direct-deposit.test.ts | 15 ++ .../pool/fixed-term-defaulted.test.ts | 17 +- .../scenarios/pool/fixed-term-matured.test.ts | 21 +- .../pool/open-term-defaulted.test.ts | 17 +- test/scenarios/pool/open-term-matured.test.ts | 21 +- .../pool/snapshot-variations.test.ts | 15 ++ test/scenarios/pool/withdraw-dos.test.ts | 15 ++ test/scenarios/pool/withdraw-request.test.ts | 19 +- test/support/erc20.ts | 15 ++ test/support/loan.ts | 23 +- test/support/pool.ts | 15 ++ test/support/serviceconfiguration.ts | 15 ++ test/support/tosacceptanceregistry.ts | 15 ++ test/support/utils.ts | 15 ++ test/support/verite.ts | 15 ++ test/upgrades/BeaconImplementation.test.ts | 15 ++ test/upgrades/BeaconProxyFactory.test.ts | 15 ++ test/upgrades/DeployerUUPSUpgradeable.test.ts | 15 ++ 117 files changed, 2321 insertions(+), 598 deletions(-) diff --git a/LICENSE b/LICENSE index 142432d3..dd5b3a58 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,174 @@ -MIT License - -Copyright (c) 2022 Circle Internet Financial, LLC. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. diff --git a/contracts/Loan.sol b/contracts/Loan.sol index 896ab569..51525efc 100644 --- a/contracts/Loan.sol +++ b/contracts/Loan.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; @@ -278,7 +292,10 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function postFungibleCollateral(address asset, uint256 amount) + function postFungibleCollateral( + address asset, + uint256 amount + ) external virtual onlyNotPaused @@ -301,7 +318,10 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function postNonFungibleCollateral(address asset, uint256 tokenId) + function postNonFungibleCollateral( + address asset, + uint256 tokenId + ) external virtual onlyNotPaused @@ -352,7 +372,9 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function drawdown(uint256 amount) + function drawdown( + uint256 amount + ) external virtual onlyNotPaused @@ -377,12 +399,9 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function paydownPrincipal(uint256 amount) - external - onlyNotPaused - onlyPermittedBorrower - onlyBorrower - { + function paydownPrincipal( + uint256 amount + ) external onlyNotPaused onlyPermittedBorrower onlyBorrower { require(outstandingPrincipal >= amount, "Loan: amount too high"); require(settings.loanType == ILoanType.Open, "Loan: invalid loan type"); LoanLib.paydownPrincipal(liquidityAsset, amount, fundingVault); @@ -428,11 +447,9 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function previewFees(uint256 amount) - public - view - returns (ILoanFees memory) - { + function previewFees( + uint256 amount + ) public view returns (ILoanFees memory) { return LoanLib.previewFees( settings, diff --git a/contracts/Pool.sol b/contracts/Pool.sol index ecf8d95b..e390ad0e 100644 --- a/contracts/Pool.sol +++ b/contracts/Pool.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/ILoan.sol"; @@ -277,12 +291,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function fundLoan(address addr) - external - onlyNotPaused - onlyPoolController - onlySnapshottedPool - { + function fundLoan( + address addr + ) external onlyNotPaused onlyPoolController onlySnapshottedPool { require(!_fundedLoans[addr], "Pool: already funded"); _fundedLoans[addr] = true; ILoan loan = ILoan(addr); @@ -347,11 +358,10 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function onLoanDefaulted(address loan, uint256 firstLossApplied) - external - override - onlyPoolController - { + function onLoanDefaulted( + address loan, + uint256 firstLossApplied + ) external override onlyPoolController { uint256 outstandingPrincipal = ILoan(loan).outstandingPrincipal(); _accountings.outstandingLoanPrincipals -= outstandingPrincipal; _accountings.totalDefaults += outstandingPrincipal; @@ -437,12 +447,10 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function withdrawFeeVault(uint256 amount, address receiver) - external - onlyNotPaused - onlyPoolController - onlySnapshottedPool - { + function withdrawFeeVault( + uint256 amount, + address receiver + ) external onlyNotPaused onlyPoolController onlySnapshottedPool { _feeVault.withdrawERC20(address(_liquidityAsset), amount, receiver); } @@ -453,73 +461,63 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function maxRedeemRequest(address owner) - public - view - returns (uint256 maxShares) - { + function maxRedeemRequest( + address owner + ) public view returns (uint256 maxShares) { maxShares = withdrawController.maxRedeemRequest(owner); } /** * @inheritdoc IRequestWithdrawable */ - function maxWithdrawRequest(address owner) - public - view - returns (uint256 maxAssets) - { + function maxWithdrawRequest( + address owner + ) public view returns (uint256 maxAssets) { maxAssets = convertToAssets(maxRedeemRequest(owner)); } /** * @inheritdoc IRequestWithdrawable */ - function previewRedeemRequest(uint256 shares) - external - view - returns (uint256 assets) - { + function previewRedeemRequest( + uint256 shares + ) external view returns (uint256 assets) { assets = withdrawController.previewRedeemRequest(shares); } /** * @inheritdoc IRequestWithdrawable */ - function previewRedeemRequestFees(uint256 shares) - external - view - returns (uint256 feeShares) - { + function previewRedeemRequestFees( + uint256 shares + ) external view returns (uint256 feeShares) { feeShares = withdrawController.previewRedeemRequestFees(shares); } /** * @inheritdoc IRequestWithdrawable */ - function previewWithdrawRequest(uint256 assets) - external - view - returns (uint256 shares) - { + function previewWithdrawRequest( + uint256 assets + ) external view returns (uint256 shares) { shares = withdrawController.previewWithdrawRequest(assets); } /** * @inheritdoc IRequestWithdrawable */ - function previewWithdrawRequestFees(uint256 assets) - external - view - returns (uint256 feeShares) - { + function previewWithdrawRequestFees( + uint256 assets + ) external view returns (uint256 feeShares) { feeShares = withdrawController.previewWithdrawRequestFees(assets); } /** * @inheritdoc IRequestWithdrawable */ - function requestRedeem(uint256 shares) + function requestRedeem( + uint256 shares + ) external onlyNotPaused onlyActivatedPool @@ -535,7 +533,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function requestWithdraw(uint256 assets) + function requestWithdraw( + uint256 assets + ) external onlyNotPaused onlyActivatedPool @@ -572,18 +572,18 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function maxRequestCancellation(address owner) - public - view - returns (uint256 maxShares) - { + function maxRequestCancellation( + address owner + ) public view returns (uint256 maxShares) { maxShares = withdrawController.maxRequestCancellation(owner); } /** * @inheritdoc IRequestWithdrawable */ - function cancelRedeemRequest(uint256 shares) + function cancelRedeemRequest( + uint256 shares + ) external onlyNotPaused onlyActivatedPool @@ -599,7 +599,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function cancelWithdrawRequest(uint256 assets) + function cancelWithdrawRequest( + uint256 assets + ) external onlyNotPaused onlyActivatedPool @@ -661,7 +663,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function claimSnapshots(uint256 limit) + function claimSnapshots( + uint256 limit + ) external onlyNotPaused onlyPermittedLender @@ -705,12 +709,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function convertToShares(uint256 assets) - public - view - override - returns (uint256 shares) - { + function convertToShares( + uint256 assets + ) public view override returns (uint256 shares) { shares = PoolLib.calculateSharesFromAssets( assets, totalAvailableSupply(), @@ -722,12 +723,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function convertToAssets(uint256 shares) - public - view - override - returns (uint256 assets) - { + function convertToAssets( + uint256 shares + ) public view override returns (uint256 assets) { assets = PoolLib.calculateAssetsFromShares( shares, totalAvailableAssets(), @@ -739,13 +737,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxDeposit(address) - public - view - virtual - override - returns (uint256) - { + function maxDeposit( + address + ) public view virtual override returns (uint256) { if (_serviceConfiguration.paused() == true) { return 0; } @@ -760,12 +754,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewDeposit(uint256 assets) - public - view - override - returns (uint256 shares) - { + function previewDeposit( + uint256 assets + ) public view override returns (uint256 shares) { shares = PoolLib.calculateSharesFromAssets( assets, totalAvailableSupply(), @@ -778,7 +769,10 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function deposit(uint256 assets, address receiver) + function deposit( + uint256 assets, + address receiver + ) public virtual override @@ -804,25 +798,18 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxMint(address receiver) - public - view - virtual - override - returns (uint256) - { + function maxMint( + address receiver + ) public view virtual override returns (uint256) { return previewDeposit(maxDeposit(receiver)); } /** * @inheritdoc IERC4626 */ - function previewMint(uint256 shares) - public - view - override - returns (uint256 assets) - { + function previewMint( + uint256 shares + ) public view override returns (uint256 assets) { assets = PoolLib.calculateAssetsFromShares( shares, totalAvailableAssets() + @@ -835,7 +822,10 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function mint(uint256 shares, address receiver) + function mint( + uint256 shares, + address receiver + ) public virtual override @@ -862,13 +852,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxWithdraw(address owner) - public - view - virtual - override - returns (uint256 assets) - { + function maxWithdraw( + address owner + ) public view virtual override returns (uint256 assets) { if (_serviceConfiguration.paused() == true) { return 0; } @@ -878,12 +864,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewWithdraw(uint256 assets) - external - view - override - returns (uint256 shares) - { + function previewWithdraw( + uint256 assets + ) external view override returns (uint256 shares) { shares = withdrawController.previewWithdraw(msg.sender, assets); } @@ -917,13 +900,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxRedeem(address owner) - public - view - virtual - override - returns (uint256 maxShares) - { + function maxRedeem( + address owner + ) public view virtual override returns (uint256 maxShares) { if (_serviceConfiguration.paused() == true) { return 0; } @@ -933,12 +912,9 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewRedeem(uint256 shares) - external - view - override - returns (uint256 assets) - { + function previewRedeem( + uint256 shares + ) external view override returns (uint256 assets) { assets = withdrawController.previewRedeem(msg.sender, shares); } diff --git a/contracts/ServiceConfiguration.sol b/contracts/ServiceConfiguration.sol index bd4457b5..768bf568 100644 --- a/contracts/ServiceConfiguration.sol +++ b/contracts/ServiceConfiguration.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol"; @@ -103,11 +117,10 @@ contract ServiceConfiguration is /** * @dev Set a liquidity asset as valid or not. */ - function setLiquidityAsset(address addr, bool value) - public - override - onlyOperator - { + function setLiquidityAsset( + address addr, + bool value + ) public override onlyOperator { isLiquidityAsset[addr] = value; emit LiquidityAssetSet(addr, value); } @@ -137,11 +150,10 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setLoanFactory(address addr, bool isValid) - external - override - onlyOperator - { + function setLoanFactory( + address addr, + bool isValid + ) external override onlyOperator { isLoanFactory[addr] = isValid; emit LoanFactorySet(addr, isValid); } @@ -149,11 +161,9 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setToSAcceptanceRegistry(address addr) - external - override - onlyOperator - { + function setToSAcceptanceRegistry( + address addr + ) external override onlyOperator { tosAcceptanceRegistry = addr; emit TermsOfServiceRegistrySet(addr); } @@ -161,11 +171,10 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setFirstLossMinimum(address addr, uint256 value) - external - override - onlyOperator - { + function setFirstLossMinimum( + address addr, + uint256 value + ) external override onlyOperator { firstLossMinimum[addr] = value; emit FirstLossMinimumSet(addr, value); } diff --git a/contracts/Vault.sol b/contracts/Vault.sol index 8631811e..f2a28850 100644 --- a/contracts/Vault.sol +++ b/contracts/Vault.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IVault.sol"; @@ -39,10 +53,10 @@ contract Vault is /** * @dev Initialize function as a Beacon proxy implementation. */ - function initialize(address owner, address serviceConfiguration) - public - initializer - { + function initialize( + address owner, + address serviceConfiguration + ) public initializer { __ERC721Holder_init(); _transferOwnership(owner); _serviceConfiguration = IServiceConfiguration(serviceConfiguration); diff --git a/contracts/controllers/PoolController.sol b/contracts/controllers/PoolController.sol index 632d6ee3..7ad2905f 100644 --- a/contracts/controllers/PoolController.sol +++ b/contracts/controllers/PoolController.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IPool.sol"; @@ -185,7 +199,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setRequestFee(uint256 feeBps) + function setRequestFee( + uint256 feeBps + ) external onlyNotPaused onlyPermittedAdmin @@ -199,11 +215,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function requestFee(uint256 sharesOrAssets) - public - view - returns (uint256 feeShares) - { + function requestFee( + uint256 sharesOrAssets + ) public view returns (uint256 feeShares) { feeShares = PoolLib.calculateRequestFee( sharesOrAssets, _settings.requestFeeBps @@ -213,7 +227,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setRequestCancellationFee(uint256 feeBps) + function setRequestCancellationFee( + uint256 feeBps + ) external onlyNotPaused onlyPermittedAdmin @@ -227,11 +243,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function requestCancellationFee(uint256 sharesOrAssets) - public - view - returns (uint256 feeShares) - { + function requestCancellationFee( + uint256 sharesOrAssets + ) public view returns (uint256 feeShares) { feeShares = PoolLib.calculateCancellationFee( sharesOrAssets, _settings.requestCancellationFeeBps @@ -241,7 +255,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setWithdrawGate(uint256 _withdrawGateBps) + function setWithdrawGate( + uint256 _withdrawGateBps + ) external onlyNotPaused onlyPermittedAdmin @@ -279,12 +295,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setPoolCapacity(uint256 newCapacity) - external - onlyNotPaused - onlyPermittedAdmin - onlyAdmin - { + function setPoolCapacity( + uint256 newCapacity + ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { require(newCapacity >= pool.totalAssets(), "Pool: invalid capacity"); _settings.maxCapacity = newCapacity; emit PoolSettingsUpdated(); @@ -293,12 +306,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setPoolEndDate(uint256 endDate) - external - onlyNotPaused - onlyPermittedAdmin - onlyAdmin - { + function setPoolEndDate( + uint256 endDate + ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { require(_settings.endDate > endDate, "Pool: can't move end date up"); require( endDate > block.timestamp, @@ -325,12 +335,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setServiceFeeBps(uint256 serviceFeeBps) - external - onlyNotPaused - onlyPermittedAdmin - onlyAdmin - { + function setServiceFeeBps( + uint256 serviceFeeBps + ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { require(serviceFeeBps <= 10000, "Pool: invalid service fee"); _settings.serviceFeeBps = serviceFeeBps; emit PoolSettingsUpdated(); @@ -339,12 +346,10 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setFixedFee(uint256 amount, uint256 interval) - external - onlyNotPaused - onlyPermittedAdmin - onlyAdmin - { + function setFixedFee( + uint256 amount, + uint256 interval + ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { if (amount > 0) { require(interval > 0, "Pool: invalid fixed fee"); } @@ -415,7 +420,10 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function depositFirstLoss(uint256 amount, address spender) + function depositFirstLoss( + uint256 amount, + address spender + ) external onlyNotPaused onlyPermittedAdmin @@ -446,7 +454,10 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function withdrawFirstLoss(uint256 amount, address receiver) + function withdrawFirstLoss( + uint256 amount, + address receiver + ) external onlyNotPaused onlyPermittedAdmin @@ -479,7 +490,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function fundLoan(address addr) + function fundLoan( + address addr + ) external onlyNotPaused onlyPermittedAdmin @@ -493,7 +506,9 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function defaultLoan(address loan) + function defaultLoan( + address loan + ) external onlyNotPaused onlyPermittedAdmin @@ -515,7 +530,10 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function reclaimLoanFunds(address loan, uint256 amount) + function reclaimLoanFunds( + address loan, + uint256 amount + ) external override onlyNotPaused @@ -542,20 +560,18 @@ contract PoolController is IPoolController, BeaconImplementation { * @inheritdoc IPoolController * @dev Note that the Loan enforces the non-paused state, so it's omitted here. */ - function cancelFundedLoan(address loan) - external - override - onlyAdmin - onlyPermittedAdmin - onlySnapshottedPool - { + function cancelFundedLoan( + address loan + ) external override onlyAdmin onlyPermittedAdmin onlySnapshottedPool { ILoan(loan).cancelFunded(); } /** * @inheritdoc IPoolController */ - function markLoanCallback(address loan) + function markLoanCallback( + address loan + ) external override onlyNotPaused @@ -589,12 +605,10 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function withdrawFeeVault(uint256 amount, address receiver) - external - onlyNotPaused - onlyPermittedAdmin - onlyAdmin - { + function withdrawFeeVault( + uint256 amount, + address receiver + ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { pool.withdrawFeeVault(amount, receiver); } diff --git a/contracts/controllers/WithdrawController.sol b/contracts/controllers/WithdrawController.sol index 26f5b058..5ea83cf9 100644 --- a/contracts/controllers/WithdrawController.sol +++ b/contracts/controllers/WithdrawController.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IPool.sol"; @@ -17,7 +31,7 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; - uint256 public constant RAY = 10**27; + uint256 public constant RAY = 10 ** 27; /** * @dev A reference to the pool for this withdraw state @@ -73,11 +87,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @dev Returns the current withdraw state of an owner. */ - function _currentWithdrawState(address owner) - internal - view - returns (IPoolWithdrawState memory state) - { + function _currentWithdrawState( + address owner + ) internal view returns (IPoolWithdrawState memory state) { uint256 currentPeriod = withdrawPeriod(); state = PoolLib.progressWithdrawState( _withdrawState[owner], @@ -106,22 +118,18 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function interestBearingBalanceOf(address owner) - external - view - returns (uint256 shares) - { + function interestBearingBalanceOf( + address owner + ) external view returns (uint256 shares) { shares = _pool.balanceOf(owner) - maxRedeem(owner); } /** * @inheritdoc IWithdrawController */ - function requestedBalanceOf(address owner) - external - view - returns (uint256 shares) - { + function requestedBalanceOf( + address owner + ) external view returns (uint256 shares) { shares = _currentWithdrawState(owner).requestedShares; } @@ -135,11 +143,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function eligibleBalanceOf(address owner) - external - view - returns (uint256 shares) - { + function eligibleBalanceOf( + address owner + ) external view returns (uint256 shares) { shares = _currentWithdrawState(owner).eligibleShares; } @@ -171,11 +177,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function maxRedeemRequest(address owner) - external - view - returns (uint256 maxShares) - { + function maxRedeemRequest( + address owner + ) external view returns (uint256 maxShares) { maxShares = PoolLib.calculateMaxRedeemRequest( _currentWithdrawState(owner), _pool.balanceOf(owner), @@ -204,22 +208,18 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewRedeemRequest(uint256 shares) - external - view - returns (uint256 assets) - { + function previewRedeemRequest( + uint256 shares + ) external view returns (uint256 assets) { assets = _pool.convertToAssets(shares); } /** * @inheritdoc IWithdrawController */ - function previewRedeemRequestFees(uint256 shares) - external - view - returns (uint256 feeShares) - { + function previewRedeemRequestFees( + uint256 shares + ) external view returns (uint256 feeShares) { feeShares = PoolLib.calculateRequestFee( shares, _pool.settings().requestFeeBps @@ -229,22 +229,18 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewWithdrawRequest(uint256 assets) - external - view - returns (uint256 shares) - { + function previewWithdrawRequest( + uint256 assets + ) external view returns (uint256 shares) { shares = _pool.convertToShares(assets); } /** * @inheritdoc IWithdrawController */ - function previewWithdrawRequestFees(uint256 assets) - external - view - returns (uint256 feeShares) - { + function previewWithdrawRequestFees( + uint256 assets + ) external view returns (uint256 feeShares) { uint256 assetFees = PoolLib.calculateRequestFee( assets, _pool.settings().requestFeeBps @@ -256,11 +252,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewRedeem(address owner, uint256 shares) - external - view - returns (uint256 assets) - { + function previewRedeem( + address owner, + uint256 shares + ) external view returns (uint256 assets) { IPoolWithdrawState memory withdrawState = _currentWithdrawState(owner); assets = PoolLib.calculateAssetsFromShares( shares, @@ -273,11 +268,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewWithdraw(address owner, uint256 assets) - external - view - returns (uint256 shares) - { + function previewWithdraw( + address owner, + uint256 assets + ) external view returns (uint256 shares) { IPoolWithdrawState memory withdrawState = _currentWithdrawState(owner); shares = PoolLib.calculateSharesFromAssets( assets, @@ -331,11 +325,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function maxRequestCancellation(address owner) - public - view - returns (uint256 maxShares) - { + function maxRequestCancellation( + address owner + ) public view returns (uint256 maxShares) { maxShares = PoolLib.calculateMaxCancellation( _currentWithdrawState(owner) ); @@ -344,10 +336,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function performRequestCancellation(address owner, uint256 shares) - external - onlyPool - { + function performRequestCancellation( + address owner, + uint256 shares + ) external onlyPool { require( !claimRequired(owner), "WithdrawController: must claim eligible first" @@ -387,7 +379,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function snapshot(uint256 withdrawGate) + function snapshot( + uint256 withdrawGate + ) external onlyPool returns ( @@ -464,11 +458,9 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @dev Internal function used to avoid duplicate calls to _currentWithdrawState. */ - function _claimRequired(IPoolWithdrawState memory state) - internal - view - returns (bool) - { + function _claimRequired( + IPoolWithdrawState memory state + ) internal view returns (bool) { return state.eligibleShares > 0 && state.latestSnapshotPeriod < @@ -478,7 +470,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function claimSnapshots(address lender, uint256 limit) + function claimSnapshots( + address lender, + uint256 limit + ) external onlyPool returns (uint256 sharesRedeemable, uint256 assetsWithdrawable) @@ -550,11 +545,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function redeem(address owner, uint256 shares) - external - onlyPool - returns (uint256 assets) - { + function redeem( + address owner, + uint256 shares + ) external onlyPool returns (uint256 assets) { IPoolWithdrawState memory state = _withdrawState[owner]; // Calculate how many assets should be transferred @@ -571,11 +565,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function withdraw(address owner, uint256 assets) - external - onlyPool - returns (uint256 shares) - { + function withdraw( + address owner, + uint256 assets + ) external onlyPool returns (uint256 shares) { IPoolWithdrawState memory state = _withdrawState[owner]; // Calculate how many shares should be burned diff --git a/contracts/controllers/interfaces/IPoolController.sol b/contracts/controllers/interfaces/IPoolController.sol index 5de9ab5e..2844af3d 100644 --- a/contracts/controllers/interfaces/IPoolController.sol +++ b/contracts/controllers/interfaces/IPoolController.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../interfaces/IPool.sol"; @@ -196,9 +210,10 @@ interface IPoolController { /** * @dev Withdraws first-loss from the pool. Can only be called by the Pool Admin. */ - function withdrawFirstLoss(uint256 amount, address receiver) - external - returns (uint256); + function withdrawFirstLoss( + uint256 amount, + address receiver + ) external returns (uint256); /*////////////////////////////////////////////////////////////// Loans diff --git a/contracts/controllers/interfaces/IWithdrawController.sol b/contracts/controllers/interfaces/IWithdrawController.sol index 88485eaf..eec3fd04 100644 --- a/contracts/controllers/interfaces/IWithdrawController.sol +++ b/contracts/controllers/interfaces/IWithdrawController.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** @@ -132,10 +146,9 @@ interface IWithdrawController { * a redeem request at this current block. * */ - function previewRedeemRequestFees(uint256 shares) - external - view - returns (uint256 feeShares); + function previewRedeemRequestFees( + uint256 shares + ) external view returns (uint256 feeShares); /** * @dev Simulate the effects of a withdrawal request at the current block. @@ -150,10 +163,9 @@ interface IWithdrawController { * @dev Returns the amount of fees that would be burned, in shares, to fulfill * a withdraw request in this current block. */ - function previewWithdrawRequestFees(uint256 assets) - external - view - returns (uint256 feeShares); + function previewWithdrawRequestFees( + uint256 assets + ) external view returns (uint256 feeShares); /** * @dev Simulates the effects of their redeemption at the current block. @@ -204,9 +216,10 @@ interface IWithdrawController { * @dev Iterates over snapshots, up to a limit, and claims eligible funds earmarked * across the snapshots, updating the lenders withdrawal state accordingly. */ - function claimSnapshots(address lender, uint256 limit) - external - returns (uint256 shares, uint256 assets); + function claimSnapshots( + address lender, + uint256 limit + ) external returns (uint256 shares, uint256 assets); /** * @dev Determines whether a lender is "up to date" with the snapshots. @@ -220,7 +233,9 @@ interface IWithdrawController { /** * @dev Snapshot the protocol. Performs accounting for withdrawals */ - function snapshot(uint256 withdrawGate) + function snapshot( + uint256 withdrawGate + ) external returns ( uint256 period, diff --git a/contracts/factories/LoanFactory.sol b/contracts/factories/LoanFactory.sol index 25baa38d..c3476cbc 100644 --- a/contracts/factories/LoanFactory.sol +++ b/contracts/factories/LoanFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IServiceConfiguration.sol"; diff --git a/contracts/factories/PoolControllerFactory.sol b/contracts/factories/PoolControllerFactory.sol index 1cc421f8..bed46436 100644 --- a/contracts/factories/PoolControllerFactory.sol +++ b/contracts/factories/PoolControllerFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../controllers/PoolController.sol"; diff --git a/contracts/factories/PoolFactory.sol b/contracts/factories/PoolFactory.sol index 5648ecbd..776b658a 100644 --- a/contracts/factories/PoolFactory.sol +++ b/contracts/factories/PoolFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../Pool.sol"; diff --git a/contracts/factories/VaultFactory.sol b/contracts/factories/VaultFactory.sol index 3582de0c..ede6e857 100644 --- a/contracts/factories/VaultFactory.sol +++ b/contracts/factories/VaultFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IServiceConfiguration.sol"; diff --git a/contracts/factories/WithdrawControllerFactory.sol b/contracts/factories/WithdrawControllerFactory.sol index 1cbc633f..efe94e74 100644 --- a/contracts/factories/WithdrawControllerFactory.sol +++ b/contracts/factories/WithdrawControllerFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../controllers/WithdrawController.sol"; @@ -27,11 +41,9 @@ contract WithdrawControllerFactory is /** * @inheritdoc IWithdrawControllerFactory */ - function createController(address pool) - public - virtual - returns (address addr) - { + function createController( + address pool + ) public virtual returns (address addr) { require( _serviceConfiguration.paused() == false, "WithdrawControllerFactory: Protocol paused" diff --git a/contracts/factories/interfaces/ILoanFactory.sol b/contracts/factories/interfaces/ILoanFactory.sol index e5cdd1da..7f801478 100644 --- a/contracts/factories/interfaces/ILoanFactory.sol +++ b/contracts/factories/interfaces/ILoanFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../interfaces/ILoan.sol"; diff --git a/contracts/factories/interfaces/IPoolControllerFactory.sol b/contracts/factories/interfaces/IPoolControllerFactory.sol index f8df7daf..e4f03e74 100644 --- a/contracts/factories/interfaces/IPoolControllerFactory.sol +++ b/contracts/factories/interfaces/IPoolControllerFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../interfaces/IPool.sol"; diff --git a/contracts/factories/interfaces/IPoolFactory.sol b/contracts/factories/interfaces/IPoolFactory.sol index 878ee363..ee0e446d 100644 --- a/contracts/factories/interfaces/IPoolFactory.sol +++ b/contracts/factories/interfaces/IPoolFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../interfaces/IPool.sol"; @@ -16,7 +30,8 @@ interface IPoolFactory { * @dev Creates a Pool. * @dev Emits `PoolCreated` event. */ - function createPool(address, IPoolConfigurableSettings calldata) - external - returns (address); + function createPool( + address, + IPoolConfigurableSettings calldata + ) external returns (address); } diff --git a/contracts/factories/interfaces/IVaultFactory.sol b/contracts/factories/interfaces/IVaultFactory.sol index d2850387..5b748432 100644 --- a/contracts/factories/interfaces/IVaultFactory.sol +++ b/contracts/factories/interfaces/IVaultFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/factories/interfaces/IWithdrawControllerFactory.sol b/contracts/factories/interfaces/IWithdrawControllerFactory.sol index 3fa795d3..9d2f0477 100644 --- a/contracts/factories/interfaces/IWithdrawControllerFactory.sol +++ b/contracts/factories/interfaces/IWithdrawControllerFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index 483cfd44..fe0bd20e 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; @@ -65,9 +79,10 @@ interface IERC4626 is IERC20Upgradeable { * @dev Deposits assets of underlying tokens into the vault and grants ownership of shares to receiver. * Emits a {Deposit} event. */ - function deposit(uint256 assets, address receiver) - external - returns (uint256); + function deposit( + uint256 assets, + address receiver + ) external returns (uint256); /** * @dev Returns the maximum amount of shares that can be minted in a single mint call by the receiver. diff --git a/contracts/interfaces/ILoan.sol b/contracts/interfaces/ILoan.sol index dc386bf8..5ec9bd26 100644 --- a/contracts/interfaces/ILoan.sol +++ b/contracts/interfaces/ILoan.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./IServiceConfiguration.sol"; @@ -184,17 +198,17 @@ interface ILoan { * @dev Preview fees for a given interest payment amount. * @param amount allows previewing the fee for a full or prorated payment. */ - function previewFees(uint256 amount) - external - view - returns (ILoanFees memory); + function previewFees( + uint256 amount + ) external view returns (ILoanFees memory); /** * @dev Called by the borrower, this posts ERC20 assets to the collateral vault. */ - function postFungibleCollateral(address asset, uint256 amount) - external - returns (ILoanLifeCycleState); + function postFungibleCollateral( + address asset, + uint256 amount + ) external returns (ILoanLifeCycleState); /** * @dev Returns the ERC20 collateral posted to the loan. @@ -204,9 +218,10 @@ interface ILoan { /** * @dev Transfers and posts NFT collateral to be held by the loan's vault. */ - function postNonFungibleCollateral(address asset, uint256 tokenId) - external - returns (ILoanLifeCycleState); + function postNonFungibleCollateral( + address asset, + uint256 tokenId + ) external returns (ILoanLifeCycleState); /** * @dev Returns NFT collateral posted to the loan. diff --git a/contracts/interfaces/IPool.sol b/contracts/interfaces/IPool.sol index 065d10de..595da18e 100644 --- a/contracts/interfaces/IPool.sol +++ b/contracts/interfaces/IPool.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./IERC4626.sol"; @@ -188,11 +202,7 @@ interface IPool is IERC4626, IRequestWithdrawable { /** * @dev Called by the Pool Controller, it transfers the fixed fee */ - function claimFixedFee( - address, - uint256, - uint256 - ) external; + function claimFixedFee(address, uint256, uint256) external; /** * @dev Called by the Pool Controller, it withdraws from the FeeVault. @@ -218,9 +228,9 @@ interface IPool is IERC4626, IRequestWithdrawable { /** * @dev Claims funds earmarked across snapshots, up a limit of n snapshots. */ - function claimSnapshots(uint256 limit) - external - returns (uint256 shares, uint256 assets); + function claimSnapshots( + uint256 limit + ) external returns (uint256 shares, uint256 assets); /** * @dev Determines whether a lender has any funds across snapshots eligible for claiming. diff --git a/contracts/interfaces/IRequestWithdrawable.sol b/contracts/interfaces/IRequestWithdrawable.sol index fcb6d238..803e0efc 100644 --- a/contracts/interfaces/IRequestWithdrawable.sol +++ b/contracts/interfaces/IRequestWithdrawable.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; @@ -15,10 +29,9 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxRedeem` */ - function maxRedeemRequest(address owner) - external - view - returns (uint256 maxShares); + function maxRedeemRequest( + address owner + ) external view returns (uint256 maxShares); /** * @dev Returns the maximum amount of underlying `assets` that can be @@ -27,10 +40,9 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxWithdraw` */ - function maxWithdrawRequest(address owner) - external - view - returns (uint256 maxAssets); + function maxWithdrawRequest( + address owner + ) external view returns (uint256 maxAssets); /** * @dev Simulate the effects of a redeem request at the current block. @@ -39,20 +51,18 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `previewRedeem` */ - function previewRedeemRequest(uint256 shares) - external - view - returns (uint256 assets); + function previewRedeemRequest( + uint256 shares + ) external view returns (uint256 assets); /** * @dev Returns the amount of fees (shares) that would be required to process * a redeem request at this current block. * */ - function previewRedeemRequestFees(uint256 shares) - external - view - returns (uint256 feeShares); + function previewRedeemRequestFees( + uint256 shares + ) external view returns (uint256 feeShares); /** * @dev Simulate the effects of a withdrawal request at the current block. @@ -61,19 +71,17 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `previewWithdraw` */ - function previewWithdrawRequest(uint256 assets) - external - view - returns (uint256 shares); + function previewWithdrawRequest( + uint256 assets + ) external view returns (uint256 shares); /** * @dev Returns the amount of fees that would be burned, in shares, to fulfill * a withdraw request in this current block. */ - function previewWithdrawRequestFees(uint256 assets) - external - view - returns (uint256 feeShares); + function previewWithdrawRequestFees( + uint256 assets + ) external view returns (uint256 feeShares); /** * @dev Submits a withdrawal request, incurring a fee. @@ -91,10 +99,9 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxRedeem` */ - function maxRequestCancellation(address owner) - external - view - returns (uint256 maxShares); + function maxRequestCancellation( + address owner + ) external view returns (uint256 maxShares); /** * @dev Cancels a redeem request for a specific number of `shares` from @@ -103,9 +110,9 @@ interface IRequestWithdrawable { * * Emits a {WithdrawRequestCancelled} event. */ - function cancelRedeemRequest(uint256 shares) - external - returns (uint256 assets); + function cancelRedeemRequest( + uint256 shares + ) external returns (uint256 assets); /** * @dev Cancels a withdraw request for a specific values of `assets` from @@ -114,7 +121,7 @@ interface IRequestWithdrawable { * * Emits a {WithdrawRequestCancelled} event. */ - function cancelWithdrawRequest(uint256 assets) - external - returns (uint256 shares); + function cancelWithdrawRequest( + uint256 assets + ) external returns (uint256 shares); } diff --git a/contracts/interfaces/IServiceConfiguration.sol b/contracts/interfaces/IServiceConfiguration.sol index cdf43187..9bb26282 100644 --- a/contracts/interfaces/IServiceConfiguration.sol +++ b/contracts/interfaces/IServiceConfiguration.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/interfaces/IVault.sol b/contracts/interfaces/IVault.sol index e2d87707..1c93eb61 100644 --- a/contracts/interfaces/IVault.sol +++ b/contracts/interfaces/IVault.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; diff --git a/contracts/libraries/LoanLib.sol b/contracts/libraries/LoanLib.sol index 8ac0fd4e..c696c14d 100644 --- a/contracts/libraries/LoanLib.sol +++ b/contracts/libraries/LoanLib.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {IERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; @@ -15,7 +29,7 @@ library LoanLib { using SafeERC20 for IERC20; using SafeMath for uint256; - uint256 public constant RAY = 10**27; + uint256 public constant RAY = 10 ** 27; /** * @dev Emitted when loan is funded. @@ -294,19 +308,17 @@ library LoanLib { emit CanceledLoanPrincipalReturned(pool, amount); } - function previewFirstLossFee(uint256 payment, uint256 firstLossFeeBps) - public - pure - returns (uint256) - { + function previewFirstLossFee( + uint256 payment, + uint256 firstLossFeeBps + ) public pure returns (uint256) { return RAY.mul(payment).mul(firstLossFeeBps).div(100_00).div(RAY); } - function previewServiceFee(uint256 payment, uint256 serviceFeeBps) - public - pure - returns (uint256) - { + function previewServiceFee( + uint256 payment, + uint256 serviceFeeBps + ) public pure returns (uint256) { return RAY.mul(payment).mul(serviceFeeBps).div(100_00).div(RAY); } diff --git a/contracts/libraries/PoolLib.sol b/contracts/libraries/PoolLib.sol index 10a84294..117e8bab 100644 --- a/contracts/libraries/PoolLib.sol +++ b/contracts/libraries/PoolLib.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -21,7 +35,7 @@ library PoolLib { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; - uint256 public constant RAY = 10**27; + uint256 public constant RAY = 10 ** 27; /** * @dev See IPoolController */ @@ -88,11 +102,10 @@ library PoolLib { /** * @dev Divide two numbers and round the result up */ - function divideCeil(uint256 lhs, uint256 rhs) - internal - pure - returns (uint256) - { + function divideCeil( + uint256 lhs, + uint256 rhs + ) internal pure returns (uint256) { return (lhs + rhs - 1) / rhs; } @@ -273,11 +286,10 @@ library PoolLib { * If the pool has assets, it is solvent. If no assets are available, * but no shares have been issued, it is solvent. Otherwise, it is insolvent. */ - function isSolvent(uint256 totalAssets, uint256 totalShares) - private - pure - returns (bool) - { + function isSolvent( + uint256 totalAssets, + uint256 totalShares + ) private pure returns (bool) { return totalAssets > 0 || totalShares == 0; } @@ -506,11 +518,10 @@ library PoolLib { * @dev Calculate the fee for making a withdrawRequest or a redeemRequest. * Per the EIP-4626 spec, this method rounds up. */ - function calculateRequestFee(uint256 shares, uint256 requestFeeBps) - public - pure - returns (uint256) - { + function calculateRequestFee( + uint256 shares, + uint256 requestFeeBps + ) public pure returns (uint256) { return divideCeil(shares * requestFeeBps, 10_000); } @@ -545,11 +556,9 @@ library PoolLib { * @dev Calculates the Maximum amount of shares that can be cancelled * from the current withdraw request. */ - function calculateMaxCancellation(IPoolWithdrawState memory state) - public - pure - returns (uint256) - { + function calculateMaxCancellation( + IPoolWithdrawState memory state + ) public pure returns (uint256) { return state.requestedShares + state.eligibleShares; } diff --git a/contracts/mocks/MockERC20.sol b/contracts/mocks/MockERC20.sol index b7b6c1ab..08c9068d 100644 --- a/contracts/mocks/MockERC20.sol +++ b/contracts/mocks/MockERC20.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {ERC20PresetMinterPauser} from "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; diff --git a/contracts/mocks/MockERC721.sol b/contracts/mocks/MockERC721.sol index 4152b9e7..a28c7f96 100644 --- a/contracts/mocks/MockERC721.sol +++ b/contracts/mocks/MockERC721.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {ERC721PresetMinterPauserAutoId} from "@openzeppelin/contracts/token/ERC721/presets/ERC721PresetMinterPauserAutoId.sol"; diff --git a/contracts/mocks/MockLoan.sol b/contracts/mocks/MockLoan.sol index 0b980adf..06b3f22d 100644 --- a/contracts/mocks/MockLoan.sol +++ b/contracts/mocks/MockLoan.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/ILoan.sol"; diff --git a/contracts/mocks/MockVeriteAccessControl.sol b/contracts/mocks/MockVeriteAccessControl.sol index 19dcb270..db08233b 100644 --- a/contracts/mocks/MockVeriteAccessControl.sol +++ b/contracts/mocks/MockVeriteAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import {VeriteAccessControl} from "../permissioned/VeriteAccessControl.sol"; diff --git a/contracts/mocks/PoolLibTestWrapper.sol b/contracts/mocks/PoolLibTestWrapper.sol index 7d94f4cd..9f6a5a57 100644 --- a/contracts/mocks/PoolLibTestWrapper.sol +++ b/contracts/mocks/PoolLibTestWrapper.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../libraries/PoolLib.sol"; @@ -243,11 +257,10 @@ contract PoolLibTestWrapper is ERC20("PoolLibTest", "PLT") { ); } - function calculateRequestFee(uint256 shares, uint256 requestFeeBps) - external - pure - returns (uint256) - { + function calculateRequestFee( + uint256 shares, + uint256 requestFeeBps + ) external pure returns (uint256) { return PoolLib.calculateRequestFee(shares, requestFeeBps); } @@ -272,11 +285,9 @@ contract PoolLibTestWrapper is ERC20("PoolLibTest", "PLT") { ); } - function calculateMaxCancellation(IPoolWithdrawState memory state) - public - pure - returns (uint256) - { + function calculateMaxCancellation( + IPoolWithdrawState memory state + ) public pure returns (uint256) { return PoolLib.calculateMaxCancellation(state); } } diff --git a/contracts/mocks/upgrades/LoanMockV2.sol b/contracts/mocks/upgrades/LoanMockV2.sol index f1f622aa..04865086 100644 --- a/contracts/mocks/upgrades/LoanMockV2.sol +++ b/contracts/mocks/upgrades/LoanMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../Loan.sol"; diff --git a/contracts/mocks/upgrades/MockBeaconImplementation.sol b/contracts/mocks/upgrades/MockBeaconImplementation.sol index 8aa83670..4965d82b 100644 --- a/contracts/mocks/upgrades/MockBeaconImplementation.sol +++ b/contracts/mocks/upgrades/MockBeaconImplementation.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../upgrades/BeaconImplementation.sol"; diff --git a/contracts/mocks/upgrades/MockBeaconProxyFactory.sol b/contracts/mocks/upgrades/MockBeaconProxyFactory.sol index a5448642..5fb1a948 100644 --- a/contracts/mocks/upgrades/MockBeaconProxyFactory.sol +++ b/contracts/mocks/upgrades/MockBeaconProxyFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../upgrades/BeaconProxyFactory.sol"; diff --git a/contracts/mocks/upgrades/MockDeployerUUPSUpgradeable.sol b/contracts/mocks/upgrades/MockDeployerUUPSUpgradeable.sol index febcb50c..a5ff510d 100644 --- a/contracts/mocks/upgrades/MockDeployerUUPSUpgradeable.sol +++ b/contracts/mocks/upgrades/MockDeployerUUPSUpgradeable.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../upgrades/DeployerUUPSUpgradeable.sol"; diff --git a/contracts/mocks/upgrades/MockUpgrade.sol b/contracts/mocks/upgrades/MockUpgrade.sol index a4dd5d85..b3aa4f8a 100644 --- a/contracts/mocks/upgrades/MockUpgrade.sol +++ b/contracts/mocks/upgrades/MockUpgrade.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; abstract contract MockUpgrade { diff --git a/contracts/mocks/upgrades/PoolAccessControlMockV2.sol b/contracts/mocks/upgrades/PoolAccessControlMockV2.sol index e15979e8..54e77777 100644 --- a/contracts/mocks/upgrades/PoolAccessControlMockV2.sol +++ b/contracts/mocks/upgrades/PoolAccessControlMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../permissioned/PoolAccessControl.sol"; diff --git a/contracts/mocks/upgrades/PoolAdminAccessControlMockV2.sol b/contracts/mocks/upgrades/PoolAdminAccessControlMockV2.sol index 861cb33a..b8ef75b0 100644 --- a/contracts/mocks/upgrades/PoolAdminAccessControlMockV2.sol +++ b/contracts/mocks/upgrades/PoolAdminAccessControlMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../permissioned/PoolAdminAccessControl.sol"; diff --git a/contracts/mocks/upgrades/PoolControllerMockV2.sol b/contracts/mocks/upgrades/PoolControllerMockV2.sol index 058569d6..b6b67e8b 100644 --- a/contracts/mocks/upgrades/PoolControllerMockV2.sol +++ b/contracts/mocks/upgrades/PoolControllerMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../controllers/PoolController.sol"; diff --git a/contracts/mocks/upgrades/PoolMockV2.sol b/contracts/mocks/upgrades/PoolMockV2.sol index ff918e2d..ee9c5f6a 100644 --- a/contracts/mocks/upgrades/PoolMockV2.sol +++ b/contracts/mocks/upgrades/PoolMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../Pool.sol"; diff --git a/contracts/mocks/upgrades/ServiceConfigurationMockV2.sol b/contracts/mocks/upgrades/ServiceConfigurationMockV2.sol index 56de396b..bdca4190 100644 --- a/contracts/mocks/upgrades/ServiceConfigurationMockV2.sol +++ b/contracts/mocks/upgrades/ServiceConfigurationMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../ServiceConfiguration.sol"; diff --git a/contracts/mocks/upgrades/ToSAcceptanceRegistryMockV2.sol b/contracts/mocks/upgrades/ToSAcceptanceRegistryMockV2.sol index 4970cb38..504c8a3b 100644 --- a/contracts/mocks/upgrades/ToSAcceptanceRegistryMockV2.sol +++ b/contracts/mocks/upgrades/ToSAcceptanceRegistryMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../permissioned/ToSAcceptanceRegistry.sol"; diff --git a/contracts/mocks/upgrades/VaultMockV2.sol b/contracts/mocks/upgrades/VaultMockV2.sol index fd217563..68435029 100644 --- a/contracts/mocks/upgrades/VaultMockV2.sol +++ b/contracts/mocks/upgrades/VaultMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../Vault.sol"; diff --git a/contracts/mocks/upgrades/WithdrawControllerMockV2.sol b/contracts/mocks/upgrades/WithdrawControllerMockV2.sol index 6799fbb5..2eb17e60 100644 --- a/contracts/mocks/upgrades/WithdrawControllerMockV2.sol +++ b/contracts/mocks/upgrades/WithdrawControllerMockV2.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../controllers/WithdrawController.sol"; diff --git a/contracts/permissioned/PermissionedLoan.sol b/contracts/permissioned/PermissionedLoan.sol index 11372009..e926e264 100644 --- a/contracts/permissioned/PermissionedLoan.sol +++ b/contracts/permissioned/PermissionedLoan.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../Loan.sol"; diff --git a/contracts/permissioned/PermissionedPool.sol b/contracts/permissioned/PermissionedPool.sol index a037a48b..cc0c75df 100644 --- a/contracts/permissioned/PermissionedPool.sol +++ b/contracts/permissioned/PermissionedPool.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../Pool.sol"; @@ -76,12 +90,9 @@ contract PermissionedPool is Pool { * @dev Since Pool does not enforce that msg.sender == receiver, we only * check the receiver here. */ - function maxDeposit(address receiver) - public - view - override - returns (uint256) - { + function maxDeposit( + address receiver + ) public view override returns (uint256) { if (!poolAccessControl.isAllowed(receiver)) { return 0; } @@ -107,12 +118,9 @@ contract PermissionedPool is Pool { * @dev If a lender is not (currently) allowed, 0 assets are allowed to be * withdrawn from the Pool. */ - function maxWithdraw(address owner) - public - view - override - returns (uint256 assets) - { + function maxWithdraw( + address owner + ) public view override returns (uint256 assets) { if (!poolAccessControl.isAllowed(owner)) { return 0; } @@ -125,12 +133,9 @@ contract PermissionedPool is Pool { * @dev If a lender is not (currently) allowed, 0 shares are allowed to be * redeemed from the Pool. */ - function maxRedeem(address owner) - public - view - override - returns (uint256 maxShares) - { + function maxRedeem( + address owner + ) public view override returns (uint256 maxShares) { if (!poolAccessControl.isAllowed(owner)) { return 0; } diff --git a/contracts/permissioned/PermissionedServiceConfiguration.sol b/contracts/permissioned/PermissionedServiceConfiguration.sol index d4b4382f..da162f8f 100644 --- a/contracts/permissioned/PermissionedServiceConfiguration.sol +++ b/contracts/permissioned/PermissionedServiceConfiguration.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IPoolAdminAccessControl.sol"; diff --git a/contracts/permissioned/PoolAccessControl.sol b/contracts/permissioned/PoolAccessControl.sol index 03039ad0..9348b826 100644 --- a/contracts/permissioned/PoolAccessControl.sol +++ b/contracts/permissioned/PoolAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IPoolAccessControl.sol"; @@ -84,10 +98,10 @@ contract PoolAccessControl is /** * @dev The constructor for the PoolAccessControl contract */ - function initialize(address pool, address tosAcceptanceRegistry) - public - initializer - { + function initialize( + address pool, + address tosAcceptanceRegistry + ) public initializer { require( tosAcceptanceRegistry != address(0), "Pool: invalid ToS registry" @@ -110,11 +124,9 @@ contract PoolAccessControl is * * Emits an {AllowedParticipantListUpdated} event. */ - function allowParticipant(address addr) - external - onlyNotPaused - onlyPoolAdmin - { + function allowParticipant( + address addr + ) external onlyNotPaused onlyPoolAdmin { require( _tosRegistry.hasAccepted(addr), "Pool: participant not accepted ToS" @@ -128,11 +140,9 @@ contract PoolAccessControl is * * Emits an {AllowedParticipantListUpdated} event. */ - function removeParticipant(address addr) - external - onlyNotPaused - onlyPoolAdmin - { + function removeParticipant( + address addr + ) external onlyNotPaused onlyPoolAdmin { delete _allowedParticipants[addr]; emit ParticipantRemoved(addr); } @@ -154,22 +164,18 @@ contract PoolAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function addCredentialSchema(string[] calldata schema) - public - override - onlyNotPaused - { + function addCredentialSchema( + string[] calldata schema + ) public override onlyNotPaused { super.addCredentialSchema(schema); } /** * @inheritdoc IVeriteAccessControl */ - function removeCredentialSchema(string[] calldata schema) - public - override - onlyNotPaused - { + function removeCredentialSchema( + string[] calldata schema + ) public override onlyNotPaused { super.removeCredentialSchema(schema); } diff --git a/contracts/permissioned/PoolAdminAccessControl.sol b/contracts/permissioned/PoolAdminAccessControl.sol index 7581faf9..1d506734 100644 --- a/contracts/permissioned/PoolAdminAccessControl.sol +++ b/contracts/permissioned/PoolAdminAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IPoolAdminAccessControl.sol"; diff --git a/contracts/permissioned/ToSAcceptanceRegistry.sol b/contracts/permissioned/ToSAcceptanceRegistry.sol index 9654b9da..ec58dee2 100644 --- a/contracts/permissioned/ToSAcceptanceRegistry.sol +++ b/contracts/permissioned/ToSAcceptanceRegistry.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IToSAcceptanceRegistry.sol"; @@ -60,11 +74,9 @@ contract ToSAcceptanceRegistry is /** * @inheritdoc IToSAcceptanceRegistry */ - function updateTermsOfService(string memory url) - external - override - onlyOperator - { + function updateTermsOfService( + string memory url + ) external override onlyOperator { _termsOfService = url; _termsSet = true; emit TermsOfServiceUpdated(); diff --git a/contracts/permissioned/VeriteAccessControl.sol b/contracts/permissioned/VeriteAccessControl.sol index 71d3ca75..213e6b76 100644 --- a/contracts/permissioned/VeriteAccessControl.sol +++ b/contracts/permissioned/VeriteAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IVeriteAccessControl.sol"; @@ -68,11 +82,9 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function removeTrustedVerifier(address addr) - public - virtual - onlyVeriteAdmin - { + function removeTrustedVerifier( + address addr + ) public virtual onlyVeriteAdmin { delete _trustedVerifiers[addr]; emit TrustedVerifierRemoved(addr); @@ -81,11 +93,9 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function addCredentialSchema(string[] calldata schema) - public - virtual - onlyVeriteAdmin - { + function addCredentialSchema( + string[] calldata schema + ) public virtual onlyVeriteAdmin { _supportedCredentialSchemas[concat(schema)] = true; emit CredentialSchemaAdded(schema); @@ -94,11 +104,9 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function removeCredentialSchema(string[] calldata schema) - public - virtual - onlyVeriteAdmin - { + function removeCredentialSchema( + string[] calldata schema + ) public virtual onlyVeriteAdmin { delete _supportedCredentialSchemas[concat(schema)]; emit CredentialSchemaRemoved(schema); @@ -176,11 +184,9 @@ abstract contract VeriteAccessControl is * encoding itself. Protocols need to implement the type-specific encoding they need in their * contracts using a combination of `abi.encode` and `keccak256`. */ - function concat(string[] memory words) - internal - pure - returns (string memory) - { + function concat( + string[] memory words + ) internal pure returns (string memory) { bytes memory output; for (uint256 i = 0; i < words.length; i++) { diff --git a/contracts/permissioned/controllers/PermissionedPoolController.sol b/contracts/permissioned/controllers/PermissionedPoolController.sol index ea29b0c7..162a5d5f 100644 --- a/contracts/permissioned/controllers/PermissionedPoolController.sol +++ b/contracts/permissioned/controllers/PermissionedPoolController.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../../controllers/PoolController.sol"; diff --git a/contracts/permissioned/factories/PermissionedLoanFactory.sol b/contracts/permissioned/factories/PermissionedLoanFactory.sol index d9c47e0c..d5ebdfbc 100644 --- a/contracts/permissioned/factories/PermissionedLoanFactory.sol +++ b/contracts/permissioned/factories/PermissionedLoanFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IPermissionedServiceConfiguration.sol"; @@ -10,9 +24,10 @@ import "../PermissionedLoan.sol"; * @dev Emits PermissionLoans. Also acts as a beacon for said proxies. */ contract PermissionedLoanFactory is LoanFactory { - constructor(address serviceConfiguration, address vaultFactory) - LoanFactory(serviceConfiguration, vaultFactory) - {} + constructor( + address serviceConfiguration, + address vaultFactory + ) LoanFactory(serviceConfiguration, vaultFactory) {} /** * @inheritdoc LoanFactory diff --git a/contracts/permissioned/factories/PermissionedPoolFactory.sol b/contracts/permissioned/factories/PermissionedPoolFactory.sol index 3e32d498..edba6ba5 100644 --- a/contracts/permissioned/factories/PermissionedPoolFactory.sol +++ b/contracts/permissioned/factories/PermissionedPoolFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IPermissionedServiceConfiguration.sol"; diff --git a/contracts/permissioned/factories/PoolAccessControlFactory.sol b/contracts/permissioned/factories/PoolAccessControlFactory.sol index cd0ed8da..c969c794 100644 --- a/contracts/permissioned/factories/PoolAccessControlFactory.sol +++ b/contracts/permissioned/factories/PoolAccessControlFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./interfaces/IPoolAccessControlFactory.sol"; diff --git a/contracts/permissioned/factories/interfaces/IPoolAccessControlFactory.sol b/contracts/permissioned/factories/interfaces/IPoolAccessControlFactory.sol index c9061e16..5f11a0e7 100644 --- a/contracts/permissioned/factories/interfaces/IPoolAccessControlFactory.sol +++ b/contracts/permissioned/factories/interfaces/IPoolAccessControlFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol b/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol index 5991ff4b..89b86d49 100644 --- a/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol +++ b/contracts/permissioned/interfaces/IPermissionedServiceConfiguration.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "./IPoolAdminAccessControl.sol"; diff --git a/contracts/permissioned/interfaces/IPoolAccessControl.sol b/contracts/permissioned/interfaces/IPoolAccessControl.sol index 03920f81..0b456b04 100644 --- a/contracts/permissioned/interfaces/IPoolAccessControl.sol +++ b/contracts/permissioned/interfaces/IPoolAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol b/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol index b5c0ab1d..84ddda02 100644 --- a/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol +++ b/contracts/permissioned/interfaces/IPoolAdminAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/permissioned/interfaces/IToSAcceptanceRegistry.sol b/contracts/permissioned/interfaces/IToSAcceptanceRegistry.sol index 02eabace..283d8b48 100644 --- a/contracts/permissioned/interfaces/IToSAcceptanceRegistry.sol +++ b/contracts/permissioned/interfaces/IToSAcceptanceRegistry.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/permissioned/interfaces/IVeriteAccessControl.sol b/contracts/permissioned/interfaces/IVeriteAccessControl.sol index 98fb9111..2699b241 100644 --- a/contracts/permissioned/interfaces/IVeriteAccessControl.sol +++ b/contracts/permissioned/interfaces/IVeriteAccessControl.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/contracts/upgrades/BeaconImplementation.sol b/contracts/upgrades/BeaconImplementation.sol index 9ffd4233..f77a6f4d 100644 --- a/contracts/upgrades/BeaconImplementation.sol +++ b/contracts/upgrades/BeaconImplementation.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; diff --git a/contracts/upgrades/BeaconProxyFactory.sol b/contracts/upgrades/BeaconProxyFactory.sol index b968d7a4..495abcdf 100644 --- a/contracts/upgrades/BeaconProxyFactory.sol +++ b/contracts/upgrades/BeaconProxyFactory.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "../interfaces/IServiceConfiguration.sol"; @@ -34,10 +48,9 @@ abstract contract BeaconProxyFactory is IBeacon { /** * @inheritdoc IBeacon */ - function setImplementation(address newImplementation) - external - onlyDeployer - { + function setImplementation( + address newImplementation + ) external onlyDeployer { implementation = newImplementation; emit ImplementationSet(newImplementation); } diff --git a/contracts/upgrades/DeployerUUPSUpgradeable.sol b/contracts/upgrades/DeployerUUPSUpgradeable.sol index 04be450a..650f1dc4 100644 --- a/contracts/upgrades/DeployerUUPSUpgradeable.sol +++ b/contracts/upgrades/DeployerUUPSUpgradeable.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol"; diff --git a/contracts/upgrades/interfaces/IBeacon.sol b/contracts/upgrades/interfaces/IBeacon.sol index db4f8006..35100c1d 100644 --- a/contracts/upgrades/interfaces/IBeacon.sol +++ b/contracts/upgrades/interfaces/IBeacon.sol @@ -1,4 +1,18 @@ -// SPDX-License-Identifier: MIT +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ pragma solidity ^0.8.16; /** diff --git a/scripts/deploy-permissionless.ts b/scripts/deploy-permissionless.ts index a4219c65..ff43ec8f 100644 --- a/scripts/deploy-permissionless.ts +++ b/scripts/deploy-permissionless.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers, upgrades } from "hardhat"; import hre from "hardhat"; diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 877aab3c..829bb98d 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers, upgrades } from "hardhat"; import hre from "hardhat"; diff --git a/scripts/verify-pool-admin.ts b/scripts/verify-pool-admin.ts index ac83af9e..154dd612 100644 --- a/scripts/verify-pool-admin.ts +++ b/scripts/verify-pool-admin.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers } from "hardhat"; import hre from "hardhat"; diff --git a/scripts/verite-verify.ts b/scripts/verite-verify.ts index 35152bd1..41df264f 100644 --- a/scripts/verite-verify.ts +++ b/scripts/verite-verify.ts @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + // import hre from "hardhat"; import fetch from "cross-fetch"; import type { PresentationDefinition } from "verite"; diff --git a/tasks/serviceConfiguration.ts b/tasks/serviceConfiguration.ts index bcec230d..6e116e4f 100644 --- a/tasks/serviceConfiguration.ts +++ b/tasks/serviceConfiguration.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { task } from "hardhat/config"; import { ContractFactory } from "ethers"; diff --git a/tasks/tosAcceptanceRegistry.ts b/tasks/tosAcceptanceRegistry.ts index 862b19d7..1437cf87 100644 --- a/tasks/tosAcceptanceRegistry.ts +++ b/tasks/tosAcceptanceRegistry.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { task } from "hardhat/config"; import { ContractFactory } from "ethers"; diff --git a/test/Loan.test.ts b/test/Loan.test.ts index 65049211..cb46cf06 100644 --- a/test/Loan.test.ts +++ b/test/Loan.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -1937,11 +1952,11 @@ describe("Loan", () => { liquidityAsset, borrower, 0 - - interestPayment - - principal - - originationFee - - firstLossFee + - prepaidPrincipal + interestPayment - + principal - + originationFee - + firstLossFee + + prepaidPrincipal ); await expect(tx).to.changeTokenBalance( liquidityAsset, diff --git a/test/Pool.test.ts b/test/Pool.test.ts index ca8b20a9..4ddfe764 100644 --- a/test/Pool.test.ts +++ b/test/Pool.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/ServiceConfiguration.test.ts b/test/ServiceConfiguration.test.ts index e95c9f5b..74f6b885 100644 --- a/test/ServiceConfiguration.test.ts +++ b/test/ServiceConfiguration.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; diff --git a/test/Vault.test.ts b/test/Vault.test.ts index 65b2a059..b9d58348 100644 --- a/test/Vault.test.ts +++ b/test/Vault.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/controllers/PoolController.test.ts b/test/controllers/PoolController.test.ts index f07b0635..d2de5ef8 100644 --- a/test/controllers/PoolController.test.ts +++ b/test/controllers/PoolController.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/controllers/WithdrawController.test.ts b/test/controllers/WithdrawController.test.ts index fc471c26..2df2f641 100644 --- a/test/controllers/WithdrawController.test.ts +++ b/test/controllers/WithdrawController.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/factories/LoanFactory.test.ts b/test/factories/LoanFactory.test.ts index 88a38878..9e78a59f 100644 --- a/test/factories/LoanFactory.test.ts +++ b/test/factories/LoanFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/factories/PoolFactory.test.ts b/test/factories/PoolFactory.test.ts index 3d1ab8b9..39cde1d9 100644 --- a/test/factories/PoolFactory.test.ts +++ b/test/factories/PoolFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/factories/VaultFactory.test.ts b/test/factories/VaultFactory.test.ts index 464ff9f4..9809dabc 100644 --- a/test/factories/VaultFactory.test.ts +++ b/test/factories/VaultFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/libraries/PoolLib.test.ts b/test/libraries/PoolLib.test.ts index 2d287875..2c6a1bc4 100644 --- a/test/libraries/PoolLib.test.ts +++ b/test/libraries/PoolLib.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture, time } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/permissioned/PermissionedLoan.test.ts b/test/permissioned/PermissionedLoan.test.ts index 0314ca0e..f41e7276 100644 --- a/test/permissioned/PermissionedLoan.test.ts +++ b/test/permissioned/PermissionedLoan.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture, time } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/permissioned/PermissionedPool.test.ts b/test/permissioned/PermissionedPool.test.ts index 112637ab..1c0b8581 100644 --- a/test/permissioned/PermissionedPool.test.ts +++ b/test/permissioned/PermissionedPool.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { diff --git a/test/permissioned/PermissionedPoolController.test.ts b/test/permissioned/PermissionedPoolController.test.ts index 40e6da04..a4fb1796 100644 --- a/test/permissioned/PermissionedPoolController.test.ts +++ b/test/permissioned/PermissionedPoolController.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { diff --git a/test/permissioned/PoolAccessControl.test.ts b/test/permissioned/PoolAccessControl.test.ts index 86928150..157159f4 100644 --- a/test/permissioned/PoolAccessControl.test.ts +++ b/test/permissioned/PoolAccessControl.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/permissioned/PoolAdminAccessControl.test.ts b/test/permissioned/PoolAdminAccessControl.test.ts index 6be1a96a..20bf818c 100644 --- a/test/permissioned/PoolAdminAccessControl.test.ts +++ b/test/permissioned/PoolAdminAccessControl.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; diff --git a/test/permissioned/ToSConsentRegistry.test.ts b/test/permissioned/ToSConsentRegistry.test.ts index c6bd2f09..0d1180b5 100644 --- a/test/permissioned/ToSConsentRegistry.test.ts +++ b/test/permissioned/ToSConsentRegistry.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; diff --git a/test/permissioned/VeriteAccessControl.test.ts b/test/permissioned/VeriteAccessControl.test.ts index 10883e60..0d3ccf8a 100644 --- a/test/permissioned/VeriteAccessControl.test.ts +++ b/test/permissioned/VeriteAccessControl.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers, upgrades } from "hardhat"; import { getSignedVerificationResult } from "../support/verite"; import { expect } from "chai"; diff --git a/test/permissioned/factories/PermissionedLoanFactory.test.ts b/test/permissioned/factories/PermissionedLoanFactory.test.ts index d151cf23..20c961cb 100644 --- a/test/permissioned/factories/PermissionedLoanFactory.test.ts +++ b/test/permissioned/factories/PermissionedLoanFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/permissioned/factories/PermissionedPoolFactory.test.ts b/test/permissioned/factories/PermissionedPoolFactory.test.ts index 5afedb12..d58f4cb8 100644 --- a/test/permissioned/factories/PermissionedPoolFactory.test.ts +++ b/test/permissioned/factories/PermissionedPoolFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; diff --git a/test/scenarios/business/1.test.ts b/test/scenarios/business/1.test.ts index 859c5c4e..f0f0929f 100644 --- a/test/scenarios/business/1.test.ts +++ b/test/scenarios/business/1.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/scenarios/business/2.test.ts b/test/scenarios/business/2.test.ts index 25fb07c2..29479604 100644 --- a/test/scenarios/business/2.test.ts +++ b/test/scenarios/business/2.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/scenarios/business/3.test.ts b/test/scenarios/business/3.test.ts index 73776e08..1f8e5964 100644 --- a/test/scenarios/business/3.test.ts +++ b/test/scenarios/business/3.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/scenarios/business/4.test.ts b/test/scenarios/business/4.test.ts index 765e9942..df9c8417 100644 --- a/test/scenarios/business/4.test.ts +++ b/test/scenarios/business/4.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/scenarios/business/permissioned/1.test.ts b/test/scenarios/business/permissioned/1.test.ts index ab110617..81ce4a23 100644 --- a/test/scenarios/business/permissioned/1.test.ts +++ b/test/scenarios/business/permissioned/1.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployPermissionedPool, activatePool } from "../../../support/pool"; diff --git a/test/scenarios/business/permissioned/2.test.ts b/test/scenarios/business/permissioned/2.test.ts index 28a9cdfc..12641ac0 100644 --- a/test/scenarios/business/permissioned/2.test.ts +++ b/test/scenarios/business/permissioned/2.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployPermissionedPool, activatePool } from "../../../support/pool"; diff --git a/test/scenarios/business/permissioned/3.test.ts b/test/scenarios/business/permissioned/3.test.ts index 0f08e299..c54a3e93 100644 --- a/test/scenarios/business/permissioned/3.test.ts +++ b/test/scenarios/business/permissioned/3.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployPermissionedPool, activatePool } from "../../../support/pool"; diff --git a/test/scenarios/business/permissioned/4.test.ts b/test/scenarios/business/permissioned/4.test.ts index 6ed6471c..972ffa10 100644 --- a/test/scenarios/business/permissioned/4.test.ts +++ b/test/scenarios/business/permissioned/4.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployPermissionedPool, activatePool } from "../../../support/pool"; diff --git a/test/scenarios/pool/direct-deposit.test.ts b/test/scenarios/pool/direct-deposit.test.ts index b1a1c868..4fe2c97e 100644 --- a/test/scenarios/pool/direct-deposit.test.ts +++ b/test/scenarios/pool/direct-deposit.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployLoan, fundLoan } from "../../support/loan"; diff --git a/test/scenarios/pool/fixed-term-defaulted.test.ts b/test/scenarios/pool/fixed-term-defaulted.test.ts index 1e51eb4c..4dc54dcc 100644 --- a/test/scenarios/pool/fixed-term-defaulted.test.ts +++ b/test/scenarios/pool/fixed-term-defaulted.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -58,7 +73,7 @@ describe("Fixed Term Defaulted Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { diff --git a/test/scenarios/pool/fixed-term-matured.test.ts b/test/scenarios/pool/fixed-term-matured.test.ts index ef61dfe4..da8499fe 100644 --- a/test/scenarios/pool/fixed-term-matured.test.ts +++ b/test/scenarios/pool/fixed-term-matured.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -58,7 +73,7 @@ describe("Fixed Term Matured Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { @@ -103,8 +118,8 @@ describe("Fixed Term Matured Loan Scenario", () => { .approve( loan.address, INPUTS.loanAmount + - (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / + DEFAULT_LOAN_SETTINGS.paymentPeriod ); await loan.connect(borrower).completeFullPayment(); diff --git a/test/scenarios/pool/open-term-defaulted.test.ts b/test/scenarios/pool/open-term-defaulted.test.ts index 6ae98fdd..03279da2 100644 --- a/test/scenarios/pool/open-term-defaulted.test.ts +++ b/test/scenarios/pool/open-term-defaulted.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -58,7 +73,7 @@ describe("Open Term Defaulted Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { diff --git a/test/scenarios/pool/open-term-matured.test.ts b/test/scenarios/pool/open-term-matured.test.ts index 7a6e2014..aa497332 100644 --- a/test/scenarios/pool/open-term-matured.test.ts +++ b/test/scenarios/pool/open-term-matured.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -59,7 +74,7 @@ describe("Open Term Matured Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { @@ -112,8 +127,8 @@ describe("Open Term Matured Loan Scenario", () => { .approve( loan.address, INPUTS.loanAmount + - (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / + DEFAULT_LOAN_SETTINGS.paymentPeriod ); await loan.connect(borrower).paydownPrincipal(500_000); // check accountings again diff --git a/test/scenarios/pool/snapshot-variations.test.ts b/test/scenarios/pool/snapshot-variations.test.ts index b38edda7..37cb893f 100644 --- a/test/scenarios/pool/snapshot-variations.test.ts +++ b/test/scenarios/pool/snapshot-variations.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployLoan, fundLoan } from "../../support/loan"; diff --git a/test/scenarios/pool/withdraw-dos.test.ts b/test/scenarios/pool/withdraw-dos.test.ts index 28c7f757..04126b67 100644 --- a/test/scenarios/pool/withdraw-dos.test.ts +++ b/test/scenarios/pool/withdraw-dos.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { deployMockERC20 } from "../../support/erc20"; diff --git a/test/scenarios/pool/withdraw-request.test.ts b/test/scenarios/pool/withdraw-request.test.ts index 440b0456..9a7b21a4 100644 --- a/test/scenarios/pool/withdraw-request.test.ts +++ b/test/scenarios/pool/withdraw-request.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time, loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; @@ -129,7 +144,7 @@ describe("Withdraw Requests", () => { (100 /* initial balance */ - 50 /* requested */ - 5) /* previous request fee */ * - 0.9 /* sub the request fee */ + 0.9 /* sub the request fee */ ) ); expect(await pool.maxWithdrawRequest(aliceLender.address)).to.equal(41); @@ -140,7 +155,7 @@ describe("Withdraw Requests", () => { (70 /* initial balance */ - 10 /* requested */ - 1) /* previous request fee */ * - 0.9 /* sub the request fee */ + 0.9 /* sub the request fee */ ) ); expect(await pool.maxWithdrawRequest(bobLender.address)).to.equal(54); diff --git a/test/support/erc20.ts b/test/support/erc20.ts index 8fe47071..deeb1f4e 100644 --- a/test/support/erc20.ts +++ b/test/support/erc20.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers } from "hardhat"; /** diff --git a/test/support/loan.ts b/test/support/loan.ts index 2c5b2c8d..c7d32124 100644 --- a/test/support/loan.ts +++ b/test/support/loan.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers } from "hardhat"; import { deployVaultFactory } from "./pool"; import { @@ -33,8 +48,8 @@ export async function deployLoan( const { serviceConfiguration } = await (existingServiceConfiguration == null ? deployServiceConfiguration() : { - serviceConfiguration: existingServiceConfiguration - }); + serviceConfiguration: existingServiceConfiguration + }); const { operator, deployer } = await getCommonSigners(); @@ -110,8 +125,8 @@ export async function deployPermissionedLoan( const { serviceConfiguration } = await (existingServiceConfiguration == null ? deployPermissionedServiceConfiguration() : { - serviceConfiguration: existingServiceConfiguration - }); + serviceConfiguration: existingServiceConfiguration + }); const vaultFactory = await deployVaultFactory(serviceConfiguration.address); diff --git a/test/support/pool.ts b/test/support/pool.ts index e0e77432..770362a5 100644 --- a/test/support/pool.ts +++ b/test/support/pool.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers } from "hardhat"; import { time } from "@nomicfoundation/hardhat-network-helpers"; import { MockERC20, PermissionedPool, Pool } from "../../typechain-types"; diff --git a/test/support/serviceconfiguration.ts b/test/support/serviceconfiguration.ts index 7e38b85b..addc6a65 100644 --- a/test/support/serviceconfiguration.ts +++ b/test/support/serviceconfiguration.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers, upgrades } from "hardhat"; import { deployToSAcceptanceRegistry } from "./tosacceptanceregistry"; import { getCommonSigners } from "./utils"; diff --git a/test/support/tosacceptanceregistry.ts b/test/support/tosacceptanceregistry.ts index 04828769..3e5544e0 100644 --- a/test/support/tosacceptanceregistry.ts +++ b/test/support/tosacceptanceregistry.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers, upgrades } from "hardhat"; /** diff --git a/test/support/utils.ts b/test/support/utils.ts index 3240691c..aa730146 100644 --- a/test/support/utils.ts +++ b/test/support/utils.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { ethers } from "hardhat"; export function findEventByName(receipt: any, name: string) { diff --git a/test/support/verite.ts b/test/support/verite.ts index d76cf7b8..59f3bdef 100644 --- a/test/support/verite.ts +++ b/test/support/verite.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { time } from "@nomicfoundation/hardhat-network-helpers"; import { ethers } from "ethers"; import { expect } from "chai"; diff --git a/test/upgrades/BeaconImplementation.test.ts b/test/upgrades/BeaconImplementation.test.ts index 2f593b07..a6cbb698 100644 --- a/test/upgrades/BeaconImplementation.test.ts +++ b/test/upgrades/BeaconImplementation.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/upgrades/BeaconProxyFactory.test.ts b/test/upgrades/BeaconProxyFactory.test.ts index 856a70aa..86812558 100644 --- a/test/upgrades/BeaconProxyFactory.test.ts +++ b/test/upgrades/BeaconProxyFactory.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers } from "hardhat"; diff --git a/test/upgrades/DeployerUUPSUpgradeable.test.ts b/test/upgrades/DeployerUUPSUpgradeable.test.ts index 1bc7da78..b2f467d5 100644 --- a/test/upgrades/DeployerUUPSUpgradeable.test.ts +++ b/test/upgrades/DeployerUUPSUpgradeable.test.ts @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2023, Circle Internet Financial Limited. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; import { expect } from "chai"; import { ethers, upgrades } from "hardhat"; From b5a2accf56e7990874a2057a8bc0129dacdb64eb Mon Sep 17 00:00:00 2001 From: Adrian Soghoian Date: Mon, 25 Sep 2023 10:26:07 -0400 Subject: [PATCH 2/2] Lint --- contracts/Loan.sol | 31 ++- contracts/Pool.sol | 208 +++++++++++------- contracts/ServiceConfiguration.sol | 35 +-- contracts/Vault.sol | 8 +- contracts/controllers/PoolController.sol | 112 +++++----- contracts/controllers/WithdrawController.sol | 143 +++++++----- .../interfaces/IPoolController.sol | 7 +- .../interfaces/IWithdrawController.sol | 25 +-- .../factories/WithdrawControllerFactory.sol | 8 +- .../factories/interfaces/IPoolFactory.sol | 7 +- contracts/interfaces/IERC4626.sol | 7 +- contracts/interfaces/ILoan.sol | 21 +- contracts/interfaces/IPool.sol | 12 +- contracts/interfaces/IRequestWithdrawable.sol | 61 ++--- contracts/libraries/LoanLib.sol | 20 +- contracts/libraries/PoolLib.sol | 37 ++-- contracts/mocks/PoolLibTestWrapper.sol | 17 +- contracts/permissioned/PermissionedPool.sol | 27 ++- contracts/permissioned/PoolAccessControl.sol | 40 ++-- .../permissioned/ToSAcceptanceRegistry.sol | 8 +- .../permissioned/VeriteAccessControl.sol | 32 ++- .../factories/PermissionedLoanFactory.sol | 7 +- contracts/upgrades/BeaconProxyFactory.sol | 7 +- test/Loan.test.ts | 10 +- .../pool/fixed-term-defaulted.test.ts | 2 +- .../scenarios/pool/fixed-term-matured.test.ts | 6 +- .../pool/open-term-defaulted.test.ts | 2 +- test/scenarios/pool/open-term-matured.test.ts | 6 +- test/scenarios/pool/withdraw-request.test.ts | 4 +- test/support/loan.ts | 8 +- 30 files changed, 512 insertions(+), 406 deletions(-) diff --git a/contracts/Loan.sol b/contracts/Loan.sol index 51525efc..fd0b1b62 100644 --- a/contracts/Loan.sol +++ b/contracts/Loan.sol @@ -292,10 +292,7 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function postFungibleCollateral( - address asset, - uint256 amount - ) + function postFungibleCollateral(address asset, uint256 amount) external virtual onlyNotPaused @@ -318,10 +315,7 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function postNonFungibleCollateral( - address asset, - uint256 tokenId - ) + function postNonFungibleCollateral(address asset, uint256 tokenId) external virtual onlyNotPaused @@ -372,9 +366,7 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function drawdown( - uint256 amount - ) + function drawdown(uint256 amount) external virtual onlyNotPaused @@ -399,9 +391,12 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function paydownPrincipal( - uint256 amount - ) external onlyNotPaused onlyPermittedBorrower onlyBorrower { + function paydownPrincipal(uint256 amount) + external + onlyNotPaused + onlyPermittedBorrower + onlyBorrower + { require(outstandingPrincipal >= amount, "Loan: amount too high"); require(settings.loanType == ILoanType.Open, "Loan: invalid loan type"); LoanLib.paydownPrincipal(liquidityAsset, amount, fundingVault); @@ -447,9 +442,11 @@ contract Loan is ILoan, BeaconImplementation { /** * @inheritdoc ILoan */ - function previewFees( - uint256 amount - ) public view returns (ILoanFees memory) { + function previewFees(uint256 amount) + public + view + returns (ILoanFees memory) + { return LoanLib.previewFees( settings, diff --git a/contracts/Pool.sol b/contracts/Pool.sol index e390ad0e..79285b8e 100644 --- a/contracts/Pool.sol +++ b/contracts/Pool.sol @@ -291,9 +291,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function fundLoan( - address addr - ) external onlyNotPaused onlyPoolController onlySnapshottedPool { + function fundLoan(address addr) + external + onlyNotPaused + onlyPoolController + onlySnapshottedPool + { require(!_fundedLoans[addr], "Pool: already funded"); _fundedLoans[addr] = true; ILoan loan = ILoan(addr); @@ -358,10 +361,11 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function onLoanDefaulted( - address loan, - uint256 firstLossApplied - ) external override onlyPoolController { + function onLoanDefaulted(address loan, uint256 firstLossApplied) + external + override + onlyPoolController + { uint256 outstandingPrincipal = ILoan(loan).outstandingPrincipal(); _accountings.outstandingLoanPrincipals -= outstandingPrincipal; _accountings.totalDefaults += outstandingPrincipal; @@ -447,10 +451,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function withdrawFeeVault( - uint256 amount, - address receiver - ) external onlyNotPaused onlyPoolController onlySnapshottedPool { + function withdrawFeeVault(uint256 amount, address receiver) + external + onlyNotPaused + onlyPoolController + onlySnapshottedPool + { _feeVault.withdrawERC20(address(_liquidityAsset), amount, receiver); } @@ -461,63 +467,73 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function maxRedeemRequest( - address owner - ) public view returns (uint256 maxShares) { + function maxRedeemRequest(address owner) + public + view + returns (uint256 maxShares) + { maxShares = withdrawController.maxRedeemRequest(owner); } /** * @inheritdoc IRequestWithdrawable */ - function maxWithdrawRequest( - address owner - ) public view returns (uint256 maxAssets) { + function maxWithdrawRequest(address owner) + public + view + returns (uint256 maxAssets) + { maxAssets = convertToAssets(maxRedeemRequest(owner)); } /** * @inheritdoc IRequestWithdrawable */ - function previewRedeemRequest( - uint256 shares - ) external view returns (uint256 assets) { + function previewRedeemRequest(uint256 shares) + external + view + returns (uint256 assets) + { assets = withdrawController.previewRedeemRequest(shares); } /** * @inheritdoc IRequestWithdrawable */ - function previewRedeemRequestFees( - uint256 shares - ) external view returns (uint256 feeShares) { + function previewRedeemRequestFees(uint256 shares) + external + view + returns (uint256 feeShares) + { feeShares = withdrawController.previewRedeemRequestFees(shares); } /** * @inheritdoc IRequestWithdrawable */ - function previewWithdrawRequest( - uint256 assets - ) external view returns (uint256 shares) { + function previewWithdrawRequest(uint256 assets) + external + view + returns (uint256 shares) + { shares = withdrawController.previewWithdrawRequest(assets); } /** * @inheritdoc IRequestWithdrawable */ - function previewWithdrawRequestFees( - uint256 assets - ) external view returns (uint256 feeShares) { + function previewWithdrawRequestFees(uint256 assets) + external + view + returns (uint256 feeShares) + { feeShares = withdrawController.previewWithdrawRequestFees(assets); } /** * @inheritdoc IRequestWithdrawable */ - function requestRedeem( - uint256 shares - ) + function requestRedeem(uint256 shares) external onlyNotPaused onlyActivatedPool @@ -533,9 +549,7 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function requestWithdraw( - uint256 assets - ) + function requestWithdraw(uint256 assets) external onlyNotPaused onlyActivatedPool @@ -572,18 +586,18 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function maxRequestCancellation( - address owner - ) public view returns (uint256 maxShares) { + function maxRequestCancellation(address owner) + public + view + returns (uint256 maxShares) + { maxShares = withdrawController.maxRequestCancellation(owner); } /** * @inheritdoc IRequestWithdrawable */ - function cancelRedeemRequest( - uint256 shares - ) + function cancelRedeemRequest(uint256 shares) external onlyNotPaused onlyActivatedPool @@ -599,9 +613,7 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IRequestWithdrawable */ - function cancelWithdrawRequest( - uint256 assets - ) + function cancelWithdrawRequest(uint256 assets) external onlyNotPaused onlyActivatedPool @@ -663,9 +675,7 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IPool */ - function claimSnapshots( - uint256 limit - ) + function claimSnapshots(uint256 limit) external onlyNotPaused onlyPermittedLender @@ -709,9 +719,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function convertToShares( - uint256 assets - ) public view override returns (uint256 shares) { + function convertToShares(uint256 assets) + public + view + override + returns (uint256 shares) + { shares = PoolLib.calculateSharesFromAssets( assets, totalAvailableSupply(), @@ -723,9 +736,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function convertToAssets( - uint256 shares - ) public view override returns (uint256 assets) { + function convertToAssets(uint256 shares) + public + view + override + returns (uint256 assets) + { assets = PoolLib.calculateAssetsFromShares( shares, totalAvailableAssets(), @@ -737,9 +753,13 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxDeposit( - address - ) public view virtual override returns (uint256) { + function maxDeposit(address) + public + view + virtual + override + returns (uint256) + { if (_serviceConfiguration.paused() == true) { return 0; } @@ -754,9 +774,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewDeposit( - uint256 assets - ) public view override returns (uint256 shares) { + function previewDeposit(uint256 assets) + public + view + override + returns (uint256 shares) + { shares = PoolLib.calculateSharesFromAssets( assets, totalAvailableSupply(), @@ -769,10 +792,7 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function deposit( - uint256 assets, - address receiver - ) + function deposit(uint256 assets, address receiver) public virtual override @@ -798,18 +818,25 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxMint( - address receiver - ) public view virtual override returns (uint256) { + function maxMint(address receiver) + public + view + virtual + override + returns (uint256) + { return previewDeposit(maxDeposit(receiver)); } /** * @inheritdoc IERC4626 */ - function previewMint( - uint256 shares - ) public view override returns (uint256 assets) { + function previewMint(uint256 shares) + public + view + override + returns (uint256 assets) + { assets = PoolLib.calculateAssetsFromShares( shares, totalAvailableAssets() + @@ -822,10 +849,7 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function mint( - uint256 shares, - address receiver - ) + function mint(uint256 shares, address receiver) public virtual override @@ -852,9 +876,13 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxWithdraw( - address owner - ) public view virtual override returns (uint256 assets) { + function maxWithdraw(address owner) + public + view + virtual + override + returns (uint256 assets) + { if (_serviceConfiguration.paused() == true) { return 0; } @@ -864,9 +892,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewWithdraw( - uint256 assets - ) external view override returns (uint256 shares) { + function previewWithdraw(uint256 assets) + external + view + override + returns (uint256 shares) + { shares = withdrawController.previewWithdraw(msg.sender, assets); } @@ -900,9 +931,13 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function maxRedeem( - address owner - ) public view virtual override returns (uint256 maxShares) { + function maxRedeem(address owner) + public + view + virtual + override + returns (uint256 maxShares) + { if (_serviceConfiguration.paused() == true) { return 0; } @@ -912,9 +947,12 @@ contract Pool is IPool, ERC20Upgradeable, BeaconImplementation { /** * @inheritdoc IERC4626 */ - function previewRedeem( - uint256 shares - ) external view override returns (uint256 assets) { + function previewRedeem(uint256 shares) + external + view + override + returns (uint256 assets) + { assets = withdrawController.previewRedeem(msg.sender, shares); } diff --git a/contracts/ServiceConfiguration.sol b/contracts/ServiceConfiguration.sol index 768bf568..990b25e2 100644 --- a/contracts/ServiceConfiguration.sol +++ b/contracts/ServiceConfiguration.sol @@ -117,10 +117,11 @@ contract ServiceConfiguration is /** * @dev Set a liquidity asset as valid or not. */ - function setLiquidityAsset( - address addr, - bool value - ) public override onlyOperator { + function setLiquidityAsset(address addr, bool value) + public + override + onlyOperator + { isLiquidityAsset[addr] = value; emit LiquidityAssetSet(addr, value); } @@ -150,10 +151,11 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setLoanFactory( - address addr, - bool isValid - ) external override onlyOperator { + function setLoanFactory(address addr, bool isValid) + external + override + onlyOperator + { isLoanFactory[addr] = isValid; emit LoanFactorySet(addr, isValid); } @@ -161,9 +163,11 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setToSAcceptanceRegistry( - address addr - ) external override onlyOperator { + function setToSAcceptanceRegistry(address addr) + external + override + onlyOperator + { tosAcceptanceRegistry = addr; emit TermsOfServiceRegistrySet(addr); } @@ -171,10 +175,11 @@ contract ServiceConfiguration is /** * @inheritdoc IServiceConfiguration */ - function setFirstLossMinimum( - address addr, - uint256 value - ) external override onlyOperator { + function setFirstLossMinimum(address addr, uint256 value) + external + override + onlyOperator + { firstLossMinimum[addr] = value; emit FirstLossMinimumSet(addr, value); } diff --git a/contracts/Vault.sol b/contracts/Vault.sol index f2a28850..df277d37 100644 --- a/contracts/Vault.sol +++ b/contracts/Vault.sol @@ -53,10 +53,10 @@ contract Vault is /** * @dev Initialize function as a Beacon proxy implementation. */ - function initialize( - address owner, - address serviceConfiguration - ) public initializer { + function initialize(address owner, address serviceConfiguration) + public + initializer + { __ERC721Holder_init(); _transferOwnership(owner); _serviceConfiguration = IServiceConfiguration(serviceConfiguration); diff --git a/contracts/controllers/PoolController.sol b/contracts/controllers/PoolController.sol index 7ad2905f..b27d4e32 100644 --- a/contracts/controllers/PoolController.sol +++ b/contracts/controllers/PoolController.sol @@ -199,9 +199,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setRequestFee( - uint256 feeBps - ) + function setRequestFee(uint256 feeBps) external onlyNotPaused onlyPermittedAdmin @@ -215,9 +213,11 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function requestFee( - uint256 sharesOrAssets - ) public view returns (uint256 feeShares) { + function requestFee(uint256 sharesOrAssets) + public + view + returns (uint256 feeShares) + { feeShares = PoolLib.calculateRequestFee( sharesOrAssets, _settings.requestFeeBps @@ -227,9 +227,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setRequestCancellationFee( - uint256 feeBps - ) + function setRequestCancellationFee(uint256 feeBps) external onlyNotPaused onlyPermittedAdmin @@ -243,9 +241,11 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function requestCancellationFee( - uint256 sharesOrAssets - ) public view returns (uint256 feeShares) { + function requestCancellationFee(uint256 sharesOrAssets) + public + view + returns (uint256 feeShares) + { feeShares = PoolLib.calculateCancellationFee( sharesOrAssets, _settings.requestCancellationFeeBps @@ -255,9 +255,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setWithdrawGate( - uint256 _withdrawGateBps - ) + function setWithdrawGate(uint256 _withdrawGateBps) external onlyNotPaused onlyPermittedAdmin @@ -295,9 +293,12 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setPoolCapacity( - uint256 newCapacity - ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { + function setPoolCapacity(uint256 newCapacity) + external + onlyNotPaused + onlyPermittedAdmin + onlyAdmin + { require(newCapacity >= pool.totalAssets(), "Pool: invalid capacity"); _settings.maxCapacity = newCapacity; emit PoolSettingsUpdated(); @@ -306,9 +307,12 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setPoolEndDate( - uint256 endDate - ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { + function setPoolEndDate(uint256 endDate) + external + onlyNotPaused + onlyPermittedAdmin + onlyAdmin + { require(_settings.endDate > endDate, "Pool: can't move end date up"); require( endDate > block.timestamp, @@ -335,9 +339,12 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setServiceFeeBps( - uint256 serviceFeeBps - ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { + function setServiceFeeBps(uint256 serviceFeeBps) + external + onlyNotPaused + onlyPermittedAdmin + onlyAdmin + { require(serviceFeeBps <= 10000, "Pool: invalid service fee"); _settings.serviceFeeBps = serviceFeeBps; emit PoolSettingsUpdated(); @@ -346,10 +353,12 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function setFixedFee( - uint256 amount, - uint256 interval - ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { + function setFixedFee(uint256 amount, uint256 interval) + external + onlyNotPaused + onlyPermittedAdmin + onlyAdmin + { if (amount > 0) { require(interval > 0, "Pool: invalid fixed fee"); } @@ -420,10 +429,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function depositFirstLoss( - uint256 amount, - address spender - ) + function depositFirstLoss(uint256 amount, address spender) external onlyNotPaused onlyPermittedAdmin @@ -454,10 +460,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function withdrawFirstLoss( - uint256 amount, - address receiver - ) + function withdrawFirstLoss(uint256 amount, address receiver) external onlyNotPaused onlyPermittedAdmin @@ -490,9 +493,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function fundLoan( - address addr - ) + function fundLoan(address addr) external onlyNotPaused onlyPermittedAdmin @@ -506,9 +507,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function defaultLoan( - address loan - ) + function defaultLoan(address loan) external onlyNotPaused onlyPermittedAdmin @@ -530,10 +529,7 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function reclaimLoanFunds( - address loan, - uint256 amount - ) + function reclaimLoanFunds(address loan, uint256 amount) external override onlyNotPaused @@ -560,18 +556,20 @@ contract PoolController is IPoolController, BeaconImplementation { * @inheritdoc IPoolController * @dev Note that the Loan enforces the non-paused state, so it's omitted here. */ - function cancelFundedLoan( - address loan - ) external override onlyAdmin onlyPermittedAdmin onlySnapshottedPool { + function cancelFundedLoan(address loan) + external + override + onlyAdmin + onlyPermittedAdmin + onlySnapshottedPool + { ILoan(loan).cancelFunded(); } /** * @inheritdoc IPoolController */ - function markLoanCallback( - address loan - ) + function markLoanCallback(address loan) external override onlyNotPaused @@ -605,10 +603,12 @@ contract PoolController is IPoolController, BeaconImplementation { /** * @inheritdoc IPoolController */ - function withdrawFeeVault( - uint256 amount, - address receiver - ) external onlyNotPaused onlyPermittedAdmin onlyAdmin { + function withdrawFeeVault(uint256 amount, address receiver) + external + onlyNotPaused + onlyPermittedAdmin + onlyAdmin + { pool.withdrawFeeVault(amount, receiver); } diff --git a/contracts/controllers/WithdrawController.sol b/contracts/controllers/WithdrawController.sol index 5ea83cf9..29e0d5df 100644 --- a/contracts/controllers/WithdrawController.sol +++ b/contracts/controllers/WithdrawController.sol @@ -31,7 +31,7 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; - uint256 public constant RAY = 10 ** 27; + uint256 public constant RAY = 10**27; /** * @dev A reference to the pool for this withdraw state @@ -87,9 +87,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @dev Returns the current withdraw state of an owner. */ - function _currentWithdrawState( - address owner - ) internal view returns (IPoolWithdrawState memory state) { + function _currentWithdrawState(address owner) + internal + view + returns (IPoolWithdrawState memory state) + { uint256 currentPeriod = withdrawPeriod(); state = PoolLib.progressWithdrawState( _withdrawState[owner], @@ -118,18 +120,22 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function interestBearingBalanceOf( - address owner - ) external view returns (uint256 shares) { + function interestBearingBalanceOf(address owner) + external + view + returns (uint256 shares) + { shares = _pool.balanceOf(owner) - maxRedeem(owner); } /** * @inheritdoc IWithdrawController */ - function requestedBalanceOf( - address owner - ) external view returns (uint256 shares) { + function requestedBalanceOf(address owner) + external + view + returns (uint256 shares) + { shares = _currentWithdrawState(owner).requestedShares; } @@ -143,9 +149,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function eligibleBalanceOf( - address owner - ) external view returns (uint256 shares) { + function eligibleBalanceOf(address owner) + external + view + returns (uint256 shares) + { shares = _currentWithdrawState(owner).eligibleShares; } @@ -177,9 +185,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function maxRedeemRequest( - address owner - ) external view returns (uint256 maxShares) { + function maxRedeemRequest(address owner) + external + view + returns (uint256 maxShares) + { maxShares = PoolLib.calculateMaxRedeemRequest( _currentWithdrawState(owner), _pool.balanceOf(owner), @@ -208,18 +218,22 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewRedeemRequest( - uint256 shares - ) external view returns (uint256 assets) { + function previewRedeemRequest(uint256 shares) + external + view + returns (uint256 assets) + { assets = _pool.convertToAssets(shares); } /** * @inheritdoc IWithdrawController */ - function previewRedeemRequestFees( - uint256 shares - ) external view returns (uint256 feeShares) { + function previewRedeemRequestFees(uint256 shares) + external + view + returns (uint256 feeShares) + { feeShares = PoolLib.calculateRequestFee( shares, _pool.settings().requestFeeBps @@ -229,18 +243,22 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewWithdrawRequest( - uint256 assets - ) external view returns (uint256 shares) { + function previewWithdrawRequest(uint256 assets) + external + view + returns (uint256 shares) + { shares = _pool.convertToShares(assets); } /** * @inheritdoc IWithdrawController */ - function previewWithdrawRequestFees( - uint256 assets - ) external view returns (uint256 feeShares) { + function previewWithdrawRequestFees(uint256 assets) + external + view + returns (uint256 feeShares) + { uint256 assetFees = PoolLib.calculateRequestFee( assets, _pool.settings().requestFeeBps @@ -252,10 +270,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewRedeem( - address owner, - uint256 shares - ) external view returns (uint256 assets) { + function previewRedeem(address owner, uint256 shares) + external + view + returns (uint256 assets) + { IPoolWithdrawState memory withdrawState = _currentWithdrawState(owner); assets = PoolLib.calculateAssetsFromShares( shares, @@ -268,10 +287,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function previewWithdraw( - address owner, - uint256 assets - ) external view returns (uint256 shares) { + function previewWithdraw(address owner, uint256 assets) + external + view + returns (uint256 shares) + { IPoolWithdrawState memory withdrawState = _currentWithdrawState(owner); shares = PoolLib.calculateSharesFromAssets( assets, @@ -325,9 +345,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function maxRequestCancellation( - address owner - ) public view returns (uint256 maxShares) { + function maxRequestCancellation(address owner) + public + view + returns (uint256 maxShares) + { maxShares = PoolLib.calculateMaxCancellation( _currentWithdrawState(owner) ); @@ -336,10 +358,10 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function performRequestCancellation( - address owner, - uint256 shares - ) external onlyPool { + function performRequestCancellation(address owner, uint256 shares) + external + onlyPool + { require( !claimRequired(owner), "WithdrawController: must claim eligible first" @@ -379,9 +401,7 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function snapshot( - uint256 withdrawGate - ) + function snapshot(uint256 withdrawGate) external onlyPool returns ( @@ -458,9 +478,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @dev Internal function used to avoid duplicate calls to _currentWithdrawState. */ - function _claimRequired( - IPoolWithdrawState memory state - ) internal view returns (bool) { + function _claimRequired(IPoolWithdrawState memory state) + internal + view + returns (bool) + { return state.eligibleShares > 0 && state.latestSnapshotPeriod < @@ -470,10 +492,7 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function claimSnapshots( - address lender, - uint256 limit - ) + function claimSnapshots(address lender, uint256 limit) external onlyPool returns (uint256 sharesRedeemable, uint256 assetsWithdrawable) @@ -545,10 +564,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function redeem( - address owner, - uint256 shares - ) external onlyPool returns (uint256 assets) { + function redeem(address owner, uint256 shares) + external + onlyPool + returns (uint256 assets) + { IPoolWithdrawState memory state = _withdrawState[owner]; // Calculate how many assets should be transferred @@ -565,10 +585,11 @@ contract WithdrawController is IWithdrawController, BeaconImplementation { /** * @inheritdoc IWithdrawController */ - function withdraw( - address owner, - uint256 assets - ) external onlyPool returns (uint256 shares) { + function withdraw(address owner, uint256 assets) + external + onlyPool + returns (uint256 shares) + { IPoolWithdrawState memory state = _withdrawState[owner]; // Calculate how many shares should be burned diff --git a/contracts/controllers/interfaces/IPoolController.sol b/contracts/controllers/interfaces/IPoolController.sol index 2844af3d..cd0510d0 100644 --- a/contracts/controllers/interfaces/IPoolController.sol +++ b/contracts/controllers/interfaces/IPoolController.sol @@ -210,10 +210,9 @@ interface IPoolController { /** * @dev Withdraws first-loss from the pool. Can only be called by the Pool Admin. */ - function withdrawFirstLoss( - uint256 amount, - address receiver - ) external returns (uint256); + function withdrawFirstLoss(uint256 amount, address receiver) + external + returns (uint256); /*////////////////////////////////////////////////////////////// Loans diff --git a/contracts/controllers/interfaces/IWithdrawController.sol b/contracts/controllers/interfaces/IWithdrawController.sol index eec3fd04..de69420e 100644 --- a/contracts/controllers/interfaces/IWithdrawController.sol +++ b/contracts/controllers/interfaces/IWithdrawController.sol @@ -146,9 +146,10 @@ interface IWithdrawController { * a redeem request at this current block. * */ - function previewRedeemRequestFees( - uint256 shares - ) external view returns (uint256 feeShares); + function previewRedeemRequestFees(uint256 shares) + external + view + returns (uint256 feeShares); /** * @dev Simulate the effects of a withdrawal request at the current block. @@ -163,9 +164,10 @@ interface IWithdrawController { * @dev Returns the amount of fees that would be burned, in shares, to fulfill * a withdraw request in this current block. */ - function previewWithdrawRequestFees( - uint256 assets - ) external view returns (uint256 feeShares); + function previewWithdrawRequestFees(uint256 assets) + external + view + returns (uint256 feeShares); /** * @dev Simulates the effects of their redeemption at the current block. @@ -216,10 +218,9 @@ interface IWithdrawController { * @dev Iterates over snapshots, up to a limit, and claims eligible funds earmarked * across the snapshots, updating the lenders withdrawal state accordingly. */ - function claimSnapshots( - address lender, - uint256 limit - ) external returns (uint256 shares, uint256 assets); + function claimSnapshots(address lender, uint256 limit) + external + returns (uint256 shares, uint256 assets); /** * @dev Determines whether a lender is "up to date" with the snapshots. @@ -233,9 +234,7 @@ interface IWithdrawController { /** * @dev Snapshot the protocol. Performs accounting for withdrawals */ - function snapshot( - uint256 withdrawGate - ) + function snapshot(uint256 withdrawGate) external returns ( uint256 period, diff --git a/contracts/factories/WithdrawControllerFactory.sol b/contracts/factories/WithdrawControllerFactory.sol index efe94e74..e3aaa04d 100644 --- a/contracts/factories/WithdrawControllerFactory.sol +++ b/contracts/factories/WithdrawControllerFactory.sol @@ -41,9 +41,11 @@ contract WithdrawControllerFactory is /** * @inheritdoc IWithdrawControllerFactory */ - function createController( - address pool - ) public virtual returns (address addr) { + function createController(address pool) + public + virtual + returns (address addr) + { require( _serviceConfiguration.paused() == false, "WithdrawControllerFactory: Protocol paused" diff --git a/contracts/factories/interfaces/IPoolFactory.sol b/contracts/factories/interfaces/IPoolFactory.sol index ee0e446d..7cda180d 100644 --- a/contracts/factories/interfaces/IPoolFactory.sol +++ b/contracts/factories/interfaces/IPoolFactory.sol @@ -30,8 +30,7 @@ interface IPoolFactory { * @dev Creates a Pool. * @dev Emits `PoolCreated` event. */ - function createPool( - address, - IPoolConfigurableSettings calldata - ) external returns (address); + function createPool(address, IPoolConfigurableSettings calldata) + external + returns (address); } diff --git a/contracts/interfaces/IERC4626.sol b/contracts/interfaces/IERC4626.sol index fe0bd20e..92a70f68 100644 --- a/contracts/interfaces/IERC4626.sol +++ b/contracts/interfaces/IERC4626.sol @@ -79,10 +79,9 @@ interface IERC4626 is IERC20Upgradeable { * @dev Deposits assets of underlying tokens into the vault and grants ownership of shares to receiver. * Emits a {Deposit} event. */ - function deposit( - uint256 assets, - address receiver - ) external returns (uint256); + function deposit(uint256 assets, address receiver) + external + returns (uint256); /** * @dev Returns the maximum amount of shares that can be minted in a single mint call by the receiver. diff --git a/contracts/interfaces/ILoan.sol b/contracts/interfaces/ILoan.sol index 5ec9bd26..da324ca3 100644 --- a/contracts/interfaces/ILoan.sol +++ b/contracts/interfaces/ILoan.sol @@ -198,17 +198,17 @@ interface ILoan { * @dev Preview fees for a given interest payment amount. * @param amount allows previewing the fee for a full or prorated payment. */ - function previewFees( - uint256 amount - ) external view returns (ILoanFees memory); + function previewFees(uint256 amount) + external + view + returns (ILoanFees memory); /** * @dev Called by the borrower, this posts ERC20 assets to the collateral vault. */ - function postFungibleCollateral( - address asset, - uint256 amount - ) external returns (ILoanLifeCycleState); + function postFungibleCollateral(address asset, uint256 amount) + external + returns (ILoanLifeCycleState); /** * @dev Returns the ERC20 collateral posted to the loan. @@ -218,10 +218,9 @@ interface ILoan { /** * @dev Transfers and posts NFT collateral to be held by the loan's vault. */ - function postNonFungibleCollateral( - address asset, - uint256 tokenId - ) external returns (ILoanLifeCycleState); + function postNonFungibleCollateral(address asset, uint256 tokenId) + external + returns (ILoanLifeCycleState); /** * @dev Returns NFT collateral posted to the loan. diff --git a/contracts/interfaces/IPool.sol b/contracts/interfaces/IPool.sol index 595da18e..be60625b 100644 --- a/contracts/interfaces/IPool.sol +++ b/contracts/interfaces/IPool.sol @@ -202,7 +202,11 @@ interface IPool is IERC4626, IRequestWithdrawable { /** * @dev Called by the Pool Controller, it transfers the fixed fee */ - function claimFixedFee(address, uint256, uint256) external; + function claimFixedFee( + address, + uint256, + uint256 + ) external; /** * @dev Called by the Pool Controller, it withdraws from the FeeVault. @@ -228,9 +232,9 @@ interface IPool is IERC4626, IRequestWithdrawable { /** * @dev Claims funds earmarked across snapshots, up a limit of n snapshots. */ - function claimSnapshots( - uint256 limit - ) external returns (uint256 shares, uint256 assets); + function claimSnapshots(uint256 limit) + external + returns (uint256 shares, uint256 assets); /** * @dev Determines whether a lender has any funds across snapshots eligible for claiming. diff --git a/contracts/interfaces/IRequestWithdrawable.sol b/contracts/interfaces/IRequestWithdrawable.sol index 803e0efc..a744b4fc 100644 --- a/contracts/interfaces/IRequestWithdrawable.sol +++ b/contracts/interfaces/IRequestWithdrawable.sol @@ -29,9 +29,10 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxRedeem` */ - function maxRedeemRequest( - address owner - ) external view returns (uint256 maxShares); + function maxRedeemRequest(address owner) + external + view + returns (uint256 maxShares); /** * @dev Returns the maximum amount of underlying `assets` that can be @@ -40,9 +41,10 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxWithdraw` */ - function maxWithdrawRequest( - address owner - ) external view returns (uint256 maxAssets); + function maxWithdrawRequest(address owner) + external + view + returns (uint256 maxAssets); /** * @dev Simulate the effects of a redeem request at the current block. @@ -51,18 +53,20 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `previewRedeem` */ - function previewRedeemRequest( - uint256 shares - ) external view returns (uint256 assets); + function previewRedeemRequest(uint256 shares) + external + view + returns (uint256 assets); /** * @dev Returns the amount of fees (shares) that would be required to process * a redeem request at this current block. * */ - function previewRedeemRequestFees( - uint256 shares - ) external view returns (uint256 feeShares); + function previewRedeemRequestFees(uint256 shares) + external + view + returns (uint256 feeShares); /** * @dev Simulate the effects of a withdrawal request at the current block. @@ -71,17 +75,19 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `previewWithdraw` */ - function previewWithdrawRequest( - uint256 assets - ) external view returns (uint256 shares); + function previewWithdrawRequest(uint256 assets) + external + view + returns (uint256 shares); /** * @dev Returns the amount of fees that would be burned, in shares, to fulfill * a withdraw request in this current block. */ - function previewWithdrawRequestFees( - uint256 assets - ) external view returns (uint256 feeShares); + function previewWithdrawRequestFees(uint256 assets) + external + view + returns (uint256 feeShares); /** * @dev Submits a withdrawal request, incurring a fee. @@ -99,9 +105,10 @@ interface IRequestWithdrawable { * * Note: This is equivalent of EIP-4626 `maxRedeem` */ - function maxRequestCancellation( - address owner - ) external view returns (uint256 maxShares); + function maxRequestCancellation(address owner) + external + view + returns (uint256 maxShares); /** * @dev Cancels a redeem request for a specific number of `shares` from @@ -110,9 +117,9 @@ interface IRequestWithdrawable { * * Emits a {WithdrawRequestCancelled} event. */ - function cancelRedeemRequest( - uint256 shares - ) external returns (uint256 assets); + function cancelRedeemRequest(uint256 shares) + external + returns (uint256 assets); /** * @dev Cancels a withdraw request for a specific values of `assets` from @@ -121,7 +128,7 @@ interface IRequestWithdrawable { * * Emits a {WithdrawRequestCancelled} event. */ - function cancelWithdrawRequest( - uint256 assets - ) external returns (uint256 shares); + function cancelWithdrawRequest(uint256 assets) + external + returns (uint256 shares); } diff --git a/contracts/libraries/LoanLib.sol b/contracts/libraries/LoanLib.sol index c696c14d..0a59fb02 100644 --- a/contracts/libraries/LoanLib.sol +++ b/contracts/libraries/LoanLib.sol @@ -29,7 +29,7 @@ library LoanLib { using SafeERC20 for IERC20; using SafeMath for uint256; - uint256 public constant RAY = 10 ** 27; + uint256 public constant RAY = 10**27; /** * @dev Emitted when loan is funded. @@ -308,17 +308,19 @@ library LoanLib { emit CanceledLoanPrincipalReturned(pool, amount); } - function previewFirstLossFee( - uint256 payment, - uint256 firstLossFeeBps - ) public pure returns (uint256) { + function previewFirstLossFee(uint256 payment, uint256 firstLossFeeBps) + public + pure + returns (uint256) + { return RAY.mul(payment).mul(firstLossFeeBps).div(100_00).div(RAY); } - function previewServiceFee( - uint256 payment, - uint256 serviceFeeBps - ) public pure returns (uint256) { + function previewServiceFee(uint256 payment, uint256 serviceFeeBps) + public + pure + returns (uint256) + { return RAY.mul(payment).mul(serviceFeeBps).div(100_00).div(RAY); } diff --git a/contracts/libraries/PoolLib.sol b/contracts/libraries/PoolLib.sol index 117e8bab..a920071d 100644 --- a/contracts/libraries/PoolLib.sol +++ b/contracts/libraries/PoolLib.sol @@ -35,7 +35,7 @@ library PoolLib { using SafeMath for uint256; using EnumerableSet for EnumerableSet.AddressSet; - uint256 public constant RAY = 10 ** 27; + uint256 public constant RAY = 10**27; /** * @dev See IPoolController */ @@ -102,10 +102,11 @@ library PoolLib { /** * @dev Divide two numbers and round the result up */ - function divideCeil( - uint256 lhs, - uint256 rhs - ) internal pure returns (uint256) { + function divideCeil(uint256 lhs, uint256 rhs) + internal + pure + returns (uint256) + { return (lhs + rhs - 1) / rhs; } @@ -286,10 +287,11 @@ library PoolLib { * If the pool has assets, it is solvent. If no assets are available, * but no shares have been issued, it is solvent. Otherwise, it is insolvent. */ - function isSolvent( - uint256 totalAssets, - uint256 totalShares - ) private pure returns (bool) { + function isSolvent(uint256 totalAssets, uint256 totalShares) + private + pure + returns (bool) + { return totalAssets > 0 || totalShares == 0; } @@ -518,10 +520,11 @@ library PoolLib { * @dev Calculate the fee for making a withdrawRequest or a redeemRequest. * Per the EIP-4626 spec, this method rounds up. */ - function calculateRequestFee( - uint256 shares, - uint256 requestFeeBps - ) public pure returns (uint256) { + function calculateRequestFee(uint256 shares, uint256 requestFeeBps) + public + pure + returns (uint256) + { return divideCeil(shares * requestFeeBps, 10_000); } @@ -556,9 +559,11 @@ library PoolLib { * @dev Calculates the Maximum amount of shares that can be cancelled * from the current withdraw request. */ - function calculateMaxCancellation( - IPoolWithdrawState memory state - ) public pure returns (uint256) { + function calculateMaxCancellation(IPoolWithdrawState memory state) + public + pure + returns (uint256) + { return state.requestedShares + state.eligibleShares; } diff --git a/contracts/mocks/PoolLibTestWrapper.sol b/contracts/mocks/PoolLibTestWrapper.sol index 9f6a5a57..87c8e2a6 100644 --- a/contracts/mocks/PoolLibTestWrapper.sol +++ b/contracts/mocks/PoolLibTestWrapper.sol @@ -257,10 +257,11 @@ contract PoolLibTestWrapper is ERC20("PoolLibTest", "PLT") { ); } - function calculateRequestFee( - uint256 shares, - uint256 requestFeeBps - ) external pure returns (uint256) { + function calculateRequestFee(uint256 shares, uint256 requestFeeBps) + external + pure + returns (uint256) + { return PoolLib.calculateRequestFee(shares, requestFeeBps); } @@ -285,9 +286,11 @@ contract PoolLibTestWrapper is ERC20("PoolLibTest", "PLT") { ); } - function calculateMaxCancellation( - IPoolWithdrawState memory state - ) public pure returns (uint256) { + function calculateMaxCancellation(IPoolWithdrawState memory state) + public + pure + returns (uint256) + { return PoolLib.calculateMaxCancellation(state); } } diff --git a/contracts/permissioned/PermissionedPool.sol b/contracts/permissioned/PermissionedPool.sol index cc0c75df..bddeca3c 100644 --- a/contracts/permissioned/PermissionedPool.sol +++ b/contracts/permissioned/PermissionedPool.sol @@ -90,9 +90,12 @@ contract PermissionedPool is Pool { * @dev Since Pool does not enforce that msg.sender == receiver, we only * check the receiver here. */ - function maxDeposit( - address receiver - ) public view override returns (uint256) { + function maxDeposit(address receiver) + public + view + override + returns (uint256) + { if (!poolAccessControl.isAllowed(receiver)) { return 0; } @@ -118,9 +121,12 @@ contract PermissionedPool is Pool { * @dev If a lender is not (currently) allowed, 0 assets are allowed to be * withdrawn from the Pool. */ - function maxWithdraw( - address owner - ) public view override returns (uint256 assets) { + function maxWithdraw(address owner) + public + view + override + returns (uint256 assets) + { if (!poolAccessControl.isAllowed(owner)) { return 0; } @@ -133,9 +139,12 @@ contract PermissionedPool is Pool { * @dev If a lender is not (currently) allowed, 0 shares are allowed to be * redeemed from the Pool. */ - function maxRedeem( - address owner - ) public view override returns (uint256 maxShares) { + function maxRedeem(address owner) + public + view + override + returns (uint256 maxShares) + { if (!poolAccessControl.isAllowed(owner)) { return 0; } diff --git a/contracts/permissioned/PoolAccessControl.sol b/contracts/permissioned/PoolAccessControl.sol index 9348b826..c8ff208d 100644 --- a/contracts/permissioned/PoolAccessControl.sol +++ b/contracts/permissioned/PoolAccessControl.sol @@ -98,10 +98,10 @@ contract PoolAccessControl is /** * @dev The constructor for the PoolAccessControl contract */ - function initialize( - address pool, - address tosAcceptanceRegistry - ) public initializer { + function initialize(address pool, address tosAcceptanceRegistry) + public + initializer + { require( tosAcceptanceRegistry != address(0), "Pool: invalid ToS registry" @@ -124,9 +124,11 @@ contract PoolAccessControl is * * Emits an {AllowedParticipantListUpdated} event. */ - function allowParticipant( - address addr - ) external onlyNotPaused onlyPoolAdmin { + function allowParticipant(address addr) + external + onlyNotPaused + onlyPoolAdmin + { require( _tosRegistry.hasAccepted(addr), "Pool: participant not accepted ToS" @@ -140,9 +142,11 @@ contract PoolAccessControl is * * Emits an {AllowedParticipantListUpdated} event. */ - function removeParticipant( - address addr - ) external onlyNotPaused onlyPoolAdmin { + function removeParticipant(address addr) + external + onlyNotPaused + onlyPoolAdmin + { delete _allowedParticipants[addr]; emit ParticipantRemoved(addr); } @@ -164,18 +168,22 @@ contract PoolAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function addCredentialSchema( - string[] calldata schema - ) public override onlyNotPaused { + function addCredentialSchema(string[] calldata schema) + public + override + onlyNotPaused + { super.addCredentialSchema(schema); } /** * @inheritdoc IVeriteAccessControl */ - function removeCredentialSchema( - string[] calldata schema - ) public override onlyNotPaused { + function removeCredentialSchema(string[] calldata schema) + public + override + onlyNotPaused + { super.removeCredentialSchema(schema); } diff --git a/contracts/permissioned/ToSAcceptanceRegistry.sol b/contracts/permissioned/ToSAcceptanceRegistry.sol index ec58dee2..dc421973 100644 --- a/contracts/permissioned/ToSAcceptanceRegistry.sol +++ b/contracts/permissioned/ToSAcceptanceRegistry.sol @@ -74,9 +74,11 @@ contract ToSAcceptanceRegistry is /** * @inheritdoc IToSAcceptanceRegistry */ - function updateTermsOfService( - string memory url - ) external override onlyOperator { + function updateTermsOfService(string memory url) + external + override + onlyOperator + { _termsOfService = url; _termsSet = true; emit TermsOfServiceUpdated(); diff --git a/contracts/permissioned/VeriteAccessControl.sol b/contracts/permissioned/VeriteAccessControl.sol index 213e6b76..b3d5fe5a 100644 --- a/contracts/permissioned/VeriteAccessControl.sol +++ b/contracts/permissioned/VeriteAccessControl.sol @@ -82,9 +82,11 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function removeTrustedVerifier( - address addr - ) public virtual onlyVeriteAdmin { + function removeTrustedVerifier(address addr) + public + virtual + onlyVeriteAdmin + { delete _trustedVerifiers[addr]; emit TrustedVerifierRemoved(addr); @@ -93,9 +95,11 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function addCredentialSchema( - string[] calldata schema - ) public virtual onlyVeriteAdmin { + function addCredentialSchema(string[] calldata schema) + public + virtual + onlyVeriteAdmin + { _supportedCredentialSchemas[concat(schema)] = true; emit CredentialSchemaAdded(schema); @@ -104,9 +108,11 @@ abstract contract VeriteAccessControl is /** * @inheritdoc IVeriteAccessControl */ - function removeCredentialSchema( - string[] calldata schema - ) public virtual onlyVeriteAdmin { + function removeCredentialSchema(string[] calldata schema) + public + virtual + onlyVeriteAdmin + { delete _supportedCredentialSchemas[concat(schema)]; emit CredentialSchemaRemoved(schema); @@ -184,9 +190,11 @@ abstract contract VeriteAccessControl is * encoding itself. Protocols need to implement the type-specific encoding they need in their * contracts using a combination of `abi.encode` and `keccak256`. */ - function concat( - string[] memory words - ) internal pure returns (string memory) { + function concat(string[] memory words) + internal + pure + returns (string memory) + { bytes memory output; for (uint256 i = 0; i < words.length; i++) { diff --git a/contracts/permissioned/factories/PermissionedLoanFactory.sol b/contracts/permissioned/factories/PermissionedLoanFactory.sol index d5ebdfbc..9d7cc711 100644 --- a/contracts/permissioned/factories/PermissionedLoanFactory.sol +++ b/contracts/permissioned/factories/PermissionedLoanFactory.sol @@ -24,10 +24,9 @@ import "../PermissionedLoan.sol"; * @dev Emits PermissionLoans. Also acts as a beacon for said proxies. */ contract PermissionedLoanFactory is LoanFactory { - constructor( - address serviceConfiguration, - address vaultFactory - ) LoanFactory(serviceConfiguration, vaultFactory) {} + constructor(address serviceConfiguration, address vaultFactory) + LoanFactory(serviceConfiguration, vaultFactory) + {} /** * @inheritdoc LoanFactory diff --git a/contracts/upgrades/BeaconProxyFactory.sol b/contracts/upgrades/BeaconProxyFactory.sol index 495abcdf..bb960834 100644 --- a/contracts/upgrades/BeaconProxyFactory.sol +++ b/contracts/upgrades/BeaconProxyFactory.sol @@ -48,9 +48,10 @@ abstract contract BeaconProxyFactory is IBeacon { /** * @inheritdoc IBeacon */ - function setImplementation( - address newImplementation - ) external onlyDeployer { + function setImplementation(address newImplementation) + external + onlyDeployer + { implementation = newImplementation; emit ImplementationSet(newImplementation); } diff --git a/test/Loan.test.ts b/test/Loan.test.ts index cb46cf06..a43d6746 100644 --- a/test/Loan.test.ts +++ b/test/Loan.test.ts @@ -1952,11 +1952,11 @@ describe("Loan", () => { liquidityAsset, borrower, 0 - - interestPayment - - principal - - originationFee - - firstLossFee + - prepaidPrincipal + interestPayment - + principal - + originationFee - + firstLossFee + + prepaidPrincipal ); await expect(tx).to.changeTokenBalance( liquidityAsset, diff --git a/test/scenarios/pool/fixed-term-defaulted.test.ts b/test/scenarios/pool/fixed-term-defaulted.test.ts index 4dc54dcc..77de068d 100644 --- a/test/scenarios/pool/fixed-term-defaulted.test.ts +++ b/test/scenarios/pool/fixed-term-defaulted.test.ts @@ -73,7 +73,7 @@ describe("Fixed Term Defaulted Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { diff --git a/test/scenarios/pool/fixed-term-matured.test.ts b/test/scenarios/pool/fixed-term-matured.test.ts index da8499fe..a1972672 100644 --- a/test/scenarios/pool/fixed-term-matured.test.ts +++ b/test/scenarios/pool/fixed-term-matured.test.ts @@ -73,7 +73,7 @@ describe("Fixed Term Matured Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { @@ -118,8 +118,8 @@ describe("Fixed Term Matured Loan Scenario", () => { .approve( loan.address, INPUTS.loanAmount + - (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / + DEFAULT_LOAN_SETTINGS.paymentPeriod ); await loan.connect(borrower).completeFullPayment(); diff --git a/test/scenarios/pool/open-term-defaulted.test.ts b/test/scenarios/pool/open-term-defaulted.test.ts index 03279da2..b3470467 100644 --- a/test/scenarios/pool/open-term-defaulted.test.ts +++ b/test/scenarios/pool/open-term-defaulted.test.ts @@ -73,7 +73,7 @@ describe("Open Term Defaulted Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { diff --git a/test/scenarios/pool/open-term-matured.test.ts b/test/scenarios/pool/open-term-matured.test.ts index aa497332..dd597dde 100644 --- a/test/scenarios/pool/open-term-matured.test.ts +++ b/test/scenarios/pool/open-term-matured.test.ts @@ -74,7 +74,7 @@ describe("Open Term Matured Loan Scenario", () => { await mockERC20.mint( borrower.address, (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + DEFAULT_LOAN_SETTINGS.paymentPeriod ); return { @@ -127,8 +127,8 @@ describe("Open Term Matured Loan Scenario", () => { .approve( loan.address, INPUTS.loanAmount + - (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / - DEFAULT_LOAN_SETTINGS.paymentPeriod + (INPUTS.loanPayment * DEFAULT_LOAN_SETTINGS.duration) / + DEFAULT_LOAN_SETTINGS.paymentPeriod ); await loan.connect(borrower).paydownPrincipal(500_000); // check accountings again diff --git a/test/scenarios/pool/withdraw-request.test.ts b/test/scenarios/pool/withdraw-request.test.ts index 9a7b21a4..44929f39 100644 --- a/test/scenarios/pool/withdraw-request.test.ts +++ b/test/scenarios/pool/withdraw-request.test.ts @@ -144,7 +144,7 @@ describe("Withdraw Requests", () => { (100 /* initial balance */ - 50 /* requested */ - 5) /* previous request fee */ * - 0.9 /* sub the request fee */ + 0.9 /* sub the request fee */ ) ); expect(await pool.maxWithdrawRequest(aliceLender.address)).to.equal(41); @@ -155,7 +155,7 @@ describe("Withdraw Requests", () => { (70 /* initial balance */ - 10 /* requested */ - 1) /* previous request fee */ * - 0.9 /* sub the request fee */ + 0.9 /* sub the request fee */ ) ); expect(await pool.maxWithdrawRequest(bobLender.address)).to.equal(54); diff --git a/test/support/loan.ts b/test/support/loan.ts index c7d32124..33123288 100644 --- a/test/support/loan.ts +++ b/test/support/loan.ts @@ -48,8 +48,8 @@ export async function deployLoan( const { serviceConfiguration } = await (existingServiceConfiguration == null ? deployServiceConfiguration() : { - serviceConfiguration: existingServiceConfiguration - }); + serviceConfiguration: existingServiceConfiguration + }); const { operator, deployer } = await getCommonSigners(); @@ -125,8 +125,8 @@ export async function deployPermissionedLoan( const { serviceConfiguration } = await (existingServiceConfiguration == null ? deployPermissionedServiceConfiguration() : { - serviceConfiguration: existingServiceConfiguration - }); + serviceConfiguration: existingServiceConfiguration + }); const vaultFactory = await deployVaultFactory(serviceConfiguration.address);