Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
kayabaNerve committed Jul 18, 2024
1 parent 4104650 commit b040dce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
22 changes: 14 additions & 8 deletions substrate/client/tests/genesis_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,22 @@ async fn test_genesis_liquidity(serai: Serai) {
provide_batch(&serai, batch).await;
}

// wait until genesis ends..
tokio::time::timeout(tokio::time::Duration::from_secs(3 * 10 * 6), async {
while serai.latest_finalized_block().await.unwrap().number() < 10 {
tokio::time::sleep(Duration::from_secs(6)).await;
}
})
// wait until genesis ends
let genesis_blocks = 10; // TODO
let block_time = 6; // TODO
tokio::time::timeout(
tokio::time::Duration::from_secs(3 * (genesis_blocks * block_time)),
async {
while serai.latest_finalized_block().await.unwrap().number() < 10 {
tokio::time::sleep(Duration::from_secs(6)).await;
}
},
)
.await
.unwrap();

// set prices
// set values relative to each other
// TODO: Random values here
let values = Values { monero: 184100, ether: 4785000, dai: 1500 };
set_values(&serai, &values).await;
let values_map = HashMap::from([
Expand Down Expand Up @@ -177,7 +183,7 @@ async fn test_genesis_liquidity(serai: Serai) {
}

async fn set_values(serai: &Serai, values: &Values) {
// prepare a Musig tx to set the initial prices
// prepare a Musig tx to oraclize the relative values
let pair = insecure_pair_from_name("Alice");
let public = pair.public();
// we publish the tx in set 4
Expand Down
1 change: 0 additions & 1 deletion substrate/genesis-liquidity/pallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ignored = ["scale", "scale-info"]
[lints]
workspace = true


[dependencies]
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
scale-info = { version = "2", default-features = false, features = ["derive"] }
Expand Down
6 changes: 3 additions & 3 deletions substrate/genesis-liquidity/pallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub mod pallet {
let final_block = MONTHS;

// Distribute the genesis sri to pools after a month
if n.saturated_into::<u64>() >= final_block &&
if (n.saturated_into::<u64>() >= final_block) &&
Self::oraclization_is_done() &&
GenesisComplete::<T>::get().is_none()
{
Expand Down Expand Up @@ -410,8 +410,8 @@ pub mod pallet {
) -> DispatchResult {
ensure_none(origin)?;

// set the prices
Oracle::<T>::set(Coin::Bitcoin, Some(10u64.pow(8)));
// set their relative values
Oracle::<T>::set(Coin::Bitcoin, Some(10u64.pow(Coin::Bitcoin.decimals())));
Oracle::<T>::set(Coin::Monero, Some(values.monero));
Oracle::<T>::set(Coin::Ether, Some(values.ether));
Oracle::<T>::set(Coin::Dai, Some(values.dai));
Expand Down
2 changes: 1 addition & 1 deletion substrate/genesis-liquidity/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use validator_sets_primitives::ValidatorSet;
pub const INITIAL_GENESIS_LP_SHARES: u64 = 10_000;

// This is the account to hold and manage the genesis liquidity.
pub const GENESIS_LIQUIDITY_ACCOUNT: SeraiAddress = system_address(b"Genesis-liquidity-account");
pub const GENESIS_LIQUIDITY_ACCOUNT: SeraiAddress = system_address(b"GenesisLiquidity-account");

#[derive(Clone, Copy, PartialEq, Eq, Debug, Encode, Decode, MaxEncodedLen, TypeInfo)]
#[cfg_attr(feature = "std", derive(Zeroize))]
Expand Down

0 comments on commit b040dce

Please sign in to comment.