Skip to content

Commit 46f4510

Browse files
committed
reduce gas costs for some tokens
1 parent da6e60b commit 46f4510

File tree

5 files changed

+104
-3
lines changed

5 files changed

+104
-3
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ members = [
1111
"proposals/mainnet_phases/phase5a",
1212
"proposals/mainnet_phases/phase5b",
1313
"proposals/mainnet/update-staking-inflation-parameters",
14-
"proposals/testnet/add-uusdc-gas-token",
14+
"proposals/testnet/add-uusdc-gas-token", "proposals/mainnet/update-gas-costs",
1515
]
1616

1717
[workspace.package]
@@ -22,9 +22,7 @@ version = "1.0.0"
2222

2323
[workspace.dependencies]
2424
namada_tx_prelude_01502 = { package = "namada_tx_prelude", git = "https://github.com/anoma/namada", tag = "libs-v0.150.2" }
25-
namada_tx_prelude_02512 = { package = "namada_tx_prelude", git = "https://github.com/anoma/namada", tag = "libs-v0.251.2" }
2625
namada_proof_of_stake_01502 = { package = "namada_proof_of_stake", git = "https://github.com/anoma/namada", tag = "libs-v0.150.2" }
27-
namada_proof_of_stake_02512 = { package = "namada_proof_of_stake", git = "https://github.com/anoma/namada", tag = "libs-v0.251.2" }
2826

2927
rlsf = "0.2.1"
3028
getrandom = { version = "0.2", features = ["custom"] }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "update-gas-costs"
3+
description = "WASM transaction to write minimum gas costs for desired tokens."
4+
authors.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
version.workspace = true
8+
9+
[dependencies]
10+
namada_tx_prelude_01502.workspace = true
11+
rlsf.workspace = true
12+
getrandom.workspace = true
13+
14+
[lib]
15+
crate-type = ["cdylib"]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"rust-version": "1.85.1",
3+
"proposal": {
4+
"title": "Insert title.",
5+
"authors": "Bob The Builer <bob@thebuilder.rock>",
6+
"discussions-to": "www.bob-the-builder.forum.rock",
7+
"abstract": "OPTIONAL: You can put an abstract here if you'd like.",
8+
"motivation": "OPTIONAL: You can put a motivation here if you'd like.",
9+
"details": "Put proposal details here.",
10+
"author": "tnam1qxfj3sf6a0meahdu9t6znp05g8zx4dkjtgyn9gfu",
11+
"voting_start_epoch": 6,
12+
"voting_end_epoch": 12,
13+
"activation_epoch": 18
14+
}
15+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use std::collections::BTreeMap;
2+
3+
use namada_tx_prelude::*;
4+
use namada_tx_prelude_01502::{self as namada_tx_prelude, parameters_storage::get_gas_cost_key};
5+
6+
pub type ChannelId = &'static str;
7+
pub type BaseToken = &'static str;
8+
9+
pub type Gas = token::Amount;
10+
11+
const IBC_TOKENS: [(ChannelId, BaseToken, Gas); 6] = [
12+
(
13+
"channel-0",
14+
"stuosmo",
15+
Gas::from_u64(3), // 3 stuosmo / gas unit
16+
),
17+
(
18+
"channel-1",
19+
"uosmo",
20+
Gas::from_u64(3), // 3 uosmo / gas unit
21+
),
22+
(
23+
"channel-4",
24+
"upenumbra",
25+
Gas::from_u64(3), // 3 upenumbra / gas unit;
26+
),
27+
(
28+
"channel-5",
29+
"uusdc",
30+
Gas::from_u64(1), // 1 uusdc / gas unit;
31+
),
32+
(
33+
"channel-6",
34+
"unym",
35+
Gas::from_u64(15), // 15 unym / gas unit;
36+
),
37+
(
38+
"channel-7",
39+
"untrn",
40+
Gas::from_u64(7), // 7 untrn / gas unit;
41+
),
42+
];
43+
44+
#[transaction]
45+
fn apply_tx(ctx: &mut Ctx, _tx_data: BatchedTx) -> TxResult {
46+
// Read the current gas cost map
47+
let gas_cost_key = get_gas_cost_key();
48+
let mut minimum_gas_price: BTreeMap<Address, token::Amount> =
49+
ctx.read(&gas_cost_key)?.unwrap_or_default();
50+
51+
// Enable IBC deposit/withdraws limits
52+
for (channel_id, base_token, gas) in IBC_TOKENS {
53+
let ibc_denom = format!("transfer/{channel_id}/{base_token}");
54+
let token_address = ibc::ibc_token(&ibc_denom).clone();
55+
56+
// Check if this ibc token should can also be used to pay for gas
57+
minimum_gas_price.insert(token_address.clone(), gas);
58+
}
59+
60+
// Write the gas cost map back to storage
61+
ctx.write(&gas_cost_key, minimum_gas_price)?;
62+
63+
Ok(())
64+
}

0 commit comments

Comments
 (0)