Skip to content

Commit

Permalink
snapshot, docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
amiecorso committed Mar 7, 2024
1 parent 3d7045b commit e0fd1f7
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 85 deletions.
155 changes: 78 additions & 77 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -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: 470204)
Checkout_buyingFromOneRemoval_byApproval:test() (gas: 408595)
Checkout_buyingFromTenRemovals:test() (gas: 1549249)
Checkout_buyingFromTenRemovals_singleSupplier:test() (gas: 1309159)
Checkout_buyingFromTenRemovals_singleSupplier_withoutFee:test() (gas: 1304359)
Checkout_buyingFromTenRemovals_withoutFee:test() (gas: 1317066)
Checkout_buyingFromTenSuppliers:test() (gas: 1818088)
Checkout_buyingWithAlternateERC20:test() (gas: 540766)
Checkout_buyingWithAlternateERC20_floatingPointPriceMultiple:test() (gas: 506820)
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: 380553)
Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test() (gas: 375252)
Checkout_swapWithoutFeeSpecialOrder:test() (gas: 380653)
Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test() (gas: 375352)
Checkout_swapWithoutFeeSpecialOrder_specificSupplier:test_revertsWhenSupplierDoesNotExistInMarket() (gas: 57753)
Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_basicFulfillment() (gas: 642401)
Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_basicFulfillment() (gas: 642523)
Checkout_swapWithoutFeeSpecialOrder_specificVintages:test_revertsWhenNoRemovalsFromSpecifiedVintages() (gas: 91022)
Checkout_swapWithoutFeeSpecialOrder_specificVintagesSpecificSupplier:test_basicFulfillment() (gas: 491863)
GasBenchmark_buyingFromManyRemovals_singleSupplier:test() (gas: 29847653)
GasBenchmark_buyingFromOneRemoval_singleSupplier:test() (gas: 322867)
Checkout_swapWithoutFeeSpecialOrder_specificVintagesSpecificSupplier:test_basicFulfillment() (gas: 491974)
GasBenchmark_buyingFromManyRemovals_singleSupplier:test() (gas: 29850540)
GasBenchmark_buyingFromOneRemoval_singleSupplier:test() (gas: 322967)
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: 4271)
MarketInvariantTest:invariant_sumOfPurchaseAmounts() (runs: 400, calls: 6000, reverts: 4262)
MarketSupplierSelectionNotUsingUpSuppliersLastRemoval:test() (gas: 644568)
MarketInvariantTest:invariant_callSummary() (runs: 400, calls: 6000, reverts: 4258)
MarketInvariantTest:invariant_sumOfPurchaseAmounts() (runs: 400, calls: 6000, reverts: 4265)
MarketSupplierSelectionNotUsingUpSuppliersLastRemoval:test() (gas: 644679)
Market_ALLOWLIST_ROLE:test() (gas: 12799)
Market_SANCTION_ALLOWLIST_ROLE:test() (gas: 12897)
Market_USDC_swap_respects_decimal_mismatch:test() (gas: 786872)
Market_USDC_swap_respects_decimal_mismatch:test() (gas: 786972)
Market__addActiveRemoval:test() (gas: 183344)
Market__addActiveRemoval:test__lis2VintagesFor1SupplierFor2SubIdentifiers() (gas: 242879)
Market__addActiveRemoval:test__list1VintageFor1Supplier() (gas: 188309)
Expand All @@ -74,45 +74,45 @@ 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: 448037)
Market_getActiveSuppliers:test_3_suppliers() (gas: 1089557)
Market_getActiveSuppliers:test_1_supplier() (gas: 448048)
Market_getActiveSuppliers:test_3_suppliers() (gas: 1089590)
Market_getActiveSuppliers:test_no_suppliers() (gas: 20859)
Market_getPriceMultiple:test() (gas: 14851)
Market_getRemovalIdsForSupplier:test_1_removal() (gas: 448440)
Market_getRemovalIdsForSupplier:test_3_removals() (gas: 831873)
Market_getRemovalIdsForSupplier:test_3_removals_different_vintages() (gas: 877982)
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_no_removals() (gas: 26044)
Market_onERC1155BatchReceived:test() (gas: 208124)
Market_onERC1155BatchReceived_reverts_SenderNotRemovalContract:test() (gas: 331734)
Market_onERC1155BatchReceived_reverts_SenderNotRemovalContract:test() (gas: 331712)
Market_onERC1155Received:test() (gas: 206036)
Market_onERC1155Received_reverts_SenderNotRemovalContract:test() (gas: 159022)
Market_purchasingTokenAddress:test() (gas: 17080)
Market_replace:test() (gas: 277947)
Market_replace:test() (gas: 278047)
Market_replace_reverts_CertificateNotYetMinted:test() (gas: 49559)
Market_replace_reverts_ReplacementAmountExceedsNrtDeficit:test() (gas: 52590)
Market_replace_reverts_ReplacementAmountMismatch:test() (gas: 86353)
Market_setNoriFeePercentage_revertsInvalidPercentage:test() (gas: 20276)
Market_setPriorityRestrictedThreshold:test() (gas: 157404)
Market_setPriorityRestrictedThreshold:test_zeroAvailable() (gas: 152379)
Market_setPriorityRestrictedThreshold:test() (gas: 157360)
Market_setPriorityRestrictedThreshold:test_zeroAvailable() (gas: 152335)
Market_setPurchasingTokenAndPriceMultiple:test() (gas: 1026610)
Market_setPurchasingTokenAndPriceMultiple_revertsIfNotAdmin:test() (gas: 50813)
Market_supplierSelectionUsingUpSuppliersLastRemoval:test() (gas: 641277)
Market_supplierSelectionUsingUpSuppliersLastRemoval:test() (gas: 641388)
Market_swap_revertsWhenUnsafeERC20TransferFails:test() (gas: 189604)
Market_validates_certificate_amount:test() (gas: 596800)
Market_withdraw_1x3_center:test() (gas: 340770)
Market_withdraw_2x1_back:test() (gas: 345430)
Market_withdraw_2x1_front:test() (gas: 333787)
Market_withdraw_2x1_front_relist:test() (gas: 381722)
Market_withdraw_as_DEFAULT_ADMIN_ROLE:test() (gas: 276480)
Market_withdraw_as_operator:test() (gas: 285625)
Market_withdraw_as_supplier:test() (gas: 274621)
Market_withdraw_reverts:test() (gas: 138665)
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)
NORI_name:test() (gas: 17205)
NORI_permit:test() (gas: 92382)
NoriUSDC_permit:test() (gas: 122061)
RemovalQueue_getTotalBalanceFromRemovalQueue:test() (gas: 23921)
RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheDifferentVintages() (gas: 895808)
RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheSameVintage() (gas: 620321)
RemovalQueue_getTotalBalanceFromRemovalQueue:test() (gas: 23899)
RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheDifferentVintages() (gas: 895786)
RemovalQueue_getTotalBalanceFromRemovalQueue:test_100xRemovalsOfTheSameVintage() (gas: 620299)
RemovalQueue_insertRemovalByVintage:test_insertRemovalOnce() (gas: 119613)
RemovalQueue_insertRemovalByVintage:test_insertRemovalTwice() (gas: 121103)
Removal__beforeTokenTransfer:test() (gas: 18010)
Expand All @@ -122,56 +122,57 @@ 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, μ: 14394, ~: 14519)
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: 4705)
Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheCertificate() (gas: 4683)
Removal__isValidTransferAmount:test_ReturnFalse_AmountIsZeroAndToIsTheMarket() (gas: 2543)
Removal__isValidTransferAmount:test_ReturnTrue_AmountIsZeroAndToIsNeitherTheMarketNorCertificate() (gas: 6852)
Removal__validateRemoval:test() (gas: 2491)
Removal__validateRemoval:test_reverts_InvalidData() (gas: 5351)
Removal_addBalance:test() (gas: 60280)
Removal_addBalance_reverts_RemovalNotYetMinted:test() (gas: 31115)
Removal_consign_revertsForSoldRemovals:test() (gas: 896663)
Removal_addBalance:test() (gas: 60269)
Removal_addBalance_reverts_RemovalNotYetMinted:test() (gas: 31093)
Removal_consign_revertsForSoldRemovals:test() (gas: 896760)
Removal_consignorBatchTransfer:test() (gas: 297347)
Removal_consignorBatchTransfer:test_reverts_whenReceiverIsNotConsignor() (gas: 128813)
Removal_consignorBatchTransfer:test_reverts_whenReceiverIsNotConsignor() (gas: 128791)
Removal_consignorBatchTransfer:test_reverts_whenSenderIsNotConsignor() (gas: 65690)
Removal_getMarketBalance:test() (gas: 907087)
Removal_getOwnedTokenIds:test_multiple_tokens_with_transfer() (gas: 916570)
Removal_getOwnedTokenIds:test_no_tokens() (gas: 18683)
Removal_getProjectId:test() (gas: 19307)
Removal_grantRole:test_reverts_when_paused() (gas: 26272)
Removal_migrate:test() (gas: 989116)
Removal_migrate_gasLimit:test() (gas: 15359829)
Removal_migrate_revertsIfRemovalBalanceSumDifferentFromCertificateAmount:test() (gas: 1002846)
Removal_mintBatch:test() (gas: 177535)
Removal_mintBatch_list:test() (gas: 395805)
Removal_mintBatch_list_sequential:test() (gas: 581611)
Removal_mintBatch_multiple:test_16() (gas: 2921425)
Removal_mintBatch_multiple:test_2() (gas: 564132)
Removal_mintBatch_multiple:test_32() (gas: 5616582)
Removal_mintBatch_multiple:test_4() (gas: 900849)
Removal_mintBatch_multiple:test_8() (gas: 1574288)
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: 140109)
Removal_mintBatch_zero_amount_removal:test() (gas: 140120)
Removal_mintBatch_zero_amount_removal_to_market_reverts:test() (gas: 61802)
Removal_multicall:test_balanceOfBatch() (gas: 320932)
Removal_release_listed:test() (gas: 356802)
Removal_release_listed_isRemovedFromMarket:test() (gas: 357156)
Removal_release_partial_listed:test() (gas: 79593)
Removal_release_retired:test() (gas: 92425)
Removal_release_retired_2x:test() (gas: 98489)
Removal_release_retired_burned:test() (gas: 94905)
Removal_release_retired_burned:testDecrementsCertificateDiscrepancy() (gas: 88881)
Removal_release_retired_oneHundredCertificates:test() (gas: 89535)
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: 19688)
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_revokeRole:test_reverts_when_paused() (gas: 26818)
Removal_safeBatchTransferFrom:test_reverts_ForbiddenTransfer() (gas: 32007)
Removal_safeBatchTransferFrom_reverts_ForbiddenTransfer:test() (gas: 32162)
Removal_safeTransferFrom_reverts_ForbiddenTransfer:test() (gas: 27716)
UInt256ArrayLib_fill:test() (gas: 120236)
UInt256ArrayLib_fill:test_gas() (gas: 101580)
UInt256ArrayLib_fill:test_library() (gas: 11821)
Expand Down
33 changes: 25 additions & 8 deletions docs/Removal.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ Emitted when legacy removals are minted and then immediately used to migrate a l
| removalAmounts | uint256[] | The amounts for each corresponding removal ID to use to mint the certificate via migration. |


### Retire

```solidity
event Retire(address certificateRecipient, uint256 certificateAmount, uint256 certificateId, uint256[] removalIds, uint256[] removalAmounts)
```

Emitted when removals are directly retired into a certificate by Nori.


| Name | Type | Description |
| ---- | ---- | ----------- |
| certificateRecipient | address | The recipient of the certificate. |
| certificateAmount | uint256 | The total amount of the certificate to mint (denominated in RTs). |
| certificateId | uint256 | The ID of the certificate being minted. |
| removalIds | uint256[] | The removal IDs to use to mint the certificate. |
| removalAmounts | uint256[] | The amounts to retire from each corresponding removal ID. |


### constructor

```solidity
Expand Down Expand Up @@ -300,27 +318,26 @@ this contract, and handles the mechanics of listing this token for sale.</i>
| amount | uint256 | The balance of this token ID to transfer to the Market contract |


### migrate
### retire

```solidity
function migrate(uint256[] ids, uint256[] amounts, address certificateRecipient, uint256 certificateAmount) external
function retire(uint256[] ids, uint256[] amounts, address certificateRecipient, uint256 certificateAmount) external
```

Transfers the provided `amounts` (denominated in NRTs) of the specified removal `ids` directly to the
Certificate contract to mint a legacy certificate. This function provides Nori the ability to execute a one-off
migration of legacy certificates and removals (legacy certificates and removals are those which existed prior to
our deployment to Polygon and covers all historic issuances and purchases up until the date that we start using the
Market contract).
Certificate contract to mint a certificate. This function provides Nori the ability to retire removals directly
into the Certificate contract and to specify exactly which removals will be retired.

<i>The Certificate contract implements `onERC1155BatchReceived`, which is invoked upon receipt of a batch of
removals (triggered via `_safeBatchTransferFrom`). This function circumvents the market contract's lifecycle by
removals (triggered via `_safeBatchTransferFrom`). This function circumvents the market contract by
transferring the removals from an account with the `CONSIGNOR_ROLE` role.
Emits a `Retire` event.

It is necessary that the consignor holds the removals because of the following:
- `ids` can be composed of a list of removal IDs that belong to one or more suppliers.
- `_safeBatchTransferFrom` only accepts one `from` address.
- `Certificate.onERC1155BatchReceived` will mint a *new* certificate every time an additional batch is received, so
we must ensure that all the removals comprising the certificate to be migrated come from a single batch.
we must ensure that all the removals comprising the certificate come from a single batch.

##### Requirements:
- The caller must have the `CONSIGNOR_ROLE` role.
Expand Down

0 comments on commit e0fd1f7

Please sign in to comment.