Skip to content

Commit

Permalink
fix last pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akildemir committed Jul 4, 2024
1 parent ef70384 commit 1eee0a4
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 93 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion substrate/abi/src/genesis_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use primitives::*;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Call {
remove_coin_liquidity { balance: Balance },
set_initial_price { prices: Prices, signature: Signature },
oraclize_values { prices: Prices, signature: Signature },
}

#[derive(Clone, PartialEq, Eq, Debug, scale::Encode, scale::Decode, scale_info::TypeInfo)]
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/src/serai/genesis_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ impl<'a> SeraiGenesisLiquidity<'a> {
.await
}

pub fn set_initial_price(prices: Prices, signature: Signature) -> Transaction {
pub fn oraclize_values(prices: Prices, signature: Signature) -> Transaction {
Serai::unsigned(serai_abi::Call::GenesisLiquidity(
serai_abi::genesis_liquidity::Call::set_initial_price { prices, signature },
serai_abi::genesis_liquidity::Call::oraclize_values { prices, signature },
))
}

Expand Down
19 changes: 9 additions & 10 deletions substrate/client/tests/genesis_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use serai_client::{
};

use serai_abi::{
genesis_liquidity::primitives::{set_initial_price_message, Prices},
genesis_liquidity::primitives::{oraclize_values_message, Prices},
primitives::COINS,
};

Expand Down Expand Up @@ -101,7 +101,7 @@ async fn test_genesis_liquidity(serai: Serai) {
.unwrap();

// set prices
let prices = Prices { bitcoin: 10u64.pow(8), monero: 184100, ethereum: 4785000, dai: 1500 };
let prices = Prices { monero: 184100, ethereum: 4785000, dai: 1500 };
set_prices(&serai, &prices).await;

// wait little bit..
Expand All @@ -127,7 +127,7 @@ async fn test_genesis_liquidity(serai: Serai) {
let pool_btc = btc_addresses.iter().fold(0u128, |acc, value| acc + u128::from(value.1 .0));
let pool_xmr = xmr_addresses.iter().fold(0u128, |acc, value| acc + u128::from(value.1 .0));

let pool_btc_value = (pool_btc * u128::from(prices.bitcoin)) / 10u128.pow(8);
let pool_btc_value = pool_btc;
let pool_xmr_value = (pool_xmr * u128::from(prices.monero)) / 10u128.pow(12);
let total_value = pool_btc_value + pool_xmr_value;

Expand Down Expand Up @@ -176,7 +176,8 @@ async fn set_prices(serai: &Serai, prices: &Prices) {
// prepare a Musig tx to set the initial prices
let pair = insecure_pair_from_name("Alice");
let public = pair.public();
let set = ValidatorSet { session: Session(0), network: NetworkId::Serai };
// we publish the tx in set 2
let set = ValidatorSet { session: Session(2), network: NetworkId::Serai };

let public_key = <Ristretto as Ciphersuite>::read_G::<&[u8]>(&mut public.0.as_ref()).unwrap();
let secret_key = <Ristretto as Ciphersuite>::read_F::<&[u8]>(
Expand All @@ -195,13 +196,11 @@ async fn set_prices(serai: &Serai, prices: &Prices) {
&Schnorrkel::new(b"substrate"),
&HashMap::from([(threshold_keys.params().i(), threshold_keys.into())]),
),
&set_initial_price_message(&set, prices),
&oraclize_values_message(&set, prices),
);

// set initial prices
let _ = publish_tx(
serai,
&SeraiGenesisLiquidity::set_initial_price(*prices, Signature(sig.to_bytes())),
)
.await;
let _ =
publish_tx(serai, &SeraiGenesisLiquidity::oraclize_values(*prices, Signature(sig.to_bytes())))
.await;
}
Loading

0 comments on commit 1eee0a4

Please sign in to comment.