diff --git a/README.md b/README.md index bc64ddd..52e8939 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ echo '' | tycho-encode -c /path/to/your/config.json Here's a complete example that encodes a swap from WETH to DAI using Uniswap V2: ```bash -echo '{"sender":"0x1234567890123456789012345678901234567890","receiver":"0x1234567890123456789012345678901234567890","given_token":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2","given_amount":"1000000000000000000","checked_token":"0x6B175474E89094C44Da98b954EedeAC495271d0F","exact_out":false,"slippage":0.01,"expected_amount":"1000000000000000000","check_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":1.0}],"direct_execution":true}' | tycho-encode ``` #### JSON Payload Structure: Solution struct @@ -62,7 +62,7 @@ The `Solution` struct is composed of the following fields: - `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 -- `check_amount`: The minimum acceptable output amount (accounting for slippage) +- `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 diff --git a/examples/quickstart/main.rs b/examples/quickstart/main.rs index f54f5e5..c2f534c 100644 --- a/examples/quickstart/main.rs +++ b/examples/quickstart/main.rs @@ -61,8 +61,8 @@ fn main() { given_token: weth.clone(), given_amount: BigUint::from_str("1_000000000000000000").expect("Failed to create amount"), checked_token: usdc.clone(), - exact_out: false, // it's an exact in solution - check_amount: None, // the amount out will not be checked in execution + exact_out: false, // it's an exact in solution + checked_amount: None, // the amount out will not be checked in execution swaps: vec![simple_swap], router_address, ..Default::default() diff --git a/src/bin/lib/cli.rs b/src/bin/lib/cli.rs index 8027b2a..60e13d3 100644 --- a/src/bin/lib/cli.rs +++ b/src/bin/lib/cli.rs @@ -14,7 +14,7 @@ pub use clap::Parser; /// "exact_out": false, /// "slippage": 0.01, /// "expected_amount": "123...", -/// "check_amount": "123...", +/// "checked_amount": "123...", /// "swaps": [{ /// "component": { /// "id": "...", diff --git a/src/encoding/evm/strategy_encoder/strategy_encoders.rs b/src/encoding/evm/strategy_encoder/strategy_encoders.rs index 01959f0..4e8193f 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoders.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoders.rs @@ -279,7 +279,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder { &solution.given_amount, )?; let mut min_amount_out = solution - .check_amount + .checked_amount .unwrap_or(BigUint::ZERO); if let (Some(expected_amount), Some(slippage)) = @@ -534,7 +534,7 @@ mod tests { given_amount: BigUint::from(1000000000000000000u64), expected_amount: Some(BigUint::from(1000000000000000000u64)), checked_token: token_out, - check_amount: None, + checked_amount: None, sender: Bytes::from_str("0x0000000000000000000000000000000000000000").unwrap(), // The receiver was generated with `makeAddr("bob") using forge` receiver: Bytes::from_str("0x1d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e").unwrap(), @@ -596,7 +596,7 @@ mod tests { fn test_split_swap_strategy_encoder_simple_route( #[case] expected_amount: Option, #[case] slippage: Option, - #[case] check_amount: Option, + #[case] checked_amount: Option, #[case] expected_min_amount: U256, ) { // Performs a single swap from WETH to DAI on a USV2 pool @@ -628,7 +628,7 @@ mod tests { checked_token: dai, expected_amount, slippage, - check_amount, + checked_amount, sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), router_address: Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), @@ -728,7 +728,7 @@ mod tests { given_amount: BigUint::from_str("1_000000000000000000").unwrap(), checked_token: dai, expected_amount: Some(BigUint::from_str("3_000_000000000000000000").unwrap()), - check_amount: None, + checked_amount: None, sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), router_address: Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), @@ -776,7 +776,7 @@ mod tests { given_amount: BigUint::from_str("3_000_000000000000000000").unwrap(), checked_token: eth(), expected_amount: Some(BigUint::from_str("1_000000000000000000").unwrap()), - check_amount: None, + checked_amount: None, sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), router_address: Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), @@ -865,7 +865,7 @@ mod tests { given_amount: BigUint::from_str("1_000000000000000000").unwrap(), checked_token: usdc, expected_amount: Some(BigUint::from_str("3_000_000000").unwrap()), - check_amount: None, + checked_amount: None, sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(), router_address: Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap(), diff --git a/src/encoding/evm/tycho_encoder.rs b/src/encoding/evm/tycho_encoder.rs index bc52fca..d20f4ad 100644 --- a/src/encoding/evm/tycho_encoder.rs +++ b/src/encoding/evm/tycho_encoder.rs @@ -269,7 +269,7 @@ mod tests { exact_out: false, given_token: eth(), checked_token: dai(), - check_amount: None, + checked_amount: None, swaps: vec![swap], native_action: Some(NativeAction::Wrap), ..Default::default() @@ -383,7 +383,7 @@ mod tests { let solution = Solution { exact_out: false, checked_token: eth(), - check_amount: None, + checked_amount: None, swaps: vec![swap], native_action: Some(NativeAction::Unwrap), ..Default::default() diff --git a/src/encoding/models.rs b/src/encoding/models.rs index f7dd483..3bf1151 100644 --- a/src/encoding/models.rs +++ b/src/encoding/models.rs @@ -38,7 +38,7 @@ pub struct Solution { /// Minimum amount to be checked for the solution to be valid. /// If not set, the check will not be performed. #[serde(with = "biguint_string_option")] - pub check_amount: Option, + pub checked_amount: Option, /// List of swaps to fulfill the solution. pub swaps: Vec, /// Address of the router contract to be used for the swaps.