Skip to content

Commit

Permalink
debt auction multiple lot update
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikasr committed Mar 13, 2024
1 parent 91ea397 commit a965d81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
3 changes: 2 additions & 1 deletion x/auctionsV2/keeper/auctions.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,8 @@ func (k Keeper) CloseEnglishAuction(ctx sdk.Context, englishAuction types.Auctio
return types.ErrAuctionLookupTableNotFound
}

auctionLookupTable.IsAuctionActive = false
// for v14 upgrade
// auctionLookupTable.IsAuctionActive = false
err = k.collector.SetAuctionMappingForApp(ctx, auctionLookupTable)
if err != nil {
return err
Expand Down
23 changes: 13 additions & 10 deletions x/liquidationsV2/keeper/liquidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,17 +493,20 @@ func (k Keeper) CheckStatsForSurplusAndDebt(ctx sdk.Context, appID, assetID uint
debtAssetID := collector.SecondaryAssetId //harbor

// for debt Auction
if netFeeCollectedData.NetFeesCollected.LTE(collector.DebtThreshold.Sub(collector.LotSize)) && auctionLookupTable.IsDebtAuction {
// net = 200 debtThreshold = 500 , lotSize = 100
// code update for v14 upgrade
// implement logic for multiple lots of debt auction at once
// previous code:
// if netFeeCollectedData.NetFeesCollected.LTE(collector.DebtThreshold.Sub(collector.LotSize)) && auctionLookupTable.IsDebtAuction
// net = 200 debtThreshold = 500 , lotSize = 100

lots := ((collector.DebtThreshold).Sub(netFeeCollectedData.NetFeesCollected.Add(collector.LotSize))).Quo(collector.LotSize).Int64()
if lots >= 1 {
collateralToken, debtToken := k.DebtTokenAmount(ctx, collateralAssetID, debtAssetID, collector.LotSize, collector.DebtLotSize)
err := k.CreateLockedVault(ctx, 0, 0, "", collateralToken, debtToken, collateralToken, debtToken, sdk.ZeroDec(), appID, false, "", "", sdk.ZeroInt(), sdk.ZeroInt(), "debt", false, true, collateralAssetID, debtAssetID)
if err != nil {
return err
}
auctionLookupTable.IsAuctionActive = true
err1 := k.collector.SetAuctionMappingForApp(ctx, auctionLookupTable)
if err1 != nil {
return err1
for i := int64(1); i <= lots; i++ {
err := k.CreateLockedVault(ctx, 0, 0, "", collateralToken, debtToken, collateralToken, debtToken, sdk.ZeroDec(), appID, false, "", "", sdk.ZeroInt(), sdk.ZeroInt(), "debt", false, true, collateralAssetID, debtAssetID)
if err != nil {
return err
}
}
}

Expand Down

0 comments on commit a965d81

Please sign in to comment.