Skip to content
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

Lending Feedback #82

Closed
9 tasks done
KaiserKarel opened this issue Sep 18, 2021 · 5 comments
Closed
9 tasks done

Lending Feedback #82

KaiserKarel opened this issue Sep 18, 2021 · 5 comments

Comments

@KaiserKarel
Copy link
Contributor

KaiserKarel commented Sep 18, 2021

traits/oracle.rs

  • The oracle trait does not specify how to handle decimal point. perhaps it should be altered to:

https://github.com/ComposableFi/composable-pallets/blob/649cf366adffa53f8ab1d1c593b3b34cca3b4dff/frame/composable-traits/src/oracle.rs#L3-L16

        /// How much `in` currency should one have to get `amount` unit `of` currency
	/// Error is returned if currency not supported or price information not available.
	/// `in` currency some well known shared (stable) currency.
	/// Consumers may assume can get price of wrapped tokens:
	/// ```python
	/// price(wrap_1(wrap_2(wrap_3((btc))) = price(btc) * stock_dilution_1_ratio * stock_dilution_2_ratio * stock_dilution_3_ratio
	/// ``
	fn get_price(of: &Self::AssetId, amount: Self::Balance) -> Result<(Self::Balance, Self::Timestamp), DispatchError>;

traits/lending.rs

  • Some minor spelling/style, will make a PR with my suggestions.

traits/liquidation

  • Spelling of filename is incorrect ;)

  • I do not think that the lending protocol is capable of determining the fee, as that is dex specific.

https://github.com/ComposableFi/composable-pallets/blob/649cf366adffa53f8ab1d1c593b3b34cca3b4dff/frame/composable-traits/src/liquidatation.rs#L14-L16

  • Should the Liquidate trait also handle routing? If so, it could be simplified to a single method, liquidate, and the implementer handles fee computation etc.

traits/rate_model.rs

  • It seems that all models could implement a single trait, which exposes get_borrow_rate.

https://github.com/ComposableFi/composable-pallets/blob/649cf366adffa53f8ab1d1c593b3b34cca3b4dff/frame/composable-traits/src/rate_model.rs#L386

  • That seems to be related to cargo fmt

https://github.com/ComposableFi/composable-pallets/blob/903c455ef72f84e405b74e1a193d4077bf6bffa4/frame/lending/src/lib.rs#L239

  • Each of the event fields may be named, which avoids confusion:
pub enum Event<T: Config> {
    /// Event emitted when new lending market is created.
    NewMarketCreated {
	market_id: MarketIndex,
	vault_id: T::VaultId,
	manager: T::AccountId,
	borrow_asset_id: T::AssetId,
	collateral_asset_id: T::AssetId,
	reserved_factor: Perquintill,
	collateral_factor: NormalizedCollateralFactor,
    },
    ...
  • How exactly does MarketDebtCurrency work?
@dzmitry-lahoda
Copy link
Contributor

we do not have liquidation implemented, i have not read details of liquidation on other protocols yet, so not clear for me it relation to DEX.

for oracle decimal point. in solana each currency has decimal point build in. should we look into orml or some other oracle and or acala to see how that stuff is handled?

about rate mode - sure - can unify with trait. about many lines, i prefer one big logical condition with all rules and one return, that may not seems same for team.

@KaiserKarel
Copy link
Contributor Author

KaiserKarel commented Sep 20, 2021

we do not have liquidation implemented, i have not read details of liquidation on other protocols yet, so not clear for me it relation to DEX.

Basically, sell the collateral on the DEX for the best price possible, once the collateral passes some price point. Need to obtain at least the lent out stablecoins as return values.

for oracle decimal point. in solana each currency has decimal point build in. should we look into orml or some other oracle and or acala to see how that stuff is handled?

This probably depends on the underlying currency pallet being used. Afaik https://docs.rs/orml-currencies/0.4.0/orml_currencies/module/struct.Pallet.html does not expose metadata about a currency, such as the name or the decimal point.

@seunlanlege seunlanlege transferred this issue from another repository Sep 20, 2021
vivekvpandya added a commit that referenced this issue Sep 21, 2021
vivekvpandya added a commit that referenced this issue Sep 21, 2021
vivekvpandya added a commit that referenced this issue Sep 21, 2021
vivekvpandya added a commit that referenced this issue Sep 22, 2021
vivekvpandya added a commit that referenced this issue Sep 22, 2021
@dzmitry-lahoda
Copy link
Contributor

for oracle decimals. may be lending should operate in planks, satoshi, lamports realms, so it can be decimals oblivion.

@dzmitry-lahoda
Copy link
Contributor

How exactly does MarketDebtCurrency work?

Right now it works just like dictionary with values and with updated summary of total. There is no usage of MarketDebtCurrency as currency for now.

		type Currency: Transfer<Self::AccountId, Balance = Self::Balance, AssetId = <Self as Config>::AssetId>
			+ Mutate<Self::AccountId, Balance = Self::Balance, AssetId = <Self as Config>::AssetId>;

		type MarketDebtCurrency: Transfer<Self::AccountId, Balance = u128, AssetId = <Self as Config>::AssetId>
			+ Mutate<Self::AccountId, Balance = u128, AssetId = <Self as Config>::AssetId>
			+ MutateHold<Self::AccountId, Balance = u128, AssetId = <Self as Config>::AssetId>
			+ InspectHold<Self::AccountId, Balance = u128, AssetId = <Self as Config>::AssetId>;

In Parallel Finance that was just StorageMap, in Warp v2 it was ERC-20 Token. So we just used tokens. There is no use of that token as some currency yet.

@dzmitry-lahoda
Copy link
Contributor

things seems done, currency stuff discussed in slack and moved as some part task to click up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants