feat: Create a EVMEncoderBuilder
- It has two three methods to be created: - new: where the user can pass any custom StrategyEncoder - tycho_router: where the default SplitSwapStrategyEncoder with Tycho Router will be used - direct_execution: where the user can encode only the execution data and integrate this into their workflow. - This replaces StrategyEncoderRegistry - EVMTychoEncoder holds directly the StrategyEncoder and not the registry (per one init of the EVMTychoEncoder there is only one possible StrategyEncoder) - Update quickstart - Update bin (add subcommands to bin to create a different instance of EVMEncoderBuilder) --- don't change below this line --- ENG-4246 Took 33 minutes Took 38 seconds Took 38 seconds
This commit is contained in:
48
README.md
48
README.md
@@ -24,30 +24,46 @@ cargo build --release
|
||||
cargo install --path .
|
||||
```
|
||||
|
||||
After installation, the `tycho-encode` command will be available to use from any directory in your terminal. The command
|
||||
accepts the following options:
|
||||
After installation, the `tycho-encode` command will be available to use from any directory in your terminal.
|
||||
|
||||
### Commands
|
||||
|
||||
The command lets you choose the encoding strategy to be used. The available strategies are:
|
||||
|
||||
#### Tycho Router
|
||||
|
||||
`tycho-router`: Encodes a transaction using the Tycho Router encoding strategy. Requires a private key for signing
|
||||
Permit2.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
echo '<solution_payload>' | tycho-encode tycho-router -p 0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234
|
||||
```
|
||||
|
||||
#### Direct execution
|
||||
|
||||
`direct-execution`: Encodes a transaction using the direct execution encoding strategy. Does not require a private key.
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
echo '<solution_payload>' | tycho-encode direct-execution
|
||||
```
|
||||
|
||||
### Encoding Transactions
|
||||
|
||||
The commands accept the following options:
|
||||
|
||||
- `-c`: Path to the executor addresses configuration file (defaults to `src/encoding/config/executor_addresses.json`)
|
||||
- `-p`: Private key for signing approvals (required when direct_execution is false)
|
||||
|
||||
### Encoding Transactions
|
||||
|
||||
To encode a transaction, you can pipe a JSON payload to the binary:
|
||||
|
||||
```bash
|
||||
# Using default config path
|
||||
echo '<solution_payload>' | tycho-encode
|
||||
|
||||
# Using custom config path
|
||||
echo '<solution_payload>' | tycho-encode -c /path/to/your/config.json
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
Here's a complete example that encodes a swap from WETH to DAI using Uniswap V2:
|
||||
Here's a complete example that encodes a swap from WETH to DAI using Uniswap V2 and the Tycho Router strategy:
|
||||
|
||||
```bash
|
||||
echo '{"sender":"0x1234567890123456789012345678901234567890","receiver":"0x1234567890123456789012345678901234567890","given_token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","given_amount":"1000000000000000000","checked_token":"0x6B175474E89094C44Da98b954EedeAC495271d0F","exact_out":false,"slippage":0.01,"expected_amount":"1000000000000000000","checked_amount":"990000000000000000","router_address":"0xaa820C29648D5EA543d712cC928377Bd7206a0E7","swaps":[{"component":{"id":"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640","protocol_system":"uniswap_v2","protocol_type_name":"UniswapV2Pool","chain":"ethereum","tokens":["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],"contract_ids":["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"],"static_attributes":{"factory":"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"},"change":"Update","creation_tx":"0x0000000000000000000000000000000000000000000000000000000000000000","created_at":"2024-02-28T12:00:00"},"token_in":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","token_out":"0x6B175474E89094C44Da98b954EedeAC495271d0F","split":1.0}],"direct_execution":true}' | tycho-encode
|
||||
echo '{"sender":"0x1234567890123456789012345678901234567890","receiver":"0x1234567890123456789012345678901234567890","given_token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","given_amount":"1000000000000000000","checked_token":"0x6B175474E89094C44Da98b954EedeAC495271d0F","exact_out":false,"slippage":0.01,"expected_amount":"1000000000000000000","checked_amount":"990000000000000000","router_address":"0xaa820C29648D5EA543d712cC928377Bd7206a0E7","swaps":[{"component":{"id":"0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640","protocol_system":"uniswap_v2","protocol_type_name":"UniswapV2Pool","chain":"ethereum","tokens":["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],"contract_ids":["0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D"],"static_attributes":{"factory":"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"},"change":"Update","creation_tx":"0x0000000000000000000000000000000000000000000000000000000000000000","created_at":"2024-02-28T12:00:00"},"token_in":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","token_out":"0x6B175474E89094C44Da98b954EedeAC495271d0F","split":0.0}],"direct_execution":true}' | tycho-encode tycho-router -p 0x123456789abcdef123456789abcdef123456789abcdef123456789abcdef1234
|
||||
```
|
||||
|
||||
#### JSON Payload Structure: Solution struct
|
||||
|
||||
Reference in New Issue
Block a user