semantic-release-bot 28bfe2e32a chore(release): 0.37.0 [skip ci]
## [0.37.0](https://github.com/propeller-heads/tycho-execution/compare/0.36.2...0.37.0) (2025-02-12)

### Features

* add callback ([ed90cb4](ed90cb4ef1))
* add new pair test ([7ca647f](7ca647f009))
* add router params ([e62c332](e62c332451))
* add test for UniswapV4Executor ([4599f07](4599f07df0))
* add univ4 executor ([cb4c8f4](cb4c8f4e51))
* handle amounts in unlockCallback ([b2097ca](b2097ca4a5))
* move encoding to test ([c264084](c264084783))
* support multi swap decoding ([d998c88](d998c88cfe))
* update solc and add V4Router into UniswapV4Executor ([bdd3daf](bdd3daffba))

### Bug Fixes

* _pay and msgSender ([d790682](d79068282a))
* add equality check, amountInOrOut check, update _decodeData ([b47cff3](b47cff3fc9))
* git submodules and strict equality check in v4 executor ([a8cc84d](a8cc84ddce))
* handle native token balance changes ([0c40e9e](0c40e9e979))
* reciever issue ([ae0b07b](ae0b07b2a4))
* remove executeActions wrapper, strict equality checks and rename swap return ([2371ab2](2371ab2a1f))
* remove extra _receiver and redundant asserts ([ff3209b](ff3209b1c8))
* rm callback fn ([1a36c33](1a36c33bc6))
* rm redundant transfer ([24d4e76](24d4e762a2))
2025-02-12 20:01:08 +00:00
2025-01-27 22:54:56 +05:30
2025-02-13 00:25:26 +05:30
2025-01-28 18:57:59 +05:30
2025-01-28 23:21:22 +05:30
2025-02-12 20:01:08 +00:00
2025-02-12 20:01:08 +00:00
2025-02-12 20:01:08 +00:00
2025-01-13 11:28:27 +00:00

Tycho Execution

img.png

Tycho Execution makes it easy to trade on different DEXs by handling the complex encoding for you. Instead of creating custom code for each DEX, you get a simple, ready-to-use tool that generates the necessary data to execute trades. It's designed to be safe, straightforward, and quick to set up, so anyone can start trading without extra effort.

Quickstart

To get started, have a look at our Quickstart example.

Bin Usage Guide

Installation

First, build and install the binary:

# Build the project
cargo build --release

# Install the binary to your system
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:

  • -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:

# 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:

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

JSON Payload Structure: Solution struct

The Solution struct is composed of the following fields:

  • sender: The address initiating the transaction
  • receiver: The address receiving the output tokens
  • given_token: The address of the input token (e.g., WETH)
  • given_amount: The amount of input tokens (in wei)
  • checked_token: The address of the output token (e.g., DAI)
  • exact_out: Boolean indicating if this is an exact output swap
  • slippage: The maximum allowed slippage (e.g., 0.01 for 1%)
  • expected_amount: The expected output amount
  • checked_amount: The minimum acceptable output amount (accounting for slippage)
  • swaps: Array of swap steps, each containing:
    • component: Details about the DEX/protocol being used
    • token_in: Input token address for this step
    • token_out: Output token address for this step
    • split: Proportion of tokens to route through this step (1.0 = 100%)
  • router_address: The address of the protocol's router contract
  • direct_execution: Boolean indicating if the transaction should be executed directly

Contract Analysis

We use Slither to detect any potential vulnerabilities in our contracts.

To run locally, simply install Slither in your conda env and run it inside the foundry directory.

conda create --name tycho-execution python=3.10
conda activate tycho-execution

pip install slither-analyzer
cd foundry
slither .
Description
No description provided
Readme 6 MiB
Languages
Rust 90.1%
JavaScript 5.9%
Python 3.6%
Solidity 0.4%