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

[Feature] Spender permit feature #110

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
d1d0156
feat: spender contract and foundry test
oneleo Oct 19, 2022
93833a5
Merge branch 'master' into LABS-960/rfq-with-spender-permit
oneleo Oct 19, 2022
ecbe62e
bug: change to new signature format
oneleo Oct 24, 2022
b05f0ec
feat: replace rfq spendfromuser func with spendfromusertowithpermit
oneleo Oct 24, 2022
a05cfcd
refac: leverage struct spendwithpermit in params
oneleo Oct 26, 2022
eae8717
chg: modify variable names for readability
oneleo Oct 26, 2022
d89c922
refac: move require condition from rfq to spender contract
oneleo Oct 26, 2022
89c376a
refac: modify variables and function in rfq foundry test
oneleo Oct 26, 2022
8af0b60
chg: modify variable names for readability
oneleo Oct 26, 2022
b5b3793
spec: Add requester verification foundry test
oneleo Oct 26, 2022
b2f296b
refac: leverage struct spendwithpermit in params
oneleo Oct 26, 2022
9dca7b1
bug: assign replay protection check before sig valid check
oneleo Oct 26, 2022
c376229
bug: use safeTransfer() in SafeERC20 instead
oneleo Oct 26, 2022
2d21eaa
feat: remove taker/maker spendWithPermit but create they from _order
oneleo Oct 26, 2022
d493f7c
refac: convert the BPS_MAX variable appropriately
oneleo Oct 26, 2022
31ad782
refac: move taker/maker spendWithPermit from fill() to _settle()
oneleo Oct 27, 2022
ac38d3e
feat: modify error message returned when replay protection checks
oneleo Oct 27, 2022
123e7df
refac: use only libconstant.bps_max variable
oneleo Oct 27, 2022
c310fa1
chg: run prettier to format spender.sol to resolve code style issues
oneleo Oct 27, 2022
556ddc7
Merge pull request #99 from consenlabs/LABS-940/spender-adds-backward…
oneleo Oct 27, 2022
65d0d60
Merge branch 'master' into modify-salt-usage-of-spendwithpermit
oneleo Oct 27, 2022
9f242b9
feat: spendWithPermit should contain transaction or order hash
oneleo Oct 28, 2022
45e146f
Merge branch 'master' into spender_permit_feature
oneleo Oct 28, 2022
049cda6
Merge branch 'spender_permit_feature' into modify-salt-usage-of-spend…
oneleo Oct 28, 2022
8acfb68
Merge pull request #105 from consenlabs/modify-salt-usage-of-spendwit…
oneleo Oct 31, 2022
c8b8f2d
Merge branch 'master' into spender_permit_feature
oneleo Nov 4, 2022
2a5da3d
feat: spendWithPermit should contain transaction or order hash
oneleo Nov 4, 2022
36d2730
Merge pull request #111 from consenlabs/modify-txhash-name-of-spendwi…
charlesjhongc Nov 7, 2022
db4726e
refac: rfq, spender contracts changed to non named parameter type
oneleo Nov 7, 2022
db1564a
Merge branch 'master' into spender_permit_feature
oneleo Nov 7, 2022
03d5b72
Merge pull request #112 from consenlabs/rfq_spender_to_no_named_param…
oneleo Nov 8, 2022
77fb55a
refac: move the signSpendWithPermit function in foundry test
oneleo Nov 9, 2022
5627a14
perf: use eip712 domain separator instead of spender contract
oneleo Nov 9, 2022
b9f4bac
bug: revert when sigType is invalid
oneleo Nov 9, 2022
9a1d452
modify spendFromUser --> spendFromUserToWithPermit
Nov 10, 2022
a130849
add helper function regarding spenderPermit on l2Deposit action
Nov 10, 2022
f17e7ab
modify test case using spenderPermit
Nov 10, 2022
0714df3
replace comment for _createSpenderPermitFromL2Deposit
Nov 10, 2022
c3377c7
remove accidentally added files
Nov 10, 2022
f02e23a
remove redundant comments
Nov 10, 2022
4dd27c9
fix nit
Nov 11, 2022
7b4392e
modify solidity objects using named parameters
Nov 11, 2022
be48682
modify DEFAULT_DEPOSIT to _deposit in _createSpenderPermitFromL2Deposit
Nov 11, 2022
b66e418
Merge pull request #114 from consenlabs/move_signspendwithpermit_func
oneleo Nov 11, 2022
6bdf206
feat: replace amm spendfromuser func with spendfromusertowithpermit
oneleo Nov 11, 2022
a52be1c
chg: modify variable name to match internal variable format
oneleo Nov 11, 2022
7150101
Merge branch 'spender_permit_feature' into modify-l2deposit-using-spe…
Nov 14, 2022
a0e582e
remove signSpendWithPermit() from Setup.t.sol
Nov 14, 2022
4130802
use signSpendWithPermit() from contracts-test/utils/Permit.sol
Nov 14, 2022
58d1b78
refec: modify comments and function names
oneleo Nov 14, 2022
4aa11d0
Merge pull request #115 from consenlabs/modify-l2deposit-using-spende…
108356037 Nov 14, 2022
eb9ca88
refec: modify comments and remove unused imported package
oneleo Nov 14, 2022
66b606f
doc: adject _transferTakerAssetToAMM func comment to be clearer
oneleo Nov 15, 2022
2619aca
doc: use named parameters to make code clearer
oneleo Nov 15, 2022
6c542db
doc: apply named parameters to transferTakerAssetToAMM in ammwrapper
oneleo Nov 15, 2022
424feec
Merge pull request #116 from consenlabs/amm-with-spender-permit
oneleo Nov 15, 2022
a67eba2
refac: handle the conflict between RFQ.t.sol and the master branch
oneleo Nov 16, 2022
e8b9284
Merge branch 'master' into spender_permit_feature
oneleo Nov 16, 2022
8dcef47
feat: remove spendFromUser() func in Spender.sol
oneleo Nov 16, 2022
d1e7f20
Merge pull request #119 from consenlabs/remove_spendfromuser_function
charlesjhongc Feb 8, 2023
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
Prev Previous commit
Next Next commit
use signSpendWithPermit() from contracts-test/utils/Permit.sol
david_tsai committed Nov 14, 2022
commit 41308028993fd00a5dbe5637d77118f46ebcda3c
31 changes: 26 additions & 5 deletions contracts/test/forkMainnet/L2Deposit/Deposit.t.sol
Original file line number Diff line number Diff line change
@@ -5,12 +5,13 @@ pragma abicoder v2;
import "contracts/interfaces/IL2Deposit.sol";
import "contracts-test/forkMainnet/L2Deposit/Setup.t.sol";
import "contracts-test/utils/BalanceSnapshot.sol";
import "contracts-test/utils/Permit.sol";

interface IArbitrumBridge {
function delayedMessageCount() external view returns (uint256);
}

contract TestL2DepositTopUp is TestL2Deposit {
contract TestL2DepositTopUp is TestL2Deposit, Permit {
using BalanceSnapshot for BalanceSnapshot.Snapshot;

uint256 arbMaxSubmissionCost = 1e18;
@@ -57,7 +58,12 @@ contract TestL2DepositTopUp is TestL2Deposit {
bytes memory depositActionSig = _signDeposit(userPrivateKey, DEFAULT_DEPOSIT);
// create spendWithPermit using the deposit and sign it
SpenderLibEIP712.SpendWithPermit memory spendWithPermit = _createSpenderPermitFromL2Deposit(DEFAULT_DEPOSIT);
bytes memory spenderPermitSig = signSpendWithPermit(userPrivateKey, spendWithPermit);
bytes memory spenderPermitSig = signSpendWithPermit(
userPrivateKey,
spendWithPermit,
spender.EIP712_DOMAIN_SEPARATOR(),
SignatureValidator.SignatureType.EIP712
);

bytes memory payload = abi.encodeWithSelector(
L2Deposit.deposit.selector,
@@ -89,7 +95,12 @@ contract TestL2DepositTopUp is TestL2Deposit {

bytes memory depositActionSig = _signDeposit(userPrivateKey, DEFAULT_DEPOSIT);
SpenderLibEIP712.SpendWithPermit memory spendWithPermit = _createSpenderPermitFromL2Deposit(DEFAULT_DEPOSIT);
bytes memory spenderPermitSig = signSpendWithPermit(userPrivateKey, spendWithPermit);
bytes memory spenderPermitSig = signSpendWithPermit(
userPrivateKey,
spendWithPermit,
spender.EIP712_DOMAIN_SEPARATOR(),
SignatureValidator.SignatureType.EIP712
);

bytes memory payload = abi.encodeWithSelector(
L2Deposit.deposit.selector,
@@ -113,7 +124,12 @@ contract TestL2DepositTopUp is TestL2Deposit {

bytes memory depositActionSig = _signDeposit(userPrivateKey, DEFAULT_DEPOSIT);
SpenderLibEIP712.SpendWithPermit memory spendWithPermit = _createSpenderPermitFromL2Deposit(DEFAULT_DEPOSIT);
bytes memory spenderPermitSig = signSpendWithPermit(userPrivateKey, spendWithPermit);
bytes memory spenderPermitSig = signSpendWithPermit(
userPrivateKey,
spendWithPermit,
spender.EIP712_DOMAIN_SEPARATOR(),
SignatureValidator.SignatureType.EIP712
);

bytes memory payload = abi.encodeWithSelector(
L2Deposit.deposit.selector,
@@ -131,7 +147,12 @@ contract TestL2DepositTopUp is TestL2Deposit {

bytes memory depositActionSig = _signDeposit(userPrivateKey, DEFAULT_DEPOSIT);
SpenderLibEIP712.SpendWithPermit memory spendWithPermit = _createSpenderPermitFromL2Deposit(DEFAULT_DEPOSIT);
bytes memory spenderPermitSig = signSpendWithPermit(userPrivateKey, spendWithPermit);
bytes memory spenderPermitSig = signSpendWithPermit(
userPrivateKey,
spendWithPermit,
spender.EIP712_DOMAIN_SEPARATOR(),
SignatureValidator.SignatureType.EIP712
);

bytes memory payload = abi.encodeWithSelector(
L2Deposit.deposit.selector,
10 changes: 8 additions & 2 deletions contracts/test/forkMainnet/L2Deposit/Optimism.t.sol
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@ import "contracts/interfaces/IL2Deposit.sol";
import "contracts/utils/L2DepositLibEIP712.sol";
import "contracts-test/forkMainnet/L2Deposit/Setup.t.sol";
import "contracts-test/utils/BalanceSnapshot.sol";
import "contracts-test/utils/Permit.sol";

contract TestL2DepositOptimism is TestL2Deposit {
contract TestL2DepositOptimism is TestL2Deposit, Permit {
using BalanceSnapshot for BalanceSnapshot.Snapshot;

uint32 optL2Gas = 1e6;
@@ -28,7 +29,12 @@ contract TestL2DepositOptimism is TestL2Deposit {
bytes memory depositActionSig = _signDeposit(userPrivateKey, DEFAULT_DEPOSIT);
// create spendWithPermit using the deposit and sign it
SpenderLibEIP712.SpendWithPermit memory spendWithPermit = _createSpenderPermitFromL2Deposit(DEFAULT_DEPOSIT);
bytes memory spenderPermitSig = signSpendWithPermit(userPrivateKey, spendWithPermit);
bytes memory spenderPermitSig = signSpendWithPermit(
userPrivateKey,
spendWithPermit,
spender.EIP712_DOMAIN_SEPARATOR(),
SignatureValidator.SignatureType.EIP712
);

bytes memory payload = abi.encodeWithSelector(
L2Deposit.deposit.selector,