Skip to content

Commit

Permalink
feat: add pool quota changes
Browse files Browse the repository at this point in the history
  • Loading branch information
5lliot committed Aug 21, 2023
1 parent 99e156f commit 0e4621e
Show file tree
Hide file tree
Showing 15 changed files with 9,879 additions and 22 deletions.
4,703 changes: 4,703 additions & 0 deletions artifacts/creditConfiguratorv3/creditConfiguratorv3.go

Large diffs are not rendered by default.

335 changes: 335 additions & 0 deletions artifacts/poolQuotaKeeperv3/poolQuotaKeeper.go

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

4,604 changes: 4,604 additions & 0 deletions artifacts/poolv3/poolv3.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions calc/account_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
type TokenDetailsForCalcI interface {
GetToken(token string) *schemas.Token
GetPrices(underlyingToken string, version core.VersionType, blockNums ...int64) *big.Int
GetLiqThreshold(cm, token string) *big.Int
GetLiqThreshold(ts int64, cm, token string) *big.Int
}

type AccountForCalcI interface {
Expand All @@ -25,7 +25,7 @@ type Calculator struct {
Store TokenDetailsForCalcI
}

func (c Calculator) CalcAccountFields(version core.VersionType, blockNum int64,
func (c Calculator) CalcAccountFields(ts int64, version core.VersionType, blockNum int64,
account AccountForCalcI, curCumIndex *big.Int, underlyingToken string, feeInterest uint16,
) (calHF, calBorrowWithInterestAndFees, calTotalValue, calThresholdValue, calBorrowWithInterest *big.Int) {

Expand All @@ -36,7 +36,7 @@ func (c Calculator) CalcAccountFields(version core.VersionType, blockNum int64,
if balance.IsEnabled && balance.HasBalanceMoreThanOne() {
//
tokenValueInUSD := c.convertToUSD(balance.BI.Convert(), token, version, blockNum)
tokenThresholdValueInUSD := new(big.Int).Mul(tokenValueInUSD, c.Store.GetLiqThreshold(account.GetCM(), token))
tokenThresholdValueInUSD := new(big.Int).Mul(tokenValueInUSD, c.Store.GetLiqThreshold(ts, account.GetCM(), token))
//
calThresholdValueInUSD = new(big.Int).Add(calThresholdValueInUSD, tokenThresholdValueInUSD)
calTotalValueInUSD = new(big.Int).Add(calTotalValueInUSD, tokenValueInUSD)
Expand Down
4 changes: 3 additions & 1 deletion calc/account_fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s store) GetPrices(token string, version core.VersionType, blockNums ...in
func (s store) GetToken(token string) *schemas.Token {
return s.Tokens[token]
}
func (s store) GetLiqThreshold(cm, token string) *big.Int {
func (s store) GetLiqThreshold(_ int64, cm, token string) *big.Int {
return s.LiqThresholds[cm][token]
}

Expand All @@ -70,6 +70,7 @@ func TestCalcFields(t *testing.T) {
// //

calHF, calDebt, calTotalValue, calThresholdValue, _ := Calculator{Store: input.store}.CalcAccountFields(
0,
input.Version,
0,
input.Account,
Expand Down Expand Up @@ -100,6 +101,7 @@ func TestCalcFieldsWithFeeInterest(t *testing.T) {
// //

calHF, calDebt, calTotalValue, calThresholdValue, _ := Calculator{Store: input.store}.CalcAccountFields(
0,
input.Version,
0,
input.Account,
Expand Down
2 changes: 1 addition & 1 deletion calc/close_amount.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func CalCloseAmount(params *schemas.Parameters, version core.VersionType, totalValue *big.Int, closureStatus int, borrowedAmountWithInterest, borrowedAmount *big.Int) (amountToPool, remainingFunds, profit, loss *big.Int) {
if version.IsGBv1() {
return calCloseAmountV1(params, totalValue, schemas.IsStatusLiquidated(closureStatus), borrowedAmountWithInterest, borrowedAmount)
} else if version.IsGBv2orAbove() {
} else if version.IsGBv2() {
amountToPool, remainingFunds, profit, loss = calCloseAmountV2(params, totalValue, closureStatus, borrowedAmountWithInterest, borrowedAmount)
}
return
Expand Down
Loading

0 comments on commit 0e4621e

Please sign in to comment.