|
1 | 1 | use { |
2 | | - alloy::primitives::{Address, Bytes, U256, address}, |
| 2 | + alloy::{ |
| 3 | + primitives::{Address, Bytes, U256, address}, |
| 4 | + signers::{SignerSync, local::PrivateKeySigner}, |
| 5 | + }, |
3 | 6 | chrono::Utc, |
4 | 7 | contracts::{ |
5 | 8 | ERC20, |
6 | | - alloy::{ILiquoriceSettlement, InstanceExt}, |
| 9 | + alloy::{InstanceExt, LiquoriceSettlement}, |
7 | 10 | }, |
8 | 11 | driver::infra, |
9 | 12 | e2e::{ |
@@ -114,9 +117,10 @@ async fn liquidity_source_notification(web3: Web3) { |
114 | 117 |
|
115 | 118 | // Liquorice settlement contract through which we will trade with the |
116 | 119 | // `liquorice_maker` |
117 | | - let liquorice_settlement = ILiquoriceSettlement::Instance::deployed(&web3.alloy) |
| 120 | + let liquorice_settlement = LiquoriceSettlement::Instance::deployed(&web3.alloy) |
118 | 121 | .await |
119 | 122 | .unwrap(); |
| 123 | + |
120 | 124 | let liquorice_balance_manager_address = liquorice_settlement |
121 | 125 | .BALANCE_MANAGER() |
122 | 126 | .call() |
@@ -223,54 +227,46 @@ http-timeout = "10s" |
223 | 227 | // Prepare Liquorice solution |
224 | 228 |
|
225 | 229 | // Create Liquorice order |
226 | | - let liquorice_order = api::liquorice::onchain::order::Single { |
227 | | - rfq_id: "c99d2e3f-702b-49c9-8bb8-43775770f2f3".to_string(), |
| 230 | + let liquorice_order = LiquoriceSettlement::ILiquoriceSettlement::Single { |
| 231 | + rfqId: "c99d2e3f-702b-49c9-8bb8-43775770f2f3".to_string(), |
228 | 232 | nonce: U256::from(0), |
229 | 233 | trader: onchain.contracts().gp_settlement.address().into_alloy(), |
230 | | - effective_trader: onchain.contracts().gp_settlement.address().into_alloy(), |
231 | | - base_token: token_usdc.address().into_alloy(), |
232 | | - quote_token: token_usdt.address().into_alloy(), |
233 | | - base_token_amount: trade_amount.into_alloy(), |
234 | | - quote_token_amount: trade_amount.into_alloy(), |
235 | | - min_fill_amount: U256::from(1), |
236 | | - quote_expiry: U256::from(Utc::now().timestamp() as u64 + 10), |
| 234 | + effectiveTrader: onchain.contracts().gp_settlement.address().into_alloy(), |
| 235 | + baseToken: token_usdc.address().into_alloy(), |
| 236 | + quoteToken: token_usdt.address().into_alloy(), |
| 237 | + baseTokenAmount: trade_amount.into_alloy(), |
| 238 | + quoteTokenAmount: trade_amount.into_alloy(), |
| 239 | + minFillAmount: U256::from(1), |
| 240 | + quoteExpiry: U256::from(Utc::now().timestamp() as u64 + 10), |
237 | 241 | recipient: liquorice_maker.address().into_alloy(), |
238 | 242 | }; |
239 | 243 |
|
240 | 244 | // Create calldata |
241 | 245 | let liquorice_solution_calldata = { |
| 246 | + let liquorice_order_hash = liquorice_settlement |
| 247 | + .hashSingleOrder(liquorice_order.clone()) |
| 248 | + .call() |
| 249 | + .await |
| 250 | + .unwrap(); |
| 251 | + |
242 | 252 | // Create Liquorice order signature |
243 | | - let liquorice_order_signature = liquorice_order.sign( |
244 | | - &api::liquorice::onchain::DomainSeparator::new(1, *liquorice_settlement.address()), |
245 | | - liquorice_order.hash(), |
246 | | - &liquorice_maker, |
247 | | - ); |
| 253 | + |
| 254 | + let signer = PrivateKeySigner::from_slice(liquorice_maker.private_key()).unwrap(); |
| 255 | + let liquorice_order_signature = signer.sign_hash_sync(&liquorice_order_hash).unwrap(); |
248 | 256 |
|
249 | 257 | // Create Liquorice settlement calldata |
250 | 258 | liquorice_settlement |
251 | 259 | .settleSingle( |
252 | 260 | liquorice_maker.address().into_alloy(), |
253 | | - ILiquoriceSettlement::ILiquoriceSettlement::Single { |
254 | | - rfqId: liquorice_order.rfq_id.clone(), |
255 | | - nonce: liquorice_order.nonce, |
256 | | - trader: liquorice_order.trader, |
257 | | - effectiveTrader: liquorice_order.effective_trader, |
258 | | - baseToken: liquorice_order.base_token, |
259 | | - quoteToken: liquorice_order.quote_token, |
260 | | - baseTokenAmount: liquorice_order.base_token_amount, |
261 | | - quoteTokenAmount: liquorice_order.quote_token_amount, |
262 | | - minFillAmount: liquorice_order.min_fill_amount, |
263 | | - quoteExpiry: liquorice_order.quote_expiry, |
264 | | - recipient: liquorice_order.recipient, |
265 | | - }, |
266 | | - ILiquoriceSettlement::Signature::TypedSignature { |
267 | | - signatureType: liquorice_order_signature.signature_type, |
268 | | - transferCommand: liquorice_order_signature.transfer_command, |
269 | | - signatureBytes: liquorice_order_signature.signature.as_bytes().into(), |
| 261 | + liquorice_order.clone(), |
| 262 | + LiquoriceSettlement::Signature::TypedSignature { |
| 263 | + signatureType: 3, // EIP712 |
| 264 | + transferCommand: 1, // SIMPLE_TRANSFER |
| 265 | + signatureBytes: liquorice_order_signature.as_bytes().into(), |
270 | 266 | }, |
271 | | - liquorice_order.quote_token_amount, |
| 267 | + liquorice_order.quoteTokenAmount, |
272 | 268 | // Taker signature is not used in this use case |
273 | | - ILiquoriceSettlement::Signature::TypedSignature { |
| 269 | + LiquoriceSettlement::Signature::TypedSignature { |
274 | 270 | signatureType: 0, |
275 | 271 | transferCommand: 0, |
276 | 272 | signatureBytes: Bytes::from(vec![0u8; 65]), |
@@ -345,5 +341,5 @@ http-timeout = "10s" |
345 | 341 | assert!(matches!(notification.content, Content::Settle(Settle { |
346 | 342 | rfq_ids, |
347 | 343 | .. |
348 | | - }) if rfq_ids.contains(&liquorice_order.rfq_id))); |
| 344 | + }) if rfq_ids.contains(&liquorice_order.rfqId))); |
349 | 345 | } |
0 commit comments