Skip to content

Commit e946b01

Browse files
authoredMar 5, 2025
♻️ Fix weight annotations (#461)
## What? This pull request primarily involves renaming the `WETH` identifier to `ETH` across various files and making some adjustments to the auction bidding logic. The most important changes are summarized below: ### Identifier Renaming: * [`integration-tests/chopsticks/README.md`](diffhunk://#diff-5f201c1ce989592c5ce187da92301bda8364d5ea345abb2fa5966d2e43d5da64L35-R37): Updated references from `WETH` to `ETH` in the TODO list. * [`integration-tests/chopsticks/overrides/polimec.ts`](diffhunk://#diff-b166cb800d57cb015c4fe852e382234955e8733273ff1d7352aa25bf45c81e79L1-R1): Replaced `WETH_ADDRESS` with `ETH_ADDRESS` and updated initial balances and supply references. [[1]](diffhunk://#diff-b166cb800d57cb015c4fe852e382234955e8733273ff1d7352aa25bf45c81e79L1-R1) [[2]](diffhunk://#diff-b166cb800d57cb015c4fe852e382234955e8733273ff1d7352aa25bf45c81e79L85-R85) * [`integration-tests/chopsticks/src/constants.ts`](diffhunk://#diff-4cc229988bf52620c16da6b575898b6d1499fcbc438a45ce77313f0e570b1b29L9-R23): Renamed `WETH` to `ETH` in initial balances and transfer amounts. * [`integration-tests/chopsticks/src/transfers/BridgeToPolimec.ts`](diffhunk://#diff-d3f932bd8fa0e6df0cbaf55474b048e8008b43a22b2f502d1ea624fd1d0b9b7eL2-R2): Changed `WETH_ADDRESS` to `ETH_ADDRESS`. * [`integration-tests/src/constants.rs`](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL73-R73): Renamed `weth` to `eth` in the `Prices` and `PricesBuilder` structs and related functions. [[1]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL73-R73) [[2]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL83-R89) [[3]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL98-R98) [[4]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL123-R124) [[5]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL135-R135) [[6]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL321-R324) [[7]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL359-R359) [[8]](diffhunk://#diff-7b342ffeb1b99c7070f0924ae1eec48d0cf9ecdba069f0b862ce98b790479b2eL387-R393) ### Auction Bidding Logic: * [`pallets/funding/src/functions/3_auction.rs`](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6L7-R7): Modified the `do_bid` function to return `DispatchResultWithPostInfo` and added weight calculation for bid calls. [[1]](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6L7-R7) [[2]](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6L32-L33) [[3]](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6R71-R76) [[4]](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6L120-R125) [[5]](diffhunk://#diff-e6d198305182d08fe41b4b370766ddebd1e900a4cba5c5381092858ee38381b6L245-R255) ### Miscellaneous: * [`integration-tests/src/tests/defaults.rs`](diffhunk://#diff-6e90bbfb709e6606b4fbc49585a7e95d67d6cfb212733d333c93b76a01f4d648R80-R87): Added a sandbox test for `WeightInfo::bid`. * [`pallets/funding/Cargo.toml`](diffhunk://#diff-41d920a1cbb982b0748207efd369a5db84f43e09d7c6afcbaeeea224cc840a75L42): Removed `pallet-xcm` references from various sections. [[1]](diffhunk://#diff-41d920a1cbb982b0748207efd369a5db84f43e09d7c6afcbaeeea224cc840a75L42) [[2]](diffhunk://#diff-41d920a1cbb982b0748207efd369a5db84f43e09d7c6afcbaeeea224cc840a75L80) [[3]](diffhunk://#diff-41d920a1cbb982b0748207efd369a5db84f43e09d7c6afcbaeeea224cc840a75L111) [[4]](diffhunk://#diff-41d920a1cbb982b0748207efd369a5db84f43e09d7c6afcbaeeea224cc840a75L129) * [`pallets/funding/src/benchmarking.rs`](diffhunk://#diff-ffb567ea90cf81e3ccb0bf17050102829044c0b8693fe8a0a7c6cf776a588123L625-R626): Updated references from `weth_price` to `eth_price`. * [`pallets/funding/src/instantiator/calculations.rs`](diffhunk://#diff-808991f71e78e2c3b44661bdb1525f5ccf042a8d32d916e0ede1d2f5eee3fc69L7-R7): Replaced `WETH` with `ETH` in the list of accepted funding assets. These changes ensure consistency in naming conventions and improve the auction bidding process by incorporating weight calculations.
2 parents bf4c2f1 + 57756e8 commit e946b01

File tree

31 files changed

+131
-171
lines changed

31 files changed

+131
-171
lines changed
 

‎Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎integration-tests/chopsticks/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ bun run test
3232

3333
> [!IMPORTANT]
3434
> TODO: Add:
35-
> - [ ] Polimec SA on AH: Add WETH balance to it in the Chopstick ovveride
36-
> - [ ] Polimec to Asset Hub: WETH transfer. This is a "normal" transfer_asset call.
37-
> - [ ] Polimec to Ethereum: WETH transfer. This is a bit more complex, example extrinsic: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fhydration.ibp.network#/extrinsics/decode/0x6b0d04010100a10f040801000007464a69c7e002020907040300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200130000e8890423c78a0204010002040816040d01000001010088ca48e3e1d0f1c50bd6b504e1312d21f5bd45ed147e3c30c77eb5e4d63bdc6310010102020907040300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000201090704081300010300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20004000d010204000103001501c1413e4178c38567ada8945a80351f7b849600
35+
> - [ ] Polimec SA on AH: Add ETH balance to it in the Chopstick ovveride
36+
> - [ ] Polimec to Asset Hub: ETH transfer. This is a "normal" transfer_asset call.
37+
> - [ ] Polimec to Ethereum: ETH transfer. This is a bit more complex, example extrinsic: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fhydration.ibp.network#/extrinsics/decode/0x6b0d04010100a10f040801000007464a69c7e002020907040300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200130000e8890423c78a0204010002040816040d01000001010088ca48e3e1d0f1c50bd6b504e1312d21f5bd45ed147e3c30c77eb5e4d63bdc6310010102020907040300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000201090704081300010300c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20004000d010204000103001501c1413e4178c38567ada8945a80351f7b849600

‎integration-tests/chopsticks/overrides/polimec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { INITIAL_BALANCES, WETH_ADDRESS } from '@/constants';
1+
import { INITIAL_BALANCES, ETH_ADDRESS } from '@/constants';
22
import { Accounts } from '@/types';
33

44
export const POLIMEC_WASM =
@@ -82,7 +82,7 @@ export const polimec_storage = {
8282
issuer: Accounts.ALICE,
8383
admin: Accounts.ALICE,
8484
freezer: Accounts.ALICE,
85-
supply: 100n * INITIAL_BALANCES.WETH,
85+
supply: 100n * INITIAL_BALANCES.ETH,
8686
deposit: 0n,
8787
min_balance: 15000000000000n,
8888
is_sufficient: true,

‎integration-tests/chopsticks/overrides/polkadot-hub.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const polkadot_hub_storage = {
3737
[
3838
[eth_location, Accounts.POLIMEC],
3939
{
40-
balance: INITIAL_BALANCES.WETH,
40+
balance: INITIAL_BALANCES.ETH,
4141
},
4242
],
4343
],

‎integration-tests/chopsticks/src/constants.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ export const INITIAL_BALANCES = {
66
USDC: 66000n * 10n ** 6n,
77
DOT: 1000000n * 10n ** 10n,
88
PLMC: 1000000n * 10n ** 10n,
9-
WETH: 2n * 10n ** 18n,
9+
ETH: 2n * 10n ** 18n,
1010
} as const;
1111

1212
export const TRANSFER_AMOUNTS = {
1313
TOKENS: 2n * 10n ** 6n, // e.g. 2 USDC
1414
NATIVE: 2n * 10n ** 10n, // e.g. 2 DOT
15-
BRIDGED: 1n * 10n ** 17n, // e.g. 0.1 WETH
15+
BRIDGED: 1n * 10n ** 17n, // e.g. 0.1 ETH
1616
} as const;
1717

1818
export const DERIVE_PATHS = {
1919
[Accounts.ALICE]: '//Alice',
2020
[Accounts.BOB]: '//Bob',
2121
} as const;
2222

23-
export const WETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
23+
export const ETH_ADDRESS = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
2424
export const DEFAULT_TOPIC = FixedSizeBinary.fromArray(Array(32).fill(1));
2525
export const FEE_AMOUNT = 40_000_000_000n;
2626
export const ETH_AMOUNT = 15_000_000_000_000n;

‎integration-tests/chopsticks/src/transfers/BridgeToPolimec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect } from 'bun:test';
2-
import { DEFAULT_TOPIC, ETH_AMOUNT, FEE_AMOUNT, WETH_ADDRESS } from '@/constants';
2+
import { DEFAULT_TOPIC, ETH_AMOUNT, FEE_AMOUNT, ETH_ADDRESS } from '@/constants';
33
import type { BridgerHubManagaer } from '@/managers/BridgeHubManager';
44
import type { PolimecManager } from '@/managers/PolimecManager';
55
import type { PolkadotHubManager } from '@/managers/PolkadotHubManager';

‎integration-tests/chopsticks/src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type polkadot,
1212
} from '@polkadot-api/descriptors';
1313
import { FixedSizeBinary, type PolkadotClient, type TypedApi } from 'polkadot-api';
14-
import { WETH_ADDRESS } from './constants';
14+
import { ETH_ADDRESS } from './constants';
1515

1616
type Polimec = typeof polimec;
1717
type PolkadotHub = typeof pah;

‎integration-tests/src/constants.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct Prices {
7070
pub usdc: FixedU128,
7171
pub usdt: FixedU128,
7272
pub plmc: FixedU128,
73-
pub weth: FixedU128,
73+
pub eth: FixedU128,
7474
}
7575

7676
// PricesBuilder for optional fields before building Prices
@@ -80,13 +80,13 @@ pub struct PricesBuilder {
8080
usdc: Option<FixedU128>,
8181
usdt: Option<FixedU128>,
8282
plmc: Option<FixedU128>,
83-
weth: Option<FixedU128>,
83+
eth: Option<FixedU128>,
8484
}
8585

8686
impl PricesBuilder {
8787
// Initialize a new builder with None for each field
8888
pub fn new() -> Self {
89-
Self { dot: None, usdc: None, usdt: None, plmc: None, weth: None }
89+
Self { dot: None, usdc: None, usdt: None, plmc: None, eth: None }
9090
}
9191

9292
pub fn default_prices() -> Prices {
@@ -95,7 +95,7 @@ impl PricesBuilder {
9595
usdc: FixedU128::from_rational(1, 1),
9696
usdt: FixedU128::from_rational(1, 1),
9797
plmc: FixedU128::from_rational(840, 100),
98-
weth: FixedU128::from_rational(3620, 1),
98+
eth: FixedU128::from_rational(3620, 1),
9999
}
100100
}
101101

@@ -120,8 +120,8 @@ impl PricesBuilder {
120120
self
121121
}
122122

123-
pub fn weth(&mut self, price: FixedU128) -> &mut Self {
124-
self.weth = Some(price);
123+
pub fn eth(&mut self, price: FixedU128) -> &mut Self {
124+
self.eth = Some(price);
125125
self
126126
}
127127

@@ -132,7 +132,7 @@ impl PricesBuilder {
132132
usdc: self.usdc.unwrap_or(FixedU128::from_rational(1, 1)), // Default USDC price
133133
usdt: self.usdt.unwrap_or(FixedU128::from_rational(1, 1)), // Default USDT price
134134
plmc: self.plmc.unwrap_or(FixedU128::from_rational(840, 100)), // Default PLMC price
135-
weth: self.weth.unwrap_or(FixedU128::from_rational(3620, 1)), // Default WETH price
135+
eth: self.eth.unwrap_or(FixedU128::from_rational(3620, 1)), // Default ETH price
136136
}
137137
}
138138
}
@@ -318,10 +318,10 @@ pub mod polimec {
318318
let usdc = (AcceptedFundingAsset::USDC.id(), prices.usdc);
319319
let usdt = (AcceptedFundingAsset::USDT.id(), prices.usdt);
320320
let plmc = (Location::here(), prices.plmc);
321-
let weth = (AcceptedFundingAsset::ETH.id(), prices.weth);
321+
let eth = (AcceptedFundingAsset::ETH.id(), prices.eth);
322322

323323
let values: BoundedVec<(Location, FixedU128), <PolimecRuntime as orml_oracle::Config>::MaxFeedValues> =
324-
vec![dot, usdc, usdt, plmc, weth].try_into().expect("benchmarks can panic");
324+
vec![dot, usdc, usdt, plmc, eth].try_into().expect("benchmarks can panic");
325325
let alice: [u8; 32] = [
326326
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205,
327327
227, 154, 86, 132, 231, 165, 109, 162, 125,
@@ -356,7 +356,7 @@ pub mod polimec {
356356
let dot_asset_id = AcceptedFundingAsset::DOT.id();
357357
let usdt_asset_id = AcceptedFundingAsset::USDT.id();
358358
let usdc_asset_id = AcceptedFundingAsset::USDC.id();
359-
let weth_asset_id = AcceptedFundingAsset::ETH.id();
359+
let eth_asset_id = AcceptedFundingAsset::ETH.id();
360360

361361
let mut funded_accounts = vec![(
362362
PolimecNet::sovereign_account_id_of((Parent, xcm::prelude::Parachain(1000)).into()),
@@ -384,13 +384,13 @@ pub mod polimec {
384384
(dot_asset_id.clone(), alice_account.clone(), true, 100_000_000),
385385
(usdt_asset_id.clone(), alice_account.clone(), true, 70_000),
386386
(usdc_asset_id.clone(), alice_account.clone(), true, 70_000),
387-
(weth_asset_id.clone(), alice_account.clone(), true, 0_000_041_000_000_000_000),
387+
(eth_asset_id.clone(), alice_account.clone(), true, 0_000_041_000_000_000_000),
388388
],
389389
metadata: vec![
390390
(dot_asset_id, "Local DOT".as_bytes().to_vec(), "DOT".as_bytes().to_vec(), 10),
391391
(usdt_asset_id, "Local USDT".as_bytes().to_vec(), "USDT".as_bytes().to_vec(), 6),
392392
(usdc_asset_id.clone(), "Local USDC".as_bytes().to_vec(), "USDC".as_bytes().to_vec(), 6),
393-
(weth_asset_id, "Local WETH".as_bytes().to_vec(), "WETH".as_bytes().to_vec(), 18),
393+
(eth_asset_id, "Local ETH".as_bytes().to_vec(), "ETH".as_bytes().to_vec(), 18),
394394
],
395395
accounts: vec![],
396396
},

‎integration-tests/src/tests/defaults.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use pallet_funding::{
2323

2424
use macros::generate_accounts;
2525
use polimec_common::{
26-
assets::AcceptedFundingAsset::{DOT, USDC, USDT, ETH},
27-
ProvideAssetPrice, USD_DECIMALS, USD_UNIT,
26+
assets::AcceptedFundingAsset::{DOT, ETH, USDC, USDT},
27+
ProvideAssetPrice, USD_DECIMALS, USD_UNIT,
2828
};
2929
use polimec_runtime::AccountId;
3030
use sp_runtime::traits::ConstU32;
@@ -77,3 +77,11 @@ pub fn default_project_metadata(issuer: AccountId) -> ProjectMetadataOf<polimec_
7777
participants_account_type: ParticipantsAccountType::Polkadot,
7878
}
7979
}
80+
81+
#[test]
82+
fn sandbox() {
83+
use pallet_funding::WeightInfo;
84+
85+
let bid_weight = polimec_runtime::weights::pallet_funding::WeightInfo::<PolimecRuntime>::bid(0);
86+
dbg!(bid_weight);
87+
}

‎integration-tests/src/tests/oracle.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ use sp_runtime::{bounded_vec, BoundedVec, FixedU128};
2121
use std::collections::BTreeMap;
2222
use tests::defaults::*;
2323

24-
use AcceptedFundingAsset::{DOT, USDC, USDT, ETH};
24+
use AcceptedFundingAsset::{DOT, ETH, USDC, USDT};
2525

2626
fn values(
2727
values: [f64; 5],
2828
) -> BoundedVec<(Location, FixedU128), <polimec_runtime::Runtime as orml_oracle::Config<()>>::MaxFeedValues> {
29-
let [dot, usdc, usdt, weth, plmc] = values;
29+
let [dot, usdc, usdt, eth, plmc] = values;
3030
bounded_vec![
3131
(DOT.id(), FixedU128::from_float(dot)),
3232
(USDC.id(), FixedU128::from_float(usdc)),
3333
(USDT.id(), FixedU128::from_float(usdt)),
34-
(ETH.id(), FixedU128::from_float(weth)),
34+
(ETH.id(), FixedU128::from_float(eth)),
3535
(Location::here(), FixedU128::from_float(plmc))
3636
]
3737
}

‎integration-tests/src/tests/runtime_apis.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,17 @@ mod fungibles_api {
8181
PolimecForeignAssets::set_balance(AcceptedFundingAsset::DOT.id(), &alice_account, 100_0_000_000_000_u128);
8282
PolimecForeignAssets::set_balance(AcceptedFundingAsset::USDT.id(), &alice_account, 100_000_u128);
8383
PolimecForeignAssets::set_balance(AcceptedFundingAsset::USDC.id(), &alice_account, 100_000_u128);
84-
PolimecForeignAssets::set_balance(
85-
AcceptedFundingAsset::ETH.id(),
86-
&alice_account,
87-
100_000_000_000_000_u128,
88-
);
84+
PolimecForeignAssets::set_balance(AcceptedFundingAsset::ETH.id(), &alice_account, 100_000_000_000_000_u128);
8985

9086
let alice_assets = PolimecRuntime::query_account_balances(alice_account).unwrap();
9187

9288
let expected_assets = VersionedAssets::V4(
9389
vec![
94-
Asset::from((Location::here(), 150_0_000_000_000_u128)),
95-
Asset::from((AcceptedFundingAsset::DOT.id(), 100_0_000_000_000_u128)),
96-
Asset::from((AcceptedFundingAsset::USDC.id(), 100_000_u128)),
97-
Asset::from((AcceptedFundingAsset::USDT.id(), 100_000_u128)),
98-
Asset::from((AcceptedFundingAsset::ETH.id(), 100_000_000_000_000_u128)),
90+
Asset::from((Location::here(), 150_0_000_000_000_u128)),
91+
Asset::from((AcceptedFundingAsset::DOT.id(), 100_0_000_000_000_u128)),
92+
Asset::from((AcceptedFundingAsset::USDC.id(), 100_000_u128)),
93+
Asset::from((AcceptedFundingAsset::USDT.id(), 100_000_u128)),
94+
Asset::from((AcceptedFundingAsset::ETH.id(), 100_000_000_000_000_u128)),
9995
]
10096
.into(),
10197
);

‎pallets/funding/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ sp-core.workspace = true
3939
pallet-balances.workspace = true
4040
xcm.workspace = true
4141
xcm-executor.workspace = true
42-
pallet-xcm.workspace = true
4342
polkadot-parachain-primitives.workspace = true
4443
sp-api.workspace = true
4544
polimec-common-test-utils = { workspace = true, optional = true }
@@ -77,7 +76,6 @@ std = [
7776
"pallet-linear-release/std",
7877
"pallet-proxy-bonding/std",
7978
"pallet-timestamp/std",
80-
"pallet-xcm/std",
8179
"parachains-common/std",
8280
"parity-scale-codec/std",
8381
"polimec-common-test-utils",
@@ -108,7 +106,6 @@ runtime-benchmarks = [
108106
"pallet-linear-release/runtime-benchmarks",
109107
"pallet-proxy-bonding/runtime-benchmarks",
110108
"pallet-timestamp/runtime-benchmarks",
111-
"pallet-xcm/runtime-benchmarks",
112109
"parachains-common/runtime-benchmarks",
113110
"polimec-common-test-utils",
114111
"polimec-common-test-utils?/runtime-benchmarks",
@@ -126,7 +123,6 @@ try-runtime = [
126123
"pallet-linear-release/try-runtime",
127124
"pallet-proxy-bonding/try-runtime",
128125
"pallet-timestamp/try-runtime",
129-
"pallet-xcm/try-runtime",
130126
"polimec-common-test-utils?/try-runtime",
131127
"polimec-common/try-runtime",
132128
"sp-runtime/try-runtime",

‎pallets/funding/src/benchmarking.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ use frame_support::{
3535
use itertools::Itertools;
3636
use parity_scale_codec::{Decode, Encode};
3737
use polimec_common::{
38-
assets::AcceptedFundingAsset::{DOT, USDC, USDT, ETH},
39-
credentials::InvestorType,
40-
ProvideAssetPrice, USD_DECIMALS, USD_UNIT,
38+
assets::AcceptedFundingAsset::{DOT, ETH, USDC, USDT},
39+
credentials::InvestorType,
40+
ProvideAssetPrice, USD_DECIMALS, USD_UNIT,
4141
};
4242
use polimec_common_test_utils::{generate_did_from_account, get_mock_jwt_with_cid};
4343
use sp_arithmetic::Percent;
@@ -622,8 +622,8 @@ mod benchmarks {
622622
let mut inst = BenchInstantiator::<T>::new(None);
623623
<T as Config>::SetPrices::set_prices();
624624

625-
let weth_price = PriceProviderOf::<T>::get_price(ETH.id()).unwrap();
626-
log::info!("weth_price: {:?}", weth_price);
625+
let eth_price = PriceProviderOf::<T>::get_price(ETH.id()).unwrap();
626+
log::info!("eth_price: {:?}", eth_price);
627627

628628
// We can't see events at block 0
629629
inst.advance_time(1u32.into());

‎pallets/funding/src/functions/3_auction.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use super::*;
44
impl<T: Config> Pallet<T> {
55
/// Place a bid on a project in the auction round
66
#[transactional]
7-
pub fn do_bid(params: DoBidParams<T>) -> DispatchResult {
7+
pub fn do_bid(params: DoBidParams<T>) -> DispatchResultWithPostInfo {
88
// * Get variables *
99
let DoBidParams {
1010
bidder,
@@ -29,8 +29,6 @@ impl<T: Config> Pallet<T> {
2929
// User will spend at least this amount of USD for his bid(s). More if the bid gets split into different buckets
3030
let min_total_ticket_size =
3131
current_bucket.current_price.checked_mul_int(ct_amount).ok_or(Error::<T>::BadMath)?;
32-
// weight return variables
33-
let mut perform_bid_calls = 0;
3432

3533
let metadata_ticket_size_bounds = match investor_type {
3634
InvestorType::Institutional => project_metadata.bidding_ticket_sizes.institutional,
@@ -70,8 +68,12 @@ impl<T: Config> Pallet<T> {
7068
Error::<T>::UnsupportedReceiverAccountJunction
7169
);
7270

71+
let mut perform_bid_calls = 0u8;
72+
7373
// While there's a remaining amount to bid for
7474
while !amount_to_bid.is_zero() {
75+
perform_bid_calls.saturating_accrue(1);
76+
7577
let ct_amount = if amount_to_bid <= current_bucket.amount_left {
7678
// Simple case, the bucket has enough to cover the bid
7779
amount_to_bid
@@ -117,7 +119,10 @@ impl<T: Config> Pallet<T> {
117119
// Note: If the bucket has been exhausted, the 'update' function has already made the 'current_bucket' point to the next one.
118120
Buckets::<T>::insert(project_id, current_bucket);
119121

120-
Ok(())
122+
Ok(PostDispatchInfo {
123+
actual_weight: Some(<T as Config>::WeightInfo::bid(perform_bid_calls as u32)),
124+
pays_fee: Pays::No,
125+
})
121126
}
122127

123128
/// Inner function to perform bids within a bucket. do_bid makes sure to split the bid into buckets and call this as
@@ -242,10 +247,12 @@ impl<T: Config> Pallet<T> {
242247
}
243248

244249
// Save state changes
245-
Bids::<T>::insert(project_id, bid.id, bid);
250+
Bids::<T>::insert(project_id, bid.id, bid.clone());
246251
OutbidBidsCutoffs::<T>::set(project_id, Some(current_cutoff));
247252
CTAmountOversubscribed::<T>::insert(project_id, ct_amount_oversubscribed);
248253

254+
Self::deposit_event(Event::OversubscribedBidProcessed { project_id, bid_id: bid.id });
255+
249256
Ok(())
250257
}
251258

‎pallets/funding/src/instantiator/calculations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use itertools::{izip, GroupBy};
44
#[allow(clippy::wildcard_imports)]
55
use polimec_common::assets::AcceptedFundingAsset;
66
use polimec_common::{
7-
assets::AcceptedFundingAsset::{DOT, USDC, USDT, ETH},
7+
assets::AcceptedFundingAsset::{DOT, ETH, USDC, USDT},
88
ProvideAssetPrice, USD_DECIMALS,
99
};
1010
use sp_core::{blake2_256, ecdsa, hexdisplay::AsBytesRef, keccak_256, sr25519, Pair};

0 commit comments

Comments
 (0)
Failed to load comments.