Skip to content

Commit

Permalink
pick: chore: add egress fee for token account rent #5315
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezs authored and dandanlen committed Oct 9, 2024
1 parent 8383ee8 commit 7ce0d5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions foreign-chains/solana/sol-prim/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub const MAX_TRANSACTION_LENGTH: usize = 1_232usize;
pub const MAX_COMPUTE_UNITS_PER_TRANSACTION: u32 = 1_400_000u32;
pub const MICROLAMPORTS_PER_LAMPORT: u32 = 1_000_000u32;
pub const LAMPORTS_PER_SIGNATURE: u64 = 5000u64;
pub const TOKEN_ACCOUNT_RENT: u64 = 2039280u64;

pub const NONCE_ACCOUNT_LENGTH: u64 = 80u64;

Expand Down
14 changes: 11 additions & 3 deletions state-chain/chains/src/sol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ pub mod transaction_builder;
pub use crate::assets::sol::Asset as SolAsset;
use crate::benchmarking_value::BenchmarkValue;
pub use sol_prim::{
consts::{LAMPORTS_PER_SIGNATURE, MAX_TRANSACTION_LENGTH, MICROLAMPORTS_PER_LAMPORT},
consts::{
LAMPORTS_PER_SIGNATURE, MAX_TRANSACTION_LENGTH, MICROLAMPORTS_PER_LAMPORT,
TOKEN_ACCOUNT_RENT,
},
pda::{Pda as DerivedAddressBuilder, PdaError as AddressDerivationError},
Address as SolAddress, Amount as SolAmount, ComputeLimit as SolComputeLimit, Digest as SolHash,
Signature as SolSignature, SlotNumber as SolBlockNumber,
Expand Down Expand Up @@ -182,14 +185,19 @@ impl FeeEstimationApi<Solana> for SolTrackedData {
},
);

LAMPORTS_PER_SIGNATURE.saturating_add(
let gas_fee = LAMPORTS_PER_SIGNATURE.saturating_add(
// It should never approach overflow but just in case
sp_std::cmp::min(
SolAmount::MAX as u128,
(self.priority_fee as u128 * compute_units_per_transfer as u128)
.div_ceil(MICROLAMPORTS_PER_LAMPORT.into()),
) as SolAmount,
)
);

match asset {
assets::sol::Asset::Sol => gas_fee,
assets::sol::Asset::SolUsdc => gas_fee.saturating_add(TOKEN_ACCOUNT_RENT),
}
}
fn estimate_ingress_fee(
&self,
Expand Down

0 comments on commit 7ce0d5b

Please sign in to comment.