Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add egress fee for token account rent #5315

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 RENT_TOKEN_ACCOUNT: u64 = 2039280u64;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the name is a bit confusing, I think TOKEN_ACCOUNT_RENT would be better.


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,
RENT_TOKEN_ACCOUNT,
},
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 @@ -188,14 +191,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(RENT_TOKEN_ACCOUNT),
}
}
fn estimate_ingress_fee(
&self,
Expand Down
Loading