From 610d3dfcadf2d2aafe18541aeb5f591129059877 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Thu, 8 Sep 2022 12:13:42 -0700 Subject: [PATCH 1/5] fix 0/0 collateral liquidity --- x/leverage/keeper/collateral.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/leverage/keeper/collateral.go b/x/leverage/keeper/collateral.go index 784e802efc..4ba0e2037e 100644 --- a/x/leverage/keeper/collateral.go +++ b/x/leverage/keeper/collateral.go @@ -144,9 +144,9 @@ func (k Keeper) CollateralLiquidity(ctx sdk.Context, denom string) sdk.Dec { exchangeRate := k.DeriveExchangeRate(ctx, denom) liquidity := k.AvailableLiquidity(ctx, denom) - // Zero collateral will be interpreted as having no liquidity + // Zero collateral will be interpreted as full liquidity if totalCollateral.IsZero() { - return sdk.ZeroDec() + return sdk.OneDec() } collateralLiquidity := toDec(liquidity).Quo(exchangeRate.MulInt(totalCollateral.Amount)) From 52592e73f1d550686cac003a5a202bc337876486 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Thu, 8 Sep 2022 12:17:58 -0700 Subject: [PATCH 2/5] cl++ --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aac3bdbccb..b7e77127a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [1018](https://github.com/umee-network/umee/pull/1018) Return nil if negative time elapsed from the last block happens. - [1156](https://github.com/umee-network/umee/pull/1156) Propagate context correctly. - [1288](https://github.com/umee-network/umee/pull/1288) Safeguards LastInterestTime against time reversals and unintended interest from hard forks. +- [1357](https://github.com/umee-network/umee/pull/1357) Interptex x/0 collateral liquidity as 100% ## [v2.0.2](https://github.com/umee-network/umee/releases/tag/v2.0.2) - 2022-05-13 From 902f66538027cc5828127cb78055b5b5ef75d7c1 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Thu, 8 Sep 2022 13:34:57 -0700 Subject: [PATCH 3/5] comment++ --- x/leverage/keeper/collateral.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/leverage/keeper/collateral.go b/x/leverage/keeper/collateral.go index 4ba0e2037e..d77835734e 100644 --- a/x/leverage/keeper/collateral.go +++ b/x/leverage/keeper/collateral.go @@ -144,7 +144,10 @@ func (k Keeper) CollateralLiquidity(ctx sdk.Context, denom string) sdk.Dec { exchangeRate := k.DeriveExchangeRate(ctx, denom) liquidity := k.AvailableLiquidity(ctx, denom) - // Zero collateral will be interpreted as full liquidity + // Zero collateral will be interpreted as full liquidity. This encompasses two cases: + // - 0/0 liquidity / collateral: Empty market, system is considered healthy by default + // - x/0 liquidity / collateral: No collateral but plenty of liquidity, also considered healthy + // In both cases, "all collateral is liquid" is technically true, given that there is no collateral. if totalCollateral.IsZero() { return sdk.OneDec() } From 9ff47104fb5648eccf41e552827a17f803a9c0d2 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Thu, 8 Sep 2022 13:35:55 -0700 Subject: [PATCH 4/5] comment++ --- x/leverage/keeper/collateral.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/leverage/keeper/collateral.go b/x/leverage/keeper/collateral.go index d77835734e..25e575e0b9 100644 --- a/x/leverage/keeper/collateral.go +++ b/x/leverage/keeper/collateral.go @@ -144,7 +144,7 @@ func (k Keeper) CollateralLiquidity(ctx sdk.Context, denom string) sdk.Dec { exchangeRate := k.DeriveExchangeRate(ctx, denom) liquidity := k.AvailableLiquidity(ctx, denom) - // Zero collateral will be interpreted as full liquidity. This encompasses two cases: + // Zero collateral will be interpreted as full collateral liquidity. This encompasses two cases: // - 0/0 liquidity / collateral: Empty market, system is considered healthy by default // - x/0 liquidity / collateral: No collateral but plenty of liquidity, also considered healthy // In both cases, "all collateral is liquid" is technically true, given that there is no collateral. From 87fb8e291f1df210a105442371de3c01edb4fdef Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Thu, 8 Sep 2022 13:36:49 -0700 Subject: [PATCH 5/5] comment++ --- x/leverage/keeper/collateral.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/leverage/keeper/collateral.go b/x/leverage/keeper/collateral.go index 25e575e0b9..c93527df81 100644 --- a/x/leverage/keeper/collateral.go +++ b/x/leverage/keeper/collateral.go @@ -145,8 +145,8 @@ func (k Keeper) CollateralLiquidity(ctx sdk.Context, denom string) sdk.Dec { liquidity := k.AvailableLiquidity(ctx, denom) // Zero collateral will be interpreted as full collateral liquidity. This encompasses two cases: - // - 0/0 liquidity / collateral: Empty market, system is considered healthy by default - // - x/0 liquidity / collateral: No collateral but plenty of liquidity, also considered healthy + // - liquidity / collateral = 0/0: Empty market, system is considered healthy by default + // - liquidity / collateral = x/0: No collateral but nonzero liquidity, also considered healthy // In both cases, "all collateral is liquid" is technically true, given that there is no collateral. if totalCollateral.IsZero() { return sdk.OneDec()