Skip to content

Commit

Permalink
↗️ Update Trusted Forwarder
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredBorders authored Dec 1, 2023
2 parents f6f8291 + 27927d5 commit 8a7fc4f
Show file tree
Hide file tree
Showing 16 changed files with 1,241 additions and 33 deletions.
53 changes: 37 additions & 16 deletions .gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ Conditions:test_isPriceAbove() (gas: 19098)
Conditions:test_isPriceBelow() (gas: 19092)
Conditions:test_isTimestampAfter() (gas: 7711)
Conditions:test_isTimestampBefore() (gas: 7579)
DeploymentTest:test_deploy() (gas: 4890231)
DeploymentTest:test_deploy_oracle_zero_address() (gas: 1903233)
DeploymentTest:test_deploy_perps_market_proxy_zero_address() (gas: 1903149)
DeploymentTest:test_deploy_spot_market_proxy_zero_address() (gas: 1903216)
DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 1903229)
DeploymentTest:test_deploy_trusted_forwarder_zero_address() (gas: 37562)
Deposit:test_depositEth() (gas: 55255)
Deposit:test_depositEth_Account_Doesnt_Exist() (gas: 34271)
Deposit:test_depositEth_event() (gas: 56815)
Deposit:test_depositEth_fuzz(uint256,uint128) (runs: 256, μ: 36476, ~: 34889)
Deposit:test_depositEth_via_trustedForwarder() (gas: 85374)
Deposit:test_depositEth_via_trustedForwarder_value_mismatch() (gas: 87469)
Deposit:test_depositEth_via_trustedForwarder_value_mismatch_allow_failure() (gas: 86713)
DeploymentTest:test_deploy() (gas: 4835482)
DeploymentTest:test_deploy_oracle_zero_address() (gas: 1902969)
DeploymentTest:test_deploy_perps_market_proxy_zero_address() (gas: 1902885)
DeploymentTest:test_deploy_spot_market_proxy_zero_address() (gas: 1902952)
DeploymentTest:test_deploy_susd_proxy_zero_address() (gas: 1902965)
DeploymentTest:test_deploy_trusted_forwarder_zero_address() (gas: 37498)
Deposit:test_depositEth() (gas: 40987)
Deposit:test_depositEth_event() (gas: 42547)
Deposit:test_depositEth_fuzz(uint256,uint128) (runs: 256, μ: 39369, ~: 40409)
Deposit:test_depositEth_via_trustedForwarder() (gas: 68338)
Deposit:test_depositEth_via_trustedForwarder_value_mismatch() (gas: 73201)
Deposit:test_depositEth_via_trustedForwarder_value_mismatch_require_success() (gas: 72445)
DepositCollateral:test_depositCollateral() (gas: 258530)
DepositCollateral:test_depositCollateral_availableMargin() (gas: 266098)
DepositCollateral:test_depositCollateral_collateralAmount() (gas: 259106)
Expand All @@ -46,9 +45,11 @@ Execute:test_execute_CannotExecuteOrder_invalid_settlementStrategyId() (gas: 968
Execute:test_execute_CannotExecuteOrder_too_leveraged() (gas: 361524)
Execute:test_execute_event() (gas: 433933)
Execute:test_execute_order_committed() (gas: 430425)
Fee:test_fee_exceeds_account_credit() (gas: 67907)
Fee:test_fee_exceeds_maxExecutorFee() (gas: 67486)
Fee:test_fee_imposed() (gas: 468614)
ExecuteBatch:test_executeBatch() (gas: 95256)
ExecuteBatch:test_executeBatch_invalid_signature() (gas: 48173)
Fee:test_fee_exceeds_account_credit() (gas: 53639)
Fee:test_fee_exceeds_maxExecutorFee() (gas: 53218)
Fee:test_fee_imposed() (gas: 465846)
MathLibTest:test_abs128() (gas: 448)
MathLibTest:test_abs256() (gas: 480)
MathLibTest:test_castU128() (gas: 350)
Expand All @@ -66,6 +67,26 @@ ReduceOnly:test_reduce_only_same_sign() (gas: 72481)
ReduceOnly:test_reduce_only_truncate_size_down() (gas: 432232)
ReduceOnly:test_reduce_only_truncate_size_up() (gas: 408894)
ReduceOnly:test_reduce_only_zero_size() (gas: 162976)
TrustedMulticallForwarderTest:testAggregate3() (gas: 24779)
TrustedMulticallForwarderTest:testAggregate3Unsuccessful() (gas: 21395)
TrustedMulticallForwarderTest:testAggregate3Value() (gas: 49261)
TrustedMulticallForwarderTest:testAggregate3ValueUnsuccessful() (gas: 87877)
TrustedMulticallForwarderTest:testAggregation() (gas: 15186)
TrustedMulticallForwarderTest:testBlockAndAggregateUnsuccessful() (gas: 21080)
TrustedMulticallForwarderTest:testGetBasefee() (gas: 5486)
TrustedMulticallForwarderTest:testGetBlockHash(uint256) (runs: 256, μ: 5674, ~: 5674)
TrustedMulticallForwarderTest:testGetBlockNumber() (gas: 5487)
TrustedMulticallForwarderTest:testGetChainId() (gas: 5486)
TrustedMulticallForwarderTest:testGetCurrentBlockCoinbase() (gas: 5579)
TrustedMulticallForwarderTest:testGetCurrentBlockGasLimit() (gas: 5463)
TrustedMulticallForwarderTest:testGetCurrentBlockTimestamp() (gas: 5433)
TrustedMulticallForwarderTest:testGetEthBalance(address) (runs: 256, μ: 8421, ~: 8451)
TrustedMulticallForwarderTest:testGetLastBlockHash() (gas: 5670)
TrustedMulticallForwarderTest:testTryAggregate() (gas: 19577)
TrustedMulticallForwarderTest:testTryAggregateUnsuccessful() (gas: 21084)
TrustedMulticallForwarderTest:testTryBlockAndAggregate() (gas: 19879)
TrustedMulticallForwarderTest:testTryBlockAndAggregateUnsuccessful() (gas: 21185)
TrustedMulticallForwarderTest:testUnsuccessfulAggregation() (gas: 20818)
VerifyConditions:test_max_condition_size_exceeded() (gas: 45101)
VerifyConditions:test_verifyConditions_InvalidConditionSelector() (gas: 14132)
VerifyConditions:test_verify_conditions_not_verified() (gas: 29707)
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +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
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
4 changes: 2 additions & 2 deletions deployments/BaseGoerli.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"TrustedMulticallForwarder": "0x14aE2D8fA531A9e77aE434d2d700218C2845Bc83"
},
"Andromeda": {
"Engine": "0x6b5864815A42565D2b421D7CEB70440cc479c568",
"TrustedMulticallForwarder": "0xAD9b7B21456E0d4c99d39AC2aB8a54241d3f1FF8"
"Engine": "0x3617154844291712cBD2148D912b61d6641229a4",
"TrustedMulticallForwarder": "0xb5dCFb08a2CB07399b75B650B980732340c5Ed90"
},
"Kwenta": {
"Engine": "0x0b5456EB6eE169C533a931aD2a420237ADf3Da49",
Expand Down
214 changes: 214 additions & 0 deletions lcov.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
TN:
SF:script/Deploy.s.sol
FN:133,DeployOptimism_Synthetix.run
FNDA:0,DeployOptimism_Synthetix.run
DA:134,0
DA:135,0
DA:137,0
DA:144,0
FN:114,DeployBaseGoerli_Andromeda.run
FNDA:0,DeployBaseGoerli_Andromeda.run
DA:115,0
DA:116,0
DA:118,0
DA:125,0
FN:26,Setup.deploySystem
FNDA:5,Setup.deploySystem
DA:38,5
DA:40,5
FN:73,DeployBaseGoerli_Synthetix.run
FNDA:0,DeployBaseGoerli_Synthetix.run
DA:74,0
Expand All @@ -12,6 +28,12 @@ DA:153,0
DA:154,0
DA:156,0
DA:163,0
FN:54,DeployBase_Synthetix.run
FNDA:0,DeployBase_Synthetix.run
DA:55,0
DA:56,0
DA:58,0
DA:65,0
FN:95,DeployBaseGoerli_KwentaFork.run
FNDA:0,DeployBaseGoerli_KwentaFork.run
DA:96,0
Expand Down Expand Up @@ -386,6 +408,156 @@ BRF:0
BRH:0
end_of_record
TN:
SF:src/utils/TrustedMulticallForwarder.sol
FN:56,TrustedMulticallForwarder.aggregate
FNDA:2,TrustedMulticallForwarder.aggregate
DA:60,2
DA:61,2
DA:62,2
DA:63,2
DA:64,2
DA:65,3
DA:66,3
DA:67,3
DA:69,3
BRDA:69,0,0,-
BRDA:69,0,1,1
DA:70,1
DA:71,1
DA:78,2
FN:88,TrustedMulticallForwarder.tryAggregate
FNDA:2,TrustedMulticallForwarder.tryAggregate
DA:92,5
DA:93,5
DA:94,5
DA:95,5
DA:96,10
DA:97,10
DA:98,10
DA:100,10
BRDA:100,1,0,3
BRDA:100,1,1,7
DA:101,3
DA:102,3
DA:108,7
FN:119,TrustedMulticallForwarder.tryBlockAndAggregate
FNDA:2,TrustedMulticallForwarder.tryBlockAndAggregate
DA:128,3
DA:129,3
DA:130,3
FN:139,TrustedMulticallForwarder.blockAndAggregate
FNDA:1,TrustedMulticallForwarder.blockAndAggregate
DA:148,1
FN:154,TrustedMulticallForwarder.aggregate3
FNDA:2,TrustedMulticallForwarder.aggregate3
DA:159,2
DA:160,2
DA:161,2
DA:162,2
DA:163,5
DA:164,5
DA:165,5
DA:167,5
BRDA:167,2,0,1
BRDA:167,2,1,4
DA:168,1
DA:169,1
DA:175,4
FN:184,TrustedMulticallForwarder.aggregate3Value
FNDA:7,TrustedMulticallForwarder.aggregate3Value
DA:189,7
DA:190,7
DA:191,7
DA:192,7
DA:193,7
DA:194,15
DA:195,15
DA:196,15
DA:200,15
DA:202,15
DA:205,15
BRDA:205,3,0,2
BRDA:205,3,1,13
DA:206,2
DA:207,2
DA:213,13
DA:217,5
BRDA:217,4,0,2
BRDA:217,4,1,3
DA:218,2
FN:227,TrustedMulticallForwarder.executeBatch
FNDA:2,TrustedMulticallForwarder.executeBatch
DA:232,2
DA:233,2
DA:235,2
DA:237,2
DA:238,2
DA:240,2
DA:241,2
DA:243,2
DA:244,2
DA:246,2
DA:251,2
DA:253,2
BRDA:253,5,0,-
BRDA:253,5,1,1
DA:255,1
DA:257,1
DA:263,1
BRDA:263,6,0,-
BRDA:263,6,1,1
DA:269,1
DA:276,2
BRDA:276,7,0,-
BRDA:276,7,1,1
DA:277,1
DA:281,2
DA:287,2
BRDA:287,8,0,-
BRDA:287,8,1,2
DA:288,0
DA:293,2
BRDA:293,9,0,1
BRDA:293,9,1,1
DA:297,1
FN:303,TrustedMulticallForwarder.getBlockHash
FNDA:256,TrustedMulticallForwarder.getBlockHash
DA:308,256
FN:312,TrustedMulticallForwarder.getBlockNumber
FNDA:1,TrustedMulticallForwarder.getBlockNumber
DA:313,1
FN:317,TrustedMulticallForwarder.getCurrentBlockCoinbase
FNDA:1,TrustedMulticallForwarder.getCurrentBlockCoinbase
DA:318,1
FN:322,TrustedMulticallForwarder.getPrevRandao
FNDA:0,TrustedMulticallForwarder.getPrevRandao
DA:323,0
FN:327,TrustedMulticallForwarder.getCurrentBlockGasLimit
FNDA:1,TrustedMulticallForwarder.getCurrentBlockGasLimit
DA:328,1
FN:332,TrustedMulticallForwarder.getCurrentBlockTimestamp
FNDA:2,TrustedMulticallForwarder.getCurrentBlockTimestamp
DA:337,2
FN:341,TrustedMulticallForwarder.getEthBalance
FNDA:256,TrustedMulticallForwarder.getEthBalance
DA:346,256
FN:350,TrustedMulticallForwarder.getLastBlockHash
FNDA:1,TrustedMulticallForwarder.getLastBlockHash
DA:352,1
FN:358,TrustedMulticallForwarder.getBasefee
FNDA:1,TrustedMulticallForwarder.getBasefee
DA:359,1
FN:363,TrustedMulticallForwarder.getChainId
FNDA:1,TrustedMulticallForwarder.getChainId
DA:364,1
FNF:17
FNH:16
LF:87
LH:85
BRF:20
BRH:15
end_of_record
TN:
SF:test/AsyncOrder.t.sol
FN:8,AsyncOrderTest.setUp
FNDA:0,AsyncOrderTest.setUp
Expand Down Expand Up @@ -466,6 +638,27 @@ BRF:0
BRH:0
end_of_record
TN:
SF:test/TrustedMulticallForwarder.t.sol
FN:14,ERC2771Example.isTrustedForwarder
FNDA:2,ERC2771Example.isTrustedForwarder
DA:19,2
FN:22,ERC2771Example.ping
FNDA:1,ERC2771Example.ping
DA:23,1
FN:38,TrustedMulticallForwarderTest.setUp
FNDA:0,TrustedMulticallForwarderTest.setUp
DA:40,0
DA:41,0
DA:44,0
DA:45,0
FNF:3
FNH:2
LF:6
LH:2
BRF:0
BRH:0
end_of_record
TN:
SF:test/utils/Bootstrap.sol
FN:113,BootstrapOptimism.init
FNDA:0,BootstrapOptimism.init
Expand Down Expand Up @@ -607,6 +800,27 @@ BRF:0
BRH:0
end_of_record
TN:
SF:test/utils/mocks/MockCallee.sol
FN:14,MockCallee.getBlockHash
FNDA:12,MockCallee.getBlockHash
DA:19,12
FN:23,MockCallee.thisMethodReverts
FNDA:11,MockCallee.thisMethodReverts
DA:24,11
FN:28,MockCallee.sendBackValue
FNDA:2,MockCallee.sendBackValue
DA:29,2
DA:30,2
BRDA:30,0,0,-
BRDA:30,0,1,2
FNF:3
FNH:3
LF:4
LH:4
BRF:2
BRH:1
end_of_record
TN:
SF:test/utils/mocks/PythMock.sol
FN:8,PythMock.mock_pyth_getPrice
FNDA:0,PythMock.mock_pyth_getPrice
Expand Down
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at 932fdd
1 change: 0 additions & 1 deletion lib/trusted-multicall-forwarder
Submodule trusted-multicall-forwarder deleted from 77ff94
2 changes: 1 addition & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity 0.8.20;
// contracts
import {Engine} from "src/Engine.sol";
import {TrustedMulticallForwarder} from
"lib/trusted-multicall-forwarder/src/TrustedMulticallForwarder.sol";
"src/utils/TrustedMulticallForwarder.sol";

// parameters
import {BaseGoerliParameters} from
Expand Down
2 changes: 1 addition & 1 deletion src/Engine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {ConditionalOrderHashLib} from
import {EIP712} from "src/utils/EIP712.sol";
import {EIP7412} from "src/utils/EIP7412.sol";
import {ERC2771Context} from
"lib/trusted-multicall-forwarder/lib/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol";
"lib/openzeppelin-contracts/contracts/metatx/ERC2771Context.sol";
import {IEngine, IPerpsMarketProxy} from "src/interfaces/IEngine.sol";
import {IERC20} from "src/interfaces/tokens/IERC20.sol";
import {IPyth, PythStructs} from "src/interfaces/oracles/IPyth.sol";
Expand Down
Loading

0 comments on commit 8a7fc4f

Please sign in to comment.