Skip to content

Commit

Permalink
Merge pull request #668 from comdex-official/feature/dev
Browse files Browse the repository at this point in the history
Feature/dev
  • Loading branch information
dheerajkd30 authored Jan 27, 2023
2 parents fc95b5f + 72cf056 commit 65812a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions x/lend/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am
if err != nil {
return err
}
return nil
}

assetRatesStat, found := k.GetAssetRatesParams(ctx, AssetID)
Expand Down Expand Up @@ -1371,6 +1372,12 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo

addr, _ := sdk.AccAddressFromBech32(lenderAddr)

assetRatesStat, found := k.GetAssetRatesParams(ctx, AssetID)
if !found {
return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10))
}
cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID)

if k.HasLendForAddressByAsset(ctx, lenderAddr, AssetID, PoolID) {
// if a lend position is opened by the user for same asset in a pool, and when the user tries to lend again in that case
// we will deposit that asset and increase user's previous lend position.
Expand All @@ -1385,14 +1392,13 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo
if err != nil {
return err
}
err = k.BorrowAsset(ctx, lenderAddr, lendID, PairID, IsStableBorrow, sdk.NewCoin(cAsset.Denom, AmountIn.Amount), AmountOut)
if err != nil {
return err
}
return nil
}

assetRatesStat, found := k.GetAssetRatesParams(ctx, AssetID)
if !found {
return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10))
}
cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID)

if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(AmountIn)); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion x/lend/types/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (m *Extended_Pair) Validate() error {
}

func (m *Pool) Validate() error {
if len(m.CPoolName) >= 16 {
if len(m.CPoolName) >= 20 {
return ErrInvalidLengthCPoolName
}
if m.AssetData == nil {
Expand Down

0 comments on commit 65812a1

Please sign in to comment.