Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
290e91d
gigahdx
enthusiastmartin May 5, 2026
9f2f343
additional integration tests
enthusiastmartin May 5, 2026
a5f8fff
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 6, 2026
08fa9c4
gigahdx impl
enthusiastmartin May 6, 2026
508ba3e
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 6, 2026
442ba8f
rename config params
enthusiastmartin May 6, 2026
6b4ad97
minor issues
enthusiastmartin May 7, 2026
02eb404
benchmarks and weights
enthusiastmartin May 7, 2026
4f966f4
add snapshot
enthusiastmartin May 7, 2026
48fb50a
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 7, 2026
96fd90f
fix clippy build
enthusiastmartin May 7, 2026
7cb379e
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 7, 2026
4c327da
Update pallets weights [ignore benchmarks]
enthusiastmartin May 7, 2026
0d6df13
weights
enthusiastmartin May 7, 2026
428b140
bump versions
enthusiastmartin May 7, 2026
3a09640
minor changes
enthusiastmartin May 7, 2026
1ca3eda
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 8, 2026
663bb3d
update extrinsics descs
enthusiastmartin May 8, 2026
e50a51d
update code comments
enthusiastmartin May 8, 2026
7eec9df
address review comments
enthusiastmartin May 8, 2026
8e8061b
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 9, 2026
96af16e
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 11, 2026
d1da293
add gigahdx voting rewards
enthusiastmartin May 12, 2026
b22167e
simplify do_stake
enthusiastmartin May 12, 2026
7fd047a
remove unsused imports
enthusiastmartin May 12, 2026
9c19cd9
happy clippy happy life
enthusiastmartin May 12, 2026
b7b75d7
add multiple unstakes positions
enthusiastmartin May 13, 2026
a4c0b53
be strict on locks
enthusiastmartin May 13, 2026
112dc21
force unstake in legacy staking
enthusiastmartin May 13, 2026
cb31d23
review comments
enthusiastmartin May 13, 2026
fac2e3c
wire legacy migrator to gigahdx
enthusiastmartin May 13, 2026
df6efc4
adjust percentages and rewards multipliers
enthusiastmartin May 13, 2026
060f53b
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 14, 2026
fdc444a
fix rewards tests to reflect param changes
enthusiastmartin May 14, 2026
de9a72f
add realize yield
enthusiastmartin May 15, 2026
0c00c31
additioan test
enthusiastmartin May 15, 2026
9c84cb5
Merge branch 'master' into gigahdx-lock
enthusiastmartin May 18, 2026
dac901d
addtional tests
enthusiastmartin May 19, 2026
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
77 changes: 74 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@ members = [
'pallets/liquidation',
'precompiles/call-permit',
'precompiles/flash-loan',
'precompiles/lock-manager',
'runtime-mock',
'pallets/broadcast',
'liquidation-worker-support',
'pallets/hsm',
"pallets/signet",
"pallets/dispenser"
"pallets/dispenser",
"pallets/gigahdx",
"pallets/gigahdx-rewards",
]

resolver = "2"
Expand Down Expand Up @@ -164,6 +167,8 @@ pallet-hsm = { path = "pallets/hsm", default-features = false }
pallet-parameters = { path = "pallets/parameters", default-features = false }
pallet-signet = { path = "pallets/signet", default-features = false }
pallet-dispenser = { path = "pallets/dispenser", default-features = false }
pallet-gigahdx = { path = "pallets/gigahdx", default-features = false }
pallet-gigahdx-rewards = { path = "pallets/gigahdx-rewards", default-features = false }

hydra-dx-build-script-utils = { path = "utils/build-script-utils", default-features = false }
scraper = { path = "scraper", default-features = false }
Expand All @@ -173,6 +178,7 @@ integration-tests = { path = "integration-tests", default-features = false }

pallet-evm-precompile-call-permit = { path = "precompiles/call-permit", default-features = false }
pallet-evm-precompile-flash-loan = { path = "precompiles/flash-loan", default-features = false }
pallet-evm-precompile-lock-manager = { path = "precompiles/lock-manager", default-features = false }
precompile-utils = { path = "precompiles/utils", default-features = false }

# Frame
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pallet-evm-accounts = { workspace = true }
pallet-xyk-liquidity-mining = { workspace = true }
pallet-transaction-pause = { workspace = true }
pallet-liquidation = { workspace = true }
pallet-gigahdx = { workspace = true }
pallet-gigahdx-rewards = { workspace = true }
liquidation-worker-support = { workspace = true }
pallet-broadcast = { workspace = true }
pallet-duster = { workspace = true }
Expand Down Expand Up @@ -228,6 +230,8 @@ std = [
"precompile-utils/std",
"pallet-transaction-pause/std",
"pallet-liquidation/std",
"pallet-gigahdx/std",
"pallet-gigahdx-rewards/std",
"pallet-broadcast/std",
"pallet-dispatcher/std",
"pallet-hsm/std",
Expand Down
Binary file added integration-tests/snapshots/gigahdx/gigahdx
Binary file not shown.
114 changes: 113 additions & 1 deletion integration-tests/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,7 @@ mod chainlink_precompile {
use hydradx_traits::{router::AssetPair, AggregatedPriceOracle, OraclePeriod};
use pallet_ema_oracle::Price;
use pallet_lbp::AssetId;
use primitives::constants::chain::{OMNIPOOL_SOURCE, XYK_SOURCE};
use primitives::constants::chain::{GIGAHDX_SOURCE, OMNIPOOL_SOURCE, XYK_SOURCE};
use primitives::EvmAddress;

fn assert_prices_are_same(ema_price: Price, precompile_price: U256, asset_a_decimals: u8, asset_b_decimals: u8) {
Expand Down Expand Up @@ -2692,6 +2692,118 @@ mod chainlink_precompile {
pretty_assertions::assert_eq!(r, expected_decimals);
});
}

const STHDX: AssetId = 670;
const HDX_ID: AssetId = 0;

fn register_st_hdx() {
if hydradx_runtime::AssetRegistry::decimals(STHDX).is_some() {
return;
}
assert_ok!(hydradx_runtime::AssetRegistry::register(
RuntimeOrigin::root(),
Some(STHDX),
Some(b"stHDX".to_vec().try_into().unwrap()),
pallet_asset_registry::AssetType::Token,
Some(1u128),
Some(b"stHDX".to_vec().try_into().unwrap()),
Some(12u8),
None,
None,
true,
));
}

fn seed_gigapot_and_supply(gigapot_hdx: Balance, st_hdx_supply: Balance) {
// `total_gigahdx_supply` reads orml-tokens issuance directly.
orml_tokens::TotalIssuance::<Runtime>::set(STHDX, st_hdx_supply);
let gigapot = pallet_gigahdx::Pallet::<Runtime>::gigapot_account_id();
assert_ok!(Balances::force_set_balance(RuntimeOrigin::root(), gigapot, gigapot_hdx,));
}

fn chainlink_latest_answer(address: EvmAddress) -> U256 {
let data = EvmDataWriter::new_with_selector(AggregatorInterface::LatestAnswer).build();
let mut handle = MockHandle {
input: data,
context: Context {
address: evm_address(),
caller: address,
apparent_value: U256::from(0),
},
code_address: address,
is_static: true,
};
let PrecompileOutput { output, exit_status } =
ChainlinkOraclePrecompile::<Runtime>::execute(&mut handle).unwrap();
pretty_assertions::assert_eq!(exit_status, ExitSucceed::Returned);
U256::from_big_endian(&output)
}

#[test]
fn chainlink_precompile_should_return_gigahdx_exchange_rate_when_source_is_gigahdx() {
TestNet::reset();

Hydra::execute_with(|| {
register_st_hdx();
// 110 HDX in gigapot, 100 stHDX issued ⇒ rate = 1.1.
seed_gigapot_and_supply(110 * UNITS, 100 * UNITS);

pretty_assertions::assert_eq!(
pallet_gigahdx::Pallet::<Runtime>::exchange_rate().cmp(&hydra_dx_math::ratio::Ratio::new(11, 10)),
std::cmp::Ordering::Equal
);

let address = encode_oracle_address(STHDX, HDX_ID, OraclePeriod::TenMinutes, GIGAHDX_SOURCE);

// Pin the canonical mainnet feed address.
pretty_assertions::assert_eq!(
address,
EvmAddress::from(hex!("0000010267696761686478730000029e00000000"))
);

pretty_assertions::assert_eq!(chainlink_latest_answer(address), U256::from(110_000_000u128));
});
}

#[test]
fn chainlink_precompile_should_floor_at_one_when_gigahdx_reserves_drained() {
TestNet::reset();

Hydra::execute_with(|| {
register_st_hdx();
// Full drain: native rate would be 0 — pallet floor must clamp to 1.0.
seed_gigapot_and_supply(0, 100 * UNITS);

pretty_assertions::assert_eq!(
pallet_gigahdx::Pallet::<Runtime>::exchange_rate().cmp(&hydra_dx_math::ratio::Ratio::one()),
std::cmp::Ordering::Equal
);

let address = encode_oracle_address(STHDX, HDX_ID, OraclePeriod::TenMinutes, GIGAHDX_SOURCE);

pretty_assertions::assert_eq!(chainlink_latest_answer(address), U256::from(100_000_000u128));
});
}

#[test]
fn chainlink_precompile_should_floor_at_one_when_gigahdx_partially_drained() {
TestNet::reset();

Hydra::execute_with(|| {
register_st_hdx();
// Partial drain: native rate would be 0.5 — clamp must hit 1.0, not 50_000_000.
seed_gigapot_and_supply(50 * UNITS, 100 * UNITS);

pretty_assertions::assert_eq!(
pallet_gigahdx::Pallet::<Runtime>::exchange_rate().cmp(&hydra_dx_math::ratio::Ratio::one()),
std::cmp::Ordering::Equal
);

let address = encode_oracle_address(STHDX, HDX_ID, OraclePeriod::TenMinutes, GIGAHDX_SOURCE);

pretty_assertions::assert_eq!(chainlink_latest_answer(address), U256::from(100_000_000u128));
});
}
}

mod contract_deployment {
Expand Down
Loading
Loading