Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Asset Conversion pallet #12984

Merged
merged 232 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 115 commits
Commits
Show all changes
232 commits
Select commit Hold shift + click to select a range
e8b13b6
Add pallet dex
jsidorenko Aug 2, 2022
afc2836
Fmt
jsidorenko Aug 2, 2022
1205c76
Add RPC endpoint
jsidorenko Aug 2, 2022
ceff65c
Fix RPC
jsidorenko Aug 2, 2022
8a9e330
Fix the build
jsidorenko Aug 2, 2022
cc98057
Some more fixes
jsidorenko Aug 3, 2022
bdbcfec
Add a method to topup pallet's account
jsidorenko Aug 3, 2022
106bfab
Add support for multi-currency into Uniques
jsidorenko Aug 3, 2022
0fd70fb
Fix the build
jsidorenko Aug 3, 2022
b9491ee
Add [transactional] + setup() + fix balances
jsidorenko Aug 3, 2022
f5e71e9
Improve tests
jsidorenko Aug 3, 2022
04ea005
Fix price quotation
jsidorenko Aug 3, 2022
7124090
Code clean up
jsidorenko Aug 3, 2022
e5d8a4d
Validate swaps
jsidorenko Aug 3, 2022
94cabb4
Fmt
jsidorenko Aug 3, 2022
3c8fb00
Update README
jsidorenko Aug 3, 2022
00a09b7
add test
gilescope Nov 8, 2022
99c18ec
mint LP assets in a different instance
gilescope Nov 8, 2022
0883485
remove transactional as now the default
gilescope Nov 9, 2022
ab04ad3
Merge pull request #1 from paritytech/giles-more
Nov 11, 2022
1b28af3
merge master
gilescope Nov 11, 2022
0aabfef
Merge pull request #2 from paritytech/giles-more
Nov 14, 2022
69b21d6
Revert "Merge master"
Nov 14, 2022
b4f6ea9
Merge pull request #4 from jsidorenko/revert-2-giles-more
Nov 14, 2022
2b4696c
Merge branch 'master' into update-master
gilescope Nov 21, 2022
eac18b3
Merge pull request #5 from paritytech/update-master
Nov 22, 2022
f406417
fix tests post merge.
gilescope Nov 22, 2022
a969f85
Merge pull request #6 from paritytech/giles-fix-tests
Nov 22, 2022
ccd34ad
attempt to set create origin
gilescope Nov 22, 2022
7c704ad
Internally allocate lp asset id.
gilescope Nov 23, 2022
279327f
Merge pull request #7 from paritytech/giles-set-create-origin
Nov 23, 2022
6bc91c8
Simplify
gilescope Nov 23, 2022
d73137f
Merge pull request #8 from paritytech/giles-set-create-origin
Nov 24, 2022
0289b6d
Merge remote-tracking branch 'origin/master' into giles-set-create-or…
gilescope Nov 25, 2022
5ebb52d
Bump to be in line
gilescope Nov 25, 2022
7700b25
additional bumps to make compile
gilescope Nov 25, 2022
fabb0fd
fix compile
gilescope Nov 25, 2022
21a2ac1
Merge pull request #9 from paritytech/giles-set-create-origin
Nov 25, 2022
e829cf4
Merge branch 'paritytech:master' into master
jsidorenko Nov 25, 2022
a6618f1
less bounds
gilescope Dec 5, 2022
aadad92
Merge pull request #10 from jsidorenko/giles-less-bounds
Dec 5, 2022
ac650c8
use fungible crates
gilescope Dec 7, 2022
eec3dd5
Merge pull request #11 from jsidorenko/giles-currency-to-fungable
Dec 8, 2022
3872184
multiasset enum
gilescope Dec 10, 2022
97936d6
only allow native currency pairs
gilescope Dec 10, 2022
68251e9
added slippage tests
gilescope Dec 11, 2022
0a17ab5
transfer into separate method
gilescope Dec 12, 2022
6d78fef
Merge pull request #13 from jsidorenko/giles-multi-asset-enum
Dec 12, 2022
f8ee5cc
Add benchmarks + weights
jsidorenko Dec 12, 2022
b6b860d
Typos
jsidorenko Dec 12, 2022
a97e46a
Clean up
jsidorenko Dec 12, 2022
ac091f7
Merge pull request #14 from jsidorenko/js-add-benchmarks
jsidorenko Dec 12, 2022
3cf6239
More tests,
gilescope Dec 12, 2022
236bef4
tighten up naming
gilescope Dec 13, 2022
20ccea2
Merge pull request #15 from jsidorenko/giles-more-tests
Dec 13, 2022
7800d10
Default, zero, square root traits not needed
gilescope Dec 13, 2022
4cebb9b
Merge pull request #16 from jsidorenko/giles-more-tests
Dec 14, 2022
9ec3871
add keep-alive param
gilescope Dec 14, 2022
36f830f
add insufficient liquidity test
gilescope Dec 14, 2022
a482298
Merge pull request #17 from jsidorenko/keep-alive
Dec 15, 2022
5b98910
Fix quote() to support u64
jsidorenko Dec 15, 2022
514332d
Avoid recording balances twice
gilescope Dec 15, 2022
a25f989
cargo fmt
gilescope Dec 15, 2022
1685cfc
Didn't mean to change error type
gilescope Dec 15, 2022
2d29613
temp
gilescope Dec 15, 2022
899045e
Less
gilescope Dec 15, 2022
b11b5f5
Rework get_amount_in/get_amount_out
jsidorenko Dec 15, 2022
abcc619
Convert other places
jsidorenko Dec 15, 2022
2e93e69
Rework the last piece
jsidorenko Dec 15, 2022
7009fc1
Merge pull request #18 from jsidorenko/js-check-u64
jsidorenko Dec 15, 2022
a386c58
Merge branch 'master' into giles-remove-balances
jsidorenko Dec 16, 2022
d6e5ee3
Merge pull request #19 from jsidorenko/giles-remove-balances
Dec 16, 2022
45099c9
Typo
jsidorenko Dec 16, 2022
22dcf91
Fix benchmarks
jsidorenko Dec 16, 2022
38498a9
use hash trait
gilescope Dec 16, 2022
a9a291c
Extract a native asset check into the runtime setting
jsidorenko Dec 16, 2022
34c9adf
Don't set the metadata
jsidorenko Dec 16, 2022
5d959ba
Merge pull request #22 from jsidorenko/js-extract-native-asset-check
jsidorenko Dec 16, 2022
7b0d909
Merge pull request #23 from jsidorenko/js-remove-metadata-creation
jsidorenko Dec 16, 2022
e154075
Merge pull request #21 from jsidorenko/giles-hash-trait
Dec 16, 2022
b4b99b3
Merge pull request #20 from jsidorenko/js-fix-benchmarks
Dec 16, 2022
9c8bd5e
Remove spec file
jsidorenko Dec 16, 2022
bb12ad6
Enable multi-assets swaps by default
jsidorenko Dec 16, 2022
a4704ee
Refactor conversion into u128
jsidorenko Dec 16, 2022
027c7a5
Merge pull request #25 from jsidorenko/js-improve-u128-support
jsidorenko Dec 16, 2022
0c6a515
Merge pull request #24 from jsidorenko/js-enable-multi-assets-swaps
jsidorenko Dec 16, 2022
dbcacff
Add path param to swap_token_for_exact_tokens
jsidorenko Dec 18, 2022
1e5a054
Fix typo + a bit of refactoring
jsidorenko Dec 19, 2022
9df535e
Implement path param for swap_exact_tokens_for_tokens()
jsidorenko Dec 19, 2022
66f27f0
Deref
jsidorenko Dec 19, 2022
f4ef006
Minor fixes
jsidorenko Dec 19, 2022
b7fb31d
Add test with sensible scale values
gilescope Dec 19, 2022
759eb91
Use .windows()
jsidorenko Dec 19, 2022
dbf9f12
Fix benchmarks
jsidorenko Dec 19, 2022
b974f23
update docs
gilescope Dec 19, 2022
c6061b3
Merge pull request #28 from jsidorenko/giles-update-docs
Dec 20, 2022
49ca641
Merge pull request #27 from jsidorenko/add-realistic-test
Dec 20, 2022
fe926c4
Fix everything :)
jsidorenko Dec 20, 2022
72c238a
Merge branch 'master' into js-multi-swaps
jsidorenko Dec 20, 2022
92f5486
Chore
jsidorenko Dec 20, 2022
9cb0779
Revert
jsidorenko Dec 20, 2022
318d488
Merge pull request #26 from jsidorenko/js-multi-swaps
jsidorenko Dec 20, 2022
6958800
Chore
jsidorenko Dec 20, 2022
e79d443
prev way of creating sub accounts lead to collisions
gilescope Dec 20, 2022
b7608cf
Update frame/dex/src/lib.rs
Dec 20, 2022
d9c3d99
Update frame/dex/src/lib.rs
Dec 20, 2022
c1ab888
Merge pull request #29 from jsidorenko/giles-truncated
Dec 20, 2022
09e1dbc
Chore
jsidorenko Dec 20, 2022
15a6969
Fmt fix on Uniques
jsidorenko Dec 20, 2022
a4ac2d4
Merge remote-tracking branch 'jeger/master' into dex-pallet
gilescope Dec 20, 2022
331c4e9
add call_index
gilescope Dec 20, 2022
4e146ca
revert readme changes
gilescope Dec 20, 2022
7a2e142
add cr
gilescope Dec 20, 2022
f984658
revert uniques changes
gilescope Dec 20, 2022
23866c5
reducing noise
gilescope Dec 20, 2022
20f1672
no need for deadline (#12990)
gilescope Dec 21, 2022
d75b442
fix kitchen sink (#12991)
gilescope Dec 21, 2022
d7ad301
add BenchmarkHelper for second instance (#12998)
gilescope Dec 22, 2022
9bd3d21
update mock to latest master
gilescope Dec 22, 2022
97a0992
less indirections (#13012)
gilescope Dec 23, 2022
e8c2c4f
remove dex PR's custom RPC (#13050)
gilescope Jan 3, 2023
5dfcb56
no longer a need to upgrade rpc version (#13053)
gilescope Jan 3, 2023
b00004a
Merge branch 'master' into dex-pallet
gilescope Jan 16, 2023
cd41d6b
add CallbackHadle
gilescope Jan 20, 2023
5a8da1e
quote bugfix (#13191)
gilescope Jan 21, 2023
8db89ab
Merge branch 'master' into dex-pallet
gilescope Jan 22, 2023
9fc0a35
merging in dex specific changes due to pay by dex
gilescope Feb 13, 2023
fed34ba
update lock file
gilescope Feb 13, 2023
1b64115
merging in kitchen sink changes
gilescope Feb 13, 2023
121ee7d
Merge remote-tracking branch 'origin/master' into dex-pallet
Mar 6, 2023
fcbbd34
Merge branch 'master' into dex-pallet
gilescope Mar 9, 2023
81f0e38
Merge remote-tracking branch 'origin/master' into dex-pallet
Mar 16, 2023
8ff6179
Add get_reserves() api method
jsidorenko Mar 17, 2023
3cdc595
Partial updating of the benchmarks
gilescope Mar 20, 2023
ffe2953
Merge branch 'dex-pallet' of github.com:paritytech/substrate into dex…
gilescope Mar 20, 2023
47d3537
Merge branch 'master' into dex-pallet
jsidorenko Mar 21, 2023
bbe81ba
Fix tests
jsidorenko Mar 22, 2023
a1edec0
clippy
jsidorenko Mar 22, 2023
67711a7
Temp fix weights
jsidorenko Mar 22, 2023
63add87
Fix benchmarks
jsidorenko Mar 22, 2023
0c78cfe
Add pool setup fee
jsidorenko Mar 22, 2023
386e424
Money upfront
jsidorenko Mar 22, 2023
80602cc
Address some comments
jsidorenko Mar 22, 2023
458eda8
Use u128 in mock
jsidorenko Mar 23, 2023
f325993
Fix benchmarks
jsidorenko Mar 23, 2023
d84ac9a
Change error message
jsidorenko Mar 24, 2023
3adf116
Update comments
jsidorenko Mar 24, 2023
d06ce8a
Change error names
jsidorenko Mar 24, 2023
437392c
Implement PartialOrd for NativeOrAssetId
jsidorenko Mar 24, 2023
e2e24a2
add note
jsidorenko Mar 24, 2023
923193b
Update errors
jsidorenko Mar 24, 2023
4c7ee70
More tests for assets sorting
jsidorenko Mar 24, 2023
f8b7a85
Merge branch 'master' of https://github.com/paritytech/substrate into…
Mar 24, 2023
c657b58
".git/.scripts/commands/bench/bench.sh" pallet dev pallet_dex
Mar 24, 2023
73daaa2
Change the way we generate pool accounts
jsidorenko Mar 27, 2023
cf0f790
Improve the liquidity removal method
jsidorenko Mar 27, 2023
3023cc3
Extract MintMinLiquidity to config, rework all tests
jsidorenko Mar 29, 2023
9229802
Add comments
jsidorenko Mar 29, 2023
89e1e41
Validate provided amount
jsidorenko Mar 30, 2023
c8c5aa6
Rename to asset-conversion
jsidorenko Mar 30, 2023
ca3b8d6
Validate ED
jsidorenko Mar 30, 2023
6828602
Improve handling the ED related errors
jsidorenko Mar 30, 2023
cfc9b30
typos
jsidorenko Mar 30, 2023
edf4b12
Try to fix benchmarks
jsidorenko Mar 30, 2023
c79eb8d
Merge branch 'master' into dex-pallet
jsidorenko Mar 30, 2023
60e1707
Another try
jsidorenko Mar 30, 2023
852f297
Another day, another try
jsidorenko Mar 31, 2023
74f26e1
Fix benchmarks
jsidorenko Mar 31, 2023
69fcf71
Expose fee related params
jsidorenko Apr 4, 2023
f553104
Validate token's minimal amount the same way as ED
jsidorenko Apr 7, 2023
a93f6d6
fix typo
gilescope Apr 11, 2023
8d48599
Merge branch 'master' into dex-pallet
gilescope Apr 12, 2023
7a1638a
Use longer path for swaps in benchmarks
jsidorenko Apr 18, 2023
c2220b5
Merge branch 'dex-pallet' of https://github.com/paritytech/substrate …
gilescope Apr 19, 2023
305a7eb
need to ref sp_std's vec.
gilescope Apr 19, 2023
732df43
Remove From<u32> requirement when benchmarking
gilescope Apr 19, 2023
bbf7d41
impl BenchmarkHelper for ()
gilescope Apr 20, 2023
fb5a946
only for runtime benchmarks
gilescope Apr 21, 2023
e608d9c
MultiLocation: !MaybeDisplay
gilescope Apr 21, 2023
82f6be6
Update frame/asset-conversion/src/lib.rs
gilescope Apr 21, 2023
ccccaa8
Update frame/asset-conversion/src/lib.rs
gilescope Apr 21, 2023
b4f7a63
Merge branch 'master' into dex-pallet
gilescope Apr 21, 2023
e4e6844
Add documentation links
gilescope Apr 21, 2023
bb84701
add collision test
gilescope Apr 21, 2023
bcd826c
Revert "[Enhancement] Throw an error when there are too many pallets …
gilescope Apr 25, 2023
70bdfae
[Enhancement] Throw an error when there are too many pallets (#13763)
ruseinov Mar 30, 2023
f1efb7d
Merge branch 'master' into dex-pallet
gilescope Apr 25, 2023
a51e6da
add benchmark helper
gilescope Apr 25, 2023
9bcaacf
cargo fmt
gilescope Apr 25, 2023
cdf673a
Fix adding liquidity to non-empty pool
jsidorenko Apr 25, 2023
a2870a7
Fix compilation error
jsidorenko Apr 25, 2023
661075b
Fix params ordering issue
jsidorenko Apr 25, 2023
5a2d97d
additional docs
gilescope Apr 25, 2023
18db17f
The swap path elements should be unique
jsidorenko Apr 25, 2023
17aff58
Fix account collision
gilescope Apr 25, 2023
f263147
Merge branch 'dex-pallet' of https://github.com/paritytech/substrate …
gilescope Apr 25, 2023
fa22694
Validate all the pool in a swap path are unique
jsidorenko Apr 26, 2023
1d60e4e
Merge branch 'master' into dex-pallet
gilescope Apr 26, 2023
c7c9422
Change the way we add liquidity to empty pools
jsidorenko Apr 26, 2023
96f4872
Merge branch 'master' into dex-pallet
gilescope Apr 26, 2023
270647a
Merge branch 'master' into dex-pallet
gilescope Apr 26, 2023
a467107
Improve docs
gilescope Apr 27, 2023
ef01a2b
remove unnessisary Display impl
gilescope Apr 27, 2023
dcee96a
cargo fmt
gilescope Apr 27, 2023
fb52368
remove unused imports
gilescope Apr 27, 2023
68ae5d2
Make api consistent
jsidorenko Apr 27, 2023
c5f8acd
Chore
jsidorenko Apr 27, 2023
c8b7e28
Merge remote-tracking branch 'origin/master' into dex-pallet
May 8, 2023
5f74237
Touch the pool account so it could hold the pair tokens
jsidorenko May 8, 2023
82b925c
Check the balance before touching the pool's account
jsidorenko May 8, 2023
2937574
Introduce liquidity provision fee
jsidorenko May 9, 2023
4004628
Touch the pool acc one more time
jsidorenko May 9, 2023
ffcf6b0
Merge remote-tracking branch 'origin/master' into dex-pallet
May 11, 2023
419b9be
Apply suggestions from code review
jsidorenko May 11, 2023
d9cf0ae
Update frame/asset-conversion/README.md
jsidorenko May 11, 2023
4df34e2
Use ContainsPair instead of the balance checker
jsidorenko May 15, 2023
5456e3f
Merge branch 'master' into dex-pallet
gilescope May 16, 2023
ae6a18c
Remove old Currency trait
jsidorenko May 17, 2023
5c486c1
Add liquidity withdrawal fee
jsidorenko May 22, 2023
4ae0d1b
Update docs
jsidorenko May 22, 2023
9577f67
Use 0 withdrawal fee in mock
jsidorenko May 22, 2023
41b07e7
Rename vars
jsidorenko May 22, 2023
124c84b
Merge branch 'master' into dex-pallet
gilescope May 24, 2023
7ec75e0
Merge branch 'master' into dex-pallet
gilescope May 24, 2023
d9b0296
asset id not clone
gilescope May 24, 2023
6bf0efd
fix: shadow var was being used
gilescope May 24, 2023
12472e1
correct tests
gilescope May 25, 2023
e261f11
fix benches
gilescope May 25, 2023
bbe2de8
Merge branch 'master' into dex-pallet
gilescope May 25, 2023
602c976
merge master
gilescope May 25, 2023
ac1812f
neater
gilescope May 25, 2023
eceafb8
Merge branch 'master' into dex-pallet
gilescope May 25, 2023
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
50 changes: 49 additions & 1 deletion Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ members = [
"frame/contracts/primitives",
"frame/conviction-voting",
"frame/democracy",
"frame/dex",
"frame/dex/rpc",
"frame/dex/rpc/runtime-api",
"frame/fast-unstake",
"frame/try-runtime",
"frame/elections-phragmen",
Expand Down
1 change: 1 addition & 0 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ frame-system = { version = "4.0.0-dev", path = "../../../frame/system" }
frame-system-rpc-runtime-api = { version = "4.0.0-dev", path = "../../../frame/system/rpc/runtime-api" }
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }
pallet-assets = { version = "4.0.0-dev", path = "../../../frame/assets/" }
pallet-dex = { version = "4.0.0-dev", path = "../../../frame/dex" }
pallet-asset-tx-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/asset-tx-payment/" }
pallet-im-online = { version = "4.0.0-dev", default-features = false, path = "../../../frame/im-online" }

Expand Down
1 change: 1 addition & 0 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ pub fn testnet_genesis(
assets: vec![(9, get_account_id_from_seed::<sr25519::Public>("Alice"), true, 1)],
..Default::default()
},
pool_assets: Default::default(),
transaction_storage: Default::default(),
transaction_payment: Default::default(),
alliance: Default::default(),
Expand Down
1 change: 1 addition & 0 deletions bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pallet-sudo = { version = "4.0.0-dev", path = "../../../frame/sudo" }
pallet-timestamp = { version = "4.0.0-dev", path = "../../../frame/timestamp" }
pallet-treasury = { version = "4.0.0-dev", path = "../../../frame/treasury" }
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }
pallet-dex = { version = "4.0.0-dev", path = "../../../frame/dex" }
gilescope marked this conversation as resolved.
Show resolved Hide resolved
sp-application-crypto = { version = "7.0.0", path = "../../../primitives/application-crypto" }
pallet-root-testing = { version = "1.0.0-dev", path = "../../../frame/root-testing" }
sp-consensus-babe = { version = "0.10.0-dev", path = "../../../primitives/consensus/babe" }
Expand Down
1 change: 1 addition & 0 deletions bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" }
mmr-rpc = { version = "4.0.0-dev", path = "../../../client/merkle-mountain-range/rpc/" }
pallet-dex-rpc = { version = "4.0.0-dev", path = "../../../frame/dex/rpc/" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
Expand Down
3 changes: 3 additions & 0 deletions bin/node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: pallet_dex_rpc::DexRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
Expand All @@ -118,6 +119,7 @@ where
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
use mmr_rpc::{Mmr, MmrApiServer};
use pallet_dex_rpc::{Dex, DexApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
Expand Down Expand Up @@ -150,6 +152,7 @@ where
// These RPCs should use an asynchronous caller instead.
io.merge(Mmr::new(client.clone()).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
io.merge(Dex::new(client.clone()).into_rpc())?;
io.merge(
Babe::new(
client.clone(),
Expand Down
5 changes: 5 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ pallet-transaction-storage = { version = "4.0.0-dev", default-features = false,
pallet-uniques = { version = "4.0.0-dev", default-features = false, path = "../../../frame/uniques" }
pallet-vesting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/vesting" }
pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" }
pallet-dex = { version = "4.0.0-dev", default-features = false, path = "../../../frame/dex" }
pallet-dex-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/dex/rpc/runtime-api/" }

[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
Expand Down Expand Up @@ -203,6 +205,8 @@ std = [
"sp-io/std",
"pallet-child-bounties/std",
"pallet-alliance/std",
"pallet-dex-rpc-runtime-api/std",
"pallet-dex/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
Expand Down Expand Up @@ -314,4 +318,5 @@ try-runtime = [
"pallet-uniques/try-runtime",
"pallet-vesting/try-runtime",
"pallet-whitelist/try-runtime",
"pallet-dex/try-runtime",
]
63 changes: 59 additions & 4 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime,
dispatch::DispatchClass,
instances::{Instance1, Instance2},
pallet_prelude::Get,
parameter_types,
traits::{
Expand Down Expand Up @@ -62,7 +63,7 @@ pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdj
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use sp_api::impl_runtime_apis;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
use sp_core::{crypto::KeyTypeId, ConstU64, OpaqueMetadata};
use sp_inherents::{CheckInherentsResult, InherentData};
use sp_runtime::{
create_runtime_str,
Expand Down Expand Up @@ -470,7 +471,7 @@ impl pallet_asset_tx_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Fungibles = Assets;
type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter<
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto>,
pallet_assets::BalanceToAssetBalance<Balances, Runtime, ConvertInto, Instance1>,
CreditToBlockAuthor,
>;
}
Expand Down Expand Up @@ -1462,7 +1463,7 @@ parameter_types! {
pub const MetadataDepositPerByte: Balance = 1 * DOLLARS;
}

impl pallet_assets::Config for Runtime {
impl pallet_assets::Config<Instance1> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = u128;
type AssetId = u32;
Expand All @@ -1484,6 +1485,45 @@ impl pallet_assets::Config for Runtime {
type BenchmarkHelper = ();
}

impl pallet_assets::Config<Instance2> for Runtime {
type RuntimeEvent = RuntimeEvent;
type Balance = u128;
type AssetId = u32;
type Currency = Balances;
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
gilescope marked this conversation as resolved.
Show resolved Hide resolved
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDeposit = AssetDeposit;
type AssetAccountDeposit = ConstU128<DOLLARS>;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type StringLimit = StringLimit;
type Freezer = ();
type Extra = ();
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
type RemoveItemsLimit = ConstU32<1000>;
}

parameter_types! {
pub const DexPalletId: PalletId = PalletId(*b"py/dexer");
pub AllowMultiAssetPools: bool = true;
}

impl pallet_dex::Config for Runtime {
type Fee = ConstU64<3>;
jsidorenko marked this conversation as resolved.
Show resolved Hide resolved
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type AssetBalance = <Self as pallet_balances::Config>::Balance;
type Assets = Assets;
type PoolAssets = PoolAssets;
type AssetId = <Self as pallet_assets::Config<Instance1>>::AssetId;
type PoolAssetId = <Self as pallet_assets::Config<Instance2>>::AssetId;
type PalletId = DexPalletId;
type WeightInfo = pallet_dex::weights::SubstrateWeight<Runtime>;
type AllowMultiAssetPools = AllowMultiAssetPools;
type MaxSwapPathLength = ConstU32<4>;
}

parameter_types! {
pub IgnoredIssuance: Balance = Treasury::pot();
pub const QueueCount: u32 = 300;
Expand Down Expand Up @@ -1534,6 +1574,9 @@ impl pallet_uniques::Config for Runtime {
type CollectionId = u32;
type ItemId = u32;
type Currency = Balances;
type CurrencyBalance = <Self as pallet_balances::Config>::Balance;
type Assets = Assets;
type AssetId = <Self as pallet_assets::Config<Instance1>>::AssetId;
gilescope marked this conversation as resolved.
Show resolved Hide resolved
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
type CollectionDeposit = CollectionDeposit;
type ItemDeposit = ItemDeposit;
Expand Down Expand Up @@ -1699,7 +1742,8 @@ construct_runtime!(
Multisig: pallet_multisig,
Bounties: pallet_bounties,
Tips: pallet_tips,
Assets: pallet_assets,
Assets: pallet_assets::<Instance1>,
PoolAssets: pallet_assets::<Instance2>,
Mmr: pallet_mmr,
Lottery: pallet_lottery,
Nis: pallet_nis,
Expand All @@ -1718,6 +1762,7 @@ construct_runtime!(
NominationPools: pallet_nomination_pools,
RankedPolls: pallet_referenda::<Instance2>,
RankedCollective: pallet_ranked_collective,
Dex: pallet_dex,
FastUnstake: pallet_fast_unstake,
MessageQueue: pallet_message_queue,
}
Expand Down Expand Up @@ -2083,6 +2128,16 @@ impl_runtime_apis! {
}
}

impl pallet_dex_rpc_runtime_api::DexApi<
Block,
Balance,
> for Runtime
{
fn quote_price(asset1: Option<u32>, asset2: Option<u32>, amount: u64) -> Option<Balance> {
Dex::quote_price(asset1, asset2, amount)
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<Block, Balance, RuntimeCall>
for Runtime
{
Expand Down
1 change: 1 addition & 0 deletions bin/node/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ kitchensink-runtime = { version = "3.0.0-dev", path = "../runtime" }
pallet-assets = { version = "4.0.0-dev", path = "../../../frame/assets" }
pallet-asset-tx-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/asset-tx-payment" }
pallet-transaction-payment = { version = "4.0.0-dev", path = "../../../frame/transaction-payment" }
pallet-dex = { version = "4.0.0-dev", path = "../../../frame/dex" }
sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-builder" }
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-client-db = { version = "0.10.0-dev", features = ["rocksdb"], path = "../../../client/db" }
Expand Down
1 change: 1 addition & 0 deletions bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Gen
society: SocietyConfig { members: vec![alice(), bob()], pot: 0, max_members: 999 },
vesting: Default::default(),
assets: AssetsConfig { assets: vec![(9, alice(), true, 1)], ..Default::default() },
pool_assets: Default::default(),
transaction_storage: Default::default(),
transaction_payment: Default::default(),
alliance: Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion client/rpc-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ thiserror = "1.0"
sc-chain-spec = { version = "4.0.0-dev", path = "../chain-spec" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-rpc = { version = "6.0.0", path = "../../primitives/rpc" }
sp-rpc = { version = "7.0.0", path = "../../primitives/rpc" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
sp-version = { version = "5.0.0", path = "../../primitives/version" }
jsonrpsee = { version = "0.16.2", features = ["server", "client-core", "macros"] }
2 changes: 1 addition & 1 deletion client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-keystore = { version = "0.13.0", path = "../../primitives/keystore" }
sp-offchain = { version = "4.0.0-dev", path = "../../primitives/offchain" }
sp-rpc = { version = "6.0.0", path = "../../primitives/rpc" }
sp-rpc = { version = "7.0.0", path = "../../primitives/rpc" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
sp-session = { version = "4.0.0-dev", path = "../../primitives/session" }
sp-version = { version = "5.0.0", path = "../../primitives/version" }
Expand Down
2 changes: 1 addition & 1 deletion client/tracing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ sc-tracing-proc-macro = { version = "4.0.0-dev", path = "./proc-macro" }
sp-api = { version = "4.0.0-dev", path = "../../primitives/api" }
sp-blockchain = { version = "4.0.0-dev", path = "../../primitives/blockchain" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
sp-rpc = { version = "6.0.0", path = "../../primitives/rpc" }
sp-rpc = { version = "7.0.0", path = "../../primitives/rpc" }
sp-runtime = { version = "7.0.0", path = "../../primitives/runtime" }
sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }

Expand Down
Loading