chore: merge main
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
## [0.32.0](https://github.com/propeller-heads/tycho-execution/compare/0.31.0...0.32.0) (2025-02-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* Accept any struct that implements Into<ProtocolComponent> in Swap ([cb14022](https://github.com/propeller-heads/tycho-execution/commit/cb140226814add4f8141f3ad36784379a80d656c))
|
||||||
|
|
||||||
## [0.31.0](https://github.com/propeller-heads/tycho-execution/compare/0.30.1...0.31.0) (2025-02-05)
|
## [0.31.0](https://github.com/propeller-heads/tycho-execution/compare/0.30.1...0.31.0) (2025-02-05)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -4231,7 +4231,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tycho-execution"
|
name = "tycho-execution"
|
||||||
version = "0.31.0"
|
version = "0.32.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"alloy",
|
"alloy",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "tycho-execution"
|
name = "tycho-execution"
|
||||||
version = "0.31.0"
|
version = "0.32.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -59,6 +59,17 @@ pub struct Swap {
|
|||||||
pub split: f64,
|
pub split: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Swap {
|
||||||
|
pub fn new<T: Into<ProtocolComponent>>(
|
||||||
|
component: T,
|
||||||
|
token_in: Bytes,
|
||||||
|
token_out: Bytes,
|
||||||
|
split: f64,
|
||||||
|
) -> Self {
|
||||||
|
Self { component: component.into(), token_in, token_out, split }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Transaction {
|
pub struct Transaction {
|
||||||
// Address of the contract to call with the calldata
|
// Address of the contract to call with the calldata
|
||||||
@@ -131,3 +142,42 @@ impl Chain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
struct MockProtocolComponent {
|
||||||
|
id: String,
|
||||||
|
protocol_system: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<MockProtocolComponent> for ProtocolComponent {
|
||||||
|
fn from(component: MockProtocolComponent) -> Self {
|
||||||
|
ProtocolComponent {
|
||||||
|
id: component.id,
|
||||||
|
protocol_system: component.protocol_system,
|
||||||
|
tokens: vec![],
|
||||||
|
protocol_type_name: "".to_string(),
|
||||||
|
chain: Default::default(),
|
||||||
|
contract_ids: vec![],
|
||||||
|
static_attributes: Default::default(),
|
||||||
|
change: Default::default(),
|
||||||
|
creation_tx: Default::default(),
|
||||||
|
created_at: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_swap_new() {
|
||||||
|
let component = MockProtocolComponent {
|
||||||
|
id: "i-am-an-id".to_string(),
|
||||||
|
protocol_system: "uniswap_v2".to_string(),
|
||||||
|
};
|
||||||
|
let swap = Swap::new(component, Bytes::from("0x12"), Bytes::from("34"), 0.5);
|
||||||
|
assert_eq!(swap.token_in, Bytes::from("0x12"));
|
||||||
|
assert_eq!(swap.token_out, Bytes::from("0x34"));
|
||||||
|
assert_eq!(swap.component.protocol_system, "uniswap_v2");
|
||||||
|
assert_eq!(swap.component.id, "i-am-an-id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user