Commit Graph

36 Commits

Author SHA1 Message Date
Diana Carvalho
b9cfc4a35b fix: Small improvements
- Rename test
- Improve error messages
- Remove unnecessary asserts

--- don't change below this line ---
ENG-4063 Took 52 seconds
2025-01-23 15:53:13 +00:00
Diana Carvalho
04e925fe81 fix: Correct encoding of the approvals
- Add data validations similar to the ones done in the Permit2 SDK
- Fix Domain main (!!!) It's Permit2 not Permit
- Return the whole function signature data (owner, permit_single, signature) encoded

test improvements:
- Don't compare the timestamps, this was making the test fail sometimes and pass other times
- Add a test to run on an anvil fork and actually call permit2 contract to double check the encoded data works

misc:
Rename get_allowance_data -> get_existing_allowance

--- don't change below this line ---
ENG-4063 Took 5 hours 19 minutes


Took 11 seconds
2025-01-23 15:52:19 +00:00
Diana Carvalho
ce9ae49e6f feat: Implement Permit2
- Retrieve allowance data from an RPC
- Encode approvals:
  - Create PermitSingle (and PermitDetails)
  - Use alloy eip712 to get signing hash on typed data
  - Sign data
- Add chrono and alloy eip712 and signer-local to Cargo.toml

--- don't change below this line ---
ENG-4063 Took 1 hour 58 minutes

Took 18 seconds

Took 32 seconds

Took 9 seconds

Took 1 minute


Took 32 minutes
2025-01-23 15:52:19 +00:00
TAMARA LIPOWSKI
ef07f49698 chore: merge main 2025-01-22 09:51:50 -05:00
TAMARA LIPOWSKI
748a3f06c3 chore: Renamings for clarity 2025-01-22 09:33:08 -05:00
TAMARA LIPOWSKI
cc979880e2 chore: Rename address_for_approvals -> router_address
When will this not be the router address that we use for approvals? It will always be the router address. address_for_approvals sounds to me very vague (which approvals?).
2025-01-21 16:35:19 -05:00
TAMARA LIPOWSKI
7b4bf0205d feat: UniswapV2 Swap Encoder 2025-01-21 16:35:19 -05:00
Diana Carvalho
979cdf7437 chore: Do not use expect
--- don't change below this line ---
ENG-4063 Took 57 minutes


Took 17 seconds

Took 45 seconds
2025-01-21 18:48:49 +00:00
Diana Carvalho
b155b273a0 chore: Add more descriptive error message
--- don't change below this line ---
ENG-4063 Took 14 minutes
2025-01-20 16:35:38 +00:00
Diana Carvalho
cbf2b4de5a feat: Implement ProtocolApprovalsManager
I decided to make ProtocolApprovalsManager public method sync not to propagate asynceness early on onto the rest of the code. If later we decide that it is better to have this async, it should be easier to make that change than the opposite one.

--- don't change below this line ---
ENG-4064 Took 24 minutes
2025-01-20 16:05:06 +00:00
Diana Carvalho
af6d73a540 fix: Add RecoverableError
--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 17:02:44 +00:00
Diana Carvalho
bab5caa6f8 feat: Add EncodingError
Change method signatures to expect it and raise it where it makes sense

--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 17:00:52 +00:00
Diana Carvalho
38b8bb0e78 feat: Simplify StrategyEncoders and RouterEncoder
No more SingleSwapStrategyEncoder or SequentialStrategyEncoder
No more batch routing (so no need for batch permits as well). If multiple solutions are found, return multiple Transactions

--- don't change below this line ---
ENG-4076 <#DTT#>
2025-01-17 16:21:26 +00:00
Diana Carvalho
6c6ba21894 feat: Add evm feature gate
- Move all evm code inside evm directory
- StrategyEncoder:
  - Kept StrategyEncoder trait but created a new one: EVMStrategyEncoder to implement encode_protocol_header (that is evm specific).
  - All StrategyEncoders implement both traits now
  - Renamed DefaultStrategySelector -> EVMStrategySelector
- RouterEncoder:
  - Created a RouterEncoder trait and a EVMRouterEncoder that implements it
- Moved utils inside evm directory as well
- Renamed config.json -> executor_addresses.json and moved it to a higher config directory
- Make alloy optional and dependent on the evm feature gate

--- don't change below this line ---
ENG-4075 <#DTT#>
2025-01-17 12:52:39 +00:00
Diana Carvalho
1d3ac22087 fix: Make executor_address a String instead of Address
--- don't change below this line ---
ENG-4075 <#DTT#>
2025-01-17 12:52:39 +00:00
Diana Carvalho
f5df1bbd87 feat: Add chain in config.json for the executor addresses
--- don't change below this line ---
ENG-4075 <#DTT#>
2025-01-17 12:52:39 +00:00
TAMARA LIPOWSKI
20fb01280c chore: add dummy test to make CI happy
Right now it complains and fails because no tests: `error: no tests to run`
2025-01-16 16:41:07 -05:00
TAMARA LIPOWSKI
f8e8a72c53 chore: fix clippy warnings and nightly fmt 2025-01-16 16:35:02 -05:00
Diana Carvalho
e93bf11a85 fix: Constrain new in SwapEncoder so it does not apply to trait objects 2025-01-16 17:18:11 +00:00
Diana Carvalho
30f2ac9f6b fix: Add new to SwapEncoder trait
Add executor_address in SwapEncoderBuilder::new and not in the builder pattern
2025-01-16 17:18:11 +00:00
Diana Carvalho
6d8cbcd80c feat: Add builder pattern and registry for SwapEncoders
Save swap executor addresses in a config file
2025-01-16 17:18:11 +00:00
Diana Carvalho
6f8bbd89a5 feat: Make check amount optional 2025-01-16 17:18:11 +00:00
Diana Carvalho
5a661ab6ca feat: Add Transaction as output of encoding 2025-01-16 17:18:11 +00:00
Diana Carvalho
f9f83b439f fix: Add expected_amount to Solution 2025-01-16 17:18:11 +00:00
Diana Carvalho
a25c56e667 fix: Simplify models. Delete Solution and rename Order->Solution 2025-01-16 17:18:11 +00:00
Diana Carvalho
68c5a914eb feat: Remove batch execute logic from StrategyEncoder
Add action_type and selector to StrategyEncoder
Rename SequentialExactInStrategyEncoder -> SequentialStrategyEncoder
2025-01-16 17:18:11 +00:00
Diana Carvalho
93410b4fe2 fix: TokenApprovalsManager should not implement ApprovalsManager
They should be separate.
ApprovalsManager is only for user approvals
2025-01-16 17:18:11 +00:00
Diana Carvalho
3e609c75ae feat: Support encoding only the pool swap
Create StraightToPoolStrategyEncoder
2025-01-16 17:18:11 +00:00
Diana Carvalho
4991883fc8 feat: ApprovalsManager trait
Make Permit2 and TokenApprovalsManager implement it.
This way in the RouternEncoder we can use either one (I'm not exactly sure what this would mean in the contract though)

I'm not sure I like this generalisation. The TokenApprovalsManager was made with a different purpose: to approve token allowances for the pools (like balancer and curve) for our router
2025-01-16 17:18:09 +00:00
Diana Carvalho
6e67875821 feat: Add StrategySelector
This way the user could be able to extend this easily
2025-01-16 17:17:52 +00:00
Diana Carvalho
647f697ea2 chore: Refactor models:
- Delete min_checked_amount and use check_amount instead
- Use Bytes and not Address in interfaces
- Move router_address from Solution to Order
2025-01-16 17:17:52 +00:00
Diana Carvalho
5d79da44f3 feat: Add permit2 draft 2025-01-16 17:17:52 +00:00
Diana Carvalho
fa462ee9f3 feat: Handle native actions 2025-01-16 17:17:52 +00:00
Diana Carvalho
36fe8f4b76 feat: Initial draft of encoding module 2025-01-16 17:17:50 +00:00
Diana Carvalho
1e54ea045e fix: Add temporary main function to lib.rs 2025-01-16 14:47:55 +00:00
Diana Carvalho
c27b253ef5 feat: Add Cargo files, CI, configs and README 2025-01-16 12:53:28 +00:00