Skip to content

Commit

Permalink
💰 Conditional Order Fee Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders authored Oct 19, 2023
2 parents d694990 + cd99533 commit e5f045a
Show file tree
Hide file tree
Showing 33 changed files with 1,122 additions and 1,166 deletions.
143 changes: 78 additions & 65 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,73 +1,86 @@
AccountDelegate:test_isAccountDelegate_account_doesnt_exist() (gas: 26514)
AccountDelegate:test_isAccountDelegate_false() (gas: 391946)
AccountDelegate:test_isAccountDelegate_true() (gas: 389915)
AccountOwner:test_isAccountOwner_account_doesnt_exist() (gas: 25010)
AccountOwner:test_isAccountOwner_false() (gas: 229790)
AccountOwner:test_isAccountOwner_true() (gas: 229780)
CanExecute:test_canExecute_false_nonce_used() (gas: 635986)
CanExecute:test_canExecute_false_trusted_executor() (gas: 44106)
CanExecute:test_canExecute_true() (gas: 43793)
AccountDelegate:test_isAccountDelegate_false() (gas: 391969)
AccountDelegate:test_isAccountDelegate_true() (gas: 389938)
AccountOwner:test_isAccountOwner_account_doesnt_exist() (gas: 25032)
AccountOwner:test_isAccountOwner_false() (gas: 229812)
AccountOwner:test_isAccountOwner_true() (gas: 229802)
CanExecute:test_canExecute_false_insufficent_account_credit() (gas: 414653)
CanExecute:test_canExecute_false_invalid_signature() (gas: 448261)
CanExecute:test_canExecute_false_invalid_signer() (gas: 441634)
CanExecute:test_canExecute_false_maxExecutorFee_exceeded() (gas: 397133)
CanExecute:test_canExecute_false_nonce_used() (gas: 825924)
CanExecute:test_canExecute_false_trusted_executor() (gas: 438376)
CanExecute:test_canExecute_true() (gas: 437970)
CommitOrder:test_commitOrder() (gas: 382994)
CommitOrder:test_commitOrder_insufficient_collateral() (gas: 441147)
CommitOrder:test_commitOrder_invalid_market() (gas: 38351)
Conditions:test_isMarketOpen() (gas: 26586)
Conditions:test_isOrderFeeBelow() (gas: 179847)
Conditions:test_isPositionSizeAbove() (gas: 18867)
Conditions:test_isPositionSizeBelow() (gas: 18762)
Conditions:test_isPriceAbove() (gas: 19150)
Conditions:test_isPriceBelow() (gas: 19178)
Conditions:test_isTimestampAfter() (gas: 7513)
Conditions:test_isTimestampBefore() (gas: 7602)
DeploymentTest:test_deploy() (gas: 2880751)
DeploymentTest:test_deploy_oracle_zero_address() (gas: 40293)
DeploymentTest:test_deploy_perps_market_proxy_zero_address() (gas: 40211)
DeploymentTest:test_deploy_spot_market_proxy_zero_address() (gas: 40267)
DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 40280)
DeploymentTest:test_deploy_trusted_forwarder_zero_address() (gas: 40327)
DepositCollateral:test_depositCollateral() (gas: 258507)
DepositCollateral:test_depositCollateral_availableMargin() (gas: 266075)
DepositCollateral:test_depositCollateral_collateralAmount() (gas: 259083)
DepositCollateral:test_depositCollateral_insufficient_balance() (gas: 56023)
DepositCollateral:test_depositCollateral_totalCollateralValue() (gas: 263459)
EIP7412Test:test_fulfillOracleQuery(bytes) (runs: 256, μ: 142463, ~: 142365)
Execute:test_execute_CannotExecuteOrder() (gas: 37220)
Execute:test_execute_leverage_exceeded() (gas: 716391)
Execute:test_execute_order_committed() (gas: 633942)
Fee:test_fee_imposed() (gas: 640084)
Fee:test_fee_imposed_above_upper_fee_cap() (gas: 618750)
Fee:test_fee_imposed_at_upper_fee_cap() (gas: 618653)
Fee:test_fee_imposed_below_lower_fee_cap() (gas: 617168)
Fee:test_fee_imposed_below_upper_fee_cap() (gas: 619573)
Fee:test_fee_imposed_fee_cannot_be_paid() (gas: 394180)
Fee:test_fee_imposed_insufficient_collateral_for_order() (gas: 716414)
CommitOrder:test_commitOrder_insufficient_collateral() (gas: 441236)
CommitOrder:test_commitOrder_invalid_market() (gas: 38373)
Conditions:test_isMarketOpen() (gas: 26619)
Conditions:test_isOrderFeeBelow() (gas: 179759)
Conditions:test_isPositionSizeAbove() (gas: 18823)
Conditions:test_isPositionSizeBelow() (gas: 18828)
Conditions:test_isPriceAbove() (gas: 19186)
Conditions:test_isPriceBelow() (gas: 19092)
Conditions:test_isTimestampAfter() (gas: 7711)
Conditions:test_isTimestampBefore() (gas: 7645)
DeploymentTest:test_deploy() (gas: 4550522)
DeploymentTest:test_deploy_oracle_zero_address() (gas: 1681379)
DeploymentTest:test_deploy_perps_market_proxy_zero_address() (gas: 1681295)
DeploymentTest:test_deploy_spot_market_proxy_zero_address() (gas: 1681362)
DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 1681375)
DeploymentTest:test_deploy_trusted_forwarder_zero_address() (gas: 37411)
Deposit:test_depositEth() (gas: 40987)
Deposit:test_depositEth_event() (gas: 42524)
Deposit:test_depositEth_fuzz(uint256,uint128) (runs: 256, μ: 39369, ~: 40409)
Deposit:test_depositEth_via_trustedForwarder() (gas: 68274)
Deposit:test_depositEth_via_trustedForwarder_value_mismatch() (gas: 72575)
DepositCollateral:test_depositCollateral() (gas: 258530)
DepositCollateral:test_depositCollateral_availableMargin() (gas: 266098)
DepositCollateral:test_depositCollateral_collateralAmount() (gas: 259106)
DepositCollateral:test_depositCollateral_insufficient_balance() (gas: 56046)
DepositCollateral:test_depositCollateral_totalCollateralValue() (gas: 263482)
EIP7412Test:test_fulfillOracleQuery(bytes) (runs: 256, μ: 142507, ~: 142409)
Execute:test_execute_CannotExecuteOrder_invalid_acceptablePrice() (gas: 330554)
Execute:test_execute_CannotExecuteOrder_invalid_settlementStrategyId() (gas: 96428)
Execute:test_execute_CannotExecuteOrder_too_leveraged() (gas: 361127)
Execute:test_execute_event() (gas: 433535)
Execute:test_execute_order_committed() (gas: 430028)
Fee:test_fee_exceeds_account_credit() (gas: 53442)
Fee:test_fee_exceeds_maxExecutorFee() (gas: 53021)
Fee:test_fee_imposed() (gas: 465437)
MathLibTest:test_abs128() (gas: 448)
MathLibTest:test_abs256() (gas: 480)
MathLibTest:test_castU128() (gas: 350)
MathLibTest:test_castU128_overflow() (gas: 3509)
MathLibTest:test_fuzz_abs128(int128) (runs: 256, μ: 576, ~: 603)
MathLibTest:test_fuzz_abs256(int256) (runs: 256, μ: 472, ~: 458)
MathLibTest:test_fuzz_abs256(int256) (runs: 256, μ: 471, ~: 458)
MathLibTest:test_isSameSign() (gas: 999)
MulticallableTest:test_multicall_depositCollateral_commitOrder() (gas: 605194)
NonceBitmapTest:test_fuzz_invalidateUnorderedNonces(uint256) (runs: 256, μ: 52780, ~: 52780)
NonceBitmapTest:test_hasUnorderedNonceBeenUsed() (gas: 54136)
NonceBitmapTest:test_invalidateUnorderedNonces() (gas: 73100)
NonceBitmapTest:test_invalidateUnorderedNonces_Only_Owner_Delegate() (gas: 190344)
ReduceOnly:test_reduce_only() (gas: 635576)
ReduceOnly:test_reduce_only_same_sign() (gas: 68498)
ReduceOnly:test_reduce_only_truncate_size_down() (gas: 635706)
ReduceOnly:test_reduce_only_truncate_size_up() (gas: 610509)
ReduceOnly:test_reduce_only_zero_size() (gas: 159015)
VerifyConditions:test_max_condition_size_exceeded() (gas: 45024)
VerifyConditions:test_verifyConditions_InvalidConditionSelector() (gas: 14123)
VerifyConditions:test_verify_conditions_not_verified() (gas: 29682)
VerifyConditions:test_verify_conditions_verified() (gas: 135831)
VerifySignature:test_verifySignature() (gas: 23816)
VerifySignature:test_verifySignature_false_private_key() (gas: 26638)
VerifySigner:test_verifySigner() (gas: 25845)
VerifySigner:test_verifySigner_false() (gas: 28553)
WithdrawCollateral:test_withdrawCollateral() (gas: 353200)
WithdrawCollateral:test_withdrawCollateral_availableMargin() (gas: 354718)
WithdrawCollateral:test_withdrawCollateral_collateralAmount() (gas: 353710)
WithdrawCollateral:test_withdrawCollateral_insufficient_account_collateral_balance() (gas: 274196)
WithdrawCollateral:test_withdrawCollateral_totalCollateralValue() (gas: 354216)
WithdrawCollateral:test_withdrawCollateral_zero() (gas: 266154)
NonceBitmapTest:test_fuzz_invalidateUnorderedNonces(uint256) (runs: 256, μ: 52725, ~: 52725)
NonceBitmapTest:test_hasUnorderedNonceBeenUsed() (gas: 54036)
NonceBitmapTest:test_invalidateUnorderedNonces() (gas: 76121)
NonceBitmapTest:test_invalidateUnorderedNonces_Only_Owner_Delegate() (gas: 190234)
NonceBitmapTest:test_invalidateUnorderedNonces_event() (gas: 53464)
ReduceOnly:test_reduce_only() (gas: 431717)
ReduceOnly:test_reduce_only_same_sign() (gas: 72073)
ReduceOnly:test_reduce_only_truncate_size_down() (gas: 431824)
ReduceOnly:test_reduce_only_truncate_size_up() (gas: 408486)
ReduceOnly:test_reduce_only_zero_size() (gas: 162568)
VerifyConditions:test_max_condition_size_exceeded() (gas: 45101)
VerifyConditions:test_verifyConditions_InvalidConditionSelector() (gas: 14132)
VerifyConditions:test_verify_conditions_not_verified() (gas: 29751)
VerifyConditions:test_verify_conditions_verified() (gas: 135901)
VerifySignature:test_verifySignature() (gas: 23931)
VerifySignature:test_verifySignature_false_private_key() (gas: 26685)
VerifySigner:test_verifySigner() (gas: 25884)
VerifySigner:test_verifySigner_false() (gas: 28636)
Withdraw:test_withdrawEth() (gas: 50332)
Withdraw:test_withdrawEth_EthTransferFailed() (gas: 78823)
Withdraw:test_withdrawEth_InsufficientEthBalance() (gas: 57013)
Withdraw:test_withdrawEth_Unauthorized() (gas: 56652)
Withdraw:test_withdrawEth_event() (gas: 49576)
Withdraw:test_withdrawEth_fuzz(uint256) (runs: 256, μ: 68193, ~: 68743)
WithdrawCollateral:test_withdrawCollateral() (gas: 353254)
WithdrawCollateral:test_withdrawCollateral_availableMargin() (gas: 354755)
WithdrawCollateral:test_withdrawCollateral_collateralAmount() (gas: 353747)
WithdrawCollateral:test_withdrawCollateral_insufficient_account_collateral_balance() (gas: 274242)
WithdrawCollateral:test_withdrawCollateral_totalCollateralValue() (gas: 354253)
WithdrawCollateral:test_withdrawCollateral_zero() (gas: 266200)
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/trusted-multicall-forwarder"]
path = lib/trusted-multicall-forwarder
url = https://github.com/Synthetixio/trusted-multicall-forwarder
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ src/
│ └── SignatureCheckerLib.sol
└── utils
├── EIP712.sol
├── EIP7412.sol
├── ERC2771Context.sol
└── Multicallable.sol
└── EIP7412.sol
```

## Tests
Expand Down
4 changes: 4 additions & 0 deletions deployments/Base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Engine": "",
"TrustedMulticallForwarder": ""
}
3 changes: 2 additions & 1 deletion deployments/BaseGoerli.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"Engine": "0x319Ae7F3a0D635eD9CCF0276dCeAF680F9C7c397"
"Engine": "",
"TrustedMulticallForwarder": ""
}
4 changes: 4 additions & 0 deletions deployments/Optimism.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Engine": "",
"TrustedMulticallForwarder": ""
}
3 changes: 2 additions & 1 deletion deployments/OptimismGoerli.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"Engine": "0x16Da5d51C1DDB43C1105A253F2dE9eAB2B3b76CA"
"Engine": "",
"TrustedMulticallForwarder": ""
}
Binary file modified diagrams/Conditional-Orders.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e5f045a

Please sign in to comment.