feat(curve): Add integration test
Bonus fix of a shameful typo :| --- don't change below this line --- ENG-4306 Took 21 minutes
This commit is contained in:
@@ -1773,4 +1773,62 @@ mod tests {
|
||||
assert_eq!(hex_calldata[1288..], expected_swaps);
|
||||
println!("{}", hex_calldata);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_encoding_strategy_curve() {
|
||||
// UWU ──(curve 2 crypto pool)──> WETH
|
||||
|
||||
let token_in = Bytes::from("0x55C08ca52497e2f1534B59E2917BF524D4765257"); // UWU
|
||||
let token_out = Bytes::from("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); // USDC
|
||||
|
||||
let static_attributes = HashMap::from([(
|
||||
"factory".to_string(),
|
||||
Bytes::from("0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f"),
|
||||
)]);
|
||||
|
||||
let component = ProtocolComponent {
|
||||
id: String::from("0x77146B0a1d08B6844376dF6d9da99bA7F1b19e71"),
|
||||
protocol_system: String::from("vm:curve"),
|
||||
static_attributes,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let swap = Swap {
|
||||
component,
|
||||
token_in: token_in.clone(),
|
||||
token_out: token_out.clone(),
|
||||
split: 0f64,
|
||||
};
|
||||
|
||||
let swap_encoder_registry = get_swap_encoder_registry();
|
||||
let encoder = SplitSwapStrategyEncoder::new(
|
||||
eth_chain(),
|
||||
swap_encoder_registry,
|
||||
None,
|
||||
Some(Bytes::from_str("0x3Ede3eCa2a72B3aeCC820E955B36f38437D01395").unwrap()),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let solution = Solution {
|
||||
exact_out: false,
|
||||
given_token: token_in,
|
||||
given_amount: BigUint::from_str("1_000000000000000000").unwrap(),
|
||||
checked_token: token_out,
|
||||
expected_amount: None,
|
||||
checked_amount: Some(BigUint::from_str("1").unwrap()),
|
||||
slippage: None,
|
||||
// Alice
|
||||
sender: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
||||
receiver: Bytes::from_str("0xcd09f75E2BF2A4d11F3AB23f1389FcC1621c0cc2").unwrap(),
|
||||
swaps: vec![swap],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let (calldata, _) = encoder
|
||||
.encode_strategy(solution)
|
||||
.unwrap();
|
||||
|
||||
let hex_calldata = encode(&calldata);
|
||||
println!("{}", hex_calldata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ impl CurveSwapEncoder {
|
||||
// Tricrypto factory
|
||||
"0x0c0e5f2fF0ff18a3be9b835635039256dC4B4963" => Ok(U8::from(3)),
|
||||
// Twocrypto factory
|
||||
"0x98ee851a00abee0d95d08cf4ca2bdce32aeaaf7f" => Ok(U8::from(2)),
|
||||
"0x98EE851a00abeE0d95D08cF4CA2BdCE32aeaAF7F" => Ok(U8::from(2)),
|
||||
// StableSwap factory
|
||||
"0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d" => Ok(U8::from(1)),
|
||||
_ => Err(EncodingError::FatalError(format!(
|
||||
@@ -1131,10 +1131,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_curve_encode_factory() {
|
||||
let mut static_attributes: HashMap<String, Bytes> = HashMap::new();
|
||||
static_attributes.insert(
|
||||
"factory".into(),
|
||||
Bytes::from_str("0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf").unwrap(),
|
||||
);
|
||||
static_attributes
|
||||
.insert("factory".into(), Bytes::from("0x6A8cbed756804B16E05E741eDaBd5cB544AE21bf"));
|
||||
let curve_pool = ProtocolComponent {
|
||||
id: String::from("0x02950460E2b9529D0E00284A5fA2d7bDF3fA4d72"),
|
||||
protocol_system: String::from("vm:curve"),
|
||||
|
||||
Reference in New Issue
Block a user