Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions .github/workflows/run_linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ jobs:
protoc --version
curl -s https://sh.rustup.rs -sSf | sh -s -- -y
source ${HOME}/.cargo/env
rustup toolchain install nightly-2023-03-13
rustup default nightly-2023-03-13
cargo install taplo-cli
rustup toolchain install nightly-2023-03-03
rustup default nightly-2023-03-03
cargo install taplo-cli --locked
- name: cache cargo
uses: Swatinem/rust-cache@v2
- name: Check Formatting
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
13 changes: 13 additions & 0 deletions tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import {BN} from "@polkadot/util";

export const MANTA_1B = "1000000000000000000000000000";
export const MANTA_1K = new BN("1000000000000000000000");
export const MANTA_1M = new BN("1000000000000000000000000");
export const MANTA_10M = new BN("10000000000000000000000000");
export const LP_1K = "1000000000000000";
export const LP_2K = "2000000000000000";
export const USDT_10M = new BN("10000000000000");
Expand Down Expand Up @@ -89,4 +91,15 @@ export const LP_USDT_USDC_METADATA = {
},
minBalance: 1,
isSufficient: true
};

export const LP_NATIVE_USDT_METADATA = {
metadata: {
name: "LP-NATIVE-USDT",
symbol: "LP",
decimals: 12,
isFrozen: false
},
minBalance: 1,
isSufficient: true
};
28 changes: 27 additions & 1 deletion tests/tests/test-dex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import {describeWithManta, executeTx, remark} from "./util";
import '@polkadot/api-augment';
import {
LP_1K, LP_2K,
LP_USDT_USDC_METADATA, MANTA_1K, USDC_10M, USDC_20M,
LP_USDT_USDC_METADATA, LP_NATIVE_USDT_METADATA,
MANTA_1K, MANTA_1M, MANTA_10M, USDC_10M, USDC_20M,
USDC_LOCATION,
USDC_METADATA,
USDT_10M, USDT_20M,
USDT_LOCATION,
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 +83,29 @@ describeWithManta("Manta RPC (Dex)", (context) => {

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

let fees_factor = 200; // 0.5%
callData = api.tx.zenlinkProtocol.setNativeSwapFeeFactor(fees_factor);
await executeTx(context, callData, true);

callData = api.tx.assetManager.registerLpAsset(1, 8, LP_NATIVE_USDT_METADATA);
await executeTx(context, callData, true);

await new Promise((res) => setTimeout(res, 2000));

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

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

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

const expectedSwapFee = new BN("5000000000000000000000");
const swapFeesBalance = (await api.query.system.account("dfZ2W8UP6LNgBri4nYSZaXXLUpXbvZM6KhpxPQnFJiKkdVvZi")).data.free.toString();
console.log("Swap fees pot balance: ", swapFeesBalance);
expect(swapFeesBalance).to.equal(expectedSwapFee.toString())
});
});