Skip to content

Commit

Permalink
feat: add zenlink rpcs to parachain service
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Hill <[email protected]>
  • Loading branch information
gregdhill committed Jan 24, 2023
1 parent babf97a commit 0c02495
Show file tree
Hide file tree
Showing 17 changed files with 718 additions and 26 deletions.
61 changes: 55 additions & 6 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ redeem-rpc-runtime-api = { path = "../crates/redeem/rpc/runtime-api" }
replace-rpc-runtime-api = { path = "../crates/replace/rpc/runtime-api" }
loans-rpc-runtime-api = { path = "../crates/loans/rpc/runtime-api" }

# Zenlink dependencies
zenlink-protocol-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00" }
zenlink-stable-amm-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00" }

# Substrate dependencies
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.31" }
Expand Down
12 changes: 11 additions & 1 deletion parachain/runtime/interlay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu
orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }
orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }

# Zenlink dependencies
zenlink-protocol = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }
zenlink-protocol-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }
zenlink-stable-amm-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }

[dev-dependencies]
hex = '0.4.2'
mocktopus = "0.8.0"
Expand Down Expand Up @@ -238,6 +243,10 @@ std = [
"orml-xcm-support/std",
"orml-unknown-tokens/std",
"orml-asset-registry/std",

"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
"zenlink-stable-amm-runtime-api/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down Expand Up @@ -316,5 +325,6 @@ try-runtime = [
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
"orml-xtokens/try-runtime",
"orml-unknown-tokens/try-runtime"
"orml-unknown-tokens/try-runtime",
"zenlink-protocol/try-runtime",
]
107 changes: 106 additions & 1 deletion parachain/runtime/interlay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub use security::StatusCode;

pub use primitives::{
self, AccountId, Balance, BlockNumber, CurrencyInfo, Hash, Liquidity, Moment, Nonce, Rate, Ratio, Shortfall,
Signature, SignedFixedPoint, SignedInner, UnsignedFixedPoint, UnsignedInner,
Signature, SignedFixedPoint, SignedInner, StablePoolId, UnsignedFixedPoint, UnsignedInner,
};

// XCM imports
Expand Down Expand Up @@ -1413,6 +1413,111 @@ impl_runtime_apis! {
}
}

impl zenlink_protocol_runtime_api::ZenlinkProtocolApi<Block, AccountId, CurrencyId> for Runtime {
fn get_balance(
_asset_id: CurrencyId,
_owner: AccountId
) -> zenlink_protocol::AssetBalance {
Default::default()
}

fn get_sovereigns_info(
_asset_id: CurrencyId
) -> Vec<(u32, AccountId, zenlink_protocol::AssetBalance)> {
Default::default()
}

fn get_pair_by_asset_id(
_asset_0: CurrencyId,
_asset_1: CurrencyId
) -> Option<zenlink_protocol::PairInfo<AccountId, zenlink_protocol::AssetBalance, CurrencyId>> {
Default::default()
}

fn get_amount_in_price(
_supply: zenlink_protocol::AssetBalance,
_path: Vec<CurrencyId>
) -> zenlink_protocol::AssetBalance {
Default::default()
}

fn get_amount_out_price(
_supply: zenlink_protocol::AssetBalance,
_path: Vec<CurrencyId>
) -> zenlink_protocol::AssetBalance {
Default::default()
}

fn get_estimate_lptoken(
_asset_0: CurrencyId,
_asset_1: CurrencyId,
_amount_0_desired: zenlink_protocol::AssetBalance,
_amount_1_desired: zenlink_protocol::AssetBalance,
_amount_0_min: zenlink_protocol::AssetBalance,
_amount_1_min: zenlink_protocol::AssetBalance,
) -> zenlink_protocol::AssetBalance {
Default::default()
}
}

impl zenlink_stable_amm_runtime_api::StableAmmApi<Block, CurrencyId, Balance, AccountId, StablePoolId> for Runtime {
fn get_virtual_price(_pool_id: StablePoolId) -> Balance {
Default::default()
}

fn get_a(_pool_id: StablePoolId) -> Balance {
Default::default()
}

fn get_a_precise(_pool_id: StablePoolId) -> Balance {
Default::default()
}

fn get_currencies(_pool_id: StablePoolId) -> Vec<CurrencyId> {
Default::default()
}

fn get_currency(_pool_id: StablePoolId, _index: u32) -> Option<CurrencyId> {
Default::default()
}

fn get_lp_currency(_pool_id: StablePoolId) -> Option<CurrencyId> {
Default::default()
}

fn get_currency_precision_multipliers(_pool_id: StablePoolId) -> Vec<Balance> {
Default::default()
}

fn get_currency_balances(_pool_id: StablePoolId) -> Vec<Balance> {
Default::default()
}

fn get_number_of_currencies(_pool_id: StablePoolId) -> u32 {
Default::default()
}

fn get_admin_balances(_pool_id: StablePoolId) -> Vec<Balance> {
Default::default()
}

fn calculate_currency_amount(_pool_id: StablePoolId, _amounts: Vec<Balance>, _deposit: bool) -> Balance {
Default::default()
}

fn calculate_swap(_pool_id: StablePoolId, _in_index: u32, _out_index: u32, _in_amount: Balance) -> Balance {
Default::default()
}

fn calculate_remove_liquidity(_pool_id: StablePoolId, _amount: Balance) -> Vec<Balance> {
Default::default()
}

fn calculate_remove_liquidity_one_currency(_pool_id: StablePoolId, _amount: Balance, _index: u32) -> Balance {
Default::default()
}
}

#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn benchmark_metadata(extra: bool) -> (
Expand Down
12 changes: 11 additions & 1 deletion parachain/runtime/kintsugi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu
orml-unknown-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }
orml-asset-registry= { git = "https://github.com/open-web3-stack/open-runtime-module-library", rev = "dc39cfddefb10ef0de23655e2c3dcdab66a19404", default-features = false }

# Zenlink dependencies
zenlink-protocol = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }
zenlink-protocol-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }
zenlink-stable-amm-runtime-api = { git = "https://github.com/interlay/Zenlink-DEX-Module", rev = "1d286f77d8fe38f3a437d35a0600081c2f5b5a00", default-features = false }

[dev-dependencies]
hex = '0.4.2'
mocktopus = "0.8.0"
Expand Down Expand Up @@ -244,6 +249,10 @@ std = [
"orml-xtokens/std",
"orml-xcm-support/std",
"orml-unknown-tokens/std",

"zenlink-protocol/std",
"zenlink-protocol-runtime-api/std",
"zenlink-stable-amm-runtime-api/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down Expand Up @@ -320,5 +329,6 @@ try-runtime = [
"cumulus-pallet-xcm/try-runtime",
"cumulus-pallet-dmp-queue/try-runtime",
"orml-xtokens/try-runtime",
"orml-unknown-tokens/try-runtime"
"orml-unknown-tokens/try-runtime",
"zenlink-protocol/try-runtime",
]
Loading

0 comments on commit 0c02495

Please sign in to comment.