Skip to content
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/workflows/integration_test_manta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
if: contains(github.event.pull_request.labels.*.name, 'A-manta')
needs: [build-node-current]
runs-on: runtime-integration-test
timeout-minutes: 240
timeout-minutes: 420
container:
image: ubuntu:20.04
strategy:
Expand Down
14 changes: 7 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ sc-transaction-pool-api = { git = "https://github.com/paritytech/substrate.git",

pallet-farming-rpc-api = { path = "../pallets/farming/rpc" }
pallet-farming-rpc-runtime-api = { path = "../pallets/farming/rpc/runtime-api" }
zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
zenlink-protocol-rpc = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37" }
zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937" }
zenlink-protocol-rpc = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937" }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937" }

# Substrate client dependencies
sc-basic-authorship = { git = 'https://github.com/paritytech/substrate.git', branch = "polkadot-v0.9.37" }
Expand Down
2 changes: 1 addition & 1 deletion pallets/asset-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sp-std = { git = "https://github.com/paritytech/substrate.git", branch = "polkad
xcm = { git = "https://github.com/paritytech/polkadot.git", default-features = false, branch = "release-v0.9.37" }

# 3rd party dependencies
orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", default-features = false, branch = "polkadot-v0.9.37" }
orml-traits = { git = "https://github.com/manta-network/open-runtime-module-library.git", branch = "polkadot-v0.9.37", default-features = false }

[dev-dependencies]
pallet-assets = { git = "https://github.com/paritytech/substrate.git", branch = "polkadot-v0.9.37" }
Expand Down
8 changes: 4 additions & 4 deletions runtime/calamari/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ runtime-common = { path = '../common', default-features = false }
session-key-primitives = { path = '../../primitives/session-keys', default-features = false }

# Third party (vendored) dependencies
orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.37" }
orml-xtokens = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.37" }
orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', branch = "polkadot-v0.9.37", default-features = false }
orml-xtokens = { git = 'https://github.com/manta-network/open-runtime-module-library.git', branch = "polkadot-v0.9.37", default-features = false }

zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37", default-features = false }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37", default-features = false }
zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937", default-features = false }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937", default-features = false }

[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
Expand Down
16 changes: 15 additions & 1 deletion runtime/calamari/src/diff_tx_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2923,7 +2923,7 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
use zenlink_protocol::AssetId as ZenlinkAssetId;
assert_eq!(
crate::RuntimeCall::get_call_names("ZenlinkProtocol").len(),
16,
17,
"Please update new extrinsic here."
);
// set_fee_receiver
Expand Down Expand Up @@ -3167,6 +3167,20 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
dispatch_info,
call_len,
));

// set_native_swap_fee_factor
let call = crate::RuntimeCall::ZenlinkProtocol(
zenlink_protocol::Call::set_native_swap_fee_factor {
native_swap_fees_factor: 200u128,
},
);
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"zenlink_protocol",
"set_native_swap_fee_factor",
dispatch_info,
call_len,
));
}

(calamari_runtime_calls, t)
Expand Down
2 changes: 2 additions & 0 deletions runtime/calamari/src/zenlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use zenlink_protocol::{
// Normal Coin AMM
parameter_types! {
pub const ZenlinkPalletId: PalletId = PalletId(*b"/zenlink");
pub const NativeSwapFeesPotId: PalletId = PalletId(*b"/swappot");
pub SelfParaId: u32 = ParachainInfo::parachain_id().into();
pub MantaNativeAssetId: CalamariAssetId = 1;
pub ZenlinkNativeAssetId: u64 = 0;
Expand All @@ -41,6 +42,7 @@ impl zenlink_protocol::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MultiAssetsHandler = MultiAssets;
type PalletId = ZenlinkPalletId;
type NativeSwapFeesPotId = NativeSwapFeesPotId;
type SelfParaId = SelfParaId;
type AssetId = ZenlinkAssetId;
#[cfg(not(feature = "runtime-benchmarks"))]
Expand Down
8 changes: 4 additions & 4 deletions runtime/manta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ xcm-builder = { git = 'https://github.com/paritytech/polkadot.git', default-feat
xcm-executor = { git = 'https://github.com/paritytech/polkadot.git', default-features = false, branch = "release-v0.9.37" }

# Third party (vendored) dependencies
orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.37" }
orml-xtokens = { git = 'https://github.com/manta-network/open-runtime-module-library.git', default-features = false, branch = "polkadot-v0.9.37" }
orml-traits = { git = 'https://github.com/manta-network/open-runtime-module-library.git', branch = "polkadot-v0.9.37", default-features = false }
orml-xtokens = { git = 'https://github.com/manta-network/open-runtime-module-library.git', branch = "polkadot-v0.9.37", default-features = false }

zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37", default-features = false }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "polkadot-v0.9.37", default-features = false }
zenlink-protocol = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937", default-features = false }
zenlink-protocol-runtime-api = { git = 'https://github.com/manta-network/Zenlink', branch = "ghzlatarev/v0937", default-features = false }

# Self dependencies
manta-collator-selection = { path = '../../pallets/collator-selection', default-features = false }
Expand Down
16 changes: 15 additions & 1 deletion runtime/manta/src/diff_tx_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2910,7 +2910,7 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
use zenlink_protocol::AssetId as ZenlinkAssetId;
assert_eq!(
crate::RuntimeCall::get_call_names("ZenlinkProtocol").len(),
16,
17,
"Please update new extrinsic here."
);
// set_fee_receiver
Expand Down Expand Up @@ -3154,6 +3154,20 @@ fn calculate_all_current_extrinsic_tx_fee() -> (
dispatch_info,
call_len,
));

// set_native_swap_fee_factor
let call = crate::RuntimeCall::ZenlinkProtocol(
zenlink_protocol::Call::set_native_swap_fee_factor {
native_swap_fees_factor: 200u128,
},
);
let (dispatch_info, call_len) = get_call_details(&call);
calamari_runtime_calls.push((
"zenlink_protocol",
"set_native_swap_fee_factor",
dispatch_info,
call_len,
));
}

(calamari_runtime_calls, t)
Expand Down
2 changes: 2 additions & 0 deletions runtime/manta/src/zenlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use zenlink_protocol::{
// Normal Coin AMM
parameter_types! {
pub const ZenlinkPalletId: PalletId = PalletId(*b"/zenlink");
pub const NativeSwapFeesPotId: PalletId = PalletId(*b"/swappot");
pub SelfParaId: u32 = ParachainInfo::parachain_id().into();
pub MantaNativeAssetId: MantaAssetId = 1;
pub ZenlinkNativeAssetId: u64 = 0;
Expand All @@ -41,6 +42,7 @@ impl zenlink_protocol::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type MultiAssetsHandler = MultiAssets;
type PalletId = ZenlinkPalletId;
type NativeSwapFeesPotId = NativeSwapFeesPotId;
type SelfParaId = SelfParaId;
type AssetId = ZenlinkAssetId;
#[cfg(not(feature = "runtime-benchmarks"))]
Expand Down
28 changes: 28 additions & 0 deletions tests/tests/test-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
USDT_METADATA
} from "../constants";
import {BN} from "@polkadot/util";
import { delay } from "../test-util";

describeWithManta("Manta RPC (Dex)", (context) => {
step("dex add liquidity should work", async function () {
Expand Down Expand Up @@ -81,5 +82,32 @@ describeWithManta("Manta RPC (Dex)", (context) => {

state = await api.query.assets.account(10, alice);
expect(JSON.parse(JSON.stringify(state))).to.equal(null);

callData = api.tx.zenlinkProtocol.setNativeSwapFeeFactor(200);
await executeTx(context, callData, true);

await delay(12000);

callData = api.tx.zenlinkProtocol.createPair([parachainId,0,1], [parachainId,2,8]);
await executeTx(context, callData, true);

callData = api.tx.zenlinkProtocol.addLiquidity([parachainId,0,1], [parachainId,2,8],
MANTA_1K, USDT_10M, MANTA_1K, USDT_10M, 1000);
await executeTx(context, callData);

callData = api.tx.zenlinkProtocol.swapExactAssetsForAssets(100,10,[[parachainId,0,1],[parachainId,2,8]],alice,1000000);
await executeTx(context, callData);

await delay(24000);

const swapFeesBalance = (await api.query.system.account("0x2f73776170706f74000000000000000000000000000000000000000000000000")).data.free.toString();
console.log("Swap fees pot balance: ", swapFeesBalance);
const swapFeesBalance2 = (await api.query.system.account("0x2f73776170706f7400000000000000000000000000000000000000000000000000")).data.free.toString();
console.log("Swap fees pot balance: ", swapFeesBalance2);
// #[pallet::compact] amount_in: AssetBalance,
// #[pallet::compact] amount_out_min: AssetBalance,
// path: Vec<T::AssetId>,
// recipient: T::AccountId,
// #[pallet::compact] deadline: T::BlockNumber,
});
});