Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Unilateral netting of offsetting positions of same Option Type #219

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 56 additions & 59 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,85 +1,82 @@
ValoremOptionsClearinghouseFuzzTest:test_fuzzExercise(uint112,uint112) (runs: 256, μ: 363675, ~: 366353)
ValoremOptionsClearinghouseFuzzTest:test_fuzzNewOptionType(uint96,uint96,uint40,uint40) (runs: 256, μ: 130922, ~: 130922)
ValoremOptionsClearinghouseFuzzTest:test_fuzzWrite(uint112) (runs: 256, μ: 284216, ~: 284216)
ValoremOptionsClearinghouseFuzzTest:test_fuzzWriteExerciseRedeem(uint32) (runs: 256, μ: 9524189, ~: 9614090)
ValoremOptionsClearinghouseIntegrationTest:test_integrationAddOptionsToExistingClaim() (gas: 400435)
ValoremOptionsClearinghouseIntegrationTest:test_integrationDustHandling() (gas: 920361)
ValoremOptionsClearinghouseFuzzTest:test_fuzzExercise(uint112,uint112) (runs: 256, μ: 363186, ~: 366311)
ValoremOptionsClearinghouseFuzzTest:test_fuzzNewOptionType(uint96,uint96,uint40,uint40) (runs: 256, μ: 130900, ~: 130900)
ValoremOptionsClearinghouseFuzzTest:test_fuzzWrite(uint112) (runs: 256, μ: 284218, ~: 284218)
ValoremOptionsClearinghouseFuzzTest:test_fuzzWriteExerciseRedeem(uint32) (runs: 256, μ: 9537440, ~: 9615628)
ValoremOptionsClearinghouseIntegrationTest:test_integrationAddOptionsToExistingClaim() (gas: 400573)
ValoremOptionsClearinghouseIntegrationTest:test_integrationDustHandling() (gas: 920297)
ValoremOptionsClearinghouseIntegrationTest:test_integrationFairAssignment() (gas: 603589)
ValoremOptionsClearinghouseIntegrationTest:test_integrationRandomAssignment() (gas: 906223)
ValoremOptionsClearinghouseIntegrationTest:test_integrationSweepFeesWhenFeesAccruedForExercise() (gas: 1418985)
ValoremOptionsClearinghouseIntegrationTest:test_integrationSweepFeesWhenFeesAccruedForWrite() (gas: 1343568)
ValoremOptionsClearinghouseIntegrationTest:test_integrationRandomAssignment() (gas: 906201)
ValoremOptionsClearinghouseIntegrationTest:test_integrationSweepFeesWhenFeesAccruedForExercise() (gas: 1418790)
ValoremOptionsClearinghouseIntegrationTest:test_integrationSweepFeesWhenFeesAccruedForWrite() (gas: 1343354)
ValoremOptionsClearinghouseIntegrationTest:test_integrationWriteExerciseAddBuckets() (gas: 1062312)
ValoremOptionsClearinghouseInvariantTest:invariant_erc20_balances() (runs: 10, calls: 10000, reverts: 5019)
ValoremOptionsClearinghouseInvariantTest:invariant_options_written_match_claims() (runs: 10, calls: 10000, reverts: 4965)
ValoremOptionsClearinghouseInvariantTest:invariant_positions_accounting() (runs: 10, calls: 10000, reverts: 4922)
ValoremOptionsClearinghouseUnitTest:testRevert_acceptFeeTo_whenNotPendingFeeTo() (gas: 35301)
ValoremOptionsClearinghouseUnitTest:testRevert_claim_whenClaimDoesNotExist() (gas: 14648)
ValoremOptionsClearinghouseUnitTest:testRevert_construction_whenFeeToIsZeroAddress() (gas: 2055329)
ValoremOptionsClearinghouseUnitTest:testRevert_construction_whenTokenURIGeneratorIsZeroAddress() (gas: 39989)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenCallerHasNotGrantedSufficientApprovalToEngine() (gas: 584824)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenCallerHoldsInsufficientExerciseAsset() (gas: 582959)
ValoremOptionsClearinghouseUnitTest:testRevert_construction_whenFeeToIsZeroAddress() (gas: 2055447)
ValoremOptionsClearinghouseUnitTest:testRevert_construction_whenTokenURIGeneratorIsZeroAddress() (gas: 40107)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenCallerHasNotGrantedSufficientApprovalToEngine() (gas: 584781)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenCallerHoldsInsufficientExerciseAsset() (gas: 582916)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenCallerHoldsInsufficientOptions() (gas: 264635)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenExerciseTooEarly() (gas: 268095)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenExpiredOption() (gas: 267890)
ValoremOptionsClearinghouseUnitTest:testRevert_exercise_whenInvalidOption() (gas: 254368)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenExerciseWindowTooShort() (gas: 23356)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenExpiryWindowTooShort() (gas: 24821)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenInvalidAssets() (gas: 21454)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenOptionsTypeExists() (gas: 26485)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenTotalSuppliesAreTooLowToExercise() (gas: 45213)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenExerciseWindowTooShort() (gas: 23334)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenExpiryWindowTooShort() (gas: 24799)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenInvalidAssets() (gas: 21432)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenOptionsTypeExists() (gas: 26463)
ValoremOptionsClearinghouseUnitTest:testRevert_newOptionType_whenTotalSuppliesAreTooLowToExercise() (gas: 45169)
ValoremOptionsClearinghouseUnitTest:testRevert_option_whenOptionDoesNotExist() (gas: 13355)
ValoremOptionsClearinghouseUnitTest:testRevert_position_whenExpiredOption() (gas: 20053)
ValoremOptionsClearinghouseUnitTest:testRevert_position_whenTokenNotFound() (gas: 12705)
ValoremOptionsClearinghouseUnitTest:testRevert_redeem_whenCallerDoesNotOwnClaimId() (gas: 249313)
ValoremOptionsClearinghouseUnitTest:testRevert_redeem_whenInvalidClaim() (gas: 9520)
ValoremOptionsClearinghouseUnitTest:testRevert_redeem_whenCallerDoesNotOwnClaimId() (gas: 249243)
ValoremOptionsClearinghouseUnitTest:testRevert_redeem_whenInvalidClaim() (gas: 9498)
ValoremOptionsClearinghouseUnitTest:testRevert_setFeeTo_whenNotCurrentFeeTo() (gas: 11919)
ValoremOptionsClearinghouseUnitTest:testRevert_setFeeTo_whenZeroAddress() (gas: 11641)
ValoremOptionsClearinghouseUnitTest:testRevert_setFeesEnabled_whenNotFeeTo() (gas: 11821)
ValoremOptionsClearinghouseUnitTest:testRevert_setTokenURIGenerator_whenNotCurrentFeeTo() (gas: 11889)
ValoremOptionsClearinghouseUnitTest:testRevert_setTokenURIGenerator_whenZeroAddress() (gas: 11609)
ValoremOptionsClearinghouseUnitTest:testRevert_sweepFees_whenNotFeeTo() (gas: 16927)
ValoremOptionsClearinghouseUnitTest:testRevert_uri_whenTokenNotFound() (gas: 20262)
ValoremOptionsClearinghouseUnitTest:testRevert_setFeesEnabled_whenNotFeeTo() (gas: 11866)
ValoremOptionsClearinghouseUnitTest:testRevert_setTokenURIGenerator_whenNotCurrentFeeTo() (gas: 11845)
ValoremOptionsClearinghouseUnitTest:testRevert_setTokenURIGenerator_whenZeroAddress() (gas: 11565)
ValoremOptionsClearinghouseUnitTest:testRevert_sweepFees_whenNotFeeTo() (gas: 16905)
ValoremOptionsClearinghouseUnitTest:testRevert_uri_whenTokenNotFound() (gas: 20218)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenAmountWrittenCannotBeZero() (gas: 10676)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenCallerDoesNotOwnClaimId() (gas: 261803)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenCallerHasNotGrantedSufficientApprovalToengine() (gas: 687624)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenCallerHoldsInsufficientExerciseAsset() (gas: 687659)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenCallerHasNotGrantedSufficientApprovalToengine() (gas: 687604)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenCallerHoldsInsufficientExerciseAsset() (gas: 687639)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenExpiredOption() (gas: 16957)
ValoremOptionsClearinghouseUnitTest:testRevert_write_whenInvalidOption() (gas: 13626)
ValoremOptionsClearinghouseUnitTest:test_claim_whenWrittenMultiple() (gas: 387402)
ValoremOptionsClearinghouseUnitTest:test_claim_whenWrittenMultiple() (gas: 387384)
ValoremOptionsClearinghouseUnitTest:test_claim_whenWrittenMultipleTimesOnMultipleClaims() (gas: 458225)
ValoremOptionsClearinghouseUnitTest:test_claim_whenWrittenOnce() (gas: 306556)
ValoremOptionsClearinghouseUnitTest:test_exercise() (gas: 383968)
ValoremOptionsClearinghouseUnitTest:test_exercise_whenExercisingMultipleTimes() (gas: 425505)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenFeeOff() (gas: 267101)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenFeeOn() (gas: 323819)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenMinimum() (gas: 401565)
ValoremOptionsClearinghouseUnitTest:test_feeBps() (gas: 5644)
ValoremOptionsClearinghouseUnitTest:test_feeTo() (gas: 7737)
ValoremOptionsClearinghouseUnitTest:test_feesEnabled() (gas: 7684)
ValoremOptionsClearinghouseUnitTest:test_newOptionType() (gas: 130083)
ValoremOptionsClearinghouseUnitTest:test_claim_whenWrittenOnce() (gas: 306539)
ValoremOptionsClearinghouseUnitTest:test_exercise() (gas: 383884)
ValoremOptionsClearinghouseUnitTest:test_exercise_whenExercisingMultipleTimes() (gas: 425331)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenFeeOff() (gas: 267067)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenFeeOn() (gas: 323643)
ValoremOptionsClearinghouseUnitTest:test_feeBalance_whenMinimum() (gas: 401499)
ValoremOptionsClearinghouseUnitTest:test_feeBps() (gas: 5600)
ValoremOptionsClearinghouseUnitTest:test_feeTo() (gas: 7760)
ValoremOptionsClearinghouseUnitTest:test_feesEnabled() (gas: 7729)
ValoremOptionsClearinghouseUnitTest:test_newOptionType() (gas: 130061)
ValoremOptionsClearinghouseUnitTest:test_option_returnsOptionInfo() (gas: 25672)
ValoremOptionsClearinghouseUnitTest:test_position_whenFullyExercisedClaim() (gas: 302781)
ValoremOptionsClearinghouseUnitTest:test_position_whenOption() (gas: 31743)
ValoremOptionsClearinghouseUnitTest:test_position_whenPartiallyExercisedClaim() (gas: 427858)
ValoremOptionsClearinghouseUnitTest:test_position_whenUnexercisedClaim() (gas: 263939)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenFullyAssigned() (gas: 335329)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenPartiallyAssigned() (gas: 346683)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenUnassigned() (gas: 238600)
ValoremOptionsClearinghouseUnitTest:test_setFeeToAndAcceptFeeTo() (gas: 29546)
ValoremOptionsClearinghouseUnitTest:test_setFeeToAndAcceptFeeTo_multipleTimes() (gas: 50411)
ValoremOptionsClearinghouseUnitTest:test_setFeesEnabled() (gas: 20581)
ValoremOptionsClearinghouseUnitTest:test_setTokenURIGenerator() (gas: 2035989)
ValoremOptionsClearinghouseUnitTest:test_sweepFees() (gas: 376859)
ValoremOptionsClearinghouseUnitTest:test_sweepFees_whenNoFees() (gas: 53259)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenFullyAssigned() (gas: 335352)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenPartiallyAssigned() (gas: 346711)
ValoremOptionsClearinghouseUnitTest:test_redeem_whenUnassigned() (gas: 238626)
ValoremOptionsClearinghouseUnitTest:test_setFeeToAndAcceptFeeTo() (gas: 29583)
ValoremOptionsClearinghouseUnitTest:test_setFeeToAndAcceptFeeTo_multipleTimes() (gas: 50448)
ValoremOptionsClearinghouseUnitTest:test_setFeesEnabled() (gas: 20761)
ValoremOptionsClearinghouseUnitTest:test_setTokenURIGenerator() (gas: 2035967)
ValoremOptionsClearinghouseUnitTest:test_sweepFees() (gas: 376661)
ValoremOptionsClearinghouseUnitTest:test_sweepFees_whenNoFees() (gas: 53105)
ValoremOptionsClearinghouseUnitTest:test_tokenType_returnsClaim() (gas: 253539)
ValoremOptionsClearinghouseUnitTest:test_tokenType_returnsNone() (gas: 7980)
ValoremOptionsClearinghouseUnitTest:test_tokenType_returnsOption() (gas: 10128)
ValoremOptionsClearinghouseUnitTest:test_tokenURIGenerator() (gas: 9941)
ValoremOptionsClearinghouseUnitTest:test_uri() (gas: 479483)
ValoremOptionsClearinghouseUnitTest:test_write_whenExistingClaim() (gas: 301062)
ValoremOptionsClearinghouseUnitTest:test_write_whenFeeOff() (gas: 259288)
ValoremOptionsClearinghouseUnitTest:test_write_whenNewClaim() (gas: 280534)
ValoremOptionsClearinghousev11UnitTest:testRevert_redeem_whenBeforeExpiryAndClaimIsPartiallyAssigned() (gas: 352537)
ValoremOptionsClearinghousev11UnitTest:testRevert_redeem_whenBeforeExpiryAndClaimIsUnassigned() (gas: 262772)
ValoremOptionsClearinghousev11UnitTest:test_claimAssignmentStatus() (gas: 342942)
ValoremOptionsClearinghousev11UnitTest:test_redeem_whenBeforeExpiryAndClaimIsFullyAssigned() (gas: 312642)
ValoremOptionsClearinghouseUnitTest:test_tokenURIGenerator() (gas: 9963)
ValoremOptionsClearinghouseUnitTest:test_uri() (gas: 479439)
ValoremOptionsClearinghouseUnitTest:test_write_whenExistingClaim() (gas: 300976)
ValoremOptionsClearinghouseUnitTest:test_write_whenFeeOff() (gas: 259335)
ValoremOptionsClearinghouseUnitTest:test_write_whenNewClaim() (gas: 280492)
ValoremOptionsClearinghousev11UnitTest:testRevert_redeem_whenBeforeExpiryAndClaimIsPartiallyAssigned() (gas: 352493)
ValoremOptionsClearinghousev11UnitTest:testRevert_redeem_whenBeforeExpiryAndClaimIsUnassigned() (gas: 262728)
ValoremOptionsClearinghousev11UnitTest:test_nettable() (gas: 3392407)
ValoremOptionsClearinghousev11UnitTest:test_redeem_whenBeforeExpiryAndClaimIsFullyAssigned() (gas: 312607)
28 changes: 28 additions & 0 deletions .gas-snapshot-custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
| src/ValoremOptionsClearinghouse.sol:ValoremOptionsClearinghouse contract | | | | | |
|--------------------------------------------------------------------------|-----------------|--------|--------|--------|---------|
| Deployment Cost | Deployment Size | | | | |
| 3361783 | 16902 | | | | |
| Function Name | min | avg | median | max | # calls |
| acceptFeeTo | 585 | 2455 | 2705 | 3825 | 4 |
| balanceOf | 642 | 2598 | 2642 | 2642 | 9578 |
| claim | 831 | 2834 | 2831 | 6269 | 4506 |
| exercise | 513 | 32222 | 20848 | 80748 | 90 |
| feeBalance | 619 | 2611 | 2619 | 2619 | 6034 |
| feeBps | 294 | 294 | 294 | 294 | 36 |
| feeTo | 406 | 2252 | 2406 | 2406 | 235 |
| feesEnabled | 395 | 1061 | 395 | 2395 | 3 |
| net | 9800 | 11455 | 9823 | 15468 | 5 |
| nettable | 3167 | 4418 | 4776 | 6385 | 9 |
| newOptionType | 3505 | 56175 | 97049 | 106049 | 234 |
| option | 1978 | 3231 | 1978 | 9978 | 7 |
| position | 1272 | 5398 | 4444 | 11026 | 61 |
| redeem | 443 | 13903 | 12830 | 24715 | 64 |
| safeTransferFrom | 3522 | 13796 | 19442 | 28802 | 87 |
| setFeeTo | 720 | 2366 | 720 | 24712 | 57 |
| setFeesEnabled | 1726 | 2591 | 2732 | 6957 | 264 |
| setTokenURIGenerator | 2594 | 4671 | 2689 | 8731 | 3 |
| sweepFees | 2863 | 16637 | 15776 | 83936 | 171 |
| tokenType | 724 | 1647 | 1062 | 2724 | 5 |
| tokenURIGenerator | 448 | 1448 | 1448 | 2448 | 2 |
| uri | 9530 | 236879 | 236879 | 464229 | 2 |
| write | 450 | 123614 | 107783 | 242841 | 365 |
Loading