diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index cacfe552e..000000000 Binary files a/.DS_Store and /dev/null differ diff --git a/app/app.go b/app/app.go index f5d539965..c25aaacc5 100644 --- a/app/app.go +++ b/app/app.go @@ -165,11 +165,11 @@ import ( cwasm "github.com/comdex-official/comdex/app/wasm" - mv5 "github.com/comdex-official/comdex/app/upgrades/mainnet/v5" tv1_0_0 "github.com/comdex-official/comdex/app/upgrades/testnet/v1_0_0" tv2_0_0 "github.com/comdex-official/comdex/app/upgrades/testnet/v2_0_0" tv3_0_0 "github.com/comdex-official/comdex/app/upgrades/testnet/v3_0_0" tv4_0_0 "github.com/comdex-official/comdex/app/upgrades/testnet/v4_0_0" + tv5_0_0 "github.com/comdex-official/comdex/app/upgrades/testnet/v5_0_0" ) const ( @@ -199,7 +199,6 @@ func GetGovProposalHandlers() []govclient.ProposalHandler { bandoraclemoduleclient.AddFetchPriceHandler, lendclient.AddLendPairsHandler, lendclient.AddPoolHandler, - lendclient.UpdateLendPairsHandler, lendclient.AddAssetToPairHandler, lendclient.AddAssetRatesParamsHandler, lendclient.AddAuctionParamsHandler, @@ -568,6 +567,8 @@ func New( &app.AssetKeeper, &app.MarketKeeper, &app.EsmKeeper, + &app.LiquidationKeeper, + &app.AuctionKeeper, ) app.EsmKeeper = esmkeeper.NewKeeper( @@ -1194,16 +1195,16 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { } func (a *App) registerUpgradeHandlers() { - a.UpgradeKeeper.SetUpgradeHandler( + /*a.UpgradeKeeper.SetUpgradeHandler( mv5.UpgradeName, mv5.CreateUpgradeHandler(a.mm, a.configurator, a.WasmKeeper, a.AssetKeeper, a.LiquidityKeeper, a.CollectorKeeper, a.AuctionKeeper, a.LockerKeeper, a.Rewardskeeper, a.LiquidationKeeper), - ) - - /*a.UpgradeKeeper.SetUpgradeHandler( - tv4_0_0.UpgradeNameV4_4_0, - tv4_0_0.CreateUpgradeHandlerV440(a.mm, a.configurator, a.LendKeeper, a.LiquidationKeeper, a.AuctionKeeper), )*/ + a.UpgradeKeeper.SetUpgradeHandler( + tv5_0_0.UpgradeNameBeta, + tv5_0_0.CreateUpgradeHandlerV5Beta(a.mm, a.configurator, a.LendKeeper, a.LiquidationKeeper, a.VaultKeeper), + ) + // When a planned update height is reached, the old binary will panic // writing on disk the height and name of the update that triggered it // This will read that value, and execute the preparations for the upgrade. @@ -1277,11 +1278,17 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades * storeUpgrades = &storetypes.StoreUpgrades{} case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_3_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): storeUpgrades = &storetypes.StoreUpgrades{} - case upgradeInfo.Name == tv4_0_0.UpgradeNameV4_4_0 && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): - storeUpgrades = &storetypes.StoreUpgrades{} + case upgradeInfo.Name == tv5_0_0.UpgradeNameBeta && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): + storeUpgrades = &storetypes.StoreUpgrades{ + Deleted: []string{"bandoracle", "market"}, + Added: []string{ + bandoraclemoduletypes.ModuleName, + markettypes.ModuleName, + }, + } - // prepare store for main net upgrade v5.0.0 - case upgradeInfo.Name == mv5.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): + // prepare store for main net upgrade v5.0.0 + /*case upgradeInfo.Name == mv5.UpgradeName && !a.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height): storeUpgrades = &storetypes.StoreUpgrades{ Added: []string{ assettypes.ModuleName, @@ -1301,7 +1308,7 @@ func upgradeHandlers(upgradeInfo storetypes.UpgradeInfo, a *App, storeUpgrades * icahosttypes.StoreKey, authz.ModuleName, }, - } + }*/ } return storeUpgrades diff --git a/app/upgrades/mainnet/v5/constants.go b/app/upgrades/mainnet/v5/constants.go index 0b25b05dd..f09b2085e 100644 --- a/app/upgrades/mainnet/v5/constants.go +++ b/app/upgrades/mainnet/v5/constants.go @@ -1,7 +1,7 @@ package v5 const ( - UpgradeName = "v5.0.0.beta" + UpgradeName = "v5" UpgradeHeight = "" UpgradeInfo = `'{ "binaries": { diff --git a/app/upgrades/mainnet/v5/upgrades.go b/app/upgrades/mainnet/v5/upgrades.go index 9959e70a5..7f60c5cd1 100644 --- a/app/upgrades/mainnet/v5/upgrades.go +++ b/app/upgrades/mainnet/v5/upgrades.go @@ -51,15 +51,15 @@ func InitializeStates( } assets := []assettypes.Asset{ - {Name: "ATOM", Denom: "uatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true}, - {Name: "CMDX", Denom: "ucmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true}, - {Name: "CMST", Denom: "ucmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false}, - {Name: "OSMO", Denom: "uosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: true}, - {Name: "CATOM", Denom: "ucatom", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false}, - {Name: "CCMDX", Denom: "uccmdx", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false}, - {Name: "CCMST", Denom: "uccmst", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false}, - {Name: "COSMO", Denom: "ucosmo", Decimals: 1000000, IsOnChain: false, IsOraclePriceRequired: false}, - {Name: "HARBOR", Denom: "uharbor", Decimals: 1000000, IsOnChain: true, IsOraclePriceRequired: false}, + {Name: "ATOM", Denom: "uatom", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: true}, + {Name: "CMDX", Denom: "ucmdx", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: true}, + {Name: "CMST", Denom: "ucmst", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false}, + {Name: "OSMO", Denom: "uosmo", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: true}, + {Name: "CATOM", Denom: "ucatom", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false}, + {Name: "CCMDX", Denom: "uccmdx", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false}, + {Name: "CCMST", Denom: "uccmst", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false}, + {Name: "COSMO", Denom: "ucosmo", Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false}, + {Name: "HARBOR", Denom: "uharbor", Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false}, } for _, asset := range assets { diff --git a/app/upgrades/testnet/v4_0_0/constants.go b/app/upgrades/testnet/v4_0_0/constants.go index b125ba5e3..b27d09e6d 100644 --- a/app/upgrades/testnet/v4_0_0/constants.go +++ b/app/upgrades/testnet/v4_0_0/constants.go @@ -55,17 +55,3 @@ const ( } }'` ) - -const ( - UpgradeNameV4_4_0 = "v4.4.0.beta" - UpgradeHeightV4_4_0 = "" // replace this height - UpgradeInfoV4_4_0 = `'{ - "binaries": { - "darwin/arm64":"", - "darwin/x86_64":"", - "linux/arm64":"", - "linux/x86_64":"", - "windows/x86_64":"" - } - }'` -) diff --git a/app/upgrades/testnet/v4_0_0/upgrades.go b/app/upgrades/testnet/v4_0_0/upgrades.go index f8f1d8a06..3d83355c6 100644 --- a/app/upgrades/testnet/v4_0_0/upgrades.go +++ b/app/upgrades/testnet/v4_0_0/upgrades.go @@ -1,9 +1,6 @@ package v4_0_0 //nolint:revive,stylecheck import ( - auctionkeeper "github.com/comdex-official/comdex/x/auction/keeper" - lendkeeper "github.com/comdex-official/comdex/x/lend/keeper" - liquidationkeeper "github.com/comdex-official/comdex/x/liquidation/keeper" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -125,39 +122,3 @@ func CreateUpgradeHandlerV430( return newVM, err } } - -func UpdateDutchLendAuctions( - ctx sdk.Context, - liquidationkeeper liquidationkeeper.Keeper, - auctionkeeper auctionkeeper.Keeper, -) { - lockedVaults := liquidationkeeper.GetLockedVaults(ctx) - for _, v := range lockedVaults { - if v.Kind != nil { - err := auctionkeeper.LendDutchActivator(ctx, v) - if err != nil { - return - } - } - } -} - -// CreateUpgradeHandler creates an SDK upgrade handler for v4_4_0 -func CreateUpgradeHandlerV440( - mm *module.Manager, - configurator module.Configurator, - lendkeeper lendkeeper.Keeper, - liquidationkeeper liquidationkeeper.Keeper, - auctionkeeper auctionkeeper.Keeper, -) upgradetypes.UpgradeHandler { - return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - // This change is only for testnet upgrade - - UpdateDutchLendAuctions(ctx, liquidationkeeper, auctionkeeper) - newVM, err := mm.RunMigrations(ctx, configurator, fromVM) - if err != nil { - return newVM, err - } - return newVM, err - } -} diff --git a/app/upgrades/testnet/v5_0_0/constants.go b/app/upgrades/testnet/v5_0_0/constants.go new file mode 100644 index 000000000..800306140 --- /dev/null +++ b/app/upgrades/testnet/v5_0_0/constants.go @@ -0,0 +1,15 @@ +package v5_0_0 //nolint:revive,stylecheck + +const ( + UpgradeNameBeta = "v5.0.0.beta" + UpgradeHeight = "" // replace this height + UpgradeInfo = `'{ + "binaries": { + "darwin/arm64":"", + "darwin/x86_64":"", + "linux/arm64":"", + "linux/x86_64":"", + "windows/x86_64":"" + } + }'` +) diff --git a/app/upgrades/testnet/v5_0_0/off_load_data.go b/app/upgrades/testnet/v5_0_0/off_load_data.go new file mode 100644 index 000000000..eabf61965 --- /dev/null +++ b/app/upgrades/testnet/v5_0_0/off_load_data.go @@ -0,0 +1,82 @@ +package v5_0_0 //nolint:revive,stylecheck + +import ( + lendkeeper "github.com/comdex-official/comdex/x/lend/keeper" + "github.com/comdex-official/comdex/x/lend/types" + liquidationkeeper "github.com/comdex-official/comdex/x/liquidation/keeper" + vaultkeeper "github.com/comdex-official/comdex/x/vault/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetVaultLengthCounter - Set vault length for liquidation check +func SetVaultLengthCounter( + ctx sdk.Context, + vaultkeeper vaultkeeper.Keeper, +) { + var count uint64 + appExtendedPairVaultData, found := vaultkeeper.GetAppMappingData(ctx, 2) + if found { + for _, data := range appExtendedPairVaultData { + count += uint64(len(data.VaultIds)) + } + } + vaultkeeper.SetLengthOfVault(ctx, count) +} + +// FuncMigrateLiquidatedBorrow - Migrate all liquidated borrow to new borrow struct and make is_liquidated field to true +func FuncMigrateLiquidatedBorrow(ctx sdk.Context, k lendkeeper.Keeper, liqK liquidationkeeper.Keeper) error { + liqBorrow := liqK.GetLockedVaultByApp(ctx, 3) + for _, v := range liqBorrow { + if v.AmountIn.GT(sdk.ZeroInt()) && v.AmountOut.GT(sdk.ZeroInt()) { + borrowMetaData := v.GetBorrowMetaData() + pair, _ := k.GetLendPair(ctx, v.ExtendedPairId) + assetIn, _ := k.Asset.GetAsset(ctx, pair.AssetIn) + assetOut, _ := k.Asset.GetAsset(ctx, pair.AssetOut) + amountIn := sdk.NewCoin(assetIn.Denom, v.AmountIn) + amountOut := sdk.NewCoin(assetOut.Denom, v.AmountOut) + var cpoolName string + if pair.AssetOutPoolID == 1 { + cpoolName = "CMDX-ATOM-CMST" + } else { + cpoolName = "OSMO-ATOM-CMST" + } + + globalIndex, _ := sdk.NewDecFromStr("0.002") + + newBorrow := types.BorrowAsset{ + ID: v.OriginalVaultId, + LendingID: borrowMetaData.LendingId, + IsStableBorrow: borrowMetaData.IsStableBorrow, + PairID: v.ExtendedPairId, + AmountIn: amountIn, + AmountOut: amountOut, + BridgedAssetAmount: borrowMetaData.BridgedAssetAmount, + BorrowingTime: ctx.BlockTime(), + StableBorrowRate: borrowMetaData.StableBorrowRate, + InterestAccumulated: sdk.NewDecFromInt(v.InterestAccumulated), + GlobalIndex: globalIndex, + ReserveGlobalIndex: sdk.OneDec(), + LastInteractionTime: ctx.BlockTime(), + CPoolName: cpoolName, + IsLiquidated: false, + } + lend, _ := k.GetLend(ctx, newBorrow.LendingID) + k.UpdateBorrowStats(ctx, pair, newBorrow.IsStableBorrow, v.AmountOut, true) + + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + poolAssetLBMappingData.BorrowIds = append(poolAssetLBMappingData.BorrowIds, newBorrow.ID) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) + + k.SetUserBorrowIDCounter(ctx, newBorrow.ID) + k.SetBorrow(ctx, newBorrow) + + mappingData, _ := k.GetUserLendBorrowMapping(ctx, lend.Owner, newBorrow.LendingID) + mappingData.BorrowId = append(mappingData.BorrowId, newBorrow.ID) + k.SetUserLendBorrowMapping(ctx, mappingData) + } else { + // delete faulty lockedVault + liqK.DeleteLockedVault(ctx, 3, v.LockedVaultId) + } + } + return nil +} diff --git a/app/upgrades/testnet/v5_0_0/upgrades.go b/app/upgrades/testnet/v5_0_0/upgrades.go new file mode 100644 index 000000000..4608cd6ee --- /dev/null +++ b/app/upgrades/testnet/v5_0_0/upgrades.go @@ -0,0 +1,31 @@ +package v5_0_0 //nolint:revive,stylecheck + +import ( + lendkeeper "github.com/comdex-official/comdex/x/lend/keeper" + liquidationkeeper "github.com/comdex-official/comdex/x/liquidation/keeper" + vaultkeeper "github.com/comdex-official/comdex/x/vault/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +func CreateUpgradeHandlerV5Beta( + mm *module.Manager, + configurator module.Configurator, + lk lendkeeper.Keeper, + liqk liquidationkeeper.Keeper, + vaultkeeper vaultkeeper.Keeper, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + vm, err := mm.RunMigrations(ctx, configurator, fromVM) + if err != nil { + return nil, err + } + SetVaultLengthCounter(ctx, vaultkeeper) + err = FuncMigrateLiquidatedBorrow(ctx, lk, liqk) + if err != nil { + return nil, err + } + return vm, err + } +} diff --git a/app/wasm/test/helpers_test.go b/app/wasm/test/helpers_test.go index e0959b4f1..dc4739ba7 100644 --- a/app/wasm/test/helpers_test.go +++ b/app/wasm/test/helpers_test.go @@ -79,7 +79,7 @@ func AddAppAsset(app *app.App, ctx1 sdk.Context) { msg2 := assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } _ = assetKeeper.AddAssetRecords(*ctx, msg2) @@ -87,7 +87,7 @@ func AddAppAsset(app *app.App, ctx1 sdk.Context) { msg3 := assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } _ = assetKeeper.AddAssetRecords(*ctx, msg3) @@ -95,7 +95,7 @@ func AddAppAsset(app *app.App, ctx1 sdk.Context) { msg4 := assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } _ = assetKeeper.AddAssetRecords(*ctx, msg4) diff --git a/go.mod b/go.mod index 75a3d460f..ee3f3b929 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/CosmWasm/wasmd v0.27.0 github.com/CosmWasm/wasmvm v1.0.0 github.com/bandprotocol/bandchain-packet v0.0.3 - github.com/cosmos/cosmos-sdk v0.45.9 + github.com/cosmos/cosmos-sdk v0.45.8 github.com/cosmos/ibc-go/v3 v3.3.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 @@ -18,10 +18,10 @@ require ( github.com/spf13/cobra v1.6.0 github.com/stretchr/testify v1.8.0 github.com/swaggo/swag v1.8.7 - github.com/tendermint/tendermint v0.34.21 + github.com/tendermint/tendermint v0.34.22 github.com/tendermint/tm-db v0.6.7 google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b - google.golang.org/grpc v1.48.0 + google.golang.org/grpc v1.50.0 google.golang.org/protobuf v1.28.1 ) @@ -74,7 +74,7 @@ require ( github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/iavl v0.19.3 // indirect + github.com/cosmos/iavl v0.19.1 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect @@ -183,7 +183,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mbilski/exhaustivestruct v1.2.0 // indirect github.com/mgechev/revive v1.2.4 // indirect - github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect + github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect @@ -207,14 +207,14 @@ require ( github.com/quasilyte/gogrep v0.0.0-20220828223005-86e4605de09f // indirect github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.27.0 // indirect github.com/ryancurrah/gomodguard v1.2.4 // indirect github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect - github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect + github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.20.0 // indirect github.com/securego/gosec/v2 v2.13.1 // indirect @@ -250,14 +250,14 @@ require ( github.com/zondax/hid v0.9.0 // indirect gitlab.com/bosi/decorder v0.2.3 // indirect go.etcd.io/bbolt v1.3.6 // indirect - go.uber.org/atomic v1.9.0 // indirect + go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.8.0 // indirect - go.uber.org/zap v1.21.0 // indirect + go.uber.org/zap v1.22.0 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/exp/typeparams v0.0.0-20220827204233-334a2380cb91 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect - golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect + golang.org/x/net v0.0.0-20220812174116-3211cb980234 // indirect golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect diff --git a/go.sum b/go.sum index 7b82e045b..439083f68 100644 --- a/go.sum +++ b/go.sum @@ -144,7 +144,6 @@ github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZw github.com/bandprotocol/bandchain-packet v0.0.3 h1:Mo2xVmjOSfc//0z1lskNkxrkpcxeU2nIwfHb2rHFLLg= github.com/bandprotocol/bandchain-packet v0.0.3/go.mod h1:6mU33VjEShPvWYoTIQywRPxyS+HXcgnm0e7mlJwiTnQ= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -231,8 +230,8 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-sdk v0.43.0/go.mod h1:ctcrTEAhei9s8O3KSNvL0dxe+fVQGp07QyRb/7H9JYE= -github.com/cosmos/cosmos-sdk v0.45.9 h1:Z4s1EZL/mfM8uSSZr8WmyEbWp4hqbWVI5sAIFR432KY= -github.com/cosmos/cosmos-sdk v0.45.9/go.mod h1:Z5M4TX7PsHNHlF/1XanI2DIpORQ+Q/st7oaeufEjnvU= +github.com/cosmos/cosmos-sdk v0.45.8 h1:UHO5LTkOYLK1pvu9WELCxnp8zw/YcjoNGqqcYiLQ4pE= +github.com/cosmos/cosmos-sdk v0.45.8/go.mod h1:+OKZMhLj+Y6LCzCDsyIvpul/xk7n9lVUn8sikLWD0Jo= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -244,8 +243,8 @@ github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIa github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I= github.com/cosmos/iavl v0.15.3/go.mod h1:OLjQiAQ4fGD2KDZooyJG9yz+p2ao2IAYSbke8mVvSA4= github.com/cosmos/iavl v0.16.0/go.mod h1:2A8O/Jz9YwtjqXMO0CjnnbTYEEaovE8jWcwrakH3PoE= -github.com/cosmos/iavl v0.19.3 h1:cESO0OwTTxQm5rmyESKW+zESheDUYI7CcZDWWDwnuxg= -github.com/cosmos/iavl v0.19.3/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= +github.com/cosmos/iavl v0.19.1 h1:3gaq9b6SjiB0KBTygRnAvEGml2pQlu1TH8uma5g63Ys= +github.com/cosmos/iavl v0.19.1/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go v1.0.0/go.mod h1:2wHKQUa+BLJMEyN635KrHfmTTwSNHBtXcqdY8JWGuXA= github.com/cosmos/ibc-go/v3 v3.3.0 h1:r8gYUvQreMQrf4R5RgedK9gcbjLk4uE2q6fuZGjf4n0= github.com/cosmos/ibc-go/v3 v3.3.0/go.mod h1:VUWLHw0C3USmTQZnTdkuXXdUdLbW8zsK3lV1Ieposog= @@ -778,8 +777,9 @@ github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aks github.com/mgechev/revive v1.2.4 h1:+2Hd/S8oO2H0Ikq2+egtNwQsVhAeELHjxjIUFX5ajLI= github.com/mgechev/revive v1.2.4/go.mod h1:iAWlQishqCuj4yhV24FTnKSXGpbAA+0SckXB8GQMX/Q= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 h1:QRUSJEgZn2Snx0EmT/QLXibWjSUDjKWvXIT19NBVp94= +github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= @@ -971,8 +971,9 @@ github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8 github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= +github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= @@ -1004,8 +1005,9 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/sanposhiho/wastedassign/v2 v2.0.6 h1:+6/hQIHKNJAUixEj6EmOngGIisyeI+T3335lYTyxRoA= github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= -github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= +github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= github.com/sashamelentyev/usestdlibvars v1.20.0 h1:K6CXjqqtSYSsuyRDDC7Sjn6vTMLiSJa4ZmDkiokoqtw= @@ -1119,8 +1121,8 @@ github.com/tendermint/tendermint v0.34.0-rc6/go.mod h1:ugzyZO5foutZImv0Iyx/gOFCX github.com/tendermint/tendermint v0.34.0/go.mod h1:Aj3PIipBFSNO21r+Lq3TtzQ+uKESxkbA3yo/INM4QwQ= github.com/tendermint/tendermint v0.34.10/go.mod h1:aeHL7alPh4uTBIJQ8mgFEE8VwJLXI1VD3rVOmH2Mcy0= github.com/tendermint/tendermint v0.34.11/go.mod h1:aeHL7alPh4uTBIJQ8mgFEE8VwJLXI1VD3rVOmH2Mcy0= -github.com/tendermint/tendermint v0.34.21 h1:UiGGnBFHVrZhoQVQ7EfwSOLuCtarqCSsRf8VrklqB7s= -github.com/tendermint/tendermint v0.34.21/go.mod h1:XDvfg6U7grcFTDx7VkzxnhazQ/bspGJAn4DZ6DcLLjQ= +github.com/tendermint/tendermint v0.34.22 h1:XMhtC8s8QqJO4l/dn+TkQvevTRSow3Vixjclr41o+2Q= +github.com/tendermint/tendermint v0.34.22/go.mod h1:YpP5vBEAKUT4g6oyfjKgFeZmdB/GjkJAxfF+cgmJg6Y= github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI= github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8= github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= @@ -1208,10 +1210,9 @@ go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1221,8 +1222,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= +go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0= +go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1353,8 +1354,8 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= -golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= +golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E= +golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/proto/comdex/asset/v1beta1/asset.proto b/proto/comdex/asset/v1beta1/asset.proto index fb8451db1..20d8b92fd 100644 --- a/proto/comdex/asset/v1beta1/asset.proto +++ b/proto/comdex/asset/v1beta1/asset.proto @@ -11,7 +11,10 @@ message Asset { uint64 id = 1; string name = 2 [(gogoproto.moretags) = "yaml:\"name\""]; string denom = 3 [(gogoproto.moretags) = "yaml:\"denom\""]; - int64 decimals = 4 [(gogoproto.moretags) = "yaml:\"decimals\""]; + string decimals = 4 [ + (gogoproto.moretags) = "yaml:\"decimals\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false]; bool is_on_chain = 5 [(gogoproto.moretags) = "yaml:\"is_on_chain\""]; bool is_oracle_price_required = 6 [(gogoproto.moretags) = "yaml:\"is_oracle_price_required\""]; } diff --git a/proto/comdex/esm/v1beta1/esm.proto b/proto/comdex/esm/v1beta1/esm.proto index 0b437ccf5..2465f5ce3 100644 --- a/proto/comdex/esm/v1beta1/esm.proto +++ b/proto/comdex/esm/v1beta1/esm.proto @@ -72,11 +72,7 @@ message ESMStatus{ (gogoproto.moretags) = "yaml:\"vault_redemption_status\"" ]; - bool stable_vault_redemption_status = 7 [ - (gogoproto.moretags) = "yaml:\"stable_vault_redemption_status\"" - ]; - - bool snapshotStatus = 8 [ + bool snapshotStatus = 7 [ (gogoproto.moretags) = "yaml:\"snapshot_status\"" ]; } @@ -103,44 +99,36 @@ message UsersDepositMapping{ message DataAfterCoolOff { uint64 appId = 1 [ (gogoproto.moretags) = "yaml:\"appId\"" ]; - repeated AssetToAmount collateral_asset = 2 [ - (gogoproto.customname) = "CollateralAsset", - (gogoproto.moretags) = "yaml:\"collateral_asset\"", - (gogoproto.nullable) = false - ]; - repeated AssetToAmount debt_asset = 3 [ - (gogoproto.customname) = "DebtAsset", - (gogoproto.moretags) = "yaml:\"debt_asset\"", - (gogoproto.nullable) = false - ]; - string collateral_total_amount = 4 [(gogoproto.moretags) = "yaml:\"collateral_total_amount\"", + string collateral_total_amount = 2 [(gogoproto.moretags) = "yaml:\"collateral_total_amount\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - string debt_total_amount = 5 [(gogoproto.moretags) = "yaml:\"debt_total_amount\"", + string debt_total_amount = 3 [(gogoproto.moretags) = "yaml:\"debt_total_amount\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; } message AssetToAmount { - uint64 asset_id = 1 [ + uint64 appId = 1 [ (gogoproto.moretags) = "yaml:\"appId\"" ]; + uint64 asset_id = 2 [ (gogoproto.customname) = "AssetID", (gogoproto.moretags) = "yaml:\"asset_id\"" ]; - string amount = 2 [ + string amount = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.moretags) = "yaml:\"amount\"", (gogoproto.nullable) = false ]; - string share = 3 [ + string share = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"share\"" ]; - string debt_token_worth = 4 [ + string debt_token_worth = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"debt_token_worth\"", (gogoproto.nullable) = false ]; + bool is_collateral = 6 [(gogoproto.moretags) = "yaml:\"is_collateral\""]; } message DebtAssetsRates { diff --git a/proto/comdex/esm/v1beta1/query.proto b/proto/comdex/esm/v1beta1/query.proto index 07ca3f5bb..f7eb14803 100644 --- a/proto/comdex/esm/v1beta1/query.proto +++ b/proto/comdex/esm/v1beta1/query.proto @@ -72,6 +72,15 @@ message QuerySnapshotPriceResponse { uint64 price = 1; } +message QueryAssetDataAfterCoolOffRequest { + uint64 app_id = 1; +} + +message QueryAssetDataAfterCoolOffResponse { + repeated AssetToAmount assetToAmount = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"asset_to_amount\""]; +} + service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/comdex/v1beta1/esm/params"; @@ -100,4 +109,8 @@ service Query { rpc QuerySnapshotPrice(QuerySnapshotPriceRequest) returns (QuerySnapshotPriceResponse) { option (google.api.http).get = "/comdex/esm/v1beta1/price_snapshot/{app_id}/{asset_id}"; } + + rpc QueryAssetDataAfterCoolOff(QueryAssetDataAfterCoolOffRequest) returns (QueryAssetDataAfterCoolOffResponse) { + option (google.api.http).get = "/comdex/esm/v1beta1/asset_data_after_cool_off/{app_id}"; + } } \ No newline at end of file diff --git a/proto/comdex/lend/v1beta1/genesis.proto b/proto/comdex/lend/v1beta1/genesis.proto index 6ffbd7d4a..b5be7d8fd 100644 --- a/proto/comdex/lend/v1beta1/genesis.proto +++ b/proto/comdex/lend/v1beta1/genesis.proto @@ -8,44 +8,28 @@ import "comdex/lend/v1beta1/params.proto"; option go_package = "github.com/comdex-official/comdex/x/lend/types"; message GenesisState { -// repeated BorrowAsset borrowAsset = 1 -// [ (gogoproto.moretags) = "yaml:\"borrowAsset\"", (gogoproto.nullable) = false ]; -// repeated UserBorrowIdMapping userBorrowIdMapping = 2 -// [ (gogoproto.moretags) = "yaml:\"userBorrowIdMapping\"", (gogoproto.nullable) = false ]; -// repeated BorrowIdByOwnerAndPoolMapping borrowIdByOwnerAndPoolMapping = 3 -// [ (gogoproto.moretags) = "yaml:\"borrowIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ]; -// BorrowMapping borrowMapping = 4 -// [ (gogoproto.moretags) = "yaml:\"borrowMapping\"", (gogoproto.nullable) = false ]; -// repeated LendAsset lendAsset = 5 -// [ (gogoproto.moretags) = "yaml:\"lendAsset\"", (gogoproto.nullable) = false ]; -// repeated Pool pool = 6 -// [ (gogoproto.moretags) = "yaml:\"pool\"", (gogoproto.nullable) = false ]; -// repeated AssetToPairMapping assetToPairMapping = 7 -// [ (gogoproto.moretags) = "yaml:\"assetToPairMapping\"", (gogoproto.nullable) = false ]; -// repeated UserLendIdMapping userLendIdMapping = 8 -// [ (gogoproto.moretags) = "yaml:\"userLendIdMapping\"", (gogoproto.nullable) = false ]; -// repeated LendIdByOwnerAndPoolMapping lendIdByOwnerAndPoolMapping = 9 -// [ (gogoproto.moretags) = "yaml:\"lendIdByOwnerAndPoolMapping\"", (gogoproto.nullable) = false ]; -// repeated LendIdToBorrowIdMapping lendIdToBorrowIdMapping = 10 -// [ (gogoproto.moretags) = "yaml:\"lendIdToBorrowIdMapping\"", (gogoproto.nullable) = false ]; -// repeated AssetStats assetStats = 11 -// [ (gogoproto.moretags) = "yaml:\"assetStats\"", (gogoproto.nullable) = false ]; -// LendMapping lendMapping = 12 -// [ (gogoproto.moretags) = "yaml:\"lendMapping\"", (gogoproto.nullable) = false ]; -// DepositStats userDepositStats = 13 -// [ (gogoproto.moretags) = "yaml:\"userDepositStats\"", (gogoproto.nullable) = false ]; -// DepositStats reserveDepositStats = 14 -// [ (gogoproto.moretags) = "yaml:\"reserveDepositStats\"", (gogoproto.nullable) = false ]; -// DepositStats buyBackDepositStats = 15 -// [ (gogoproto.moretags) = "yaml:\"buyBackDepositStats\"", (gogoproto.nullable) = false ]; -// DepositStats borrowDepositStats = 16 -// [ (gogoproto.moretags) = "yaml:\"borrowDepositStats\"", (gogoproto.nullable) = false ]; -// repeated Extended_Pair extended_Pair = 17 -// [ (gogoproto.moretags) = "yaml:\"extended_Pair\"", (gogoproto.nullable) = false ]; -// repeated AssetRatesStats assetRatesStats = 18 -// [ (gogoproto.moretags) = "yaml:\"assetRatesStats\"", (gogoproto.nullable) = false ]; -// repeated AuctionParams auctionParams = 19 -// [ (gogoproto.moretags) = "yaml:\"auctionParams\"", (gogoproto.nullable) = false ]; -// Params params = 20 [(gogoproto.nullable) = false]; - + repeated BorrowAsset borrowAsset = 1 + [ (gogoproto.moretags) = "yaml:\"borrowAsset\"", (gogoproto.nullable) = false ]; + repeated Borrow_interest_tracker borrowInterestTracker = 2 + [ (gogoproto.moretags) = "yaml:\"borrowInterestTracker\"", (gogoproto.nullable) = false ]; + repeated LendAsset lendAsset = 3 + [ (gogoproto.moretags) = "yaml:\"lendAsset\"", (gogoproto.nullable) = false ]; + repeated Pool pool = 4 + [ (gogoproto.moretags) = "yaml:\"pool\"", (gogoproto.nullable) = false ]; + repeated AssetToPairMapping assetToPairMapping = 5 + [ (gogoproto.moretags) = "yaml:\"assetToPairMapping\"", (gogoproto.nullable) = false ]; + repeated PoolAssetLBMapping poolAssetLBMapping = 6 + [ (gogoproto.moretags) = "yaml:\"poolAssetLBMapping\"", (gogoproto.nullable) = false ]; + repeated Lend_rewards_tracker lendRewardsTracker = 7 + [ (gogoproto.moretags) = "yaml:\"lendRewardsTracker\"", (gogoproto.nullable) = false ]; + repeated UserAssetLendBorrowMapping userAssetLendBorrowMapping = 8 + [ (gogoproto.moretags) = "yaml:\"userAssetLendBorrowMapping\"", (gogoproto.nullable) = false ]; + repeated ReserveBuybackAssetData reserveBuybackAssetData = 9 + [ (gogoproto.moretags) = "yaml:\"reserveBuybackAssetData\"", (gogoproto.nullable) = false ]; + repeated Extended_Pair extended_Pair = 10 + [ (gogoproto.moretags) = "yaml:\"extended_Pair\"", (gogoproto.nullable) = false ]; + repeated AuctionParams auctionParams = 11 + [ (gogoproto.moretags) = "yaml:\"auctionParams\"", (gogoproto.nullable) = false ]; + repeated AssetRatesParams assetRatesParams = 12 + [ (gogoproto.moretags) = "yaml:\"assetRatesParams\"", (gogoproto.nullable) = false ]; } diff --git a/proto/comdex/lend/v1beta1/gov.proto b/proto/comdex/lend/v1beta1/gov.proto index 5e2c803ab..83dea8e9f 100644 --- a/proto/comdex/lend/v1beta1/gov.proto +++ b/proto/comdex/lend/v1beta1/gov.proto @@ -18,11 +18,6 @@ message AddPoolsProposal { string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; Pool Pool = 3 [(gogoproto.nullable) = false]; } -message UpdateLendPairsProposal { - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - Extended_Pair pairs = 3 [(gogoproto.nullable) = false]; -} message AddAssetToPairProposal { string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; diff --git a/proto/comdex/lend/v1beta1/lend.proto b/proto/comdex/lend/v1beta1/lend.proto index f74b5eb52..6bec37b30 100644 --- a/proto/comdex/lend/v1beta1/lend.proto +++ b/proto/comdex/lend/v1beta1/lend.proto @@ -361,13 +361,6 @@ message AssetRatesParams{ //AssetRatesStats } -message StableBorrowMapping{ - repeated uint64 stable_borrow_ids = 1 [ - (gogoproto.customname) = "StableBorrowIDs", - (gogoproto.moretags) = "yaml:\"stable_borrow_ids\"" - ]; -} - message ReserveBuybackAssetData{ // BalanceStats uint64 asset_id = 1 [ (gogoproto.customname) = "AssetID", @@ -438,4 +431,27 @@ message Lend_rewards_tracker{ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interest_accumulated\"" ]; +} + +message ModuleBalance{ + uint64 pool_id = 1 [ + (gogoproto.customname) = "PoolID", + (gogoproto.moretags) = "yaml:\"pool_id\"" + ]; + repeated ModuleBalanceStats module_balance_stats = 2[ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"module_balance_stats\"" + ]; +} + +message ModuleBalanceStats{ + uint64 asset_id = 1 [ + (gogoproto.customname) = "AssetID", + (gogoproto.moretags) = "yaml:\"asset_id\"" + ]; + cosmos.base.v1beta1.Coin balance = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"balance\"", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; } \ No newline at end of file diff --git a/proto/comdex/lend/v1beta1/query.proto b/proto/comdex/lend/v1beta1/query.proto index 16b3549e1..f85fcb2f9 100644 --- a/proto/comdex/lend/v1beta1/query.proto +++ b/proto/comdex/lend/v1beta1/query.proto @@ -290,6 +290,16 @@ message QueryAuctionParamResponse { [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"auction_params\""]; } +message QueryModuleBalanceRequest { + uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""]; +} + +message QueryModuleBalanceResponse { + ModuleBalance ModuleBalance = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"module_balance\""]; +} + service Query { rpc QueryLends(QueryLendsRequest) returns (QueryLendsResponse) { option (google.api.http).get = "/comdex/lend/v1beta1/lends"; @@ -384,6 +394,8 @@ service Query { rpc QueryAuctionParams(QueryAuctionParamRequest) returns (QueryAuctionParamResponse) { option (google.api.http).get = "/comdex/lend/v1beta1/auctionparams/{app_id}"; } - + rpc QueryModuleBalance(QueryModuleBalanceRequest) returns (QueryModuleBalanceResponse) { + option (google.api.http).get = "/comdex/lend/v1beta1/module_balance/{pool_id}"; + }; } diff --git a/proto/comdex/lend/v1beta1/tx.proto b/proto/comdex/lend/v1beta1/tx.proto index 165a8c0ce..f3f59c947 100644 --- a/proto/comdex/lend/v1beta1/tx.proto +++ b/proto/comdex/lend/v1beta1/tx.proto @@ -108,7 +108,7 @@ message MsgBorrowAlternate { } message MsgFundModuleAccounts { - string moduleName = 1; + uint64 poolId = 1; uint64 assetId = 2; string lender = 3; cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; diff --git a/scripts/comdex_local_setup/constants.py b/scripts/comdex_local_setup/constants.py index 69e143c9b..09fa4721e 100644 --- a/scripts/comdex_local_setup/constants.py +++ b/scripts/comdex_local_setup/constants.py @@ -7,7 +7,7 @@ NODE_MONIKER = "testdev" CHAIN_ID = "test-1" GENESIS_ACCOUNT_NAME = "cooluser" -GENESIS_TOKENS = "1000000000000000000000stake,100000000000000000000000ucmdx,100000000000000000000000ucmst,100000000000000000000000uosmo,100000000000000000000000uatom" +GENESIS_TOKENS = "1000000000000000000000stake,100000000000000000000000ucmdx,100000000000000000000000ucmst,100000000000000000000000uosmo,100000000000000000000000uatom,100000000000000000000000weth-wei" VOTING_PERIOD_IN_SEC = 10 DEPOSIT_PERIOD_IN_SEC = 10 \ No newline at end of file diff --git a/scripts/comdex_local_setup/main.py b/scripts/comdex_local_setup/main.py index f5c004950..7e2ee05bf 100644 --- a/scripts/comdex_local_setup/main.py +++ b/scripts/comdex_local_setup/main.py @@ -106,11 +106,11 @@ def AddApp(name, shortName, minGovDeposit=0, govTimeInSeconds=0): exit("error in add app prop") print(f"New App {name} Proposal Submitted ✔️") -def AddAsset(name, denom, isOnChain=1, assetOraclePriceRequired=1): +def AddAsset(name, denom, decimals=1, isOnChain=1, assetOraclePriceRequired=1): jsonData = { "name" : name, "denom" : denom, - "decimals" :"1000000", + "decimals" :str(decimals), "is_on_chain" :str(isOnChain), "asset_oracle_price" :str(assetOraclePriceRequired), "title" :"Add assets for applications to be deployed on comdex chain", @@ -353,7 +353,7 @@ def CreateState(): Vote("yes") for asset in ASSETS: - if len(asset) != 4: + if len(asset) != 5: exit("Invalid asset configs") AddAsset(asset[0], asset[1], asset[2], asset[3]) Vote("yes") diff --git a/scripts/comdex_local_setup/states.py b/scripts/comdex_local_setup/states.py index 259446b51..86ecf5c4b 100644 --- a/scripts/comdex_local_setup/states.py +++ b/scripts/comdex_local_setup/states.py @@ -8,16 +8,17 @@ ] ASSETS = [ - # [name, denom, isOnChain, assetOraclePriceRequired] - ["ATOM", "uatom", 0, 1], # ID - 1 - ["CMDX", "ucmdx", 0, 1], # ID - 2 - ["CMST", "ucmst", 0, 0], # ID - 3 - ["OSMO", "uosmo", 0, 1], # ID - 4 - ["CATOM", "ucatom", 0, 0], # ID - 5 - ["CCMDX", "uccmdx", 0, 0], # ID - 6 - ["CCMST", "uccmst", 0, 0], # ID - 7 - ["COSMO", "ucosmo", 0, 0], # ID - 8 - ["HARBOR", "uharbor", 1, 0], # ID - 9 + # [name, denom, decimals, isOnChain, assetOraclePriceRequired] + ["ATOM", "uatom", 1000000, 0, 1], # ID - 1 + ["CMDX", "ucmdx",1000000, 0, 1], # ID - 2 + ["CMST", "ucmst",1000000, 0, 0], # ID - 3 + ["OSMO", "uosmo",1000000, 0, 1], # ID - 4 + ["CATOM", "ucatom",1000000, 0, 0], # ID - 5 + ["CCMDX", "uccmdx",1000000, 0, 0], # ID - 6 + ["CCMST", "uccmst",1000000, 0, 0], # ID - 7 + ["COSMO", "ucosmo",1000000, 0, 0], # ID - 8 + ["HARBOR", "uharbor",1000000, 1, 0], # ID - 9 + ["WETH", "weth-wei",1000000000000000000, 1, 1], # ID - 10 ] PAIRS = [ @@ -25,6 +26,7 @@ [1, 3], # ID - 1 [2, 3], # ID - 2 [4, 3], # ID - 3 + [10, 3], # ID - 3 ] LIQUIDITY_PAIRS = [ @@ -713,4 +715,74 @@ } }, }, + { + "proposalID": 11, + "isProposal": True, + "contractAddressKey": "governance_contract", + "content": { + "propose": { + "propose": { + "title": "New proposal for add vault pair for CMDX C - CMST", + "description": "This is a base execution proposal to add CMDX C - CMST vault pair with given Vault properties a. Liquidation ratio : 140 % b. Stability Fee : 1% c. Liquidation Penalty : 12% d. DrawDown Fee : 1% e. Debt Cieling : 100000000 CMST f. Debt Floor : 100 CMST ", + "msgs": [ + { + "msg_add_extended_pairs_vault": { + "app_id": 1, + "pair_id": 4, + "stability_fee": "0.025", + "closing_fee": "0.00", + "liquidation_penalty": "0.12", + "draw_down_fee": "0.001", + "is_vault_active": True, + "debt_ceiling": 100000000000000, + "debt_floor": 100000000, + "is_stable_mint_vault": False, + "min_cr": "1.7", + "pair_name": "WETH-A", + "asset_out_oracle_price": False, + "asset_out_price": 1000000, + "min_usd_value_left": 100000, + } + } + ], + "app_id_param": 1, + } + } + }, + }, + { + "proposalID": 12, + "isProposal": True, + "contractAddressKey": "governance_contract", + "content": { + "propose": { + "propose": { + "title": "New proposal for add vault pair for CMDX C - CMST", + "description": "This is a base execution proposal to add CMDX C - CMST vault pair with given Vault properties a. Liquidation ratio : 140 % b. Stability Fee : 1% c. Liquidation Penalty : 12% d. DrawDown Fee : 1% e. Debt Cieling : 100000000 CMST f. Debt Floor : 100 CMST ", + "msgs": [ + { + "msg_add_extended_pairs_vault": { + "app_id": 1, + "pair_id": 4, + "stability_fee": "0.025", + "closing_fee": "0.00", + "liquidation_penalty": "0.12", + "draw_down_fee": "0.001", + "is_vault_active": True, + "debt_ceiling": 100000000000000, + "debt_floor": 100000000, + "is_stable_mint_vault": True, + "min_cr": "1.01", + "pair_name": "WETH-B", + "asset_out_oracle_price": False, + "asset_out_price": 1000000, + "min_usd_value_left": 100000, + } + } + ], + "app_id_param": 1, + } + } + }, + }, ] diff --git a/x/asset/client/cli/tx.go b/x/asset/client/cli/tx.go index fb161fb41..8ca032f8d 100644 --- a/x/asset/client/cli/tx.go +++ b/x/asset/client/cli/tx.go @@ -65,10 +65,7 @@ func NewCreateAssets(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) denoms := assetsMapping.Denom - decimals, err := strconv.ParseInt(assetsMapping.Decimals, 10, 64) - if err != nil { - return txf, nil, err - } + decimals := assetsMapping.Decimals isOnChain := ParseBoolFromString(assetsMapping.IsOnChain) if err != nil { @@ -82,10 +79,14 @@ func NewCreateAssets(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) from := clientCtx.GetFromAddress() + newDecimals, ok := sdk.NewIntFromString(decimals) + if !ok { + return txf, nil, types.ErrorInvalidDecimals + } assets := types.Asset{ Name: names, Denom: denoms, - Decimals: decimals, + Decimals: newDecimals, IsOnChain: isOnChain, IsOraclePriceRequired: assetOraclePrice, } @@ -135,7 +136,7 @@ func NewCmdSubmitUpdateAssetProposal() *cobra.Command { return err } - decimals, err := cmd.Flags().GetInt64(flagDecimals) + decimals, err := cmd.Flags().GetString(flagDecimals) if err != nil { return err } @@ -158,12 +159,16 @@ func NewCmdSubmitUpdateAssetProposal() *cobra.Command { } from := clientCtx.GetFromAddress() + newDecimals, ok := sdk.NewIntFromString(decimals) + if !ok { + return types.ErrorInvalidDecimals + } asset := types.Asset{ Id: id, Name: name, Denom: denom, - Decimals: decimals, + Decimals: newDecimals, IsOraclePriceRequired: newAssetOraclePrice, } diff --git a/x/asset/keeper/asset.go b/x/asset/keeper/asset.go index 16718895e..585cc7575 100644 --- a/x/asset/keeper/asset.go +++ b/x/asset/keeper/asset.go @@ -245,7 +245,7 @@ func (k Keeper) UpdateAssetRecords(ctx sdk.Context, msg types.Asset) error { asset.Denom = msg.Denom k.SetAssetForDenom(ctx, asset.Denom, asset.Id) } - if msg.Decimals >= 0 { + if msg.Decimals.GTE(sdk.ZeroInt()) { asset.Decimals = msg.Decimals } asset.IsOraclePriceRequired = msg.IsOraclePriceRequired diff --git a/x/asset/keeper/asset_test.go b/x/asset/keeper/asset_test.go index 06477df0d..45c3c30a8 100644 --- a/x/asset/keeper/asset_test.go +++ b/x/asset/keeper/asset_test.go @@ -183,7 +183,7 @@ func (s *KeeperTestSuite) TestUpdateAssetRecords() { Id: 1, Name: "CMRT", Denom: "ucmrt", - Decimals: 100, + Decimals: sdk.NewInt(100), IsOnChain: false, IsOraclePriceRequired: false, }, @@ -224,7 +224,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }, @@ -244,7 +244,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "OSMO", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, }, @@ -256,7 +256,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, }, @@ -268,7 +268,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }, @@ -280,7 +280,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "CMDO", Denom: "ucmdo", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: false, }, @@ -292,7 +292,7 @@ func (s *KeeperTestSuite) TestAddAssetRecords() { assetTypes.Asset{ Name: "SPX", Denom: "uspx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: false, IsOraclePriceRequired: false, }, diff --git a/x/asset/keeper/migrations.go b/x/asset/keeper/migrations.go new file mode 100644 index 000000000..370c9e3cd --- /dev/null +++ b/x/asset/keeper/migrations.go @@ -0,0 +1,23 @@ +package keeper + +import ( + "fmt" + + v5types "github.com/comdex-official/comdex/x/asset/migrations/v5" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + fmt.Println("Migrate1to2") + return v5types.MigrateStore(ctx, m.keeper.key, m.keeper.cdc) +} diff --git a/x/asset/migrations/v5/migrations.go b/x/asset/migrations/v5/migrations.go new file mode 100644 index 000000000..3e46f641f --- /dev/null +++ b/x/asset/migrations/v5/migrations.go @@ -0,0 +1,222 @@ +package v5 + +import ( + assettypes "github.com/comdex-official/comdex/x/asset/types" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + err := MigrateValueApps(store, cdc) + if err != nil { + return err + } + err = MigrateValueAsset(store, cdc) + if err != nil { + return err + } + return err +} + +func MigrateValueApps(store sdk.KVStore, cdc codec.BinaryCodec) error { + app1 := assettypes.AppData{ + Id: 1, + Name: "CSWAP", + ShortName: "cswap", + MinGovDeposit: sdk.ZeroInt(), + GovTimeInSeconds: 300, + GenesisToken: nil, + } + key1 := assettypes.AppKey(app1.Id) + store.Delete(key1) + SetApp(store, cdc, app1) + + genesisToken := assettypes.MintGenesisToken{ + AssetId: 9, + GenesisSupply: sdk.NewIntFromUint64(1000000000000000), + IsGovToken: true, + Recipient: "comdex1unvvj23q89dlgh82rdtk5su7akdl5932reqarg", + } + var gToken []assettypes.MintGenesisToken + gToken = append(gToken, genesisToken) + app2 := assettypes.AppData{ + Id: 2, + Name: "HARBOR", + ShortName: "hbr", + MinGovDeposit: sdk.NewIntFromUint64(10000000), + GovTimeInSeconds: 300, + GenesisToken: gToken, + } + key2 := assettypes.AppKey(app2.Id) + store.Delete(key2) + SetApp(store, cdc, app2) + + app3 := assettypes.AppData{ + Id: 3, + Name: "commodo", + ShortName: "cmdo", + MinGovDeposit: sdk.ZeroInt(), + GovTimeInSeconds: 0, + GenesisToken: nil, + } + key3 := assettypes.AppKey(app3.Id) + store.Delete(key3) + SetApp(store, cdc, app3) + return nil +} + +func MigrateValueAsset(store sdk.KVStore, cdc codec.BinaryCodec) error { + asset1 := assettypes.Asset{ + Id: 1, + Name: "ATOM", + Denom: "ibc/2E5D0AC026AC1AFA65A23023BA4F24BB8DDF94F118EDC0BAD6F625BFC557CDED", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: true, + } + key1 := assettypes.AssetKey(asset1.Id) + store.Delete(key1) + SetAsset(store, cdc, asset1) + + asset2 := assettypes.Asset{ + Id: 2, + Name: "CMDX", + Denom: "ucmdx", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: true, + } + key2 := assettypes.AssetKey(asset2.Id) + store.Delete(key2) + SetAsset(store, cdc, asset2) + + asset3 := assettypes.Asset{ + Id: 3, + Name: "CMST", + Denom: "ucmst", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: false, + } + key3 := assettypes.AssetKey(asset3.Id) + store.Delete(key3) + SetAsset(store, cdc, asset3) + + asset4 := assettypes.Asset{ + Id: 4, + Name: "OSMO", + Denom: "ibc/868AF0A32D53849B6093348F5A47BB969A98E71A3F0CD2D3BE406EA25DA7F836", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: true, + } + key4 := assettypes.AssetKey(asset4.Id) + store.Delete(key4) + SetAsset(store, cdc, asset4) + + asset5 := assettypes.Asset{ + Id: 5, + Name: "cATOM", + Denom: "ucatom", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: false, + } + key5 := assettypes.AssetKey(asset5.Id) + store.Delete(key5) + SetAsset(store, cdc, asset5) + + asset6 := assettypes.Asset{ + Id: 6, + Name: "cCMDX", + Denom: "uccmdx", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: false, + } + key6 := assettypes.AssetKey(asset6.Id) + store.Delete(key6) + SetAsset(store, cdc, asset6) + + asset7 := assettypes.Asset{ + Id: 7, + Name: "cCMST", + Denom: "uccmst", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: false, + } + key7 := assettypes.AssetKey(asset7.Id) + store.Delete(key7) + SetAsset(store, cdc, asset7) + + asset8 := assettypes.Asset{ + Id: 8, + Name: "cOSMO", + Denom: "ucosmo", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: false, + } + key8 := assettypes.AssetKey(asset8.Id) + store.Delete(key8) + SetAsset(store, cdc, asset8) + + asset9 := assettypes.Asset{ + Id: 9, + Name: "HARBOR", + Denom: "uharbor", + Decimals: sdk.NewInt(1000000), + IsOnChain: true, + IsOraclePriceRequired: false, + } + key9 := assettypes.AssetKey(asset9.Id) + store.Delete(key9) + SetAsset(store, cdc, asset9) + + asset10 := assettypes.Asset{ + Id: 10, + Name: "USDC", + Denom: "ibc/EF8A76D0FD3F3F45D8DB7FEBFCF921206DF58CA41493ED16D69BF7B4E061C60C", + Decimals: sdk.NewInt(1000000), + IsOnChain: false, + IsOraclePriceRequired: true, + } + key10 := assettypes.AssetKey(asset10.Id) + store.Delete(key10) + SetAsset(store, cdc, asset10) + + asset11 := assettypes.Asset{ + Id: 11, + Name: "WETH", + Denom: "ibc/A99459944FD67B5711735B4B4D3FE30BA45328E94D437C78E47CA8DEFA781E49", + Decimals: sdk.NewInt(1000000000000000000), + IsOnChain: false, + IsOraclePriceRequired: true, + } + key11 := assettypes.AssetKey(asset11.Id) + store.Delete(key11) + SetAsset(store, cdc, asset11) + + return nil +} + +func SetApp(store sdk.KVStore, cdc codec.BinaryCodec, app assettypes.AppData) { + var ( + key = assettypes.AppKey(app.Id) + value = cdc.MustMarshal(&app) + ) + + store.Set(key, value) +} + +func SetAsset(store sdk.KVStore, cdc codec.BinaryCodec, asset assettypes.Asset) { + var ( + key = assettypes.AssetKey(asset.Id) + value = cdc.MustMarshal(&asset) + ) + + store.Set(key, value) +} diff --git a/x/asset/module.go b/x/asset/module.go index 984003343..b3c03f276 100644 --- a/x/asset/module.go +++ b/x/asset/module.go @@ -3,6 +3,7 @@ package asset import ( "context" "encoding/json" + "fmt" "math/rand" "github.com/cosmos/cosmos-sdk/client" @@ -86,7 +87,7 @@ type AppModule struct { } func (a AppModule) ConsensusVersion() uint64 { - return 1 + return 2 } func (a AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, message json.RawMessage) []abcitypes.ValidatorUpdate { @@ -114,6 +115,11 @@ func (a AppModule) QuerierRoute() string { func (a AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { return nil } func (a AppModule) RegisterServices(configurator module.Configurator) { + migrator := keeper.NewMigrator(a.keeper) + // register v1 -> v2 migration + if err := configurator.RegisterMigration(types.ModuleName, 1, migrator.Migrate1to2); err != nil { + panic(fmt.Errorf("failed to migrate %s to v2: %w", types.ModuleName, err)) + } types.RegisterQueryServer(configurator.QueryServer(), keeper.NewQueryServer(a.keeper)) } diff --git a/x/asset/types/asset.go b/x/asset/types/asset.go index 94a13c0d8..4d9b610f5 100644 --- a/x/asset/types/asset.go +++ b/x/asset/types/asset.go @@ -21,7 +21,7 @@ func (m *Asset) Validate() error { if err := sdk.ValidateDenom(m.Denom); err != nil { return errors.Wrapf(err, "invalid denom %s", m.Denom) } - if m.Decimals < 0 { + if m.Decimals.LT(sdk.ZeroInt()) { return fmt.Errorf("decimals cannot be less than zero") } @@ -37,7 +37,7 @@ func (m *Asset) UpdateValidate() error { return errors.Wrapf(err, "invalid denom %s", m.Denom) } } - if m.Decimals < 0 { + if m.Decimals.LT(sdk.ZeroInt()) { return fmt.Errorf("decimals cannot be less than zero") } diff --git a/x/asset/types/asset.pb.go b/x/asset/types/asset.pb.go index 8525537d2..0883148ef 100644 --- a/x/asset/types/asset.pb.go +++ b/x/asset/types/asset.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -24,12 +25,12 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Asset struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` - Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` - Decimals int64 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty" yaml:"decimals"` - IsOnChain bool `protobuf:"varint,5,opt,name=is_on_chain,json=isOnChain,proto3" json:"is_on_chain,omitempty" yaml:"is_on_chain"` - IsOraclePriceRequired bool `protobuf:"varint,6,opt,name=is_oracle_price_required,json=isOraclePriceRequired,proto3" json:"is_oracle_price_required,omitempty" yaml:"is_oracle_price_required"` + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` + Decimals github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=decimals,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"decimals" yaml:"decimals"` + IsOnChain bool `protobuf:"varint,5,opt,name=is_on_chain,json=isOnChain,proto3" json:"is_on_chain,omitempty" yaml:"is_on_chain"` + IsOraclePriceRequired bool `protobuf:"varint,6,opt,name=is_oracle_price_required,json=isOraclePriceRequired,proto3" json:"is_oracle_price_required,omitempty" yaml:"is_oracle_price_required"` } func (m *Asset) Reset() { *m = Asset{} } @@ -72,29 +73,31 @@ func init() { func init() { proto.RegisterFile("comdex/asset/v1beta1/asset.proto", fileDescriptor_67277aee9bd3eed4) } var fileDescriptor_67277aee9bd3eed4 = []byte{ - // 350 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x4a, 0xeb, 0x40, - 0x14, 0xc6, 0x33, 0xe9, 0x1f, 0xda, 0xe9, 0xe5, 0xf6, 0x32, 0xb7, 0x4a, 0x70, 0x31, 0x09, 0x29, - 0x48, 0x36, 0x36, 0x14, 0xc1, 0x85, 0x3b, 0x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xab, - 0xc2, 0x44, 0xea, 0xe6, 0x07, 0xb4, 0xfd, 0x2e, 0x13, 0x93, 0xf4, 0xba, 0x9e, 0xd1, 0x3d, 0x34, - 0x6a, 0x94, 0x91, 0x30, 0xa6, 0xc1, 0x32, 0x63, 0x21, 0x0d, 0x32, 0xfa, 0xb0, 0x62, 0x19, 0x8d, - 0x8c, 0xb6, 0x7c, 0x32, 0xac, 0x0a, 0xd3, 0xfc, 0x7e, 0xf2, 0x9b, 0x69, 0xfb, 0x47, 0x4c, 0x4c, - 0x24, 0xb9, 0xa9, 0x81, 0xbf, 0xcf, 0xbd, 0xdb, 0xcd, 0x07, 0xd6, 0x5e, 0x4a, 0xac, 0x6d, 0x4a, - 0x0c, 0xb6, 0x25, 0x06, 0xef, 0x25, 0x06, 0xcf, 0x3b, 0xac, 0x6d, 0x77, 0x58, 0x7b, 0xdb, 0x61, - 0xed, 0xce, 0x9d, 0xb3, 0x7c, 0xb1, 0x9a, 0x8e, 0x42, 0x9e, 0xb8, 0xaa, 0x86, 0x33, 0x3e, 0x9b, - 0xb1, 0x90, 0x91, 0x78, 0xbf, 0xbb, 0x87, 0xea, 0xf2, 0xf5, 0x92, 0x8a, 0x69, 0x5b, 0xf6, 0x70, - 0xfe, 0x19, 0x00, 0x00, 0xff, 0xff, 0x01, 0x5e, 0x55, 0xb5, 0xd7, 0x01, 0x00, 0x00, + // 377 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x4f, 0x8e, 0xda, 0x30, + 0x18, 0xc5, 0x93, 0x14, 0x10, 0x98, 0xaa, 0x54, 0x16, 0xad, 0xa2, 0x2e, 0xec, 0x28, 0x48, 0x88, + 0x0d, 0x89, 0x50, 0xa5, 0x2e, 0xba, 0x83, 0xae, 0xba, 0xa2, 0xcd, 0xb2, 0x6a, 0x15, 0x19, 0xc7, + 0x80, 0xd5, 0x24, 0xa6, 0x71, 0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1b, 0xdc, 0x47, 0xc2, 0x0f, + 0xa0, 0xcf, 0x65, 0x28, 0xd2, 0x90, 0x6e, 0x09, 0x4f, 0xed, 0xb6, 0x63, 0x4e, 0xba, 0x8b, 0xb7, + 0x55, 0x81, 0xa1, 0xbe, 0xf3, 0xc8, 0x74, 0x83, 0x1e, 0x97, 0xcb, 0xf4, 0x53, 0x3d, 0xc3, 0xef, + 0xc0, 0xae, 0xad, 0x8c, 0xd0, 0x98, 0x85, 0xbb, 0x8c, 0x53, 0x16, 0x66, 0xec, 0xd7, 0x9e, 0x67, + 0x2c, 0xb2, 0x3b, 0x2a, 0x64, 0x54, 0x15, 0x18, 0x3f, 0x84, 0x3c, 0x47, 0xba, 0xc1, 0x1b, 0x2e, + 0x97, 0xca, 0xf9, 0x52, 0x1b, 0x41, 0xa3, 0x2f, 0xbe, 0x1e, 0x6f, 0x91, 0xf1, 0xaf, 0x44, 0xc6, + 0xb1, 0x44, 0xe6, 0xa9, 0x44, 0xe6, 0x4d, 0x89, 0xcc, 0xbf, 0x67, 0x64, 0x9c, 0xce, 0xc8, 0xf8, + 0x7f, 0x46, 0xc6, 0x37, 0xff, 0xc9, 0xe3, 0xeb, 0xd2, 0xa6, 0x62, 0xbd, 0xe6, 0x94, 0x93, 0xb8, + 0xd9, 0xfd, 0x4b, 0xd1, 0xea, 0x27, 0x56, 0x1d, 0xd5, 0xda, 0xfb, 0xbb, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xaf, 0x85, 0xa2, 0x61, 0x05, 0x02, 0x00, 0x00, } func (m *Asset) Marshal() (dAtA []byte, err error) { @@ -137,11 +140,16 @@ func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x28 } - if m.Decimals != 0 { - i = encodeVarintAsset(dAtA, i, uint64(m.Decimals)) - i-- - dAtA[i] = 0x20 + { + size := m.Decimals.Size() + i -= size + if _, err := m.Decimals.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintAsset(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x22 if len(m.Denom) > 0 { i -= len(m.Denom) copy(dAtA[i:], m.Denom) @@ -192,9 +200,8 @@ func (m *Asset) Size() (n int) { if l > 0 { n += 1 + l + sovAsset(uint64(l)) } - if m.Decimals != 0 { - n += 1 + sovAsset(uint64(m.Decimals)) - } + l = m.Decimals.Size() + n += 1 + l + sovAsset(uint64(l)) if m.IsOnChain { n += 2 } @@ -323,10 +330,10 @@ func (m *Asset) Unmarshal(dAtA []byte) error { m.Denom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) } - m.Decimals = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAsset @@ -336,11 +343,26 @@ func (m *Asset) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Decimals |= int64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAsset + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAsset + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Decimals.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IsOnChain", wireType) diff --git a/x/auction/keeper/auction.go b/x/auction/keeper/auction.go index 2cf0ce9b7..f87c1e14f 100644 --- a/x/auction/keeper/auction.go +++ b/x/auction/keeper/auction.go @@ -67,6 +67,6 @@ func (k Keeper) CalcDollarValueForToken(ctx sdk.Context, id uint64, rate sdk.Dec } numerator := sdk.NewDecFromInt(amt).Mul(rate) - denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset.Decimals))) + denominator := sdk.NewDecFromInt(asset.Decimals) return numerator.Quo(denominator), nil } diff --git a/x/auction/keeper/debt.go b/x/auction/keeper/debt.go index 06bf822c9..632c786f3 100644 --- a/x/auction/keeper/debt.go +++ b/x/auction/keeper/debt.go @@ -170,6 +170,7 @@ func (k Keeper) RestartDebt( ) error { status, _, inflowToken := k.getDebtSellTokenAmount(ctx, appID, debtAuction.AssetInId, debtAuction.AssetOutId, debtAuction.ExpectedUserToken.Amount) if status == auctiontypes.NoAuction { + ctx.Logger().Error("auction types mismatch for debt restart") return nil } auctionParams, found := k.GetAuctionParams(ctx, appID) diff --git a/x/auction/keeper/dutch_lend.go b/x/auction/keeper/dutch_lend.go index 762b528b4..21993c89c 100644 --- a/x/auction/keeper/dutch_lend.go +++ b/x/auction/keeper/dutch_lend.go @@ -28,14 +28,14 @@ func (k Keeper) LendDutchActivator(ctx sdk.Context, lockedVault liquidationtypes assetInTwA, found := k.market.GetTwa(ctx, assetIn.Id) if !found || !assetInTwA.IsPriceActive { ctx.Logger().Error(auctiontypes.ErrorPrices.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorPrices } assetInPrice := assetInTwA.Twa assetOutTwA, found := k.market.GetTwa(ctx, assetOut.Id) if !found || !assetOutTwA.IsPriceActive { ctx.Logger().Error(auctiontypes.ErrorPrices.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorPrices } assetOutPrice := assetOutTwA.Twa //assetInPrice is the collateral price @@ -43,12 +43,12 @@ func (k Keeper) LendDutchActivator(ctx sdk.Context, lockedVault liquidationtypes AssetInPrice := sdk.NewDecFromInt(sdk.NewIntFromUint64(assetInPrice)) if AssetInPrice.Equal(sdk.ZeroDec()) { ctx.Logger().Error(auctiontypes.ErrorPrices.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorPrices } AssetOutPrice := sdk.NewDecFromInt(sdk.NewIntFromUint64(assetOutPrice)) if AssetOutPrice.Equal(sdk.ZeroDec()) { ctx.Logger().Error(auctiontypes.ErrorPrices.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorPrices } outflowToken := sdk.NewCoin(assetIn.Denom, lockedVault.CollateralToBeAuctioned.Quo(AssetInPrice).TruncateInt()) inflowToken := sdk.NewCoin(assetOut.Denom, lockedVault.CollateralToBeAuctioned.Quo(AssetOutPrice).TruncateInt()) @@ -56,14 +56,14 @@ func (k Keeper) LendDutchActivator(ctx sdk.Context, lockedVault liquidationtypes AssetRatesStats, found := k.lend.GetAssetRatesParams(ctx, extendedPair.AssetIn) if !found { ctx.Logger().Error(auctiontypes.ErrorAssetRates.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorAssetRates } liquidationPenalty := AssetRatesStats.LiquidationPenalty // from here the lend dutch auction is started err1 := k.StartLendDutchAuction(ctx, outflowToken, inflowToken, lockedVault.AppId, assetOut.Id, assetIn.Id, lockedVault.LockedVaultId, lockedVault.Owner, liquidationPenalty) if err1 != nil { ctx.Logger().Error(auctiontypes.ErrorInStartDutchAuction.Error(), lockedVault.LockedVaultId) - return nil + return auctiontypes.ErrorInStartDutchAuction } } } @@ -410,17 +410,11 @@ func (k Keeper) CloseDutchLendAuction( return auctiontypes.ErrorVaultNotFound } - lockedVault.AmountIn = lockedVault.AmountIn.Sub(dutchAuction.OutflowTokenInitAmount.Amount) // set sell of history in locked vault err := k.liquidation.CreateLockedVaultHistory(ctx, lockedVault) if err != nil { return err } - borrowMetaData := lockedVault.GetBorrowMetaData() - lendPos, _ := k.lend.GetLend(ctx, borrowMetaData.LendingId) - lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(dutchAuction.OutflowTokenInitAmount.Amount) - lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(dutchAuction.OutflowTokenInitAmount.Amount) - k.lend.SetLend(ctx, lendPos) lockedVault.AmountOut = lockedVault.AmountOut.Sub(dutchAuction.InflowTokenTargetAmount.Amount) lockedVault.UpdatedAmountOut = lockedVault.UpdatedAmountOut.Sub(dutchAuction.InflowTokenTargetAmount.Amount) diff --git a/x/auction/keeper/dutch_test.go b/x/auction/keeper/dutch_test.go index 8c8fc0fe4..6420800ee 100644 --- a/x/auction/keeper/dutch_test.go +++ b/x/auction/keeper/dutch_test.go @@ -76,7 +76,6 @@ func (s *KeeperTestSuite) SetOraclePrice(assetID uint64, price uint64) { PriceValue: []uint64{price}, } s.app.MarketKeeper.SetTwa(s.ctx, market) - } func (s *KeeperTestSuite) SetInitialOraclePriceForID(asset1 uint64, asset2 uint64) { @@ -193,7 +192,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, @@ -202,7 +201,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, @@ -211,7 +210,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, diff --git a/x/auction/keeper/surplus.go b/x/auction/keeper/surplus.go index 8fde47a43..aa34e6d51 100644 --- a/x/auction/keeper/surplus.go +++ b/x/auction/keeper/surplus.go @@ -172,6 +172,7 @@ func (k Keeper) RestartSurplus( ) error { status, _, buyToken := k.getSurplusBuyTokenAmount(ctx, surplusAuction.AssetInId, surplusAuction.AssetOutId, surplusAuction.BuyToken.Amount) if status == auctiontypes.NoAuction { + ctx.Logger().Error("auction types mismatch for surplus restart") return nil } auctionParams, found := k.GetAuctionParams(ctx, appID) diff --git a/x/bandoracle/types/keys.go b/x/bandoracle/types/keys.go index 032f6d0a1..6aff0ba85 100644 --- a/x/bandoracle/types/keys.go +++ b/x/bandoracle/types/keys.go @@ -2,7 +2,7 @@ package types const ( // ModuleName defines the module name. - ModuleName = "bandoracle" + ModuleName = "bandoracleV1" // StoreKey defines the primary module store key. StoreKey = ModuleName @@ -20,7 +20,7 @@ const ( Version = "bandchain-1" // PortID is the default port id that module binds to. - PortID = "bandoracle" + PortID = "bandoracleV1" ) var ( diff --git a/x/collector/keeper/collector.go b/x/collector/keeper/collector.go index e284b4e37..9f6cd9ed9 100644 --- a/x/collector/keeper/collector.go +++ b/x/collector/keeper/collector.go @@ -29,7 +29,7 @@ func (k Keeper) GetAmountFromCollector(ctx sdk.Context, appID, assetID uint64, a if err != nil { return returnedFee, err } - err = k.DecreaseNetFeeCollectedData(ctx, appID, assetID, amount, netFeeData) + err = k.DecreaseNetFeeCollectedData(ctx, appID, assetID, amount) if err != nil { return sdk.Int{}, err } @@ -38,17 +38,21 @@ func (k Keeper) GetAmountFromCollector(ctx sdk.Context, appID, assetID uint64, a return returnedFee, nil } -func (k Keeper) DecreaseNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, amount sdk.Int, netCollected types.AppAssetIdToFeeCollectedData) error { - netCollectedFee := netCollected.NetFeesCollected.Sub(amount) - if netCollectedFee.IsNegative() { +func (k Keeper) DecreaseNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, amount sdk.Int) error { + netFeeData, found := k.GetNetFeeCollectedData(ctx, appID, assetID) + if !found { + return types.ErrorDataDoesNotExists + } + netFeeData.NetFeesCollected = netFeeData.NetFeesCollected.Sub(amount) + + if netFeeData.NetFeesCollected.IsNegative() { return types.ErrorNetFeesCanNotBeNegative } - netCollected.NetFeesCollected = netCollectedFee var ( store = ctx.KVStore(k.storeKey) key = types.NetFeeCollectedDataKey(appID, assetID) - value = k.cdc.MustMarshal(&netCollected) + value = k.cdc.MustMarshal(&netFeeData) ) store.Set(key, value) @@ -748,11 +752,7 @@ func (k Keeper) LockerIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, coll newRewardDec := sdk.NewDec(newReward.Int64()) lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Sub(newRewardDec) k.rewards.SetLockerRewardTracker(ctx, lockerRewardsTracker) - netFeeCollectedData, found := k.GetNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId) - if !found { - continue - } - err = k.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward, netFeeCollectedData) + err = k.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward) if err != nil { continue } @@ -836,7 +836,7 @@ func (k Keeper) WasmMsgGetSurplusFund(ctx sdk.Context, appID, assetID uint64, ad if err != nil { return err } - err = k.DecreaseNetFeeCollectedData(ctx, appID, assetID, amount.Amount, types.AppAssetIdToFeeCollectedData{}) + err = k.DecreaseNetFeeCollectedData(ctx, appID, assetID, amount.Amount) if err != nil { return err } diff --git a/x/collector/keeper/collector_test.go b/x/collector/keeper/collector_test.go index d2c145223..0fd2c0894 100644 --- a/x/collector/keeper/collector_test.go +++ b/x/collector/keeper/collector_test.go @@ -52,7 +52,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg2 := assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg2) @@ -60,7 +60,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg3 := assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg3) @@ -68,7 +68,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg4 := assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg4) @@ -345,7 +345,7 @@ func (s *KeeperTestSuite) TestDecreaseNetFeesCollected() { s.Run(tc.name, func() { netFeesData1, found := collectorKeeper.GetNetFeeCollectedData(*ctx, tc.appID, tc.assetID) s.Require().True(found) - err := collectorKeeper.DecreaseNetFeeCollectedData(*ctx, tc.appID, tc.assetID, tc.fee, netFeesData1) + err := collectorKeeper.DecreaseNetFeeCollectedData(*ctx, tc.appID, tc.assetID, tc.fee) if tc.errorExpected { s.Require().Error(err) } else { diff --git a/x/esm/abci.go b/x/esm/abci.go index 658ac844a..4a3b24444 100644 --- a/x/esm/abci.go +++ b/x/esm/abci.go @@ -1,13 +1,13 @@ package esm import ( + assettypes "github.com/comdex-official/comdex/x/asset/types" "github.com/comdex-official/comdex/x/esm/expected" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/tendermint/tendermint/abci/types" utils "github.com/comdex-official/comdex/types" - assettypes "github.com/comdex-official/comdex/x/asset/types" "github.com/comdex-official/comdex/x/esm/keeper" "github.com/comdex-official/comdex/x/esm/types" ) @@ -26,17 +26,12 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper, as continue } if ctx.BlockTime().After(esmStatus.EndTime) && esmStatus.Status && !esmStatus.VaultRedemptionStatus { - err := k.SetUpCollateralRedemptionForVault(ctx, esmStatus.AppId) - if err != nil { - continue - } - } - if ctx.BlockTime().After(esmStatus.EndTime) && esmStatus.Status && !esmStatus.StableVaultRedemptionStatus { - err := k.SetUpCollateralRedemptionForStableVault(ctx, esmStatus.AppId) + err := k.EsmStepStateTrigger(ctx, esmStatus.AppId) if err != nil { continue } } + if !esmStatus.SnapshotStatus && esmStatus.Status { err := k.SnapshotOfPrices(ctx, esmStatus) if err != nil { diff --git a/x/esm/client/cli/query.go b/x/esm/client/cli/query.go index 5e1ee540d..332b2a377 100644 --- a/x/esm/client/cli/query.go +++ b/x/esm/client/cli/query.go @@ -33,6 +33,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command { queryUsersDepositMapping(), queryDataAfterCoolOff(), querySnapshotPrice(), + queryAssetDataAfterCoolOff(), ) return cmd @@ -267,3 +268,40 @@ func querySnapshotPrice() *cobra.Command { return cmd } + +func queryAssetDataAfterCoolOff() *cobra.Command { + cmd := &cobra.Command{ + Use: "asset_data_after_cool_off [app-id]", + Short: "Query asset data after cool off period for esm", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + id, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + + res, err := queryClient.QueryAssetDataAfterCoolOff( + context.Background(), + &types.QueryAssetDataAfterCoolOffRequest{ + AppId: id, + }, + ) + if err != nil { + return err + } + + return ctx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/esm/expected/keeper.go b/x/esm/expected/keeper.go index 4838e11bb..13335815e 100644 --- a/x/esm/expected/keeper.go +++ b/x/esm/expected/keeper.go @@ -24,6 +24,9 @@ type VaultKeeper interface { DeleteVault(ctx sdk.Context, id uint64) DeleteAddressFromAppExtendedPairVaultMapping(ctx sdk.Context, extendedPairID uint64, userVaultID uint64, appMappingID uint64) GetStableMintVaults(ctx sdk.Context) (stableVaults []vaulttypes.StableMintVault) + UpdateCollateralLockedAmountLockerMapping(ctx sdk.Context, appMappingID uint64, extendedPairID uint64, amount sdk.Int, changeType bool) + UpdateTokenMintedAmountLockerMapping(ctx sdk.Context, appMappingID uint64, extendedPairID uint64, amount sdk.Int, changeType bool) + DeleteUserVaultExtendedPairMapping(ctx sdk.Context, address string, appID uint64, pairVaultID uint64) } type BankKeeper interface { @@ -51,4 +54,5 @@ type Tokenmint interface { type Collector interface { GetNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64) (netFeeData collectortypes.AppAssetIdToFeeCollectedData, found bool) GetAppNetFeeCollectedData(ctx sdk.Context, appID uint64) (netFeeData []collectortypes.AppAssetIdToFeeCollectedData, found bool) + DecreaseNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, amount sdk.Int) error } diff --git a/x/esm/keeper/esm.go b/x/esm/keeper/esm.go index 04571faf7..f22837d5b 100644 --- a/x/esm/keeper/esm.go +++ b/x/esm/keeper/esm.go @@ -6,27 +6,11 @@ import ( "github.com/comdex-official/comdex/app/wasm/bindings" assettypes "github.com/comdex-official/comdex/x/asset/types" + collectortypes "github.com/comdex-official/comdex/x/collector/types" "github.com/comdex-official/comdex/x/esm/types" vaulttypes "github.com/comdex-official/comdex/x/vault/types" ) -func (k Keeper) AddESMTriggerParamsRecords(ctx sdk.Context, record types.ESMTriggerParams) error { - _, found := k.GetESMTriggerParams(ctx, record.AppId) - if found { - return types.ErrorDuplicateESMTriggerParams - } - - esmTriggerParams := types.ESMTriggerParams{ - AppId: record.AppId, - TargetValue: record.TargetValue, - CoolOffPeriod: record.CoolOffPeriod, - AssetsRates: record.AssetsRates, - } - k.SetESMTriggerParams(ctx, esmTriggerParams) - - return nil -} - func (k Keeper) SetESMTriggerParams(ctx sdk.Context, esmTriggerParams types.ESMTriggerParams) { var ( store = k.Store(ctx) @@ -280,13 +264,115 @@ func (k Keeper) GetAllDataAfterCoolOff(ctx sdk.Context) (dataAfterCoolOff []type return dataAfterCoolOff } -func (k Keeper) SetUpCollateralRedemptionForVault(ctx sdk.Context, appID uint64) error { - totalVaults := k.vault.GetVaults(ctx) +// A top level function gets called from the abci +// It internally calls the following functions +// 1. Vault +// 2, stable Vault (code for vault and stabel vault can be reused +// 3. collector +// 4. share calc. +// 5. esm setting data + +func (k Keeper) EsmStepStateTrigger(ctx sdk.Context, appID uint64) error { esmStatus, found := k.GetESMStatus(ctx, appID) if !found { return types.ErrESMParamsNotFound } esmData, _ := k.GetESMTriggerParams(ctx, appID) + // 1. Vault Calling + + err := k.SetUpCollateralRedemptionForVault(ctx, appID, esmData) + if err != nil { + return err + } + // 2, stable Vault (code for vault and stabel vault can be reused) + + err = k.SetUpCollateralRedemptionForStableVault(ctx, appID, esmData) + if err != nil { + return err + } + + // 3. collector + // Used to reduce debt tokens from the debt pool. + // Call collector. for each debt token, subtract it from debt pool, burn it. + + netFee, found1 := k.collector.GetAppNetFeeCollectedData(ctx, appID) + if found1 { + for _, data := range netFee { + coolOffData, _ := k.GetDataAfterCoolOff(ctx, appID) + // Call AssetToAmount for the debt asset + value, _ := k.GetAssetToAmount(ctx, data.AppId, data.AssetId) + + if !value.IsCollateral && !data.NetFeesCollected.IsZero() { + // subtract dollar value + // burn token + // update collector data + assetData, found := k.asset.GetAsset(ctx, value.AssetID) + if !found { + return assettypes.ErrorAssetDoesNotExist + } + rateIn, found := k.GetSnapshotOfPrices(ctx, appID, assetData.Id) + if !found { + continue + } + + dollarVal := k.CalcDollarValueOfToken(ctx, rateIn, data.NetFeesCollected, assetData.Decimals) + value.Amount = value.Amount.Sub(data.NetFeesCollected) + coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Sub(dollarVal) + burnCoin := sdk.NewCoin(assetData.Denom, data.NetFeesCollected) + if err := k.bank.BurnCoins(ctx, collectortypes.ModuleName, sdk.NewCoins(burnCoin)); err != nil { + return err + } + k.SetDataAfterCoolOff(ctx, coolOffData) + k.SetAssetToAmount(ctx, value) + err = k.collector.DecreaseNetFeeCollectedData(ctx, appID, assetData.Id, data.NetFeesCollected) + if err != nil { + return nil + } + } + } + } + + // 4. share calc. + coolOffData, _ := k.GetDataAfterCoolOff(ctx, appID) + allAssetToAmtData := k.GetAllAssetToAmount(ctx, appID) + for _, amt := range allAssetToAmtData { + assetData, found := k.asset.GetAsset(ctx, amt.AssetID) + if !found { + return assettypes.ErrorAssetDoesNotExist + } + // TODO Refactor + // Call Rate out function for debt asset + rate := k.GetRateOfAsset(ctx, appID, amt.AssetID) + if rate == 0 { + rate, _ = k.GetSnapshotOfPrices(ctx, appID, amt.AssetID) + } + amtDValue := k.CalcDollarValueOfToken(ctx, rate, amt.Amount, assetData.Decimals) + if amt.IsCollateral { + amt.Share = amtDValue.Quo(coolOffData.CollateralTotalAmount) + } else { + amt.Share = amtDValue.Quo(coolOffData.DebtTotalAmount) + debtDValue := amt.Share.Mul(coolOffData.CollateralTotalAmount) + // amt.DebtTokenWorth = debtDValue.Quo(sdk.Dec(amt.Amount)) + denominator := sdk.NewDecFromInt(assetData.Decimals) + numerator := sdk.NewDecFromInt(amt.Amount).Quo(denominator) + amt.DebtTokenWorth = debtDValue.Quo(numerator) + } + k.SetAssetToAmount(ctx, amt) + } + + // 5. esm setting data + esmStatus.VaultRedemptionStatus = true + + k.SetESMStatus(ctx, esmStatus) + + return nil +} + +func (k Keeper) SetUpCollateralRedemptionForVault(ctx sdk.Context, appID uint64, esmData types.ESMTriggerParams) error { + // var totalVaults []vaulttypes.Vault; + + totalVaults := k.vault.GetVaults(ctx) + for _, data := range totalVaults { if data.AppId == appID { extendedPairVault, found := k.asset.GetPairsVault(ctx, data.ExtendedPairVaultID) @@ -309,18 +395,10 @@ func (k Keeper) SetUpCollateralRedemptionForVault(ctx sdk.Context, appID uint64) if !found { return assettypes.ErrorAssetDoesNotExist } - rateOut, found := k.GetSnapshotOfPrices(ctx, appID, pairData.AssetOut) - if !found { - for _, data := range esmData.AssetsRates { - if pairData.AssetOut == data.AssetID { - rateOut = data.Rates - break - } - rateOut = 0 - } - } + // Call Rate out function for debt asset + rateOut := k.GetRateOfAsset(ctx, appID, assetOutData.Id) if rateOut == 0 { - continue + rateOut, _ = k.GetSnapshotOfPrices(ctx, appID, assetOutData.Id) } coolOffData, found := k.GetDataAfterCoolOff(ctx, appID) if !found { @@ -328,113 +406,75 @@ func (k Keeper) SetUpCollateralRedemptionForVault(ctx sdk.Context, appID uint64) var itemc types.AssetToAmount var itemd types.AssetToAmount + itemc.AppId = appID itemc.AssetID = assetInData.Id itemc.Amount = data.AmountIn - x, _ := k.CalcDollarValueOfToken(ctx, assetInData.Id, rateIn, data.AmountIn) - // x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = x - itemc.Share = x.Quo(coolOffData.CollateralTotalAmount) + itemc.IsCollateral = true + coolOffData.CollateralTotalAmount = k.CalcDollarValueOfToken(ctx, rateIn, data.AmountIn, assetInData.Decimals) + itemc.Share = sdk.OneDec() err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) if err != nil { return err } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, itemc) + k.SetAssetToAmount(ctx, itemc) + itemd.AppId = appID itemd.AssetID = assetOutData.Id itemd.Amount = data.AmountOut - y, _ := k.CalcDollarValueOfToken(ctx, assetOutData.Id, rateOut, data.AmountOut) - // y := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = y - itemd.Share = y.Quo(coolOffData.DebtTotalAmount) - - itemd.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(itemd.Share).Quo(sdk.NewDecFromInt(itemd.Amount)) - - coolOffData.DebtAsset = append(coolOffData.DebtAsset, itemd) - + itemd.IsCollateral = false + coolOffData.DebtTotalAmount = k.CalcDollarValueOfToken(ctx, rateOut, data.AmountOut, assetOutData.Decimals) + itemd.Share = sdk.OneDec() + k.SetAssetToAmount(ctx, itemd) k.SetDataAfterCoolOff(ctx, coolOffData) } else { - count := 0 - for i, indata := range coolOffData.CollateralAsset { - if indata.AssetID == assetInData.Id { - count++ - indata.Amount = indata.Amount.Add(data.AmountIn) - x, _ := k.CalcDollarValueOfToken(ctx, assetInData.Id, rateIn, data.AmountIn) - // x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(x) - indata.Share = x.Quo(coolOffData.CollateralTotalAmount) - err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) - if err != nil { - return err - } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset[:i], coolOffData.CollateralAsset[i+1:]...) - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, indata) - break - } - } - if count == 0 { - var item types.AssetToAmount - - item.AssetID = assetInData.Id - item.Amount = data.AmountIn - x, _ := k.CalcDollarValueOfToken(ctx, assetInData.Id, rateIn, data.AmountIn) - // x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(x) - item.Share = x.Quo(coolOffData.CollateralTotalAmount) - - err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) - if err != nil { - return err - } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, item) + coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(k.CalcDollarValueOfToken(ctx, rateIn, data.AmountIn, assetInData.Decimals)) + coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(k.CalcDollarValueOfToken(ctx, rateOut, data.AmountOut, assetOutData.Decimals)) + assetToAmtInData, found := k.GetAssetToAmount(ctx, appID, assetInData.Id) + if !found { + assetToAmtInData.AppId = appID + assetToAmtInData.AssetID = assetInData.Id + assetToAmtInData.Amount = data.AmountIn + assetToAmtInData.IsCollateral = true + } else { + assetToAmtInData.Amount = assetToAmtInData.Amount.Add(data.AmountIn) } - count = 0 - for i, indatadebt := range coolOffData.DebtAsset { - if indatadebt.AssetID == assetOutData.Id { - count++ - indatadebt.Amount = indatadebt.Amount.Add(data.AmountOut) - y, _ := k.CalcDollarValueOfToken(ctx, assetOutData.Id, rateOut, data.AmountOut) - // y := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(y) - indatadebt.Share = y.Quo(coolOffData.DebtTotalAmount) - indatadebt.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(indatadebt.Share).Quo(sdk.NewDecFromInt(indatadebt.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset[:i], coolOffData.DebtAsset[i+1:]...) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, indatadebt) - break - } + assetToAmtOutData, found := k.GetAssetToAmount(ctx, appID, assetOutData.Id) + if !found { + assetToAmtOutData.AppId = appID + assetToAmtOutData.AssetID = assetOutData.Id + assetToAmtOutData.Amount = data.AmountOut + assetToAmtOutData.IsCollateral = false + } else { + assetToAmtOutData.Amount = assetToAmtOutData.Amount.Add(data.AmountOut) } - if count == 0 { - var itemx types.AssetToAmount - - itemx.AssetID = assetOutData.Id - itemx.Amount = data.AmountOut - z, _ := k.CalcDollarValueOfToken(ctx, assetOutData.Id, rateOut, data.AmountOut) - // z := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(z) - itemx.Share = z.Quo(coolOffData.DebtTotalAmount) - itemx.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(itemx.Share).Quo(sdk.NewDecFromInt(itemx.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, itemx) + err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) + if err != nil { + return err } k.SetDataAfterCoolOff(ctx, coolOffData) + k.SetAssetToAmount(ctx, assetToAmtInData) + k.SetAssetToAmount(ctx, assetToAmtOutData) } - k.SetESMStatus(ctx, esmStatus) k.vault.DeleteVault(ctx, data.Id) k.vault.DeleteAddressFromAppExtendedPairVaultMapping(ctx, data.ExtendedPairVaultID, data.Id, data.AppId) + //Delete User Data + k.vault.UpdateCollateralLockedAmountLockerMapping(ctx, appID, data.ExtendedPairVaultID, data.AmountIn, false) + k.vault.UpdateTokenMintedAmountLockerMapping(ctx, appID, data.ExtendedPairVaultID, data.AmountOut, false) + k.vault.DeleteUserVaultExtendedPairMapping(ctx, data.Owner, appID, data.ExtendedPairVaultID) } } - esmStatus.VaultRedemptionStatus = true - k.SetESMStatus(ctx, esmStatus) return nil } -func (k Keeper) SetUpCollateralRedemptionForStableVault(ctx sdk.Context, appID uint64) error { +// StableMintVault Function + +func (k Keeper) SetUpCollateralRedemptionForStableVault(ctx sdk.Context, appID uint64, esmData types.ESMTriggerParams) error { + // var totalVaults []vaulttypes.Vault; + totalStableVaults := k.vault.GetStableMintVaults(ctx) - esmStatus, found := k.GetESMStatus(ctx, appID) - if !found { - return types.ErrESMParamsNotFound - } - esmData, _ := k.GetESMTriggerParams(ctx, appID) + for _, data := range totalStableVaults { if data.AppId == appID { extendedPairVault, found := k.asset.GetPairsVault(ctx, data.ExtendedPairVaultID) @@ -449,151 +489,82 @@ func (k Keeper) SetUpCollateralRedemptionForStableVault(ctx sdk.Context, appID u if !found { return assettypes.ErrorAssetDoesNotExist } - rateIn, found := k.GetSnapshotOfPrices(ctx, appID, pairData.AssetIn) - if !found { - continue - } + assetOutData, found := k.asset.GetAsset(ctx, pairData.AssetOut) if !found { return assettypes.ErrorAssetDoesNotExist } - rateOut, found := k.GetSnapshotOfPrices(ctx, appID, pairData.AssetOut) - if !found { - for _, data := range esmData.AssetsRates { - if pairData.AssetOut == data.AssetID { - rateOut = data.Rates - break - } - rateOut = 0 - } - } - if rateOut == 0 { - continue - } + // Call Rate in function for collateral + rateIn := k.GetRateOfAsset(ctx, appID, assetInData.Id) + // Call Rate out function for debt asset + rateOut := k.GetRateOfAsset(ctx, appID, assetOutData.Id) + coolOffData, found := k.GetDataAfterCoolOff(ctx, appID) if !found { coolOffData.AppId = appID var itemc types.AssetToAmount var itemd types.AssetToAmount + itemc.AppId = appID itemc.AssetID = assetInData.Id itemc.Amount = data.AmountIn - x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = sdk.NewDecFromInt(x) - itemc.Share = sdk.NewDecFromInt(x).Quo(coolOffData.CollateralTotalAmount) + itemc.IsCollateral = true + coolOffData.CollateralTotalAmount = k.CalcDollarValueOfToken(ctx, rateIn, data.AmountIn, assetInData.Decimals) + itemc.Share = sdk.OneDec() err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) if err != nil { return err } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, itemc) + k.SetAssetToAmount(ctx, itemc) + itemd.AppId = appID itemd.AssetID = assetOutData.Id itemd.Amount = data.AmountOut - y := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = sdk.NewDecFromInt(y) - itemd.Share = sdk.NewDecFromInt(y).Quo(coolOffData.DebtTotalAmount) - itemd.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(itemd.Share).Quo(sdk.NewDecFromInt(itemd.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, itemd) + itemd.IsCollateral = false + coolOffData.DebtTotalAmount = k.CalcDollarValueOfToken(ctx, rateOut, data.AmountOut, assetOutData.Decimals) + itemd.Share = sdk.OneDec() + k.SetAssetToAmount(ctx, itemd) + + // debt token worth ???? + // itemd.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(itemd.Share).Quo(sdk.NewDecFromInt(itemd.Amount)) k.SetDataAfterCoolOff(ctx, coolOffData) } else { - count := 0 - for i, indata := range coolOffData.CollateralAsset { - if indata.AssetID == assetInData.Id { - count++ - indata.Amount = indata.Amount.Add(data.AmountIn) - x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(sdk.NewDecFromInt(x)) - indata.Share = sdk.NewDecFromInt(x).Quo(coolOffData.CollateralTotalAmount) - - err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) - if err != nil { - return err - } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset[:i], coolOffData.CollateralAsset[i+1:]...) - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, indata) - break - } - } - if count == 0 { - var item types.AssetToAmount - - item.AssetID = assetInData.Id - item.Amount = data.AmountIn - x := sdk.NewIntFromUint64(rateIn).Mul(data.AmountIn) - coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(sdk.NewDecFromInt(x)) - item.Share = sdk.NewDecFromInt(x).Quo(coolOffData.CollateralTotalAmount) - - err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) - if err != nil { - return err - } - coolOffData.CollateralAsset = append(coolOffData.CollateralAsset, item) + coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Add(k.CalcDollarValueOfToken(ctx, rateIn, data.AmountIn, assetInData.Decimals)) + coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(k.CalcDollarValueOfToken(ctx, rateOut, data.AmountOut, assetOutData.Decimals)) + assetToAmtInData, found := k.GetAssetToAmount(ctx, appID, assetInData.Id) + if !found { + assetToAmtInData.AppId = appID + assetToAmtInData.AssetID = assetInData.Id + assetToAmtInData.Amount = data.AmountIn + assetToAmtInData.IsCollateral = true + } else { + assetToAmtInData.Amount = assetToAmtInData.Amount.Add(data.AmountIn) } - count = 0 - for i, indatadebt := range coolOffData.DebtAsset { - if indatadebt.AssetID == assetOutData.Id { - count++ - indatadebt.Amount = indatadebt.Amount.Add(data.AmountOut) - x := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(sdk.NewDecFromInt(x)) - indatadebt.Share = sdk.NewDecFromInt(x).Quo(coolOffData.DebtTotalAmount) - indatadebt.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(indatadebt.Share).Quo(sdk.NewDecFromInt(indatadebt.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset[:i], coolOffData.DebtAsset[i+1:]...) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, indatadebt) - break - } + assetToAmtOutData, found := k.GetAssetToAmount(ctx, appID, assetOutData.Id) + if !found { + assetToAmtOutData.AppId = appID + assetToAmtOutData.AssetID = assetOutData.Id + assetToAmtOutData.Amount = data.AmountOut + assetToAmtOutData.IsCollateral = false + } else { + assetToAmtOutData.Amount = assetToAmtOutData.Amount.Add(data.AmountOut) } - if count == 0 { - var item types.AssetToAmount - - item.AssetID = assetOutData.Id - item.Amount = data.AmountOut - x := sdk.NewIntFromUint64(rateOut).Mul(data.AmountOut) - coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Add(sdk.NewDecFromInt(x)) - item.Share = sdk.NewDecFromInt(x).Quo(coolOffData.DebtTotalAmount) - item.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(item.Share).Quo(sdk.NewDecFromInt(item.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, item) + err := k.bank.SendCoinsFromModuleToModule(ctx, vaulttypes.ModuleName, types.ModuleName, sdk.NewCoins(sdk.NewCoin(assetInData.Denom, data.AmountIn))) + if err != nil { + return err } k.SetDataAfterCoolOff(ctx, coolOffData) + k.SetAssetToAmount(ctx, assetToAmtInData) + k.SetAssetToAmount(ctx, assetToAmtOutData) } + k.vault.DeleteAddressFromAppExtendedPairVaultMapping(ctx, data.ExtendedPairVaultID, data.Id, data.AppId) + k.vault.UpdateCollateralLockedAmountLockerMapping(ctx, appID, data.ExtendedPairVaultID, data.AmountIn, false) + k.vault.UpdateTokenMintedAmountLockerMapping(ctx, appID, data.ExtendedPairVaultID, data.AmountOut, false) } } - netFee, found1 := k.collector.GetAppNetFeeCollectedData(ctx, appID) - coolOffData, found := k.GetDataAfterCoolOff(ctx, appID) - if !found { - return nil - } - if found1 { - for _, data := range netFee { - for i, indatanet := range coolOffData.DebtAsset { - if data.AssetId == indatanet.AssetID { - rateOut, found := k.GetSnapshotOfPrices(ctx, appID, data.AssetId) - if !found { - for _, datan := range esmData.AssetsRates { - if data.AssetId == datan.AssetID { - rateOut = datan.Rates - break - } - rateOut = 0 - } - } - indatanet.Amount = indatanet.Amount.Sub(data.NetFeesCollected) - x, _ := k.CalcDollarValueOfToken(ctx, data.AssetId, rateOut, indatanet.Amount) - // x := sdk.NewIntFromUint64(rateOut).Mul(indatanet.Amount) - coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Sub(x) - indatanet.Share = x.Quo(coolOffData.DebtTotalAmount) - indatanet.DebtTokenWorth = coolOffData.CollateralTotalAmount.Mul(indatanet.Share).Quo(sdk.NewDecFromInt(indatanet.Amount)) - coolOffData.DebtAsset = append(coolOffData.DebtAsset[:i], coolOffData.DebtAsset[i+1:]...) - coolOffData.DebtAsset = append(coolOffData.DebtAsset, indatanet) - } - } - } - } - esmStatus.StableVaultRedemptionStatus = true - k.SetESMStatus(ctx, esmStatus) - k.SetDataAfterCoolOff(ctx, coolOffData) + return nil } @@ -645,13 +616,66 @@ func (k Keeper) GetSnapshotOfPrices(ctx sdk.Context, appID, assetID uint64) (pri return id.GetValue(), true } -func (k Keeper) CalcDollarValueOfToken(ctx sdk.Context, id uint64, rate uint64, amt sdk.Int) (price sdk.Dec, err error) { - asset, found := k.asset.GetAsset(ctx, id) - if !found { - return sdk.ZeroDec(), assettypes.ErrorAssetDoesNotExist +func (k Keeper) SetAssetToAmount(ctx sdk.Context, assetToAmount types.AssetToAmount) { + var ( + store = k.Store(ctx) + key = types.AssetToAmountKey(assetToAmount.AppId, assetToAmount.AssetID) + value = k.cdc.MustMarshal(&assetToAmount) + ) + + store.Set(key, value) +} + +func (k Keeper) GetAssetToAmount(ctx sdk.Context, appID, assetID uint64) (assetToAmount types.AssetToAmount, found bool) { + var ( + store = k.Store(ctx) + key = types.AssetToAmountKey(appID, assetID) + value = store.Get(key) + ) + + if value == nil { + return assetToAmount, false } + k.cdc.MustUnmarshal(value, &assetToAmount) + return assetToAmount, true +} + +func (k Keeper) GetAllAssetToAmount(ctx sdk.Context, appID uint64) (assetToAmount []types.AssetToAmount) { + var ( + store = k.Store(ctx) + key = types.AppAssetToAmountKey(appID) + iter = sdk.KVStorePrefixIterator(store, key) + ) + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var esm types.AssetToAmount + k.cdc.MustUnmarshal(iter.Value(), &esm) + assetToAmount = append(assetToAmount, esm) + } + return assetToAmount +} + +func (k Keeper) CalcDollarValueOfToken(ctx sdk.Context, rate uint64, amt sdk.Int, decimals sdk.Int) (price sdk.Dec) { numerator := sdk.NewDecFromInt(amt).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(rate))) - denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset.Decimals))) - return numerator.Quo(denominator), nil + denominator := sdk.NewDecFromInt(decimals) + return numerator.Quo(denominator) +} + +func (k Keeper) GetRateOfAsset(ctx sdk.Context, appID, assetID uint64) uint64 { + esmData, _ := k.GetESMTriggerParams(ctx, appID) + var rateOut uint64 + for _, data := range esmData.AssetsRates { + if assetID == data.AssetID { + rateOut = data.Rates + return rateOut + } + } + return rateOut } diff --git a/x/esm/keeper/grpc_query.go b/x/esm/keeper/grpc_query.go index bf4ebaca5..c1601cefd 100644 --- a/x/esm/keeper/grpc_query.go +++ b/x/esm/keeper/grpc_query.go @@ -123,3 +123,20 @@ func (q QueryServer) QuerySnapshotPrice(c context.Context, req *types.QuerySnaps Price: price, }, nil } + +func (q QueryServer) QueryAssetDataAfterCoolOff(c context.Context, req *types.QueryAssetDataAfterCoolOffRequest) (*types.QueryAssetDataAfterCoolOffResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "request cannot be empty") + } + + ctx := sdk.UnwrapSDKContext(c) + + item := q.GetAllAssetToAmount(ctx, req.AppId) + if item == nil { + return &types.QueryAssetDataAfterCoolOffResponse{}, nil + } + + return &types.QueryAssetDataAfterCoolOffResponse{ + AssetToAmount: item, + }, nil +} diff --git a/x/esm/keeper/keeper.go b/x/esm/keeper/keeper.go index 58eb169cc..563ce0400 100644 --- a/x/esm/keeper/keeper.go +++ b/x/esm/keeper/keeper.go @@ -97,36 +97,27 @@ func (k Keeper) DepositESM(ctx sdk.Context, depositorAddr string, AppID uint64, if !found { return types.ErrESMTriggerParamsNotFound } - currentDeposit, found := k.GetCurrentDepositStats(ctx, AppID) + existingDeposit, found := k.GetCurrentDepositStats(ctx, AppID) if !found { - newCurrentDeposit := types.CurrentDepositStats{ + existingDeposit = types.CurrentDepositStats{ AppId: AppID, Balance: Amount, } - k.SetCurrentDepositStats(ctx, newCurrentDeposit) } else { - newCurrentDeposit := types.CurrentDepositStats{ - AppId: AppID, - Balance: currentDeposit.Balance.Add(Amount), + if existingDeposit.Balance.Amount.GT(esmTriggerParams.TargetValue.Amount) { + return types.ErrDepositForAppReached } - k.SetCurrentDepositStats(ctx, newCurrentDeposit) - } - newCurrentDeposit, _ := k.GetCurrentDepositStats(ctx, AppID) - - if newCurrentDeposit.Balance.Amount.GT(esmTriggerParams.TargetValue.Amount) { - return types.ErrDepositForAppReached - } - if Amount.Amount.GT(esmTriggerParams.TargetValue.Amount) { - return types.ErrAmtExceedsTargetValue + existingDeposit.Balance = existingDeposit.Balance.Add(Amount) } addr, _ := sdk.AccAddressFromBech32(depositorAddr) - if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, tokenminttypes.ModuleName, sdk.NewCoins(Amount)); err != nil { return err } if err1 := k.tokenmint.BurnTokensForApp(ctx, AppID, govAsset.Id, Amount.Amount); err1 != nil { return err1 } + k.SetCurrentDepositStats(ctx, existingDeposit) + // currentDeposit, found := k.GetCurrentDepositStats(ctx, AppID) userDeposits, found := k.GetUserDepositByApp(ctx, depositorAddr, AppID) if !found { @@ -181,56 +172,86 @@ func (k Keeper) ExecuteESM(ctx sdk.Context, executor string, AppID uint64) error return nil } -func (k Keeper) CalculateCollateral(ctx sdk.Context, appID uint64, amount sdk.Coin, esmDataAfterCoolOff types.DataAfterCoolOff, from string) error { +// take token input from user +// find the token and its per token dollar value +// calculate percentage of dollar of each collateral token +// calculate token quantity from dollar value +// subtract total dollar value from the end from the struct, +// subtract token quantity from each collateral +func (k Keeper) CalculateCollateral(ctx sdk.Context, appID uint64, amount sdk.Coin, from string) error { userAddress, err := sdk.AccAddressFromBech32(from) if err != nil { return err } - assetInID, _ := k.asset.GetAssetForDenom(ctx, amount.Denom) - - // initializing userWorth - userWorth := sdk.ZeroDec() - for _, v := range esmDataAfterCoolOff.DebtAsset { - if v.AssetID == assetInID.Id { - userWorth = v.DebtTokenWorth.Mul(sdk.NewDecFromInt(amount.Amount)) - break - } + assetID, _ := k.asset.GetAssetForDenom(ctx, amount.Denom) + coolOffData, found := k.GetDataAfterCoolOff(ctx, appID) + if !found { + return types.ErrAppDataNotFound + } + assetESMData, found := k.GetAssetToAmount(ctx, appID, assetID.Id) + if !found || assetESMData.IsCollateral || assetESMData.Amount.IsZero() || amount.Amount.GT(assetESMData.Amount) { + return types.ErrInvalidAsset + } + unitWorth := assetESMData.DebtTokenWorth + // Total worth of debt asset brought by user + // totalDebtAssetWorth := unitWorth.Mul(amount.Amount.ToDec()) + totalDebtAssetWorth := k.CalcDollarValueOfToken(ctx, unitWorth.TruncateInt().Uint64(), amount.Amount, assetID.Decimals) + err1 := k.bank.SendCoinsFromAccountToModule(ctx, userAddress, types.ModuleName, sdk.NewCoins(amount)) + if err1 != nil { + return err1 + } + err2 := k.bank.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) + if err2 != nil { + return err2 } - for i, data := range esmDataAfterCoolOff.CollateralAsset { - collAsset, _ := k.asset.GetAsset(ctx, data.AssetID) - tokenDValue := data.Share.Mul(userWorth) - price, _ := k.GetSnapshotOfPrices(ctx, appID, data.AssetID) // getting last saved prices - oldTokenQuant := tokenDValue.Quo(sdk.NewDecFromInt(sdk.NewIntFromUint64(price))) - usd := 1000000 - tokenQuant := oldTokenQuant.Quo(sdk.NewDec(int64(usd))) - err1 := k.bank.SendCoinsFromAccountToModule(ctx, userAddress, types.ModuleName, sdk.NewCoins(amount)) - if err1 != nil { - return err1 - } - err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, userAddress, sdk.NewCoins(sdk.NewCoin(collAsset.Denom, tokenQuant.TruncateInt()))) - if err != nil { - return err - } - err2 := k.bank.BurnCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) - if err2 != nil { - return err2 + // Calculating share of all collateral asset that needs to be paid to the user upto the $ value of totalDebtAssetWorth + // Eg. If user brought $20 of CMST (totalDebtAssetWorth) and if 2 collateral exist as CMDX(80%) and ATOM(20%) then 20% of tokens that + // will be paid will be in terms of ATOM tokens , rest CMDX. + allAssetToAmtData := k.GetAllAssetToAmount(ctx, appID) + for _, tokenData := range allAssetToAmtData { + assetData, found := k.asset.GetAsset(ctx, tokenData.AssetID) + if !found { + return assettypes.ErrorAssetDoesNotExist } - data.Amount = data.Amount.Sub(tokenQuant.TruncateInt()) - esmDataAfterCoolOff.CollateralAsset = append(esmDataAfterCoolOff.CollateralAsset[:i], esmDataAfterCoolOff.CollateralAsset[i+1:]...) - esmDataAfterCoolOff.CollateralAsset = append(esmDataAfterCoolOff.CollateralAsset[:i+1], esmDataAfterCoolOff.CollateralAsset[i:]...) - esmDataAfterCoolOff.CollateralAsset[i] = data - k.SetDataAfterCoolOff(ctx, esmDataAfterCoolOff) - } - - for i, b := range esmDataAfterCoolOff.DebtAsset { - if b.AssetID == assetInID.Id { - b.Amount = b.Amount.Sub(amount.Amount) - esmDataAfterCoolOff.DebtAsset = append(esmDataAfterCoolOff.DebtAsset[:i], esmDataAfterCoolOff.DebtAsset[i+1:]...) - esmDataAfterCoolOff.DebtAsset = append(esmDataAfterCoolOff.DebtAsset, b) - k.SetDataAfterCoolOff(ctx, esmDataAfterCoolOff) + + if tokenData.IsCollateral && !tokenData.Amount.IsZero() { + unitRate, _ := k.GetSnapshotOfPrices(ctx, appID, assetData.Id) + tokenShare := totalDebtAssetWorth.Mul(tokenData.Share) //$CMST Multiplied with Share of collateral give $share of collateral + // To calculate quantity of collateral token from the $share of tokenShare + collateralQuantity := tokenShare.Quo(sdk.NewDecFromInt(sdk.NewIntFromUint64(unitRate))) + collateralQuantity = collateralQuantity.Mul(sdk.NewDecFromInt(assetData.Decimals)) + err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, userAddress, sdk.NewCoins(sdk.NewCoin(assetData.Denom, collateralQuantity.TruncateInt()))) + if err != nil { + return err + } + // Reducing quantity of token in collateral + tokenData.Amount = tokenData.Amount.Sub(collateralQuantity.TruncateInt()) } + k.SetAssetToAmount(ctx, tokenData) + } + + // To reduce collateral token dollar quantity + + // As the worth was calculated against collateral asset - totalDebtAssetWorth so we use it to subtract collateral dollar value + coolOffData.CollateralTotalAmount = coolOffData.CollateralTotalAmount.Sub(totalDebtAssetWorth) + + // To reduce Debt token dollar quantity + // We need to now find the debt token worth,to subtract it + rate, found := k.GetSnapshotOfPrices(ctx, appID, assetID.Id) + if !found { + rate = k.GetRateOfAsset(ctx, appID, assetID.Id) } + totalAmount := sdk.NewDecFromInt(amount.Amount) + totalPrice := totalAmount.Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(rate))) + coolOffData.DebtTotalAmount = coolOffData.DebtTotalAmount.Sub(totalPrice) + + // To reduce the debt token amount from asset data. + + assetESMData.Amount = assetESMData.Amount.Sub(amount.Amount) + k.SetAssetToAmount(ctx, assetESMData) + + k.SetDataAfterCoolOff(ctx, coolOffData) return nil } diff --git a/x/esm/keeper/msg_server.go b/x/esm/keeper/msg_server.go index e629d8a99..e4a4f962e 100644 --- a/x/esm/keeper/msg_server.go +++ b/x/esm/keeper/msg_server.go @@ -73,21 +73,8 @@ func (m msgServer) MsgCollateralRedemption(c context.Context, req *types.MsgColl if ctx.BlockTime().Before(esmStatus.EndTime) && status { return nil, types.ErrCoolOffPeriodRemains } - if ctx.BlockTime().After(esmStatus.EndTime) && status { - esmDataAfterCoolOff, _ := m.keeper.GetDataAfterCoolOff(ctx, req.AppId) - for _, v := range esmDataAfterCoolOff.DebtAsset { - debtAsset, _ := m.keeper.asset.GetAsset(ctx, v.AssetID) - if req.Amount.Denom == debtAsset.Denom { - if !req.Amount.Amount.LTE(v.Amount) { - return nil, types.ErrorInvalidAmount - } - if err := m.keeper.CalculateCollateral(ctx, req.AppId, req.Amount, esmDataAfterCoolOff, req.From); err != nil { - return nil, err - } - } else { - return nil, types.ErrInvalidAsset - } - } + if err := m.keeper.CalculateCollateral(ctx, req.AppId, req.Amount, req.From); err != nil { + return nil, err } ctx.GasMeter().ConsumeGas(types.MsgCollateralRedemptionGas, "MsgCollateralRedemptionGas") diff --git a/x/esm/types/esm.pb.go b/x/esm/types/esm.pb.go index 1a551669e..d0cffd308 100644 --- a/x/esm/types/esm.pb.go +++ b/x/esm/types/esm.pb.go @@ -150,14 +150,13 @@ func (m *CurrentDepositStats) GetBalance() github_com_cosmos_cosmos_sdk_types.Co } type ESMStatus struct { - AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"id"` - Executor string `protobuf:"bytes,2,opt,name=executor,proto3" json:"executor,omitempty" yaml:"executor"` - Status bool `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty" yaml:"status"` - StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` - EndTime time.Time `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` - VaultRedemptionStatus bool `protobuf:"varint,6,opt,name=vault_redemption_status,json=vaultRedemptionStatus,proto3" json:"vault_redemption_status,omitempty" yaml:"vault_redemption_status"` - StableVaultRedemptionStatus bool `protobuf:"varint,7,opt,name=stable_vault_redemption_status,json=stableVaultRedemptionStatus,proto3" json:"stable_vault_redemption_status,omitempty" yaml:"stable_vault_redemption_status"` - SnapshotStatus bool `protobuf:"varint,8,opt,name=snapshotStatus,proto3" json:"snapshotStatus,omitempty" yaml:"snapshot_status"` + AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"id"` + Executor string `protobuf:"bytes,2,opt,name=executor,proto3" json:"executor,omitempty" yaml:"executor"` + Status bool `protobuf:"varint,3,opt,name=status,proto3" json:"status,omitempty" yaml:"status"` + StartTime time.Time `protobuf:"bytes,4,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` + EndTime time.Time `protobuf:"bytes,5,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time" yaml:"end_time"` + VaultRedemptionStatus bool `protobuf:"varint,6,opt,name=vault_redemption_status,json=vaultRedemptionStatus,proto3" json:"vault_redemption_status,omitempty" yaml:"vault_redemption_status"` + SnapshotStatus bool `protobuf:"varint,7,opt,name=snapshotStatus,proto3" json:"snapshotStatus,omitempty" yaml:"snapshot_status"` } func (m *ESMStatus) Reset() { *m = ESMStatus{} } @@ -235,13 +234,6 @@ func (m *ESMStatus) GetVaultRedemptionStatus() bool { return false } -func (m *ESMStatus) GetStableVaultRedemptionStatus() bool { - if m != nil { - return m.StableVaultRedemptionStatus - } - return false -} - func (m *ESMStatus) GetSnapshotStatus() bool { if m != nil { return m.SnapshotStatus @@ -363,10 +355,8 @@ func (m *UsersDepositMapping) GetDeposits() github_com_cosmos_cosmos_sdk_types.C type DataAfterCoolOff struct { AppId uint64 `protobuf:"varint,1,opt,name=appId,proto3" json:"appId,omitempty" yaml:"appId"` - CollateralAsset []AssetToAmount `protobuf:"bytes,2,rep,name=collateral_asset,json=collateralAsset,proto3" json:"collateral_asset" yaml:"collateral_asset"` - DebtAsset []AssetToAmount `protobuf:"bytes,3,rep,name=debt_asset,json=debtAsset,proto3" json:"debt_asset" yaml:"debt_asset"` - CollateralTotalAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=collateral_total_amount,json=collateralTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"collateral_total_amount" yaml:"collateral_total_amount"` - DebtTotalAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=debt_total_amount,json=debtTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"debt_total_amount" yaml:"debt_total_amount"` + CollateralTotalAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=collateral_total_amount,json=collateralTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"collateral_total_amount" yaml:"collateral_total_amount"` + DebtTotalAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=debt_total_amount,json=debtTotalAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"debt_total_amount" yaml:"debt_total_amount"` } func (m *DataAfterCoolOff) Reset() { *m = DataAfterCoolOff{} } @@ -409,25 +399,13 @@ func (m *DataAfterCoolOff) GetAppId() uint64 { return 0 } -func (m *DataAfterCoolOff) GetCollateralAsset() []AssetToAmount { - if m != nil { - return m.CollateralAsset - } - return nil -} - -func (m *DataAfterCoolOff) GetDebtAsset() []AssetToAmount { - if m != nil { - return m.DebtAsset - } - return nil -} - type AssetToAmount struct { - AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"amount"` - Share github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=share,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"share" yaml:"share"` - DebtTokenWorth github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=debt_token_worth,json=debtTokenWorth,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"debt_token_worth" yaml:"debt_token_worth"` + AppId uint64 `protobuf:"varint,1,opt,name=appId,proto3" json:"appId,omitempty" yaml:"appId"` + AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"amount"` + Share github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=share,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"share" yaml:"share"` + DebtTokenWorth github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=debt_token_worth,json=debtTokenWorth,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"debt_token_worth" yaml:"debt_token_worth"` + IsCollateral bool `protobuf:"varint,6,opt,name=is_collateral,json=isCollateral,proto3" json:"is_collateral,omitempty" yaml:"is_collateral"` } func (m *AssetToAmount) Reset() { *m = AssetToAmount{} } @@ -463,6 +441,13 @@ func (m *AssetToAmount) XXX_DiscardUnknown() { var xxx_messageInfo_AssetToAmount proto.InternalMessageInfo +func (m *AssetToAmount) GetAppId() uint64 { + if m != nil { + return m.AppId + } + return 0 +} + func (m *AssetToAmount) GetAssetID() uint64 { if m != nil { return m.AssetID @@ -470,6 +455,13 @@ func (m *AssetToAmount) GetAssetID() uint64 { return 0 } +func (m *AssetToAmount) GetIsCollateral() bool { + if m != nil { + return m.IsCollateral + } + return false +} + type DebtAssetsRates struct { AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` Rates uint64 `protobuf:"varint,2,opt,name=rates,proto3" json:"rates,omitempty"` @@ -536,76 +528,72 @@ func init() { func init() { proto.RegisterFile("comdex/esm/v1beta1/esm.proto", fileDescriptor_e7f9b0ecd3a9e62a) } var fileDescriptor_e7f9b0ecd3a9e62a = []byte{ - // 1104 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x3f, 0x73, 0xe3, 0x44, - 0x14, 0x8f, 0x2e, 0x76, 0x62, 0x6f, 0x2e, 0xb1, 0xa3, 0x24, 0x17, 0x5f, 0x0e, 0xac, 0xb0, 0x0c, - 0x21, 0x07, 0x13, 0x79, 0x2e, 0x54, 0x50, 0x00, 0x51, 0x12, 0x98, 0xc0, 0x64, 0xc8, 0x28, 0xe1, - 0x8e, 0xb9, 0x46, 0xb3, 0x92, 0xd6, 0xb6, 0x26, 0x92, 0x56, 0x68, 0xd7, 0xbe, 0xcb, 0x0c, 0x05, - 0x05, 0x05, 0x65, 0x3e, 0x07, 0x9f, 0x81, 0x0f, 0x70, 0xe5, 0x15, 0x14, 0x0c, 0x85, 0x60, 0x9c, - 0x9e, 0x42, 0x74, 0x54, 0x8c, 0x76, 0x57, 0x92, 0x1d, 0x2e, 0x47, 0x3c, 0x54, 0x96, 0xde, 0xfb, - 0xbd, 0xdf, 0xfb, 0xff, 0x2c, 0xf0, 0x86, 0x43, 0x02, 0x17, 0x3f, 0xef, 0x60, 0x1a, 0x74, 0x86, - 0x8f, 0x6c, 0xcc, 0xd0, 0xa3, 0xec, 0x59, 0x8f, 0x62, 0xc2, 0x88, 0xaa, 0x0a, 0xad, 0x9e, 0x49, - 0xa4, 0x76, 0x63, 0xb5, 0x47, 0x7a, 0x84, 0xab, 0x3b, 0xd9, 0x93, 0x40, 0x6e, 0x68, 0x3d, 0x42, - 0x7a, 0x3e, 0xee, 0xf0, 0x37, 0x7b, 0xd0, 0xed, 0x30, 0x2f, 0xc0, 0x94, 0xa1, 0x20, 0x92, 0x80, - 0xb6, 0x43, 0x68, 0x40, 0x68, 0xc7, 0x46, 0x14, 0x17, 0x9e, 0x1c, 0xe2, 0x85, 0x42, 0x0f, 0x2f, - 0x67, 0x41, 0xf3, 0xf0, 0xf4, 0xf8, 0x2c, 0xf6, 0x7a, 0x3d, 0x1c, 0x9f, 0xa0, 0x18, 0x05, 0x54, - 0xdd, 0x01, 0x73, 0x28, 0x8a, 0x2c, 0xcf, 0x6d, 0x29, 0x9b, 0xca, 0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b4, 0x79, 0x0e, 0x3a, 0x3a, 0x28, 0xa7, 0x34, 0x07, 0x41, 0x73, 0x9e, - 0x3f, 0x1e, 0xb9, 0xea, 0x13, 0x30, 0x27, 0x23, 0x17, 0x5b, 0xf2, 0xc9, 0x14, 0x91, 0x1f, 0x85, - 0xac, 0xfc, 0x13, 0xc8, 0xc3, 0x95, 0x74, 0xea, 0x19, 0xa8, 0xd2, 0x3e, 0x8a, 0x31, 0x5f, 0xa5, - 0xba, 0xf1, 0xf1, 0xd4, 0x15, 0x91, 0xb3, 0xce, 0x49, 0xa0, 0x29, 0xc8, 0x54, 0x0a, 0x9a, 0xb2, - 0x44, 0xe7, 0x38, 0xb4, 0x9e, 0x91, 0x98, 0xf5, 0x65, 0xdb, 0x8f, 0xa6, 0x76, 0xb0, 0x3e, 0x51, - 0xf2, 0x82, 0x0f, 0x9a, 0x4b, 0xa2, 0xe2, 0xe7, 0x38, 0x7c, 0xc2, 0x05, 0x36, 0x68, 0x5c, 0xfb, - 0xe6, 0xf8, 0x3f, 0x15, 0x5f, 0x05, 0x55, 0xfe, 0x31, 0xc2, 0x0b, 0x5e, 0x31, 0xc5, 0x8b, 0xf1, - 0xf9, 0x8b, 0x51, 0x5b, 0x79, 0x39, 0x6a, 0x2b, 0x7f, 0x8c, 0xda, 0xca, 0xe5, 0x55, 0x7b, 0xe6, - 0xe5, 0x55, 0x7b, 0xe6, 0xd7, 0xab, 0xf6, 0xcc, 0xd3, 0x9d, 0x89, 0x84, 0xb2, 0x8d, 0xda, 0x21, - 0xdd, 0xae, 0xe7, 0x78, 0xc8, 0x97, 0xef, 0x1d, 0xf1, 0x79, 0xcb, 0x73, 0xb3, 0xe7, 0xf8, 0x1f, - 0xe1, 0x07, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x46, 0x36, 0x21, 0x63, 0xf9, 0x0a, 0x00, 0x00, + // 1037 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00,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, 0x05, 0x5b, 0x23, 0x3c, 0x0c, 0xb8, + 0x1d, 0x13, 0x8f, 0x0c, 0x22, 0xee, 0xd3, 0xd0, 0x56, 0x95, 0x2e, 0x88, 0x4a, 0x61, 0x9a, 0x18, + 0x1d, 0x09, 0xf1, 0x0a, 0x43, 0x88, 0x36, 0x85, 0x06, 0x15, 0x0a, 0x45, 0x8a, 0x05, 0x56, 0x58, + 0x88, 0x23, 0x76, 0x49, 0xb9, 0x94, 0xb4, 0x17, 0x05, 0xe4, 0x76, 0xb9, 0x17, 0xb9, 0xbe, 0x80, + 0xba, 0xe3, 0x01, 0x7f, 0x00, 0xad, 0xaf, 0xfc, 0x20, 0x38, 0x7f, 0xe6, 0x73, 0xf7, 0x52, 0xdd, + 0x1b, 0x8f, 0x80, 0xa4, 0x51, 0x71, 0xdd, 0x4a, 0x13, 0x63, 0x59, 0x8d, 0x7b, 0x26, 0x2e, 0x58, + 0xfe, 0x0c, 0xac, 0x38, 0x31, 0xc1, 0x57, 0x24, 0xb6, 0x49, 0x88, 0x9d, 0x40, 0x4e, 0x68, 0xdd, + 0x7a, 0x98, 0x26, 0xc6, 0xa6, 0x1a, 0xc1, 0x29, 0x3d, 0x44, 0x4d, 0x25, 0x38, 0x96, 0xe7, 0xbf, + 0x35, 0xb0, 0xfe, 0x0d, 0x23, 0x31, 0x53, 0x1b, 0x72, 0x8a, 0xa3, 0xc8, 0x0f, 0xfb, 0x55, 0xc7, + 0x6d, 0x1f, 0x34, 0x3c, 0x09, 0x50, 0xcc, 0xdb, 0x46, 0x9a, 0x18, 0x2d, 0x69, 0x58, 0xa8, 0x20, + 0x2a, 0xcd, 0xf4, 0x6b, 0x50, 0x57, 0x07, 0x39, 0x73, 0xff, 0xbb, 0x58, 0xd6, 0x34, 0xd7, 0xb9, + 0x63, 0xa5, 0xcd, 0x2a, 0xc2, 0xc1, 0x5f, 0x66, 0x41, 0xeb, 0x08, 0x73, 0x7c, 0xd0, 0xe3, 0x24, + 0x56, 0x17,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cc, 0x5c, 0x91, 0xf0, 0x49, 0x26, 0xd0, 0x3f, + 0x06, 0x4d, 0x9f, 0xd9, 0xe5, 0xb0, 0xa8, 0x2b, 0xae, 0x9d, 0x26, 0xc6, 0x86, 0x5a, 0xda, 0x49, + 0x35, 0x44, 0xcb, 0x3e, 0x3b, 0x2c, 0x8f, 0x0e, 0x58, 0xbd, 0xf3, 0xfa, 0x4e, 0x11, 0xa6, 0x55, + 0x23, 0x6c, 0x03, 0xcc, 0x8b, 0x67, 0x59, 0x12, 0x8d, 0xe4, 0xc1, 0xfa, 0xe2, 0xc5, 0xb8, 0xa3, + 0xbd, 0x1c, 0x77, 0xb4, 0x3f, 0xc7, 0x1d, 0xed, 0xe6, 0xb6, 0x33, 0xf3, 0xf2, 0xb6, 0x33, 0xf3, + 0xdb, 0x6d, 0x67, 0xe6, 0xe9, 0xde, 0x54, 0x3f, 0xb2, 0xff, 0x05, 0x7b, 0xb4, 0xd7, 0xf3, 0x5d, + 0x1f, 0x07, 0xea, 0xdc, 0x95, 0x7f, 0xf4, 0x44, 0x6b, 0x9c, 0x05, 0xf1, 0x24, 0x7c, 0xf0, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xad, 0xe8, 0xbb, 0xf6, 0x03, 0x0a, 0x00, 0x00, } func (m *ESMTriggerParams) Marshal() (dAtA []byte, err error) { @@ -731,16 +719,6 @@ func (m *ESMStatus) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0 } i-- - dAtA[i] = 0x40 - } - if m.StableVaultRedemptionStatus { - i-- - if m.StableVaultRedemptionStatus { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- dAtA[i] = 0x38 } if m.VaultRedemptionStatus { @@ -906,7 +884,7 @@ func (m *DataAfterCoolOff) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEsm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x1a { size := m.CollateralTotalAmount.Size() i -= size @@ -916,35 +894,7 @@ func (m *DataAfterCoolOff) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEsm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 - if len(m.DebtAsset) > 0 { - for iNdEx := len(m.DebtAsset) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.DebtAsset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEsm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.CollateralAsset) > 0 { - for iNdEx := len(m.CollateralAsset) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CollateralAsset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEsm(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } + dAtA[i] = 0x12 if m.AppId != 0 { i = encodeVarintEsm(dAtA, i, uint64(m.AppId)) i-- @@ -973,6 +923,16 @@ func (m *AssetToAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.IsCollateral { + i-- + if m.IsCollateral { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } { size := m.DebtTokenWorth.Size() i -= size @@ -982,7 +942,7 @@ func (m *AssetToAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEsm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a { size := m.Share.Size() i -= size @@ -992,7 +952,7 @@ func (m *AssetToAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEsm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 { size := m.Amount.Size() i -= size @@ -1002,10 +962,15 @@ func (m *AssetToAmount) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintEsm(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a if m.AssetID != 0 { i = encodeVarintEsm(dAtA, i, uint64(m.AssetID)) i-- + dAtA[i] = 0x10 + } + if m.AppId != 0 { + i = encodeVarintEsm(dAtA, i, uint64(m.AppId)) + i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil @@ -1115,9 +1080,6 @@ func (m *ESMStatus) Size() (n int) { if m.VaultRedemptionStatus { n += 2 } - if m.StableVaultRedemptionStatus { - n += 2 - } if m.SnapshotStatus { n += 2 } @@ -1166,18 +1128,6 @@ func (m *DataAfterCoolOff) Size() (n int) { if m.AppId != 0 { n += 1 + sovEsm(uint64(m.AppId)) } - if len(m.CollateralAsset) > 0 { - for _, e := range m.CollateralAsset { - l = e.Size() - n += 1 + l + sovEsm(uint64(l)) - } - } - if len(m.DebtAsset) > 0 { - for _, e := range m.DebtAsset { - l = e.Size() - n += 1 + l + sovEsm(uint64(l)) - } - } l = m.CollateralTotalAmount.Size() n += 1 + l + sovEsm(uint64(l)) l = m.DebtTotalAmount.Size() @@ -1191,6 +1141,9 @@ func (m *AssetToAmount) Size() (n int) { } var l int _ = l + if m.AppId != 0 { + n += 1 + sovEsm(uint64(m.AppId)) + } if m.AssetID != 0 { n += 1 + sovEsm(uint64(m.AssetID)) } @@ -1200,6 +1153,9 @@ func (m *AssetToAmount) Size() (n int) { n += 1 + l + sovEsm(uint64(l)) l = m.DebtTokenWorth.Size() n += 1 + l + sovEsm(uint64(l)) + if m.IsCollateral { + n += 2 + } return n } @@ -1668,26 +1624,6 @@ func (m *ESMStatus) Unmarshal(dAtA []byte) error { } m.VaultRedemptionStatus = bool(v != 0) case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StableVaultRedemptionStatus", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEsm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.StableVaultRedemptionStatus = bool(v != 0) - case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SnapshotStatus", wireType) } @@ -2000,74 +1936,6 @@ func (m *DataAfterCoolOff) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CollateralAsset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEsm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEsm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEsm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CollateralAsset = append(m.CollateralAsset, AssetToAmount{}) - if err := m.CollateralAsset[len(m.CollateralAsset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DebtAsset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEsm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEsm - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEsm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DebtAsset = append(m.DebtAsset, AssetToAmount{}) - if err := m.DebtAsset[len(m.DebtAsset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CollateralTotalAmount", wireType) } @@ -2101,7 +1969,7 @@ func (m *DataAfterCoolOff) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DebtTotalAmount", wireType) } @@ -2186,6 +2054,25 @@ func (m *AssetToAmount) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AppId", wireType) + } + m.AppId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } @@ -2204,7 +2091,7 @@ func (m *AssetToAmount) Unmarshal(dAtA []byte) error { break } } - case 2: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } @@ -2238,7 +2125,7 @@ func (m *AssetToAmount) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Share", wireType) } @@ -2272,7 +2159,7 @@ func (m *AssetToAmount) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field DebtTokenWorth", wireType) } @@ -2306,6 +2193,26 @@ func (m *AssetToAmount) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsCollateral", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEsm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsCollateral = bool(v != 0) default: iNdEx = preIndex skippy, err := skipEsm(dAtA[iNdEx:]) diff --git a/x/esm/types/keys.go b/x/esm/types/keys.go index 0df3e6530..c346eb4a7 100644 --- a/x/esm/types/keys.go +++ b/x/esm/types/keys.go @@ -27,6 +27,7 @@ var ( UserDepositByAppPrefix = []byte{0x05} ESMDataAfterCoolOffPrefix = []byte{0x07} SnapshotKeyPrefix = []byte{0x10} + AssetToAmountKeyPrefix = []byte{0x11} ) func ESMTriggerParamsKey(id uint64) []byte { @@ -56,3 +57,11 @@ func UserDepositByAppKey(owner string, id uint64) []byte { func SnapshotTypeKey(appID uint64, assetID uint64) []byte { return append(append(SnapshotKeyPrefix, sdk.Uint64ToBigEndian(appID)...), sdk.Uint64ToBigEndian(assetID)...) } + +func AssetToAmountKey(appID uint64, assetID uint64) []byte { + return append(append(AssetToAmountKeyPrefix, sdk.Uint64ToBigEndian(appID)...), sdk.Uint64ToBigEndian(assetID)...) +} + +func AppAssetToAmountKey(appID uint64) []byte { + return append(AssetToAmountKeyPrefix, sdk.Uint64ToBigEndian(appID)...) +} diff --git a/x/esm/types/query.pb.go b/x/esm/types/query.pb.go index 47975e924..348029b8b 100644 --- a/x/esm/types/query.pb.go +++ b/x/esm/types/query.pb.go @@ -654,6 +654,94 @@ func (m *QuerySnapshotPriceResponse) GetPrice() uint64 { return 0 } +type QueryAssetDataAfterCoolOffRequest struct { + AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` +} + +func (m *QueryAssetDataAfterCoolOffRequest) Reset() { *m = QueryAssetDataAfterCoolOffRequest{} } +func (m *QueryAssetDataAfterCoolOffRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAssetDataAfterCoolOffRequest) ProtoMessage() {} +func (*QueryAssetDataAfterCoolOffRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_ce2498af68083759, []int{14} +} +func (m *QueryAssetDataAfterCoolOffRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAssetDataAfterCoolOffRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAssetDataAfterCoolOffRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAssetDataAfterCoolOffRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetDataAfterCoolOffRequest.Merge(m, src) +} +func (m *QueryAssetDataAfterCoolOffRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAssetDataAfterCoolOffRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetDataAfterCoolOffRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAssetDataAfterCoolOffRequest proto.InternalMessageInfo + +func (m *QueryAssetDataAfterCoolOffRequest) GetAppId() uint64 { + if m != nil { + return m.AppId + } + return 0 +} + +type QueryAssetDataAfterCoolOffResponse struct { + AssetToAmount []AssetToAmount `protobuf:"bytes,1,rep,name=assetToAmount,proto3" json:"assetToAmount" yaml:"asset_to_amount"` +} + +func (m *QueryAssetDataAfterCoolOffResponse) Reset() { *m = QueryAssetDataAfterCoolOffResponse{} } +func (m *QueryAssetDataAfterCoolOffResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAssetDataAfterCoolOffResponse) ProtoMessage() {} +func (*QueryAssetDataAfterCoolOffResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_ce2498af68083759, []int{15} +} +func (m *QueryAssetDataAfterCoolOffResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAssetDataAfterCoolOffResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAssetDataAfterCoolOffResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAssetDataAfterCoolOffResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetDataAfterCoolOffResponse.Merge(m, src) +} +func (m *QueryAssetDataAfterCoolOffResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAssetDataAfterCoolOffResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetDataAfterCoolOffResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAssetDataAfterCoolOffResponse proto.InternalMessageInfo + +func (m *QueryAssetDataAfterCoolOffResponse) GetAssetToAmount() []AssetToAmount { + if m != nil { + return m.AssetToAmount + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "comdex.esm.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "comdex.esm.v1beta1.QueryParamsResponse") @@ -669,70 +757,77 @@ func init() { proto.RegisterType((*QueryDataAfterCoolOffResponse)(nil), "comdex.esm.v1beta1.QueryDataAfterCoolOffResponse") proto.RegisterType((*QuerySnapshotPriceRequest)(nil), "comdex.esm.v1beta1.QuerySnapshotPriceRequest") proto.RegisterType((*QuerySnapshotPriceResponse)(nil), "comdex.esm.v1beta1.QuerySnapshotPriceResponse") + proto.RegisterType((*QueryAssetDataAfterCoolOffRequest)(nil), "comdex.esm.v1beta1.QueryAssetDataAfterCoolOffRequest") + proto.RegisterType((*QueryAssetDataAfterCoolOffResponse)(nil), "comdex.esm.v1beta1.QueryAssetDataAfterCoolOffResponse") } func init() { proto.RegisterFile("comdex/esm/v1beta1/query.proto", fileDescriptor_ce2498af68083759) } var fileDescriptor_ce2498af68083759 = []byte{ - // 913 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0xc1, 0x6e, 0x1b, 0x45, - 0x18, 0xc7, 0xb3, 0x56, 0x13, 0xc8, 0x20, 0x55, 0x61, 0x92, 0xa2, 0x64, 0x71, 0xed, 0x30, 0x2d, - 0xa4, 0xb4, 0x64, 0xb7, 0x49, 0xaa, 0xaa, 0x80, 0x84, 0x54, 0xb7, 0x08, 0xf5, 0x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 0xf1, 0x38, 0x4d, 0x47, 0xf8, 0xd7, 0xea, 0xad, 0x9e, 0x4d, 0x8c, 0x9a, 0xb7, 0xda, 0x91, 0x6a, - 0x35, 0x6f, 0xb5, 0x2b, 0xd6, 0xc8, 0x2d, 0xbd, 0x41, 0x80, 0xdf, 0xb3, 0x6d, 0x60, 0x09, 0x29, - 0x73, 0xfe, 0xbf, 0x79, 0xf0, 0x6b, 0x68, 0x2a, 0x48, 0xf0, 0xb6, 0xd3, 0xdf, 0x96, 0x5f, 0x7e, - 0xf0, 0xa2, 0xed, 0xc0, 0xfa, 0x91, 0x66, 0xbd, 0x83, 0x6f, 0xdb, 0x58, 0x75, 0x58, 0x75, 0x25, - 0x0c, 0x86, 0xc7, 0x26, 0x19, 0x47, 0xe1, 0x71, 0x95, 0x85, 0xa3, 0xce, 0x27, 0x27, 0x67, 0x2d, - 0xef, 0xd9, 0x59, 0xcb, 0xfb, 0xfb, 0xac, 0xe5, 0x7d, 0x7f, 0xde, 0x5a, 0x78, 0x76, 0xde, 0x5a, - 0xf8, 0xeb, 0xbc, 0xb5, 0xf0, 0xe5, 0x76, 0x92, 0xaa, 0xc7, 0xc3, 0xc3, 0x92, 0x07, 0xb4, 0xb7, - 0x79, 0xbf, 0x9f, 0xf6, 0x52, 0x3a, 0xa8, 0xbc, 0x8c, 0x9b, 0x3a, 0x12, 0x4c, 0x1e, 0x2e, 0xe9, - 0x9f, 0x84, 0x7b, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x5e, 0xaa, 0xad, 0xe7, 0x0a, 0x00, - 0x00, + // 1002 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0x4f, 0x6f, 0x1b, 0x45, + 0x18, 0xc6, 0xb3, 0xa6, 0x09, 0x64, 0x22, 0xaa, 0x30, 0x49, 0xab, 0x64, 0x71, 0xed, 0x64, 0x5a, + 0x48, 0x68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0x1e, 0x57, + 0x9c, 0x9f, 0x4e, 0x2a, 0x53, 0x2f, 0x4f, 0x2a, 0x53, 0xff, 0x9c, 0x54, 0xa6, 0xbe, 0xde, 0x08, + 0x42, 0xf9, 0xb4, 0xbf, 0x97, 0x71, 0x41, 0xef, 0x0d, 0xde, 0xed, 0x86, 0xed, 0x90, 0xf6, 0x72, + 0x2d, 0xad, 0x26, 0xf7, 0x13, 0x26, 0xf6, 0x66, 0xd4, 0xc7, 0xfa, 0xd6, 0xff, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x95, 0x8b, 0x33, 0x2a, 0x81, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -754,6 +849,7 @@ type QueryClient interface { QueryUsersDepositMapping(ctx context.Context, in *QueryUsersDepositMappingRequest, opts ...grpc.CallOption) (*QueryUsersDepositMappingResponse, error) QueryDataAfterCoolOff(ctx context.Context, in *QueryDataAfterCoolOffRequest, opts ...grpc.CallOption) (*QueryDataAfterCoolOffResponse, error) QuerySnapshotPrice(ctx context.Context, in *QuerySnapshotPriceRequest, opts ...grpc.CallOption) (*QuerySnapshotPriceResponse, error) + QueryAssetDataAfterCoolOff(ctx context.Context, in *QueryAssetDataAfterCoolOffRequest, opts ...grpc.CallOption) (*QueryAssetDataAfterCoolOffResponse, error) } type queryClient struct { @@ -827,6 +923,15 @@ func (c *queryClient) QuerySnapshotPrice(ctx context.Context, in *QuerySnapshotP return out, nil } +func (c *queryClient) QueryAssetDataAfterCoolOff(ctx context.Context, in *QueryAssetDataAfterCoolOffRequest, opts ...grpc.CallOption) (*QueryAssetDataAfterCoolOffResponse, error) { + out := new(QueryAssetDataAfterCoolOffResponse) + err := c.cc.Invoke(ctx, "/comdex.esm.v1beta1.Query/QueryAssetDataAfterCoolOff", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) @@ -836,6 +941,7 @@ type QueryServer interface { QueryUsersDepositMapping(context.Context, *QueryUsersDepositMappingRequest) (*QueryUsersDepositMappingResponse, error) QueryDataAfterCoolOff(context.Context, *QueryDataAfterCoolOffRequest) (*QueryDataAfterCoolOffResponse, error) QuerySnapshotPrice(context.Context, *QuerySnapshotPriceRequest) (*QuerySnapshotPriceResponse, error) + QueryAssetDataAfterCoolOff(context.Context, *QueryAssetDataAfterCoolOffRequest) (*QueryAssetDataAfterCoolOffResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -863,6 +969,9 @@ func (*UnimplementedQueryServer) QueryDataAfterCoolOff(ctx context.Context, req func (*UnimplementedQueryServer) QuerySnapshotPrice(ctx context.Context, req *QuerySnapshotPriceRequest) (*QuerySnapshotPriceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QuerySnapshotPrice not implemented") } +func (*UnimplementedQueryServer) QueryAssetDataAfterCoolOff(ctx context.Context, req *QueryAssetDataAfterCoolOffRequest) (*QueryAssetDataAfterCoolOffResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAssetDataAfterCoolOff not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -994,6 +1103,24 @@ func _Query_QuerySnapshotPrice_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_QueryAssetDataAfterCoolOff_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAssetDataAfterCoolOffRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryAssetDataAfterCoolOff(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.esm.v1beta1.Query/QueryAssetDataAfterCoolOff", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryAssetDataAfterCoolOff(ctx, req.(*QueryAssetDataAfterCoolOffRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "comdex.esm.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -1026,6 +1153,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QuerySnapshotPrice", Handler: _Query_QuerySnapshotPrice_Handler, }, + { + MethodName: "QueryAssetDataAfterCoolOff", + Handler: _Query_QueryAssetDataAfterCoolOff_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "comdex/esm/v1beta1/query.proto", @@ -1460,6 +1591,71 @@ func (m *QuerySnapshotPriceResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *QueryAssetDataAfterCoolOffRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAssetDataAfterCoolOffRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAssetDataAfterCoolOffRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AppId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AppId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryAssetDataAfterCoolOffResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAssetDataAfterCoolOffResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAssetDataAfterCoolOffResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetToAmount) > 0 { + for iNdEx := len(m.AssetToAmount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetToAmount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1637,6 +1833,33 @@ func (m *QuerySnapshotPriceResponse) Size() (n int) { return n } +func (m *QueryAssetDataAfterCoolOffRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AppId != 0 { + n += 1 + sovQuery(uint64(m.AppId)) + } + return n +} + +func (m *QueryAssetDataAfterCoolOffResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AssetToAmount) > 0 { + for _, e := range m.AssetToAmount { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2725,6 +2948,159 @@ func (m *QuerySnapshotPriceResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryAssetDataAfterCoolOffRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAssetDataAfterCoolOffRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAssetDataAfterCoolOffRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AppId", wireType) + } + m.AppId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAssetDataAfterCoolOffResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAssetDataAfterCoolOffResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAssetDataAfterCoolOffResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetToAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetToAmount = append(m.AssetToAmount, AssetToAmount{}) + if err := m.AssetToAmount[len(m.AssetToAmount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/esm/types/query.pb.gw.go b/x/esm/types/query.pb.gw.go index db7cc2dc8..75f5e2dec 100644 --- a/x/esm/types/query.pb.gw.go +++ b/x/esm/types/query.pb.gw.go @@ -419,6 +419,60 @@ func local_request_Query_QuerySnapshotPrice_0(ctx context.Context, marshaler run } +func request_Query_QueryAssetDataAfterCoolOff_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetDataAfterCoolOffRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["app_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "app_id") + } + + protoReq.AppId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "app_id", err) + } + + msg, err := client.QueryAssetDataAfterCoolOff(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryAssetDataAfterCoolOff_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetDataAfterCoolOffRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["app_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "app_id") + } + + protoReq.AppId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "app_id", err) + } + + msg, err := server.QueryAssetDataAfterCoolOff(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -586,6 +640,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryAssetDataAfterCoolOff_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryAssetDataAfterCoolOff_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAssetDataAfterCoolOff_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -767,6 +844,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryAssetDataAfterCoolOff_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryAssetDataAfterCoolOff_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryAssetDataAfterCoolOff_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -784,6 +881,8 @@ var ( pattern_Query_QueryDataAfterCoolOff_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"comdex", "esm", "v1beta1", "data_after_cool_off", "id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QuerySnapshotPrice_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"comdex", "esm", "v1beta1", "price_snapshot", "app_id", "asset_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryAssetDataAfterCoolOff_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"comdex", "esm", "v1beta1", "asset_data_after_cool_off", "app_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -800,4 +899,6 @@ var ( forward_Query_QueryDataAfterCoolOff_0 = runtime.ForwardResponseMessage forward_Query_QuerySnapshotPrice_0 = runtime.ForwardResponseMessage + + forward_Query_QueryAssetDataAfterCoolOff_0 = runtime.ForwardResponseMessage ) diff --git a/x/lend/abci.go b/x/lend/abci.go deleted file mode 100644 index d3a4a05fd..000000000 --- a/x/lend/abci.go +++ /dev/null @@ -1,23 +0,0 @@ -package lend - -import ( - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - abci "github.com/tendermint/tendermint/abci/types" - - utils "github.com/comdex-official/comdex/types" - "github.com/comdex-official/comdex/x/lend/keeper" - "github.com/comdex-official/comdex/x/lend/types" -) - -func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { - defer telemetry.ModuleMeasureSince(types.ModuleName, ctx.BlockTime(), telemetry.MetricKeyBeginBlocker) - - _ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error { - err := k.ReBalanceStableRates(ctx) - if err != nil { - ctx.Logger().Error("error in ReBalance Stable Rates") - } - return nil - }) -} diff --git a/x/lend/client/cli/query.go b/x/lend/client/cli/query.go index 269774a6e..ff846e16c 100644 --- a/x/lend/client/cli/query.go +++ b/x/lend/client/cli/query.go @@ -49,7 +49,8 @@ func GetQueryCmd() *cobra.Command { // queryReserveDepositStats(), queryReserveBuybackAssetData(), // queryBorrowStats(), - queryAuctionParams(), // + queryAuctionParams(), + QueryModuleBalance(), // ) return cmd @@ -647,7 +648,7 @@ func QueryAssetRatesParams() *cobra.Command { func QueryPoolAssetLBMapping() *cobra.Command { cmd := &cobra.Command{ - Use: "asset-stats [asset-id] [pool-id]", + Use: "asset-stats [pool-id] [asset-id]", Short: "Query asset stats for an asset-id and pool-id", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { @@ -658,12 +659,12 @@ func QueryPoolAssetLBMapping() *cobra.Command { queryClient := types.NewQueryClient(ctx) - assetID, err := strconv.ParseUint(args[0], 10, 64) + poolID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } - poolID, err := strconv.ParseUint(args[1], 10, 64) + assetID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err } @@ -715,96 +716,6 @@ func QueryPoolAssetLBMapping() *cobra.Command { // return cmd // } -// func queryDepositStats() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "deposit-stats", -// Short: "Query deposit stats", -// RunE: func(cmd *cobra.Command, args []string) error { -// ctx, err := client.GetClientQueryContext(cmd) -// if err != nil { -// return err -// } - -// queryClient := types.NewQueryClient(ctx) - -// res, err := queryClient.QueryDepositStats( -// context.Background(), -// &types.QueryDepositStatsRequest{}, -// ) -// if err != nil { -// return err -// } - -// return ctx.PrintProto(res) -// }, -// } - -// flags.AddQueryFlagsToCmd(cmd) -// flags.AddPaginationFlagsToCmd(cmd, "deposit-stats") - -// return cmd -// } - -// func queryUserDepositStats() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "user-deposit-stats", -// Short: "Query user deposit stats", -// RunE: func(cmd *cobra.Command, args []string) error { -// ctx, err := client.GetClientQueryContext(cmd) -// if err != nil { -// return err -// } - -// queryClient := types.NewQueryClient(ctx) - -// res, err := queryClient.QueryUserDepositStats( -// context.Background(), -// &types.QueryUserDepositStatsRequest{}, -// ) -// if err != nil { -// return err -// } - -// return ctx.PrintProto(res) -// }, -// } - -// flags.AddQueryFlagsToCmd(cmd) -// flags.AddPaginationFlagsToCmd(cmd, "user-deposit-stats") - -// return cmd -// } - -// func queryReserveDepositStats() *cobra.Command { -// cmd := &cobra.Command{ -// Use: "reserve-deposit-stats", -// Short: "Query reserve deposit stats", -// RunE: func(cmd *cobra.Command, args []string) error { -// ctx, err := client.GetClientQueryContext(cmd) -// if err != nil { -// return err -// } - -// queryClient := types.NewQueryClient(ctx) - -// res, err := queryClient.QueryReserveDepositStats( -// context.Background(), -// &types.QueryReserveDepositStatsRequest{}, -// ) -// if err != nil { -// return err -// } - -// return ctx.PrintProto(res) -// }, -// } - -// flags.AddQueryFlagsToCmd(cmd) -// flags.AddPaginationFlagsToCmd(cmd, "reserve-deposit-stats") - -// return cmd -// } - func queryReserveBuybackAssetData() *cobra.Command { cmd := &cobra.Command{ Use: "buy-back-deposit-stats [id]", @@ -909,3 +820,35 @@ func queryAuctionParams() *cobra.Command { return cmd } + +func QueryModuleBalance() *cobra.Command { + cmd := &cobra.Command{ + Use: "module-balance [pool-id]", + Short: "borrows list for a owner", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + ctx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(ctx) + + poolID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return err + } + + res, err := queryClient.QueryModuleBalance(cmd.Context(), &types.QueryModuleBalanceRequest{ + PoolId: poolID, + }) + if err != nil { + return err + } + return ctx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/lend/client/cli/tx.go b/x/lend/client/cli/tx.go index b48622cbb..b28885235 100644 --- a/x/lend/client/cli/tx.go +++ b/x/lend/client/cli/tx.go @@ -49,7 +49,9 @@ func txLend() *cobra.Command { cmd := &cobra.Command{ Use: "lend [asset-id] [amount] [pool-id] [app-id]", Short: "lend a whitelisted asset", - Args: cobra.ExactArgs(4), + Long: `Users can lend their IBC-Assets in any of the specified pools according to their choice and start earning lending rewards. + A cToken representative of their IBC asset will be sent to the user's address which can be used to borrow Assets from any pool.`, + Args: cobra.ExactArgs(4), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -90,7 +92,9 @@ func txWithdraw() *cobra.Command { cmd := &cobra.Command{ Use: "withdraw [lend-id] [amount]", Short: "withdraw lent asset", - Args: cobra.ExactArgs(2), + Long: `Users can withdraw their IBC-Assets from previously opened lend position. The cTokens are sent from the user's address + and desired amount is sent back to the user's address. If a user has no borrow position open, he can withdraw all amount to close his lend position.'`, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -121,7 +125,9 @@ func txDeposit() *cobra.Command { cmd := &cobra.Command{ Use: "deposit [lend-id] [amount]", Short: "deposit into a lent position", - Args: cobra.ExactArgs(2), + Long: `Users can deposit more IBC-Assets into their previously opened lend position. The cTokens are then minted + from the cPool's module and sent to the user's address and deposited amount is sent to the pool's module account'`, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -151,8 +157,10 @@ func txDeposit() *cobra.Command { func txCloseLend() *cobra.Command { cmd := &cobra.Command{ Use: "close-lend [lend-id]", - Short: "close a lent position", - Args: cobra.ExactArgs(1), + Short: "close a previously opened lend position", + Long: `Users can close their lend position by this transaction. The cTokens will be transferred to the module + account and user's IBC assets will be sent to his address.'`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -178,7 +186,9 @@ func txBorrowAsset() *cobra.Command { cmd := &cobra.Command{ Use: "borrow [lend-id] [pair-id] [is-stable-borrow] [amount-in] [amount-out]", Short: "borrow a whitelisted asset", - Args: cobra.ExactArgs(5), + Long: `This transaction only works after creating a lend position by depositing assets in any of the pool. + After creating a lend position a user can use the cTokens to create a new borrow position.`, + Args: cobra.ExactArgs(5), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -225,7 +235,9 @@ func txRepayAsset() *cobra.Command { cmd := &cobra.Command{ Use: "repay [borrow-id] [amount]", Short: "repay borrowed asset", - Args: cobra.ExactArgs(2), + Long: `For an open borrow position a user can repay the borrowed amount back to protcol. While repaying the + interest is paid first then the principal borrowed amount. A user can repay all the amount to close it's borrow position.'`, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -256,7 +268,9 @@ func txDrawAsset() *cobra.Command { cmd := &cobra.Command{ Use: "draw [borrow-id] [amount]", Short: "draw borrowed asset", - Args: cobra.ExactArgs(2), + Long: `If a user has to draw more assets from his borrow position, this transaction can be used. A user can draw + max amount below the loan to value amount specified by the protocol for the borrowed asset`, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -287,7 +301,9 @@ func txDepositBorrowAsset() *cobra.Command { cmd := &cobra.Command{ Use: "deposit-borrow [borrow-id] [amount]", Short: "deposit borrowed asset", - Args: cobra.ExactArgs(2), + Long: `If a user has to deposit more assets from to borrow position, this transaction can be used. A user can deposit + cTokens to his borrow position to keep his position safe from being liquidated`, + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -318,7 +334,9 @@ func txCloseBorrowAsset() *cobra.Command { cmd := &cobra.Command{ Use: "close-borrow [borrow-id] ", Short: " close borrow position", - Args: cobra.ExactArgs(1), + Long: `If a user has to close his borrow position then this transaction is used. All the repayment amount is + taken from the user and the previously locked cTokens are returned back to the user's address.'`, + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -344,7 +362,9 @@ func txBorrowAssetAlternate() *cobra.Command { cmd := &cobra.Command{ Use: "borrow-alternate [asset-id] [pool-id] [amount-in] [pair-id] [is-stable-borrow] [amount-out] [app-id]", Short: "directly borrow from a whitelisted asset", - Args: cobra.ExactArgs(7), + Long: `If a user has to borrow directly by depositing asset in a single go, then this transaction is used. + The cTokens for the lend position will be directly used to create a borrow position against it.`, + Args: cobra.ExactArgs(7), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { @@ -400,32 +420,33 @@ func txBorrowAssetAlternate() *cobra.Command { func txFundModuleAccounts() *cobra.Command { cmd := &cobra.Command{ - Use: "fund-module [module-name] [asset_id] [amount]", + Use: "fund-module [pool_id] [asset_id] [amount]", Short: "Deposit amount to the respective module account", - Args: cobra.ExactArgs(3), + Long: `This is a liquidity bootstrapping function only for the protocol admins. + No user should run this transaction as it will lead to loss of funds.`, + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) if err != nil { return err } - moduleName := args[0] - - assetID, err := strconv.ParseUint(args[1], 10, 64) + poolID, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } - amount, err := sdk.ParseCoinNormalized(args[2]) + assetID, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err } - msg := types.NewMsgFundModuleAccounts(moduleName, assetID, ctx.GetFromAddress().String(), amount) - err = msg.ValidateBasic() + amount, err := sdk.ParseCoinNormalized(args[2]) if err != nil { return err } + + msg := types.NewMsgFundModuleAccounts(poolID, assetID, ctx.GetFromAddress().String(), amount) return tx.GenerateOrBroadcastTxCLI(ctx, cmd.Flags(), msg) }, } @@ -513,9 +534,6 @@ func NewCreateNewLendPairs(clientCtx client.Context, txf tx.Factory, fs *flag.Fl return txf, nil, err } - if err = msg.ValidateBasic(); err != nil { - return txf, nil, err - } return txf, msg, nil } @@ -545,90 +563,6 @@ func CmdAddPoolProposal() *cobra.Command { return cmd } -func CmdUpdateLendPairProposal() *cobra.Command { - cmd := &cobra.Command{ - Use: "update-lend-pair [id] [asset-in] [asset-out] [min-usd-value-left]", - Short: "Update a lend pair", - Args: cobra.ExactArgs(4), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - id, err := strconv.ParseUint(args[0], 10, 64) - if err != nil { - return err - } - - assetIn, err := strconv.ParseUint(args[1], 10, 64) - if err != nil { - return err - } - - assetOut, err := strconv.ParseUint(args[2], 10, 64) - if err != nil { - return err - } - - minUsdValueLeft, err := strconv.ParseUint(args[3], 10, 64) - if err != nil { - return err - } - - pair := types.Extended_Pair{ - Id: id, - AssetIn: assetIn, - AssetOut: assetOut, - MinUsdValueLeft: minUsdValueLeft, - } - - title, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return err - } - - description, err := cmd.Flags().GetString(cli.FlagDescription) - if err != nil { - return err - } - - from := clientCtx.GetFromAddress() - - depositStr, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return err - } - deposit, err := sdk.ParseCoinsNormalized(depositStr) - if err != nil { - return err - } - - content := types.NewUpdateLendPairsProposal(title, description, pair) - - msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) - if err != nil { - return err - } - - if err = msg.ValidateBasic(); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") - cmd.Flags().String(cli.FlagDescription, "", "description of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - - _ = cmd.MarkFlagRequired(cli.FlagTitle) - _ = cmd.MarkFlagRequired(cli.FlagDescription) - - return cmd -} - func NewCreateLendPool(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { newLendPool, err := parseAddPoolFlags(fs) if err != nil { @@ -689,10 +623,6 @@ func NewCreateLendPool(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSe return txf, nil, err } - if err = msg.ValidateBasic(); err != nil { - return txf, nil, err - } - return txf, msg, nil } @@ -757,10 +687,6 @@ func CmdAddAssetToPairProposal() *cobra.Command { return err } - if err = msg.ValidateBasic(); err != nil { - return err - } - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } @@ -890,10 +816,6 @@ func NewCreateassetRatesParams(clientCtx client.Context, txf tx.Factory, fs *fla return txf, nil, err } - if err = msg.ValidateBasic(); err != nil { - return txf, nil, err - } - return txf, msg, nil } @@ -982,10 +904,6 @@ func NewAddAuctionParams(clientCtx client.Context, txf tx.Factory, fs *flag.Flag return txf, nil, err } - if err = msg.ValidateBasic(); err != nil { - return txf, nil, err - } - return txf, msg, nil } @@ -993,6 +911,7 @@ func txCalculateInterestAndRewards() *cobra.Command { cmd := &cobra.Command{ Use: "calculate-interest-rewards", Short: " calculate interest and rewards for a user", + Long: `This function is used to calculate Rewards for lend as well as interest for all borrow positions for a user.`, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { ctx, err := client.GetClientTxContext(cmd) diff --git a/x/lend/client/proposal_handler.go b/x/lend/client/proposal_handler.go index 6337d2475..c46c04ee9 100644 --- a/x/lend/client/proposal_handler.go +++ b/x/lend/client/proposal_handler.go @@ -9,7 +9,6 @@ import ( var ( AddLendPairsHandler = govclient.NewProposalHandler(cli.CmdAddNewLendPairsProposal, rest.AddNewPairsProposalRESTHandler) - UpdateLendPairsHandler = govclient.NewProposalHandler(cli.CmdUpdateLendPairProposal, rest.UpdatePairProposalRESTHandler) AddPoolHandler = govclient.NewProposalHandler(cli.CmdAddPoolProposal, rest.AddPoolProposalRESTHandler) AddAssetToPairHandler = govclient.NewProposalHandler(cli.CmdAddAssetToPairProposal, rest.AddAssetToPairProposalRESTHandler) AddAssetRatesParamsHandler = govclient.NewProposalHandler(cli.CmdAddNewAssetRatesParamsProposal, rest.AddNewAssetRatesParamsProposalRESTHandler) diff --git a/x/lend/expected/keeper.go b/x/lend/expected/keeper.go index 6661b3adb..5081a4ced 100644 --- a/x/lend/expected/keeper.go +++ b/x/lend/expected/keeper.go @@ -1,6 +1,7 @@ package expected import ( + "github.com/comdex-official/comdex/x/liquidation/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -40,8 +41,28 @@ type BandOracleKeeper interface { type AssetKeeper interface { GetAsset(ctx sdk.Context, id uint64) (assettypes.Asset, bool) GetApp(ctx sdk.Context, id uint64) (assettypes.AppData, bool) + SetApp(ctx sdk.Context, app assettypes.AppData) + SetAppID(ctx sdk.Context, id uint64) } type EsmKeeper interface { GetKillSwitchData(ctx sdk.Context, appID uint64) (esmtypes.KillSwitchParams, bool) } + +type LiquidationKeeper interface { + GetLockedVaultByApp(ctx sdk.Context, appID uint64) (lockedVault []types.LockedVault) +} + +type AuctionKeeper interface { + LendDutchActivator(ctx sdk.Context, lockedVault types.LockedVault) error + StartLendDutchAuction( + ctx sdk.Context, + outFlowToken sdk.Coin, + inFlowToken sdk.Coin, + appID uint64, + assetInID, assetOutID uint64, + lockedVaultID uint64, + lockedVaultOwner string, + liquidationPenalty sdk.Dec, + ) error +} diff --git a/x/lend/genesis.go b/x/lend/genesis.go index 5f9fa12ed..6528aac2d 100644 --- a/x/lend/genesis.go +++ b/x/lend/genesis.go @@ -8,104 +8,85 @@ import ( ) func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { - // k.SetParams(ctx, state.Params) - - // for _, item := range state.BorrowAsset { - // k.SetBorrow(ctx, item) - // } - - // for _, item := range state.UserBorrowIdMapping { - // k.SetUserBorrows(ctx, item) - // } - - // for _, item := range state.BorrowIdByOwnerAndPoolMapping { - // k.SetBorrowIDByOwnerAndPool(ctx, item) - // } - - // k.SetBorrows(ctx, state.BorrowMapping) - - // for _, item := range state.LendAsset { - // k.SetLend(ctx, item) - // } - - // for _, item := range state.Pool { - // k.SetPool(ctx, item) - // } - - // for _, item := range state.AssetToPairMapping { - // k.SetAssetToPair(ctx, item) - // } - - // for _, item := range state.UserLendIdMapping { - // k.SetUserLends(ctx, item) - // } - - // for _, item := range state.LendIdByOwnerAndPoolMapping { - // k.SetLendIDByOwnerAndPool(ctx, item) - // } - - // for _, item := range state.LendIdToBorrowIdMapping { - // k.SetLendIDToBorrowIDMapping(ctx, item) - // } - - // for _, item := range state.AssetStats { - // k.SetAssetStatsByPoolIDAndAssetID(ctx, item) - // } - - // k.SetLends(ctx, state.LendMapping) - - // k.SetUserDepositStats(ctx, state.UserDepositStats) - - // k.SetReserveDepositStats(ctx, state.ReserveDepositStats) - - // k.SetBuyBackDepositStats(ctx, state.BuyBackDepositStats) - - // k.SetBorrowStats(ctx, state.BorrowDepositStats) - - // for _, item := range state.Extended_Pair { - // k.SetLendPair(ctx, item) - // } - - // for _, item := range state.AssetRatesStats { - // k.SetAssetRatesStats(ctx, item) - // } - - // for _, item := range state.AuctionParams { - // err := k.AddAuctionParamsData(ctx, item) - // if err != nil { - // return - // } - // } + var ( + borrowID uint64 + lendID uint64 + poolID uint64 + extendedPairID uint64 + ) + + for _, item := range state.BorrowAsset { + k.SetBorrow(ctx, item) + borrowID = item.ID + } + + for _, item := range state.BorrowInterestTracker { + k.SetBorrowInterestTracker(ctx, item) + } + + for _, item := range state.LendAsset { + k.SetLend(ctx, item) + lendID = item.ID + } + + for _, item := range state.Pool { + k.SetPool(ctx, item) + poolID = item.PoolID + } + + for _, item := range state.AssetToPairMapping { + k.SetAssetToPair(ctx, item) + } + + for _, item := range state.PoolAssetLBMapping { + k.SetAssetStatsByPoolIDAndAssetID(ctx, item) + } + + for _, item := range state.LendRewardsTracker { + k.SetLendRewardTracker(ctx, item) + } + + for _, item := range state.UserAssetLendBorrowMapping { + k.SetUserLendBorrowMapping(ctx, item) + } + + for _, item := range state.ReserveBuybackAssetData { + k.SetReserveBuybackAssetData(ctx, item) + } + + for _, item := range state.Extended_Pair { + k.SetLendPair(ctx, item) + extendedPairID = item.Id + } + + for _, item := range state.AuctionParams { + err := k.AddAuctionParamsData(ctx, item) + if err != nil { + continue + } + } + for _, item := range state.AssetRatesParams { + k.SetAssetRatesParams(ctx, item) + } + k.SetUserBorrowIDCounter(ctx, borrowID) + k.SetUserLendIDCounter(ctx, lendID) + k.SetPoolID(ctx, poolID) + k.SetLendPairID(ctx, extendedPairID) } func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - // borrowMap, _ := k.GetBorrows(ctx) - // lends, _ := k.GetLends(ctx) - // userDeposit, _ := k.GetUserDepositStats(ctx) - // reserveDeposit, _ := k.GetReserveDepositStats(ctx) - // buyBackDeposit, _ := k.GetBuyBackDepositStats(ctx) - // borrowDeposit, _ := k.GetBorrowStats(ctx) - // return types.NewGenesisState( - // k.GetAllBorrow(ctx), - // k.GetAllUserBorrows(ctx), - // k.GetAllBorrowIDByOwnerAndPool(ctx), - // borrowMap, - // k.GetAllLend(ctx), - // k.GetPools(ctx), - // k.GetAllAssetToPair(ctx), - // k.GetAllUserLends(ctx), - // k.GetAllLendIDByOwnerAndPool(ctx), - // k.GetAllLendIDToBorrowIDMapping(ctx), - // k.GetAllAssetStatsByPoolIDAndAssetID(ctx), - // lends, - // userDeposit, - // reserveDeposit, - // buyBackDeposit, - // borrowDeposit, - // k.GetLendPairs(ctx), - // k.GetAllAssetRatesStats(ctx), - // k.GetAllAddAuctionParamsData(ctx), - // k.GetParams(ctx), - // ) - return nil + return types.NewGenesisState( + k.GetAllBorrow(ctx), + k.GetAllBorrowInterestTracker(ctx), + k.GetAllLend(ctx), + k.GetPools(ctx), + k.GetAllAssetToPair(ctx), + k.GetAllAssetStatsByPoolIDAndAssetID(ctx), + k.GetAllLendRewardTracker(ctx), + k.GetAllUserTotalMappingData(ctx), + k.GetAllReserveBuybackAssetData(ctx), + k.GetLendPairs(ctx), + k.GetAllAddAuctionParamsData(ctx), + k.GetAllAssetRatesParams(ctx), + ) } diff --git a/x/lend/handler.go b/x/lend/handler.go index fe9f0a4b8..767b1a1dc 100644 --- a/x/lend/handler.go +++ b/x/lend/handler.go @@ -81,8 +81,6 @@ func NewLendHandler(k keeper.Keeper) govtypes.Handler { switch c := content.(type) { case *types.LendPairsProposal: return handleAddWhitelistedPairsProposal(ctx, k, c) - case *types.UpdateLendPairsProposal: - return handleUpdateWhitelistedPairsProposal(ctx, k, c) case *types.AddPoolsProposal: return handleAddPoolProposal(ctx, k, c) case *types.AddAssetToPairProposal: @@ -102,10 +100,6 @@ func handleAddWhitelistedPairsProposal(ctx sdk.Context, k keeper.Keeper, p *type return k.HandleAddWhitelistedPairsRecords(ctx, p) } -func handleUpdateWhitelistedPairsProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateLendPairsProposal) error { - return k.HandleUpdateWhitelistedPairsRecords(ctx, p) -} - func handleAddPoolProposal(ctx sdk.Context, k keeper.Keeper, p *types.AddPoolsProposal) error { return k.HandleAddPoolRecords(ctx, p) } diff --git a/x/lend/keeper/alias.go b/x/lend/keeper/alias.go deleted file mode 100644 index 1c7e56b33..000000000 --- a/x/lend/keeper/alias.go +++ /dev/null @@ -1,81 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - assettypes "github.com/comdex-official/comdex/x/asset/types" - esmtypes "github.com/comdex-official/comdex/x/esm/types" - lendtypes "github.com/comdex-official/comdex/x/lend/types" - markettypes "github.com/comdex-official/comdex/x/market/types" -) - -func (k Keeper) BurnCoin(ctx sdk.Context, name string, coin sdk.Coin) error { - if coin.IsZero() { - return lendtypes.BurnCoinValueInLendIsZero - } - - return k.bank.BurnCoins(ctx, name, sdk.NewCoins(coin)) -} - -func (k Keeper) MintCoin(ctx sdk.Context, name string, coin sdk.Coin) error { - if coin.IsZero() { - return lendtypes.MintCoinValueInLendIsZero - } - - return k.bank.MintCoins(ctx, name, sdk.NewCoins(coin)) -} - -func (k Keeper) SendCoinFromAccountToModule(ctx sdk.Context, address sdk.AccAddress, name string, coin sdk.Coin) error { - if coin.IsZero() { - return lendtypes.SendCoinsFromAccountToModuleInLendIsZero - } - - return k.bank.SendCoinsFromAccountToModule(ctx, address, name, sdk.NewCoins(coin)) -} - -func (k Keeper) SendCoinFromModuleToAccount(ctx sdk.Context, name string, address sdk.AccAddress, coin sdk.Coin) error { - if coin.IsZero() { - return lendtypes.SendCoinsFromModuleToAccountInLendIsZero - } - - return k.bank.SendCoinsFromModuleToAccount(ctx, name, address, sdk.NewCoins(coin)) -} - -func (k Keeper) SpendableCoins(ctx sdk.Context, address sdk.AccAddress) sdk.Coins { - return k.bank.SpendableCoins(ctx, address) -} - -func (k Keeper) GetModuleAddress(name string) sdk.AccAddress { - return k.account.GetModuleAddress(name) -} - -func (k Keeper) GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins { - return k.bank.GetAllBalances(ctx, addr) -} - -func (k Keeper) GetAsset(ctx sdk.Context, ID uint64) (assettypes.Asset, bool) { - return k.asset.GetAsset(ctx, ID) -} - -func (k Keeper) GetTwa(ctx sdk.Context, id uint64) (twa markettypes.TimeWeightedAverage, found bool) { - return k.market.GetTwa(ctx, id) -} - -func (k Keeper) SendCoinFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, coin sdk.Coins) error { - if coin.IsZero() { - return lendtypes.SendCoinsFromModuleToModuleInLendIsZero - } - return k.bank.SendCoinsFromModuleToModule(ctx, senderModule, recipientModule, coin) -} - -func (k Keeper) GetApp(ctx sdk.Context, id uint64) (assettypes.AppData, bool) { - return k.asset.GetApp(ctx, id) -} - -func (k Keeper) GetKillSwitchData(ctx sdk.Context, appID uint64) (esmtypes.KillSwitchParams, bool) { - return k.esm.GetKillSwitchData(ctx, appID) -} - -func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Dec, err error) { - return k.market.CalcAssetPrice(ctx, id, amt) -} diff --git a/x/lend/keeper/borrow.go b/x/lend/keeper/borrow.go index c93e706dc..294ab1631 100644 --- a/x/lend/keeper/borrow.go +++ b/x/lend/keeper/borrow.go @@ -106,9 +106,27 @@ func (k Keeper) HasBorrowForAddressByPair(ctx sdk.Context, address string, pairI } func (k Keeper) GetBorrows(ctx sdk.Context) (borrowIds []uint64, found bool) { - assetStats := k.GetAllAssetStatsByPoolIDAndAssetID(ctx) - for _, data := range assetStats { - borrowIds = append(borrowIds, data.BorrowIds...) + // assetStats := k.GetAllAssetStatsByPoolIDAndAssetID(ctx) + // for _, data := range assetStats { + // borrowIds = append(borrowIds, data.BorrowIds...) + // } + // return borrowIds, true + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.AssetStatsByPoolIDAndAssetIDKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var asset types.PoolAssetLBMapping + k.cdc.MustUnmarshal(iter.Value(), &asset) + borrowIds = append(borrowIds, asset.BorrowIds...) } return borrowIds, true } @@ -138,6 +156,27 @@ func (k Keeper) GetBorrowInterestTracker(ctx sdk.Context, ID uint64) (interest t return interest, true } +func (k Keeper) GetAllBorrowInterestTracker(ctx sdk.Context) (interest []types.BorrowInterestTracker) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.BorrowInterestTrackerKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var tracker types.BorrowInterestTracker + k.cdc.MustUnmarshal(iter.Value(), &tracker) + interest = append(interest, tracker) + } + return interest +} + func (k Keeper) DeleteBorrowInterestTracker(ctx sdk.Context, ID uint64) { var ( store = k.Store(ctx) diff --git a/x/lend/keeper/gov.go b/x/lend/keeper/gov.go index 1ba6443cf..d94fa9673 100644 --- a/x/lend/keeper/gov.go +++ b/x/lend/keeper/gov.go @@ -10,10 +10,6 @@ func (k Keeper) HandleAddWhitelistedPairsRecords(ctx sdk.Context, p *types.LendP return k.AddLendPairsRecords(ctx, p.Pairs) } -func (k Keeper) HandleUpdateWhitelistedPairsRecords(ctx sdk.Context, p *types.UpdateLendPairsProposal) error { - return k.UpdateLendPairsRecords(ctx, p.Pairs) -} - func (k Keeper) HandleAddPoolRecords(ctx sdk.Context, p *types.AddPoolsProposal) error { return k.AddPoolRecords(ctx, p.Pool) } diff --git a/x/lend/keeper/grpc_query.go b/x/lend/keeper/grpc_query.go index 02ea06d87..04bcba869 100644 --- a/x/lend/keeper/grpc_query.go +++ b/x/lend/keeper/grpc_query.go @@ -481,7 +481,7 @@ func (q QueryServer) QueryPoolAssetLBMapping(c context.Context, req *types.Query } ctx := sdk.UnwrapSDKContext(c) - assetStatsData, found := q.AssetStatsByPoolIDAndAssetID(ctx, req.AssetId, req.PoolId) + assetStatsData, found := q.AssetStatsByPoolIDAndAssetID(ctx, req.PoolId, req.AssetId) if !found { return &types.QueryPoolAssetLBMappingResponse{}, nil } @@ -523,3 +523,19 @@ func (q QueryServer) QueryAuctionParams(c context.Context, req *types.QueryAucti AuctionParams: item, }, nil } + +func (q QueryServer) QueryModuleBalance(c context.Context, req *types.QueryModuleBalanceRequest) (*types.QueryModuleBalanceResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "request cannot be empty") + } + ctx := sdk.UnwrapSDKContext(c) + + modBal, found := q.GetModuleBalanceByPoolID(ctx, req.PoolId) + if !found { + return &types.QueryModuleBalanceResponse{}, nil + } + + return &types.QueryModuleBalanceResponse{ + ModuleBalance: modBal, + }, nil +} diff --git a/x/lend/keeper/iter.go b/x/lend/keeper/iter.go index ac932602c..147bc8229 100644 --- a/x/lend/keeper/iter.go +++ b/x/lend/keeper/iter.go @@ -53,21 +53,20 @@ func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerInteraction) pool, _ := k.GetPool(ctx, lend.PoolID) - asset, _ := k.GetAsset(ctx, lend.AssetID) + asset, _ := k.Asset.GetAsset(ctx, lend.AssetID) Amount := sdk.NewCoin(asset.Denom, newInterestPerInteraction) assetRatesStat, _ := k.GetAssetRatesParams(ctx, lend.AssetID) - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, Amount.Amount) addr, _ := sdk.AccAddressFromBech32(lend.Owner) - err := k.SendCoinFromModuleToAccount(ctx, pool.ModuleName, addr, cToken) + err := k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, sdk.NewCoins(cToken)) if err != nil { return sdk.Dec{}, err } // subtracting newInterestPerInteraction from global lend and interest accumulated poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Sub(newInterestPerInteraction) - // poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Sub(newInterestPerInteraction) k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) k.SetLend(ctx, lend) } @@ -197,39 +196,26 @@ func (k Keeper) CalculateBorrowInterest(ctx sdk.Context, amount string, rate, re return newAmount, indexGlobalCurrent, newAmountReservePool, reserveIndexGlobalCurrent, nil } -func (k Keeper) ReBalanceStableRates(ctx sdk.Context) error { - borrows, _ := k.GetBorrows(ctx) - - for _, v := range borrows { - borrowPos, found := k.GetBorrow(ctx, v) - if !found { - continue - } - if !borrowPos.IsLiquidated { - if borrowPos.IsStableBorrow { - pair, found := k.GetLendPair(ctx, borrowPos.PairID) - if !found { - continue - } - assetStats, found := k.UpdateAPR(ctx, pair.AssetOutPoolID, pair.AssetOut) - if !found { - continue - } - utilizationRatio, err := k.GetUtilisationRatioByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) - if err != nil { - continue - } - perc1, _ := sdk.NewDecFromStr(types.Perc1) - perc2, _ := sdk.NewDecFromStr(types.Perc2) - if borrowPos.StableBorrowRate.GTE(assetStats.StableBorrowApr.Add(perc1)) { - borrowPos.StableBorrowRate = assetStats.StableBorrowApr - k.SetBorrow(ctx, borrowPos) - } else if utilizationRatio.GT(perc2) && (borrowPos.StableBorrowRate.Add(perc1)).LTE(assetStats.StableBorrowApr) { - borrowPos.StableBorrowRate = assetStats.StableBorrowApr - k.SetBorrow(ctx, borrowPos) - } - } - } +func (k Keeper) ReBalanceStableRates(ctx sdk.Context, borrowPos types.BorrowAsset) (types.BorrowAsset, error) { + pair, found := k.GetLendPair(ctx, borrowPos.PairID) + if !found { + return borrowPos, types.ErrorPairNotFound + } + assetStats, found := k.UpdateAPR(ctx, pair.AssetOutPoolID, pair.AssetOut) + if !found { + return borrowPos, types.ErrorAssetRatesParamsNotFound + } + utilizationRatio, err := k.GetUtilisationRatioByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + if err != nil { + return borrowPos, err } - return nil + perc1, _ := sdk.NewDecFromStr(types.Perc1) // 20% + perc2, _ := sdk.NewDecFromStr(types.Perc2) // 90% + if borrowPos.StableBorrowRate.GTE(assetStats.StableBorrowApr.Add(perc1)) { // condition 1, 𝑆 ≥ 𝑆𝑡 + 20% + borrowPos.StableBorrowRate = assetStats.StableBorrowApr + } else if (borrowPos.StableBorrowRate.Add(perc1)).LTE(assetStats.StableBorrowApr) || utilizationRatio.GT(perc2) { // condition 2, 𝑆 + 20% ≤ 𝑆𝑡 ∨ 𝑢𝑡𝑖𝑙𝑖𝑧𝑎𝑡𝑖𝑜𝑛 ≥ 90% + borrowPos.StableBorrowRate = assetStats.StableBorrowApr + } + + return borrowPos, nil } diff --git a/x/lend/keeper/keeper.go b/x/lend/keeper/keeper.go index 994e8b491..b8de269a2 100644 --- a/x/lend/keeper/keeper.go +++ b/x/lend/keeper/keeper.go @@ -22,15 +22,17 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey sdk.StoreKey - memKey sdk.StoreKey - paramstore paramtypes.Subspace - bank expected.BankKeeper - account expected.AccountKeeper - asset expected.AssetKeeper - market expected.MarketKeeper - esm expected.EsmKeeper + cdc codec.BinaryCodec + storeKey sdk.StoreKey + memKey sdk.StoreKey + paramstore paramtypes.Subspace + bank expected.BankKeeper + account expected.AccountKeeper + Asset expected.AssetKeeper + Market expected.MarketKeeper + esm expected.EsmKeeper + Liquidation expected.LiquidationKeeper + Auction expected.AuctionKeeper } ) @@ -44,6 +46,8 @@ func NewKeeper( asset expected.AssetKeeper, market expected.MarketKeeper, esm expected.EsmKeeper, + liquidation expected.LiquidationKeeper, + auction expected.AuctionKeeper, ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -51,15 +55,17 @@ func NewKeeper( } return Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - bank: bank, - account: account, - asset: asset, - market: market, - esm: esm, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bank: bank, + account: account, + Asset: asset, + Market: market, + esm: esm, + Liquidation: liquidation, + Auction: auction, } } @@ -85,7 +91,7 @@ func (k Keeper) CheckSupplyCap(ctx sdk.Context, assetID, poolID uint64, amt sdk. var supplyCap uint64 assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) - currentSupply, err := k.CalcAssetPrice(ctx, assetID, assetStats.TotalLend.Add(amt)) + currentSupply, err := k.Market.CalcAssetPrice(ctx, assetID, assetStats.TotalLend.Add(amt)) if err != nil { return false, err } @@ -111,11 +117,11 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am // mints cAsset representative of the lent asset // creates a lent Position and updates global lend - killSwitchParams, _ := k.GetKillSwitchData(ctx, AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } - asset, found := k.GetAsset(ctx, AssetID) + asset, found := k.Asset.GetAsset(ctx, AssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -123,7 +129,7 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am if !found { return types.ErrPoolNotFound } - appMapping, found := k.GetApp(ctx, AppID) + appMapping, found := k.Asset.GetApp(ctx, AppID) if !found { return types.ErrorAppMappingDoesNotExist } @@ -160,7 +166,7 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10)) } - cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -248,7 +254,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd } return nil } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -260,7 +266,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd lendPos.GlobalIndex = indexGlobalCurrent lendPos.LastInteractionTime = ctx.BlockTime() - getAsset, _ := k.GetAsset(ctx, lendPos.AssetID) + getAsset, _ := k.Asset.GetAsset(ctx, lendPos.AssetID) pool, _ := k.GetPool(ctx, lendPos.PoolID) if lendPos.Owner != addr { @@ -286,7 +292,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, withdrawal.Amount) cTokens := sdk.NewCoins(cToken) @@ -301,7 +307,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd // as no further lend rewards will be available for this user. if withdrawal.Amount.LT(lendPos.AmountIn.Amount) { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, pool.ModuleName, sdk.NewCoins(cToken)); err != nil { return err } // burn c/Token @@ -318,7 +324,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) k.SetLend(ctx, lendPos) } else { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, pool.ModuleName, sdk.NewCoins(cToken)); err != nil { return err } // burn c/Token @@ -350,7 +356,7 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -361,7 +367,11 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi lendPos, _ = k.GetLend(ctx, lendID) lendPos.GlobalIndex = indexGlobalCurrent lendPos.LastInteractionTime = ctx.BlockTime() - getAsset, _ := k.GetAsset(ctx, lendPos.AssetID) + // checking if the caller is the owner to Lend Position + if lendPos.Owner != addr { + return types.ErrLendAccessUnauthorized + } + getAsset, _ := k.Asset.GetAsset(ctx, lendPos.AssetID) pool, _ := k.GetPool(ctx, lendPos.PoolID) found, err = k.CheckSupplyCap(ctx, lendPos.AssetID, lendPos.PoolID, deposit.Amount) @@ -380,7 +390,7 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, deposit.Amount) cTokens := sdk.NewCoins(cToken) @@ -417,7 +427,7 @@ func (k Keeper) CloseLend(ctx sdk.Context, addr string, lendID uint64) error { return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -451,10 +461,10 @@ func (k Keeper) CloseLend(ctx sdk.Context, addr string, lendID uint64) error { if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, lendPos.AvailableToBorrow) - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, pool.ModuleName, sdk.NewCoins(cToken)); err != nil { return err } @@ -496,7 +506,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -515,11 +525,11 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return types.ErrorPairNotFound } // check cr ratio - assetIn, found := k.GetAsset(ctx, lendPos.AssetID) + assetIn, found := k.Asset.GetAsset(ctx, lendPos.AssetID) if !found { return assettypes.ErrorAssetDoesNotExist } - assetOut, found := k.GetAsset(ctx, pair.AssetOut) + assetOut, found := k.Asset.GetAsset(ctx, pair.AssetOut) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -528,7 +538,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return types.ErrAssetStatsNotFound } - cAsset, found := k.GetAsset(ctx, assetInRatesStats.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetInRatesStats.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -587,11 +597,11 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, // else the borrowing pool is not having sufficient tokens to loan if !pair.IsInterPool { // take c/Tokens from the user - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } - if err = k.SendCoinFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, loan); err != nil { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, sdk.NewCoins(loan)); err != nil { return err } @@ -623,10 +633,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, IsLiquidated: false, } k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, AmountOut.Amount, true) - // err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, true) - // if err != nil { - // return err - // } + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) poolAssetLBMappingData.BorrowIds = append(poolAssetLBMappingData.BorrowIds, borrowPos.ID) k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) @@ -641,7 +648,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, k.SetUserLendBorrowMapping(ctx, mappingData) } else { updatedAmtIn := AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) - updatedAmtInPrice, err := k.CalcAssetPrice(ctx, lendPos.AssetID, updatedAmtIn.TruncateInt()) + updatedAmtInPrice, err := k.Market.CalcAssetPrice(ctx, lendPos.AssetID, updatedAmtIn.TruncateInt()) if err != nil { return err } @@ -654,14 +661,14 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, secondTransitAssetID = data.AssetID } } - firstTransitAsset, _ := k.GetAsset(ctx, firstTransitAssetID) - secondTransitAsset, _ := k.GetAsset(ctx, secondTransitAssetID) + firstTransitAsset, _ := k.Asset.GetAsset(ctx, firstTransitAssetID) + secondTransitAsset, _ := k.Asset.GetAsset(ctx, secondTransitAssetID) - unitAmountFirstTransitAsset, err := k.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) + unitAmountFirstTransitAsset, err := k.Market.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) if err != nil { return err } - unitAmountSecondTransitAsset, err := k.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) + unitAmountSecondTransitAsset, err := k.Market.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) if err != nil { return err } @@ -687,15 +694,15 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return err } // take c/Tokens from the user - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } bridgedAssetAmount := sdk.NewCoin(firstTransitAsset.Denom, firstBridgedAssetQty.TruncateInt()) - if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { + if err = k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { return err } - if err = k.SendCoinFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, loan); err != nil { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, sdk.NewCoins(loan)); err != nil { return err } @@ -745,16 +752,16 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return err } // take c/Tokens from the user - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } bridgedAssetAmount := sdk.NewCoin(secondTransitAsset.Denom, secondBridgedAssetQty.TruncateInt()) - if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { + if err = k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { return err } - if err = k.SendCoinFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, loan); err != nil { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, AssetOutPool.ModuleName, lenderAddr, sdk.NewCoins(loan)); err != nil { return err } @@ -832,7 +839,7 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string if !found { return types.ErrAssetStatsNotFound } - cAsset, found := k.GetAsset(ctx, assetStats.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetStats.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -845,7 +852,7 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -913,7 +920,7 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string return types.ErrReserveRatesNotFound } if cTokensAmount.GT(sdk.ZeroInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, cTokensAmount)) + err = k.bank.MintCoins(ctx, pool.ModuleName, sdk.NewCoins(sdk.NewCoin(cAsset.Denom, cTokensAmount))) if err != nil { return err } @@ -950,7 +957,7 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string return types.ErrReserveRatesNotFound } if cTokensAmount.GT(sdk.ZeroInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, cTokensAmount)) + err = k.bank.MintCoins(ctx, pool.ModuleName, sdk.NewCoins(sdk.NewCoin(cAsset.Denom, cTokensAmount))) if err != nil { return err } @@ -990,7 +997,7 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -1013,7 +1020,7 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } - cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -1037,7 +1044,7 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string } if !pair.IsInterPool { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) @@ -1045,7 +1052,7 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string borrowPos.AmountIn = borrowPos.AmountIn.Add(AmountIn) k.SetBorrow(ctx, borrowPos) } else { - amtIn, err := k.CalcAssetPrice(ctx, pair.AssetIn, (sdk.NewDecFromInt(AmountIn.Amount).Mul(assetRatesStat.Ltv)).TruncateInt()) + amtIn, err := k.Market.CalcAssetPrice(ctx, pair.AssetIn, (sdk.NewDecFromInt(AmountIn.Amount).Mul(assetRatesStat.Ltv)).TruncateInt()) if err != nil { return err } @@ -1059,14 +1066,14 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string secondTransitAssetID = data.AssetID } } - firstTransitAsset, _ := k.GetAsset(ctx, firstTransitAssetID) - secondTransitAsset, _ := k.GetAsset(ctx, secondTransitAssetID) + firstTransitAsset, _ := k.Asset.GetAsset(ctx, firstTransitAssetID) + secondTransitAsset, _ := k.Asset.GetAsset(ctx, secondTransitAssetID) - unitAmountFirstTransitAsset, err := k.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) + unitAmountFirstTransitAsset, err := k.Market.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) if err != nil { return err } - unitAmountSecondTransitAsset, err := k.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) + unitAmountSecondTransitAsset, err := k.Market.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) if err != nil { return err } @@ -1082,11 +1089,11 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string if borrowPos.BridgedAssetAmount.Denom == firstTransitAsset.Denom && firstBridgedAssetQty.LT(sdk.NewDecFromInt(firstBridgedAssetBal)) { // take c/Tokens from the user - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } - if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(firstTransitAsset.Denom, firstBridgedAssetQty.TruncateInt()))); err != nil { + if err = k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(firstTransitAsset.Denom, firstBridgedAssetQty.TruncateInt()))); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) @@ -1096,11 +1103,11 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string k.SetBorrow(ctx, borrowPos) } else if secondBridgedAssetQty.LT(sdk.NewDecFromInt(secondBridgedAssetBal)) { // take c/Tokens from the user - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, sdk.NewCoins(AmountIn)); err != nil { return err } - if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(secondTransitAsset.Denom, secondBridgedAssetQty.TruncateInt()))); err != nil { + if err = k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(secondTransitAsset.Denom, secondBridgedAssetQty.TruncateInt()))); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) @@ -1139,7 +1146,7 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -1161,11 +1168,11 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if borrowPos.AmountOut.Denom != amount.Denom { return types.ErrBadOfferCoinAmount } - assetIn, found := k.GetAsset(ctx, lendPos.AssetID) + assetIn, found := k.Asset.GetAsset(ctx, lendPos.AssetID) if !found { return assettypes.ErrorAssetDoesNotExist } - assetOut, found := k.GetAsset(ctx, pair.AssetOut) + assetOut, found := k.Asset.GetAsset(ctx, pair.AssetOut) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -1177,7 +1184,7 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if err != nil { return err } - if err = k.SendCoinFromModuleToAccount(ctx, pool.ModuleName, addr, amount); err != nil { + if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, sdk.NewCoins(amount)); err != nil { return err } borrowPos.AmountOut = borrowPos.AmountOut.Add(amount) @@ -1204,7 +1211,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 if !found { return types.ErrAssetStatsNotFound } - cAsset, found := k.GetAsset(ctx, assetStats.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetStats.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -1216,7 +1223,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 if !found { return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -1238,7 +1245,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 if !found { return types.ErrPoolNotFound } - assetOut, found := k.GetAsset(ctx, pair.AssetOut) + assetOut, found := k.Asset.GetAsset(ctx, pair.AssetOut) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -1275,7 +1282,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 } amtToMint := borrowPos.InterestAccumulated.TruncateInt().Sub(amtToReservePool.TruncateInt()) if amtToMint.GT(sdk.ZeroInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtToMint)) + err = k.bank.MintCoins(ctx, pool.ModuleName, sdk.NewCoins(sdk.NewCoin(cAsset.Denom, amtToMint))) if err != nil { return err } @@ -1303,11 +1310,11 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 } func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, PoolID uint64, AmountIn sdk.Coin, PairID uint64, IsStableBorrow bool, AmountOut sdk.Coin, AppID uint64) error { - killSwitchParams, _ := k.GetKillSwitchData(ctx, AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } - asset, found := k.GetAsset(ctx, AssetID) + asset, found := k.Asset.GetAsset(ctx, AssetID) if !found { return assettypes.ErrorAssetDoesNotExist } @@ -1315,7 +1322,7 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo if !found { return types.ErrPoolNotFound } - appMapping, found := k.GetApp(ctx, AppID) + appMapping, found := k.Asset.GetApp(ctx, AppID) if !found { return types.ErrorAppMappingDoesNotExist } @@ -1352,7 +1359,7 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10)) } - cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, _ := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, AmountIn.Amount) if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, loanTokens); err != nil { @@ -1414,13 +1421,17 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo return nil } -func (k Keeper) FundModAcc(ctx sdk.Context, moduleName string, assetID uint64, lenderAddr sdk.AccAddress, payment sdk.Coin) error { +func (k Keeper) FundModAcc(ctx sdk.Context, poolID, assetID uint64, lenderAddr sdk.AccAddress, payment sdk.Coin) error { loanTokens := sdk.NewCoins(payment) - if err := k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, moduleName, loanTokens); err != nil { + pool, found := k.GetPool(ctx, poolID) + if !found { + return types.ErrPoolNotFound + } + if err := k.bank.SendCoinsFromAccountToModule(ctx, lenderAddr, pool.ModuleName, loanTokens); err != nil { return err } - asset, found := k.GetAsset(ctx, assetID) + asset, found := k.Asset.GetAsset(ctx, assetID) if !found { return types.ErrLendNotFound } @@ -1433,13 +1444,13 @@ func (k Keeper) FundModAcc(ctx sdk.Context, moduleName string, assetID uint64, l if !found { return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(assetID, 10)) } - cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) + cAsset, found := k.Asset.GetAsset(ctx, assetRatesStat.CAssetID) if !found { return assettypes.ErrorAssetDoesNotExist } cToken := sdk.NewCoin(cAsset.Denom, payment.Amount) - err := k.MintCoin(ctx, moduleName, cToken) + err := k.bank.MintCoins(ctx, pool.ModuleName, sdk.NewCoins(cToken)) if err != nil { return err } @@ -1479,18 +1490,18 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke // Adjusting bridged asset qty after auctions if !kind.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { - priceAssetIn, _ := k.GetTwa(ctx, pair.AssetIn) + priceAssetIn, _ := k.Market.GetTwa(ctx, pair.AssetIn) adjustedBridgedAssetAmt := borrowPos.AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) amtIn := adjustedBridgedAssetAmt.TruncateInt().Mul(sdk.NewIntFromUint64(priceAssetIn.Twa)) - priceFirstBridgedAsset, _ := k.GetTwa(ctx, firstTransitAssetID) - priceSecondBridgedAsset, _ := k.GetTwa(ctx, secondTransitAssetID) - firstBridgedAsset, _ := k.GetAsset(ctx, firstTransitAssetID) + priceFirstBridgedAsset, _ := k.Market.GetTwa(ctx, firstTransitAssetID) + priceSecondBridgedAsset, _ := k.Market.GetTwa(ctx, secondTransitAssetID) + firstBridgedAsset, _ := k.Asset.GetAsset(ctx, firstTransitAssetID) if kind.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { firstBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceFirstBridgedAsset.Twa)) diff := borrowPos.BridgedAssetAmount.Amount.Sub(firstBridgedAssetQty) if diff.GT(sdk.ZeroInt()) { - err := k.SendCoinFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) + err := k.bank.SendCoinsFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) if err != nil { return } @@ -1498,7 +1509,7 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke } else { newDiff := firstBridgedAssetQty.Sub(borrowPos.BridgedAssetAmount.Amount) if newDiff.GT(sdk.ZeroInt()) { - err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) + err := k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) if err != nil { return } @@ -1509,7 +1520,7 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke secondBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceSecondBridgedAsset.Twa)) diff := borrowPos.BridgedAssetAmount.Amount.Sub(secondBridgedAssetQty) if diff.GT(sdk.ZeroInt()) { - err := k.SendCoinFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) + err := k.bank.SendCoinsFromModuleToModule(ctx, AssetOutPool.ModuleName, AssetInPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, diff))) if err != nil { return } @@ -1517,7 +1528,7 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke } else { newDiff := secondBridgedAssetQty.Sub(borrowPos.BridgedAssetAmount.Amount) if newDiff.GT(sdk.ZeroInt()) { - err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) + err := k.bank.SendCoinsFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(borrowPos.BridgedAssetAmount.Denom, newDiff))) if err != nil { return } @@ -1543,7 +1554,7 @@ func (k Keeper) MsgCalculateBorrowInterest(ctx sdk.Context, borrowerAddr string, if !found { return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -1571,7 +1582,7 @@ func (k Keeper) MsgCalculateLendRewards(ctx sdk.Context, addr string, lendID uin return types.ErrLendNotFound } - killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled } @@ -1594,18 +1605,20 @@ func (k Keeper) MsgCalculateInterestAndRewards(ctx sdk.Context, addr string) err lendIDs []uint64 borrowIDs []uint64 ) + fmt.Println(addr) mappingData := k.GetUserTotalMappingData(ctx, addr) for _, data := range mappingData { lendIDs = append(lendIDs, data.LendId) } - if len(lendIDs) == 0 { - return types.ErrLendNotFound - } for _, v := range lendIDs { lendBorrowMappingData, _ := k.GetUserLendBorrowMapping(ctx, addr, v) borrowIDs = append(borrowIDs, lendBorrowMappingData.BorrowId...) } + if len(lendIDs) == 0 { + return types.ErrLendNotFound + } + if len(borrowIDs) != 0 { for _, borrowID := range borrowIDs { err := k.MsgCalculateBorrowInterest(ctx, addr, borrowID) diff --git a/x/lend/keeper/keeper_test.go b/x/lend/keeper/keeper_test.go index 0f5d1c8e0..0931b46c5 100644 --- a/x/lend/keeper/keeper_test.go +++ b/x/lend/keeper/keeper_test.go @@ -92,7 +92,7 @@ func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) uint6 err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) @@ -154,7 +154,7 @@ func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) uint6 s.app.MarketKeeper.SetTwa(s.ctx, twa3) s.app.MarketKeeper.SetTwa(s.ctx, twa4) // s.Suite.Require().False(exists) - //s.app.MarketKeeper.SetMarketForAsset(s.ctx, assetID, name) + // s.app.MarketKeeper.SetMarketForAsset(s.ctx, assetID, name) return assetID } diff --git a/x/lend/keeper/lend.go b/x/lend/keeper/lend.go index d9b5604c6..90b6dc7b2 100644 --- a/x/lend/keeper/lend.go +++ b/x/lend/keeper/lend.go @@ -296,7 +296,27 @@ func (k Keeper) GetLendRewardTracker(ctx sdk.Context, id uint64) (rewards types. return rewards, true } -// only called while borrowing +func (k Keeper) GetAllLendRewardTracker(ctx sdk.Context) (rewards []types.LendRewardsTracker) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.LendRewardsTrackerKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var tracker types.LendRewardsTracker + k.cdc.MustUnmarshal(iter.Value(), &tracker) + rewards = append(rewards, tracker) + } + return rewards +} + func (k Keeper) SetUserLendBorrowMapping(ctx sdk.Context, userMapping types.UserAssetLendBorrowMapping) { var ( store = k.Store(ctx) @@ -345,6 +365,29 @@ func (k Keeper) GetUserTotalMappingData(ctx sdk.Context, address string) (mappin return mappingData } +func (k Keeper) GetAllUserTotalMappingData(ctx sdk.Context) (mappingData []types.UserAssetLendBorrowMapping) { + var ( + store = k.Store(ctx) + key = types.UserLendBorrowMappingKeyPrefix + iter = sdk.KVStorePrefixIterator(store, key) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var mapData types.UserAssetLendBorrowMapping + k.cdc.MustUnmarshal(iter.Value(), &mapData) + mappingData = append(mappingData, mapData) + } + + return mappingData +} + func (k Keeper) HasLendForAddressByAsset(ctx sdk.Context, address string, assetID, poolID uint64) bool { mappingData := k.GetUserTotalMappingData(ctx, address) for _, data := range mappingData { @@ -415,6 +458,27 @@ func (k Keeper) GetReserveBuybackAssetData(ctx sdk.Context, id uint64) (reserve return reserve, true } +func (k Keeper) GetAllReserveBuybackAssetData(ctx sdk.Context) (reserve []types.ReserveBuybackAssetData) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.ReserveBuybackAssetDataKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var tracker types.ReserveBuybackAssetData + k.cdc.MustUnmarshal(iter.Value(), &tracker) + reserve = append(reserve, tracker) + } + return reserve +} + func (k Keeper) DeleteBorrowIDFromUserMapping(ctx sdk.Context, owner string, lendID, borrowID uint64) { userData, _ := k.GetUserLendBorrowMapping(ctx, owner, lendID) lengthOfIDs := len(userData.BorrowId) @@ -437,3 +501,22 @@ func (k Keeper) WasmHasBorrowForAddressAndAsset(ctx sdk.Context, assetID uint64, } return false } + +func (k Keeper) GetModuleBalanceByPoolID(ctx sdk.Context, poolID uint64) (ModuleBalance types.ModuleBalance, found bool) { + pool, found := k.GetPool(ctx, poolID) + if !found { + return ModuleBalance, false + } + for _, v := range pool.AssetData { + asset, _ := k.Asset.GetAsset(ctx, v.AssetID) + balance := k.ModuleBalance(ctx, pool.ModuleName, asset.Denom) + tokenBal := sdk.NewCoin(asset.Denom, balance) + modBalStats := types.ModuleBalanceStats{ + AssetID: asset.Id, + Balance: tokenBal, + } + ModuleBalance.PoolID = poolID + ModuleBalance.ModuleBalanceStats = append(ModuleBalance.ModuleBalanceStats, modBalStats) + } + return ModuleBalance, true +} diff --git a/x/lend/keeper/maths.go b/x/lend/keeper/maths.go index e85e6ad97..d87b34380 100644 --- a/x/lend/keeper/maths.go +++ b/x/lend/keeper/maths.go @@ -8,7 +8,7 @@ import ( func (k Keeper) GetUtilisationRatioByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (sdk.Dec, error) { pool, _ := k.GetPool(ctx, poolID) - asset, _ := k.GetAsset(ctx, assetID) + asset, _ := k.Asset.GetAsset(ctx, assetID) moduleBalance := k.ModuleBalance(ctx, pool.ModuleName, asset.Denom) assetStats, found := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) if !found { diff --git a/x/lend/keeper/migrations.go b/x/lend/keeper/migrations.go new file mode 100644 index 000000000..3f43c4b8a --- /dev/null +++ b/x/lend/keeper/migrations.go @@ -0,0 +1,21 @@ +package keeper + +import ( + v5types "github.com/comdex-official/comdex/x/lend/migrations/v5" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate2to3 migrates from version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdk.Context) error { + return v5types.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) +} diff --git a/x/lend/keeper/msg_server.go b/x/lend/keeper/msg_server.go index b90834664..4dd1dcfe2 100644 --- a/x/lend/keeper/msg_server.go +++ b/x/lend/keeper/msg_server.go @@ -22,130 +22,112 @@ var _ types.MsgServer = msgServer{} func (m msgServer) Lend(goCtx context.Context, lend *types.MsgLend) (*types.MsgLendResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.LendGas, "LendGas") if err := m.keeper.LendAsset(ctx, lend.Lender, lend.AssetId, lend.Amount, lend.PoolId, lend.AppId); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.LendGas, "LendGas") - return &types.MsgLendResponse{}, nil } func (m msgServer) Withdraw(goCtx context.Context, withdraw *types.MsgWithdraw) (*types.MsgWithdrawResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.WithdrawGas, "WithdrawGas") lendID := withdraw.LendId if err := m.keeper.WithdrawAsset(ctx, withdraw.Lender, lendID, withdraw.Amount); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.WithdrawGas, "WithdrawGas") - return &types.MsgWithdrawResponse{}, nil } func (m msgServer) Deposit(goCtx context.Context, deposit *types.MsgDeposit) (*types.MsgDepositResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.DepositGas, "DepositGas") lendID := deposit.LendId if err := m.keeper.DepositAsset(ctx, deposit.Lender, lendID, deposit.Amount); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.DepositGas, "DepositGas") - return &types.MsgDepositResponse{}, nil } func (m msgServer) CloseLend(goCtx context.Context, lend *types.MsgCloseLend) (*types.MsgCloseLendResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.CloseLendGas, "CloseLendGas") lendID := lend.LendId if err := m.keeper.CloseLend(ctx, lend.Lender, lendID); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.CloseLendGas, "CloseLendGas") - return &types.MsgCloseLendResponse{}, nil } func (m msgServer) Borrow(goCtx context.Context, borrow *types.MsgBorrow) (*types.MsgBorrowResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.BorrowAssetGas, "BorrowAssetGas") if err := m.keeper.BorrowAsset(ctx, borrow.Borrower, borrow.LendId, borrow.PairId, borrow.IsStableBorrow, borrow.AmountIn, borrow.AmountOut); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.BorrowAssetGas, "BorrowAssetGas") - return &types.MsgBorrowResponse{}, nil } func (m msgServer) Repay(goCtx context.Context, repay *types.MsgRepay) (*types.MsgRepayResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.RepayAssetGas, "RepayAssetGas") if err := m.keeper.RepayAsset(ctx, repay.BorrowId, repay.Borrower, repay.Amount); err != nil { return nil, err } - ctx.GasMeter().ConsumeGas(types.RepayAssetGas, "RepayAssetGas") - return &types.MsgRepayResponse{}, nil } func (m msgServer) DepositBorrow(goCtx context.Context, borrow *types.MsgDepositBorrow) (*types.MsgDepositBorrowResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.DepositBorrowAssetGas, "DepositBorrowAssetGas") if err := m.keeper.DepositBorrowAsset(ctx, borrow.BorrowId, borrow.Borrower, borrow.Amount); err != nil { return nil, err } - ctx.GasMeter().ConsumeGas(types.DepositBorrowAssetGas, "DepositBorrowAssetGas") - return &types.MsgDepositBorrowResponse{}, nil } func (m msgServer) Draw(goCtx context.Context, draw *types.MsgDraw) (*types.MsgDrawResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.DrawAssetGas, "DrawAssetGas") err := m.keeper.DrawAsset(ctx, draw.BorrowId, draw.Borrower, draw.Amount) if err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.DrawAssetGas, "DrawAssetGas") - return &types.MsgDrawResponse{}, nil } func (m msgServer) CloseBorrow(goCtx context.Context, borrow *types.MsgCloseBorrow) (*types.MsgCloseBorrowResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.CloseBorrowAssetGas, "CloseBorrowAssetGas") borrowID := borrow.BorrowId if err := m.keeper.CloseBorrow(ctx, borrow.Borrower, borrowID); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.CloseBorrowAssetGas, "CloseBorrowAssetGas") - return &types.MsgCloseBorrowResponse{}, nil } func (m msgServer) BorrowAlternate(goCtx context.Context, alternate *types.MsgBorrowAlternate) (*types.MsgBorrowAlternateResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.BorrowAssetAlternateGas, "BorrowAssetAlternateGas") if err := m.keeper.BorrowAlternate(ctx, alternate.Lender, alternate.AssetId, alternate.PoolId, alternate.AmountIn, alternate.PairId, alternate.IsStableBorrow, alternate.AmountOut, alternate.AppId); err != nil { return nil, err } - - ctx.GasMeter().ConsumeGas(types.BorrowAssetAlternateGas, "BorrowAssetAlternateGas") - return &types.MsgBorrowAlternateResponse{}, nil } @@ -156,8 +138,7 @@ func (m msgServer) FundModuleAccounts(goCtx context.Context, accounts *types.Msg if err != nil { return nil, err } - - if err = m.keeper.FundModAcc(ctx, accounts.ModuleName, accounts.AssetId, lenderAddr, accounts.Amount); err != nil { + if err = m.keeper.FundModAcc(ctx, accounts.PoolId, accounts.AssetId, lenderAddr, accounts.Amount); err != nil { return nil, err } @@ -166,12 +147,11 @@ func (m msgServer) FundModuleAccounts(goCtx context.Context, accounts *types.Msg func (m msgServer) CalculateInterestAndRewards(goCtx context.Context, rewards *types.MsgCalculateInterestAndRewards) (*types.MsgCalculateInterestAndRewardsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + ctx.GasMeter().ConsumeGas(types.CalculateInterestAndRewardGas, "CalculateInterestAndRewardGas") if err := m.keeper.MsgCalculateInterestAndRewards(ctx, rewards.Borrower); err != nil { return nil, err } - ctx.GasMeter().ConsumeGas(types.CalculateInterestAndRewardGas, "CalculateInterestAndRewardGas") - return &types.MsgCalculateInterestAndRewardsResponse{}, nil } diff --git a/x/lend/keeper/msg_server_test.go b/x/lend/keeper/msg_server_test.go index 019c419ce..7ae67ade6 100644 --- a/x/lend/keeper/msg_server_test.go +++ b/x/lend/keeper/msg_server_test.go @@ -83,12 +83,12 @@ func (s *KeeperTestSuite) TestMsgLend() { appOneID := s.CreateNewApp("commodo", "cmmdo") appTwoID := s.CreateNewApp("cswap", "cswap") - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) - // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + // msg6 := types.NewMsgFundModuleAccounts(2, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) @@ -772,12 +772,12 @@ func (s *KeeperTestSuite) TestMsgBorrow() { msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) msgLend2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(10000000000)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) - // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + // msg6 := types.NewMsgFundModuleAccounts(2, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) @@ -1033,12 +1033,12 @@ func (s *KeeperTestSuite) TestMsgRepay() { msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) msgLend2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(10000000000)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) @@ -1231,12 +1231,12 @@ func (s *KeeperTestSuite) TestMsgDepositBorrow() { msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) msgLend2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(10000000000)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) @@ -1424,12 +1424,12 @@ func (s *KeeperTestSuite) TestMsgDraw() { msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) msgLend2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(10000000000)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) - // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + // msg6 := types.NewMsgFundModuleAccounts(2", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) @@ -1601,12 +1601,12 @@ func (s *KeeperTestSuite) TestMsgCloseBorrow() { msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) msgLend2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(10000000000)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) - // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + // msg6 := types.NewMsgFundModuleAccounts(2", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) @@ -1781,12 +1781,12 @@ func (s *KeeperTestSuite) TestMsgBorrowAlternate() { appTwoID := s.CreateNewApp("cswap", "cswap") msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetThreeID, sdk.NewCoin("uasset3", newInt(300)), poolOneID, appOneID) - msg3 := types.NewMsgFundModuleAccounts("cmdx", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg4 := types.NewMsgFundModuleAccounts("cmdx", assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) - msg5 := types.NewMsgFundModuleAccounts("cmdx", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) - // msg6 := types.NewMsgFundModuleAccounts("osmo", assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) - msg7 := types.NewMsgFundModuleAccounts("osmo", assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) - msg8 := types.NewMsgFundModuleAccounts("osmo", assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) + msg3 := types.NewMsgFundModuleAccounts(1, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg4 := types.NewMsgFundModuleAccounts(1, assetTwoID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset2", newInt(10000000000))) + msg5 := types.NewMsgFundModuleAccounts(1, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(120000000))) + // msg6 := types.NewMsgFundModuleAccounts(2, assetThreeID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset3", newInt(10000000000))) + msg7 := types.NewMsgFundModuleAccounts(2, assetOneID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset1", newInt(10000000000))) + msg8 := types.NewMsgFundModuleAccounts(2, assetFourID, "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", sdk.NewCoin("uasset4", newInt(10000000000))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) diff --git a/x/lend/keeper/pair.go b/x/lend/keeper/pair.go index 6b2ed3494..1b303359e 100644 --- a/x/lend/keeper/pair.go +++ b/x/lend/keeper/pair.go @@ -35,36 +35,9 @@ func (k Keeper) AddLendPairsRecords(ctx sdk.Context, records ...types.Extended_P return nil } -func (k Keeper) UpdateLendPairsRecords(ctx sdk.Context, msg types.Extended_Pair) error { - pair, found := k.GetLendPair(ctx, msg.Id) - if !found { - return types.ErrorPairNotFound - } - - _, found = k.GetAsset(ctx, msg.AssetIn) - if !found { - return types.ErrorAssetDoesNotExist - } - _, found = k.GetAsset(ctx, msg.AssetOut) - if !found { - return types.ErrorAssetDoesNotExist - } - - if msg.AssetIn == msg.AssetOut { - return types.ErrorAssetsCanNotBeSame - } - - pair.AssetIn = msg.AssetIn - pair.AssetOut = msg.AssetOut - pair.MinUsdValueLeft = msg.MinUsdValueLeft - - k.SetLendPair(ctx, pair) - return nil -} - func (k Keeper) AddPoolRecords(ctx sdk.Context, pool types.Pool) error { for _, v := range pool.AssetData { - _, found := k.GetAsset(ctx, v.AssetID) + _, found := k.Asset.GetAsset(ctx, v.AssetID) if !found { return types.ErrorAssetDoesNotExist } @@ -103,7 +76,7 @@ func (k Keeper) AddPoolRecords(ctx sdk.Context, pool types.Pool) error { } func (k Keeper) AddAssetToPair(ctx sdk.Context, assetToPair types.AssetToPairMapping) error { - _, found := k.GetAsset(ctx, assetToPair.AssetID) + _, found := k.Asset.GetAsset(ctx, assetToPair.AssetID) if !found { return types.ErrorAssetDoesNotExist } @@ -204,7 +177,7 @@ func (k Keeper) AddAssetRatesParams(ctx sdk.Context, records ...types.AssetRates for _, msg := range records { _, found := k.GetAssetRatesParams(ctx, msg.AssetID) if found { - return types.ErrorAssetRatesParamsNotFound + return types.ErrorAssetRatesParamsAlreadyExists } assetRatesParams := types.AssetRatesParams{ diff --git a/x/lend/keeper/rates.go b/x/lend/keeper/rates.go index eef0e5637..e4dfc8b05 100644 --- a/x/lend/keeper/rates.go +++ b/x/lend/keeper/rates.go @@ -34,11 +34,11 @@ func (k Keeper) CalculateCollateralizationRatio( amountOut sdk.Int, assetOut assettypes.Asset, ) (sdk.Dec, error) { - totalIn, err := k.CalcAssetPrice(ctx, assetIn.Id, amountIn) + totalIn, err := k.Market.CalcAssetPrice(ctx, assetIn.Id, amountIn) if err != nil { return sdk.ZeroDec(), err } - totalOut, err := k.CalcAssetPrice(ctx, assetOut.Id, amountOut) + totalOut, err := k.Market.CalcAssetPrice(ctx, assetOut.Id, amountOut) if err != nil { return sdk.ZeroDec(), err } diff --git a/x/lend/migrations/v5/migrations.go b/x/lend/migrations/v5/migrations.go new file mode 100644 index 000000000..ca8fa6610 --- /dev/null +++ b/x/lend/migrations/v5/migrations.go @@ -0,0 +1,516 @@ +package v5 + +import ( + v5types "github.com/comdex-official/comdex/x/lend/migrations/v5/types" + "github.com/comdex-official/comdex/x/lend/types" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + protobuftypes "github.com/gogo/protobuf/types" +) + +func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { + store := ctx.KVStore(storeKey) + err := migrateValuesPool(store, cdc) + if err != nil { + return err + } + err = migrateValuesLend(store, cdc) + if err != nil { + return err + } + err = migrateValuesBorrow(store, cdc) + if err != nil { + return err + } + err = migrateValueAuctionParams(store, cdc) + if err != nil { + return err + } + return err +} + +func migrateValuesPool(store sdk.KVStore, cdc codec.BinaryCodec) error { + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + assetData []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: 1, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: 2, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: 3, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: 4, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolTwo, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + oldPools := GetPools(store, cdc) + for _, j := range oldPools { + if j.PoolID == 1 { + assetData = assetDataPoolOne + } else { + assetData = assetDataPoolTwo + } + newPool := types.Pool{ + PoolID: j.PoolID, + ModuleName: j.ModuleName, + CPoolName: j.CPoolName, + ReserveFunds: j.ReserveFunds, + AssetData: assetData, + } + + for _, v := range newPool.AssetData { + var assetStats types.PoolAssetLBMapping + assetStats.PoolID = newPool.PoolID + assetStats.AssetID = v.AssetID + assetStats.TotalBorrowed = sdk.ZeroInt() + assetStats.TotalStableBorrowed = sdk.ZeroInt() + assetStats.TotalLend = sdk.ZeroInt() + assetStats.TotalInterestAccumulated = sdk.ZeroInt() + SetAssetStatsByPoolIDAndAssetID(store, cdc, assetStats) + reserveBuybackStats, found := GetReserveBuybackAssetData(store, cdc, v.AssetID) + if !found { + reserveBuybackStats.AssetID = v.AssetID + reserveBuybackStats.ReserveAmount = sdk.ZeroInt() + reserveBuybackStats.BuybackAmount = sdk.ZeroInt() + SetReserveBuybackAssetData(store, cdc, reserveBuybackStats) + } + } + key := types.PoolKey(j.PoolID) + store.Delete(key) + SetPool(store, cdc, newPool) + SetPoolID(store, cdc, newPool.PoolID) + } + return nil +} + +func SetPoolID(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) { + var ( + key = types.PoolIDPrefix + value = cdc.MustMarshal( + &protobuftypes.UInt64Value{ + Value: id, + }, + ) + ) + store.Set(key, value) +} + +func SetPool(store sdk.KVStore, cdc codec.BinaryCodec, pool types.Pool) { + var ( + key = types.PoolKey(pool.PoolID) + value = cdc.MustMarshal(&pool) + ) + + store.Set(key, value) +} + +func SetReserveBuybackAssetData(store sdk.KVStore, cdc codec.BinaryCodec, reserve types.ReserveBuybackAssetData) { + var ( + key = types.ReserveBuybackAssetDataKey(reserve.AssetID) + value = cdc.MustMarshal(&reserve) + ) + + store.Set(key, value) +} + +func GetReserveBuybackAssetData(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) (reserve types.ReserveBuybackAssetData, found bool) { + var ( + key = types.ReserveBuybackAssetDataKey(id) + value = store.Get(key) + ) + + if value == nil { + return reserve, false + } + + cdc.MustUnmarshal(value, &reserve) + return reserve, true +} + +func GetPools(store sdk.KVStore, cdc codec.BinaryCodec) (pools []v5types.PoolOld) { + iter := sdk.KVStorePrefixIterator(store, types.PoolKeyPrefix) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var pool v5types.PoolOld + cdc.MustUnmarshal(iter.Value(), &pool) + pools = append(pools, pool) + } + return pools +} + +func migrateValuesLend(store sdk.KVStore, cdc codec.BinaryCodec) error { + iter := sdk.KVStorePrefixIterator(store, types.LendUserPrefix) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + var lendAssets []v5types.LendAssetOld + for ; iter.Valid(); iter.Next() { + var asset v5types.LendAssetOld + cdc.MustUnmarshal(iter.Value(), &asset) + lendAssets = append(lendAssets, asset) + } + counterKey := types.LendCounterIDPrefix + for _, v := range lendAssets { + newVal, Key := migrateValueLend(v) + if v.AmountIn.Amount.LTE(sdk.ZeroInt()) || v.AvailableToBorrow.LT(sdk.ZeroInt()) { + store.Delete(Key) + continue + } + store.Delete(Key) + value := cdc.MustMarshal(&newVal) + idValue := cdc.MustMarshal( + &protobuftypes.UInt64Value{ + Value: v.ID, + }, + ) + store.Set(counterKey, idValue) + store.Set(Key, value) + // updating global lend stats and lending IDs + PoolAssetLBMapping := GetAssetStatsByPoolIDAndAssetID(store, cdc, v.PoolID, v.AssetID) + PoolAssetLBMapping.TotalLend = PoolAssetLBMapping.TotalLend.Add(v.AmountIn.Amount) + PoolAssetLBMapping.LendIds = append(PoolAssetLBMapping.LendIds, v.ID) + SetAssetStatsByPoolIDAndAssetID(store, cdc, PoolAssetLBMapping) + // making UserAssetLendBorrowMapping for user + var mappingData types.UserAssetLendBorrowMapping + mappingData.Owner = v.Owner + mappingData.LendId = v.ID + mappingData.PoolId = v.PoolID + mappingData.BorrowId = nil + SetUserLendBorrowMapping(store, cdc, mappingData) + } + return nil +} + +func SetAssetStatsByPoolIDAndAssetID(store sdk.KVStore, cdc codec.BinaryCodec, PoolAssetLBMapping types.PoolAssetLBMapping) { + var ( + key = types.SetAssetStatsByPoolIDAndAssetID(PoolAssetLBMapping.PoolID, PoolAssetLBMapping.AssetID) + value = cdc.MustMarshal(&PoolAssetLBMapping) + ) + + store.Set(key, value) +} + +func SetUserLendBorrowMapping(store sdk.KVStore, cdc codec.BinaryCodec, userMapping types.UserAssetLendBorrowMapping) { + var ( + key = types.UserLendBorrowMappingKey(userMapping.Owner, userMapping.LendId) + value = cdc.MustMarshal(&userMapping) + ) + + store.Set(key, value) +} + +func GetAssetStatsByPoolIDAndAssetID(store sdk.KVStore, cdc codec.BinaryCodec, poolID, assetID uint64) (PoolAssetLBMapping types.PoolAssetLBMapping) { + var ( + key = types.SetAssetStatsByPoolIDAndAssetID(poolID, assetID) + value = store.Get(key) + ) + + if value == nil { + return PoolAssetLBMapping + } + + cdc.MustUnmarshal(value, &PoolAssetLBMapping) + return PoolAssetLBMapping +} + +func migrateValueLend(oldVal v5types.LendAssetOld) (newVal types.LendAsset, oldKey []byte) { + newVal = types.LendAsset{ + ID: oldVal.ID, + AssetID: oldVal.AssetID, + PoolID: oldVal.PoolID, + Owner: oldVal.Owner, + AmountIn: oldVal.AmountIn, + LendingTime: oldVal.LendingTime, + AvailableToBorrow: oldVal.AvailableToBorrow, + AppID: oldVal.AppID, + GlobalIndex: oldVal.GlobalIndex, + LastInteractionTime: oldVal.LastInteractionTime, + CPoolName: oldVal.CPoolName, + } + return newVal, types.LendUserKey(newVal.ID) +} + +// for borrow function migration + +func migrateValuesBorrow(store sdk.KVStore, cdc codec.BinaryCodec) error { + iter := sdk.KVStorePrefixIterator(store, types.BorrowPairKeyPrefix) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + var borrowAssets []v5types.BorrowAssetOld + for ; iter.Valid(); iter.Next() { + var asset v5types.BorrowAssetOld + cdc.MustUnmarshal(iter.Value(), &asset) + borrowAssets = append(borrowAssets, asset) + } + counterKey := types.BorrowCounterIDPrefix + for _, v := range borrowAssets { + newVal, Key := migrateValueBorrow(v) + if v.AmountIn.Amount.LTE(sdk.ZeroInt()) || v.AmountOut.Amount.LTE(sdk.ZeroInt()) { + store.Delete(Key) + continue + } + store.Delete(Key) + value := cdc.MustMarshal(&newVal) + idValue := cdc.MustMarshal( + &protobuftypes.UInt64Value{ + Value: v.ID, + }, + ) + store.Set(counterKey, idValue) + store.Set(Key, value) + // updating global borrow stats and borrowing IDs + pair, found := GetLendPair(store, cdc, v.PairID) + if !found { + return types.ErrorPairNotFound + } + PoolAssetLBMapping := GetAssetStatsByPoolIDAndAssetID(store, cdc, pair.AssetOutPoolID, pair.AssetOut) + PoolAssetLBMapping.TotalBorrowed = PoolAssetLBMapping.TotalBorrowed.Add(v.AmountOut.Amount) + PoolAssetLBMapping.BorrowIds = append(PoolAssetLBMapping.BorrowIds, v.ID) + SetAssetStatsByPoolIDAndAssetID(store, cdc, PoolAssetLBMapping) + + // updating UserAssetLendBorrowMapping for user + lend, _ := GetLend(store, cdc, v.LendingID) + mappingData, _ := GetUserLendBorrowMapping(store, cdc, lend.Owner, lend.ID) + mappingData.BorrowId = append(mappingData.BorrowId, v.ID) + SetUserLendBorrowMapping(store, cdc, mappingData) + } + return nil +} + +func GetLend(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) (lend types.LendAsset, found bool) { + var ( + key = types.LendUserKey(id) + value = store.Get(key) + ) + + if value == nil { + return lend, false + } + + cdc.MustUnmarshal(value, &lend) + return lend, true +} + +func GetLendPair(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) (pair types.Extended_Pair, found bool) { + var ( + key = types.LendPairKey(id) + value = store.Get(key) + ) + + if value == nil { + return pair, false + } + + cdc.MustUnmarshal(value, &pair) + return pair, true +} + +func GetUserLendBorrowMapping(store sdk.KVStore, cdc codec.BinaryCodec, owner string, lendID uint64) (userMapping types.UserAssetLendBorrowMapping, found bool) { + var ( + key = types.UserLendBorrowMappingKey(owner, lendID) + value = store.Get(key) + ) + + if value == nil { + return userMapping, false + } + + cdc.MustUnmarshal(value, &userMapping) + return userMapping, true +} + +func migrateValueBorrow(v v5types.BorrowAssetOld) (newVal types.BorrowAsset, oldKey []byte) { + newVal = types.BorrowAsset{ + ID: v.ID, + LendingID: v.LendingID, + IsStableBorrow: v.IsStableBorrow, + PairID: v.PairID, + AmountIn: v.AmountIn, + AmountOut: v.AmountOut, + BridgedAssetAmount: v.BridgedAssetAmount, + BorrowingTime: v.BorrowingTime, + StableBorrowRate: v.StableBorrowRate, + InterestAccumulated: sdk.NewDecFromInt(v.Interest_Accumulated), + GlobalIndex: v.GlobalIndex, + ReserveGlobalIndex: v.ReserveGlobalIndex, + LastInteractionTime: v.LastInteractionTime, + CPoolName: v.CPoolName, + IsLiquidated: false, + } + return newVal, types.BorrowUserKey(newVal.ID) +} + +// for auction params migration + +func migrateValueAuctionParams(store sdk.KVStore, cdc codec.BinaryCodec) error { + buffer, _ := sdk.NewDecFromStr("1.2") + cusp, _ := sdk.NewDecFromStr("0.4") + auctionParams := types.AuctionParams{ + AppId: 3, + AuctionDurationSeconds: 21600, + Buffer: buffer, + Cusp: cusp, + Step: sdk.NewIntFromUint64(360), + PriceFunctionType: 1, + DutchId: 3, + BidDurationSeconds: 10800, + } + var ( + oldKey = types.AuctionParamKey(1) + key = types.AuctionParamKey(auctionParams.AppId) + value = cdc.MustMarshal(&auctionParams) + ) + store.Delete(oldKey) + store.Set(key, value) + return nil +} + +// for locked borrow to borrow + +//func migrateValueLockedBorrows(store sdk.KVStore, cdc codec.BinaryCodec) error { +// var ( +// iter = sdk.KVStorePrefixIterator(store, liquidationtypes.LockedVaultKeyPrefix) +// ) +// counterKey := types.BorrowCounterIDPrefix +// defer func(iter sdk.Iterator) { +// err := iter.Close() +// if err != nil { +// return +// } +// }(iter) +// for ; iter.Valid(); iter.Next() { +// var lockedVault liquidationtypes.LockedVault +// cdc.MustUnmarshal(iter.Value(), &lockedVault) +// fmt.Println("lockedVault", lockedVault) +// if lockedVault.GetBorrowMetaData() != nil { +// +// fmt.Println("lockedVault.GetBorrowMetaData", lockedVault.GetBorrowMetaData()) +// +// if lockedVault.AmountIn.GT(sdk.ZeroInt()) && lockedVault.AmountOut.GT(sdk.ZeroInt()) { +// lockedVaultKey := liquidationtypes.LockedVaultKey(lockedVault.AppId, lockedVault.LockedVaultId) +// newVal, Key := migrateValueLockedBorrow(store, cdc, lockedVault) +// store.Delete(lockedVaultKey) +// +// store.Delete(Key) +// value := cdc.MustMarshal(&newVal) +// idValue := cdc.MustMarshal( +// &protobuftypes.UInt64Value{ +// Value: newVal.ID, +// }, +// ) +// store.Set(counterKey, idValue) +// store.Set(Key, value) +// // updating global borrow stats and borrowing IDs +// pair, found := GetLendPair(store, cdc, newVal.PairID) +// if !found { +// return types.ErrorPairNotFound +// } +// PoolAssetLBMapping := GetAssetStatsByPoolIDAndAssetID(store, cdc, pair.AssetOutPoolID, pair.AssetOut) +// PoolAssetLBMapping.TotalBorrowed = PoolAssetLBMapping.TotalBorrowed.Add(newVal.AmountOut.Amount) +// PoolAssetLBMapping.BorrowIds = append(PoolAssetLBMapping.BorrowIds, newVal.ID) +// SetAssetStatsByPoolIDAndAssetID(store, cdc, PoolAssetLBMapping) +// +// // updating UserAssetLendBorrowMapping for user +// lend, found := GetLend(store, cdc, newVal.LendingID) +// mappingData, found := GetUserLendBorrowMapping(store, cdc, lend.Owner, lend.ID) +// mappingData.BorrowId = append(mappingData.BorrowId, newVal.ID) +// SetUserLendBorrowMapping(store, cdc, mappingData) +// } else { +// fmt.Println("in else part") +// key := liquidationtypes.LockedVaultKey(lockedVault.AppId, lockedVault.LockedVaultId) +// store.Delete(key) +// } +// } +// } +// +// return nil +//} + +//func GetAsset(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) (asset assettypes.Asset, found bool) { +// var ( +// key = assettypes.AssetKey(id) +// value = store.Get(key) +// ) +// +// if value == nil { +// return asset, false +// } +// +// cdc.MustUnmarshal(value, &asset) +// return asset, true +//} +// +//func GetPool(store sdk.KVStore, cdc codec.BinaryCodec, id uint64) (pool types.Pool, found bool) { +// var ( +// key = types.PoolKey(id) +// value = store.Get(key) +// ) +// +// if value == nil { +// return pool, false +// } +// +// cdc.MustUnmarshal(value, &pool) +// return pool, true +//} + +//func migrateValueLockedBorrow(store sdk.KVStore, cdc codec.BinaryCodec, v liquidationtypes.LockedVault) (newBorrow types.BorrowAsset, oldKey []byte) { +// pair, _ := GetLendPair(store, cdc, v.ExtendedPairId) +// assetIn, _ := GetAsset(store, cdc, pair.AssetIn) +// assetOut, _ := GetAsset(store, cdc, pair.AssetOut) +// amountIn := sdk.NewCoin(assetIn.Denom, v.AmountIn) +// amountOut := sdk.NewCoin(assetOut.Denom, v.AmountOut) +// pool, _ := GetPool(store, cdc, pair.AssetOutPoolID) +// +// borrowMetaData := v.GetBorrowMetaData() +// globalIndex, _ := sdk.NewDecFromStr("0.002") +// newBorrow = types.BorrowAsset{ +// ID: v.OriginalVaultId, +// LendingID: borrowMetaData.LendingId, +// IsStableBorrow: borrowMetaData.IsStableBorrow, +// PairID: v.ExtendedPairId, +// AmountIn: amountIn, +// AmountOut: amountOut, +// BridgedAssetAmount: borrowMetaData.BridgedAssetAmount, +// BorrowingTime: v.LiquidationTimestamp, +// StableBorrowRate: borrowMetaData.StableBorrowRate, +// InterestAccumulated: sdk.NewDecFromInt(v.InterestAccumulated), +// GlobalIndex: globalIndex, +// ReserveGlobalIndex: sdk.OneDec(), +// LastInteractionTime: v.LiquidationTimestamp, +// CPoolName: pool.CPoolName, +// IsLiquidated: false, +// } +// return newBorrow, types.BorrowUserKey(newBorrow.ID) +//} diff --git a/x/lend/migrations/v5/types/lend.pb.go b/x/lend/migrations/v5/types/lend.pb.go new file mode 100644 index 000000000..3cd8ae062 --- /dev/null +++ b/x/lend/migrations/v5/types/lend.pb.go @@ -0,0 +1,2392 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: comdex/lend/v1beta1/lend.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/timestamp" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type LendAssetOld struct { + ID uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` + AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + PoolID uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + Owner string `protobuf:"bytes,4,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` + AmountIn github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,5,opt,name=amount_in,json=amountIn,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount_in" yaml:"amount_in"` + LendingTime time.Time `protobuf:"bytes,6,opt,name=lending_time,json=lendingTime,proto3,stdtime" json:"lending_time" yaml:"lending_time"` + UpdatedAmountIn github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=updated_amount_in,json=updatedAmountIn,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"updated_amount_in" yaml:"updated_amount_in"` + AvailableToBorrow github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=available_to_borrow,json=availableToBorrow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"available_to_borrow" yaml:"available_to_borrow"` + Reward_Accumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,9,opt,name=reward_Accumulated,json=rewardAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"reward_Accumulated" yaml:"reward_accumulated"` + AppID uint64 `protobuf:"varint,10,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` + GlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=global_index,json=globalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"global_index" yaml:"global_index"` + LastInteractionTime time.Time `protobuf:"bytes,12,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,13,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` +} + +func (m *LendAssetOld) Reset() { *m = LendAssetOld{} } +func (m *LendAssetOld) String() string { return proto.CompactTextString(m) } +func (*LendAssetOld) ProtoMessage() {} +func (*LendAssetOld) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{0} +} +func (m *LendAssetOld) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LendAssetOld) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LendAssetOld.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LendAssetOld) XXX_Merge(src proto.Message) { + xxx_messageInfo_LendAssetOld.Merge(m, src) +} +func (m *LendAssetOld) XXX_Size() int { + return m.Size() +} +func (m *LendAssetOld) XXX_DiscardUnknown() { + xxx_messageInfo_LendAssetOld.DiscardUnknown(m) +} + +var xxx_messageInfo_LendAssetOld proto.InternalMessageInfo + +func (m *LendAssetOld) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *LendAssetOld) GetAssetID() uint64 { + if m != nil { + return m.AssetID + } + return 0 +} + +func (m *LendAssetOld) GetPoolID() uint64 { + if m != nil { + return m.PoolID + } + return 0 +} + +func (m *LendAssetOld) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *LendAssetOld) GetAmountIn() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.AmountIn + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *LendAssetOld) GetLendingTime() time.Time { + if m != nil { + return m.LendingTime + } + return time.Time{} +} + +func (m *LendAssetOld) GetAppID() uint64 { + if m != nil { + return m.AppID + } + return 0 +} + +func (m *LendAssetOld) GetLastInteractionTime() time.Time { + if m != nil { + return m.LastInteractionTime + } + return time.Time{} +} + +func (m *LendAssetOld) GetCPoolName() string { + if m != nil { + return m.CPoolName + } + return "" +} + +type BorrowAssetOld struct { + ID uint64 `protobuf:"varint,1,opt,name=borrowing_id,json=borrowingId,proto3" json:"borrowing_id,omitempty" yaml:"borrowing_id"` + LendingID uint64 `protobuf:"varint,2,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` + IsStableBorrow bool `protobuf:"varint,3,opt,name=is_stable_borrow,json=isStableBorrow,proto3" json:"is_stable_borrow,omitempty" yaml:"is_stable_borrow"` + PairID uint64 `protobuf:"varint,4,opt,name=pair_id,json=pairId,proto3" json:"pair_id,omitempty" yaml:"pair_id"` + AmountIn github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,5,opt,name=amount_in,json=amountIn,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount_in" yaml:"amount_in"` + AmountOut github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,6,opt,name=amount_out,json=amountOut,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"amount_out" yaml:"amount_out"` + BridgedAssetAmount github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,7,opt,name=bridged_asset_amount,json=bridgedAssetAmount,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"bridged_asset_amount" yaml:"bridged_asset_amount"` + BorrowingTime time.Time `protobuf:"bytes,8,opt,name=borrowing_time,json=borrowingTime,proto3,stdtime" json:"borrowing_time" yaml:"borrowing_time"` + StableBorrowRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=stable_borrow_rate,json=stableBorrowRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_borrow_rate" yaml:"stable_borrow_rate"` + UpdatedAmountOut github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=updated_amount_out,json=updatedAmountOut,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"updated_amount_out" yaml:"updated_amount_out"` + Interest_Accumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=interest_Accumulated,json=interestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"interest_Accumulated" yaml:"interest_accumulated"` + GlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=global_index,json=globalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"global_index" yaml:"global_index"` + ReserveGlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=reserve_global_index,json=reserveGlobalIndex,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reserve_global_index" yaml:"reserve_global_index"` + LastInteractionTime time.Time `protobuf:"bytes,14,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,15,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` +} + +func (m *BorrowAssetOld) Reset() { *m = BorrowAssetOld{} } +func (m *BorrowAssetOld) String() string { return proto.CompactTextString(m) } +func (*BorrowAssetOld) ProtoMessage() {} +func (*BorrowAssetOld) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{1} +} +func (m *BorrowAssetOld) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BorrowAssetOld) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BorrowAssetOld.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *BorrowAssetOld) XXX_Merge(src proto.Message) { + xxx_messageInfo_BorrowAssetOld.Merge(m, src) +} +func (m *BorrowAssetOld) XXX_Size() int { + return m.Size() +} +func (m *BorrowAssetOld) XXX_DiscardUnknown() { + xxx_messageInfo_BorrowAssetOld.DiscardUnknown(m) +} + +var xxx_messageInfo_BorrowAssetOld proto.InternalMessageInfo + +func (m *BorrowAssetOld) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *BorrowAssetOld) GetLendingID() uint64 { + if m != nil { + return m.LendingID + } + return 0 +} + +func (m *BorrowAssetOld) GetIsStableBorrow() bool { + if m != nil { + return m.IsStableBorrow + } + return false +} + +func (m *BorrowAssetOld) GetPairID() uint64 { + if m != nil { + return m.PairID + } + return 0 +} + +func (m *BorrowAssetOld) GetAmountIn() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.AmountIn + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *BorrowAssetOld) GetAmountOut() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.AmountOut + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *BorrowAssetOld) GetBridgedAssetAmount() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.BridgedAssetAmount + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *BorrowAssetOld) GetBorrowingTime() time.Time { + if m != nil { + return m.BorrowingTime + } + return time.Time{} +} + +func (m *BorrowAssetOld) GetLastInteractionTime() time.Time { + if m != nil { + return m.LastInteractionTime + } + return time.Time{} +} + +func (m *BorrowAssetOld) GetCPoolName() string { + if m != nil { + return m.CPoolName + } + return "" +} + +type PoolOld struct { + PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + ModuleName string `protobuf:"bytes,2,opt,name=module_name,json=moduleName,proto3" json:"module_name,omitempty" yaml:"module_name"` + MainAssetId uint64 `protobuf:"varint,3,opt,name=main_asset_id,json=mainAssetId,proto3" json:"main_asset_id,omitempty" yaml:"main_asset_id"` + FirstBridgedAssetID uint64 `protobuf:"varint,4,opt,name=first_bridged_asset_id,json=firstBridgedAssetId,proto3" json:"first_bridged_asset_id,omitempty" yaml:"first_bridged_asset_id"` + SecondBridgedAssetID uint64 `protobuf:"varint,5,opt,name=second_bridged_asset_id,json=secondBridgedAssetId,proto3" json:"second_bridged_asset_id,omitempty" yaml:"second_bridged_asset_id"` + CPoolName string `protobuf:"bytes,6,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` + ReserveFunds uint64 `protobuf:"varint,7,opt,name=reserve_funds,json=reserveFunds,proto3" json:"reserve_funds,omitempty" yaml:"reserve_funds"` + AssetData []AssetDataPoolMappingOld `protobuf:"bytes,8,rep,name=asset_data,json=assetData,proto3" json:"asset_data" yaml:"asset_data"` +} + +func (m *PoolOld) Reset() { *m = PoolOld{} } +func (m *PoolOld) String() string { return proto.CompactTextString(m) } +func (*PoolOld) ProtoMessage() {} +func (*PoolOld) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{2} +} +func (m *PoolOld) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PoolOld) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PoolOld.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PoolOld) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolOld.Merge(m, src) +} +func (m *PoolOld) XXX_Size() int { + return m.Size() +} +func (m *PoolOld) XXX_DiscardUnknown() { + xxx_messageInfo_PoolOld.DiscardUnknown(m) +} + +var xxx_messageInfo_PoolOld proto.InternalMessageInfo + +func (m *PoolOld) GetPoolID() uint64 { + if m != nil { + return m.PoolID + } + return 0 +} + +func (m *PoolOld) GetModuleName() string { + if m != nil { + return m.ModuleName + } + return "" +} + +func (m *PoolOld) GetMainAssetId() uint64 { + if m != nil { + return m.MainAssetId + } + return 0 +} + +func (m *PoolOld) GetFirstBridgedAssetID() uint64 { + if m != nil { + return m.FirstBridgedAssetID + } + return 0 +} + +func (m *PoolOld) GetSecondBridgedAssetID() uint64 { + if m != nil { + return m.SecondBridgedAssetID + } + return 0 +} + +func (m *PoolOld) GetCPoolName() string { + if m != nil { + return m.CPoolName + } + return "" +} + +func (m *PoolOld) GetReserveFunds() uint64 { + if m != nil { + return m.ReserveFunds + } + return 0 +} + +func (m *PoolOld) GetAssetData() []AssetDataPoolMappingOld { + if m != nil { + return m.AssetData + } + return nil +} + +type AssetDataPoolMappingOld struct { + AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + IsBridged bool `protobuf:"varint,2,opt,name=is_bridged,json=isBridged,proto3" json:"is_bridged,omitempty" yaml:"is_bridged"` +} + +func (m *AssetDataPoolMappingOld) Reset() { *m = AssetDataPoolMappingOld{} } +func (m *AssetDataPoolMappingOld) String() string { return proto.CompactTextString(m) } +func (*AssetDataPoolMappingOld) ProtoMessage() {} +func (*AssetDataPoolMappingOld) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{3} +} +func (m *AssetDataPoolMappingOld) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AssetDataPoolMappingOld) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AssetDataPoolMappingOld.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AssetDataPoolMappingOld) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetDataPoolMappingOld.Merge(m, src) +} +func (m *AssetDataPoolMappingOld) XXX_Size() int { + return m.Size() +} +func (m *AssetDataPoolMappingOld) XXX_DiscardUnknown() { + xxx_messageInfo_AssetDataPoolMappingOld.DiscardUnknown(m) +} + +var xxx_messageInfo_AssetDataPoolMappingOld proto.InternalMessageInfo + +func (m *AssetDataPoolMappingOld) GetAssetID() uint64 { + if m != nil { + return m.AssetID + } + return 0 +} + +func (m *AssetDataPoolMappingOld) GetIsBridged() bool { + if m != nil { + return m.IsBridged + } + return false +} + +func init() { + proto.RegisterType((*LendAssetOld)(nil), "comdex.lend.v1beta1.LendAssetOld") + proto.RegisterType((*BorrowAssetOld)(nil), "comdex.lend.v1beta1.BorrowAssetOld") + proto.RegisterType((*PoolOld)(nil), "comdex.lend.v1beta1.PoolOld") + proto.RegisterType((*AssetDataPoolMappingOld)(nil), "comdex.lend.v1beta1.AssetDataPoolMappingOld") +} + +func init() { proto.RegisterFile("comdex/lend/v1beta1/lend.proto", fileDescriptor_b87bb4bef8334ddd) } + +var fileDescriptor_b87bb4bef8334ddd = []byte{ + // 1297 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0x4d, 0x6f, 0x1b, 0xc5, + 0x1b, 0xcf, 0xb6, 0x79, 0xb1, 0xc7, 0x4e, 0x9a, 0x8c, 0xdd, 0x7f, 0xdd, 0xa4, 0xf5, 0xe6, 0x3f, + 0x42, 0x6d, 0x0e, 0x74, 0xad, 0x16, 0x90, 0xa0, 0x12, 0x12, 0x71, 0xd3, 0x82, 0x69, 0xd3, 0xa2, + 0x69, 0x4f, 0x1c, 0x58, 0x8d, 0x3d, 0x13, 0x77, 0xc5, 0xee, 0xce, 0xb2, 0xbb, 0x4e, 0x5b, 0x40, + 0xc0, 0x19, 0x09, 0xa9, 0x77, 0x3e, 0x03, 0x47, 0xbe, 0x43, 0x8f, 0x3d, 0x22, 0x0e, 0x0b, 0xda, + 0x7e, 0x03, 0x1f, 0x39, 0xa1, 0x79, 0xd9, 0xb7, 0x38, 0xb4, 0x75, 0x10, 0x70, 0xb2, 0xe7, 0x79, + 0xf9, 0x3d, 0xcf, 0x3c, 0xf3, 0xdb, 0xdf, 0xec, 0x82, 0xee, 0x88, 0x7b, 0x94, 0x3d, 0xee, 0xb9, + 0xcc, 0xa7, 0xbd, 0xc3, 0xab, 0x43, 0x16, 0x93, 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0x9a, 0xac, 0x7c, 0x67, 0xee, 0xca, 0x9b, 0x7a, 0xda, 0xb3, 0x90, 0x08, 0x6f, + 0xe4, 0xd6, 0x07, 0xbc, 0x2f, 0x6d, 0xf0, 0x4b, 0x00, 0x43, 0xf6, 0x88, 0x84, 0xd4, 0xde, 0x1d, + 0x8d, 0x26, 0xde, 0xc4, 0x15, 0xbd, 0x75, 0xea, 0xb2, 0xf8, 0xed, 0xb9, 0x8b, 0x9f, 0x57, 0xc5, + 0x35, 0x22, 0x29, 0x10, 0x11, 0xde, 0x50, 0xc6, 0x52, 0x15, 0x78, 0x15, 0x2c, 0x93, 0x20, 0x10, + 0x64, 0x05, 0x92, 0xac, 0x9b, 0x69, 0x62, 0x2e, 0xed, 0x06, 0x81, 0xe4, 0xea, 0xaa, 0xde, 0x87, + 0x0c, 0x40, 0x78, 0x89, 0x04, 0xc1, 0x80, 0xc2, 0x87, 0xa0, 0x39, 0x76, 0xf9, 0x90, 0xb8, 0xb6, + 0xe3, 0x53, 0xf6, 0xb8, 0xd3, 0x90, 0x8d, 0xde, 0x9c, 0xa3, 0xd1, 0x3d, 0x36, 0x2a, 0x28, 0x51, + 0xc6, 0x42, 0xb8, 0xa1, 0x96, 0x03, 0xb1, 0x82, 0x8f, 0xc1, 0x59, 0x97, 0x44, 0xe2, 0xcc, 0x62, + 0x16, 0x92, 0x51, 0xec, 0x70, 0x5f, 0xf1, 0xae, 0xf9, 0x4a, 0xde, 0xed, 0x68, 0xde, 0x5d, 0xd0, + 0xbc, 0x3b, 0x0e, 0x46, 0x11, 0xb0, 0x25, 0x7c, 0x83, 0xc2, 0x25, 0x89, 0xb8, 0x0b, 0xc0, 0x48, + 0x3e, 0xa2, 0x3e, 0xf1, 0x58, 0x67, 0x55, 0xee, 0x10, 0xa5, 0x89, 0x59, 0xbf, 0x21, 0x1e, 0xe4, + 0xbb, 0xc4, 0x63, 0x85, 0x84, 0x14, 0x81, 0x08, 0xd7, 0xe5, 0x42, 0xf8, 0xd1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ec, 0x25, 0x85, 0x6b, 0xfd, 0xb3, 0x45, 0x33, 0x85, 0x0f, 0xe1, 0xba, 0x13, 0xe9, 0xa3, 0xe8, + 0x7f, 0xf4, 0x2c, 0xed, 0x1a, 0xcf, 0xd3, 0xae, 0xf1, 0x7b, 0xda, 0x35, 0x9e, 0xbe, 0xe8, 0x2e, + 0x3c, 0x7f, 0xd1, 0x5d, 0xf8, 0xe5, 0x45, 0x77, 0xe1, 0x53, 0xab, 0x22, 0x37, 0x62, 0x22, 0x57, + 0xf8, 0xc1, 0x81, 0x33, 0x72, 0x88, 0xab, 0xd7, 0x3d, 0xfd, 0x1d, 0x2b, 0xa5, 0x67, 0xb8, 0x2c, + 0xc5, 0xe1, 0xad, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x09, 0x9b, 0xcf, 0xc1, 0xe3, 0x0e, 0x00, + 0x00, +} + +func (m *LendAssetOld) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LendAssetOld) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LendAssetOld) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CPoolName) > 0 { + i -= len(m.CPoolName) + copy(dAtA[i:], m.CPoolName) + i = encodeVarintLend(dAtA, i, uint64(len(m.CPoolName))) + i-- + dAtA[i] = 0x6a + } + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastInteractionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintLend(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x62 + { + size := m.GlobalIndex.Size() + i -= size + if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + if m.AppID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AppID)) + i-- + dAtA[i] = 0x50 + } + { + size := m.Reward_Accumulated.Size() + i -= size + if _, err := m.Reward_Accumulated.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + { + size := m.AvailableToBorrow.Size() + i -= size + if _, err := m.AvailableToBorrow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.UpdatedAmountIn.Size() + i -= size + if _, err := m.UpdatedAmountIn.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LendingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LendingTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintLend(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x32 + { + size, err := m.AmountIn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintLend(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x22 + } + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x18 + } + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x10 + } + if m.ID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BorrowAssetOld) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *BorrowAssetOld) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BorrowAssetOld) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CPoolName) > 0 { + i -= len(m.CPoolName) + copy(dAtA[i:], m.CPoolName) + i = encodeVarintLend(dAtA, i, uint64(len(m.CPoolName))) + i-- + dAtA[i] = 0x7a + } + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastInteractionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintLend(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x72 + { + size := m.ReserveGlobalIndex.Size() + i -= size + if _, err := m.ReserveGlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + { + size := m.GlobalIndex.Size() + i -= size + if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + { + size := m.Interest_Accumulated.Size() + i -= size + if _, err := m.Interest_Accumulated.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size := m.UpdatedAmountOut.Size() + i -= size + if _, err := m.UpdatedAmountOut.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + { + size := m.StableBorrowRate.Size() + i -= size + if _, err := m.StableBorrowRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.BorrowingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.BorrowingTime):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintLend(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x42 + { + size, err := m.BridgedAssetAmount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size, err := m.AmountOut.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size, err := m.AmountIn.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if m.PairID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PairID)) + i-- + dAtA[i] = 0x20 + } + if m.IsStableBorrow { + i-- + if m.IsStableBorrow { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if m.LendingID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.LendingID)) + i-- + dAtA[i] = 0x10 + } + if m.ID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PoolOld) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PoolOld) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolOld) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetData) > 0 { + for iNdEx := len(m.AssetData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if m.ReserveFunds != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ReserveFunds)) + i-- + dAtA[i] = 0x38 + } + if len(m.CPoolName) > 0 { + i -= len(m.CPoolName) + copy(dAtA[i:], m.CPoolName) + i = encodeVarintLend(dAtA, i, uint64(len(m.CPoolName))) + i-- + dAtA[i] = 0x32 + } + if m.SecondBridgedAssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.SecondBridgedAssetID)) + i-- + dAtA[i] = 0x28 + } + if m.FirstBridgedAssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.FirstBridgedAssetID)) + i-- + dAtA[i] = 0x20 + } + if m.MainAssetId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.MainAssetId)) + i-- + dAtA[i] = 0x18 + } + if len(m.ModuleName) > 0 { + i -= len(m.ModuleName) + copy(dAtA[i:], m.ModuleName) + i = encodeVarintLend(dAtA, i, uint64(len(m.ModuleName))) + i-- + dAtA[i] = 0x12 + } + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *AssetDataPoolMappingOld) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AssetDataPoolMappingOld) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetDataPoolMappingOld) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsBridged { + i-- + if m.IsBridged { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintLend(dAtA []byte, offset int, v uint64) int { + offset -= sovLend(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *LendAssetOld) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovLend(uint64(m.ID)) + } + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) + } + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + l = m.AmountIn.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LendingTime) + n += 1 + l + sovLend(uint64(l)) + l = m.UpdatedAmountIn.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.AvailableToBorrow.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Reward_Accumulated.Size() + n += 1 + l + sovLend(uint64(l)) + if m.AppID != 0 { + n += 1 + sovLend(uint64(m.AppID)) + } + l = m.GlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime) + n += 1 + l + sovLend(uint64(l)) + l = len(m.CPoolName) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + return n +} + +func (m *BorrowAssetOld) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ID != 0 { + n += 1 + sovLend(uint64(m.ID)) + } + if m.LendingID != 0 { + n += 1 + sovLend(uint64(m.LendingID)) + } + if m.IsStableBorrow { + n += 2 + } + if m.PairID != 0 { + n += 1 + sovLend(uint64(m.PairID)) + } + l = m.AmountIn.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.AmountOut.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.BridgedAssetAmount.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.BorrowingTime) + n += 1 + l + sovLend(uint64(l)) + l = m.StableBorrowRate.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.UpdatedAmountOut.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Interest_Accumulated.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.GlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.ReserveGlobalIndex.Size() + n += 1 + l + sovLend(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastInteractionTime) + n += 1 + l + sovLend(uint64(l)) + l = len(m.CPoolName) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + return n +} + +func (m *PoolOld) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) + } + l = len(m.ModuleName) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + if m.MainAssetId != 0 { + n += 1 + sovLend(uint64(m.MainAssetId)) + } + if m.FirstBridgedAssetID != 0 { + n += 1 + sovLend(uint64(m.FirstBridgedAssetID)) + } + if m.SecondBridgedAssetID != 0 { + n += 1 + sovLend(uint64(m.SecondBridgedAssetID)) + } + l = len(m.CPoolName) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + if m.ReserveFunds != 0 { + n += 1 + sovLend(uint64(m.ReserveFunds)) + } + if len(m.AssetData) > 0 { + for _, e := range m.AssetData { + l = e.Size() + n += 1 + l + sovLend(uint64(l)) + } + } + return n +} + +func (m *AssetDataPoolMappingOld) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) + } + if m.IsBridged { + n += 2 + } + return n +} + +func sovLend(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozLend(x uint64) (n int) { + return sovLend(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *LendAssetOld) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LendAssetOld: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LendAssetOld: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) + } + m.AssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + } + m.PoolID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountIn", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LendingTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LendingTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAmountIn", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UpdatedAmountIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailableToBorrow", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvailableToBorrow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Reward_Accumulated", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Reward_Accumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AppID", wireType) + } + m.AppID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastInteractionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CPoolName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BorrowAssetOld) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: BorrowAssetOld: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BorrowAssetOld: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) + } + m.ID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LendingID", wireType) + } + m.LendingID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LendingID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsStableBorrow", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsStableBorrow = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) + } + m.PairID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PairID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountIn", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountIn.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountOut", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AmountOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BridgedAssetAmount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.BridgedAssetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowingTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.BorrowingTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StableBorrowRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StableBorrowRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAmountOut", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UpdatedAmountOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Interest_Accumulated", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Interest_Accumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveGlobalIndex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ReserveGlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastInteractionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 15: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CPoolName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PoolOld) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PoolOld: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolOld: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + } + m.PoolID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModuleName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MainAssetId", wireType) + } + m.MainAssetId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MainAssetId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstBridgedAssetID", wireType) + } + m.FirstBridgedAssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FirstBridgedAssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SecondBridgedAssetID", wireType) + } + m.SecondBridgedAssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SecondBridgedAssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CPoolName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveFunds", wireType) + } + m.ReserveFunds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReserveFunds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetData = append(m.AssetData, AssetDataPoolMappingOld{}) + if err := m.AssetData[len(m.AssetData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *AssetDataPoolMappingOld) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AssetDataPoolMappingOld: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AssetDataPoolMappingOld: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) + } + m.AssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsBridged", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsBridged = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipLend(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLend + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLend + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowLend + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthLend + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupLend + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthLend + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthLend = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowLend = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupLend = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/lend/module.go b/x/lend/module.go index 1392a0c8c..27a91bdf5 100644 --- a/x/lend/module.go +++ b/x/lend/module.go @@ -139,6 +139,13 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { + migrator := keeper.NewMigrator(am.keeper) + + // register v2 -> v3 migration + if err := cfg.RegisterMigration(types.ModuleName, 2, migrator.Migrate2to3); err != nil { + panic(fmt.Errorf("failed to migrate %s to v3: %w", types.ModuleName, err)) + } + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQueryServer(am.keeper)) } @@ -164,12 +171,10 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. -func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - BeginBlocker(ctx, req, am.keeper) -} +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {} // EndBlock executes all ABCI EndBlock logic respective to the capability module. It // returns no validator updates. diff --git a/x/lend/types/codec.go b/x/lend/types/codec.go index 27f82c242..55598165f 100644 --- a/x/lend/types/codec.go +++ b/x/lend/types/codec.go @@ -22,7 +22,6 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgBorrowAlternate{}, "comdex/lend/MsgBorrowAlternate", nil) cdc.RegisterConcrete(&MsgFundModuleAccounts{}, "comdex/lend/MsgFundModuleAccounts", nil) cdc.RegisterConcrete(&LendPairsProposal{}, "comdex/lend/LendPairsProposal", nil) - cdc.RegisterConcrete(&UpdateLendPairsProposal{}, "comdex/lend/UpdateLendPairsProposal", nil) cdc.RegisterConcrete(&AddPoolsProposal{}, "comdex/lend/AddPoolsProposal", nil) cdc.RegisterConcrete(&AddAssetToPairProposal{}, "comdex/lend/AddAssetToPairProposal", nil) cdc.RegisterConcrete(&AddAssetRatesParams{}, "comdex/lend/AddAssetRatesParams", nil) @@ -34,7 +33,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*govtypes.Content)(nil), &LendPairsProposal{}, - &UpdateLendPairsProposal{}, &AddPoolsProposal{}, &AddAssetToPairProposal{}, &AddAssetRatesParams{}, diff --git a/x/lend/types/errors.go b/x/lend/types/errors.go index af255e281..c068b8b37 100644 --- a/x/lend/types/errors.go +++ b/x/lend/types/errors.go @@ -59,4 +59,5 @@ var ( ErrorSupplyCapExceeds = sdkerrors.Register(ModuleName, 1166, "Supply cap exceeds") ErrorBorrowPosLiquidated = sdkerrors.Register(ModuleName, 1167, "Borrow Position Liquidated") ErrorInsufficientCTokensForRewards = sdkerrors.Register(ModuleName, 1168, "Insufficient CTokens For Rewards in the cPool") + ErrorAssetRatesParamsAlreadyExists = sdkerrors.Register(ModuleName, 1169, "Asset Rates Params already exists") ) diff --git a/x/lend/types/genesis.go b/x/lend/types/genesis.go index f8950844c..d413dcbef 100644 --- a/x/lend/types/genesis.go +++ b/x/lend/types/genesis.go @@ -1,52 +1,36 @@ package types -func NewGenesisState() *GenesisState { +func NewGenesisState(borrowAsset []BorrowAsset, borrowInterestTracker []BorrowInterestTracker, lendAsset []LendAsset, pool []Pool, assetToPairMapping []AssetToPairMapping, poolAssetLBMapping []PoolAssetLBMapping, lendRewardsTracker []LendRewardsTracker, userAssetLendBorrowMapping []UserAssetLendBorrowMapping, reserveBuybackAssetData []ReserveBuybackAssetData, extendedPair []Extended_Pair, auctionParams []AuctionParams, assetRatesParams []AssetRatesParams) *GenesisState { return &GenesisState{ - // BorrowAsset: borrowAsset, - // UserBorrowIdMapping: userBorrowIDMapping, - // BorrowIdByOwnerAndPoolMapping: borrowIDByOwnerAndPoolMapping, - // BorrowMapping: borrowMapping, - // LendAsset: lendAsset, - // Pool: pool, - // AssetToPairMapping: assetToPairMapping, - // UserLendIdMapping: userLendIdMapping, - // LendIdByOwnerAndPoolMapping: lendIdByOwnerAndPoolMapping, - // LendIdToBorrowIdMapping: lendIdToBorrowIdMapping, - // AssetStats: assetStats, - // LendMapping: lendMapping, - // UserDepositStats: userdepositStats, - // ReserveDepositStats: reservedepositStats, - // BuyBackDepositStats: buybackdepositStats, - // BorrowDepositStats: borrowdepositStats, - // Extended_Pair: extended_Pair, - // AssetRatesStats: assetRatesStats, - // AuctionParams: auctionParams, - // Params: params, + BorrowAsset: borrowAsset, + BorrowInterestTracker: borrowInterestTracker, + LendAsset: lendAsset, + Pool: pool, + AssetToPairMapping: assetToPairMapping, + PoolAssetLBMapping: poolAssetLBMapping, + LendRewardsTracker: lendRewardsTracker, + UserAssetLendBorrowMapping: userAssetLendBorrowMapping, + ReserveBuybackAssetData: reserveBuybackAssetData, + Extended_Pair: extendedPair, + AuctionParams: auctionParams, + AssetRatesParams: assetRatesParams, } } func DefaultGenesisState() *GenesisState { return NewGenesisState( - // []BorrowAsset{}, - // []UserBorrowIdMapping{}, - // []BorrowIdByOwnerAndPoolMapping{}, - // BorrowMapping{}, - // []LendAsset{}, - // []Pool{}, - // []AssetToPairMapping{}, - // []UserLendIdMapping{}, - // []LendIdByOwnerAndPoolMapping{}, - // []LendIdToBorrowIdMapping{}, - // []AssetStats{}, - // LendMapping{}, - // DepositStats{}, - // DepositStats{}, - // DepositStats{}, - // DepositStats{}, - // []Extended_Pair{}, - // []AssetRatesStats{}, - // []AuctionParams{}, - // DefaultParams(), + []BorrowAsset{}, + []BorrowInterestTracker{}, + []LendAsset{}, + []Pool{}, + []AssetToPairMapping{}, + []PoolAssetLBMapping{}, + []LendRewardsTracker{}, + []UserAssetLendBorrowMapping{}, + []ReserveBuybackAssetData{}, + []Extended_Pair{}, + []AuctionParams{}, + []AssetRatesParams{}, ) } diff --git a/x/lend/types/genesis.pb.go b/x/lend/types/genesis.pb.go index f54089a29..475a22cee 100644 --- a/x/lend/types/genesis.pb.go +++ b/x/lend/types/genesis.pb.go @@ -24,6 +24,18 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type GenesisState struct { + BorrowAsset []BorrowAsset `protobuf:"bytes,1,rep,name=borrowAsset,proto3" json:"borrowAsset" yaml:"borrowAsset"` + BorrowInterestTracker []BorrowInterestTracker `protobuf:"bytes,2,rep,name=borrowInterestTracker,proto3" json:"borrowInterestTracker" yaml:"borrowInterestTracker"` + LendAsset []LendAsset `protobuf:"bytes,3,rep,name=lendAsset,proto3" json:"lendAsset" yaml:"lendAsset"` + Pool []Pool `protobuf:"bytes,4,rep,name=pool,proto3" json:"pool" yaml:"pool"` + AssetToPairMapping []AssetToPairMapping `protobuf:"bytes,5,rep,name=assetToPairMapping,proto3" json:"assetToPairMapping" yaml:"assetToPairMapping"` + PoolAssetLBMapping []PoolAssetLBMapping `protobuf:"bytes,6,rep,name=poolAssetLBMapping,proto3" json:"poolAssetLBMapping" yaml:"poolAssetLBMapping"` + LendRewardsTracker []LendRewardsTracker `protobuf:"bytes,7,rep,name=lendRewardsTracker,proto3" json:"lendRewardsTracker" yaml:"lendRewardsTracker"` + UserAssetLendBorrowMapping []UserAssetLendBorrowMapping `protobuf:"bytes,8,rep,name=userAssetLendBorrowMapping,proto3" json:"userAssetLendBorrowMapping" yaml:"userAssetLendBorrowMapping"` + ReserveBuybackAssetData []ReserveBuybackAssetData `protobuf:"bytes,9,rep,name=reserveBuybackAssetData,proto3" json:"reserveBuybackAssetData" yaml:"reserveBuybackAssetData"` + Extended_Pair []Extended_Pair `protobuf:"bytes,10,rep,name=extended_Pair,json=extendedPair,proto3" json:"extended_Pair" yaml:"extended_Pair"` + AuctionParams []AuctionParams `protobuf:"bytes,11,rep,name=auctionParams,proto3" json:"auctionParams" yaml:"auctionParams"` + AssetRatesParams []AssetRatesParams `protobuf:"bytes,12,rep,name=assetRatesParams,proto3" json:"assetRatesParams" yaml:"assetRatesParams"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -59,6 +71,90 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetBorrowAsset() []BorrowAsset { + if m != nil { + return m.BorrowAsset + } + return nil +} + +func (m *GenesisState) GetBorrowInterestTracker() []BorrowInterestTracker { + if m != nil { + return m.BorrowInterestTracker + } + return nil +} + +func (m *GenesisState) GetLendAsset() []LendAsset { + if m != nil { + return m.LendAsset + } + return nil +} + +func (m *GenesisState) GetPool() []Pool { + if m != nil { + return m.Pool + } + return nil +} + +func (m *GenesisState) GetAssetToPairMapping() []AssetToPairMapping { + if m != nil { + return m.AssetToPairMapping + } + return nil +} + +func (m *GenesisState) GetPoolAssetLBMapping() []PoolAssetLBMapping { + if m != nil { + return m.PoolAssetLBMapping + } + return nil +} + +func (m *GenesisState) GetLendRewardsTracker() []LendRewardsTracker { + if m != nil { + return m.LendRewardsTracker + } + return nil +} + +func (m *GenesisState) GetUserAssetLendBorrowMapping() []UserAssetLendBorrowMapping { + if m != nil { + return m.UserAssetLendBorrowMapping + } + return nil +} + +func (m *GenesisState) GetReserveBuybackAssetData() []ReserveBuybackAssetData { + if m != nil { + return m.ReserveBuybackAssetData + } + return nil +} + +func (m *GenesisState) GetExtended_Pair() []Extended_Pair { + if m != nil { + return m.Extended_Pair + } + return nil +} + +func (m *GenesisState) GetAuctionParams() []AuctionParams { + if m != nil { + return m.AuctionParams + } + return nil +} + +func (m *GenesisState) GetAssetRatesParams() []AssetRatesParams { + if m != nil { + return m.AssetRatesParams + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "comdex.lend.v1beta1.GenesisState") } @@ -66,19 +162,45 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/genesis.proto", fileDescriptor_4df703d992154ae9) } var fileDescriptor_4df703d992154ae9 = []byte{ - // 179 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0xcf, 0x4d, - 0x49, 0xad, 0xd0, 0xcf, 0x49, 0xcd, 0x4b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, - 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, - 0x28, 0xd1, 0x03, 0x29, 0xd1, 0x83, 0x2a, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, - 0x83, 0x58, 0x10, 0xa5, 0x52, 0x72, 0xd8, 0x4c, 0x03, 0xeb, 0x83, 0xc8, 0x2b, 0x60, 0x93, 0x2f, - 0x48, 0x2c, 0x4a, 0xcc, 0x85, 0x5a, 0xa6, 0xc4, 0xc7, 0xc5, 0xe3, 0x0e, 0xb1, 0x3d, 0xb8, 0x24, - 0xb1, 0x24, 0xd5, 0xc9, 0xe3, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, - 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xf4, - 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x21, 0xc6, 0xea, 0xe6, 0xa7, - 0xa5, 0x65, 0x26, 0x67, 0x26, 0xe6, 0x40, 0xf9, 0xfa, 0x50, 0x8b, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, - 0x93, 0xd8, 0xc0, 0x16, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x38, 0x41, 0xc9, 0xe9, 0xf2, - 0x00, 0x00, 0x00, + // 608 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x1c, 0x86, 0x1b, 0x36, 0x06, 0x73, 0x37, 0x69, 0xf2, 0x86, 0x96, 0x55, 0x53, 0xb6, 0x5a, 0xfc, + 0x9b, 0x04, 0x89, 0x06, 0x37, 0x6e, 0xb5, 0x40, 0x80, 0x34, 0xa4, 0xca, 0x0c, 0x0e, 0x1c, 0xa8, + 0xdc, 0xc6, 0x2d, 0xd1, 0xda, 0x38, 0x72, 0xdc, 0x6d, 0x45, 0x7c, 0x00, 0x4e, 0x88, 0x33, 0x9f, + 0x68, 0xc7, 0x1d, 0x39, 0x4d, 0xa8, 0xfd, 0x06, 0x9c, 0x39, 0xa0, 0xd8, 0xee, 0x96, 0x36, 0x4e, + 0x6f, 0xb5, 0xfc, 0xfe, 0x9e, 0xe7, 0x6d, 0x6b, 0x1b, 0xd4, 0x3b, 0x7c, 0x10, 0xb2, 0xf3, 0xa0, + 0xcf, 0xe2, 0x30, 0x38, 0x3d, 0x6c, 0x33, 0x49, 0x0f, 0x83, 0x1e, 0x8b, 0x59, 0x1a, 0xa5, 0x7e, + 0x22, 0xb8, 0xe4, 0x70, 0x53, 0x47, 0xfc, 0x2c, 0xe2, 0x9b, 0x48, 0x6d, 0xab, 0xc7, 0x7b, 0x5c, + 0xed, 0x07, 0xd9, 0x27, 0x1d, 0xad, 0x79, 0x36, 0x9a, 0x9a, 0xd3, 0xfb, 0xfb, 0xb6, 0xfd, 0x84, + 0x0a, 0x3a, 0x30, 0x32, 0xf4, 0x0f, 0x80, 0xb5, 0xd7, 0x5a, 0xff, 0x5e, 0x52, 0xc9, 0xe0, 0x67, + 0x50, 0x6d, 0x73, 0x21, 0xf8,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, 0x76, 0xee, 0xba, 0xe5, 0xf6, 0x11, 0x29, 0xf0, 0xf1, 0x9b, 0x8b, 0xb1, 0xe7, + 0x5c, 0x8e, 0x3d, 0xe7, 0xcf, 0xd8, 0x73, 0x7e, 0x4e, 0xbc, 0xca, 0xe5, 0xc4, 0xab, 0xfc, 0x9e, + 0x78, 0x95, 0x4f, 0x7e, 0x2f, 0x92, 0x5f, 0x86, 0xed, 0xcc, 0x1c, 0x68, 0xfb, 0x53, 0xde, 0xed, + 0x46, 0x9d, 0x88, 0xf6, 0xcd, 0x3a, 0x30, 0xef, 0xba, 0x1c, 0x25, 0x2c, 0x6d, 0xaf, 0xa8, 0xf7, + 0xfc, 0xf9, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x01, 0x1e, 0x9c, 0x61, 0x06, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -101,6 +223,174 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AssetRatesParams) > 0 { + for iNdEx := len(m.AssetRatesParams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetRatesParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + } + if len(m.AuctionParams) > 0 { + for iNdEx := len(m.AuctionParams) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AuctionParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } + if len(m.Extended_Pair) > 0 { + for iNdEx := len(m.Extended_Pair) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Extended_Pair[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.ReserveBuybackAssetData) > 0 { + for iNdEx := len(m.ReserveBuybackAssetData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ReserveBuybackAssetData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } + if len(m.UserAssetLendBorrowMapping) > 0 { + for iNdEx := len(m.UserAssetLendBorrowMapping) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.UserAssetLendBorrowMapping[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } + if len(m.LendRewardsTracker) > 0 { + for iNdEx := len(m.LendRewardsTracker) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LendRewardsTracker[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } + if len(m.PoolAssetLBMapping) > 0 { + for iNdEx := len(m.PoolAssetLBMapping) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PoolAssetLBMapping[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.AssetToPairMapping) > 0 { + for iNdEx := len(m.AssetToPairMapping) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AssetToPairMapping[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.Pool) > 0 { + for iNdEx := len(m.Pool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pool[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.LendAsset) > 0 { + for iNdEx := len(m.LendAsset) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LendAsset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.BorrowInterestTracker) > 0 { + for iNdEx := len(m.BorrowInterestTracker) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BorrowInterestTracker[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.BorrowAsset) > 0 { + for iNdEx := len(m.BorrowAsset) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BorrowAsset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } return len(dAtA) - i, nil } @@ -121,6 +411,78 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + if len(m.BorrowAsset) > 0 { + for _, e := range m.BorrowAsset { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.BorrowInterestTracker) > 0 { + for _, e := range m.BorrowInterestTracker { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LendAsset) > 0 { + for _, e := range m.LendAsset { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Pool) > 0 { + for _, e := range m.Pool { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AssetToPairMapping) > 0 { + for _, e := range m.AssetToPairMapping { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PoolAssetLBMapping) > 0 { + for _, e := range m.PoolAssetLBMapping { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LendRewardsTracker) > 0 { + for _, e := range m.LendRewardsTracker { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.UserAssetLendBorrowMapping) > 0 { + for _, e := range m.UserAssetLendBorrowMapping { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ReserveBuybackAssetData) > 0 { + for _, e := range m.ReserveBuybackAssetData { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Extended_Pair) > 0 { + for _, e := range m.Extended_Pair { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AuctionParams) > 0 { + for _, e := range m.AuctionParams { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.AssetRatesParams) > 0 { + for _, e := range m.AssetRatesParams { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -159,6 +521,414 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowAsset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BorrowAsset = append(m.BorrowAsset, BorrowAsset{}) + if err := m.BorrowAsset[len(m.BorrowAsset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowInterestTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BorrowInterestTracker = append(m.BorrowInterestTracker, BorrowInterestTracker{}) + if err := m.BorrowInterestTracker[len(m.BorrowInterestTracker)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LendAsset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LendAsset = append(m.LendAsset, LendAsset{}) + if err := m.LendAsset[len(m.LendAsset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pool = append(m.Pool, Pool{}) + if err := m.Pool[len(m.Pool)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetToPairMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetToPairMapping = append(m.AssetToPairMapping, AssetToPairMapping{}) + if err := m.AssetToPairMapping[len(m.AssetToPairMapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolAssetLBMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PoolAssetLBMapping = append(m.PoolAssetLBMapping, PoolAssetLBMapping{}) + if err := m.PoolAssetLBMapping[len(m.PoolAssetLBMapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LendRewardsTracker", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LendRewardsTracker = append(m.LendRewardsTracker, LendRewardsTracker{}) + if err := m.LendRewardsTracker[len(m.LendRewardsTracker)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserAssetLendBorrowMapping", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserAssetLendBorrowMapping = append(m.UserAssetLendBorrowMapping, UserAssetLendBorrowMapping{}) + if err := m.UserAssetLendBorrowMapping[len(m.UserAssetLendBorrowMapping)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReserveBuybackAssetData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReserveBuybackAssetData = append(m.ReserveBuybackAssetData, ReserveBuybackAssetData{}) + if err := m.ReserveBuybackAssetData[len(m.ReserveBuybackAssetData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Extended_Pair", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Extended_Pair = append(m.Extended_Pair, Extended_Pair{}) + if err := m.Extended_Pair[len(m.Extended_Pair)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuctionParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuctionParams = append(m.AuctionParams, AuctionParams{}) + if err := m.AuctionParams[len(m.AuctionParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesParams", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetRatesParams = append(m.AssetRatesParams, AssetRatesParams{}) + if err := m.AssetRatesParams[len(m.AssetRatesParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/lend/types/gov.go b/x/lend/types/gov.go index ea59b898d..2cbe4e271 100644 --- a/x/lend/types/gov.go +++ b/x/lend/types/gov.go @@ -6,7 +6,6 @@ import ( var ( ProposalAddLendPairs = "ProposalAddLendPairs" - ProposalUpdateLendPairs = "ProposalUpdateLendPairs" ProposalAddPool = "ProposalAddPool" ProposalAddAssetToPair = "ProposalAddAssetToPair" ProposalAddAssetRatesParams = "ProposalAddAssetRatesParams" @@ -16,8 +15,6 @@ var ( func init() { govtypes.RegisterProposalType(ProposalAddLendPairs) govtypes.RegisterProposalTypeCodec(&LendPairsProposal{}, "comdex/AddLendPairsProposal") - govtypes.RegisterProposalType(ProposalUpdateLendPairs) - govtypes.RegisterProposalTypeCodec(&UpdateLendPairsProposal{}, "comdex/UpdateLendPairsProposal") govtypes.RegisterProposalType(ProposalAddPool) govtypes.RegisterProposalTypeCodec(&AddPoolsProposal{}, "comdex/AddPoolsProposal") govtypes.RegisterProposalType(ProposalAddAssetToPair) @@ -30,7 +27,6 @@ func init() { var ( _ govtypes.Content = &LendPairsProposal{} - _ govtypes.Content = &UpdateLendPairsProposal{} _ govtypes.Content = &AddPoolsProposal{} _ govtypes.Content = &AddAssetToPairProposal{} _ govtypes.Content = &AddAssetRatesParams{} @@ -62,31 +58,6 @@ func (p *LendPairsProposal) ValidateBasic() error { return nil } -func NewUpdateLendPairsProposal(title, description string, pairs Extended_Pair) govtypes.Content { - return &UpdateLendPairsProposal{ - Title: title, - Description: description, - Pairs: pairs, - } -} - -func (p *UpdateLendPairsProposal) ProposalRoute() string { return RouterKey } - -func (p *UpdateLendPairsProposal) ProposalType() string { return ProposalUpdateLendPairs } - -func (p *UpdateLendPairsProposal) ValidateBasic() error { - err := govtypes.ValidateAbstract(p) - if err != nil { - return err - } - - if err := p.Pairs.Validate(); err != nil { - return err - } - - return nil -} - func NewAddPoolProposal(title, description string, pool Pool) govtypes.Content { return &AddPoolsProposal{ Title: title, diff --git a/x/lend/types/gov.pb.go b/x/lend/types/gov.pb.go index 7d6ab5b01..5fbdb358e 100644 --- a/x/lend/types/gov.pb.go +++ b/x/lend/types/gov.pb.go @@ -143,66 +143,6 @@ func (m *AddPoolsProposal) GetPool() Pool { return Pool{} } -type UpdateLendPairsProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - Pairs Extended_Pair `protobuf:"bytes,3,opt,name=pairs,proto3" json:"pairs"` -} - -func (m *UpdateLendPairsProposal) Reset() { *m = UpdateLendPairsProposal{} } -func (m *UpdateLendPairsProposal) String() string { return proto.CompactTextString(m) } -func (*UpdateLendPairsProposal) ProtoMessage() {} -func (*UpdateLendPairsProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_4c877ba3eefc3a22, []int{2} -} -func (m *UpdateLendPairsProposal) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UpdateLendPairsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UpdateLendPairsProposal.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *UpdateLendPairsProposal) XXX_Merge(src proto.Message) { - xxx_messageInfo_UpdateLendPairsProposal.Merge(m, src) -} -func (m *UpdateLendPairsProposal) XXX_Size() int { - return m.Size() -} -func (m *UpdateLendPairsProposal) XXX_DiscardUnknown() { - xxx_messageInfo_UpdateLendPairsProposal.DiscardUnknown(m) -} - -var xxx_messageInfo_UpdateLendPairsProposal proto.InternalMessageInfo - -func (m *UpdateLendPairsProposal) GetTitle() string { - if m != nil { - return m.Title - } - return "" -} - -func (m *UpdateLendPairsProposal) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func (m *UpdateLendPairsProposal) GetPairs() Extended_Pair { - if m != nil { - return m.Pairs - } - return Extended_Pair{} -} - type AddAssetToPairProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` @@ -213,7 +153,7 @@ func (m *AddAssetToPairProposal) Reset() { *m = AddAssetToPairProposal{} func (m *AddAssetToPairProposal) String() string { return proto.CompactTextString(m) } func (*AddAssetToPairProposal) ProtoMessage() {} func (*AddAssetToPairProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_4c877ba3eefc3a22, []int{3} + return fileDescriptor_4c877ba3eefc3a22, []int{2} } func (m *AddAssetToPairProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -273,7 +213,7 @@ func (m *AddAssetRatesParams) Reset() { *m = AddAssetRatesParams{} } func (m *AddAssetRatesParams) String() string { return proto.CompactTextString(m) } func (*AddAssetRatesParams) ProtoMessage() {} func (*AddAssetRatesParams) Descriptor() ([]byte, []int) { - return fileDescriptor_4c877ba3eefc3a22, []int{4} + return fileDescriptor_4c877ba3eefc3a22, []int{3} } func (m *AddAssetRatesParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -333,7 +273,7 @@ func (m *AddAuctionParamsProposal) Reset() { *m = AddAuctionParamsPropos func (m *AddAuctionParamsProposal) String() string { return proto.CompactTextString(m) } func (*AddAuctionParamsProposal) ProtoMessage() {} func (*AddAuctionParamsProposal) Descriptor() ([]byte, []int) { - return fileDescriptor_4c877ba3eefc3a22, []int{5} + return fileDescriptor_4c877ba3eefc3a22, []int{4} } func (m *AddAuctionParamsProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -386,7 +326,6 @@ func (m *AddAuctionParamsProposal) GetAuctionParams() AuctionParams { func init() { proto.RegisterType((*LendPairsProposal)(nil), "comdex.lend.v1beta1.LendPairsProposal") proto.RegisterType((*AddPoolsProposal)(nil), "comdex.lend.v1beta1.AddPoolsProposal") - proto.RegisterType((*UpdateLendPairsProposal)(nil), "comdex.lend.v1beta1.UpdateLendPairsProposal") proto.RegisterType((*AddAssetToPairProposal)(nil), "comdex.lend.v1beta1.AddAssetToPairProposal") proto.RegisterType((*AddAssetRatesParams)(nil), "comdex.lend.v1beta1.AddAssetRatesParams") proto.RegisterType((*AddAuctionParamsProposal)(nil), "comdex.lend.v1beta1.AddAuctionParamsProposal") @@ -395,35 +334,34 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/gov.proto", fileDescriptor_4c877ba3eefc3a22) } var fileDescriptor_4c877ba3eefc3a22 = []byte{ - // 434 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x94, 0x41, 0xca, 0xd3, 0x40, - 0x1c, 0xc5, 0x33, 0xfa, 0x55, 0x70, 0xaa, 0x50, 0x53, 0xa9, 0xb1, 0x60, 0x5a, 0x06, 0xd4, 0x6e, - 0x4c, 0xa8, 0xdd, 0x88, 0x0b, 0xa1, 0x05, 0xc1, 0x85, 0x4a, 0x08, 0x8a, 0x20, 0x88, 0x4c, 0x33, - 0xd3, 0x38, 0x90, 0x66, 0x86, 0xcc, 0xb4, 0xb4, 0xb7, 0xf0, 0x1a, 0x1e, 0xc0, 0x95, 0x17, 0xe8, - 0xc2, 0x45, 0x97, 0xba, 0x29, 0xd2, 0xde, 0xa0, 0x27, 0x90, 0x49, 0x46, 0x48, 0x6d, 0x74, 0x19, - 0xf8, 0x76, 0xed, 0xbc, 0xf7, 0xff, 0xbf, 0xf7, 0x4b, 0xc2, 0xc0, 0x7b, 0x11, 0x9f, 0x13, 0xba, - 0xf2, 0x13, 0x9a, 0x12, 0x7f, 0x39, 0x9c, 0x52, 0x85, 0x87, 0x7e, 0xcc, 0x97, 0x9e, 0xc8, 0xb8, - 0xe2, 0x76, 0xbb, 0x90, 0x3d, 0x2d, 0x7b, 0x46, 0xee, 0xde, 0x8e, 0x79, 0xcc, 0x73, 0xdd, 0xd7, - 0xbf, 0x0a, 0x6b, 0xd7, 0xad, 0xda, 0x94, 0xcf, 0xe5, 0x3a, 0xfa, 0x0a, 0xe0, 0xad, 0x97, 0x34, - 0x25, 0x01, 0x66, 0x99, 0x0c, 0x32, 0x2e, 0xb8, 0xc4, 0x89, 0xfd, 0x00, 0x36, 0x14, 0x53, 0x09, - 0x75, 0x40, 0x1f, 0x0c, 0xae, 0x4f, 0x5a, 0xc7, 0x5d, 0xef, 0xc6, 0x1a, 0xcf, 0x93, 0xa7, 0x28, - 0x3f, 0x46, 0x61, 0x21, 0xdb, 0x4f, 0x60, 0x93, 0x50, 0x19, 0x65, 0x4c, 0x28, 0xc6, 0x53, 0xe7, - 0x4a, 0xee, 0xee, 0x1c, 0x77, 0x3d, 0xbb, 0x70, 0x97, 0x44, 0x14, 0x96, 0xad, 0xf6, 0x33, 0xd8, - 0x10, 0x3a, 0xd2, 0xb9, 0xda, 0x07, 0x83, 0xe6, 0x63, 0xe4, 0x55, 0x20, 0x79, 0xcf, 0x57, 0x8a, - 0xa6, 0x84, 0x92, 0x8f, 0xba, 0xdd, 0xe4, 0x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 0x4e, 0xaf, - 0xe5, 0x17, 0xde, 0xe8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x98, 0xb8, 0xe2, 0x5c, 0x05, - 0x00, 0x00, + // 423 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x94, 0xc1, 0x8a, 0xd3, 0x40, + 0x1c, 0xc6, 0x33, 0xda, 0x0a, 0x4e, 0x15, 0x6a, 0x2a, 0x25, 0x16, 0x4c, 0xcb, 0x80, 0xda, 0x8b, + 0x09, 0xb5, 0x17, 0xf1, 0x20, 0xb4, 0x20, 0x78, 0x50, 0x09, 0x41, 0x10, 0x04, 0x91, 0x69, 0x66, + 0x1a, 0x07, 0xd2, 0x4c, 0xc8, 0x4c, 0x4b, 0xfb, 0x16, 0xbe, 0xc6, 0x3e, 0xc0, 0xbe, 0x43, 0x0f, + 0x7b, 0xe8, 0x71, 0xf7, 0x52, 0x96, 0xf6, 0x0d, 0xfa, 0x04, 0xcb, 0x24, 0xb3, 0x90, 0x6e, 0xb3, + 0x7b, 0xcc, 0x2d, 0x99, 0xef, 0xfb, 0xff, 0xbf, 0xef, 0x47, 0xc8, 0xc0, 0xd7, 0x01, 0x9f, 0x11, + 0xba, 0x74, 0x23, 0x1a, 0x13, 0x77, 0x31, 0x98, 0x50, 0x89, 0x07, 0x6e, 0xc8, 0x17, 0x4e, 0x92, + 0x72, 0xc9, 0xcd, 0x56, 0x2e, 0x3b, 0x4a, 0x76, 0xb4, 0xdc, 0x79, 0x19, 0xf2, 0x90, 0x67, 0xba, + 0xab, 0x9e, 0x72, 0x6b, 0xc7, 0x2e, 0xdb, 0x94, 0xcd, 0x65, 0x3a, 0x3a, 0x07, 0xf0, 0xc5, 0x37, + 0x1a, 0x13, 0x0f, 0xb3, 0x54, 0x78, 0x29, 0x4f, 0xb8, 0xc0, 0x91, 0xf9, 0x16, 0xd6, 0x25, 0x93, + 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1f, 0xec, 0x07, 0x7c, 0x7e, 0x14, 0xfd, 0xe0, 0x1f, 0x72, 0xe4, + 0xd4, 0x44, 0xc7, 0xe3, 0xe3, 0xaf, 0xeb, 0x9d, 0x0d, 0x36, 0x3b, 0x1b, 0x5c, 0xef, 0x6c, 0xf0, + 0x7f, 0x6f, 0x1b, 0x9b, 0xbd, 0x6d, 0x5c, 0xee, 0x6d, 0xe3, 0xb7, 0x13, 0x32, 0xf9, 0x6f, 0x3e, + 0x51, 0x8b, 0xdd, 0x7c, 0xf9, 0x7b, 0x3e, 0x9d, 0xb2, 0x80, 0xe1, 0x48, 0xbf, 0xbb, 0xfa, 0xe2, + 0x90, 0xab, 0x84, 0x8a, 0xc9, 0x93, 0xec, 0xca, 0x18, 0xde, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf4, + 0xeb, 0x4b, 0xb2, 0x9e, 0x04, 0x00, 0x00, } func (m *LendPairsProposal) Marshal() (dAtA []byte, err error) { @@ -520,53 +458,6 @@ func (m *AddPoolsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *UpdateLendPairsProposal) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *UpdateLendPairsProposal) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UpdateLendPairsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Pairs.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGov(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if len(m.Title) > 0 { - i -= len(m.Title) - copy(dAtA[i:], m.Title) - i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *AddAssetToPairProposal) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -757,25 +648,6 @@ func (m *AddPoolsProposal) Size() (n int) { return n } -func (m *UpdateLendPairsProposal) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Title) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovGov(uint64(l)) - } - l = m.Pairs.Size() - n += 1 + l + sovGov(uint64(l)) - return n -} - func (m *AddAssetToPairProposal) Size() (n int) { if m == nil { return 0 @@ -1133,153 +1005,6 @@ func (m *AddPoolsProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *UpdateLendPairsProposal) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UpdateLendPairsProposal: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UpdateLendPairsProposal: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Title = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGov - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pairs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGov - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGov - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGov - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Pairs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGov(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGov - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *AddAssetToPairProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/lend/types/keys.go b/x/lend/types/keys.go index 5b3277813..ff4da9b56 100644 --- a/x/lend/types/keys.go +++ b/x/lend/types/keys.go @@ -44,8 +44,6 @@ var ( ) var ( - KeyPrefixReserveAmount = []byte{0x05} - PoolKeyPrefix = []byte{0x13} LendUserPrefix = []byte{0x15} LendCounterIDPrefix = []byte{0x16} @@ -65,6 +63,7 @@ var ( BorrowInterestTrackerKeyPrefix = []byte{0x44} UserLendBorrowMappingKeyPrefix = []byte{0x45} ReserveBuybackAssetDataKeyPrefix = []byte{0x46} + NewStableBorrowIDsKeyPrefix = []byte{0x47} ) func LendUserKey(ID uint64) []byte { diff --git a/x/lend/types/lend.pb.go b/x/lend/types/lend.pb.go index a369db1b2..d7365e522 100644 --- a/x/lend/types/lend.pb.go +++ b/x/lend/types/lend.pb.go @@ -765,50 +765,6 @@ func (m *AssetRatesParams) GetCAssetID() uint64 { return 0 } -type StableBorrowMapping struct { - StableBorrowIDs []uint64 `protobuf:"varint,1,rep,packed,name=stable_borrow_ids,json=stableBorrowIds,proto3" json:"stable_borrow_ids,omitempty" yaml:"stable_borrow_ids"` -} - -func (m *StableBorrowMapping) Reset() { *m = StableBorrowMapping{} } -func (m *StableBorrowMapping) String() string { return proto.CompactTextString(m) } -func (*StableBorrowMapping) ProtoMessage() {} -func (*StableBorrowMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{9} -} -func (m *StableBorrowMapping) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *StableBorrowMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_StableBorrowMapping.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *StableBorrowMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_StableBorrowMapping.Merge(m, src) -} -func (m *StableBorrowMapping) XXX_Size() int { - return m.Size() -} -func (m *StableBorrowMapping) XXX_DiscardUnknown() { - xxx_messageInfo_StableBorrowMapping.DiscardUnknown(m) -} - -var xxx_messageInfo_StableBorrowMapping proto.InternalMessageInfo - -func (m *StableBorrowMapping) GetStableBorrowIDs() []uint64 { - if m != nil { - return m.StableBorrowIDs - } - return nil -} - type ReserveBuybackAssetData struct { AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` ReserveAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=reserve_amount,json=reserveAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"reserve_amount" yaml:"reserve_amount"` @@ -819,7 +775,7 @@ func (m *ReserveBuybackAssetData) Reset() { *m = ReserveBuybackAssetData func (m *ReserveBuybackAssetData) String() string { return proto.CompactTextString(m) } func (*ReserveBuybackAssetData) ProtoMessage() {} func (*ReserveBuybackAssetData) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{10} + return fileDescriptor_b87bb4bef8334ddd, []int{9} } func (m *ReserveBuybackAssetData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -870,7 +826,7 @@ func (m *AuctionParams) Reset() { *m = AuctionParams{} } func (m *AuctionParams) String() string { return proto.CompactTextString(m) } func (*AuctionParams) ProtoMessage() {} func (*AuctionParams) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{11} + return fileDescriptor_b87bb4bef8334ddd, []int{10} } func (m *AuctionParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -943,7 +899,7 @@ func (m *BorrowInterestTracker) Reset() { *m = BorrowInterestTracker{} } func (m *BorrowInterestTracker) String() string { return proto.CompactTextString(m) } func (*BorrowInterestTracker) ProtoMessage() {} func (*BorrowInterestTracker) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{12} + return fileDescriptor_b87bb4bef8334ddd, []int{11} } func (m *BorrowInterestTracker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -988,7 +944,7 @@ func (m *LendRewardsTracker) Reset() { *m = LendRewardsTracker{} } func (m *LendRewardsTracker) String() string { return proto.CompactTextString(m) } func (*LendRewardsTracker) ProtoMessage() {} func (*LendRewardsTracker) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{13} + return fileDescriptor_b87bb4bef8334ddd, []int{12} } func (m *LendRewardsTracker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1024,6 +980,110 @@ func (m *LendRewardsTracker) GetLendingId() uint64 { return 0 } +type ModuleBalance struct { + PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + ModuleBalanceStats []ModuleBalanceStats `protobuf:"bytes,2,rep,name=module_balance_stats,json=moduleBalanceStats,proto3" json:"module_balance_stats" yaml:"module_balance_stats"` +} + +func (m *ModuleBalance) Reset() { *m = ModuleBalance{} } +func (m *ModuleBalance) String() string { return proto.CompactTextString(m) } +func (*ModuleBalance) ProtoMessage() {} +func (*ModuleBalance) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{13} +} +func (m *ModuleBalance) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleBalance) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleBalance.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleBalance) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleBalance.Merge(m, src) +} +func (m *ModuleBalance) XXX_Size() int { + return m.Size() +} +func (m *ModuleBalance) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleBalance.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleBalance proto.InternalMessageInfo + +func (m *ModuleBalance) GetPoolID() uint64 { + if m != nil { + return m.PoolID + } + return 0 +} + +func (m *ModuleBalance) GetModuleBalanceStats() []ModuleBalanceStats { + if m != nil { + return m.ModuleBalanceStats + } + return nil +} + +type ModuleBalanceStats struct { + AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + Balance github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,2,opt,name=balance,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"balance" yaml:"balance"` +} + +func (m *ModuleBalanceStats) Reset() { *m = ModuleBalanceStats{} } +func (m *ModuleBalanceStats) String() string { return proto.CompactTextString(m) } +func (*ModuleBalanceStats) ProtoMessage() {} +func (*ModuleBalanceStats) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{14} +} +func (m *ModuleBalanceStats) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ModuleBalanceStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ModuleBalanceStats.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ModuleBalanceStats) XXX_Merge(src proto.Message) { + xxx_messageInfo_ModuleBalanceStats.Merge(m, src) +} +func (m *ModuleBalanceStats) XXX_Size() int { + return m.Size() +} +func (m *ModuleBalanceStats) XXX_DiscardUnknown() { + xxx_messageInfo_ModuleBalanceStats.DiscardUnknown(m) +} + +var xxx_messageInfo_ModuleBalanceStats proto.InternalMessageInfo + +func (m *ModuleBalanceStats) GetAssetID() uint64 { + if m != nil { + return m.AssetID + } + return 0 +} + +func (m *ModuleBalanceStats) GetBalance() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.Balance + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + func init() { proto.RegisterType((*LendAsset)(nil), "comdex.lend.v1beta1.LendAsset") proto.RegisterType((*BorrowAsset)(nil), "comdex.lend.v1beta1.BorrowAsset") @@ -1034,164 +1094,168 @@ func init() { proto.RegisterType((*AssetToPairMapping)(nil), "comdex.lend.v1beta1.AssetToPairMapping") proto.RegisterType((*PoolAssetLBMapping)(nil), "comdex.lend.v1beta1.PoolAssetLBMapping") proto.RegisterType((*AssetRatesParams)(nil), "comdex.lend.v1beta1.AssetRatesParams") - proto.RegisterType((*StableBorrowMapping)(nil), "comdex.lend.v1beta1.StableBorrowMapping") proto.RegisterType((*ReserveBuybackAssetData)(nil), "comdex.lend.v1beta1.ReserveBuybackAssetData") proto.RegisterType((*AuctionParams)(nil), "comdex.lend.v1beta1.AuctionParams") proto.RegisterType((*BorrowInterestTracker)(nil), "comdex.lend.v1beta1.Borrow_interest_tracker") proto.RegisterType((*LendRewardsTracker)(nil), "comdex.lend.v1beta1.Lend_rewards_tracker") + proto.RegisterType((*ModuleBalance)(nil), "comdex.lend.v1beta1.ModuleBalance") + proto.RegisterType((*ModuleBalanceStats)(nil), "comdex.lend.v1beta1.ModuleBalanceStats") } func init() { proto.RegisterFile("comdex/lend/v1beta1/lend.proto", fileDescriptor_b87bb4bef8334ddd) } var fileDescriptor_b87bb4bef8334ddd = []byte{ - // 2346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x19, 0x4d, 0x73, 0x1c, 0x47, - 0xd5, 0xa3, 0xcf, 0xdd, 0x5e, 0x7d, 0xf6, 0xae, 0xf0, 0x46, 0x71, 0x34, 0x76, 0x43, 0x05, 0x51, - 0x54, 0x56, 0x65, 0x11, 0x0e, 0xb8, 0xe2, 0x0a, 0x5a, 0xc9, 0x36, 0x9b, 0xc8, 0x8e, 0xd3, 0x56, - 0xa0, 0xf8, 0x9c, 0xea, 0x9d, 0x69, 0xc9, 0x53, 0x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, 0xf0, 0x4e, 0xe5, 0x2e, 0xad, 0x18, 0x80, 0x2c, 0x8c, - 0x20, 0x00, 0x77, 0xc2, 0x48, 0x5a, 0x15, 0x82, 0x4c, 0xf2, 0x47, 0x95, 0xad, 0xaa, 0xf9, 0x97, - 0xc3, 0x55, 0x49, 0x80, 0x70, 0x95, 0x32, 0x8e, 0xd1, 0x6a, 0xb9, 0x13, 0x97, 0xa2, 0x74, 0x8b, - 0xfb, 0x4e, 0x65, 0x51, 0xed, 0x49, 0xad, 0xbd, 0x92, 0xb8, 0x5c, 0xec, 0xec, 0xa5, 0xdc, 0xc7, - 0x68, 0x35, 0x89, 0x5d, 0xcf, 0x15, 0x4c, 0xb5, 0x87, 0x91, 0xfc, 0x81, 0x46, 0xf7, 0xdc, 0x72, - 0xcf, 0x30, 0x24, 0x74, 0xa5, 0x00, 0xa3, 0x0a, 0xf4, 0xc7, 0x06, 0x5a, 0x51, 0xd5, 0x42, 0xce, - 0x17, 0xe2, 0x3e, 0x8b, 0xd8, 0x40, 0x5c, 0xe4, 0x62, 0xb6, 0x50, 0x3d, 0xb1, 0x82, 0x30, 0x76, - 0x07, 0xcc, 0x83, 0xae, 0xaf, 0x5b, 0xf9, 0x00, 0x70, 0xc9, 0x65, 0x8c, 0x08, 0xad, 0x25, 0xef, - 0xe9, 0xbf, 0xf8, 0x7d, 0x34, 0x23, 0x87, 0x4b, 0xe8, 0x05, 0x6f, 0x56, 0xe6, 0xdd, 0x00, 0xff, - 0x33, 0xc1, 0x09, 0x55, 0xac, 0xf0, 0x77, 0xd0, 0x9c, 0xf0, 0x82, 0x90, 0x5f, 0x87, 0x27, 0xbc, - 0xb7, 0x2b, 0x33, 0x85, 0x37, 0x26, 0xcd, 0x85, 0x50, 0x60, 0x97, 0x31, 0xde, 0x86, 0xa2, 0x77, - 0x31, 0xc6, 0xdb, 0x29, 0xe3, 0x6d, 0xfc, 0x3e, 0x6a, 0x71, 0x5f, 0x45, 0x55, 0xf9, 0x15, 0x64, -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 0x9c, 0x86, 0xac, 0x88, 0x3f, 0x66, 0x91, 0x23, 0xb2, 0x93, 0xbd, 0x39, 0xe1, 0x13, 0xf2, 0xda, - 0x0b, 0x3f, 0x2c, 0x7d, 0x88, 0x9a, 0x29, 0xa3, 0xe2, 0x2c, 0x35, 0xf5, 0x59, 0x3c, 0xae, 0x63, - 0x90, 0x54, 0x98, 0x9f, 0xba, 0xdf, 0xfa, 0x78, 0xb4, 0x61, 0x7c, 0x32, 0xda, 0x30, 0xfe, 0x36, - 0xda, 0x30, 0x3e, 0x7a, 0xba, 0x71, 0xe9, 0x93, 0xa7, 0x1b, 0x97, 0xfe, 0xf2, 0x74, 0xe3, 0xd2, - 0xf7, 0x3a, 0x25, 0xa1, 0x03, 0x87, 0x3f, 0x79, 0x23, 0x38, 0x3c, 0x74, 0x6d, 0x97, 0x79, 0xb0, - 0xde, 0x82, 0x2f, 0xf9, 0x4a, 0x81, 0xfe, 0x9c, 0x7a, 0x93, 0xfe, 0xda, 0x7f, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x6d, 0x52, 0xcc, 0x93, 0xe5, 0x1f, 0x00, 0x00, + // 2398 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x5a, 0xcf, 0x73, 0x1c, 0x47, + 0xf5, 0xf7, 0xe8, 0xe7, 0x6e, 0xaf, 0x24, 0x4b, 0xbd, 0xab, 0xaf, 0x37, 0x4a, 0xa2, 0xb1, 0x3b, + 0xdf, 0x4a, 0x44, 0x51, 0x59, 0x95, 0x45, 0x38, 0xe0, 0x8a, 0x2b, 0x68, 0x25, 0xdb, 0x6c, 0x22, + 0x3b, 0x4e, 0x4b, 0x81, 0x82, 0x02, 0xa6, 0x7a, 0x67, 0x5a, 0xf2, 0x94, 0x67, 0x67, 0x86, 0xe9, + 0x19, 0xd9, 0x2a, 0xc0, 0x50, 0x70, 0xe5, 0x10, 0x2e, 0x5c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 0x57, 0x03, 0xc9, 0x27, + 0xff, 0x6a, 0xa0, 0x86, 0x56, 0xb2, 0x0e, 0xcd, 0x6f, 0xa2, 0x05, 0x6d, 0x87, 0x52, 0x70, 0xbe, + 0x9a, 0x05, 0x27, 0xa8, 0xa3, 0x38, 0x87, 0xd0, 0x46, 0x36, 0xec, 0x39, 0x72, 0x53, 0x85, 0xe0, + 0xd6, 0x21, 0xaa, 0x36, 0xb5, 0x07, 0x31, 0xfc, 0xfc, 0x18, 0xbf, 0x85, 0x96, 0x5d, 0x61, 0x89, + 0x58, 0x79, 0x06, 0x78, 0x9a, 0x8c, 0xd8, 0x5a, 0xf7, 0xe5, 0xd3, 0xa1, 0x79, 0x45, 0xaf, 0x3d, + 0x3b, 0x83, 0xd0, 0x25, 0x57, 0xec, 0x2b, 0x0a, 0x78, 0x8d, 0x8c, 0x77, 0xe6, 0x46, 0x72, 0x1b, + 0x33, 0x85, 0x78, 0x67, 0x6e, 0x54, 0x8a, 0x77, 0x3d, 0x45, 0xc6, 0xbb, 0xe4, 0x38, 0x5f, 0x6e, + 0x1c, 0x3f, 0x41, 0x08, 0x20, 0x82, 0x24, 0x86, 0x28, 0x7e, 0x86, 0xf4, 0x5d, 0x90, 0xbe, 0x52, + 0x92, 0x1e, 0x24, 0x71, 0x25, 0xf1, 0x70, 0xde, 0xf7, 0x93, 0x18, 0xff, 0xd6, 0x40, 0xad, 0x7e, + 0xe4, 0x3a, 0x47, 0xdc, 0xb1, 0x74, 0x0a, 0xd5, 0x3c, 0x15, 0xe9, 0xcf, 0xdc, 0xca, 0x3d, 0xd8, + 0xca, 0xcb, 0xe0, 0x21, 0x13, 0x40, 0x2a, 0x6d, 0x0a, 0x03, 0x82, 0xf2, 0xcb, 0x6d, 0xb5, 0x1e, + 0x3b, 0x68, 0x29, 0xf7, 0x3c, 0x15, 0x63, 0xb5, 0xe7, 0xc6, 0xd8, 0x35, 0xd8, 0xd7, 0xea, 0x59, + 0xcf, 0xcd, 0x83, 0x6b, 0x31, 0x23, 0xaa, 0xb0, 0x3a, 0x41, 0xb8, 0xe4, 0x59, 0x56, 0xc4, 0x62, + 0x0e, 0x09, 0xe4, 0xbd, 0xca, 0x09, 0xe4, 0x25, 0x2d, 0x77, 0x1c, 0x91, 0xd0, 0x65, 0x51, 0x70, + 0x57, 0xca, 0x62, 0x8e, 0x7f, 0x6e, 0xa0, 0x96, 0x4a, 0x00, 0x5c, 0xc4, 0x16, 0xb3, 0xed, 0x64, + 0x90, 0x78, 0x2c, 0xe6, 0x8e, 0xca, 0x25, 0xf5, 0xee, 0xdd, 0xca, 0xd2, 0xc1, 0x1a, 0x93, 0x30, + 0x09, 0x6d, 0xa6, 0xe4, 0xed, 0x9c, 0x3a, 0x96, 0x38, 0x1b, 0x5f, 0x58, 0xe2, 0xfc, 0x19, 0x6a, + 0x45, 0x5c, 0xf0, 0xe8, 0x98, 0x5b, 0x25, 0x89, 0x0b, 0x17, 0x3b, 0xeb, 0x24, 0x4c, 0x42, 0x31, + 0x90, 0xef, 0xbc, 0x48, 0xe6, 0x5e, 0xfc, 0xdf, 0x66, 0xee, 0xa5, 0x73, 0x64, 0x6e, 0x7c, 0x13, + 0x2d, 0xba, 0xc2, 0xf2, 0xdc, 0x1f, 0x25, 0xae, 0xa3, 0x5c, 0xe4, 0xb2, 0xca, 0x90, 0xed, 0xd3, + 0xa1, 0xd9, 0xca, 0x32, 0x64, 0xce, 0x26, 0x74, 0xc1, 0x15, 0x7b, 0xf9, 0xf0, 0x9f, 0x53, 0x68, + 0x46, 0xca, 0x2a, 0x56, 0x45, 0x46, 0x85, 0xaa, 0xe8, 0x16, 0x6a, 0x0c, 0x02, 0x27, 0xf1, 0xb8, + 0x3e, 0xc2, 0x94, 0x3a, 0xc2, 0xff, 0x8f, 0x86, 0x26, 0xba, 0xab, 0xc8, 0x70, 0x06, 0xac, 0x97, + 0x17, 0xa6, 0x12, 0x8a, 0x06, 0xd9, 0x8c, 0x33, 0x8a, 0x98, 0x3e, 0xa7,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9d, 0x25, 0xd5, 0xab, 0x93, 0xd6, 0x6e, 0xe5, 0x0d, + 0xe3, 0xb2, 0xcf, 0x2b, 0x2d, 0x23, 0xf0, 0x76, 0xa9, 0xeb, 0x87, 0x68, 0x11, 0x78, 0xa0, 0x72, + 0x9d, 0xa8, 0x6e, 0x57, 0x16, 0xd4, 0x2a, 0x09, 0x4a, 0x35, 0xbf, 0xa0, 0xc7, 0xfb, 0x5a, 0xff, + 0x67, 0x84, 0x6d, 0x41, 0x52, 0xfa, 0xaf, 0x08, 0xdb, 0x2a, 0x0b, 0xdb, 0xc2, 0xf7, 0xd0, 0xb4, + 0x17, 0x1f, 0x43, 0x5e, 0x7a, 0xbb, 0xb2, 0x08, 0x04, 0x79, 0x2f, 0x3e, 0x26, 0x54, 0x02, 0xe1, + 0x5f, 0x1a, 0x68, 0x35, 0xed, 0xcf, 0x54, 0xcb, 0xf8, 0x20, 0xe2, 0xe2, 0x41, 0xe0, 0x39, 0x90, + 0x8f, 0xee, 0x55, 0x16, 0x91, 0x36, 0xa3, 0x93, 0x40, 0x09, 0x6d, 0x15, 0xe8, 0x07, 0x29, 0x19, + 0xff, 0x14, 0x35, 0x8b, 0xf3, 0x43, 0xee, 0x33, 0x2f, 0x3e, 0x81, 0xd4, 0xb4, 0x57, 0x79, 0x0b, + 0x6b, 0xe3, 0x5b, 0x00, 0x48, 0x42, 0x71, 0x81, 0x7a, 0x5f, 0x13, 0x65, 0x5e, 0x2c, 0xce, 0xed, + 0x07, 0x7e, 0x22, 0x54, 0xfb, 0x7d, 0x81, 0xbc, 0x38, 0x06, 0x48, 0xe8, 0x72, 0x81, 0xd6, 0x95, + 0x24, 0x59, 0xb7, 0x64, 0x6d, 0x21, 0xb3, 0xe3, 0x20, 0x82, 0x2e, 0xfc, 0x4e, 0x65, 0xa9, 0xab, + 0x67, 0x9a, 0x4c, 0x85, 0x46, 0x68, 0xda, 0x94, 0xde, 0x56, 0x63, 0xfc, 0x0e, 0x42, 0xb6, 0x95, +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xaf, 0x81, 0x64, 0x35, 0x16, 0xcb, 0x0c, + 0x31, 0xbd, 0xd1, 0xd8, 0x7a, 0x63, 0xe2, 0x53, 0x62, 0x49, 0xf0, 0xbe, 0x9c, 0xde, 0x7d, 0xad, + 0xfc, 0xfd, 0x64, 0x12, 0x24, 0xa1, 0x78, 0x30, 0xb6, 0x90, 0xfc, 0xc1, 0x40, 0x78, 0x1c, 0xef, + 0x22, 0x77, 0xc2, 0x31, 0x9a, 0x07, 0xb9, 0xca, 0x1c, 0xcf, 0xfc, 0xec, 0xb3, 0x0d, 0xdb, 0x5e, + 0x4a, 0xcb, 0x6e, 0xb5, 0xae, 0xd2, 0x97, 0x9e, 0x54, 0x58, 0xf7, 0x5b, 0x9f, 0x8c, 0xd6, 0x8d, + 0x4f, 0x47, 0xeb, 0xc6, 0x5f, 0x47, 0xeb, 0xc6, 0x47, 0x4f, 0xd7, 0x2f, 0x7d, 0xfa, 0x74, 0xfd, + 0xd2, 0x9f, 0x9f, 0xae, 0x5f, 0xfa, 0x5e, 0xa7, 0x84, 0x25, 0xf5, 0xf9, 0x66, 0x70, 0x78, 0xe8, + 0xda, 0x2e, 0xf3, 0x60, 0xbc, 0x09, 0xff, 0xe8, 0xa0, 0x70, 0xfb, 0x73, 0xea, 0xc9, 0xfe, 0x6b, + 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x56, 0x60, 0xbf, 0xea, 0x04, 0x21, 0x00, 0x00, } func (m *LendAsset) Marshal() (dAtA []byte, err error) { @@ -2026,47 +2090,6 @@ func (m *AssetRatesParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *StableBorrowMapping) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *StableBorrowMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *StableBorrowMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.StableBorrowIDs) > 0 { - dAtA18 := make([]byte, len(m.StableBorrowIDs)*10) - var j17 int - for _, num := range m.StableBorrowIDs { - for num >= 1<<7 { - dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j17++ - } - dAtA18[j17] = uint8(num) - j17++ - } - i -= j17 - copy(dAtA[i:], dAtA18[:j17]) - i = encodeVarintLend(dAtA, i, uint64(j17)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *ReserveBuybackAssetData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2269,6 +2292,86 @@ func (m *LendRewardsTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ModuleBalance) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleBalance) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleBalance) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ModuleBalanceStats) > 0 { + for iNdEx := len(m.ModuleBalanceStats) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ModuleBalanceStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ModuleBalanceStats) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ModuleBalanceStats) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ModuleBalanceStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintLend(dAtA []byte, offset int, v uint64) int { offset -= sovLend(v) base := offset @@ -2574,22 +2677,6 @@ func (m *AssetRatesParams) Size() (n int) { return n } -func (m *StableBorrowMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.StableBorrowIDs) > 0 { - l = 0 - for _, e := range m.StableBorrowIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - func (m *ReserveBuybackAssetData) Size() (n int) { if m == nil { return 0 @@ -2664,6 +2751,38 @@ func (m *LendRewardsTracker) Size() (n int) { return n } +func (m *ModuleBalance) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) + } + if len(m.ModuleBalanceStats) > 0 { + for _, e := range m.ModuleBalanceStats { + l = e.Size() + n += 1 + l + sovLend(uint64(l)) + } + } + return n +} + +func (m *ModuleBalanceStats) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) + } + l = m.Balance.Size() + n += 1 + l + sovLend(uint64(l)) + return n +} + func sovLend(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -5353,7 +5472,7 @@ func (m *AssetRatesParams) Unmarshal(dAtA []byte) error { } return nil } -func (m *StableBorrowMapping) Unmarshal(dAtA []byte) error { +func (m *ReserveBuybackAssetData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5376,136 +5495,10 @@ func (m *StableBorrowMapping) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: StableBorrowMapping: wiretype end group for non-group") + return fmt.Errorf("proto: ReserveBuybackAssetData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: StableBorrowMapping: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.StableBorrowIDs = append(m.StableBorrowIDs, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthLend - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.StableBorrowIDs) == 0 { - m.StableBorrowIDs = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.StableBorrowIDs = append(m.StableBorrowIDs, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field StableBorrowIDs", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthLend - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ReserveBuybackAssetData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ReserveBuybackAssetData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ReserveBuybackAssetData: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ReserveBuybackAssetData: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -6069,6 +6062,211 @@ func (m *LendRewardsTracker) Unmarshal(dAtA []byte) error { } return nil } +func (m *ModuleBalance) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleBalance: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleBalance: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + } + m.PoolID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleBalanceStats", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ModuleBalanceStats = append(m.ModuleBalanceStats, ModuleBalanceStats{}) + if err := m.ModuleBalanceStats[len(m.ModuleBalanceStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ModuleBalanceStats) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ModuleBalanceStats: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ModuleBalanceStats: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) + } + m.AssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthLend + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipLend(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/lend/types/pair.go b/x/lend/types/pair.go index 81a5ca865..8bf9ededc 100644 --- a/x/lend/types/pair.go +++ b/x/lend/types/pair.go @@ -2,6 +2,8 @@ package types import ( "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" ) func (m *Extended_Pair) Validate() error { @@ -11,6 +13,12 @@ func (m *Extended_Pair) Validate() error { if m.AssetOut == 0 { return fmt.Errorf("asset_out cannot be zero") } + if m.AssetOutPoolID == 0 { + return fmt.Errorf("AssetOutPoolID cannot be zero") + } + if m.MinUsdValueLeft == 0 { + return fmt.Errorf("MinUsdValueLeft cannot be zero") + } return nil } @@ -19,13 +27,67 @@ func (m *Pool) Validate() error { if len(m.CPoolName) >= 16 { return ErrInvalidLengthCPoolName } + if m.ReserveFunds == 0 { + return fmt.Errorf("ReserveFunds cannot be zero") + } + if m.AssetData == nil { + return fmt.Errorf("AssetData cannot be nil") + } return nil } func (m *AssetToPairMapping) Validate() error { + if m.AssetID == 0 { + return fmt.Errorf("assetID cannot be zero") + } + if m.PairID == nil { + return fmt.Errorf("PairIDs cannot be nil") + } return nil } func (m *AssetRatesParams) Validate() error { + if m.AssetID == 0 { + return fmt.Errorf("assetID cannot be zero") + } + if m.UOptimal.LTE(sdk.ZeroDec()) { + return fmt.Errorf("UOptimal cannot be zero") + } + if m.Base.LTE(sdk.ZeroDec()) { + return fmt.Errorf("base cannot be zero") + } + if m.Slope1.LTE(sdk.ZeroDec()) { + return fmt.Errorf("slope1 cannot be zero") + } + if m.Slope2.LTE(sdk.ZeroDec()) { + return fmt.Errorf("slope2 cannot be zero") + } + if m.StableBase.LT(sdk.ZeroDec()) { + return fmt.Errorf("StableBase cannot be less than zero") + } + if m.StableSlope1.LT(sdk.ZeroDec()) { + return fmt.Errorf("StableSlope1 cannot be less than zero") + } + if m.StableSlope2.LT(sdk.ZeroDec()) { + return fmt.Errorf("StableSlope2 cannot be less than zero") + } + if m.LiquidationThreshold.LTE(sdk.ZeroDec()) { + return fmt.Errorf("LiquidationThreshold cannot be zero") + } + if m.LiquidationBonus.LTE(sdk.ZeroDec()) { + return fmt.Errorf("LiquidationBonus cannot be zero") + } + if m.LiquidationPenalty.LTE(sdk.ZeroDec()) { + return fmt.Errorf("LiquidationPenalty cannot be zero") + } + if m.Ltv.LTE(sdk.ZeroDec()) { + return fmt.Errorf("ltv cannot be zero") + } + if m.ReserveFactor.LTE(sdk.ZeroDec()) { + return fmt.Errorf("ReserveFactor cannot be zero") + } + if m.CAssetID == 0 { + return fmt.Errorf("cAssetID cannot be zero") + } return nil } diff --git a/x/lend/types/query.pb.go b/x/lend/types/query.pb.go index 1ef06e90b..c2e037870 100644 --- a/x/lend/types/query.pb.go +++ b/x/lend/types/query.pb.go @@ -1530,6 +1530,80 @@ func (m *QueryAuctionParamResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAuctionParamResponse proto.InternalMessageInfo +type QueryModuleBalanceRequest struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` +} + +func (m *QueryModuleBalanceRequest) Reset() { *m = QueryModuleBalanceRequest{} } +func (m *QueryModuleBalanceRequest) String() string { return proto.CompactTextString(m) } +func (*QueryModuleBalanceRequest) ProtoMessage() {} +func (*QueryModuleBalanceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_462bf3f1a3eff175, []int{40} +} +func (m *QueryModuleBalanceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryModuleBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryModuleBalanceRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryModuleBalanceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryModuleBalanceRequest.Merge(m, src) +} +func (m *QueryModuleBalanceRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryModuleBalanceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryModuleBalanceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryModuleBalanceRequest proto.InternalMessageInfo + +type QueryModuleBalanceResponse struct { + ModuleBalance ModuleBalance `protobuf:"bytes,1,opt,name=ModuleBalance,proto3" json:"ModuleBalance" yaml:"module_balance"` +} + +func (m *QueryModuleBalanceResponse) Reset() { *m = QueryModuleBalanceResponse{} } +func (m *QueryModuleBalanceResponse) String() string { return proto.CompactTextString(m) } +func (*QueryModuleBalanceResponse) ProtoMessage() {} +func (*QueryModuleBalanceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_462bf3f1a3eff175, []int{41} +} +func (m *QueryModuleBalanceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryModuleBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryModuleBalanceResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryModuleBalanceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryModuleBalanceResponse.Merge(m, src) +} +func (m *QueryModuleBalanceResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryModuleBalanceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryModuleBalanceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryModuleBalanceResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "comdex.lend.v1beta1.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "comdex.lend.v1beta1.QueryParamsResponse") @@ -1571,124 +1645,130 @@ func init() { proto.RegisterType((*QueryReserveBuybackAssetDataResponse)(nil), "comdex.lend.v1beta1.QueryReserveBuybackAssetDataResponse") proto.RegisterType((*QueryAuctionParamRequest)(nil), "comdex.lend.v1beta1.QueryAuctionParamRequest") proto.RegisterType((*QueryAuctionParamResponse)(nil), "comdex.lend.v1beta1.QueryAuctionParamResponse") + proto.RegisterType((*QueryModuleBalanceRequest)(nil), "comdex.lend.v1beta1.QueryModuleBalanceRequest") + proto.RegisterType((*QueryModuleBalanceResponse)(nil), "comdex.lend.v1beta1.QueryModuleBalanceResponse") } func init() { proto.RegisterFile("comdex/lend/v1beta1/query.proto", fileDescriptor_462bf3f1a3eff175) } var fileDescriptor_462bf3f1a3eff175 = []byte{ - // 1778 bytes of a gzipped FileDescriptorProto + // 1850 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x5a, 0xdf, 0x6f, 0x14, 0xd5, - 0x17, 0xef, 0x2d, 0x6d, 0xf9, 0x72, 0x0b, 0x7c, 0xe1, 0xb6, 0x15, 0x3a, 0xb4, 0xdb, 0xf6, 0xd2, - 0x9f, 0x62, 0x77, 0x68, 0x01, 0x15, 0x42, 0x94, 0x4e, 0x20, 0x88, 0x81, 0x50, 0x27, 0x26, 0x26, - 0x46, 0xdd, 0xcc, 0x76, 0x86, 0x75, 0xe3, 0x76, 0x67, 0xd9, 0x99, 0x02, 0x4d, 0xd3, 0x04, 0x7f, - 0x3d, 0x18, 0x5f, 0x34, 0xfa, 0x07, 0x98, 0xa8, 0x09, 0x2f, 0x46, 0x5f, 0x7c, 0x51, 0x1f, 0x7c, - 0x24, 0x46, 0x0d, 0x86, 0x07, 0xc4, 0xc4, 0x46, 0x8b, 0x7f, 0x01, 0x89, 0xef, 0xe6, 0xde, 0x7b, - 0xe6, 0xe7, 0xde, 0x99, 0x9d, 0x35, 0x74, 0x15, 0x9f, 0x5c, 0xe7, 0xde, 0x73, 0xce, 0xe7, 0x73, - 0xce, 0xb9, 0xe7, 0xde, 0x73, 0x0a, 0x1e, 0x59, 0xb2, 0x97, 0x4d, 0xeb, 0x9a, 0x5a, 0xb1, 0xaa, - 0xa6, 0x7a, 0x65, 0xae, 0x68, 0xb9, 0xc6, 0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d7, 0xf0, 0xdc, 0x34, 0x18, 0x77, 0x93, 0xef, 0x11, - 0xfa, 0x95, 0x97, 0x40, 0x89, 0x2a, 0x80, 0xe9, 0xfb, 0x08, 0xef, 0x4b, 0xd8, 0x03, 0x7c, 0x1f, - 0x93, 0xf2, 0x4d, 0x90, 0xd1, 0x66, 0x80, 0xf4, 0x98, 0x20, 0x5d, 0x17, 0xdb, 0x0a, 0x45, 0xb1, - 0x0f, 0xf8, 0x9b, 0x86, 0x6b, 0x50, 0x3d, 0xc9, 0x2e, 0x9d, 0xc3, 0xfb, 0x45, 0xf2, 0xaf, 0x2c, - 0xb1, 0x84, 0x89, 0xf4, 0x11, 0x03, 0xb8, 0xc7, 0xa8, 0xd5, 0x02, 0xc6, 0xdd, 0x46, 0xad, 0x76, - 0xce, 0xa4, 0x6f, 0x21, 0x3c, 0x28, 0x91, 0x09, 0x5a, 0x6f, 0x23, 0xf4, 0xdd, 0x49, 0xed, 0x3c, - 0xc3, 0x1a, 0x9c, 0x78, 0xeb, 0x0d, 0x6a, 0xfc, 0x0e, 0x22, 0xaa, 0x77, 0xfe, 0x13, 0x05, 0x77, - 0x73, 0x18, 0xe4, 0x75, 0x84, 0x71, 0x30, 0xdf, 0x24, 0x93, 0x52, 0x53, 0x0d, 0x53, 0x57, 0x65, - 0xaa, 0xe9, 0x3e, 0x41, 0x89, 0xd2, 0x37, 0x6e, 0xff, 0xf1, 0x41, 0xe7, 0x10, 0x51, 0xd4, 0xa4, - 0x31, 0xb3, 0x43, 0xde, 0x44, 0x78, 0x87, 0x2f, 0x4a, 0x26, 0xd2, 0x55, 0x7b, 0x08, 0x26, 0x9b, - 0x6d, 0x03, 0x00, 0x53, 0x1c, 0xc0, 0x18, 0x19, 0x49, 0x06, 0xa0, 0xae, 0x95, 0xcd, 0x75, 0xf2, - 0x19, 0x82, 0xeb, 0x38, 0x3a, 0x55, 0x22, 0x6a, 0xb2, 0x21, 0xe9, 0x38, 0x53, 0x39, 0x9c, 0x5d, - 0x00, 0x30, 0x1e, 0xe1, 0x18, 0x67, 0xc9, 0xa1, 0x64, 0x8c, 0x85, 0xe2, 0x6a, 0x81, 0xd7, 0x7f, - 0x75, 0x8d, 0xff, 0x67, 0x9d, 0xfc, 0x24, 0x1f, 0xaa, 0x42, 0xe5, 0x25, 0x8f, 0x67, 0x45, 0x11, - 0xbd, 0x86, 0x94, 0x27, 0x5a, 0x96, 0x03, 0x12, 0x1a, 0x27, 0x71, 0x92, 0x9c, 0xc8, 0x40, 0xa2, - 0xc0, 0x8a, 0x8c, 0xc7, 0x44, 0x5d, 0x83, 0xda, 0xb7, 0xce, 0xfa, 0x8f, 0x1e, 0x98, 0x03, 0xa4, - 0x64, 0x58, 0x64, 0x4e, 0xa2, 0x4c, 0x37, 0xdf, 0x08, 0x08, 0x0f, 0x72, 0x84, 0xc3, 0xe4, 0x80, - 0x9a, 0xfc, 0x27, 0x8d, 0xe0, 0x40, 0x88, 0x21, 0xd5, 0x64, 0x9a, 0xf6, 0x60, 0x56, 0xa7, 0x4c, - 0x35, 0xdd, 0x97, 0xe9, 0x40, 0xf0, 0x49, 0x59, 0x70, 0x20, 0x98, 0x68, 0xda, 0x81, 0x08, 0x8d, - 0xb6, 0x94, 0xc9, 0x66, 0xdb, 0x32, 0x1d, 0x08, 0x0e, 0x40, 0x1c, 0x88, 0xcf, 0x11, 0x1e, 0x90, - 0x4e, 0x88, 0xc8, 0x5c, 0x4a, 0x8e, 0xc8, 0xa7, 0x59, 0xca, 0x7c, 0x2b, 0x22, 0x80, 0x54, 0xe5, - 0x48, 0x67, 0xc8, 0x94, 0x14, 0x69, 0xe3, 0xa0, 0x84, 0x7c, 0xe1, 0xf5, 0x10, 0x31, 0x95, 0xe4, - 0x70, 0x66, 0xeb, 0x1e, 0xde, 0xb9, 0x16, 0x24, 0x32, 0x9d, 0xe2, 0x06, 0xb8, 0xc2, 0xc9, 0x41, - 0xba, 0xf1, 0x29, 0x48, 0x5a, 0x10, 0x43, 0xa3, 0x9e,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xbc, 0xea, 0xf1, 0xd3, 0x51, 0x07, + 0x45, 0x08, 0xfe, 0x4c, 0xa0, 0x17, 0x79, 0x00, 0x51, 0x25, 0x62, 0x30, 0x5d, 0x72, 0x5d, 0x41, + 0xc3, 0x7e, 0x16, 0xbd, 0xe0, 0xd0, 0x02, 0x70, 0xc1, 0xac, 0xd5, 0xca, 0xd5, 0xd2, 0x56, 0x45, + 0xef, 0x46, 0x3b, 0x1a, 0x89, 0x87, 0x00, 0x5c, 0xaf, 0x2b, 0xa8, 0xc7, 0x6c, 0x5e, 0x87, 0xd0, + 0x4e, 0xc6, 0x27, 0x74, 0x48, 0x5e, 0x1f, 0x07, 0x4f, 0x0c, 0x05, 0x53, 0xda, 0x75, 0x58, 0x19, + 0x2c, 0x2c, 0x81, 0x51, 0x62, 0xc8, 0xb6, 0xda, 0xf4, 0x3c, 0x58, 0x43, 0xb9, 0x18, 0x37, 0x88, + 0x40, 0xe4, 0xd1, 0xff, 0x38, 0x62, 0x91, 0x1b, 0x7a, 0x8f, 0xff, 0x8c, 0x13, 0x2b, 0xc4, 0xd8, + 0xce, 0x7e, 0x9e, 0xb3, 0x5a, 0x7a, 0x1a, 0x91, 0x8f, 0xe2, 0x33, 0xc1, 0x8b, 0xc2, 0x1a, 0xc2, + 0xcd, 0xab, 0x90, 0x11, 0x99, 0x63, 0x30, 0x06, 0x31, 0x18, 0x4c, 0x88, 0x01, 0x31, 0x24, 0x1b, + 0x11, 0x17, 0x1a, 0x37, 0xdd, 0xa9, 0xd7, 0x9d, 0xab, 0x5b, 0x95, 0x9f, 0xdf, 0x29, 0xa8, 0x37, + 0xbc, 0x2d, 0x78, 0xc3, 0x40, 0xdb, 0x8b, 0xfc, 0x13, 0xa4, 0xe1, 0x88, 0xd4, 0x05, 0x5c, 0x8d, + 0x3f, 0xe5, 0x1e, 0x03, 0xee, 0x10, 0x04, 0x50, 0x27, 0x86, 0x30, 0xb4, 0xe9, 0x49, 0x36, 0x06, + 0x95, 0x92, 0x83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0x32, 0x6b, 0x35, 0x9f, 0x71, 0xa7, + 0x59, 0xab, 0x9d, 0xb3, 0xc8, 0xdb, 0x0a, 0xea, 0x97, 0xe8, 0xf8, 0xad, 0xb7, 0x19, 0xf8, 0xde, + 0x48, 0xec, 0x3c, 0x83, 0x16, 0x1a, 0xd1, 0xd6, 0x1b, 0xcc, 0x78, 0x1d, 0x44, 0xd8, 0x2e, 0x39, + 0x0b, 0x28, 0x2e, 0x38, 0xd6, 0x72, 0xc5, 0xd6, 0xcd, 0x8a, 0x59, 0x5d, 0x14, 0xe7, 0x3e, 0x98, + 0xa5, 0x4a, 0x6a, 0x96, 0xde, 0x10, 0xa3, 0xbd, 0x88, 0x29, 0x9f, 0x51, 0x68, 0x21, 0x91, 0x51, + 0x48, 0x32, 0xca, 0x68, 0x89, 0x2d, 0x16, 0x8a, 0x7c, 0x95, 0x18, 0x61, 0xbb, 0x73, 0x77, 0x06, + 0x50, 0x27, 0xc3, 0x81, 0xdf, 0x50, 0x10, 0xf2, 0x27, 0xb6, 0x78, 0x42, 0xba, 0x55, 0xd3, 0x1c, + 0x59, 0x9d, 0x4c, 0x95, 0xe3, 0x94, 0x08, 0x79, 0xf3, 0xce, 0x1f, 0x1f, 0xb4, 0x0f, 0x62, 0x55, + 0x8b, 0x1b, 0x9c, 0x37, 0xf0, 0x5b, 0x0a, 0xda, 0xe1, 0xa9, 0xe2, 0xf1, 0x64, 0xd3, 0x02, 0xc1, + 0x44, 0x9a, 0x18, 0x00, 0x98, 0x64, 0x00, 0x46, 0xf1, 0x70, 0x3c, 0x00, 0x6d, 0xb5, 0x6c, 0xad, + 0xe1, 0xcf, 0x14, 0x78, 0x60, 0x84, 0xe7, 0x64, 0x58, 0x8b, 0xdf, 0x48, 0x3a, 0xa0, 0x55, 0x0f, + 0x65, 0x57, 0x00, 0x8c, 0x87, 0x19, 0xc6, 0x19, 0x7c, 0x30, 0x1e, 0x63, 0xa1, 0xb8, 0x52, 0x60, + 0x37, 0x9a, 0xb6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, 0x8c, 0x25, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1723,6 +1803,7 @@ type QueryClient interface { QueryPoolAssetLBMapping(ctx context.Context, in *QueryPoolAssetLBMappingRequest, opts ...grpc.CallOption) (*QueryPoolAssetLBMappingResponse, error) QueryReserveBuybackAssetData(ctx context.Context, in *QueryReserveBuybackAssetDataRequest, opts ...grpc.CallOption) (*QueryReserveBuybackAssetDataResponse, error) QueryAuctionParams(ctx context.Context, in *QueryAuctionParamRequest, opts ...grpc.CallOption) (*QueryAuctionParamResponse, error) + QueryModuleBalance(ctx context.Context, in *QueryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryModuleBalanceResponse, error) } type queryClient struct { @@ -1913,6 +1994,15 @@ func (c *queryClient) QueryAuctionParams(ctx context.Context, in *QueryAuctionPa return out, nil } +func (c *queryClient) QueryModuleBalance(ctx context.Context, in *QueryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryModuleBalanceResponse, error) { + out := new(QueryModuleBalanceResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryModuleBalance", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { QueryLends(context.Context, *QueryLendsRequest) (*QueryLendsResponse, error) @@ -1935,6 +2025,7 @@ type QueryServer interface { QueryPoolAssetLBMapping(context.Context, *QueryPoolAssetLBMappingRequest) (*QueryPoolAssetLBMappingResponse, error) QueryReserveBuybackAssetData(context.Context, *QueryReserveBuybackAssetDataRequest) (*QueryReserveBuybackAssetDataResponse, error) QueryAuctionParams(context.Context, *QueryAuctionParamRequest) (*QueryAuctionParamResponse, error) + QueryModuleBalance(context.Context, *QueryModuleBalanceRequest) (*QueryModuleBalanceResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -2001,6 +2092,9 @@ func (*UnimplementedQueryServer) QueryReserveBuybackAssetData(ctx context.Contex func (*UnimplementedQueryServer) QueryAuctionParams(ctx context.Context, req *QueryAuctionParamRequest) (*QueryAuctionParamResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAuctionParams not implemented") } +func (*UnimplementedQueryServer) QueryModuleBalance(ctx context.Context, req *QueryModuleBalanceRequest) (*QueryModuleBalanceResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryModuleBalance not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -2366,6 +2460,24 @@ func _Query_QueryAuctionParams_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_QueryModuleBalance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryModuleBalanceRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryModuleBalance(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/comdex.lend.v1beta1.Query/QueryModuleBalance", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryModuleBalance(ctx, req.(*QueryModuleBalanceRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "comdex.lend.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -2450,6 +2562,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryAuctionParams", Handler: _Query_QueryAuctionParams_Handler, }, + { + MethodName: "QueryModuleBalance", + Handler: _Query_QueryModuleBalance_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "comdex/lend/v1beta1/query.proto", @@ -3948,6 +4064,67 @@ func (m *QueryAuctionParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryModuleBalanceRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryModuleBalanceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryModuleBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PoolId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryModuleBalanceResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryModuleBalanceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryModuleBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.ModuleBalance.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -4534,6 +4711,29 @@ func (m *QueryAuctionParamResponse) Size() (n int) { return n } +func (m *QueryModuleBalanceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) + } + return n +} + +func (m *QueryModuleBalanceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.ModuleBalance.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -8305,6 +8505,158 @@ func (m *QueryAuctionParamResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryModuleBalanceRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryModuleBalanceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryModuleBalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryModuleBalanceResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryModuleBalanceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryModuleBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ModuleBalance", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ModuleBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/lend/types/query.pb.gw.go b/x/lend/types/query.pb.gw.go index 3eb6c7af3..7bb3cf335 100644 --- a/x/lend/types/query.pb.gw.go +++ b/x/lend/types/query.pb.gw.go @@ -1129,6 +1129,60 @@ func local_request_Query_QueryAuctionParams_0(ctx context.Context, marshaler run } +func request_Query_QueryModuleBalance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryModuleBalanceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := client.QueryModuleBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryModuleBalance_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryModuleBalanceRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["pool_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + } + + protoReq.PoolId, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + } + + msg, err := server.QueryModuleBalance(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -1595,6 +1649,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryModuleBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryModuleBalance_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryModuleBalance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2036,6 +2113,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryModuleBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryModuleBalance_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryModuleBalance_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -2079,6 +2176,8 @@ var ( pattern_Query_QueryReserveBuybackAssetData_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"comdex", "lend", "v1beta1", "reserve_buyback_asset_data", "asset_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryAuctionParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"comdex", "lend", "v1beta1", "auctionparams", "app_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryModuleBalance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"comdex", "lend", "v1beta1", "module_balance", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -2121,4 +2220,6 @@ var ( forward_Query_QueryReserveBuybackAssetData_0 = runtime.ForwardResponseMessage forward_Query_QueryAuctionParams_0 = runtime.ForwardResponseMessage + + forward_Query_QueryModuleBalance_0 = runtime.ForwardResponseMessage ) diff --git a/x/lend/types/tx.go b/x/lend/types/tx.go index 2a2f3b045..80f2d3ada 100644 --- a/x/lend/types/tx.go +++ b/x/lend/types/tx.go @@ -24,17 +24,17 @@ func (msg *MsgLend) ValidateBasic() error { if err != nil { return err } - if msg.AssetId <= 0 { - return fmt.Errorf("asset id should be positive: %d > 0", msg.AssetId) + if msg.AssetId == 0 { + return fmt.Errorf("asset id should not be 0: %d ", msg.AssetId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) } - if msg.PoolId <= 0 { - return fmt.Errorf("pool id should be positive: %d > 0", msg.AssetId) + if msg.PoolId == 0 { + return fmt.Errorf("pool id should not be 0: %d ", msg.AssetId) } - if msg.AppId <= 0 { - return fmt.Errorf("app id should be positive: %d > 0", msg.AppId) + if msg.AppId == 0 { + return fmt.Errorf("app id should not be 0: %d ", msg.AppId) } return nil @@ -68,8 +68,8 @@ func (msg *MsgWithdraw) ValidateBasic() error { return err } - if msg.LendId <= 0 { - return fmt.Errorf("lend id should be positive: %d > 0", msg.LendId) + if msg.LendId == 0 { + return fmt.Errorf("lend id should not be 0: %d ", msg.LendId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -109,11 +109,11 @@ func (msg *MsgBorrow) ValidateBasic() error { return err } - if msg.LendId <= 0 { - return fmt.Errorf("lend id should be positive: %d > 0", msg.LendId) + if msg.LendId == 0 { + return fmt.Errorf("lend id should not be 0: %d ", msg.LendId) } - if msg.PairId <= 0 { - return fmt.Errorf("pair id should be positive: %d > 0", msg.PairId) + if msg.PairId == 0 { + return fmt.Errorf("pair id should not be 0: %d ", msg.PairId) } if msg.AmountIn.Amount.IsNegative() || msg.AmountIn.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.AmountIn.Amount) @@ -156,8 +156,8 @@ func (msg *MsgRepay) ValidateBasic() error { return err } - if msg.BorrowId <= 0 { - return fmt.Errorf("borrower id should be positive: %d > 0", msg.BorrowId) + if msg.BorrowId == 0 { + return fmt.Errorf("borrower id should not be 0: %d ", msg.BorrowId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -180,12 +180,12 @@ func (msg *MsgRepay) GetSignBytes() []byte { return sdk.MustSortJSON(bz) } -func NewMsgFundModuleAccounts(moduleName string, assetID uint64, lender string, amount sdk.Coin) *MsgFundModuleAccounts { +func NewMsgFundModuleAccounts(poolID, assetID uint64, lender string, amount sdk.Coin) *MsgFundModuleAccounts { return &MsgFundModuleAccounts{ - ModuleName: moduleName, - AssetId: assetID, - Lender: lender, - Amount: amount, + PoolId: poolID, + AssetId: assetID, + Lender: lender, + Amount: amount, } } @@ -197,12 +197,11 @@ func (msg *MsgFundModuleAccounts) ValidateBasic() error { if err != nil { return err } - if msg.ModuleName == "" { - return fmt.Errorf("module name can not be empty") + if msg.PoolId == 0 { + return fmt.Errorf("pool id should not be 0: %d ", msg.PoolId) } - - if msg.AssetId <= 0 { - return fmt.Errorf("asset id should be positive: %d > 0", msg.AssetId) + if msg.AssetId == 0 { + return fmt.Errorf("asset id should not be 0: %d ", msg.AssetId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -242,8 +241,8 @@ func (msg *MsgDeposit) ValidateBasic() error { return err } - if msg.LendId <= 0 { - return fmt.Errorf("lend id should be positive: %d > 0", msg.LendId) + if msg.LendId == 0 { + return fmt.Errorf("lend id should not be 0: %d ", msg.LendId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -281,8 +280,8 @@ func (msg *MsgCloseLend) ValidateBasic() error { if err != nil { return err } - if msg.LendId <= 0 { - return fmt.Errorf("lend id should be positive: %d > 0", msg.LendId) + if msg.LendId == 0 { + return fmt.Errorf("lend id should not be 0: %d ", msg.LendId) } return nil @@ -318,8 +317,8 @@ func (msg *MsgDraw) ValidateBasic() error { if err != nil { return err } - if msg.BorrowId <= 0 { - return fmt.Errorf("borrow id should be positive: %d > 0", msg.BorrowId) + if msg.BorrowId == 0 { + return fmt.Errorf("borrow id should not be 0: %d ", msg.BorrowId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -358,8 +357,8 @@ func (msg *MsgDepositBorrow) ValidateBasic() error { return err } - if msg.BorrowId <= 0 { - return fmt.Errorf("borrow id should be positive: %d > 0", msg.BorrowId) + if msg.BorrowId == 0 { + return fmt.Errorf("borrow id should not be 0: %d ", msg.BorrowId) } if msg.Amount.Amount.IsNegative() || msg.Amount.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.Amount.Amount) @@ -396,8 +395,8 @@ func (msg *MsgCloseBorrow) ValidateBasic() error { if err != nil { return err } - if msg.BorrowId <= 0 { - return fmt.Errorf("borrow id should be positive: %d > 0", msg.BorrowId) + if msg.BorrowId == 0 { + return fmt.Errorf("borrow id should not be 0: %d ", msg.BorrowId) } return nil @@ -439,17 +438,17 @@ func (msg *MsgBorrowAlternate) ValidateBasic() error { return err } - if msg.AssetId <= 0 { - return fmt.Errorf("asset id should be positive: %d > 0", msg.AssetId) + if msg.AssetId == 0 { + return fmt.Errorf("asset id should not be 0: %d ", msg.AssetId) } - if msg.PoolId <= 0 { - return fmt.Errorf("pool id should be positive: %d > 0", msg.PoolId) + if msg.PoolId == 0 { + return fmt.Errorf("pool id should not be 0: %d ", msg.PoolId) } - if msg.PairId <= 0 { - return fmt.Errorf("pair id should be positive: %d > 0", msg.PairId) + if msg.PairId == 0 { + return fmt.Errorf("pair id should not be 0: %d ", msg.PairId) } - if msg.AppId <= 0 { - return fmt.Errorf("pair id should be positive: %d > 0", msg.AppId) + if msg.AppId == 0 { + return fmt.Errorf("pair id should not be 0: %d ", msg.AppId) } if msg.AmountIn.Amount.IsNegative() || msg.AmountIn.Amount.IsZero() { return fmt.Errorf("invalid coin amount: %s < 0", msg.AmountIn.Amount) diff --git a/x/lend/types/tx.pb.go b/x/lend/types/tx.pb.go index 67bc4e813..6a2804413 100644 --- a/x/lend/types/tx.pb.go +++ b/x/lend/types/tx.pb.go @@ -694,10 +694,10 @@ func (m *MsgBorrowAlternate) GetAppId() uint64 { } type MsgFundModuleAccounts struct { - ModuleName string `protobuf:"bytes,1,opt,name=moduleName,proto3" json:"moduleName,omitempty"` - AssetId uint64 `protobuf:"varint,2,opt,name=assetId,proto3" json:"assetId,omitempty"` - Lender string `protobuf:"bytes,3,opt,name=lender,proto3" json:"lender,omitempty"` - Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` + PoolId uint64 `protobuf:"varint,1,opt,name=poolId,proto3" json:"poolId,omitempty"` + AssetId uint64 `protobuf:"varint,2,opt,name=assetId,proto3" json:"assetId,omitempty"` + Lender string `protobuf:"bytes,3,opt,name=lender,proto3" json:"lender,omitempty"` + Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` } func (m *MsgFundModuleAccounts) Reset() { *m = MsgFundModuleAccounts{} } @@ -733,11 +733,11 @@ func (m *MsgFundModuleAccounts) XXX_DiscardUnknown() { var xxx_messageInfo_MsgFundModuleAccounts proto.InternalMessageInfo -func (m *MsgFundModuleAccounts) GetModuleName() string { +func (m *MsgFundModuleAccounts) GetPoolId() uint64 { if m != nil { - return m.ModuleName + return m.PoolId } - return "" + return 0 } func (m *MsgFundModuleAccounts) GetAssetId() uint64 { @@ -1269,65 +1269,65 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/tx.proto", fileDescriptor_957d64b59d60594d) } var fileDescriptor_957d64b59d60594d = []byte{ - // 926 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x5f, 0x6f, 0xdb, 0x54, - 0x14, 0xaf, 0x9b, 0xd4, 0x49, 0x4e, 0x61, 0x7f, 0x6e, 0xff, 0x2c, 0xf3, 0x3a, 0xb7, 0x18, 0xb6, - 0x05, 0xd0, 0x6c, 0xad, 0x7b, 0xe0, 0x81, 0x09, 0xd4, 0xae, 0x42, 0x64, 0xc2, 0x80, 0x32, 0x09, - 0x04, 0x2f, 0xd1, 0x4d, 0x7c, 0xe7, 0x59, 0x38, 0xbe, 0x96, 0xef, 0xcd, 0xb2, 0x09, 0x5e, 0x10, - 0xbc, 0xc3, 0x67, 0x40, 0xe2, 0x3b, 0xf0, 0x11, 0xf6, 0xb8, 0x47, 0x9e, 0x10, 0x6a, 0xbf, 0x08, - 0xf2, 0xf5, 0xf5, 0x8d, 0xd3, 0xc5, 0x4e, 0xba, 0x8a, 0xbe, 0xf9, 0x9e, 0xf3, 0x3b, 0x7f, 0x7a, - 0xce, 0xef, 0x9c, 0xd3, 0xc0, 0xce, 0x90, 0x8e, 0x3c, 0xf2, 0xdc, 0x09, 0x49, 0xe4, 0x39, 0xcf, - 0xee, 0x0d, 0x08, 0xc7, 0xf7, 0x1c, 0xfe, 0xdc, 0x8e, 0x13, 0xca, 0x29, 0xda, 0xc8, 0xb4, 0x76, - 0xaa, 0xb5, 0xa5, 0xd6, 0x30, 0x87, 0x94, 0x8d, 0x28, 0x73, 0x06, 0x98, 0x11, 0x65, 0x32, 0xa4, - 0x41, 0x94, 0x19, 0x19, 0x9b, 0x3e, 0xf5, 0xa9, 0xf8, 0x74, 0xd2, 0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ef, - 0x6d, 0x3f, 0xe0, 0x4f, 0xc7, 0x83, 0xd4, 0xb9, 0x93, 0x05, 0xb8, 0x4b, 0x9f, 0x3c, 0x09, 0x86, - 0x01, 0x0e, 0xe5, 0xdb, 0x91, 0xbf, 0x90, 0xf8, 0x8b, 0x98, 0xb0, 0x81, 0x2e, 0x7e, 0xd2, 0xdc, - 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xad, 0x28, 0x2c, 0x5f, 0x3d, 0x0d, 0x00, 0x00, + // 921 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x8f, 0xdb, 0x44, + 0x14, 0x5f, 0x6f, 0xb2, 0x4e, 0xf2, 0x16, 0xfa, 0xc7, 0xfb, 0xa7, 0xa9, 0xbb, 0xf5, 0x06, 0x43, + 0xdb, 0x00, 0xaa, 0xad, 0x6e, 0x0f, 0x1c, 0xa8, 0x40, 0xbb, 0x5d, 0x21, 0x52, 0x61, 0x81, 0x52, + 0x09, 0x04, 0x97, 0x68, 0x12, 0x4f, 0x5d, 0x0b, 0xaf, 0xc7, 0xf2, 0x4c, 0x9a, 0x56, 0x70, 0x41, + 0x70, 0x87, 0x33, 0x77, 0xbe, 0x03, 0x1f, 0xa1, 0xc7, 0x1e, 0x39, 0x21, 0xb4, 0xfb, 0x45, 0xd0, + 0x8c, 0xc7, 0x13, 0x67, 0x1b, 0x3b, 0xd9, 0xae, 0xba, 0xb7, 0x99, 0x79, 0x7f, 0xf3, 0x7b, 0xbf, + 0xf7, 0x5e, 0x0c, 0x3b, 0x23, 0x72, 0xe4, 0xe3, 0xe7, 0x6e, 0x84, 0x63, 0xdf, 0x7d, 0x76, 0x6f, + 0x88, 0x19, 0xba, 0xe7, 0xb2, 0xe7, 0x4e, 0x92, 0x12, 0x46, 0x8c, 0x8d, 0x4c, 0xea, 0x70, 0xa9, + 0x23, 0xa5, 0xa6, 0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0x55, 0x68, 0x79, 0x34, 0x38, 0x20, + 0x69, 0x4a, 0x26, 0x86, 0x09, 0xcd, 0xa1, 0x38, 0x29, 0x07, 0xea, 0x5e, 0x9e, 0x3c, 0x2f, 0x12, + 0x0a, 0x53, 0x2e, 0xa8, 0xc9, 0x22, 0xa1, 0x30, 0xed, 0xf9, 0x46, 0x17, 0xae, 0x84, 0x74, 0x40, + 0x19, 0x1a, 0x46, 0x78, 0x90, 0xf9, 0x11, 0x65, 0x6c, 0xf6, 0x2f, 0x85, 0xf4, 0xb1, 0x78, 0x96, + 0x71, 0x1f, 0x40, 0x2b, 0xfb, 0x41, 0x83, 0x30, 0x16, 0x15, 0x5d, 0x02, 0x82, 0x66, 0x66, 0xd1, + 0x8b, 0x8d, 0xcf, 0x00, 0xa4, 0x35, 0x19, 0xb3, 0xb6, 0xbe, 0x9c, 0xb9, 0x0c, 0xf8, 0xf5, 0x98, + 0xd9, 0x3f, 0x43, 0xd3, 0xa3, 0x41, 0x1f, 0x27, 0xe8, 0x45, 0x25, 0x02, 0x37, 0xa0, 0x95, 0x9d, + 0xa7, 0x18, 0x48, 0xe1, 0x79, 0x4a, 0xf8, 0x9b, 0x06, 0x57, 0xa6, 0xdc, 0x59, 0xa2, 0x10, 0x6f, + 0x27, 0x8d, 0x9f, 0x44, 0x87, 0x1f, 0xf2, 0xb6, 0xb9, 0xf8, 0xe0, 0x3d, 0xb8, 0x94, 0xd3, 0xf8, + 0x9c, 0x00, 0xd8, 0x7f, 0xaf, 0x82, 0xa1, 0x08, 0xbd, 0x1f, 0x31, 0x9c, 0xc6, 0x88, 0xe1, 0x37, + 0x99, 0x5a, 0x85, 0xe1, 0x53, 0x9b, 0x19, 0x3e, 0x33, 0x6c, 0xad, 0x9f, 0x95, 0xad, 0x85, 0x76, + 0x59, 0x5b, 0xd8, 0x2e, 0xfa, 0xdc, 0x76, 0x99, 0x25, 0x7c, 0xe3, 0xac, 0x84, 0x2f, 0x4c, 0xcf, + 0x66, 0x71, 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xf6, 0xc7, 0x89, + 0xb5, 0xf2, 0xea, 0xc4, 0x5a, 0xf9, 0xe7, 0xc4, 0x5a, 0xf9, 0xc1, 0x09, 0x42, 0xf6, 0x74, 0x3c, + 0xe4, 0xce, 0xdd, 0x2c, 0xc0, 0x5d, 0xf2, 0xe4, 0x49, 0x38, 0x0a, 0x51, 0x24, 0xef, 0xae, 0xfc, + 0x32, 0x62, 0x2f, 0x12, 0x4c, 0x87, 0xba, 0xf8, 0x94, 0xb9, 0xff, 0x7f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xef, 0x86, 0x56, 0x0a, 0x35, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2360,12 +2360,10 @@ func (m *MsgFundModuleAccounts) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.ModuleName) > 0 { - i -= len(m.ModuleName) - copy(dAtA[i:], m.ModuleName) - i = encodeVarintTx(dAtA, i, uint64(len(m.ModuleName))) + if m.PoolId != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.PoolId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -2897,9 +2895,8 @@ func (m *MsgFundModuleAccounts) Size() (n int) { } var l int _ = l - l = len(m.ModuleName) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.PoolId != 0 { + n += 1 + sovTx(uint64(m.PoolId)) } if m.AssetId != 0 { n += 1 + sovTx(uint64(m.AssetId)) @@ -4564,10 +4561,10 @@ func (m *MsgFundModuleAccounts) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ModuleName", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) } - var stringLen uint64 + m.PoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -4577,24 +4574,11 @@ func (m *MsgFundModuleAccounts) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.PoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ModuleName = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) diff --git a/x/liquidation/expected/keeper.go b/x/liquidation/expected/keeper.go index 8be701a9d..bdde6c792 100644 --- a/x/liquidation/expected/keeper.go +++ b/x/liquidation/expected/keeper.go @@ -9,6 +9,7 @@ import ( esmtypes "github.com/comdex-official/comdex/x/esm/types" lendtypes "github.com/comdex-official/comdex/x/lend/types" liquidationtypes "github.com/comdex-official/comdex/x/liquidation/types" + markettypes "github.com/comdex-official/comdex/x/market/types" rewardstypes "github.com/comdex-official/comdex/x/rewards/types" "github.com/comdex-official/comdex/x/vault/types" ) @@ -51,6 +52,7 @@ type VaultKeeper interface { type MarketKeeper interface { CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Dec, err error) + GetTwa(ctx sdk.Context, id uint64) (twa markettypes.TimeWeightedAverage, found bool) } type AuctionKeeper interface { @@ -80,6 +82,9 @@ type LendKeeper interface { UpdateReserveBalances(ctx sdk.Context, assetID uint64, moduleName string, payment sdk.Coin, inc bool) error SetLend(ctx sdk.Context, lend lendtypes.LendAsset) SetBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset) + MsgCalculateBorrowInterest(ctx sdk.Context, borrowerAddr string, borrowID uint64) error + ReBalanceStableRates(ctx sdk.Context, borrowPos lendtypes.BorrowAsset) (lendtypes.BorrowAsset, error) + DeleteBorrow(ctx sdk.Context, ID uint64) } type RewardsKeeper interface { diff --git a/x/liquidation/keeper/liquidate_borrow.go b/x/liquidation/keeper/liquidate_borrow.go index 01efb566f..2efee6c8c 100644 --- a/x/liquidation/keeper/liquidate_borrow.go +++ b/x/liquidation/keeper/liquidate_borrow.go @@ -12,6 +12,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { borrows, found := k.lend.GetBorrows(ctx) params := k.GetParams(ctx) if !found { + ctx.Logger().Error("Params Not Found in Liquidation, liquidate_borrow.go") return nil } liquidationOffsetHolder, found := k.GetLiquidationOffsetHolder(ctx, lendtypes.AppID, types.VaultLiquidationsOffsetPrefix) @@ -37,10 +38,34 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { lendPair, _ := k.lend.GetLendPair(ctx, borrowPos.PairID) lendPos, found := k.lend.GetLend(ctx, borrowPos.LendingID) if !found { + ctx.Logger().Error("Lend Pos Not Found in Liquidation, liquidate_borrow.go for ID %d", borrowPos.LendingID) continue } + + // calculating and updating the interest accumulated before checking for liquidations + err := k.lend.MsgCalculateBorrowInterest(ctx, lendPos.Owner, borrowPos.ID) + if err != nil { + ctx.Logger().Error("error in calculating Borrow Interest before liquidation") + continue + } + borrowPos, _ = k.lend.GetBorrow(ctx, newBorrowIDs[l]) + if !borrowPos.StableBorrowRate.Equal(sdk.ZeroDec()) { + borrowPos, err = k.lend.ReBalanceStableRates(ctx, borrowPos) + if err != nil { + ctx.Logger().Error("error in re-balance stable rate check before liquidation") + continue + } + } + killSwitchParams, _ := k.esm.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { + ctx.Logger().Error("Kill Switch is enabled in Liquidation, liquidate_borrow.go for ID %d", lendPos.AppID) + continue + } + // calculating and updating the interest accumulated before checking for liquidations + err1 := k.lend.MsgCalculateBorrowInterest(ctx, lendPos.Owner, borrowPos.ID) + if err1 != nil { + ctx.Logger().Error("Error in calculating Borrow Interest before liquidation, liquidate_borrow.go for ID %d", borrowPos.ID) continue } pool, _ := k.lend.GetPool(ctx, lendPos.PoolID) @@ -68,55 +93,59 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { // b. if borrow is from first transit asset // c. if borrow is from second transit asset if borrowPos.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { // first condition - currentCollateralizationRatio, _ = k.lend.CalculateCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()), assetOut) + currentCollateralizationRatio, err = k.lend.CalculateCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()), assetOut) + if err != nil { + ctx.Logger().Error("Error in CalculateCollateralizationRatio for borrow pos ") + continue + } if sdk.Dec.GT(currentCollateralizationRatio, liqThreshold.LiquidationThreshold) { // after checking the currentCollateralizationRatio with LiquidationThreshold if borrow is to be liquidated then // CreateLockedBorrow function is called - err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) + lockedVault, err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) if err != nil { + ctx.Logger().Error("Error in first condition CreateLockedBorrow in Liquidation, liquidate_borrow.go for ID %d", borrowPos.LendingID) continue } borrowPos.IsLiquidated = true // isLiquidated flag is set to true k.lend.SetBorrow(ctx, borrowPos) - lockedVaultID := k.GetLockedVaultID(ctx) - lockedVault, _ := k.GetLockedVault(ctx, lendPos.AppID, lockedVaultID) err = k.UpdateLockedBorrows(ctx, lockedVault) if err != nil { - return nil + ctx.Logger().Error("Error in first condition UpdateLockedBorrows in UpdateLockedBorrows , liquidate_borrow.go for ID %d", lockedVault.LockedVaultId) + continue } } } else { if borrowPos.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { currentCollateralizationRatio, _ = k.lend.CalculateCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()), assetOut) if sdk.Dec.GT(currentCollateralizationRatio, liqThreshold.LiquidationThreshold.Mul(liqThresholdBridgedAssetOne.LiquidationThreshold)) { - err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) + lockedVault, err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) if err != nil { + ctx.Logger().Error("Error in second condition CreateLockedBorrow in Liquidation, liquidate_borrow.go for ID %d", borrowPos.LendingID) continue } borrowPos.IsLiquidated = true k.lend.SetBorrow(ctx, borrowPos) - lockedVaultID := k.GetLockedVaultID(ctx) - lockedVault, _ := k.GetLockedVault(ctx, lendPos.AppID, lockedVaultID) err = k.UpdateLockedBorrows(ctx, lockedVault) if err != nil { - return nil + ctx.Logger().Error("Error in second condition UpdateLockedBorrows in UpdateLockedBorrows, liquidate_borrow.go for ID %d", lockedVault.LockedVaultId) + continue } } } else { currentCollateralizationRatio, _ = k.lend.CalculateCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()), assetOut) if sdk.Dec.GT(currentCollateralizationRatio, liqThreshold.LiquidationThreshold.Mul(liqThresholdBridgedAssetTwo.LiquidationThreshold)) { - err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) + lockedVault, err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) if err != nil { + ctx.Logger().Error("Error in third condition CreateLockedBorrow in Liquidation, liquidate_borrow.go for ID %d", borrowPos.LendingID) continue } borrowPos.IsLiquidated = true k.lend.SetBorrow(ctx, borrowPos) - lockedVaultID := k.GetLockedVaultID(ctx) - lockedVault, _ := k.GetLockedVault(ctx, lendPos.AppID, lockedVaultID) err = k.UpdateLockedBorrows(ctx, lockedVault) if err != nil { - return nil + ctx.Logger().Error("Error in third condition UpdateLockedBorrows in UpdateLockedBorrows, liquidate_borrow.go for ID %d", lockedVault.LockedVaultId) + continue } } } @@ -128,7 +157,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { return nil } -func (k Keeper) CreateLockedBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset, collateralizationRatio sdk.Dec, appID uint64) error { +func (k Keeper) CreateLockedBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset, collateralizationRatio sdk.Dec, appID uint64) (types.LockedVault, error) { lockedVaultID := k.GetLockedVaultID(ctx) lendPos, _ := k.lend.GetLend(ctx, borrow.LendingID) kind := &types.LockedVault_BorrowMetaData{ @@ -161,7 +190,7 @@ func (k Keeper) CreateLockedBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset } k.SetLockedVault(ctx, value) k.SetLockedVaultID(ctx, value.LockedVaultId) - return nil + return value, nil } func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVault) error { @@ -188,13 +217,13 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVau liqThreshold, _ := k.lend.GetAssetRatesParams(ctx, pair.AssetIn) // finding unLiquidate Point percentage - if !borrowMetaData.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { + if !borrowMetaData.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { // if bridged asset is being used for borrow (inter-pool borrow) if borrowMetaData.BridgedAssetAmount.Denom == firstBridgeAsset.Denom { unliquidatePointPercentage = liqThreshold.LiquidationThreshold.Mul(firstBridgeAssetStats.LiquidationThreshold) } else { unliquidatePointPercentage = liqThreshold.LiquidationThreshold.Mul(secondBridgeAssetStats.LiquidationThreshold) } - } else { + } else { // same pool borrow unliquidatePointPercentage = liqThreshold.LiquidationThreshold } @@ -206,11 +235,16 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVau assetOut, _ := k.asset.GetAsset(ctx, pair.AssetOut) collateralizationRatio, err := k.lend.CalculateCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if err != nil { - return nil + ctx.Logger().Error("Error Calculating CR in Liquidation, liquidate_borrow.go for locked vault ID %d", lockedVault.LockedVaultId) + return err } + assetInprice, _ := k.market.GetTwa(ctx, assetIn.Id) + assetOutprice, _ := k.market.GetTwa(ctx, assetOut.Id) - assetInTotal, _ := k.market.CalcAssetPrice(ctx, assetIn.Id, lockedVault.AmountIn) - assetOutTotal, _ := k.market.CalcAssetPrice(ctx, assetOut.Id, lockedVault.AmountOut) + assetInTotalUint := lockedVault.AmountIn.Mul(sdk.NewIntFromUint64(assetInprice.Twa)) + assetOutTotalUint := lockedVault.AmountOut.Mul(sdk.NewIntFromUint64(assetOutprice.Twa)) + assetInTotal := sdk.NewDecFromInt(assetInTotalUint) + assetOutTotal := sdk.NewDecFromInt(assetOutTotalUint) deductionPercentage, _ := sdk.NewDecFromStr("1.0") var c sdk.Dec @@ -236,8 +270,8 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVau // using this check as we want to deduct the liquidation penalty and auction bonus from the borrower position only once - // TODO: revisit - aip := sdk.NewDec(int64(1)) + // TODO: revisit : DONE + aip := sdk.NewDecFromInt(sdk.NewIntFromUint64(assetInprice.Twa)) liquidationDeductionAmt := selloffAmount.Mul(penalty) liquidationDeductionAmount := liquidationDeductionAmt.Quo(aip) bonusToBidderAmt := selloffAmount.Mul(assetRatesStats.LiquidationBonus) @@ -255,7 +289,8 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVau } cAsset, _ := k.asset.GetAsset(ctx, assetRatesStats.CAssetID) // totalDeduction is the sum of liquidationDeductionAmount and selloffAmount - totalDeduction := liquidationDeductionAmount.TruncateInt().Add(selloffAmount.TruncateInt()) + sellOffAmt := selloffAmount.Quo(aip) + totalDeduction := liquidationDeductionAmount.TruncateInt().Add(sellOffAmt.TruncateInt()) updatedLockedVault.AmountIn = updatedLockedVault.AmountIn.Sub(totalDeduction) lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(totalDeduction) if totalDeduction.GTE(updatedLockedVault.AmountIn) { // rare case only @@ -291,6 +326,7 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, lockedVault types.LockedVau err := k.auction.LendDutchActivator(ctx, updatedLockedVault) if err != nil { ctx.Logger().Error("error in dutch lend activator") + return err } } return nil @@ -300,8 +336,14 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc lockedVault, _ := k.GetLockedVault(ctx, appID, id) borrowMetadata := lockedVault.GetBorrowMetaData() if borrowMetadata != nil { - lendPos, _ := k.lend.GetLend(ctx, borrowMetadata.LendingId) - assetInPool, _ := k.lend.GetPool(ctx, lendPos.PoolID) + lendPos, found := k.lend.GetLend(ctx, borrowMetadata.LendingId) + if !found { + return lendtypes.ErrLendNotFound + } + assetInPool, found := k.lend.GetPool(ctx, lendPos.PoolID) + if !found { + return lendtypes.ErrPoolNotFound + } var firstTransitAssetID, secondTransitAssetID uint64 for _, data := range assetInPool.AssetData { if data.AssetTransitType == 2 { @@ -335,6 +377,10 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc return err } } + if lockedVault.AmountIn.IsZero() { + k.lend.DeleteBorrow(ctx, lockedVault.OriginalVaultId) + return nil + } newCalculatedCollateralizationRatio, _ := k.lend.CalculateCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if newCalculatedCollateralizationRatio.GT(unliquidatePointPercentage) { updatedLockedVault := lockedVault @@ -343,6 +389,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc k.SetLockedVault(ctx, updatedLockedVault) err := k.UpdateLockedBorrows(ctx, updatedLockedVault) if err != nil { + ctx.Logger().Error("Error in UnLiquidateLockedBorrows first condition UpdateLockedBorrows in Liquidation, liquidate_borrow.go for ID %d", updatedLockedVault.LockedVaultId) return nil } } @@ -379,6 +426,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc k.SetLockedVault(ctx, updatedLockedVault) err := k.UpdateLockedBorrows(ctx, updatedLockedVault) if err != nil { + ctx.Logger().Error("Error in UnLiquidateLockedBorrows second condition UpdateLockedBorrows in Liquidation, liquidate_borrow.go for ID %d", updatedLockedVault.LockedVaultId) return nil } } @@ -414,6 +462,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc k.SetLockedVault(ctx, updatedLockedVault) err := k.UpdateLockedBorrows(ctx, updatedLockedVault) if err != nil { + ctx.Logger().Error("Error in UnLiquidateLockedBorrows third condition UpdateLockedBorrows in Liquidation, liquidate_borrow.go for ID %d", updatedLockedVault.LockedVaultId) return nil } } diff --git a/x/liquidation/keeper/liquidate_vaults.go b/x/liquidation/keeper/liquidate_vaults.go index 4a98b98f9..85a920b35 100644 --- a/x/liquidation/keeper/liquidate_vaults.go +++ b/x/liquidation/keeper/liquidate_vaults.go @@ -21,7 +21,7 @@ func (k Keeper) LiquidateVaults(ctx sdk.Context) error { } klwsParams, _ := k.esm.GetKillSwitchData(ctx, appIds[i]) if klwsParams.BreakerEnable || status { - ctx.Logger().Info("Kill Switch Or ESM is enabled") + ctx.Logger().Error("Kill Switch Or ESM is enabled For Liquidation, liquidate_vaults.go for AppID %d", appIds[i]) continue } @@ -45,16 +45,19 @@ func (k Keeper) LiquidateVaults(ctx sdk.Context) error { newVaults := totalVaults[start:end] for _, vault := range newVaults { if vault.AppId != appIds[i] { + ctx.Logger().Error("Vault and app id mismatch in Liquidation, liquidate_vaults.go for vault ID %d", vault.Id) continue } extPair, _ := k.asset.GetPairsVault(ctx, vault.ExtendedPairVaultID) pair, _ := k.asset.GetPair(ctx, extPair.PairId) assetIn, found := k.asset.GetAsset(ctx, pair.AssetIn) if !found { + ctx.Logger().Error("Asset not found in Liquidation, liquidate_vaults.go for vault ID %d", vault.Id) continue } totalRate, err := k.market.CalcAssetPrice(ctx, assetIn.Id, vault.AmountIn) if err != nil { + ctx.Logger().Error("Error in CalcAssetPrice in Liquidation, liquidate_vaults.go for vault ID %d", vault.Id) continue } totalIn := totalRate @@ -63,6 +66,7 @@ func (k Keeper) LiquidateVaults(ctx sdk.Context) error { totalOut := vault.AmountOut.Add(vault.InterestAccumulated).Add(vault.ClosingFeeAccumulated) collateralizationRatio, err := k.vault.CalculateCollateralizationRatio(ctx, vault.ExtendedPairVaultID, vault.AmountIn, totalOut) if err != nil { + ctx.Logger().Error("Error Calculating CR in Liquidation, liquidate_vaults.go for vault ID %d", vault.Id) continue } if collateralizationRatio.LT(liqRatio) { @@ -70,16 +74,19 @@ func (k Keeper) LiquidateVaults(ctx sdk.Context) error { totalDebt := vault.AmountOut.Add(vault.InterestAccumulated) err1 := k.rewards.CalculateVaultInterest(ctx, vault.AppId, vault.ExtendedPairVaultID, vault.Id, totalDebt, vault.BlockHeight, vault.BlockTime.Unix()) if err1 != nil { + ctx.Logger().Error("Error Calculating vault interest in Liquidation, liquidate_vaults.go for vaultID %d", vault.Id) continue } vault, _ := k.vault.GetVault(ctx, vault.Id) totalFees := vault.InterestAccumulated.Add(vault.ClosingFeeAccumulated) collateralizationRatio, err := k.vault.CalculateCollateralizationRatio(ctx, vault.ExtendedPairVaultID, vault.AmountIn, totalOut) if err != nil { + ctx.Logger().Error("Error Calculating CR in Liquidation, liquidate_vaults.go for vaultID %d", vault.Id) continue } err = k.CreateLockedVault(ctx, vault, totalIn, collateralizationRatio, appIds[i], totalFees) if err != nil { + ctx.Logger().Error("Error Creating Locked Vaults in Liquidation, liquidate_vaults.go for Vault %d", vault.Id) continue } k.vault.DeleteVault(ctx, vault.Id) diff --git a/x/liquidation/keeper/liquidate_vaults_test.go b/x/liquidation/keeper/liquidate_vaults_test.go index 8ac69e1c0..981010835 100644 --- a/x/liquidation/keeper/liquidate_vaults_test.go +++ b/x/liquidation/keeper/liquidate_vaults_test.go @@ -72,7 +72,6 @@ func (s *KeeperTestSuite) SetOraclePrice(assetID uint64, price uint64) { PriceValue: []uint64{price}, } s.app.MarketKeeper.SetTwa(s.ctx, market) - } func (s *KeeperTestSuite) SetInitialOraclePriceForID(asset1 uint64, asset2 uint64) { @@ -190,7 +189,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, @@ -199,7 +198,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, @@ -208,7 +207,7 @@ func (s *KeeperTestSuite) AddAppAsset() { assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, }, }, diff --git a/x/liquidity/client/testutil/helpers.go b/x/liquidity/client/testutil/helpers.go index f02512942..5e2b194a1 100644 --- a/x/liquidity/client/testutil/helpers.go +++ b/x/liquidity/client/testutil/helpers.go @@ -77,7 +77,7 @@ func (s *LiquidityIntegrationTestSuite) CreateNewAsset(name, denom string, price err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) diff --git a/x/liquidity/keeper/keeper_test.go b/x/liquidity/keeper/keeper_test.go index f4ac716ca..6320ce5cf 100644 --- a/x/liquidity/keeper/keeper_test.go +++ b/x/liquidity/keeper/keeper_test.go @@ -116,7 +116,7 @@ func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) asset err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) diff --git a/x/liquidity/module_test.go b/x/liquidity/module_test.go index d3a9631a9..f988c6b5f 100644 --- a/x/liquidity/module_test.go +++ b/x/liquidity/module_test.go @@ -97,7 +97,7 @@ func (s *ModuleTestSuite) CreateNewAsset(name, denom string, price uint64) asset err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) diff --git a/x/locker/keeper/locker_test.go b/x/locker/keeper/locker_test.go index de5cf1a57..c387b1051 100644 --- a/x/locker/keeper/locker_test.go +++ b/x/locker/keeper/locker_test.go @@ -31,7 +31,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg3 := assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } @@ -41,7 +41,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg4 := assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg4) @@ -50,7 +50,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg5 := assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg5) diff --git a/x/market/keeper/keeper_test.go b/x/market/keeper/keeper_test.go index aff7b93e0..16034a55e 100644 --- a/x/market/keeper/keeper_test.go +++ b/x/market/keeper/keeper_test.go @@ -45,5 +45,9 @@ func TestFucn(t *testing.T) { test123 := sdk.Int(newAmtwithDec.Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(1000000))))) fmt.Println("test123 ", test123) fmt.Println("truncate ", finalAMount.TruncateInt()) +} +func TestFucn1(t *testing.T) { + x := sdk.MustNewDecFromStr("128345678.4567432") + fmt.Println("uint64 value", x.TruncateInt().Uint64()) } diff --git a/x/market/keeper/oracle.go b/x/market/keeper/oracle.go index d8e2c7f27..a0154265e 100644 --- a/x/market/keeper/oracle.go +++ b/x/market/keeper/oracle.go @@ -119,8 +119,62 @@ func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price s twa, found := k.GetTwa(ctx, id) if found && twa.IsPriceActive { numerator := sdk.NewDecFromInt(amt).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(twa.Twa))) - denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset.Decimals))) + denominator := sdk.NewDecFromInt(asset.Decimals) return numerator.Quo(denominator), nil } return sdk.ZeroDec(), types.ErrorPriceNotActive } + +// UNComment below and comment respective functions + +//func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Dec, err error) { +// asset, found := k.assetKeeper.GetAsset(ctx, id) +// if !found { +// return sdk.ZeroDec(), assetTypes.ErrorAssetDoesNotExist +// } +// // twa, found := k.GetTwa(ctx, id) +// var rate uint64 +// if id == 1 { +// rate = 1000000 +// } +// if id == 2 { +// rate = 1100000 +// } +// if id == 3 { +// rate = 1000000 +// } +// if id == 4 { +// rate = 1000000 +// } +// if id == 10 { +// rate = 1000000 +// } +// if found { +// numerator := sdk.NewDecFromInt(amt).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(rate))) +// denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset.Decimals))) +// return numerator.Quo(denominator), nil +// } +// return sdk.ZeroDec(), types.ErrorPriceNotActive +//} +// +//func (k Keeper) GetTwa(ctx sdk.Context, id uint64) (twa types.TimeWeightedAverage, found bool) { +// twa.AssetID = id +// twa.IsPriceActive = true +// if id == 1 { +// twa.Twa = 1000000 +// } +// if id == 2 { +// twa.Twa = 1100000 +// } +// if id == 3 { +// twa.Twa = 1000000 +// } +// if id == 4 { +// twa.Twa = 1000000 +// } +// if id == 10 { +// twa.Twa = 1000000 +// } +// +// return twa, true +//} diff --git a/x/market/types/keys.go b/x/market/types/keys.go index 9217daa3e..b2690ee55 100644 --- a/x/market/types/keys.go +++ b/x/market/types/keys.go @@ -5,7 +5,7 @@ import ( ) const ( - ModuleName = "market" + ModuleName = "marketV1" ParamsSubspace = ModuleName QuerierRoute = ModuleName RouterKey = ModuleName diff --git a/x/rewards/expected/keeper.go b/x/rewards/expected/keeper.go index d55604df5..8286d147e 100644 --- a/x/rewards/expected/keeper.go +++ b/x/rewards/expected/keeper.go @@ -64,7 +64,7 @@ type CollectorKeeper interface { GetAppToDenomsMapping(ctx sdk.Context, appID uint64) (appToDenom collectortypes.AppToDenomsMapping, found bool) GetNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64) (netFeeData collectortypes.AppAssetIdToFeeCollectedData, found bool) SetNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, fee sdk.Int) error - DecreaseNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, amount sdk.Int, netFeeCollectedData collectortypes.AppAssetIdToFeeCollectedData) error + DecreaseNetFeeCollectedData(ctx sdk.Context, appID, assetID uint64, amount sdk.Int) error } type VaultKeeper interface { diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index cceae122b..189c39648 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -583,11 +583,11 @@ func (k Keeper) CalculateLockerRewards(ctx sdk.Context, appID, assetID, lockerID newRewardDec := sdk.NewDec(newReward.Int64()) lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Sub(newRewardDec) k.SetLockerRewardTracker(ctx, lockerRewardsTracker) - netFeeCollectedData, found := k.collector.GetNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId) - if !found { - return nil - } - err = k.collector.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward, netFeeCollectedData) + // netFeeCollectedData, found := k.collector.GetNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId) + // if !found { + // return nil + // } + err = k.collector.DecreaseNetFeeCollectedData(ctx, appID, lockerData.AssetDepositId, newReward) if err != nil { return nil } diff --git a/x/tokenmint/keeper/mint_test.go b/x/tokenmint/keeper/mint_test.go index a433f09c0..afac97e2b 100644 --- a/x/tokenmint/keeper/mint_test.go +++ b/x/tokenmint/keeper/mint_test.go @@ -54,7 +54,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg3 := assetTypes.Asset{ Name: "CMDX", Denom: "ucmdx", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } @@ -64,7 +64,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg4 := assetTypes.Asset{ Name: "CMST", Denom: "ucmst", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } err = assetKeeper.AddAssetRecords(*ctx, msg4) @@ -73,7 +73,7 @@ func (s *KeeperTestSuite) AddAppAsset() { msg5 := assetTypes.Asset{ Name: "HARBOR", Denom: "uharbor", - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, } diff --git a/x/vault/client/testutil/helpers.go b/x/vault/client/testutil/helpers.go index 7bb4657b8..9734a7f84 100644 --- a/x/vault/client/testutil/helpers.go +++ b/x/vault/client/testutil/helpers.go @@ -93,7 +93,7 @@ func (s *VaultIntegrationTestSuite) CreateNewAsset(name, denom string, price uin err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) diff --git a/x/vault/keeper/keeper_test.go b/x/vault/keeper/keeper_test.go index 708ee95bd..d6ee2e632 100644 --- a/x/vault/keeper/keeper_test.go +++ b/x/vault/keeper/keeper_test.go @@ -103,7 +103,7 @@ func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) uint6 err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, }) diff --git a/x/vault/keeper/msg_server.go b/x/vault/keeper/msg_server.go index 4adcf2229..4b21658de 100644 --- a/x/vault/keeper/msg_server.go +++ b/x/vault/keeper/msg_server.go @@ -377,6 +377,9 @@ func (k msgServer) MsgWithdraw(c context.Context, msg *types.MsgWithdrawRequest) totalDebtCalculation = totalDebtCalculation.Add(userVault.ClosingFeeAccumulated) // Calculate CR - make necessary changes to the calculate collateralization function + if esmStatus.Status { + totalDebtCalculation = userVault.AmountOut + } if err := k.VerifyCollaterlizationRatio(ctx, extendedPairVault.Id, userVault.AmountIn, totalDebtCalculation, extendedPairVault.MinCr, status); err != nil { return nil, err } diff --git a/x/vault/keeper/query_server.go b/x/vault/keeper/query_server.go index a204b630e..8a02025af 100644 --- a/x/vault/keeper/query_server.go +++ b/x/vault/keeper/query_server.go @@ -663,7 +663,7 @@ func (q QueryServer) QueryUserMyPositionByApp(c context.Context, req *types.Quer if extPairVault.AssetOutOraclePrice { assetOutTotalPrice, _ = q.oracle.CalcAssetPrice(ctx, pairID.AssetOut, vault.AmountOut) } else { - assetOutTotalPrice = (sdk.NewDecFromInt(sdk.NewIntFromUint64(extPairVault.AssetOutPrice)).Mul(sdk.NewDecFromInt(vault.AmountOut))).Quo(sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(assetOutData.Decimals)))) + assetOutTotalPrice = (sdk.NewDecFromInt(sdk.NewIntFromUint64(extPairVault.AssetOutPrice)).Mul(sdk.NewDecFromInt(vault.AmountOut))).Quo(sdk.NewDecFromInt(assetOutData.Decimals)) } totalDue = assetOutTotalPrice.Add(totalDue) diff --git a/x/vault/keeper/vault.go b/x/vault/keeper/vault.go index aecc53354..01a43c478 100644 --- a/x/vault/keeper/vault.go +++ b/x/vault/keeper/vault.go @@ -327,25 +327,26 @@ func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, extendedPairVau // check to get calc asset price from esm if statusEsm && esmStatus.SnapshotStatus { - // TODO: function update - price, found := k.esm.GetSnapshotOfPrices(ctx, extendedPairVault.AppId, assetInData.Id) if !found { return sdk.ZeroDec(), types.ErrorPriceDoesNotExist } - assetInTotalPrice = sdk.NewDecFromInt(sdk.NewIntFromUint64(price)) + numerator := sdk.NewDecFromInt(amountIn).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(price))) + denominator := sdk.NewDecFromInt(assetInData.Decimals) + assetInTotalPrice = numerator.Quo(denominator) } var assetOutTotalPrice sdk.Dec if extendedPairVault.AssetOutOraclePrice { // If oracle Price required for the assetOut if statusEsm && esmStatus.SnapshotStatus { - // TODO: function update price, found := k.esm.GetSnapshotOfPrices(ctx, extendedPairVault.AppId, assetOutData.Id) if !found { return sdk.ZeroDec(), types.ErrorPriceDoesNotExist } - assetInTotalPrice = sdk.NewDecFromInt(sdk.NewIntFromUint64(price)) + numerator := sdk.NewDecFromInt(amountOut).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(price))) + denominator := sdk.NewDecFromInt(assetOutData.Decimals) + assetOutTotalPrice = numerator.Quo(denominator) } else { assetOutTotalPrice, err = k.oracle.CalcAssetPrice(ctx, assetOutData.Id, amountOut) if err != nil { @@ -354,7 +355,9 @@ func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, extendedPairVau } } else { // If oracle Price is not required for the assetOut - assetOutTotalPrice = (sdk.NewDecFromInt(sdk.NewIntFromUint64(extendedPairVault.AssetOutPrice)).Mul(sdk.NewDecFromInt(amountOut))).Quo(sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(assetOutData.Decimals)))) + numerator := sdk.NewDecFromInt(amountOut).Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(extendedPairVault.AssetOutPrice))) + denominator := sdk.NewDecFromInt(assetOutData.Decimals) + assetOutTotalPrice = numerator.Quo(denominator) } if assetInTotalPrice.LTE(sdk.ZeroDec()) { @@ -670,11 +673,11 @@ func (k Keeper) GetAmountOfOtherToken(ctx sdk.Context, id1 uint64, rate1 sdk.Dec } numerator := sdk.NewDecFromInt(amt1).Mul(rate1) - denominator := sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset1.Decimals))) + denominator := sdk.NewDecFromInt(asset1.Decimals) t1dAmount := numerator.Quo(denominator) newAmount := t1dAmount.Quo(rate2) - tokenAmount := newAmount.Mul(sdk.NewDecFromInt(sdk.NewIntFromUint64(uint64(asset2.Decimals)))) + tokenAmount := newAmount.Mul(sdk.NewDecFromInt(asset2.Decimals)) // return sdk.Int(tokenAmount), nil return t1dAmount, tokenAmount.TruncateInt(), nil } diff --git a/x/vault/module_test.go b/x/vault/module_test.go index 54ec5bf93..0fcb6d72c 100644 --- a/x/vault/module_test.go +++ b/x/vault/module_test.go @@ -89,7 +89,7 @@ func (s *ModuleTestSuite) CreateNewAsset(name, denom string, price uint64) uint6 err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ Name: name, Denom: denom, - Decimals: 1000000, + Decimals: sdk.NewInt(1000000), IsOnChain: true, IsOraclePriceRequired: true, })