test: remove partial_fill_offset from MockRFQState
This commit is contained in:
@@ -868,7 +868,7 @@ impl SwapEncoder for HashflowSwapEncoder {
|
|||||||
let hashflow_router_address = config
|
let hashflow_router_address = config
|
||||||
.get("hashflow_router_address")
|
.get("hashflow_router_address")
|
||||||
.ok_or(EncodingError::FatalError(
|
.ok_or(EncodingError::FatalError(
|
||||||
"Missing bebop settlement address in config".to_string(),
|
"Missing hashflow router address in config".to_string(),
|
||||||
))?
|
))?
|
||||||
.to_string();
|
.to_string();
|
||||||
let native_token_address = chain.native_token().address;
|
let native_token_address = chain.native_token().address;
|
||||||
@@ -2123,8 +2123,17 @@ mod tests {
|
|||||||
};
|
};
|
||||||
let bebop_state = MockRFQState {
|
let bebop_state = MockRFQState {
|
||||||
quote_amount_out,
|
quote_amount_out,
|
||||||
quote_data: vec![("calldata".to_string(), bebop_calldata.clone())],
|
quote_data: HashMap::from([
|
||||||
quote_partial_fill_offset: partial_fill_offset,
|
("calldata".to_string(), bebop_calldata.clone()),
|
||||||
|
(
|
||||||
|
"partial_fill_offset".to_string(),
|
||||||
|
Bytes::from(
|
||||||
|
partial_fill_offset
|
||||||
|
.to_be_bytes()
|
||||||
|
.to_vec(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let token_in = Bytes::from("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); // USDC
|
let token_in = Bytes::from("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); // USDC
|
||||||
@@ -2232,7 +2241,6 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_encode_hashflow_single_with_protocol_state() {
|
fn test_encode_hashflow_single_with_protocol_state() {
|
||||||
// 3000 USDC -> 1 WETH using a mocked RFQ state to get a quote
|
// 3000 USDC -> 1 WETH using a mocked RFQ state to get a quote
|
||||||
let partial_fill_offset = 12u64;
|
|
||||||
let quote_amount_out = BigUint::from_str("1000000000000000000").unwrap();
|
let quote_amount_out = BigUint::from_str("1000000000000000000").unwrap();
|
||||||
|
|
||||||
let hashflow_component = ProtocolComponent {
|
let hashflow_component = ProtocolComponent {
|
||||||
@@ -2295,8 +2303,9 @@ mod tests {
|
|||||||
let hashflow_calldata = Bytes::from(hashflow_quote_data_values);
|
let hashflow_calldata = Bytes::from(hashflow_quote_data_values);
|
||||||
let hashflow_state = MockRFQState {
|
let hashflow_state = MockRFQState {
|
||||||
quote_amount_out,
|
quote_amount_out,
|
||||||
quote_data: hashflow_quote_data,
|
quote_data: hashflow_quote_data
|
||||||
quote_partial_fill_offset: partial_fill_offset,
|
.into_iter()
|
||||||
|
.collect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let token_in = Bytes::from("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); // USDC
|
let token_in = Bytes::from("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"); // USDC
|
||||||
|
|||||||
@@ -17,8 +17,7 @@ use tycho_common::{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MockRFQState {
|
pub struct MockRFQState {
|
||||||
pub quote_amount_out: BigUint,
|
pub quote_amount_out: BigUint,
|
||||||
pub quote_data: Vec<(String, Bytes)>,
|
pub quote_data: HashMap<String, Bytes>,
|
||||||
pub quote_partial_fill_offset: u64,
|
|
||||||
}
|
}
|
||||||
impl ProtocolSim for MockRFQState {
|
impl ProtocolSim for MockRFQState {
|
||||||
fn fee(&self) -> f64 {
|
fn fee(&self) -> f64 {
|
||||||
@@ -82,25 +81,12 @@ impl IndicativelyPriced for MockRFQState {
|
|||||||
&self,
|
&self,
|
||||||
params: GetAmountOutParams,
|
params: GetAmountOutParams,
|
||||||
) -> Result<SignedQuote, SimulationError> {
|
) -> Result<SignedQuote, SimulationError> {
|
||||||
let mut quote_attributes: HashMap<String, Bytes> = HashMap::new();
|
|
||||||
for (attr, value) in &self.quote_data {
|
|
||||||
quote_attributes.insert(attr.clone(), value.clone());
|
|
||||||
}
|
|
||||||
quote_attributes.insert(
|
|
||||||
"partial_fill_offset".to_string(),
|
|
||||||
Bytes::from(
|
|
||||||
self.quote_partial_fill_offset
|
|
||||||
.to_be_bytes()
|
|
||||||
.to_vec(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(SignedQuote {
|
Ok(SignedQuote {
|
||||||
base_token: params.token_in,
|
base_token: params.token_in,
|
||||||
quote_token: params.token_out,
|
quote_token: params.token_out,
|
||||||
amount_in: params.amount_in,
|
amount_in: params.amount_in,
|
||||||
amount_out: self.quote_amount_out.clone(),
|
amount_out: self.quote_amount_out.clone(),
|
||||||
quote_attributes,
|
quote_attributes: self.quote_data.clone(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -653,8 +653,17 @@ fn test_uniswap_v3_bebop() {
|
|||||||
|
|
||||||
let bebop_state = MockRFQState {
|
let bebop_state = MockRFQState {
|
||||||
quote_amount_out,
|
quote_amount_out,
|
||||||
quote_data: vec![("calldata".to_string(), bebop_calldata)],
|
quote_data: HashMap::from([
|
||||||
quote_partial_fill_offset: partial_fill_offset,
|
("calldata".to_string(), bebop_calldata),
|
||||||
|
(
|
||||||
|
"partial_fill_offset".to_string(),
|
||||||
|
Bytes::from(
|
||||||
|
partial_fill_offset
|
||||||
|
.to_be_bytes()
|
||||||
|
.to_vec(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
};
|
};
|
||||||
|
|
||||||
let bebop_component = ProtocolComponent {
|
let bebop_component = ProtocolComponent {
|
||||||
@@ -719,7 +728,7 @@ fn test_hashflow() {
|
|||||||
|
|
||||||
let hashflow_state = MockRFQState {
|
let hashflow_state = MockRFQState {
|
||||||
quote_amount_out,
|
quote_amount_out,
|
||||||
quote_data: vec![
|
quote_data: HashMap::from([
|
||||||
(
|
(
|
||||||
"pool".to_string(),
|
"pool".to_string(),
|
||||||
Bytes::from_str("0x478eca1b93865dca0b9f325935eb123c8a4af011").unwrap(),
|
Bytes::from_str("0x478eca1b93865dca0b9f325935eb123c8a4af011").unwrap(),
|
||||||
@@ -763,8 +772,7 @@ fn test_hashflow() {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
("signature".to_string(), Bytes::from_str("0x6ddb3b21fe8509e274ddf46c55209cdbf30360944abbca6569ed6b26740d052f419964dcb5a3bdb98b4ed1fb3642a2760b8312118599a962251f7a8f73fe4fbe1c").unwrap()),
|
("signature".to_string(), Bytes::from_str("0x6ddb3b21fe8509e274ddf46c55209cdbf30360944abbca6569ed6b26740d052f419964dcb5a3bdb98b4ed1fb3642a2760b8312118599a962251f7a8f73fe4fbe1c").unwrap()),
|
||||||
],
|
]),
|
||||||
quote_partial_fill_offset: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let hashflow_component = ProtocolComponent {
|
let hashflow_component = ProtocolComponent {
|
||||||
@@ -851,7 +859,7 @@ fn test_uniswap_v3_hashflow() {
|
|||||||
|
|
||||||
let hashflow_state = MockRFQState {
|
let hashflow_state = MockRFQState {
|
||||||
quote_amount_out,
|
quote_amount_out,
|
||||||
quote_data: vec![
|
quote_data: HashMap::from([
|
||||||
(
|
(
|
||||||
"pool".to_string(),
|
"pool".to_string(),
|
||||||
Bytes::from_str("0x478eca1b93865dca0b9f325935eb123c8a4af011").unwrap(),
|
Bytes::from_str("0x478eca1b93865dca0b9f325935eb123c8a4af011").unwrap(),
|
||||||
@@ -895,8 +903,7 @@ fn test_uniswap_v3_hashflow() {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
),
|
),
|
||||||
("signature".to_string(), Bytes::from_str("0x6ddb3b21fe8509e274ddf46c55209cdbf30360944abbca6569ed6b26740d052f419964dcb5a3bdb98b4ed1fb3642a2760b8312118599a962251f7a8f73fe4fbe1c").unwrap()),
|
("signature".to_string(), Bytes::from_str("0x6ddb3b21fe8509e274ddf46c55209cdbf30360944abbca6569ed6b26740d052f419964dcb5a3bdb98b4ed1fb3642a2760b8312118599a962251f7a8f73fe4fbe1c").unwrap()),
|
||||||
],
|
]),
|
||||||
quote_partial_fill_offset: 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let hashflow_component = ProtocolComponent {
|
let hashflow_component = ProtocolComponent {
|
||||||
|
|||||||
Reference in New Issue
Block a user