-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add base_asset to Market structure and make prediction_markets pallet use it instead of Asset::Ztg #894
Conversation
… use it instead of Asset::Ztg
…hangelog_for_devs.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially this is a great work to allow different base assets in prediction markets. I think about unintended consequences....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just passing through and leaving a couple of hopefully useful comments. Do you understand what the purpose of using the __private
prefix on the imports in the orml_mock_registry
module is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks okay, when you ask me. I am waiting until the conversations with Malte are resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good to allow different assets as the denominator in prediction markets.
zrml/prediction-markets/Cargo.toml
Outdated
"parity-scale-codec/std", | ||
"serde/std", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"serde/std", | |
"serde?/std", |
The package serde
has also got optional = true
. Am I missing something?
Really great work here Vivek! Love that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
It seems like the CI doesn't run the tests with
parachain
; it only runscheck
. I guess you could addcargo test -p zrml-prediction-markets --features parachain
to
misc.sh
(not sure what the exact structure of those scripts is). -
One test is still failing.
-
Is there a test for
create_market
failing if an invalid base asset is specified? -
There are some comments above that are still unaccounted for.
zrml/prediction-markets/src/tests.rs
Outdated
let oracle_bond = <Runtime as Config>::OracleBond::get(); | ||
// substract min_liquidity twice, one for buy_complete_set() in | ||
// create_cpmm_market_and_deploy_assets() and one in swaps::create_pool() | ||
// then again substract BASE as buy_complete_set() on line 786 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to specific lines in comments is a bad idea.
zrml/prediction-markets/src/tests.rs
Outdated
// check native balance | ||
let bal = Balances::free_balance(&BOB); | ||
assert_eq!(bal, 1_000 * BASE - CENT); | ||
|
||
let market_bal = Balances::free_balance(market_account); | ||
assert_eq!(market_bal, CENT); | ||
} else { | ||
let bal = Tokens::free_balance(base_asset, &BOB); | ||
assert_eq!(bal, 1_000 * BASE - CENT); | ||
|
||
let market_bal = Tokens::free_balance(base_asset, &market_account); | ||
assert_eq!(market_bal, CENT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could have used AssetManager::free_balance
and then used base_asset
to avoid this if
.
please check test create_market_with_foreign_assets() it covers to failure where if a FA is not registered in AssetRegistry and if FA is registered but in metadata its not allowed to be used as base_asset. |
Codecov Report
@@ Coverage Diff @@
## main #894 +/- ##
==========================================
- Coverage 94.70% 94.42% -0.28%
==========================================
Files 92 93 +1
Lines 19368 20258 +890
==========================================
+ Hits 18342 19129 +787
- Misses 1026 1129 +103
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now.
Just one question (I may have asked this before): Why are we using the parachain
feature to begin with? Edit. Seems to me like parachain
can be removed from zrml_prediction_markets
. Only price to pay is longer compiler times since you need some XCM imports. Seems worth it, though. Am I wrong about this?
Perhaps it would also bring in some testing time too as there will be XCM tests. |
Fixes #226