diff --git a/x/lend/keeper/keeper.go b/x/lend/keeper/keeper.go index 670e5d7a9..6ea3c9952 100644 --- a/x/lend/keeper/keeper.go +++ b/x/lend/keeper/keeper.go @@ -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) @@ -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. @@ -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 } diff --git a/x/lend/types/pair.go b/x/lend/types/pair.go index 35049734e..b35cbe22c 100644 --- a/x/lend/types/pair.go +++ b/x/lend/types/pair.go @@ -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 {