From 702b4c860ca177fe59e3240f1a49deb663cbc21b Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Fri, 20 Sep 2024 00:55:03 -0400 Subject: [PATCH] Add dummy fee values to the scheduler --- processor/ethereum/src/rpc.rs | 9 +++------ processor/ethereum/src/scheduler.rs | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/processor/ethereum/src/rpc.rs b/processor/ethereum/src/rpc.rs index 0769c5c3..1eaa4988 100644 --- a/processor/ethereum/src/rpc.rs +++ b/processor/ethereum/src/rpc.rs @@ -18,7 +18,7 @@ use ethereum_erc20::{TopLevelTransfer, Erc20}; use ethereum_router::{Coin as EthereumCoin, InInstruction as EthereumInInstruction, Router}; use crate::{ - TOKENS, InitialSeraiKey, + TOKENS, ETHER_DUST, DAI_DUST, InitialSeraiKey, block::{Epoch, FullEpoch}, }; @@ -207,12 +207,9 @@ impl ScannerFeed for Rpc { fn dust(coin: Coin) -> Amount { assert_eq!(coin.network(), NetworkId::Ethereum); - #[allow(clippy::inconsistent_digit_grouping)] match coin { - // 5 USD if Ether is ~3300 USD - Coin::Ether => Amount(1_500_00), - // 5 DAI - Coin::Dai => Amount(5_000_000_00), + Coin::Ether => ETHER_DUST, + Coin::Dai => DAI_DUST, _ => unreachable!(), } } diff --git a/processor/ethereum/src/scheduler.rs b/processor/ethereum/src/scheduler.rs index f4c31ec6..e8a437c1 100644 --- a/processor/ethereum/src/scheduler.rs +++ b/processor/ethereum/src/scheduler.rs @@ -77,7 +77,17 @@ impl smart_contract_scheduler::SmartContract> for SmartContract { let Some(outs) = outs.remove(&coin) else { continue }; assert!(!outs.is_empty()); - let fee_per_gas: U256 = todo!("TODO"); + let fee_per_gas = match coin { + // 10 gwei + Coin::Ether => { + U256::try_from(10u64).unwrap() * alloy_core::primitives::utils::Unit::GWEI.wei() + } + // 0.0003 DAI + Coin::Dai => { + U256::try_from(30u64).unwrap() * alloy_core::primitives::utils::Unit::TWEI.wei() + } + _ => unreachable!(), + }; // The gas required to perform any interaction with the Router. const BASE_GAS: u32 = 0; // TODO @@ -96,7 +106,7 @@ impl smart_contract_scheduler::SmartContract> for SmartContract { let mut batches = vec![vec![]]; let mut current_gas = BASE_GAS; for out in outs { - let payment_gas = match out.0 { + let payment_gas = match &out.0 { Address::Address(_) => ADDRESS_PAYMENT_GAS, Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(), }; @@ -110,14 +120,14 @@ impl smart_contract_scheduler::SmartContract> for SmartContract { } // Push each batch onto the result - for outs in batches { + for mut outs in batches { let mut total_gas = 0; let base_gas_per_payment = BASE_GAS.div_ceil(u32::try_from(outs.len()).unwrap()); // Deduce the fee from each out for out in &mut outs { let payment_gas = base_gas_per_payment + - match out.0 { + match &out.0 { Address::Address(_) => ADDRESS_PAYMENT_GAS, Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(), };