mirror of
https://github.com/serai-dex/serai.git
synced 2024-12-26 05:29:55 +00:00
695d1f0ecf
* Remove subxt Removes ~20 crates from our Cargo.lock. Removes downloading the metadata and enables removing the getMetadata RPC route (relevant to #379). Moves forward #337. Done now due to distinctions in the subxt 0.32 API surface which make it justifiable to not update. * fmt, update due to deny triggering on a yanked crate * Correct the handling of substrate_block_notifier now that it's ephemeral, not long-lived * Correct URL in tests/coordinator from ws to http
49 lines
969 B
Rust
49 lines
969 B
Rust
use serai_runtime::primitives::{Coin, Amount};
|
|
|
|
use serai_client::{Serai, SeraiDex};
|
|
use sp_core::{sr25519::Pair, Pair as PairTrait};
|
|
|
|
use crate::common::tx::publish_tx;
|
|
|
|
#[allow(dead_code)]
|
|
pub async fn add_liquidity(
|
|
serai: &Serai,
|
|
coin: Coin,
|
|
coin_amount: Amount,
|
|
sri_amount: Amount,
|
|
nonce: u32,
|
|
pair: Pair,
|
|
) -> [u8; 32] {
|
|
let address = pair.public();
|
|
|
|
let tx = serai.sign(
|
|
&pair,
|
|
&SeraiDex::add_liquidity(coin, coin_amount, sri_amount, Amount(1), Amount(1), address.into()),
|
|
nonce,
|
|
0,
|
|
);
|
|
|
|
publish_tx(serai, &tx).await
|
|
}
|
|
|
|
#[allow(dead_code)]
|
|
pub async fn swap(
|
|
serai: &Serai,
|
|
from_coin: Coin,
|
|
to_coin: Coin,
|
|
amount_in: Amount,
|
|
amount_out_min: Amount,
|
|
nonce: u32,
|
|
pair: Pair,
|
|
) -> [u8; 32] {
|
|
let address = pair.public();
|
|
|
|
let tx = serai.sign(
|
|
&pair,
|
|
&SeraiDex::swap(from_coin, to_coin, amount_in, amount_out_min, address.into()),
|
|
nonce,
|
|
Default::default(),
|
|
);
|
|
|
|
publish_tx(serai, &tx).await
|
|
}
|