mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-25 21:19:35 +00:00
Add dummy fee values to the scheduler
This commit is contained in:
parent
bc1bbf9951
commit
702b4c860c
2 changed files with 17 additions and 10 deletions
|
@ -18,7 +18,7 @@ use ethereum_erc20::{TopLevelTransfer, Erc20};
|
||||||
use ethereum_router::{Coin as EthereumCoin, InInstruction as EthereumInInstruction, Router};
|
use ethereum_router::{Coin as EthereumCoin, InInstruction as EthereumInInstruction, Router};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
TOKENS, InitialSeraiKey,
|
TOKENS, ETHER_DUST, DAI_DUST, InitialSeraiKey,
|
||||||
block::{Epoch, FullEpoch},
|
block::{Epoch, FullEpoch},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -207,12 +207,9 @@ impl<D: Db> ScannerFeed for Rpc<D> {
|
||||||
|
|
||||||
fn dust(coin: Coin) -> Amount {
|
fn dust(coin: Coin) -> Amount {
|
||||||
assert_eq!(coin.network(), NetworkId::Ethereum);
|
assert_eq!(coin.network(), NetworkId::Ethereum);
|
||||||
#[allow(clippy::inconsistent_digit_grouping)]
|
|
||||||
match coin {
|
match coin {
|
||||||
// 5 USD if Ether is ~3300 USD
|
Coin::Ether => ETHER_DUST,
|
||||||
Coin::Ether => Amount(1_500_00),
|
Coin::Dai => DAI_DUST,
|
||||||
// 5 DAI
|
|
||||||
Coin::Dai => Amount(5_000_000_00),
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,17 @@ impl<D: Db> smart_contract_scheduler::SmartContract<Rpc<D>> for SmartContract {
|
||||||
let Some(outs) = outs.remove(&coin) else { continue };
|
let Some(outs) = outs.remove(&coin) else { continue };
|
||||||
assert!(!outs.is_empty());
|
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.
|
// The gas required to perform any interaction with the Router.
|
||||||
const BASE_GAS: u32 = 0; // TODO
|
const BASE_GAS: u32 = 0; // TODO
|
||||||
|
@ -96,7 +106,7 @@ impl<D: Db> smart_contract_scheduler::SmartContract<Rpc<D>> for SmartContract {
|
||||||
let mut batches = vec![vec![]];
|
let mut batches = vec![vec![]];
|
||||||
let mut current_gas = BASE_GAS;
|
let mut current_gas = BASE_GAS;
|
||||||
for out in outs {
|
for out in outs {
|
||||||
let payment_gas = match out.0 {
|
let payment_gas = match &out.0 {
|
||||||
Address::Address(_) => ADDRESS_PAYMENT_GAS,
|
Address::Address(_) => ADDRESS_PAYMENT_GAS,
|
||||||
Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(),
|
Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(),
|
||||||
};
|
};
|
||||||
|
@ -110,14 +120,14 @@ impl<D: Db> smart_contract_scheduler::SmartContract<Rpc<D>> for SmartContract {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push each batch onto the result
|
// Push each batch onto the result
|
||||||
for outs in batches {
|
for mut outs in batches {
|
||||||
let mut total_gas = 0;
|
let mut total_gas = 0;
|
||||||
|
|
||||||
let base_gas_per_payment = BASE_GAS.div_ceil(u32::try_from(outs.len()).unwrap());
|
let base_gas_per_payment = BASE_GAS.div_ceil(u32::try_from(outs.len()).unwrap());
|
||||||
// Deduce the fee from each out
|
// Deduce the fee from each out
|
||||||
for out in &mut outs {
|
for out in &mut outs {
|
||||||
let payment_gas = base_gas_per_payment +
|
let payment_gas = base_gas_per_payment +
|
||||||
match out.0 {
|
match &out.0 {
|
||||||
Address::Address(_) => ADDRESS_PAYMENT_GAS,
|
Address::Address(_) => ADDRESS_PAYMENT_GAS,
|
||||||
Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(),
|
Address::Contract(deployment) => CONTRACT_PAYMENT_GAS + deployment.gas_limit(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue