diff --git a/.gas-snapshot b/.gas-snapshot index b364258d..f129a939 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -20,37 +20,37 @@ Certificate_supportsInterface:test() (gas: 5159) Certificate_transferFrom:test() (gas: 48618) Certificate_transferFrom:test_reverts_when_paused() (gas: 38088) Certificate_transferFrom_reverts_ForbiddenTransferAfterMinting:test() (gas: 18960) -Checkout_buyingFromOneRemoval:test() (gas: 470304) -Checkout_buyingFromOneRemoval_byApproval:test() (gas: 408695) -Checkout_buyingFromTenRemovals:test() (gas: 1550316) -Checkout_buyingFromTenRemovals_singleSupplier:test() (gas: 1310226) -Checkout_buyingFromTenRemovals_singleSupplier_withoutFee:test() (gas: 1305426) -Checkout_buyingFromTenRemovals_withoutFee:test() (gas: 1318133) -Checkout_buyingFromTenSuppliers:test() (gas: 1818941) -Checkout_buyingWithAlternateERC20:test() (gas: 540866) -Checkout_buyingWithAlternateERC20_floatingPointPriceMultiple:test() (gas: 506920) -Checkout_swapRevertsWhenBuyerIsMissingSANCTION_ALLOWLIST_ROLE:test() (gas: 168649) -Checkout_swapRevertsWithDifferentPermitSignerAndMsgSender:test() (gas: 168661) -Checkout_swapWithoutFeeSpecialOrder:test() (gas: 380653) -Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test() (gas: 375352) +Checkout_buyingFromOneRemoval:test() (gas: 470314) +Checkout_buyingFromOneRemoval_byApproval:test() (gas: 408705) +Checkout_buyingFromTenRemovals:test() (gas: 1549359) +Checkout_buyingFromTenRemovals_singleSupplier:test() (gas: 1309225) +Checkout_buyingFromTenRemovals_singleSupplier_withoutFee:test() (gas: 1304425) +Checkout_buyingFromTenRemovals_withoutFee:test() (gas: 1317176) +Checkout_buyingFromTenSuppliers:test() (gas: 1818158) +Checkout_buyingWithAlternateERC20:test() (gas: 540964) +Checkout_buyingWithAlternateERC20_floatingPointPriceMultiple:test() (gas: 506930) +Checkout_swapRevertsWhenBuyerIsMissingSANCTION_ALLOWLIST_ROLE:test() (gas: 168693) +Checkout_swapRevertsWithDifferentPermitSignerAndMsgSender:test() (gas: 168705) +Checkout_swapWithoutFeeSpecialOrder:test() (gas: 380597) +Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test() (gas: 375252) Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test_revertsWhenSupplierDoesNotExistInMarket() (gas: 57753) -Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_basicFulfillment() (gas: 642523) -Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_revertsWhenNoRemovalsFromSpecifiedVintages() (gas: 91022) -Checkout_swapWithoutFeeSpecialOrder_specificVintagesSpecificSupplier:test_basicFulfillment() (gas: 491974) -GasBenchmark_buyingFromManyRemovals_singleSupplier:test() (gas: 29850540) -GasBenchmark_buyingFromOneRemoval_singleSupplier:test() (gas: 322967) +Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_basicFulfillment() (gas: 642423) +Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_revertsWhenNoRemovalsFromSpecifiedVintages() (gas: 91044) +Checkout_swapWithoutFeeSpecialOrder_specificVintagesSpecificSupplier:test_basicFulfillment() (gas: 491863) +GasBenchmark_buyingFromManyRemovals_singleSupplier:test() (gas: 29847653) +GasBenchmark_buyingFromOneRemoval_singleSupplier:test() (gas: 322867) LockedNORILib_availableAmount:test() (gas: 12371) LockedNORITest:testBatchGrantCreation() (gas: 705179) LockedNORITest:testNormalWithdrawal() (gas: 1102743) LockedNORITest:testReentryTokensReceived() (gas: 1102887) LockedNORITest:testReentryTokensToSend() (gas: 1104432) LockedNORITest:testTokensReceivedReverts() (gas: 69026) -MarketInvariantTest:invariant_callSummary() (runs: 400, calls: 6000, reverts: 4264) -MarketInvariantTest:invariant_sumOfPurchaseAmounts() (runs: 400, calls: 6000, reverts: 4263) -MarketSupplierSelectionNotUsingUpSuppliersLastRemoval:test() (gas: 644679) +MarketInvariantTest:invariant_callSummary() (runs: 400, calls: 6000, reverts: 4285) +MarketInvariantTest:invariant_sumOfPurchaseAmounts() (runs: 400, calls: 6000, reverts: 4268) +MarketSupplierSelectionNotUsingUpSuppliersLastRemoval:test() (gas: 644612) Market_ALLOWLIST_ROLE:test() (gas: 12799) Market_SANCTION_ALLOWLIST_ROLE:test() (gas: 12897) -Market_USDC_swap_respects_decimal_mismatch:test() (gas: 786972) +Market_USDC_swap_respects_decimal_mismatch:test() (gas: 786916) Market__addActiveRemoval:test() (gas: 183344) Market__addActiveRemoval:test__lis2VintagesFor1SupplierFor2SubIdentifiers() (gas: 242879) Market__addActiveRemoval:test__list1VintageFor1Supplier() (gas: 188309) @@ -75,104 +75,104 @@ Market__validateSupply:test_reverts_OutOfSupply() (gas: 3172) Market_calculates_prices_using_decimal:test() (gas: 66514) Market_convertPurchasingTokenDecimalsToRemovalDecimals:test() (gas: 26029) Market_convertRemovalDecimalsToPurchasingTokenDecimals:test() (gas: 29773) -Market_getActiveSuppliers:test_1_supplier() (gas: 448048) -Market_getActiveSuppliers:test_3_suppliers() (gas: 1089590) +Market_getActiveSuppliers:test_1_supplier() (gas: 447828) +Market_getActiveSuppliers:test_3_suppliers() (gas: 1088942) Market_getActiveSuppliers:test_no_suppliers() (gas: 20859) Market_getPriceMultiple:test() (gas: 14851) -Market_getRemovalIdsForSupplier:test_1_removal() (gas: 448451) -Market_getRemovalIdsForSupplier:test_3_removals() (gas: 831906) -Market_getRemovalIdsForSupplier:test_3_removals_different_vintages() (gas: 878015) +Market_getRemovalIdsForSupplier:test_1_removal() (gas: 448231) +Market_getRemovalIdsForSupplier:test_3_removals() (gas: 831646) +Market_getRemovalIdsForSupplier:test_3_removals_different_vintages() (gas: 877755) Market_getRemovalIdsForSupplier:test_no_removals() (gas: 26044) Market_onERC1155BatchReceived:test() (gas: 208124) -Market_onERC1155BatchReceived_reverts_SenderNotRemovalContract:test() (gas: 331712) +Market_onERC1155BatchReceived_reverts_SenderNotRemovalContract:test() (gas: 331570) Market_onERC1155Received:test() (gas: 206036) -Market_onERC1155Received_reverts_SenderNotRemovalContract:test() (gas: 159022) +Market_onERC1155Received_reverts_SenderNotRemovalContract:test() (gas: 159044) Market_purchasingTokenAddress:test() (gas: 17080) -Market_replace:test() (gas: 278047) +Market_replace:test() (gas: 277991) Market_replace_reverts_CertificateNotYetMinted:test() (gas: 49559) Market_replace_reverts_ReplacementAmountExceedsNrtDeficit:test() (gas: 52590) -Market_replace_reverts_ReplacementAmountMismatch:test() (gas: 86353) +Market_replace_reverts_ReplacementAmountMismatch:test() (gas: 86397) Market_setNoriFeePercentage_revertsInvalidPercentage:test() (gas: 20276) -Market_setPriorityRestrictedThreshold:test() (gas: 157360) -Market_setPriorityRestrictedThreshold:test_zeroAvailable() (gas: 152335) +Market_setPriorityRestrictedThreshold:test() (gas: 157448) +Market_setPriorityRestrictedThreshold:test_zeroAvailable() (gas: 152423) Market_setPurchasingTokenAndPriceMultiple:test() (gas: 1026641) Market_setPurchasingTokenAndPriceMultiple_revertsIfNotAdmin:test() (gas: 50813) -Market_supplierSelectionUsingUpSuppliersLastRemoval:test() (gas: 641388) -Market_swap_revertsWhenUnsafeERC20TransferFails:test() (gas: 189604) +Market_supplierSelectionUsingUpSuppliersLastRemoval:test() (gas: 641321) +Market_swap_revertsWhenUnsafeERC20TransferFails:test() (gas: 189648) Market_validates_certificate_amount:test() (gas: 596800) -Market_withdraw_1x3_center:test() (gas: 340737) -Market_withdraw_2x1_back:test() (gas: 345397) -Market_withdraw_2x1_front:test() (gas: 333754) -Market_withdraw_2x1_front_relist:test() (gas: 381689) -Market_withdraw_as_DEFAULT_ADMIN_ROLE:test() (gas: 276447) -Market_withdraw_as_operator:test() (gas: 285592) -Market_withdraw_as_supplier:test() (gas: 274588) -Market_withdraw_reverts:test() (gas: 138621) +Market_withdraw_1x3_center:test() (gas: 340814) +Market_withdraw_2x1_back:test() (gas: 345496) +Market_withdraw_2x1_front:test() (gas: 333831) +Market_withdraw_2x1_front_relist:test() (gas: 381788) +Market_withdraw_as_DEFAULT_ADMIN_ROLE:test() (gas: 276524) +Market_withdraw_as_operator:test() (gas: 285669) +Market_withdraw_as_supplier:test() (gas: 274665) +Market_withdraw_reverts:test() (gas: 138709) NORI_name:test() (gas: 17205) NORI_permit:test() (gas: 92382) NoriUSDC_permit:test() (gas: 122061) -RemovalQueue_getTotalBalanceFromRemovalQueue:test() (gas: 23899) -RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheDifferentVintages() (gas: 895786) -RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheSameVintage() (gas: 620299) +RemovalQueue_getTotalBalanceFromRemovalQueue:test() (gas: 23921) +RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheDifferentVintages() (gas: 895808) +RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheSameVintage() (gas: 620321) RemovalQueue_insertRemovalByVintage:test_insertRemovalOnce() (gas: 119613) RemovalQueue_insertRemovalByVintage:test_insertRemovalTwice() (gas: 121103) Removal__beforeTokenTransfer:test() (gas: 18010) Removal__beforeTokenTransfer:test_paused_reverts_Paused() (gas: 29432) Removal__createRemovalData:test() (gas: 22593) -Removal__createRemovalData:test_reverts_InvalidData() (gas: 25689) -Removal__createRemovalDataBatch:test() (gas: 29572) -Removal__createRemovalDataBatch:test_reverts_InvalidData2() (gas: 36736) -Removal__isValidTransferAmount:testFuzz_ReturnFalse_NonMultiplesOf1e14(uint256) (runs: 256, μ: 13913, ~: 13869) -Removal__isValidTransferAmount:testFuzz_ReturnTrue_MultiplesOf1e14(uint256) (runs: 256, μ: 14397, ~: 14519) -Removal__isValidTransferAmount:testFuzz_ReturnTrue_SmallestGranularity() (gas: 6854) -Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranular() (gas: 6832) -Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranularAndToIsTheCertificate() (gas: 4767) -Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranularAndToIsTheMarket() (gas: 2630) -Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheCertificate() (gas: 4683) -Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheMarket() (gas: 2543) +Removal__createRemovalData:test_reverts_InvalidData() (gas: 25711) +Removal__createRemovalDataBatch:test() (gas: 29594) +Removal__createRemovalDataBatch:test_reverts_InvalidData2() (gas: 36802) +Removal__isValidTransferAmount:testFuzz_ReturnFalse_NonMultiplesOf1e14(uint256) (runs: 256, μ: 13935, ~: 13891) +Removal__isValidTransferAmount:testFuzz_ReturnTrue_MultiplesOf1e14(uint256) (runs: 256, μ: 14315, ~: 14432) +Removal__isValidTransferAmount:testFuzz_ReturnTrue_SmallestGranularity() (gas: 6876) +Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranular() (gas: 6854) +Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranularAndToIsTheCertificate() (gas: 4789) +Removal__isValidTransferAmount:test_ReturnFalse_AmountIsTooGranularAndToIsTheMarket() (gas: 2652) +Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheCertificate() (gas: 4705) +Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheMarket() (gas: 2565) Removal__isValidTransferAmount:test_ReturnTrue_AmountIsZeroAndToIsNeitherTheMarketNorCertificate() (gas: 6852) Removal__validateRemoval:test() (gas: 2491) -Removal__validateRemoval:test_reverts_InvalidData() (gas: 5351) -Removal_addBalance:test() (gas: 60269) -Removal_addBalance_reverts_RemovalNotYetMinted:test() (gas: 31093) -Removal_consign_revertsForSoldRemovals:test() (gas: 896760) -Removal_consignorBatchTransfer:test() (gas: 297347) +Removal__validateRemoval:test_reverts_InvalidData() (gas: 5373) +Removal_addBalance:test() (gas: 60280) +Removal_addBalance_reverts_RemovalNotYetMinted:test() (gas: 31115) +Removal_consign_revertsForSoldRemovals:test() (gas: 896622) +Removal_consignorBatchTransfer:test() (gas: 297325) Removal_consignorBatchTransfer:test_reverts_whenReceiverIsNotConsignor() (gas: 128791) -Removal_consignorBatchTransfer:test_reverts_whenSenderIsNotConsignor() (gas: 65690) -Removal_getMarketBalance:test() (gas: 907193) -Removal_getOwnedTokenIds:test_multiple_tokens_with_transfer() (gas: 917081) -Removal_getOwnedTokenIds:test_no_tokens() (gas: 18772) -Removal_getProjectId:test() (gas: 19395) -Removal_grantRole:test_reverts_when_paused() (gas: 26250) -Removal_mintBatch:test() (gas: 177546) -Removal_mintBatch_list:test() (gas: 395816) -Removal_mintBatch_list_sequential:test() (gas: 581633) -Removal_mintBatch_multiple:test_16() (gas: 2921601) -Removal_mintBatch_multiple:test_2() (gas: 564154) -Removal_mintBatch_multiple:test_32() (gas: 5616934) -Removal_mintBatch_multiple:test_4() (gas: 900893) -Removal_mintBatch_multiple:test_8() (gas: 1574376) -Removal_mintBatch_reverts_mint_to_wrong_address:test() (gas: 65369) -Removal_mintBatch_zero_amount_removal:test() (gas: 140120) -Removal_mintBatch_zero_amount_removal_to_market_reverts:test() (gas: 61802) -Removal_multicall:test_balanceOfBatch() (gas: 320910) -Removal_release_listed:test() (gas: 356793) -Removal_release_listed_isRemovedFromMarket:test() (gas: 357148) -Removal_release_partial_listed:test() (gas: 79571) -Removal_release_retired:test() (gas: 92381) -Removal_release_retired_2x:test() (gas: 98467) -Removal_release_retired_burned:test() (gas: 94861) -Removal_release_retired_burned:testDecrementsCertificateDiscrepancy() (gas: 88859) -Removal_release_retired_oneHundredCertificates:test() (gas: 89491) -Removal_release_reverts_AccessControl:test() (gas: 48735) -Removal_release_unlisted:test() (gas: 48600) -Removal_release_unlisted_listed_and_retired:test() (gas: 237463) -Removal_renounceRole:test_reverts_when_paused() (gas: 19666) -Removal_retire:test() (gas: 989180) -Removal_retire_gasLimit:test() (gas: 15361939) -Removal_retire_revertsIfRemovalBalanceSumDifferentFromCertificateAmount:test() (gas: 1002910) +Removal_consignorBatchTransfer:test_reverts_whenSenderIsNotConsignor() (gas: 65646) +Removal_getMarketBalance:test() (gas: 907046) +Removal_getOwnedTokenIds:test_multiple_tokens_with_transfer() (gas: 916416) +Removal_getOwnedTokenIds:test_no_tokens() (gas: 18683) +Removal_getProjectId:test() (gas: 19307) +Removal_grantRole:test_reverts_when_paused() (gas: 26183) +Removal_mintBatch:test() (gas: 177323) +Removal_mintBatch_list:test() (gas: 395593) +Removal_mintBatch_list_sequential:test() (gas: 581194) +Removal_mintBatch_multiple:test_16() (gas: 2921030) +Removal_mintBatch_multiple:test_2() (gas: 563909) +Removal_mintBatch_multiple:test_32() (gas: 5615988) +Removal_mintBatch_multiple:test_4() (gas: 900601) +Removal_mintBatch_multiple:test_8() (gas: 1573991) +Removal_mintBatch_reverts_mint_to_wrong_address:test() (gas: 65162) +Removal_mintBatch_zero_amount_removal:test() (gas: 139898) +Removal_mintBatch_zero_amount_removal_to_market_reverts:test() (gas: 61595) +Removal_multicall:test_balanceOfBatch() (gas: 320743) +Removal_release_listed:test() (gas: 356643) +Removal_release_listed_isRemovedFromMarket:test() (gas: 356996) +Removal_release_partial_listed:test() (gas: 79593) +Removal_release_retired:test() (gas: 92447) +Removal_release_retired_2x:test() (gas: 98511) +Removal_release_retired_burned:test() (gas: 94927) +Removal_release_retired_burned:testDecrementsCertificateDiscrepancy() (gas: 88881) +Removal_release_retired_oneHundredCertificates:test() (gas: 89557) +Removal_release_reverts_AccessControl:test() (gas: 48757) +Removal_release_unlisted:test() (gas: 48617) +Removal_release_unlisted_listed_and_retired:test() (gas: 237498) +Removal_renounceRole:test_reverts_when_paused() (gas: 19599) +Removal_retire:test() (gas: 989092) +Removal_retire_gasLimit:test() (gas: 15359805) +Removal_retire_revertsIfRemovalBalanceSumDifferentFromCertificateAmount:test() (gas: 1002822) Removal_revokeRole:test_reverts_when_paused() (gas: 26818) -Removal_safeBatchTransferFrom_reverts_ForbiddenTransfer:test() (gas: 32162) +Removal_safeBatchTransferFrom_reverts_ForbiddenTransfer:test() (gas: 32073) Removal_safeTransferFrom_reverts_ForbiddenTransfer:test() (gas: 27716) UInt256ArrayLib_fill:test() (gas: 120236) UInt256ArrayLib_fill:test_gas() (gas: 101580) diff --git a/contracts/Errors.sol b/contracts/Errors.sol index a485403f..fa3af002 100644 --- a/contracts/Errors.sol +++ b/contracts/Errors.sol @@ -120,10 +120,6 @@ error RemovalNotYetMinted(uint256 tokenId); * @notice Thrown when the caller specifies the zero address for the Nori fee wallet. */ error NoriFeeWalletZeroAddress(); -/** - * @notice Thrown when a holdback percentage greater than 100 is submitted to `mintBatch`. - */ -error InvalidHoldbackPercentage(uint8 holdbackPercentage); /** * @notice Thrown when a purchasing token decimals value is not between 6 and 18. * @param decimals The purchasing token decimals value that is invalid. diff --git a/contracts/Removal.sol b/contracts/Removal.sol index c4c33158..489f19b2 100644 --- a/contracts/Removal.sol +++ b/contracts/Removal.sol @@ -22,7 +22,6 @@ import { RemovalAlreadySoldOrConsigned, ForbiddenTransfer, ForbiddenTransfer, - InvalidHoldbackPercentage, ForbiddenTransfer, InvalidData } from "./Errors.sol"; @@ -172,13 +171,6 @@ contract Removal is */ event RegisterContractAddresses(IMarket market, ICertificate certificate); - /** - * @notice Emitted when the holdback percentage is updated for a project. - * @param projectId The ID of the project. - * @param holdbackPercentage The new holdback percentage for the project. - */ - event SetHoldbackPercentage(uint256 projectId, uint8 holdbackPercentage); - /** * @notice Emitted on releasing a removal from a supplier, the market, or a certificate. * @param id The id of the removal that was released. @@ -286,16 +278,12 @@ contract Removal is * @param removals The removals to mint (represented as an array of `DecodedRemovalIdV0`). These removals are used * to encode the removal IDs. * @param projectId The project ID for this batch of removals. - * @param scheduleStartTime The start time of the schedule for this batch of removals. - * @param holdbackPercentage The holdback percentage for this batch of removals. */ function mintBatch( address to, uint256[] calldata amounts, DecodedRemovalIdV0[] calldata removals, - uint256 projectId, - uint256 scheduleStartTime, - uint8 holdbackPercentage + uint256 projectId ) external onlyRole(CONSIGNOR_ROLE) { uint256[] memory ids = _createRemovals({ removals: removals, diff --git a/docs/Errors.md b/docs/Errors.md index 982e224d..f50677cb 100644 --- a/docs/Errors.md +++ b/docs/Errors.md @@ -316,17 +316,6 @@ Thrown when the caller specifies the zero address for the Nori fee wallet. -## InvalidHoldbackPercentage - -```solidity -error InvalidHoldbackPercentage(uint8 holdbackPercentage) -``` - -Thrown when a holdback percentage greater than 100 is submitted to `mintBatch`. - - - - ## InvalidPurchasingTokenDecimals ```solidity diff --git a/docs/Removal.md b/docs/Removal.md index fd281cf7..77e1be46 100644 --- a/docs/Removal.md +++ b/docs/Removal.md @@ -136,21 +136,6 @@ Emitted on updating the addresses for contracts. | certificate | contract ICertificate | The address of the new certificate contract. | -### SetHoldbackPercentage - -```solidity -event SetHoldbackPercentage(uint256 projectId, uint8 holdbackPercentage) -``` - -Emitted when the holdback percentage is updated for a project. - - -| Name | Type | Description | -| ---- | ---- | ----------- | -| projectId | uint256 | The ID of the project. | -| holdbackPercentage | uint8 | The new holdback percentage for the project. | - - ### ReleaseRemoval ```solidity @@ -254,7 +239,7 @@ Called as part of the market contract system deployment process. ### mintBatch ```solidity -function mintBatch(address to, uint256[] amounts, struct DecodedRemovalIdV0[] removals, uint256 projectId, uint256 scheduleStartTime, uint8 holdbackPercentage) external +function mintBatch(address to, uint256[] amounts, struct DecodedRemovalIdV0[] removals, uint256 projectId) external ``` Mints multiple removals at once (for a single supplier). @@ -273,8 +258,6 @@ Mints multiple removals at once (for a single supplier). | amounts | uint256[] | Each removal's tonnes of CO2 formatted. | | removals | struct DecodedRemovalIdV0[] | The removals to mint (represented as an array of `DecodedRemovalIdV0`). These removals are used to encode the removal IDs. | | projectId | uint256 | The project ID for this batch of removals. | -| scheduleStartTime | uint256 | The start time of the schedule for this batch of removals. | -| holdbackPercentage | uint8 | The holdback percentage for this batch of removals. | ### addBalance diff --git a/script/MintAndListRemovals.s.sol b/script/MintAndListRemovals.s.sol index b5f73160..53c7876a 100644 --- a/script/MintAndListRemovals.s.sol +++ b/script/MintAndListRemovals.s.sol @@ -37,9 +37,7 @@ contract MintAndListRemovals is Script { to: listInMarketNow ? _removal.getMarketAddress() : mockSupplierAddress, amounts: new uint256[](numberOfRemovalsToCreate).fill(100 ether), removals: removals, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); vm.stopBroadcast(); } diff --git a/tasks/migrate-removals.ts b/tasks/migrate-removals.ts index 72318467..d091846f 100644 --- a/tasks/migrate-removals.ts +++ b/tasks/migrate-removals.ts @@ -44,8 +44,6 @@ interface Project { amounts: number[]; removals: RemovalData[]; projectId: number; - scheduleStartTime: number; - holdbackPercentage: number; txReceipt?: TransactionReceipt; tokenIds?: string[]; error?: any; @@ -55,8 +53,6 @@ interface InputData { amounts: number[]; removals: RemovalData[]; projectId: number; - scheduleStartTime: number; - holdbackPercentage: number; } type Projects = Project[]; @@ -310,8 +306,6 @@ export const GET_MIGRATE_REMOVALS_TASK = () => amounts, removals, project.projectId, - project.scheduleStartTime, - project.holdbackPercentage, { gasPrice } ), TIMEOUT_DURATION @@ -324,9 +318,7 @@ export const GET_MIGRATE_REMOVALS_TASK = () => signerAddress, // mint to the consignor amounts, removals, - project.projectId, - project.scheduleStartTime, - project.holdbackPercentage + project.projectId ), TIMEOUT_DURATION ); diff --git a/test/Market.t.sol b/test/Market.t.sol index 3bbcfdd7..decf5b8a 100644 --- a/test/Market.t.sol +++ b/test/Market.t.sol @@ -1394,9 +1394,7 @@ contract Market_USDC_swap_respects_decimal_mismatch is UpgradeableUSDCMarket { address(_market), new uint256[](1).fill(2 ether), removals, - 1_234_567_890, - block.timestamp, - uint8(0) + 1_234_567_890 ); } diff --git a/test/MarketInvariants.t.sol b/test/MarketInvariants.t.sol index 0ec31fce..1a80dffa 100644 --- a/test/MarketInvariants.t.sol +++ b/test/MarketInvariants.t.sol @@ -58,8 +58,6 @@ contract MarketHandler is UpgradeableMarket { * - the supplier is chosen randomly from a predefined set of possible suppliers * - the amounts are chosen randomly between 0 and 1 ether- * - the projectId is between 1 and 1 billion - * - the scheduleStartTime is between 1 and intMax minus 10 years (avoid overflow when calculating end time for schedules) - * - the holdbackPercentage is between 0 and 100 * - other ID fields are hardcoded */ function mintRemovalBatchMinimizeReverts(uint256 fuzz) external { @@ -92,9 +90,7 @@ contract MarketHandler is UpgradeableMarket { to: supplierAddress, amounts: amounts, removals: removals, - projectId: (fuzz % 1_000_000_000) + 1, - scheduleStartTime: (fuzz % (type(uint256).max - 315_569_520)) + 1, - holdbackPercentage: uint8(fuzz % 100) + projectId: (fuzz % 1_000_000_000) + 1 }); } diff --git a/test/Removal.t.sol b/test/Removal.t.sol index df9c1275..0cf0ceb2 100644 --- a/test/Removal.t.sol +++ b/test/Removal.t.sol @@ -350,9 +350,7 @@ contract Removal_mintBatch_list_sequential is UpgradeableMarket { to: address(_market), amounts: new uint256[](1).fill(1 ether), removals: ids, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); } } @@ -375,9 +373,7 @@ contract Removal_mintBatch_reverts_mint_to_wrong_address is UpgradeableMarket { to: _namedAccounts.supplier2, // not the supplier encoded in the removal ID amounts: new uint256[](1).fill(1 ether), removals: ids, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); } } @@ -399,9 +395,7 @@ contract Removal_mintBatch_zero_amount_removal is UpgradeableMarket { to: _namedAccounts.supplier, amounts: new uint256[](1).fill(0 ether), removals: ids, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); } } @@ -426,9 +420,7 @@ contract Removal_mintBatch_zero_amount_removal_to_market_reverts is to: address(_market), amounts: new uint256[](1).fill(0 ether), removals: ids, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); } } @@ -574,9 +566,7 @@ contract Removal_release_listed_isRemovedFromMarket is UpgradeableMarket { to: _marketAddress, amounts: _asSingletonUintArray(_REMOVAL_AMOUNT), removals: _REMOVAL_FIXTURES, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); assertEq( _removal.balanceOf(_namedAccounts.supplier, REMOVAL_ID_FIXTURE), @@ -770,9 +760,7 @@ contract Removal_release_retired_oneHundredCertificates is UpgradeableMarket { to: address(_market), amounts: new uint256[](1).fill(100 ether), removals: _REMOVAL_FIXTURES, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); uint256 ownerPrivateKey = 0xA11CE; // todo use named accounts address owner = vm.addr(ownerPrivateKey); // todo checkout helper function that accepts pk @@ -831,9 +819,7 @@ contract Removal_release_listed is UpgradeableMarket { to: _marketAddress, amounts: _asSingletonUintArray(_REMOVAL_AMOUNT), removals: _REMOVAL_FIXTURES, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 }); assertEq( _removal.balanceOf(_namedAccounts.supplier, REMOVAL_ID_FIXTURE), diff --git a/test/Removal.test.ts b/test/Removal.test.ts index 7b957a2b..08dfceb7 100644 --- a/test/Removal.test.ts +++ b/test/Removal.test.ts @@ -57,14 +57,7 @@ describe('Removal', () => { hre, }); await expect( - removal.mintBatch( - supplier, - removalBalances, - tokenIds, - data.projectId, - data.scheduleStartTime, - data.holdbackPercentage - ) + removal.mintBatch(supplier, removalBalances, tokenIds, data.projectId) ) .to.emit(removal, 'TransferBatch') .withArgs( @@ -95,7 +88,7 @@ describe('Removal', () => { formatTokenAmount(balance) ); const expectedMarketSupply = sum(removalBalances); - const { supplier, admin } = hre.namedAccounts; + const { admin } = hre.namedAccounts; const defaultStartingVintage = 2016; const tokenIds = await Promise.all( removalBalances.map((_, index) => { @@ -113,9 +106,7 @@ describe('Removal', () => { market.address, removalBalances, tokenIds, - data.projectId, - data.scheduleStartTime, - data.holdbackPercentage + data.projectId ) ) .to.emit(removal, 'TransferBatch') @@ -163,9 +154,7 @@ describe('Removal', () => { namedAccounts.supplier, removalBalances, removals, - data.projectId, - data.scheduleStartTime, - data.holdbackPercentage + data.projectId ) ) .to.emit(removal, 'TransferBatch') diff --git a/test/checkout.int.t.sol b/test/checkout.int.t.sol index 25042814..c662dd9f 100644 --- a/test/checkout.int.t.sol +++ b/test/checkout.int.t.sol @@ -709,8 +709,7 @@ contract Checkout_buyingWithAlternateERC20 is Checkout { _removalIds = _seedRemovals({ to: _namedAccounts.supplier, count: 1, - list: true, - holdbackPercentage: 0 + list: true }); _market.grantRole(_market.SWAP_ALLOWLIST_ROLE(), _owner); } @@ -820,8 +819,7 @@ contract Checkout_buyingWithAlternateERC20_floatingPointPriceMultiple is _removalIds = _seedRemovals({ to: _namedAccounts.supplier, count: 1, - list: true, - holdbackPercentage: 0 + list: true }); assertEq(_removal.getMarketBalance(), 1 ether); assertEq(_removal.numberOfTokensOwnedByAddress(address(_market)), 1); diff --git a/test/helpers/index.ts b/test/helpers/index.ts index 9916f13d..736ab8c2 100644 --- a/test/helpers/index.ts +++ b/test/helpers/index.ts @@ -105,25 +105,14 @@ type TestEnvironment = export const createBatchMintData = async ({ hre, projectId = 1_234_567_890, - scheduleStartTime, - holdbackPercentage = Zero, }: { hre: CustomHardHatRuntimeEnvironment; projectId?: number; - scheduleStartTime?: number; - holdbackPercentage?: BigNumber; }): Promise<{ projectId: Parameters[3]; - scheduleStartTime: Parameters[4]; - holdbackPercentage: Parameters[5]; }> => { - const actualScheduleStartTime = BigNumber.from( - scheduleStartTime ?? (await getLatestBlockTime({ hre })) - ); return { projectId: BigNumber.from(projectId), - scheduleStartTime: actualScheduleStartTime, - holdbackPercentage, }; }; @@ -135,22 +124,16 @@ interface RemovalDataFromListing { totalAmountOfRemovals: number; removalAmounts: BigNumber[]; projectId: number; - scheduleStartTime: number; - holdbackPercentage: BigNumber; } // todo helpers/removal.ts export interface RemovalDataForListing { projectId?: number; - scheduleStartTime?: number; - holdbackPercentage?: BigNumber; listNow?: boolean; removals: (Partial & { tokenId?: BigNumber; amount: BigNumber; projectId?: number; - scheduleStartTime?: number; - holdbackPercentage?: number; })[]; } @@ -177,13 +160,8 @@ export const batchMintAndListRemovalsForSale = async (options: { removalDataToList: RemovalDataForListing; }): Promise => { const { removal, hre, removalDataToList, market } = options; - const { projectId, scheduleStartTime, holdbackPercentage } = { - projectId: removalDataToList.projectId ?? 1_234_567_890, - scheduleStartTime: - removalDataToList.scheduleStartTime ?? - (await getLatestBlockTime({ hre })), - holdbackPercentage: removalDataToList.holdbackPercentage ?? Zero, - }; + const projectId = removalDataToList.projectId ?? 1_234_567_890; + const { supplier } = hre.namedAccounts; const defaultStartingVintage = 2016; const removals: DecodedRemovalIdV0Struct[] = []; @@ -205,9 +183,7 @@ export const batchMintAndListRemovalsForSale = async (options: { : market.address, removalAmounts, removals, - projectId, - scheduleStartTime, - holdbackPercentage + projectId ); const totalAmountOfSupply = sum(removalAmounts); const totalAmountOfSuppliers = getTotalAmountOfSuppliers(removalDataToList); @@ -219,8 +195,6 @@ export const batchMintAndListRemovalsForSale = async (options: { totalAmountOfRemovals, removalAmounts, projectId, - scheduleStartTime, - holdbackPercentage, }; }; @@ -229,7 +203,7 @@ export const setupTest = global.hre.deployments.createFixture( async ( hre: CustomHardHatRuntimeEnvironment, options?: SetupTestOptions - ): Promise> => { + ): Promise => { const userFixtures: UserFixtures = { ...options?.userFixtures, buyer: { @@ -266,8 +240,6 @@ export const setupTest = global.hre.deployments.createFixture( let totalAmountOfSuppliers = 0; let totalAmountOfRemovals = 0; let projectId = 0; - let scheduleStartTime = 0; - let holdbackPercentage = Zero; let removalAmounts: BigNumber[] = []; for (const [k, v] of Object.entries(userFixtures) as [ keyof typeof namedAccounts, @@ -307,8 +279,6 @@ export const setupTest = global.hre.deployments.createFixture( totalAmountOfRemovals = mintResultData.totalAmountOfRemovals + totalAmountOfRemovals; projectId = mintResultData.projectId; // todo allow multiple schedules/projects/percentages per fixture - scheduleStartTime = mintResultData.scheduleStartTime; // todo allow multiple schedules/projects/percentages per fixture - holdbackPercentage = mintResultData.holdbackPercentage; // todo allow multiple schedules/projects/percentages per fixture } if (v.bpBalance !== undefined) { // eslint-disable-next-line no-await-in-loop -- these need to run serially @@ -350,9 +320,7 @@ export const setupTest = global.hre.deployments.createFixture( totalAmountOfSuppliers, totalAmountOfRemovals, projectId, - scheduleStartTime, - holdbackPercentage, removalAmounts, - } as TestEnvironment; + } as TestEnvironment; } ); diff --git a/test/helpers/removal.sol b/test/helpers/removal.sol index 9aa83aea..f0390753 100644 --- a/test/helpers/removal.sol +++ b/test/helpers/removal.sol @@ -107,42 +107,7 @@ abstract contract UpgradeableRemoval is Upgradeable { to: list ? _marketAddress : to, amounts: new uint256[](count).fill(1 ether), removals: removals, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 - }); - return _removalIds; - } - - function _seedRemovals( - address to, - uint32 count, - bool list, - uint8 holdbackPercentage - ) internal returns (uint256[] memory) { - uint256[] memory _removalIds = new uint256[](count); - DecodedRemovalIdV0[] memory removals = new DecodedRemovalIdV0[](count); - for (uint32 i = 0; i < count; i++) { - DecodedRemovalIdV0 memory removalData = DecodedRemovalIdV0({ - idVersion: 0, - methodology: 1, - methodologyVersion: 0, - vintage: 2018, - country: "AA", - subdivision: "ZZ", - supplierAddress: to, - subIdentifier: count + i - }); - removals[i] = removalData; - _removalIds[i] = RemovalIdLib.createRemovalId(removalData); - } - _removal.mintBatch({ - to: list ? _marketAddress : to, - amounts: new uint256[](count).fill(1 ether), - removals: removals, - projectId: 1_234_567_890, - scheduleStartTime: block.timestamp, - holdbackPercentage: holdbackPercentage + projectId: 1_234_567_890 }); return _removalIds; } @@ -172,9 +137,7 @@ abstract contract UpgradeableRemoval is Upgradeable { list ? _marketAddress : to, new uint256[](count).fill(1 ether), _removals, - 1_234_567_890, - block.timestamp, - 50 + 1_234_567_890 ); return _removalIds; } @@ -204,9 +167,7 @@ abstract contract UpgradeableRemoval is Upgradeable { consignor, new uint256[](count).fill(1 ether), _removals, - 1_234_567_890, - block.timestamp, - 50 + 1_234_567_890 ); return _removalIds; } @@ -234,9 +195,7 @@ abstract contract UpgradeableRemoval is Upgradeable { mintTo, new uint256[](1).fill(removalAmount), _removals, - 1_234_567_890, - block.timestamp, - 50 + 1_234_567_890 ); return _removalIds; } @@ -263,9 +222,7 @@ abstract contract UpgradeableRemoval is Upgradeable { to: _marketAddress, // list on market amounts: new uint256[](1).fill(amount), removals: removalsData, - projectId: 1_234_567_890, // projectId - scheduleStartTime: block.timestamp, - holdbackPercentage: 50 + projectId: 1_234_567_890 // projectId }); return removalId; } @@ -313,9 +270,7 @@ contract NonUpgradeableRemoval is Removal, Global { list ? address(_market) : to, new uint256[](count).fill(1 ether), _removals, - 1_234_567_890, - block.timestamp, - 50 + 1_234_567_890 ); return _removalIds; } diff --git a/types/events/Removal.ts b/types/events/Removal.ts index cac2ed50..9c0e9a21 100644 --- a/types/events/Removal.ts +++ b/types/events/Removal.ts @@ -11,7 +11,6 @@ import type { RoleAdminChangedEvent, RoleGrantedEvent, RoleRevokedEvent, - SetHoldbackPercentageEvent, TransferBatchEvent, TransferSingleEvent, URIEvent, @@ -62,10 +61,6 @@ export interface RemovalEventMap { name: 'RoleRevoked'; args: RoleRevokedEvent['args']; }; - SetHoldbackPercentage: { - name: 'SetHoldbackPercentage'; - args: SetHoldbackPercentageEvent['args']; - }; TransferBatch: { name: 'TransferBatch'; /**