Skip to content

Commit

Permalink
🧩 ERC-7412 Support
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders authored Oct 5, 2023
2 parents 7ac8eb4 + 8c1f471 commit d694990
Show file tree
Hide file tree
Showing 21 changed files with 607 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ BASE_RPC_URL=https://base-mainnet.g.alchemy.com/v2/KEY
GOERLI_RPC_URL=https://eth-goerli.g.alchemy.com/v2/KEY
OPTIMISM_GOERLI_RPC_URL=https://opt-goerli.g.alchemy.com/v2/KEY
BASE_GOERLI_RPC_URL=https://base-goerli.g.alchemy.com/v2/KEY
PRIVATE_KEY=KEY
PRIVATE_KEY=0xKEY
ETHERSCAN_API_KEY=KEY
OPTIMISM_ETHERSCAN_API_KEY=KEY
BASESCAN_API_KEY=KEY
126 changes: 64 additions & 62 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,71 +1,73 @@
AccountDelegate:test_isAccountDelegate_account_doesnt_exist() (gas: 26514)
AccountDelegate:test_isAccountDelegate_false() (gas: 391991)
AccountDelegate:test_isAccountDelegate_true() (gas: 389960)
AccountOwner:test_isAccountOwner_account_doesnt_exist() (gas: 25032)
AccountOwner:test_isAccountOwner_false() (gas: 229812)
AccountOwner:test_isAccountOwner_true() (gas: 229802)
CanExecute:test_canExecute_false_nonce_used() (gas: 635740)
CanExecute:test_canExecute_false_trusted_executor() (gas: 44071)
CanExecute:test_canExecute_true() (gas: 43670)
CommitOrder:test_commitOrder() (gas: 382895)
CommitOrder:test_commitOrder_insufficient_collateral() (gas: 441115)
CommitOrder:test_commitOrder_invalid_market() (gas: 38252)
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)
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: 179759)
Conditions:test_isPositionSizeAbove() (gas: 18801)
Conditions:test_isPositionSizeBelow() (gas: 18783)
Conditions:test_isPriceAbove() (gas: 19194)
Conditions:test_isPriceBelow() (gas: 18998)
Conditions:test_isTimestampAfter() (gas: 7645)
Conditions:test_isTimestampBefore() (gas: 7668)
DeploymentTest:test_deploy() (gas: 2684850)
DeploymentTest:test_deploy_oracle_zero_address() (gas: 39879)
DeploymentTest:test_deploy_perps_market_proxy_zero_address() (gas: 39775)
DeploymentTest:test_deploy_spot_market_proxy_zero_address() (gas: 39853)
DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 39866)
DepositCollateral:test_depositCollateral() (gas: 258373)
DepositCollateral:test_depositCollateral_availableMargin() (gas: 265941)
DepositCollateral:test_depositCollateral_collateralAmount() (gas: 258949)
DepositCollateral:test_depositCollateral_insufficient_balance() (gas: 55891)
DepositCollateral:test_depositCollateral_totalCollateralValue() (gas: 263325)
Execute:test_execute_CannotExecuteOrder() (gas: 37262)
Execute:test_execute_leverage_exceeded() (gas: 716169)
Execute:test_execute_order_committed() (gas: 633720)
Fee:test_fee_imposed() (gas: 639801)
Fee:test_fee_imposed_above_upper_fee_cap() (gas: 618512)
Fee:test_fee_imposed_at_upper_fee_cap() (gas: 618415)
Fee:test_fee_imposed_below_lower_fee_cap() (gas: 617062)
Fee:test_fee_imposed_below_upper_fee_cap() (gas: 619335)
Fee:test_fee_imposed_fee_cannot_be_paid() (gas: 393807)
Fee:test_fee_imposed_insufficient_collateral_for_order() (gas: 716154)
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)
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_isSameSign() (gas: 999)
MulticallableTest:test_multicall_depositCollateral_commitOrder() (gas: 604961)
NonceBitmapTest:test_fuzz_invalidateUnorderedNonces(uint256) (runs: 256, μ: 52614, ~: 52614)
NonceBitmapTest:test_hasUnorderedNonceBeenUsed() (gas: 53925)
NonceBitmapTest:test_invalidateUnorderedNonces() (gas: 72854)
NonceBitmapTest:test_invalidateUnorderedNonces_Only_Owner_Delegate() (gas: 190012)
ReduceOnly:test_reduce_only() (gas: 635354)
ReduceOnly:test_reduce_only_same_sign() (gas: 68419)
ReduceOnly:test_reduce_only_truncate_size_down() (gas: 635484)
ReduceOnly:test_reduce_only_truncate_size_up() (gas: 610287)
ReduceOnly:test_reduce_only_zero_size() (gas: 158892)
VerifyConditions:test_max_condition_size_exceeded() (gas: 45046)
VerifyConditions:test_verifyConditions_InvalidConditionSelector() (gas: 14079)
VerifyConditions:test_verify_conditions_not_verified() (gas: 29659)
VerifyConditions:test_verify_conditions_verified() (gas: 135808)
VerifySignature:test_verifySignature() (gas: 23770)
VerifySignature:test_verifySignature_false_private_key() (gas: 26592)
VerifySigner:test_verifySigner() (gas: 25823)
VerifySigner:test_verifySigner_false() (gas: 28531)
WithdrawCollateral:test_withdrawCollateral() (gas: 352984)
WithdrawCollateral:test_withdrawCollateral_availableMargin() (gas: 354503)
WithdrawCollateral:test_withdrawCollateral_collateralAmount() (gas: 353495)
WithdrawCollateral:test_withdrawCollateral_insufficient_account_collateral_balance() (gas: 273929)
WithdrawCollateral:test_withdrawCollateral_totalCollateralValue() (gas: 354001)
WithdrawCollateral:test_withdrawCollateral_zero() (gas: 265887)
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)
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ src/
│ ├── oracles
│ │ └── IPyth.sol
│ ├── synthetix
│ │ ├── IERC7412.sol
│ │ ├── IPerpsMarketProxy.sol
│ │ └── ISpotMarketProxy.sol
│ └── tokens
Expand All @@ -37,6 +38,8 @@ src/
│ └── SignatureCheckerLib.sol
└── utils
├── EIP712.sol
├── EIP7412.sol
├── ERC2771Context.sol
└── Multicallable.sol
```

Expand Down
2 changes: 1 addition & 1 deletion deployments/BaseGoerli.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Engine": "0xb3E58002aAf9d21a39a19DB784f10c30c9e5bE76"
"Engine": "0x319Ae7F3a0D635eD9CCF0276dCeAF680F9C7c397"
}
2 changes: 1 addition & 1 deletion deployments/OptimismGoerli.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Engine": "0xB52640E47b3fe5bdcB113430328BF5ea96261160"
"Engine": "0x16Da5d51C1DDB43C1105A253F2dE9eAB2B3b76CA"
}
Binary file modified diagrams/SMv3-Overview.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 d694990

Please sign in to comment.