@layerzerolabs/protocol-stellar-v2 0.2.46 → 0.2.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +235 -231
- package/.turbo/turbo-lint.log +304 -97
- package/.turbo/turbo-test.log +1745 -1806
- package/contracts/workers/dvn/src/tests/dvn.rs +4 -0
- package/contracts/workers/dvn-fee-lib/src/dvn_fee_lib.rs +4 -0
- package/contracts/workers/fee-lib-interfaces/src/dvn_fee_lib.rs +6 -0
- package/contracts/workers/price-feed/src/price_feed.rs +17 -28
- package/package.json +4 -4
- package/sdk/.turbo/turbo-test.log +268 -270
- package/sdk/dist/generated/dvn_fee_lib.d.ts +8 -3
- package/sdk/dist/generated/dvn_fee_lib.js +5 -3
- package/sdk/dist/generated/price_feed.d.ts +3 -3
- package/sdk/dist/generated/price_feed.js +3 -3
- package/sdk/package.json +1 -1
|
@@ -73,4 +73,10 @@ pub trait IDvnFeeLib {
|
|
|
73
73
|
/// # Returns
|
|
74
74
|
/// The calculated fee in native token units (stroops for Stellar).
|
|
75
75
|
fn get_fee(env: &Env, dvn: &Address, params: &DvnFeeParams) -> i128;
|
|
76
|
+
|
|
77
|
+
/// Returns the fee library contract version.
|
|
78
|
+
///
|
|
79
|
+
/// # Returns
|
|
80
|
+
/// Tuple of (major version, minor version).
|
|
81
|
+
fn version(env: &Env) -> (u64, u32);
|
|
76
82
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use common_macros::{contract_impl, lz_contract, only_auth};
|
|
2
2
|
use fee_lib_interfaces::{FeeEstimate, ILayerZeroPriceFeed, Price};
|
|
3
|
-
use soroban_sdk::{assert_with_error,
|
|
3
|
+
use soroban_sdk::{assert_with_error, Address, Env, Vec};
|
|
4
|
+
use utils::option_ext::OptionExt;
|
|
4
5
|
|
|
5
6
|
use crate::{
|
|
6
7
|
errors::PriceFeedError,
|
|
@@ -110,7 +111,7 @@ impl LzPriceFeed {
|
|
|
110
111
|
|
|
111
112
|
/// Set prices for multiple destinations (price updater or owner)
|
|
112
113
|
pub fn set_price(env: &Env, price_updater: &Address, prices: &Vec<UpdatePrice>) {
|
|
113
|
-
Self::
|
|
114
|
+
Self::require_owner_or_price_updater(env, price_updater);
|
|
114
115
|
|
|
115
116
|
prices.iter().for_each(|update| Self::set_price_internal(env, update.eid, &update.price));
|
|
116
117
|
}
|
|
@@ -118,7 +119,7 @@ impl LzPriceFeed {
|
|
|
118
119
|
/// Set price for Arbitrum with extension (price updater or owner)
|
|
119
120
|
/// Corresponds to setPriceForArbitrum in PriceFeed.sol
|
|
120
121
|
pub fn set_price_for_arbitrum(env: &Env, price_updater: &Address, update: &UpdatePriceExt) {
|
|
121
|
-
Self::
|
|
122
|
+
Self::require_owner_or_price_updater(env, price_updater);
|
|
122
123
|
|
|
123
124
|
Self::set_price_internal(env, update.eid, &update.price);
|
|
124
125
|
|
|
@@ -131,7 +132,7 @@ impl LzPriceFeed {
|
|
|
131
132
|
///
|
|
132
133
|
/// Kept as a standalone contract function (not part of the canonical `fee_lib_interfaces::ILayerZeroPriceFeed` interface).
|
|
133
134
|
pub fn set_native_token_price_usd(env: &Env, price_updater: &Address, native_token_price_usd: u128) {
|
|
134
|
-
Self::
|
|
135
|
+
Self::require_owner_or_price_updater(env, price_updater);
|
|
135
136
|
PriceFeedStorage::set_native_price_usd(env, &native_token_price_usd);
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -171,7 +172,7 @@ impl LzPriceFeed {
|
|
|
171
172
|
|
|
172
173
|
/// Estimate fee with default model
|
|
173
174
|
fn estimate_fee_with_default_model(env: &Env, dst_eid: u32, calldata_size: u32, gas: u128) -> (u128, u128) {
|
|
174
|
-
let price = Self::get_price(env, dst_eid).
|
|
175
|
+
let price = Self::get_price(env, dst_eid).unwrap_or_panic(env, PriceFeedError::NoPrice);
|
|
175
176
|
|
|
176
177
|
// assuming the _gas includes (1) the 21,000 overhead and (2) not the calldata gas
|
|
177
178
|
let gas_for_calldata = (calldata_size as u128) * (price.gas_per_byte as u128);
|
|
@@ -183,17 +184,14 @@ impl LzPriceFeed {
|
|
|
183
184
|
|
|
184
185
|
/// Estimate fee with Optimism model
|
|
185
186
|
fn estimate_fee_with_optimism_model(env: &Env, dst_eid: u32, calldata_size: u32, gas: u128) -> (u128, u128) {
|
|
186
|
-
let ethereum_id = Self::get_l1_lookup_id_for_optimism_model(env, dst_eid);
|
|
187
|
-
|
|
188
187
|
// L1 fee (Ethereum)
|
|
189
|
-
let
|
|
190
|
-
|
|
188
|
+
let ethereum_id = Self::get_l1_lookup_id_for_optimism_model(env, dst_eid);
|
|
189
|
+
let ethereum_price = Self::get_price(env, ethereum_id).unwrap_or_panic(env, PriceFeedError::NoPrice);
|
|
191
190
|
let gas_for_l1_calldata = ((calldata_size as u128) * (ethereum_price.gas_per_byte as u128)) + 3188; // 2100 + 68 * 16
|
|
192
191
|
let l1_fee = gas_for_l1_calldata * (ethereum_price.gas_price_in_unit as u128);
|
|
193
192
|
|
|
194
193
|
// L2 fee (Optimism)
|
|
195
|
-
let optimism_price =
|
|
196
|
-
Self::get_price(env, dst_eid).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
|
|
194
|
+
let optimism_price = Self::get_price(env, dst_eid).unwrap_or_panic(env, PriceFeedError::NoPrice);
|
|
197
195
|
let gas_for_l2_calldata = (calldata_size as u128) * (optimism_price.gas_per_byte as u128);
|
|
198
196
|
let l2_fee = (gas_for_l2_calldata + gas) * (optimism_price.gas_price_in_unit as u128);
|
|
199
197
|
|
|
@@ -207,16 +205,13 @@ impl LzPriceFeed {
|
|
|
207
205
|
|
|
208
206
|
/// Estimate fee with Arbitrum model
|
|
209
207
|
fn estimate_fee_with_arbitrum_model(env: &Env, dst_eid: u32, calldata_size: u32, gas: u128) -> (u128, u128) {
|
|
210
|
-
let arbitrum_price =
|
|
211
|
-
Self::get_price(env, dst_eid).unwrap_or_else(|| panic_with_error!(env, PriceFeedError::NoPrice));
|
|
212
|
-
|
|
213
|
-
let arbitrum_price_ext = Self::arbitrum_price_ext(env);
|
|
214
|
-
|
|
215
208
|
// L1 fee (compressed calldata)
|
|
209
|
+
let arbitrum_price_ext = Self::arbitrum_price_ext(env);
|
|
216
210
|
let gas_for_l1_calldata = (((calldata_size as u128) * Self::arbitrum_compression_percent(env)) / 100)
|
|
217
211
|
* (arbitrum_price_ext.gas_per_l1_calldata_byte as u128);
|
|
218
212
|
|
|
219
213
|
// L2 fee
|
|
214
|
+
let arbitrum_price = Self::get_price(env, dst_eid).unwrap_or_panic(env, PriceFeedError::NoPrice);
|
|
220
215
|
let gas_for_l2_calldata = (calldata_size as u128) * (arbitrum_price.gas_per_byte as u128);
|
|
221
216
|
let gas_fee = (gas + (arbitrum_price_ext.gas_per_l2_tx as u128) + gas_for_l1_calldata + gas_for_l2_calldata)
|
|
222
217
|
* (arbitrum_price.gas_price_in_unit as u128);
|
|
@@ -251,18 +246,12 @@ impl LzPriceFeed {
|
|
|
251
246
|
}
|
|
252
247
|
|
|
253
248
|
/// Check if caller is price updater or owner
|
|
254
|
-
fn
|
|
249
|
+
fn require_owner_or_price_updater(env: &Env, caller: &Address) {
|
|
255
250
|
caller.require_auth();
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Check if caller is an active price updater
|
|
265
|
-
assert_with_error!(env, Self::is_price_updater(env, caller), PriceFeedError::OnlyPriceUpdater);
|
|
251
|
+
assert_with_error!(
|
|
252
|
+
env,
|
|
253
|
+
Self::owner(env).as_ref() == Some(caller) || Self::is_price_updater(env, caller),
|
|
254
|
+
PriceFeedError::OnlyPriceUpdater
|
|
255
|
+
);
|
|
266
256
|
}
|
|
267
257
|
}
|
|
268
|
-
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/protocol-stellar-v2",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.47",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "LZBL-1.2",
|
|
6
6
|
"devDependencies": {
|
|
7
7
|
"@types/node": "^22.18.6",
|
|
8
8
|
"tsx": "^4.19.3",
|
|
9
9
|
"typescript": "^5.8.2",
|
|
10
|
-
"@layerzerolabs/common-node-utils": "0.2.
|
|
11
|
-
"@layerzerolabs/stellar-ts-bindings-gen": "0.2.
|
|
12
|
-
"@layerzerolabs/vm-tooling-stellar": "0.2.
|
|
10
|
+
"@layerzerolabs/common-node-utils": "0.2.47",
|
|
11
|
+
"@layerzerolabs/stellar-ts-bindings-gen": "0.2.47",
|
|
12
|
+
"@layerzerolabs/vm-tooling-stellar": "0.2.47"
|
|
13
13
|
},
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "restricted",
|