Conversation
Codecov Report
@@ Coverage Diff @@
## main #50 +/- ##
==========================================
+ Coverage 75.89% 77.99% +2.10%
==========================================
Files 17 19 +2
Lines 892 1409 +517
==========================================
+ Hits 677 1099 +422
- Misses 215 310 +95
Continue to review full report at Codecov.
|
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.
I havent looked at it all yet.
but here my initial findings. i'll continue again later.
version = "1.0.0" | ||
description = "Liquidity mining" | ||
authors = ["GalacticCouncil"] | ||
edition = "2018" |
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.
2021
edition = "2018" | ||
homepage = "https://github.com/galacticcouncil/Basilisk-node" | ||
license = "Apache 2.0" | ||
repository = "https://github.com/galacticcouncil/Basilisk-node" |
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.
warehouse repo
/// Minimum total rewards to distribute from global pool during liquidity mining. | ||
type MinTotalFarmRewards: Get<Balance>; | ||
|
||
/// Minimum number of periods to run liquidity mining program. | ||
type MinPlannedYieldingPeriods: Get<Self::BlockNumber>; | ||
|
||
/// Mininum user's deposit to enter liquidity mining pool. | ||
type MinDeposit: Get<Balance>; |
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.
I believe all these can be marked as constants
/// `LiquidityPoolYieldFarm` metadata holding: `(existing deposits count, global pool id)` | ||
#[pallet::storage] | ||
#[pallet::getter(fn liq_pool_meta)] | ||
pub type LiquidityPoolMetadata<T: Config> = StorageMap<_, Twox64Concat, PoolId, (u64, GlobalPoolId), OptionQuery>; |
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.
instead of u64 - perhaps it would be good to create a type alias, so it is more readable.
/// - `owner`: liq. mining farm owner. | ||
/// - `yield_per_period`: percentage return on `reward_currency` of all pools | ||
#[allow(clippy::too_many_arguments)] | ||
#[transactional] |
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.
I believe this will part of another transactional operation.
#[transactional] | |
#[require_transactional] |
let undistributed_reward = T::MultiCurrency::total_balance(global_pool.reward_currency, &global_pool_account); | ||
|
||
T::MultiCurrency::transfer( | ||
global_pool.reward_currency, | ||
&global_pool_account, | ||
&who, | ||
undistributed_reward, | ||
)?; |
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.
I believe that the transfer would fail if there is a locked/reserved amount in global_pool_account.
because the total_balance returns combined balance but the transfer checks only the "free" part.
#[cfg_attr(test, derive(PartialEq))] | ||
pub enum Error<T> { | ||
/// Math computation overflow. | ||
Overflow, |
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.
Instead of custom overflow, you can use sp_runtime::ArithmeticError;
that's what we started to do in other crates where math error is needed/
Twox64Concat, | ||
GlobalPoolId, | ||
Twox64Concat, | ||
T::AmmPoolId, | ||
LiquidityPoolYieldFarm<T>, | ||
OptionQuery, | ||
>; |
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 is not clear who can create T::AmmPoolIds
so i'd suggest to use "Blake2_128Concat" hasher. Also it might preferable choice in other other storages too.
galacticcouncil/Basilisk-node#446