Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/porto-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pub struct Quote {
pub intent: Intent,
pub ttl: u64, // Time-to-live prevents stale quotes
pub signature: Signature, // Relay commitment to pricing
pub eth_price: U256, // Exchange rate at quote time
pub native_price: U256, // Exchange rate at quote time
pub native_fee_estimate: FeeEstimate,
}
```
Expand Down
14 changes: 7 additions & 7 deletions src/rpc/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ impl Relay {
self.inner.price_oracle.native_conversion_rate(token_uid.clone(), native_uid.clone());

// Execute all futures in parallel and handle errors
let (assets_response, fee_history, eth_price) = try_join!(
let (assets_response, fee_history, native_price) = try_join!(
async { user_balance_fut.await.map_err(RelayError::internal) },
async { fee_history_fut.await.map_err(RelayError::from) },
async { Ok(native_price_fut.await) }
Expand All @@ -402,19 +402,19 @@ impl Relay {
%chain_id,
fee_token = ?token,
?fee_history,
?eth_price,
?native_price,
orchestrator_version = ?orchestrator.version(),
"Got fee parameters"
);

let native_fee_estimate = chain.fee_config().estimate_eip1559_fees(&fee_history);

let Some(eth_price) = eth_price else {
let Some(native_price) = native_price else {
return Err(QuoteError::UnavailablePrice(token.address).into());
};
let payment_per_gas = (native_fee_estimate.max_fee_per_gas as f64
* 10u128.pow(token.decimals as u32) as f64)
/ f64::from(eth_price);
/ f64::from(native_price);

// fill intent - use the appropriate version based on orchestrator
let mut intent_to_sign = Intent::for_orchestrator(
Expand Down Expand Up @@ -556,13 +556,13 @@ impl Relay {

let extra_fee_native = extra_fee_info.extra_fee();
let extra_payment =
extra_fee_native * U256::from(10u128.pow(token.decimals as u32)) / eth_price;
extra_fee_native * U256::from(10u128.pow(token.decimals as u32)) / native_price;

debug!(
chain_id = %chain.id(),
%extra_payment,
%extra_fee_native,
%eth_price,
%native_price,
"Calculated extra payment"
);

Expand All @@ -586,7 +586,7 @@ impl Relay {
payment_token_decimals: token.decimals,
intent: intent_to_sign,
extra_payment,
eth_price,
native_price,
tx_gas: gas_estimate.tx,
native_fee_estimate,
authorization_address: context.stored_authorization.as_ref().map(|auth| auth.address),
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ mod tests {
chain_id: Default::default(),
extra_payment: Default::default(),
payment_token_decimals: Default::default(),
eth_price: Default::default(),
native_price: Default::default(),
tx_gas: Default::default(),
native_fee_estimate: Eip1559Estimation {
max_fee_per_gas: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl RelayTransaction {
+ (U256::from(gas_limit)
* U256::from(fees.max_fee_per_gas)
* U256::from(10u128.pow(quote.payment_token_decimals as u32)))
.div_ceil(quote.eth_price))
.div_ceil(quote.native_price))
.min(intent.total_payment_max_amount());

intent = intent
Expand Down
4 changes: 2 additions & 2 deletions src/types/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ pub struct Quote {
pub intent: Intent,
/// Extra payment for e.g L1 DA fee that is paid on top of the execution gas.
pub extra_payment: U256,
/// Price of the ETH in the [`Intent::paymentToken`] in wei.
pub eth_price: U256,
/// Price of the native token in the [`Intent::paymentToken`] in wei.
pub native_price: U256,
/// Decimals of the [`Intent::paymentToken`].
pub payment_token_decimals: u8,
/// The recommended gas limit for the transaction.
Expand Down
2 changes: 1 addition & 1 deletion tests/storage/roundtrip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl Fixtures {
chain_id: r_u64,
intent,
extra_payment: r_u256,
eth_price: r_u256,
native_price: r_u256,
payment_token_decimals: 1,
tx_gas: r_u64,
native_fee_estimate: r_fee,
Expand Down