diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..cacfe552e Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index d1e5484b6..e913f09b8 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -6,6 +6,6 @@ jobs: labeler: runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4.0.0 + - uses: actions/labeler@v4.0.2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/app/app.go b/app/app.go index 6682f8bfd..2e409f132 100644 --- a/app/app.go +++ b/app/app.go @@ -197,8 +197,9 @@ func GetGovProposalHandlers() []govclient.ProposalHandler { bandoraclemoduleclient.AddFetchPriceHandler, lendclient.AddLendPairsHandler, lendclient.AddPoolHandler, + lendclient.UpdateLendPairsHandler, lendclient.AddAssetToPairHandler, - lendclient.AddAssetRatesStatsHandler, + lendclient.AddAssetRatesParamsHandler, lendclient.AddAuctionParamsHandler, paramsclient.ProposalHandler, distrclient.ProposalHandler, @@ -553,6 +554,7 @@ func New( &app.MarketKeeper, &app.Rewardskeeper, &app.VaultKeeper, + &app.BandoracleKeeper, ) app.LendKeeper = lendkeeper.NewKeeper( @@ -723,6 +725,7 @@ func New( app.LiquidityKeeper, &app.MarketKeeper, &app.EsmKeeper, + &app.LendKeeper, ) wasmDir := filepath.Join(homePath, "wasm") @@ -1141,8 +1144,8 @@ func (a *App) ModuleAccountsPermissions() map[string][]string { func (a *App) registerUpgradeHandlers() { a.UpgradeKeeper.SetUpgradeHandler( - tv4_0_0.UpgradeNameV4_3_0, - tv4_0_0.CreateUpgradeHandlerV430(a.mm, a.configurator, a.AssetKeeper), + tv4_0_0.UpgradeNameV4_4_0, + tv4_0_0.CreateUpgradeHandlerV440(a.mm, a.configurator, a.LendKeeper, a.LiquidationKeeper, a.AuctionKeeper), ) // When a planned update height is reached, the old binary will panic @@ -1218,6 +1221,8 @@ 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{} } return storeUpgrades } diff --git a/app/upgrades/testnet/v4_0_0/constants.go b/app/upgrades/testnet/v4_0_0/constants.go index 914c6cf2f..53005be04 100644 --- a/app/upgrades/testnet/v4_0_0/constants.go +++ b/app/upgrades/testnet/v4_0_0/constants.go @@ -55,3 +55,17 @@ 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 d948d86d5..60f04a20c 100644 --- a/app/upgrades/testnet/v4_0_0/upgrades.go +++ b/app/upgrades/testnet/v4_0_0/upgrades.go @@ -1,6 +1,9 @@ package v4_0_0 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" @@ -122,3 +125,39 @@ 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/wasm/bindings/msg.go b/app/wasm/bindings/msg.go index 9a906ea21..f5b13287c 100644 --- a/app/wasm/bindings/msg.go +++ b/app/wasm/bindings/msg.go @@ -87,6 +87,7 @@ type MsgUpdatePairsVault struct { ClosingFee sdk.Dec `json:"closing_fee"` LiquidationPenalty sdk.Dec `json:"liquidation_penalty"` DrawDownFee sdk.Dec `json:"draw_down_fee"` + IsVaultActive bool `json:"is_vault_active"` MinCr sdk.Dec `json:"min_cr"` DebtCeiling uint64 `json:"debt_ceiling"` DebtFloor uint64 `json:"debt_floor"` diff --git a/proto/comdex/asset/v1beta1/app.proto b/proto/comdex/asset/v1beta1/app.proto index c853d2c48..d04fbad94 100644 --- a/proto/comdex/asset/v1beta1/app.proto +++ b/proto/comdex/asset/v1beta1/app.proto @@ -15,7 +15,7 @@ message AppData { (gogoproto.moretags) = "yaml:\"min_gov_deposit\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; - double gov_time_in_seconds = 5 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""]; + uint64 gov_time_in_seconds = 5 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""]; repeated MintGenesisToken genesis_token = 6 [(gogoproto.moretags) = "yaml:\"genesis_token\"", (gogoproto.nullable) = false]; } @@ -30,7 +30,7 @@ message MintGenesisToken { message AppAndGovTime { uint64 app_id = 1 [(gogoproto.moretags) = "yaml:\"app_id\""]; - double gov_time_in_seconds = 2 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""]; + uint64 gov_time_in_seconds = 2 [(gogoproto.moretags) = "yaml:\"gov_time_in_seconds\""]; string min_gov_deposit = 3 [ (gogoproto.moretags) = "yaml:\"min_gov_deposit\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/proto/comdex/bandoracle/v1beta1/tx.proto b/proto/comdex/bandoracle/v1beta1/tx.proto index 4650dcef2..ac5002b42 100644 --- a/proto/comdex/bandoracle/v1beta1/tx.proto +++ b/proto/comdex/bandoracle/v1beta1/tx.proto @@ -7,10 +7,6 @@ import "comdex/bandoracle/v1beta1/fetch_price.proto"; option go_package = "github.com/comdex-official/comdex/x/bandoracle/types"; -service Msg { - rpc FetchPriceData(MsgFetchPriceData) returns (MsgFetchPriceDataResponse); -} - message MsgFetchPriceData { string creator = 1; uint64 oracle_script_id = 2 [ diff --git a/proto/comdex/lend/v1beta1/genesis.proto b/proto/comdex/lend/v1beta1/genesis.proto index d58a927db..6ffbd7d4a 100644 --- a/proto/comdex/lend/v1beta1/genesis.proto +++ b/proto/comdex/lend/v1beta1/genesis.proto @@ -8,44 +8,44 @@ 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 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]; } diff --git a/proto/comdex/lend/v1beta1/gov.proto b/proto/comdex/lend/v1beta1/gov.proto index 80f091e48..5e2c803ab 100644 --- a/proto/comdex/lend/v1beta1/gov.proto +++ b/proto/comdex/lend/v1beta1/gov.proto @@ -18,6 +18,11 @@ 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\""]; @@ -25,10 +30,10 @@ message AddAssetToPairProposal { AssetToPairMapping AssetToPairMapping = 3 [(gogoproto.nullable) = false]; } -message AddAssetRatesStats { +message AddAssetRatesParams { string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - AssetRatesStats AssetRatesStats = 3 [(gogoproto.nullable) = false]; + AssetRatesParams AssetRatesParams = 3 [(gogoproto.nullable) = false]; } message AddAuctionParamsProposal { diff --git a/proto/comdex/lend/v1beta1/lend.proto b/proto/comdex/lend/v1beta1/lend.proto index 4206b63c5..f74b5eb52 100644 --- a/proto/comdex/lend/v1beta1/lend.proto +++ b/proto/comdex/lend/v1beta1/lend.proto @@ -35,40 +35,28 @@ message LendAsset { (gogoproto.moretags) = "yaml:\"lending_time\"" ]; - string updated_amount_in = 7 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"updated_amount_in\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" - ]; - - string available_to_borrow = 8 [ + string available_to_borrow = 7 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"available_to_borrow\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; - string reward_Accumulated = 9 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"reward_accumulated\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" - ]; - - uint64 app_id = 10 + uint64 app_id = 8 [(gogoproto.customname) = "AppID", (gogoproto.moretags) = "yaml:\"app_id\""]; - string global_index = 11 [ + string global_index = 9 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"global_index\"" ]; - google.protobuf.Timestamp last_interaction_time = 12 [ + google.protobuf.Timestamp last_interaction_time = 10 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_interaction_time\"" ]; - string cpool_name = 13 [ + string cpool_name = 11 [ (gogoproto.customname) = "CPoolName", (gogoproto.moretags) = "yaml:\"cpool_name\"" ]; @@ -124,39 +112,37 @@ message BorrowAsset { (gogoproto.moretags) = "yaml:\"stable_borrow_rate\"" ]; - string updated_amount_out = 10 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"updated_amount_out\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" - ]; - - string interest_Accumulated = 11 [ + string interest_accumulated = 10 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"interest_accumulated\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" ]; - string global_index = 12 [ + string global_index = 11 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"global_index\"" ]; - string reserve_global_index = 13 [ + string reserve_global_index = 12 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"reserve_global_index\"" ]; - google.protobuf.Timestamp last_interaction_time = 14 [ + google.protobuf.Timestamp last_interaction_time = 13 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_interaction_time\"" ]; - string cpool_name = 15 [ + string cpool_name = 14 [ (gogoproto.customname) = "CPoolName", (gogoproto.moretags) = "yaml:\"cpool_name\"" ]; + + bool is_liquidated = 15 [ + (gogoproto.moretags) = "yaml:\"is_liquidated\"" + ]; } message Pool { @@ -170,45 +156,42 @@ message Pool { (gogoproto.moretags) = "yaml:\"module_name\"" ]; - uint64 main_asset_id = 3 [ - (gogoproto.customname) = "MainAssetId", - (gogoproto.moretags) = "yaml:\"main_asset_id\"" - ]; - - uint64 first_bridged_asset_id = 4 [ - (gogoproto.customname) = "FirstBridgedAssetID", - (gogoproto.moretags) = "yaml:\"first_bridged_asset_id\"" - ]; - - uint64 second_bridged_asset_id = 5 [ - (gogoproto.customname) = "SecondBridgedAssetID", - (gogoproto.moretags) = "yaml:\"second_bridged_asset_id\"" - ]; - - string cpool_name = 6 [ + string cpool_name = 3 [ (gogoproto.customname) = "CPoolName", (gogoproto.moretags) = "yaml:\"cpool_name\"" ]; - uint64 reserve_funds = 7 [ + uint64 reserve_funds = 4 [ (gogoproto.moretags) = "yaml:\"reserve_funds\"" ]; - repeated AssetDataPoolMapping asset_data = 8 [ - (gogoproto.nullable) = false, + repeated AssetDataPoolMapping asset_data = 5 [ (gogoproto.customname) = "AssetData", (gogoproto.moretags) = "yaml:\"asset_data\"" ]; } +message UserAssetLendBorrowMapping { + string owner = 1 [(gogoproto.moretags) = "yaml:\"owner\""]; + //to check if poool id is needed + uint64 lend_id = 2 [(gogoproto.moretags) = "yaml:\"lend_id\""]; + uint64 pool_id = 3 [(gogoproto.moretags) = "yaml:\"pool_id\""]; + repeated uint64 borrow_id = 4 [(gogoproto.moretags) = "yaml:\"borrow_id\""]; +} + message AssetDataPoolMapping{ uint64 asset_id = 1 [ (gogoproto.customname) = "AssetID", (gogoproto.moretags) = "yaml:\"asset_id\"" ]; - bool is_bridged = 2 [ - (gogoproto.moretags) = "yaml:\"is_bridged\"" + // 1 for main_asset, 2 for 1st transit_asset, 3 for 2nd transit_asset + uint64 asset_transit_type = 2 [ + (gogoproto.moretags) = "yaml:\"asset_transit_type\"" + ]; + uint64 supply_cap = 3 [ + (gogoproto.customname) = "SupplyCap", + (gogoproto.moretags) = "yaml:\"supply_cap\"" ]; } @@ -230,72 +213,21 @@ message Extended_Pair { } message AssetToPairMapping{ - uint64 asset_id = 1 [ - (gogoproto.customname) = "AssetID", - (gogoproto.moretags) = "yaml:\"asset_id\"" - ]; - uint64 pool_id = 2 [ + uint64 pool_id = 1 [ (gogoproto.customname) = "PoolID", (gogoproto.moretags) = "yaml:\"pool_id\"" ]; + uint64 asset_id = 2 [ + (gogoproto.customname) = "AssetID", + (gogoproto.moretags) = "yaml:\"asset_id\"" + ]; repeated uint64 pair_id = 3 [ (gogoproto.customname) = "PairID", (gogoproto.moretags) = "yaml:\"pair_id\"" ]; } -message UserLendIdMapping{ - string owner = 1 [(gogoproto.moretags) = "yaml:\"owner\""]; - repeated uint64 lend_ids = 2 [ - (gogoproto.customname) = "LendIDs", - (gogoproto.moretags) = "yaml:\"lend_ids\"" - ]; -} - -message LendIdByOwnerAndPoolMapping{ - string owner = 1 [(gogoproto.moretags) = "yaml:\"owner\""]; - uint64 pool_id = 2 [ - (gogoproto.customname) = "PoolID", - (gogoproto.moretags) = "yaml:\"pool_id\"" - ]; - repeated uint64 lendIds = 3 [ - (gogoproto.customname) = "LendIDs", - (gogoproto.moretags) = "yaml:\"lend_ids\"" - ]; -} - -message BorrowIdByOwnerAndPoolMapping{ - string owner = 1 [(gogoproto.moretags) = "yaml:\"owner\""]; - uint64 pool_id = 2 [ - (gogoproto.customname) = "PoolID", - (gogoproto.moretags) = "yaml:\"pool_id\"" - ]; - repeated uint64 borrowIds = 3 [ - (gogoproto.customname) = "BorrowIDs", - (gogoproto.moretags) = "yaml:\"borrow_ids\"" - ]; -} - -message UserBorrowIdMapping{ - string owner = 1 [(gogoproto.moretags) = "yaml:\"owner\""]; - repeated uint64 borrow_ids = 2 [ - (gogoproto.customname) = "BorrowIDs", - (gogoproto.moretags) = "yaml:\"borrow_ids\"" - ]; -} - -message LendIdToBorrowIdMapping{ - uint64 lending_id = 1[ - (gogoproto.customname) = "LendingID", - (gogoproto.moretags) = "yaml:\"lending_id\"" - ]; - repeated uint64 borrowing_id = 2 [ - (gogoproto.customname) = "BorrowingID", - (gogoproto.moretags) = "yaml:\"borrowing_id\"" - ]; -} - -message AssetStats{ +message PoolAssetLBMapping{ //AssetStats uint64 pool_id = 1 [ (gogoproto.customname) = "PoolID", (gogoproto.moretags) = "yaml:\"pool_id\"" @@ -305,51 +237,56 @@ message AssetStats{ (gogoproto.customname) = "AssetID", (gogoproto.moretags) = "yaml:\"asset_id\"" ]; - - string total_borrowed = 3 [ + repeated uint64 lend_ids = 3 [(gogoproto.moretags) = "yaml:\"lend_ids\""]; + repeated uint64 borrow_ids = 4 [(gogoproto.moretags) = "yaml:\"borrow_ids\""]; + string total_borrowed = 5 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"total_borrowed\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; - string total_stable_borrowed = 4 [ + string total_stable_borrowed = 6 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"total_stable_borrowed\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; - string total_lend = 5 [ + string total_lend = 7 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"total_lend\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; - - string lend_apr = 6 [ + string total_interest_accumulated = 8 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"total_interest_accumulated\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" + ]; + string lend_apr = 9 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"lend_apr\"" ]; - string borrow_apr = 7 [ + string borrow_apr = 10 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"borrow_apr\"" ]; - string stable_borrow_apr = 8 [ + string stable_borrow_apr = 11 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"stable_borrow_apr\"" ]; - string utilisation_ratio = 9 [ + string utilisation_ratio = 12 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"utilisation_ratio\"" ]; } -message AssetRatesStats{ +message AssetRatesParams{ //AssetRatesStats uint64 asset_id = 1 [ (gogoproto.customname) = "AssetID", (gogoproto.moretags) = "yaml:\"asset_id\"" @@ -424,20 +361,6 @@ message AssetRatesStats{ } -message LendMapping{ - repeated uint64 lend_ids = 1 [ - (gogoproto.customname) = "LendIDs", - (gogoproto.moretags) = "yaml:\"lend_ids\"" - ]; -} - -message BorrowMapping{ - repeated uint64 borrow_ids = 1 [ - (gogoproto.customname) = "BorrowIDs", - (gogoproto.moretags) = "yaml:\"borrow_ids\"" - ]; -} - message StableBorrowMapping{ repeated uint64 stable_borrow_ids = 1 [ (gogoproto.customname) = "StableBorrowIDs", @@ -445,45 +368,20 @@ message StableBorrowMapping{ ]; } -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" - ]; -} - -message BalanceStats{ +message ReserveBuybackAssetData{ // BalanceStats uint64 asset_id = 1 [ (gogoproto.customname) = "AssetID", (gogoproto.moretags) = "yaml:\"asset_id\"" ]; - string amount = 2 [ + string reserve_amount = 2 [ (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"amount\"", + (gogoproto.moretags) = "yaml:\"reserve_amount\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; -} - -message DepositStats{ - repeated BalanceStats balance_stats = 1[ + string buyback_amount = 3 [ (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"balance_stats\"" + (gogoproto.moretags) = "yaml:\"buyback_amount\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int" ]; } @@ -520,26 +418,14 @@ message AuctionParams{ ]; } -message ReservePoolRecordsForBorrow{ - uint64 borrowing_id = 1 [ - (gogoproto.customname) = "ID", - (gogoproto.moretags) = "yaml:\"borrowing_id\"" - ]; - string interest_accumulated = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"interest_accumulated\"" - ]; -} - message Borrow_interest_tracker{ uint64 borrowing_id = 1 [ (gogoproto.moretags) = "yaml:\"borrowing_id\"" ]; - string interest_accumulated = 2 [ + string reserve_pool_interest = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"interest_accumulated\"" + (gogoproto.moretags) = "yaml:\"reserve_pool_interest\"" ]; } diff --git a/proto/comdex/lend/v1beta1/query.proto b/proto/comdex/lend/v1beta1/query.proto index f1e7ffdd6..16b3549e1 100644 --- a/proto/comdex/lend/v1beta1/query.proto +++ b/proto/comdex/lend/v1beta1/query.proto @@ -96,27 +96,27 @@ message QueryPairResponse { [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"extended_pair\""]; } -message QueryAssetRatesStatsRequest { +message QueryAssetRatesParamsRequest { cosmos.base.query.v1beta1.PageRequest pagination = 1 [(gogoproto.moretags) = "yaml:\"pagination\""]; } -message QueryAssetRatesStatsResponse { - repeated AssetRatesStats AssetRatesStats = 1 [ +message QueryAssetRatesParamsResponse { + repeated AssetRatesParams AssetRatesParams = 1 [ (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"asset_rates_stats\"" + (gogoproto.moretags) = "yaml:\"asset_rates_params\"" ]; cosmos.base.query.v1beta1.PageResponse pagination = 2 [(gogoproto.moretags) = "yaml:\"pagination\""]; } -message QueryAssetRatesStatRequest { +message QueryAssetRatesParamRequest { uint64 id = 1; } -message QueryAssetRatesStatResponse { - AssetRatesStats AssetRatesStat = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"asset_rates_stat\""]; +message QueryAssetRatesParamResponse { + AssetRatesParams AssetRatesparams = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"asset_rates_params\""]; } message QueryPoolsRequest { @@ -218,66 +218,68 @@ message QueryAllBorrowByOwnerAndPoolResponse { [(gogoproto.moretags) = "yaml:\"pagination\""]; } -message QueryAssetStatsRequest { +message QueryPoolAssetLBMappingRequest { uint64 asset_id = 1 [(gogoproto.moretags) = "yaml:\"asset_id\""]; uint64 pool_id = 2 [(gogoproto.moretags) = "yaml:\"pool_id\""]; } -message QueryAssetStatsResponse { - AssetStats AssetStats = 1 [ +message QueryPoolAssetLBMappingResponse { + PoolAssetLBMapping PoolAssetLBMapping = 1 [ (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"asset_stats\""]; + (gogoproto.moretags) = "yaml:\"pool_asset_lb_mapping\""]; } -message QueryModuleBalanceRequest { - uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""]; -} +// message QueryModuleBalanceRequest { +// uint64 pool_id = 1 [(gogoproto.moretags) = "yaml:\"pool_id\""]; +// } -message QueryModuleBalanceResponse { - ModuleBalance ModuleBalance = 1 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"module_balance\""]; -} +// message QueryModuleBalanceResponse { +// ModuleBalance ModuleBalance = 1 [ +// (gogoproto.nullable) = false, +// (gogoproto.moretags) = "yaml:\"module_balance\""]; +// } -message QueryDepositStatsRequest {} +// message QueryDepositStatsRequest {} -message QueryDepositStatsResponse { - DepositStats DepositStats = 1 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"deposit_stats\""]; -} +// message QueryDepositStatsResponse { +// DepositStats DepositStats = 1 [ +// (gogoproto.nullable) = false, +// (gogoproto.moretags) = "yaml:\"deposit_stats\""]; +// } -message QueryUserDepositStatsRequest {} +// message QueryUserDepositStatsRequest {} -message QueryUserDepositStatsResponse { - DepositStats UserDepositStats = 1 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"user_deposit_stats\""]; -} +// message QueryUserDepositStatsResponse { +// DepositStats UserDepositStats = 1 [ +// (gogoproto.nullable) = false, +// (gogoproto.moretags) = "yaml:\"user_deposit_stats\""]; +// } -message QueryReserveDepositStatsRequest {} +// message QueryReserveDepositStatsRequest {} -message QueryReserveDepositStatsResponse { - DepositStats ReserveDepositStats = 1 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"reserve_deposit_stats\""]; -} +// message QueryReserveDepositStatsResponse { +// DepositStats ReserveDepositStats = 1 [ +// (gogoproto.nullable) = false, +// (gogoproto.moretags) = "yaml:\"reserve_deposit_stats\""]; +// } -message QueryBuyBackDepositStatsRequest {} +message QueryReserveBuybackAssetDataRequest { + uint64 asset_id = 1; +} -message QueryBuyBackDepositStatsResponse { - DepositStats BuyBackDepositStats = 1 [ +message QueryReserveBuybackAssetDataResponse { + ReserveBuybackAssetData ReserveBuybackAssetData = 1 [ (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"buy_back_deposit_stats\""]; + (gogoproto.moretags) = "yaml:\"reserve_buyback_asset_data\""]; } -message QueryBorrowStatsRequest {} +// message QueryBorrowStatsRequest {} -message QueryBorrowStatsResponse { - DepositStats BorrowStats = 1 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"borrow_stats\""]; -} +// message QueryBorrowStatsResponse { +// DepositStats BorrowStats = 1 [ +// (gogoproto.nullable) = false, +// (gogoproto.moretags) = "yaml:\"borrow_stats\""]; +// } message QueryAuctionParamRequest { uint64 app_id = 1; @@ -315,11 +317,11 @@ service Query { option (google.api.http).get = "/comdex/lend/v1beta1/pairs/{id}"; } - rpc QueryAssetRatesStats(QueryAssetRatesStatsRequest) returns (QueryAssetRatesStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/asset_rates_stats"; + rpc QueryAssetRatesParams(QueryAssetRatesParamsRequest) returns (QueryAssetRatesParamsResponse) { + option (google.api.http).get = "/comdex/lend/v1beta1/asset_rates_params"; } - rpc QueryAssetRatesStat(QueryAssetRatesStatRequest) returns (QueryAssetRatesStatResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/asset_rates_stats/{id}"; + rpc QueryAssetRatesParam(QueryAssetRatesParamRequest) returns (QueryAssetRatesParamResponse) { + option (google.api.http).get = "/comdex/lend/v1beta1/asset_rates_param/{id}"; } rpc QueryPools(QueryPoolsRequest) returns (QueryPoolsResponse) { @@ -351,33 +353,33 @@ service Query { option (google.api.http).get = "/comdex/lend/v1beta1/borrows_by_owner_pool/{owner}/{pool_id}"; } - rpc QueryAssetStats(QueryAssetStatsRequest) returns (QueryAssetStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/asset_stats/{asset_id}/{pool_id}"; + rpc QueryPoolAssetLBMapping(QueryPoolAssetLBMappingRequest) returns (QueryPoolAssetLBMappingResponse) { + option (google.api.http).get = "/comdex/lend/v1beta1/pool_asset_lb_mapping/{asset_id}/{pool_id}"; }; - rpc QueryModuleBalance(QueryModuleBalanceRequest) returns (QueryModuleBalanceResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/module_balance/{pool_id}"; - }; + // rpc QueryModuleBalance(QueryModuleBalanceRequest) returns (QueryModuleBalanceResponse) { + // option (google.api.http).get = "/comdex/lend/v1beta1/module_balance/{pool_id}"; + // }; - rpc QueryDepositStats(QueryDepositStatsRequest) returns (QueryDepositStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/deposit_stats"; - } + // rpc QueryDepositStats(QueryDepositStatsRequest) returns (QueryDepositStatsResponse) { + // option (google.api.http).get = "/comdex/lend/v1beta1/deposit_stats"; + // } - rpc QueryUserDepositStats(QueryUserDepositStatsRequest) returns (QueryUserDepositStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/user_deposit_stats"; - } + // rpc QueryUserDepositStats(QueryUserDepositStatsRequest) returns (QueryUserDepositStatsResponse) { + // option (google.api.http).get = "/comdex/lend/v1beta1/user_deposit_stats"; + // } - rpc QueryReserveDepositStats(QueryReserveDepositStatsRequest) returns (QueryReserveDepositStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/reserve_deposit_stats"; - } + // rpc QueryReserveDepositStats(QueryReserveDepositStatsRequest) returns (QueryReserveDepositStatsResponse) { + // option (google.api.http).get = "/comdex/lend/v1beta1/reserve_deposit_stats"; + // } - rpc QueryBuyBackDepositStats(QueryBuyBackDepositStatsRequest) returns (QueryBuyBackDepositStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/buy_back_deposit_stats"; + rpc QueryReserveBuybackAssetData(QueryReserveBuybackAssetDataRequest) returns (QueryReserveBuybackAssetDataResponse) { + option (google.api.http).get = "/comdex/lend/v1beta1/reserve_buyback_asset_data/{asset_id}"; } - rpc QueryBorrowStats(QueryBorrowStatsRequest) returns (QueryBorrowStatsResponse) { - option (google.api.http).get = "/comdex/lend/v1beta1/borrow_stats"; - } + // rpc QueryBorrowStats(QueryBorrowStatsRequest) returns (QueryBorrowStatsResponse) { + // option (google.api.http).get = "/comdex/lend/v1beta1/borrow_stats"; + // } rpc QueryAuctionParams(QueryAuctionParamRequest) returns (QueryAuctionParamResponse) { option (google.api.http).get = "/comdex/lend/v1beta1/auctionparams/{app_id}"; diff --git a/proto/comdex/market/v1beta1/market.proto b/proto/comdex/market/v1beta1/market.proto index d997e61c4..9ebf408f4 100644 --- a/proto/comdex/market/v1beta1/market.proto +++ b/proto/comdex/market/v1beta1/market.proto @@ -15,3 +15,27 @@ message Market { ]; uint64 rates = 3; } + +message TimeWeightedAverage { + uint64 asset_id = 1 [ + (gogoproto.customname) = "AssetID", + (gogoproto.moretags) = "yaml:\"asset_id\"" + ]; + uint64 script_id = 2 [ + (gogoproto.customname) = "ScriptID", + (gogoproto.moretags) = "yaml:\"script_id\"" + ]; + uint64 twa = 3 [ + (gogoproto.customname) = "Twa", + (gogoproto.moretags) = "yaml:\"twa\"" + ]; + uint64 current_index = 4 [ + (gogoproto.customname) = "CurrentIndex", + (gogoproto.moretags) = "yaml:\"current_index\"" + ]; + bool is_price_active = 5 [(gogoproto.moretags) = "yaml:\"is_price_active\""]; + repeated uint64 price_value = 6 [ + (gogoproto.customname) = "PriceValue", + (gogoproto.moretags) = "yaml:\"price_value\"" + ]; +} \ No newline at end of file diff --git a/proto/comdex/rewards/v1beta1/rewards.proto b/proto/comdex/rewards/v1beta1/rewards.proto index ca079e33d..3e2b1565e 100644 --- a/proto/comdex/rewards/v1beta1/rewards.proto +++ b/proto/comdex/rewards/v1beta1/rewards.proto @@ -153,4 +153,63 @@ message EpochTime{ uint64 count = 4 [ (gogoproto.moretags) = "yaml:\"count\"" ]; +} + +message Lend_external_rewards{ + uint64 id = 1 [ + (gogoproto.moretags) = "yaml:\"id\"" + ]; + uint64 app_mapping_id = 2 [ + (gogoproto.moretags) = "yaml:\"app_mapping_id\"" + ]; + repeated Rewards_asset_pool_data rewards_asset_pool_data = 3 [ + (gogoproto.moretags) = "yaml:\"rewards_asset_pool_data\"" + ]; + cosmos.base.v1beta1.Coin total_rewards = 4 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"total_rewards\"", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + uint64 reward_asset_id = 5 [ + (gogoproto.moretags) = "yaml:\"epoch_id\"" + ]; + int64 duration_days = 6 [ + (gogoproto.moretags) = "yaml:\"duration_days\"" + ]; + bool is_active = 7 [ + (gogoproto.moretags) = "yaml:\"is_active\"" + ]; + cosmos.base.v1beta1.Coin available_rewards = 8 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"available_rewards\"", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + string depositor = 9 [ + (gogoproto.moretags) = "yaml:\"depositor\"" + ]; + google.protobuf.Timestamp start_timestamp = 10 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"start_timestamp\"" + ]; + google.protobuf.Timestamp end_timestamp = 11 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"end_timestamp\"" + ]; + int64 min_lockup_time_seconds = 12 [ + (gogoproto.moretags) = "yaml:\"min_lockup_time_seconds\"" + ]; + uint64 epoch_id = 13 [ + (gogoproto.moretags) = "yaml:\"epoch_id\"" + ]; +} + +message Rewards_asset_pool_data{ + uint64 c_pool_id = 1 [ + (gogoproto.moretags) = "yaml:\"c_pool_id\"" + ]; + repeated uint64 asset_id = 2 [ + (gogoproto.moretags) = "yaml:\"asset_id\"" + ]; } \ No newline at end of file diff --git a/scripts/comdex_local_setup/main.py b/scripts/comdex_local_setup/main.py index 4f1706112..f5c004950 100644 --- a/scripts/comdex_local_setup/main.py +++ b/scripts/comdex_local_setup/main.py @@ -267,7 +267,7 @@ def AddAssetRates(assetName, jsonData): with open(fileName, "w") as jsonFile: json.dump(jsonData, jsonFile) - command = f"""comdex tx gov submit-proposal add-asset-rates-stats --add-asset-rates-stats-file '{fileName}' --from {GENESIS_ACCOUNT_NAME} --chain-id {CHAIN_ID} --keyring-backend test --gas 5000000 -y""" + command = f"""comdex tx gov submit-proposal add-asset-rates-params --add-asset-rates-params-file '{fileName}' --from {GENESIS_ACCOUNT_NAME} --chain-id {CHAIN_ID} --keyring-backend test --gas 5000000 -y""" output = subprocess.getstatusoutput(command)[1] output = json.loads(output) if int(output["code"]) != 0: diff --git a/scripts/comdex_local_setup/states.py b/scripts/comdex_local_setup/states.py index aafc8f6a3..60a713151 100644 --- a/scripts/comdex_local_setup/states.py +++ b/scripts/comdex_local_setup/states.py @@ -137,11 +137,9 @@ ADD_LEND_POOL = [ { "module_name": "cmdx", - "main_asset_id": "2", - "first_bridged_asset_id": "3", - "second_bridged_asset_id": "1", "asset_id": "1,2,3", - "is_bridged_asset": "1,0,1", + "asset_transit_type": "3,1,2", + "supply_cap": "5000000000000000000,1000000000000000000,5000000000000000000", "c_pool_name": "CMDX-ATOM-CMST", "reserve_funds": "100000000", "title": "Add pool", @@ -150,11 +148,9 @@ }, { "module_name": "osmo", - "main_asset_id": "4", - "first_bridged_asset_id": "3", - "second_bridged_asset_id": "1", "asset_id": "1,4,3", - "is_bridged_asset": "1,0,1", + "asset_transit_type": "3,1,2", + "supply_cap": "5000000000000000000,3000000000000000000,5000000000000000000", "c_pool_name": "OSMO-ATOM-CMST", "reserve_funds": "100000000", "title": "Add pool", diff --git a/x/asset/client/cli/tx.go b/x/asset/client/cli/tx.go index ccd4ee366..fb161fb41 100644 --- a/x/asset/client/cli/tx.go +++ b/x/asset/client/cli/tx.go @@ -3,7 +3,6 @@ package cli import ( "fmt" "strconv" - "time" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" @@ -371,7 +370,7 @@ func NewCmdSubmitAddAppProposal() *cobra.Command { minGovDeposit := args[2] - govTimeIn, err := time.ParseDuration(args[3] + "s") + govTimeIn, err := strconv.ParseUint(args[3], 10, 64) if err != nil { return err } @@ -402,7 +401,7 @@ func NewCmdSubmitAddAppProposal() *cobra.Command { Name: name, ShortName: shortName, MinGovDeposit: newMinGovDeposit, - GovTimeInSeconds: govTimeIn.Seconds(), + GovTimeInSeconds: govTimeIn, GenesisToken: bMap, } @@ -455,7 +454,7 @@ func NewCmdSubmitUpdateGovTimeInAppProposal() *cobra.Command { return err } - govTimeIn, err := time.ParseDuration(args[1] + "s") + govTimeIn, err := strconv.ParseUint(args[1], 10, 64) if err != nil { return err } @@ -487,7 +486,7 @@ func NewCmdSubmitUpdateGovTimeInAppProposal() *cobra.Command { aTime := types.AppAndGovTime{ AppId: appID, - GovTimeInSeconds: govTimeIn.Seconds(), + GovTimeInSeconds: govTimeIn, MinGovDeposit: minGovDeposit, } diff --git a/x/asset/client/rest/tx.go b/x/asset/client/rest/tx.go index 83b7dc29d..592fdb27c 100644 --- a/x/asset/client/rest/tx.go +++ b/x/asset/client/rest/tx.go @@ -4,23 +4,10 @@ import ( "net/http" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - - "github.com/comdex-official/comdex/x/asset/types" ) -type AddNewAssetsRequest struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Deposit sdk.Coins `json:"deposit" yaml:"deposit"` - Asset types.Asset `json:"assets" yaml:"assets"` -} - type ( UpdateNewAssetRequest struct{} AddNewPairsRequest struct{} @@ -64,35 +51,11 @@ func AddNewPairsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRE func AddNewAssetsRESTHandler(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req AddNewAssetsRequest + var req UpdateNewAssetRequest if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { return } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - fromAddr, err := sdk.AccAddressFromBech32(req.BaseReq.From) - if rest.CheckBadRequestError(w, err) { - return - } - - content := types.NewAddAssetsProposal( - req.Title, - req.Description, - req.Asset) - msg, err := govtypes.NewMsgSubmitProposal(content, req.Deposit, fromAddr) - if rest.CheckBadRequestError(w, err) { - return - } - if rest.CheckBadRequestError(w, msg.ValidateBasic()) { - return - } - - tx.WriteGeneratedTxResponse(clientCtx, w, req.BaseReq, msg) } } diff --git a/x/asset/expected/keeper.go b/x/asset/expected/keeper.go index 0da80b1e4..b2400da84 100644 --- a/x/asset/expected/keeper.go +++ b/x/asset/expected/keeper.go @@ -25,3 +25,7 @@ type VaultKeeper interface { GetVault(ctx sdk.Context, id uint64) (vault vaulttypes.Vault, found bool) SetVault(ctx sdk.Context, vault vaulttypes.Vault) } + +type Bandoraclekeeper interface { + SetCheckFlag(ctx sdk.Context, flag bool) +} diff --git a/x/asset/keeper/app.go b/x/asset/keeper/app.go index 083389dd9..5f27ebbca 100644 --- a/x/asset/keeper/app.go +++ b/x/asset/keeper/app.go @@ -221,7 +221,7 @@ func (k Keeper) AddAppRecords(ctx sdk.Context, msg types.AppData) error { return types.ErrorNameDidNotMeetCriterion } - if msg.MinGovDeposit.LT(sdk.ZeroInt()) || msg.GovTimeInSeconds < 0 { + if msg.MinGovDeposit.LT(sdk.ZeroInt()) { return types.ErrorValueCantBeNegative } diff --git a/x/asset/keeper/asset.go b/x/asset/keeper/asset.go index 17e07042e..3a768394b 100644 --- a/x/asset/keeper/asset.go +++ b/x/asset/keeper/asset.go @@ -182,15 +182,6 @@ func (k Keeper) DeleteAssetForName(ctx sdk.Context, name string) { store.Delete(key) } -func (k Keeper) GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) { - market, found := k.oracle.GetMarketForAsset(ctx, id) - if !found { - return 0, false - } - - return k.oracle.GetPriceForMarket(ctx, market.Symbol) -} - func (k Keeper) AddAssetRecords(ctx sdk.Context, msg types.Asset) error { if k.HasAssetForDenom(ctx, msg.Denom) || k.HasAssetForName(ctx, msg.Name) { return types.ErrorDuplicateAsset @@ -213,6 +204,9 @@ func (k Keeper) AddAssetRecords(ctx sdk.Context, msg types.Asset) error { IsOraclePriceRequired: msg.IsOraclePriceRequired, } ) + if msg.IsOraclePriceRequired { + k.bandoracle.SetCheckFlag(ctx, false) + } k.SetAssetID(ctx, asset.Id) k.SetAsset(ctx, asset) @@ -233,9 +227,7 @@ func (k Keeper) UpdateAssetRecords(ctx sdk.Context, msg types.Asset) error { if !IsLetter(msg.Name) || len(msg.Name) > 10 { return types.ErrorNameDidNotMeetCriterion } - } - if msg.Name != "" { if k.HasAssetForName(ctx, msg.Name) { return types.ErrorDuplicateAsset } @@ -243,6 +235,7 @@ func (k Keeper) UpdateAssetRecords(ctx sdk.Context, msg types.Asset) error { asset.Name = msg.Name k.SetAssetForName(ctx, asset.Name, asset.Id) } + if msg.Denom != "" { if k.HasAssetForDenom(ctx, msg.Denom) { return types.ErrorDuplicateAsset @@ -256,6 +249,9 @@ func (k Keeper) UpdateAssetRecords(ctx sdk.Context, msg types.Asset) error { asset.Decimals = msg.Decimals } asset.IsOraclePriceRequired = msg.IsOraclePriceRequired + if msg.IsOraclePriceRequired { + k.bandoracle.SetCheckFlag(ctx, false) + } k.SetAsset(ctx, asset) return nil diff --git a/x/asset/keeper/keeper.go b/x/asset/keeper/keeper.go index 1fec15de9..662d9386e 100644 --- a/x/asset/keeper/keeper.go +++ b/x/asset/keeper/keeper.go @@ -11,26 +11,28 @@ import ( ) type Keeper struct { - cdc codec.BinaryCodec - key sdk.StoreKey - params paramstypes.Subspace - oracle expected.MarketKeeper - rewards expected.RewardsKeeper - vault expected.VaultKeeper + cdc codec.BinaryCodec + key sdk.StoreKey + params paramstypes.Subspace + oracle expected.MarketKeeper + rewards expected.RewardsKeeper + vault expected.VaultKeeper + bandoracle expected.Bandoraclekeeper } -func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, params paramstypes.Subspace, oracle expected.MarketKeeper, rewards expected.RewardsKeeper, vault expected.VaultKeeper) Keeper { +func NewKeeper(cdc codec.BinaryCodec, key sdk.StoreKey, params paramstypes.Subspace, oracle expected.MarketKeeper, rewards expected.RewardsKeeper, vault expected.VaultKeeper, bandoracle expected.Bandoraclekeeper) Keeper { if !params.HasKeyTable() { params = params.WithKeyTable(assettypes.ParamKeyTable()) } return Keeper{ - cdc: cdc, - key: key, - params: params, - oracle: oracle, - rewards: rewards, - vault: vault, + cdc: cdc, + key: key, + params: params, + oracle: oracle, + rewards: rewards, + vault: vault, + bandoracle: bandoracle, } } diff --git a/x/asset/keeper/pair.go b/x/asset/keeper/pair.go index ee1fe973d..ba70340bf 100644 --- a/x/asset/keeper/pair.go +++ b/x/asset/keeper/pair.go @@ -92,6 +92,9 @@ func (k Keeper) NewAddPair(ctx sdk.Context, msg *types.MsgAddPairRequest) (*type if !k.HasAsset(ctx, msg.AssetOut) { return nil, types.ErrorAssetDoesNotExist } + if msg.AssetIn == msg.AssetOut { + return nil, types.ErrorDuplicateAsset + } var ( id = k.GetPairID(ctx) pair = types.Pair{ @@ -116,6 +119,9 @@ func (k *Keeper) UpdatePairRecords(ctx sdk.Context, msg types.Pair) error { if !k.HasAsset(ctx, msg.AssetOut) { return types.ErrorAssetDoesNotExist } + if msg.AssetIn == msg.AssetOut { + return types.ErrorDuplicateAsset + } pair.AssetIn = msg.AssetIn pair.AssetOut = msg.AssetOut k.SetPair(ctx, pair) diff --git a/x/asset/keeper/pairs_vault.go b/x/asset/keeper/pairs_vault.go index 5f52b1384..bc19b96ee 100644 --- a/x/asset/keeper/pairs_vault.go +++ b/x/asset/keeper/pairs_vault.go @@ -261,6 +261,7 @@ func (k Keeper) WasmUpdatePairsVault(ctx sdk.Context, updatePairVault *bindings. ExtPairVaultData.ClosingFee = updatePairVault.ClosingFee ExtPairVaultData.LiquidationPenalty = updatePairVault.LiquidationPenalty ExtPairVaultData.DrawDownFee = updatePairVault.DrawDownFee + ExtPairVaultData.IsVaultActive = updatePairVault.IsVaultActive ExtPairVaultData.DebtCeiling = sdk.NewInt(int64(updatePairVault.DebtCeiling)) ExtPairVaultData.DebtFloor = sdk.NewInt(int64(updatePairVault.DebtFloor)) ExtPairVaultData.MinCr = updatePairVault.MinCr @@ -301,7 +302,7 @@ func (k Keeper) VaultIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, colle if !found { continue } - interest := sdk.ZeroDec() + var interest sdk.Dec var err error if vaultData.BlockHeight == 0 { interest, err = k.rewards.CalculationOfRewards(ctx, vaultData.AmountOut, collectorLsr, collectorBt) @@ -326,8 +327,7 @@ func (k Keeper) VaultIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, colle vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Add(interest) } if vaultInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { - newInterest := sdk.ZeroInt() - newInterest = vaultInterestTracker.InterestAccumulated.TruncateInt() + newInterest := vaultInterestTracker.InterestAccumulated.TruncateInt() newInterestDec := sdk.NewDec(newInterest.Int64()) vaultInterestTracker.InterestAccumulated = vaultInterestTracker.InterestAccumulated.Sub(newInterestDec) diff --git a/x/asset/types/app.pb.go b/x/asset/types/app.pb.go index 6096dc760..401221d82 100644 --- a/x/asset/types/app.pb.go +++ b/x/asset/types/app.pb.go @@ -4,7 +4,6 @@ package types import ( - encoding_binary "encoding/binary" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" @@ -30,7 +29,7 @@ type AppData struct { Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty" yaml:"name"` ShortName string `protobuf:"bytes,3,opt,name=short_name,json=shortName,proto3" json:"short_name,omitempty" yaml:"short_name"` MinGovDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=min_gov_deposit,json=minGovDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_gov_deposit" yaml:"min_gov_deposit"` - GovTimeInSeconds float64 `protobuf:"fixed64,5,opt,name=gov_time_in_seconds,json=govTimeInSeconds,proto3" json:"gov_time_in_seconds,omitempty" yaml:"gov_time_in_seconds"` + GovTimeInSeconds uint64 `protobuf:"varint,5,opt,name=gov_time_in_seconds,json=govTimeInSeconds,proto3" json:"gov_time_in_seconds,omitempty" yaml:"gov_time_in_seconds"` GenesisToken []MintGenesisToken `protobuf:"bytes,6,rep,name=genesis_token,json=genesisToken,proto3" json:"genesis_token" yaml:"genesis_token"` } @@ -109,7 +108,7 @@ var xxx_messageInfo_MintGenesisToken proto.InternalMessageInfo type AppAndGovTime struct { AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` - GovTimeInSeconds float64 `protobuf:"fixed64,2,opt,name=gov_time_in_seconds,json=govTimeInSeconds,proto3" json:"gov_time_in_seconds,omitempty" yaml:"gov_time_in_seconds"` + GovTimeInSeconds uint64 `protobuf:"varint,2,opt,name=gov_time_in_seconds,json=govTimeInSeconds,proto3" json:"gov_time_in_seconds,omitempty" yaml:"gov_time_in_seconds"` MinGovDeposit github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_gov_deposit,json=minGovDeposit,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_gov_deposit" yaml:"min_gov_deposit"` } @@ -155,7 +154,7 @@ func init() { func init() { proto.RegisterFile("comdex/asset/v1beta1/app.proto", fileDescriptor_1372b4734b6486fd) } var fileDescriptor_1372b4734b6486fd = []byte{ - // 570 bytes of a gzipped FileDescriptorProto + // 569 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x54, 0xbd, 0x6e, 0xdb, 0x3c, 0x14, 0x95, 0xec, 0xfc, 0x32, 0x71, 0xec, 0xc8, 0xfe, 0xbe, 0x1a, 0x41, 0x21, 0x19, 0x2c, 0x10, 0x78, 0x89, 0x84, 0xa4, 0x5d, 0xda, 0xcd, 0x42, 0x00, 0xd7, 0x43, 0x0a, 0x54, 0x49, 0x97, 0x2e, @@ -174,24 +173,24 @@ var fileDescriptor_1372b4734b6486fd = []byte{ 0x21, 0xe5, 0x09, 0xe5, 0xc5, 0xe7, 0x84, 0x47, 0xb7, 0x8e, 0x98, 0x32, 0xc4, 0xed, 0x01, 0x11, 0x59, 0x6a, 0xfd, 0xaf, 0x8c, 0x1e, 0xc8, 0x41, 0xaf, 0x96, 0x60, 0xd2, 0xa7, 0x93, 0x73, 0xb5, 0x37, 0x2e, 0x40, 0x33, 0x87, 0x05, 0x4e, 0x90, 0x8f, 0x89, 0xcf, 0x51, 0x48, 0x49, 0xc4, 0xdb, - 0x9b, 0x1d, 0xbd, 0xab, 0xbb, 0x66, 0x96, 0x5a, 0x47, 0x4a, 0x67, 0x0d, 0x09, 0x7a, 0x8d, 0x98, - 0x4e, 0xae, 0x70, 0x82, 0x06, 0xe4, 0x52, 0x1d, 0x19, 0x18, 0xd4, 0x62, 0x44, 0x10, 0xc7, 0xdc, - 0x17, 0xf4, 0x16, 0x91, 0xf6, 0x56, 0xa7, 0xda, 0xdd, 0x3b, 0x3b, 0xb6, 0xd7, 0x65, 0x6f, 0x5f, - 0x60, 0x22, 0xfa, 0x8a, 0x7e, 0x95, 0xb3, 0xdd, 0xc7, 0x79, 0x99, 0x59, 0x6a, 0xb5, 0x0a, 0xd3, - 0x55, 0x29, 0xe8, 0xed, 0xc7, 0x2b, 0x5c, 0xf8, 0xbe, 0x02, 0x1a, 0x0f, 0x05, 0x0c, 0x1b, 0xec, - 0x48, 0x0b, 0xbf, 0xec, 0x98, 0xdb, 0xcc, 0x52, 0xab, 0xae, 0xe4, 0x4a, 0x04, 0x7a, 0xdb, 0x72, - 0x39, 0x88, 0x8c, 0x37, 0xe0, 0xa0, 0x34, 0xe1, 0x77, 0x8c, 0x8d, 0xa6, 0x45, 0x57, 0xed, 0x3f, - 0xcb, 0xdb, 0x2b, 0xab, 0xbe, 0x94, 0x22, 0xc6, 0x73, 0xb0, 0x8f, 0xb9, 0xcc, 0x5d, 0xa5, 0x90, - 0xf7, 0x7f, 0xc7, 0x7d, 0x94, 0xa5, 0x56, 0x53, 0xfd, 0xca, 0x2a, 0x0a, 0x3d, 0x80, 0x79, 0x9f, - 0x4e, 0x54, 0x05, 0x67, 0x60, 0x77, 0x8c, 0x42, 0xcc, 0x30, 0x22, 0x65, 0xf3, 0x5b, 0x59, 0x6a, - 0x35, 0xd4, 0xbd, 0x9f, 0x10, 0xf4, 0x96, 0x34, 0xf8, 0x5d, 0x07, 0xb5, 0x1e, 0x63, 0x3d, 0x12, - 0xf5, 0x55, 0x43, 0x8c, 0x2e, 0xd8, 0x0a, 0x18, 0x5b, 0xa6, 0x70, 0x98, 0xa5, 0x56, 0xad, 0x48, - 0x41, 0x9e, 0x43, 0x6f, 0x33, 0x60, 0x6c, 0x10, 0xfd, 0x6e, 0x00, 0x2a, 0x7f, 0x39, 0x00, 0x6b, - 0x26, 0xb8, 0xfa, 0x4f, 0x27, 0xd8, 0x7d, 0x3d, 0xfb, 0x66, 0x6a, 0x9f, 0xe6, 0xa6, 0x36, 0x9b, - 0x9b, 0xfa, 0xfd, 0xdc, 0xd4, 0xbf, 0xce, 0x4d, 0xfd, 0xc3, 0xc2, 0xd4, 0xee, 0x17, 0xa6, 0xf6, - 0x79, 0x61, 0x6a, 0x6f, 0x9d, 0x5f, 0x2c, 0xf3, 0x39, 0x3c, 0xa1, 0xd7, 0xd7, 0x38, 0xc4, 0xc1, - 0xa8, 0xd8, 0x3b, 0xe5, 0xab, 0x21, 0xfd, 0x87, 0x5b, 0xf2, 0x11, 0x78, 0xfa, 0x23, 0x00, 0x00, - 0xff, 0xff, 0xbc, 0x7b, 0xd8, 0x69, 0x52, 0x04, 0x00, 0x00, + 0x9b, 0x79, 0xb5, 0xae, 0x99, 0xa5, 0xd6, 0x91, 0xd2, 0x59, 0x43, 0x82, 0x5e, 0x23, 0xa6, 0x93, + 0x2b, 0x9c, 0xa0, 0x01, 0xb9, 0x54, 0x47, 0x06, 0x06, 0xb5, 0x18, 0x11, 0xc4, 0x31, 0xf7, 0x05, + 0xbd, 0x45, 0xa4, 0xbd, 0xd5, 0xa9, 0x76, 0xf7, 0xce, 0x8e, 0xed, 0x75, 0xd9, 0xdb, 0x17, 0x98, + 0x88, 0xbe, 0xa2, 0x5f, 0xe5, 0x6c, 0xf7, 0x71, 0x5e, 0x66, 0x96, 0x5a, 0xad, 0xc2, 0x74, 0x55, + 0x0a, 0x7a, 0xfb, 0xf1, 0x0a, 0x17, 0xbe, 0xaf, 0x80, 0xc6, 0x43, 0x01, 0xc3, 0x06, 0x3b, 0xd2, + 0xc2, 0x2f, 0x3b, 0xe6, 0x36, 0xb3, 0xd4, 0xaa, 0x2b, 0xb9, 0x12, 0x81, 0xde, 0xb6, 0x5c, 0x0e, + 0x22, 0xe3, 0x0d, 0x38, 0x28, 0x4d, 0xf8, 0x1d, 0x63, 0xa3, 0x69, 0xd1, 0x55, 0xfb, 0xcf, 0xf2, + 0xf6, 0xca, 0xaa, 0x2f, 0xa5, 0x88, 0xf1, 0x1c, 0xec, 0x63, 0x2e, 0x73, 0x57, 0x29, 0xe4, 0xfd, + 0xdf, 0x71, 0x1f, 0x65, 0xa9, 0xd5, 0x54, 0xbf, 0xb2, 0x8a, 0x42, 0x0f, 0x60, 0xde, 0xa7, 0x13, + 0x55, 0xc1, 0x19, 0xd8, 0x1d, 0xa3, 0x10, 0x33, 0x8c, 0x48, 0xd9, 0xfc, 0x56, 0x96, 0x5a, 0x0d, + 0x75, 0xef, 0x27, 0x04, 0xbd, 0x25, 0x0d, 0x7e, 0xd7, 0x41, 0xad, 0xc7, 0x58, 0x8f, 0x44, 0x7d, + 0xd5, 0x10, 0xa3, 0x0b, 0xb6, 0x02, 0xc6, 0x96, 0x29, 0x1c, 0x66, 0xa9, 0x55, 0x2b, 0x52, 0x90, + 0xe7, 0xd0, 0xdb, 0x0c, 0x18, 0x1b, 0x44, 0xbf, 0x1b, 0x80, 0xca, 0x5f, 0x0e, 0xc0, 0x9a, 0x09, + 0xae, 0xfe, 0xd3, 0x09, 0x76, 0x5f, 0xcf, 0xbe, 0x99, 0xda, 0xa7, 0xb9, 0xa9, 0xcd, 0xe6, 0xa6, + 0x7e, 0x3f, 0x37, 0xf5, 0xaf, 0x73, 0x53, 0xff, 0xb0, 0x30, 0xb5, 0xfb, 0x85, 0xa9, 0x7d, 0x5e, + 0x98, 0xda, 0x5b, 0xe7, 0x17, 0xcb, 0x7c, 0x0e, 0x4f, 0xe8, 0xf5, 0x35, 0x0e, 0x71, 0x30, 0x2a, + 0xf6, 0x4e, 0xf9, 0x6a, 0x48, 0xff, 0xe1, 0x96, 0x7c, 0x04, 0x9e, 0xfe, 0x08, 0x00, 0x00, 0xff, + 0xff, 0xf0, 0xde, 0x5d, 0x41, 0x52, 0x04, 0x00, 0x00, } func (m *AppData) Marshal() (dAtA []byte, err error) { @@ -229,10 +228,9 @@ func (m *AppData) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } if m.GovTimeInSeconds != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.GovTimeInSeconds)))) + i = encodeVarintApp(dAtA, i, uint64(m.GovTimeInSeconds)) i-- - dAtA[i] = 0x29 + dAtA[i] = 0x28 } { size := m.MinGovDeposit.Size() @@ -352,10 +350,9 @@ func (m *AppAndGovTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a if m.GovTimeInSeconds != 0 { - i -= 8 - encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(m.GovTimeInSeconds)))) + i = encodeVarintApp(dAtA, i, uint64(m.GovTimeInSeconds)) i-- - dAtA[i] = 0x11 + dAtA[i] = 0x10 } if m.AppId != 0 { i = encodeVarintApp(dAtA, i, uint64(m.AppId)) @@ -396,7 +393,7 @@ func (m *AppData) Size() (n int) { l = m.MinGovDeposit.Size() n += 1 + l + sovApp(uint64(l)) if m.GovTimeInSeconds != 0 { - n += 9 + n += 1 + sovApp(uint64(m.GovTimeInSeconds)) } if len(m.GenesisToken) > 0 { for _, e := range m.GenesisToken { @@ -438,7 +435,7 @@ func (m *AppAndGovTime) Size() (n int) { n += 1 + sovApp(uint64(m.AppId)) } if m.GovTimeInSeconds != 0 { - n += 9 + n += 1 + sovApp(uint64(m.GovTimeInSeconds)) } l = m.MinGovDeposit.Size() n += 1 + l + sovApp(uint64(l)) @@ -598,16 +595,24 @@ func (m *AppData) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: - if wireType != 1 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GovTimeInSeconds", wireType) } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF + m.GovTimeInSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GovTimeInSeconds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.GovTimeInSeconds = float64(math.Float64frombits(v)) case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field GenesisToken", wireType) @@ -867,16 +872,24 @@ func (m *AppAndGovTime) Unmarshal(dAtA []byte) error { } } case 2: - if wireType != 1 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field GovTimeInSeconds", wireType) } - var v uint64 - if (iNdEx + 8) > l { - return io.ErrUnexpectedEOF + m.GovTimeInSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowApp + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GovTimeInSeconds |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } } - v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:])) - iNdEx += 8 - m.GovTimeInSeconds = float64(math.Float64frombits(v)) case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinGovDeposit", wireType) diff --git a/x/auction/expected/keeper.go b/x/auction/expected/keeper.go index 3bfc2b417..9cd125e94 100644 --- a/x/auction/expected/keeper.go +++ b/x/auction/expected/keeper.go @@ -88,23 +88,15 @@ type EsmKeeper interface { } type LendKeeper interface { - GetBorrows(ctx sdk.Context) (userBorrows lendtypes.BorrowMapping, found bool) GetBorrow(ctx sdk.Context, id uint64) (borrow lendtypes.BorrowAsset, found bool) GetLendPair(ctx sdk.Context, id uint64) (pair lendtypes.Extended_Pair, found bool) - GetAssetRatesStats(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesStats, found bool) - VerifyCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error - CalculateCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) + GetAssetRatesParams(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesParams, found bool) + VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error + CalculateCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) DeleteBorrow(ctx sdk.Context, id uint64) - - DeleteBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) - UpdateUserBorrowIDMapping(ctx sdk.Context, lendOwner string, borrowID uint64, isInsert bool) error - UpdateBorrowIDByOwnerAndPoolMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, poolID uint64, isInsert bool) error - UpdateBorrowIdsMapping(ctx sdk.Context, borrowID uint64, isInsert bool) error - CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) GetAddAuctionParamsData(ctx sdk.Context, appID uint64) (auctionParams lendtypes.AuctionParams, found bool) - GetReserveDepositStats(ctx sdk.Context) (depositStats lendtypes.DepositStats, found bool) ModuleBalance(ctx sdk.Context, moduleName string, denom string) sdk.Int UpdateReserveBalances(ctx sdk.Context, assetID uint64, moduleName string, payment sdk.Coin, inc bool) error SetLend(ctx sdk.Context, lend lendtypes.LendAsset) diff --git a/x/auction/keeper/alias.go b/x/auction/keeper/alias.go index 92df13b60..59208d369 100644 --- a/x/auction/keeper/alias.go +++ b/x/auction/keeper/alias.go @@ -197,10 +197,6 @@ func (k Keeper) GetUserAppMappingData(ctx sdk.Context, address string, appID uin return k.vault.GetUserAppMappingData(ctx, address, appID) } -// func (k Keeper) CheckUserAppToExtendedPairMapping(ctx sdk.Context, userVaultAssetData vaulttypes.UserVaultAssetMapping, extendedPairVaultID uint64, appMappingID uint64) (vaultID uint64, found bool) { -// return k.vault.CheckUserAppToExtendedPairMapping(ctx, userVaultAssetData, extendedPairVaultID, appMappingID) -// } - func (k Keeper) SetVault(ctx sdk.Context, vault vaulttypes.Vault) { k.vault.SetVault(ctx, vault) } @@ -209,10 +205,6 @@ func (k Keeper) GetVault(ctx sdk.Context, id uint64) (vault vaulttypes.Vault, fo return k.vault.GetVault(ctx, id) } -func (k Keeper) GetBorrows(ctx sdk.Context) (userBorrows lendtypes.BorrowMapping, found bool) { - return k.lend.GetBorrows(ctx) -} - func (k Keeper) GetBorrow(ctx sdk.Context, id uint64) (borrow lendtypes.BorrowAsset, found bool) { return k.lend.GetBorrow(ctx, id) } @@ -221,16 +213,16 @@ func (k Keeper) GetLendPair(ctx sdk.Context, id uint64) (pair lendtypes.Extended return k.lend.GetLendPair(ctx, id) } -func (k Keeper) GetAssetRatesStats(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesStats, found bool) { - return k.lend.GetAssetRatesStats(ctx, assetID) +func (k Keeper) GetAssetRatesParams(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesParams, found bool) { + return k.lend.GetAssetRatesParams(ctx, assetID) } -func (k Keeper) VerifyCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error { - return k.lend.VerifyCollaterlizationRatio(ctx, amountIn, assetIn, amountOut, assetOut, liquidationThreshold) +func (k Keeper) VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error { + return k.lend.VerifyCollateralizationRatio(ctx, amountIn, assetIn, amountOut, assetOut, liquidationThreshold) } -func (k Keeper) CalculateLendCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) { - return k.lend.CalculateCollaterlizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) +func (k Keeper) CalculateCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) { + return k.lend.CalculateCollateralizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) } func (k Keeper) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) { @@ -241,26 +233,6 @@ func (k Keeper) DeleteBorrow(ctx sdk.Context, id uint64) { k.lend.DeleteBorrow(ctx, id) } -func (k Keeper) DeleteBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) { - k.lend.DeleteBorrowForAddressByPair(ctx, address, pairID) -} - -func (k Keeper) UpdateUserBorrowIDMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, isInsert bool) error { - return k.lend.UpdateUserBorrowIDMapping(ctx, borrowOwner, borrowID, isInsert) -} - -func (k Keeper) UpdateBorrowIDByOwnerAndPoolMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, poolID uint64, isInsert bool) error { - return k.lend.UpdateBorrowIDByOwnerAndPoolMapping(ctx, borrowOwner, borrowID, poolID, isInsert) -} - -func (k Keeper) UpdateBorrowIdsMapping(ctx sdk.Context, borrowID uint64, isInsert bool) error { - return k.lend.UpdateBorrowIdsMapping(ctx, borrowID, isInsert) -} - -func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) { - k.lend.CreteNewBorrow(ctx, liqBorrow) -} - func (k Keeper) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) { return k.lend.GetPool(ctx, id) } @@ -269,10 +241,6 @@ func (k Keeper) GetAddAuctionParamsData(ctx sdk.Context, appID uint64) (auctionP return k.lend.GetAddAuctionParamsData(ctx, appID) } -func (k Keeper) GetReserveDepositStats(ctx sdk.Context) (depositStats lendtypes.DepositStats, found bool) { - return k.lend.GetReserveDepositStats(ctx) -} - func (k Keeper) ModuleBalance(ctx sdk.Context, moduleName string, denom string) sdk.Int { return k.lend.ModuleBalance(ctx, moduleName, denom) } diff --git a/x/auction/keeper/dutch_lend.go b/x/auction/keeper/dutch_lend.go index d8413585e..37189c813 100644 --- a/x/auction/keeper/dutch_lend.go +++ b/x/auction/keeper/dutch_lend.go @@ -49,7 +49,7 @@ func (k Keeper) LendDutchActivator(ctx sdk.Context, lockedVault liquidationtypes outflowToken := sdk.NewCoin(assetIn.Denom, lockedVault.CollateralToBeAuctioned.Quo(AssetInPrice).TruncateInt()) inflowToken := sdk.NewCoin(assetOut.Denom, lockedVault.CollateralToBeAuctioned.Quo(AssetOutPrice).TruncateInt()) - AssetRatesStats, found := k.GetAssetRatesStats(ctx, extendedPair.AssetIn) + AssetRatesStats, found := k.GetAssetRatesParams(ctx, extendedPair.AssetIn) if !found { ctx.Logger().Error(auctiontypes.ErrorAssetRates.Error(), lockedVault.LockedVaultId) return nil @@ -101,7 +101,7 @@ func (k Keeper) StartLendDutchAuction( BorrowMetaData := lockedVault.GetBorrowMetaData() LendPos, _ := k.GetLend(ctx, BorrowMetaData.LendingId) pool, _ := k.GetPool(ctx, LendPos.PoolID) - assetStat, _ := k.GetAssetRatesStats(ctx, LendPos.AssetID) + assetStat, _ := k.GetAssetRatesParams(ctx, LendPos.AssetID) cAsset, _ := k.GetAsset(ctx, assetStat.CAssetID) if outFlowToken.Amount.GT(sdk.ZeroInt()) { err := k.SendCoinsFromModuleToModule(ctx, pool.ModuleName, auctiontypes.ModuleName, sdk.NewCoins(outFlowToken)) @@ -220,7 +220,7 @@ func (k Keeper) PlaceLendDutchAuctionBid(ctx sdk.Context, appID, auctionMappingI if !found { return auctiontypes.ErrorInvalidExtendedPairVault } - assetStats, _ := k.GetAssetRatesStats(ctx, ExtendedPairVault.AssetIn) + assetStats, _ := k.GetAssetRatesParams(ctx, ExtendedPairVault.AssetIn) assetOutPool, _ := k.GetPool(ctx, ExtendedPairVault.AssetOutPoolID) // dust is in usd * 10*-6 (uusd) dust := sdk.NewIntFromUint64(ExtendedPairVault.MinUsdValueLeft) @@ -410,7 +410,7 @@ func (k Keeper) CloseDutchLendAuction( borrowMetaData := lockedVault.GetBorrowMetaData() lendPos, _ := k.GetLend(ctx, borrowMetaData.LendingId) lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(dutchAuction.OutflowTokenInitAmount.Amount) - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(dutchAuction.OutflowTokenInitAmount.Amount) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(dutchAuction.OutflowTokenInitAmount.Amount) k.SetLend(ctx, lendPos) lockedVault.AmountOut = lockedVault.AmountOut.Sub(dutchAuction.InflowTokenTargetAmount.Amount) diff --git a/x/bandoracle/abci.go b/x/bandoracle/abci.go index 6208236ae..b82143667 100644 --- a/x/bandoracle/abci.go +++ b/x/bandoracle/abci.go @@ -16,18 +16,26 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { _ = utils.ApplyFuncIfNoError(ctx, func(ctx sdk.Context) error { block := k.GetLastBlockHeight(ctx) if block != types.Int64Zero { - if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero { - req := k.GetTempFetchPriceID(ctx) - res := k.OraclePriceValidationByRequestID(ctx, req) - k.SetOracleValidationResult(ctx, res) - } - if ctx.BlockHeight()%types.Int64Twenty-types.Int64One == types.Int64Zero && ctx.BlockHeight() > block+types.Int64Eleven { - id := k.GetLastFetchPriceID(ctx) - k.SetTempFetchPriceID(ctx, id) - msg := k.GetFetchPriceMsg(ctx) - _, err := k.FetchPrice(ctx, msg) - if err != nil { - return err + if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero && ctx.BlockHeight() != block { + if !k.GetCheckFlag(ctx) { + msg := k.GetFetchPriceMsg(ctx) + _, err := k.FetchPrice(ctx, msg) + if err != nil { + return err + } + k.SetTempFetchPriceID(ctx, 0) + k.SetCheckFlag(ctx, true) + } else { + msg := k.GetFetchPriceMsg(ctx) + _, err := k.FetchPrice(ctx, msg) + if err != nil { + return err + } + id := k.GetLastFetchPriceID(ctx) + req := k.GetTempFetchPriceID(ctx) + res := k.OraclePriceValidationByRequestID(ctx, req) + k.SetOracleValidationResult(ctx, res) + k.SetTempFetchPriceID(ctx, id) } } } diff --git a/x/bandoracle/handler.go b/x/bandoracle/handler.go index c6ff98f06..e2f199a24 100644 --- a/x/bandoracle/handler.go +++ b/x/bandoracle/handler.go @@ -15,15 +15,8 @@ import ( // NewHandler ... func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - switch msg := msg.(type) { - case *types.MsgFetchPriceData: - res, err := msgServer.FetchPriceData(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/bandoracle/keeper/msg_server.go b/x/bandoracle/keeper/msg_server.go deleted file mode 100644 index 633a6cfa1..000000000 --- a/x/bandoracle/keeper/msg_server.go +++ /dev/null @@ -1,88 +0,0 @@ -package keeper - -import ( - "context" - "time" - - "github.com/bandprotocol/bandchain-packet/obi" - "github.com/bandprotocol/bandchain-packet/packet" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - - "github.com/comdex-official/comdex/x/bandoracle/types" - - host "github.com/cosmos/ibc-go/v3/modules/core/24-host" -) - -type msgServer struct { - Keeper -} - -// NewMsgServerImpl returns an implementation of the MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} - -var _ types.MsgServer = msgServer{} - -func (k msgServer) FetchPriceData(goCtx context.Context, msg *types.MsgFetchPriceData) (*types.MsgFetchPriceDataResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - sourcePort := types.PortID - sourceChannelEnd, found := k.channelKeeper.GetChannel(ctx, sourcePort, msg.SourceChannel) - if !found { - return nil, sdkerrors.Wrapf( - sdkerrors.ErrUnknownRequest, - "unknown channel %s port %s", - msg.SourceChannel, - sourcePort, - ) - } - destinationPort := sourceChannelEnd.GetCounterparty().GetPortID() - destinationChannel := sourceChannelEnd.GetCounterparty().GetChannelID() - - // get the next sequence - sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, msg.SourceChannel) - if !found { - return nil, sdkerrors.Wrapf( - channeltypes.ErrSequenceSendNotFound, - "source port: %s, source channel: %s", sourcePort, msg.SourceChannel) - } - - channelCap, ok := k.scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePort, msg.SourceChannel)) - if !ok { - return nil, sdkerrors.Wrap(channeltypes.ErrChannelCapabilityNotFound, - "module does not own channel capability") - } - - encodedCalldata := obi.MustEncode(*msg.Calldata) - packetData := packet.NewOracleRequestPacketData( - msg.ClientID, - msg.OracleScriptID, - encodedCalldata, - msg.AskCount, - msg.MinCount, - msg.FeeLimit, - msg.PrepareGas, - msg.ExecuteGas, - ) - - err := k.channelKeeper.SendPacket(ctx, channelCap, channeltypes.NewPacket( - packetData.GetBytes(), - sequence, - sourcePort, - msg.SourceChannel, - destinationPort, - destinationChannel, - clienttypes.NewHeight(0, 0), - uint64(ctx.BlockTime().UnixNano()+int64(10*time.Minute)), // Arbitrary timestamp timeout for now - )) - if err != nil { - return nil, err - } - - return &types.MsgFetchPriceDataResponse{}, nil -} diff --git a/x/bandoracle/keeper/oracle.go b/x/bandoracle/keeper/oracle.go index edb4a00a9..ec0968e34 100644 --- a/x/bandoracle/keeper/oracle.go +++ b/x/bandoracle/keeper/oracle.go @@ -11,6 +11,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" gogotypes "github.com/gogo/protobuf/types" + protobuftypes "github.com/gogo/protobuf/types" "github.com/comdex-official/comdex/x/bandoracle/types" ) @@ -156,6 +157,7 @@ func (k Keeper) SetLastBlockHeight(ctx sdk.Context, height int64) { func (k Keeper) AddFetchPriceRecords(ctx sdk.Context, price types.MsgFetchPriceData) error { k.SetFetchPriceMsg(ctx, price) k.SetLastBlockHeight(ctx, ctx.BlockHeight()) + k.SetCheckFlag(ctx, false) return nil } @@ -190,3 +192,30 @@ func (k Keeper) GetTempFetchPriceID(ctx sdk.Context) int64 { k.cdc.MustUnmarshalLengthPrefixed(bz, &intV) return intV.GetValue() } + +func (k Keeper) SetCheckFlag(ctx sdk.Context, flag bool) { + var ( + store = ctx.KVStore(k.storeKey) + key = types.CheckFlagKey + value = k.cdc.MustMarshal( + &protobuftypes.BoolValue{ + Value: flag, + }, + ) + ) + + store.Set(key, value) +} + +func (k Keeper) GetCheckFlag(ctx sdk.Context) bool { + var ( + store = ctx.KVStore(k.storeKey) + key = types.CheckFlagKey + value = store.Get(key) + ) + + var id protobuftypes.BoolValue + k.cdc.MustUnmarshal(value, &id) + + return id.GetValue() +} diff --git a/x/bandoracle/module.go b/x/bandoracle/module.go index 4621a1bd7..ae6285afc 100644 --- a/x/bandoracle/module.go +++ b/x/bandoracle/module.go @@ -1,6 +1,7 @@ package bandoracle import ( + "context" "encoding/json" "fmt" @@ -92,6 +93,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } // GetTxCmd returns the capability module's root tx command. diff --git a/x/bandoracle/types/codec.go b/x/bandoracle/types/codec.go index 67d1fad97..a1eff4c1a 100644 --- a/x/bandoracle/types/codec.go +++ b/x/bandoracle/types/codec.go @@ -4,12 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgFetchPriceData{}, "bandoracle/FetchPriceData", nil) } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { @@ -17,8 +15,6 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgFetchPriceData{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) - registry.RegisterImplementations( (*govtypes.Content)(nil), &FetchPriceProposal{}, diff --git a/x/bandoracle/types/keys.go b/x/bandoracle/types/keys.go index ca48de7d8..032f6d0a1 100644 --- a/x/bandoracle/types/keys.go +++ b/x/bandoracle/types/keys.go @@ -25,8 +25,9 @@ const ( var ( // PortKey defines the key to store the port ID in store. - PortKey = KeyPrefix("bandoracle-port-") - MsgDataKey = []byte{0x02} + PortKey = KeyPrefix("bandoracle-port-") + MsgDataKey = []byte{0x02} + CheckFlagKey = []byte{0x03} ) func KeyPrefix(p string) []byte { diff --git a/x/bandoracle/types/tx.pb.go b/x/bandoracle/types/tx.pb.go index 15dba7f33..c223c313a 100644 --- a/x/bandoracle/types/tx.pb.go +++ b/x/bandoracle/types/tx.pb.go @@ -4,16 +4,11 @@ package types import ( - context "context" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" io "io" math "math" math_bits "math/bits" @@ -200,122 +195,40 @@ func init() { } var fileDescriptor_e41ad8b392d8eeff = []byte{ - // 549 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xd1, 0x6e, 0xd3, 0x3c, - 0x14, 0xc7, 0x9b, 0x6f, 0xfd, 0xb6, 0xd4, 0x85, 0x0a, 0x22, 0x24, 0xd2, 0x4e, 0x4a, 0xaa, 0x4a, - 0x48, 0x45, 0xd0, 0x84, 0x95, 0x5d, 0x71, 0xd9, 0x56, 0xa0, 0x0a, 0x06, 0x28, 0x5c, 0x20, 0x71, - 0x13, 0xb9, 0xce, 0x69, 0x6a, 0x35, 0x89, 0x43, 0xec, 0xa2, 0x56, 0xbc, 0x04, 0xcf, 0xb1, 0x27, - 0xd9, 0xe5, 0x2e, 0xb9, 0x2a, 0xa8, 0x7d, 0x03, 0x9e, 0x00, 0xd9, 0xce, 0x56, 0xb6, 0x69, 0x48, - 0x5c, 0x25, 0xfe, 0xff, 0x7f, 0xe7, 0x1c, 0xfb, 0x1c, 0x1b, 0x75, 0x08, 0x4b, 0x23, 0x58, 0xfa, - 0x13, 0x9c, 0x45, 0xac, 0xc0, 0x24, 0x01, 0xff, 0xcb, 0xd1, 0x04, 0x04, 0x3e, 0xf2, 0xc5, 0xd2, - 0xcb, 0x0b, 0x26, 0x98, 0xd5, 0xd4, 0x8c, 0xb7, 0x63, 0xbc, 0x92, 0x69, 0x3d, 0x88, 0x59, 0xcc, - 0x14, 0xe5, 0xcb, 0x3f, 0x1d, 0xd0, 0x72, 0x08, 0xe3, 0x29, 0xe3, 0xfe, 0x04, 0xf3, 0x5d, 0x3a, - 0xc2, 0x68, 0x56, 0xfa, 0x4f, 0x6e, 0x2f, 0x3a, 0x05, 0x41, 0x66, 0x61, 0x5e, 0x50, 0x02, 0x1a, - 0xee, 0x9c, 0x56, 0xd1, 0xfd, 0x13, 0x1e, 0xbf, 0x94, 0xc6, 0x7b, 0xa9, 0x8f, 0xb0, 0xc0, 0x96, - 0x8d, 0x0e, 0x48, 0x01, 0x58, 0xb0, 0xc2, 0x36, 0xda, 0x46, 0xb7, 0x16, 0x5c, 0x2c, 0xad, 0x8f, - 0xe8, 0x9e, 0xce, 0x19, 0x72, 0x52, 0xd0, 0x5c, 0x84, 0x34, 0xb2, 0xff, 0x6b, 0x1b, 0xdd, 0xea, - 0xa0, 0xb7, 0x59, 0xbb, 0x8d, 0x77, 0xca, 0xfb, 0xa0, 0xac, 0xf1, 0xe8, 0xd7, 0xda, 0x7d, 0xb8, - 0xc2, 0x69, 0xf2, 0xa2, 0x73, 0x3d, 0xa6, 0x13, 0x34, 0xd8, 0x9f, 0x68, 0x64, 0x3d, 0x42, 0x0d, - 0xce, 0x16, 0x05, 0x81, 0x90, 0xcc, 0x70, 0x96, 0x41, 0x62, 0xef, 0xa9, 0xca, 0x77, 0xb5, 0x3a, - 0xd4, 0xa2, 0x35, 0x46, 0x26, 0xc1, 0x49, 0x12, 0x61, 0x81, 0xed, 0x6a, 0xdb, 0xe8, 0xd6, 0xfb, - 0x3d, 0xef, 0xd6, 0x06, 0x7a, 0xbb, 0x63, 0x0d, 0x71, 0x92, 0xc8, 0xa3, 0x05, 0x97, 0xe1, 0xd6, - 0x21, 0xaa, 0x61, 0x3e, 0x0f, 0x09, 0x5b, 0x64, 0xc2, 0xfe, 0x5f, 0x9e, 0x21, 0x30, 0x31, 0x9f, - 0x0f, 0xe5, 0x5a, 0x9a, 0x29, 0xcd, 0x4a, 0x73, 0x5f, 0x9b, 0x29, 0xcd, 0xb4, 0x39, 0x43, 0xb5, - 0x29, 0x40, 0x98, 0xd0, 0x94, 0x0a, 0xfb, 0xa0, 0xbd, 0xd7, 0xad, 0xf7, 0x9b, 0x9e, 0x9e, 0x8a, - 0x27, 0xa7, 0x72, 0x59, 0x7f, 0xc8, 0x68, 0x36, 0x78, 0x76, 0xb6, 0x76, 0x2b, 0xa7, 0x3f, 0xdc, - 0x6e, 0x4c, 0xc5, 0x6c, 0x31, 0x91, 0xdb, 0xf5, 0xcb, 0x11, 0xea, 0x4f, 0x8f, 0x47, 0x73, 0x5f, - 0xac, 0x72, 0xe0, 0x2a, 0x80, 0x07, 0xe6, 0x14, 0xe0, 0x8d, 0x4c, 0x6e, 0xb9, 0xa8, 0x5e, 0xc0, - 0xe7, 0x05, 0x70, 0x11, 0xce, 0x61, 0x65, 0x9b, 0xaa, 0x25, 0xa8, 0x94, 0x5e, 0xc3, 0x4a, 0x02, - 0x79, 0x01, 0x39, 0x2e, 0x20, 0x8c, 0x31, 0xb7, 0x6b, 0x6a, 0xa7, 0xa8, 0x94, 0x5e, 0x61, 0x2e, - 0x01, 0x58, 0x02, 0x59, 0x08, 0x0d, 0x20, 0x0d, 0x94, 0x92, 0x04, 0x1e, 0xa3, 0x1a, 0x49, 0x28, - 0x64, 0x6a, 0x94, 0x75, 0x59, 0x60, 0x70, 0x67, 0xb3, 0x76, 0xcd, 0xa1, 0x12, 0xc7, 0xa3, 0xc0, - 0xd4, 0xf6, 0x38, 0xea, 0x1c, 0xa2, 0xe6, 0x8d, 0xbb, 0x12, 0x00, 0xcf, 0x59, 0xc6, 0xa1, 0xff, - 0x15, 0xed, 0x9d, 0xf0, 0xd8, 0x12, 0xa8, 0x71, 0xed, 0x32, 0x3d, 0xfd, 0xcb, 0x80, 0x6e, 0xa4, - 0x6b, 0x1d, 0xff, 0x0b, 0x7d, 0x51, 0x7c, 0xf0, 0xf6, 0x6c, 0xe3, 0x18, 0xe7, 0x1b, 0xc7, 0xf8, - 0xb9, 0x71, 0x8c, 0x6f, 0x5b, 0xa7, 0x72, 0xbe, 0x75, 0x2a, 0xdf, 0xb7, 0x4e, 0xe5, 0xd3, 0xf1, - 0x95, 0xae, 0xcb, 0xcc, 0x3d, 0x36, 0x9d, 0x52, 0x42, 0x71, 0x52, 0xae, 0xfd, 0x2b, 0x4f, 0x45, - 0xcd, 0x61, 0xb2, 0xaf, 0x5e, 0xc7, 0xf3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x73, 0x71, 0xaf, - 0x76, 0xc1, 0x03, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type MsgClient interface { - FetchPriceData(ctx context.Context, in *MsgFetchPriceData, opts ...grpc.CallOption) (*MsgFetchPriceDataResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) FetchPriceData(ctx context.Context, in *MsgFetchPriceData, opts ...grpc.CallOption) (*MsgFetchPriceDataResponse, error) { - out := new(MsgFetchPriceDataResponse) - err := c.cc.Invoke(ctx, "/comdex.bandoracle.v1beta1.Msg/FetchPriceData", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - FetchPriceData(context.Context, *MsgFetchPriceData) (*MsgFetchPriceDataResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) FetchPriceData(ctx context.Context, req *MsgFetchPriceData) (*MsgFetchPriceDataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FetchPriceData not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_FetchPriceData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgFetchPriceData) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).FetchPriceData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.bandoracle.v1beta1.Msg/FetchPriceData", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).FetchPriceData(ctx, req.(*MsgFetchPriceData)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "comdex.bandoracle.v1beta1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "FetchPriceData", - Handler: _Msg_FetchPriceData_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "comdex/bandoracle/v1beta1/tx.proto", + // 519 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xdd, 0x6e, 0xd3, 0x30, + 0x14, 0xc7, 0x1b, 0x56, 0xb6, 0xd4, 0x85, 0x0a, 0x22, 0x24, 0xd2, 0x4d, 0x4a, 0xaa, 0x4a, 0x48, + 0x45, 0xa8, 0x09, 0x1b, 0x5c, 0x71, 0xd9, 0x56, 0xa0, 0x8a, 0x4f, 0x85, 0x0b, 0x24, 0x6e, 0x22, + 0xd7, 0x39, 0x6d, 0xad, 0x26, 0x76, 0xb0, 0x5d, 0xd4, 0xbe, 0x05, 0xcf, 0xb1, 0x27, 0xd9, 0xe5, + 0x2e, 0xb9, 0x2a, 0xa8, 0x7d, 0x03, 0x9e, 0x00, 0xd9, 0x0e, 0x2b, 0x03, 0xed, 0x2a, 0xf1, 0xff, + 0xff, 0x3b, 0x3e, 0x3e, 0x1f, 0xa8, 0x4b, 0x78, 0x91, 0xc1, 0x2a, 0x9e, 0x60, 0x96, 0x71, 0x81, + 0x49, 0x0e, 0xf1, 0xd7, 0xd3, 0x09, 0x28, 0x7c, 0x1a, 0xab, 0x55, 0x54, 0x0a, 0xae, 0xb8, 0xd7, + 0xb6, 0x4c, 0xb4, 0x67, 0xa2, 0x8a, 0x39, 0x7e, 0x30, 0xe3, 0x33, 0x6e, 0xa8, 0x58, 0xff, 0xd9, + 0x80, 0xe3, 0x80, 0x70, 0x59, 0x70, 0x19, 0x4f, 0xb0, 0xdc, 0x5f, 0x47, 0x38, 0x65, 0x95, 0xff, + 0xe4, 0xe6, 0xa4, 0x53, 0x50, 0x64, 0x9e, 0x96, 0x82, 0x12, 0xb0, 0x70, 0xf7, 0xbc, 0x8e, 0xee, + 0xbf, 0x95, 0xb3, 0x97, 0xda, 0xf8, 0xa0, 0xf5, 0x11, 0x56, 0xd8, 0xf3, 0xd1, 0x11, 0x11, 0x80, + 0x15, 0x17, 0xbe, 0xd3, 0x71, 0x7a, 0x8d, 0xe4, 0xcf, 0xd1, 0xfb, 0x84, 0xee, 0xd9, 0x3b, 0x53, + 0x49, 0x04, 0x2d, 0x55, 0x4a, 0x33, 0xff, 0x56, 0xc7, 0xe9, 0xd5, 0x07, 0xfd, 0xed, 0x26, 0x6c, + 0xbd, 0x37, 0xde, 0x47, 0x63, 0x8d, 0x47, 0xbf, 0x36, 0xe1, 0xc3, 0x35, 0x2e, 0xf2, 0x17, 0xdd, + 0x7f, 0x63, 0xba, 0x49, 0x8b, 0xff, 0x8d, 0x66, 0xde, 0x23, 0xd4, 0x92, 0x7c, 0x29, 0x08, 0xa4, + 0x64, 0x8e, 0x19, 0x83, 0xdc, 0x3f, 0x30, 0x99, 0xef, 0x5a, 0x75, 0x68, 0x45, 0x6f, 0x8c, 0x5c, + 0x82, 0xf3, 0x3c, 0xc3, 0x0a, 0xfb, 0xf5, 0x8e, 0xd3, 0x6b, 0x9e, 0xf5, 0xa3, 0x1b, 0x1b, 0x18, + 0xed, 0xcb, 0x1a, 0xe2, 0x3c, 0xd7, 0xa5, 0x25, 0x57, 0xe1, 0xde, 0x09, 0x6a, 0x60, 0xb9, 0x48, + 0x09, 0x5f, 0x32, 0xe5, 0xdf, 0xd6, 0x35, 0x24, 0x2e, 0x96, 0x8b, 0xa1, 0x3e, 0x6b, 0xb3, 0xa0, + 0xac, 0x32, 0x0f, 0xad, 0x59, 0x50, 0x66, 0xcd, 0x39, 0x6a, 0x4c, 0x01, 0xd2, 0x9c, 0x16, 0x54, + 0xf9, 0x47, 0x9d, 0x83, 0x5e, 0xf3, 0xac, 0x1d, 0xd9, 0xa9, 0x44, 0x7a, 0x2a, 0x57, 0xf9, 0x87, + 0x9c, 0xb2, 0xc1, 0xd3, 0x8b, 0x4d, 0x58, 0x3b, 0xff, 0x11, 0xf6, 0x66, 0x54, 0xcd, 0x97, 0x13, + 0xfd, 0xdc, 0xb8, 0x1a, 0xa1, 0xfd, 0xf4, 0x65, 0xb6, 0x88, 0xd5, 0xba, 0x04, 0x69, 0x02, 0x64, + 0xe2, 0x4e, 0x01, 0xde, 0xe8, 0xcb, 0xbd, 0x10, 0x35, 0x05, 0x7c, 0x59, 0x82, 0x54, 0xe9, 0x02, + 0xd6, 0xbe, 0x6b, 0x5a, 0x82, 0x2a, 0xe9, 0x35, 0xac, 0x35, 0x50, 0x0a, 0x28, 0xb1, 0x80, 0x74, + 0x86, 0xa5, 0xdf, 0x30, 0x2f, 0x45, 0x95, 0xf4, 0x0a, 0x4b, 0x0d, 0xc0, 0x0a, 0xc8, 0x52, 0x59, + 0x00, 0x59, 0xa0, 0x92, 0x34, 0xf0, 0x18, 0x35, 0x48, 0x4e, 0x81, 0x99, 0x51, 0x36, 0x75, 0x82, + 0xc1, 0x9d, 0xed, 0x26, 0x74, 0x87, 0x46, 0x1c, 0x8f, 0x12, 0xd7, 0xda, 0xe3, 0xac, 0x7b, 0x82, + 0xda, 0xff, 0xed, 0x4a, 0x02, 0xb2, 0xe4, 0x4c, 0xc2, 0xe0, 0xdd, 0xc5, 0x36, 0x70, 0x2e, 0xb7, + 0x81, 0xf3, 0x73, 0x1b, 0x38, 0xdf, 0x76, 0x41, 0xed, 0x72, 0x17, 0xd4, 0xbe, 0xef, 0x82, 0xda, + 0xe7, 0xe7, 0xd7, 0x0a, 0xd7, 0xb3, 0xea, 0xf3, 0xe9, 0x94, 0x12, 0x8a, 0xf3, 0xea, 0x1c, 0x5f, + 0xdb, 0x56, 0xd3, 0x8a, 0xc9, 0xa1, 0x59, 0xd0, 0x67, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x1b, + 0xde, 0x17, 0xd2, 0x44, 0x03, 0x00, 0x00, } func (m *MsgFetchPriceData) Marshal() (dAtA []byte, err error) { diff --git a/x/collector/keeper/collector.go b/x/collector/keeper/collector.go index daee5306e..c2cec45dd 100644 --- a/x/collector/keeper/collector.go +++ b/x/collector/keeper/collector.go @@ -736,7 +736,7 @@ func (k Keeper) LockerIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, coll if found { for _, lockID := range lockers.LockerIds { lockerData, _ := k.GetLocker(ctx, lockID) - rewards := sdk.ZeroDec() + var rewards sdk.Dec var err error if lockerData.BlockHeight == 0 { rewards, err = k.CalculationOfRewards(ctx, lockerData.NetBalance, collectorLsr, collectorBt) @@ -763,8 +763,7 @@ func (k Keeper) LockerIterateRewards(ctx sdk.Context, collectorLsr sdk.Dec, coll if lockerRewardsTracker.RewardsAccumulated.GTE(sdk.OneDec()) { // send rewards - newReward := sdk.ZeroInt() - newReward = lockerRewardsTracker.RewardsAccumulated.TruncateInt() + newReward := lockerRewardsTracker.RewardsAccumulated.TruncateInt() newRewardDec := sdk.NewDec(newReward.Int64()) lockerRewardsTracker.RewardsAccumulated = lockerRewardsTracker.RewardsAccumulated.Sub(newRewardDec) k.SetLockerRewardTracker(ctx, lockerRewardsTracker) diff --git a/x/lend/client/cli/flags.go b/x/lend/client/cli/flags.go index 476da2e2a..fd416ba17 100644 --- a/x/lend/client/cli/flags.go +++ b/x/lend/client/cli/flags.go @@ -8,10 +8,10 @@ import ( ) const ( - FlagNewLendPairFile = "add-lend-pair-file" - FlagAddLendPoolFile = "add-lend-pool-file" - FlagAddAssetRatesStatsFile = "add-asset-rates-stats-file" - FlagSetAuctionParamsFile = "add-auction-params-file" + FlagNewLendPairFile = "add-lend-pair-file" + FlagAddLendPoolFile = "add-lend-pool-file" + FlagAddAssetRatesParamsFile = "add-asset-rates-params-file" + FlagSetAuctionParamsFile = "add-auction-params-file" ) func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) { @@ -51,10 +51,10 @@ func FlagSetAddLendPoolMapping() *flag.FlagSet { return fs } -func FlagSetAddAssetRatesStatsMapping() *flag.FlagSet { +func FlagSetAddAssetRatesParamsMapping() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) - fs.String(FlagAddAssetRatesStatsFile, "", "add asset rates stats json file path") + fs.String(FlagAddAssetRatesParamsFile, "", "add asset rates stats json file path") return fs } @@ -77,20 +77,18 @@ type addNewLendPairsInputs struct { } type addLendPoolInputs struct { - ModuleName string `json:"module_name"` - MainAssetID string `json:"main_asset_id"` - FirstBridgedAssetID string `json:"first_bridged_asset_id"` - SecondBridgedAssetID string `json:"second_bridged_asset_id"` - AssetID string `json:"asset_id"` - IsBridgedAsset string `json:"is_bridged_asset"` - CPoolName string `json:"c_pool_name"` - ReserveFunds string `json:"reserve_funds"` - Title string - Description string - Deposit string + ModuleName string `json:"module_name"` + AssetID string `json:"asset_id"` + AssetTransitType string `json:"asset_transit_type"` + SupplyCap string `json:"supply_cap"` + CPoolName string `json:"c_pool_name"` + ReserveFunds string `json:"reserve_funds"` + Title string + Description string + Deposit string } -type addAssetRatesStatsInputs struct { +type addAssetRatesParamsInputs struct { AssetID string `json:"asset_id"` UOptimal string `json:"u_optimal"` Base string `json:"base"` diff --git a/x/lend/client/cli/parse.go b/x/lend/client/cli/parse.go index 94d5e042b..e44673ba4 100644 --- a/x/lend/client/cli/parse.go +++ b/x/lend/client/cli/parse.go @@ -10,10 +10,10 @@ import ( ) type ( - XAddNewLendPairsInputs addNewLendPairsInputs - XAddLendPoolInputs addLendPoolInputs - XAddAssetRatesStatsInputs addAssetRatesStatsInputs - XSetAuctionParamsInputs addNewAuctionParamsInputs + XAddNewLendPairsInputs addNewLendPairsInputs + XAddLendPoolInputs addLendPoolInputs + XAddAssetRatesParamsInputs addAssetRatesParamsInputs + XSetAuctionParamsInputs addNewAuctionParamsInputs ) type XAddNewLendPairsInputsExceptions struct { @@ -25,8 +25,8 @@ type XAddPoolInputsExceptions struct { XAddLendPoolInputs Other *string // Other won't raise an error } -type XAddAssetRatesStatsInputsExceptions struct { - XAddAssetRatesStatsInputs +type XAddAssetRatesParamsInputsExceptions struct { + XAddAssetRatesParamsInputs Other *string // Other won't raise an error } @@ -63,16 +63,16 @@ func (release *addLendPoolInputs) UnmarshalJSON(data []byte) error { return nil } -func (release *addAssetRatesStatsInputs) UnmarshalJSON(data []byte) error { - var addAssetRatesStatsE XAddAssetRatesStatsInputsExceptions +func (release *addAssetRatesParamsInputs) UnmarshalJSON(data []byte) error { + var addAssetRatesParamsE XAddAssetRatesParamsInputsExceptions dec := json.NewDecoder(bytes.NewReader(data)) dec.DisallowUnknownFields() // Force - if err := dec.Decode(&addAssetRatesStatsE); err != nil { + if err := dec.Decode(&addAssetRatesParamsE); err != nil { return err } - *release = addAssetRatesStatsInputs(addAssetRatesStatsE.XAddAssetRatesStatsInputs) + *release = addAssetRatesParamsInputs(addAssetRatesParamsE.XAddAssetRatesParamsInputs) return nil } @@ -134,26 +134,26 @@ func parseAddPoolFlags(fs *pflag.FlagSet) (*addLendPoolInputs, error) { return addPoolParams, nil } -func parseAssetRateStatsFlags(fs *pflag.FlagSet) (*addAssetRatesStatsInputs, error) { - addAssetRatesStats := &addAssetRatesStatsInputs{} - addAssetRatesStatsFile, _ := fs.GetString(FlagAddAssetRatesStatsFile) +func parseAssetRateStatsFlags(fs *pflag.FlagSet) (*addAssetRatesParamsInputs, error) { + addAssetRatesParams := &addAssetRatesParamsInputs{} + addAssetRatesParamsFile, _ := fs.GetString(FlagAddAssetRatesParamsFile) - if addAssetRatesStatsFile == "" { - return nil, fmt.Errorf("must pass in a add asset rates stats json using the --%s flag", FlagAddAssetRatesStatsFile) + if addAssetRatesParamsFile == "" { + return nil, fmt.Errorf("must pass in a add asset rates stats json using the --%s flag", FlagAddAssetRatesParamsFile) } - contents, err := os.ReadFile(addAssetRatesStatsFile) + contents, err := os.ReadFile(addAssetRatesParamsFile) if err != nil { return nil, err } // make exception if unknown field exists - err = addAssetRatesStats.UnmarshalJSON(contents) + err = addAssetRatesParams.UnmarshalJSON(contents) if err != nil { return nil, err } - return addAssetRatesStats, nil + return addAssetRatesParams, nil } func parseAuctionPramsFlags(fs *pflag.FlagSet) (*addNewAuctionParamsInputs, error) { diff --git a/x/lend/client/cli/query.go b/x/lend/client/cli/query.go index f7a21209a..269774a6e 100644 --- a/x/lend/client/cli/query.go +++ b/x/lend/client/cli/query.go @@ -40,16 +40,16 @@ func GetQueryCmd() *cobra.Command { queryBorrows(), QueryAllBorrowsByOwner(), QueryAllBorrowsByOwnerAndPoolID(), - queryAssetRatesStat(), - queryAssetRatesStats(), - QueryAssetStats(), - QueryModuleBalance(), - queryDepositStats(), - queryUserDepositStats(), - queryReserveDepositStats(), - queryBuyBackDepositStats(), - queryBorrowStats(), - queryAuctionParams(), + QueryAssetRatesParam(), + QueryAssetRatesParams(), + QueryPoolAssetLBMapping(), + // QueryModuleBalance(), + // queryDepositStats(), + // queryUserDepositStats(), + // queryReserveDepositStats(), + queryReserveBuybackAssetData(), + // queryBorrowStats(), + queryAuctionParams(), // ) return cmd @@ -571,7 +571,7 @@ func QueryAllBorrowsByOwnerAndPoolID() *cobra.Command { return cmd } -func queryAssetRatesStat() *cobra.Command { +func QueryAssetRatesParam() *cobra.Command { cmd := &cobra.Command{ Use: "asset-rates-stat [asset-id]", Short: "Query asset rates stat by asset-id", @@ -589,9 +589,9 @@ func queryAssetRatesStat() *cobra.Command { queryClient := types.NewQueryClient(ctx) - res, err := queryClient.QueryAssetRatesStat( + res, err := queryClient.QueryAssetRatesParam( context.Background(), - &types.QueryAssetRatesStatRequest{ + &types.QueryAssetRatesParamRequest{ Id: id, }, ) @@ -608,7 +608,7 @@ func queryAssetRatesStat() *cobra.Command { return cmd } -func queryAssetRatesStats() *cobra.Command { +func QueryAssetRatesParams() *cobra.Command { cmd := &cobra.Command{ Use: "asset-rates-stats", Short: "Query asset rates stats", @@ -625,9 +625,9 @@ func queryAssetRatesStats() *cobra.Command { queryClient := types.NewQueryClient(ctx) - res, err := queryClient.QueryAssetRatesStats( + res, err := queryClient.QueryAssetRatesParams( context.Background(), - &types.QueryAssetRatesStatsRequest{ + &types.QueryAssetRatesParamsRequest{ Pagination: pagination, }, ) @@ -645,7 +645,7 @@ func queryAssetRatesStats() *cobra.Command { return cmd } -func QueryAssetStats() *cobra.Command { +func QueryPoolAssetLBMapping() *cobra.Command { cmd := &cobra.Command{ Use: "asset-stats [asset-id] [pool-id]", Short: "Query asset stats for an asset-id and pool-id", @@ -668,7 +668,7 @@ func QueryAssetStats() *cobra.Command { return err } - res, err := queryClient.QueryAssetStats(cmd.Context(), &types.QueryAssetStatsRequest{ + res, err := queryClient.QueryPoolAssetLBMapping(cmd.Context(), &types.QueryPoolAssetLBMappingRequest{ AssetId: assetID, PoolId: poolID, }) @@ -683,143 +683,151 @@ func QueryAssetStats() *cobra.Command { return cmd } -func QueryModuleBalance() *cobra.Command { +// 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 +// } + +// 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: "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 -} - -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", + Use: "buy-back-deposit-stats [id]", Short: "Query reserve deposit stats", + 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) - - 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 queryBuyBackDepositStats() *cobra.Command { - cmd := &cobra.Command{ - Use: "buy-back-deposit-stats", - Short: "Query reserve deposit stats", - RunE: func(cmd *cobra.Command, args []string) error { - ctx, err := client.GetClientQueryContext(cmd) + id, err := strconv.ParseUint(args[0], 10, 64) if err != nil { return err } queryClient := types.NewQueryClient(ctx) - res, err := queryClient.QueryBuyBackDepositStats( + res, err := queryClient.QueryReserveBuybackAssetData( context.Background(), - &types.QueryBuyBackDepositStatsRequest{}, + &types.QueryReserveBuybackAssetDataRequest{ + AssetId: id, + }, ) if err != nil { return err @@ -835,35 +843,35 @@ func queryBuyBackDepositStats() *cobra.Command { return cmd } -func queryBorrowStats() *cobra.Command { - cmd := &cobra.Command{ - Use: "borrow-stats", - Short: "Query borrow 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.QueryBorrowStats( - context.Background(), - &types.QueryBorrowStatsRequest{}, - ) - if err != nil { - return err - } - - return ctx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - flags.AddPaginationFlagsToCmd(cmd, "borrow-stats") - - return cmd -} +// func queryBorrowStats() *cobra.Command { +// cmd := &cobra.Command{ +// Use: "borrow-stats", +// Short: "Query borrow 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.QueryBorrowStats( +// context.Background(), +// &types.QueryBorrowStatsRequest{}, +// ) +// if err != nil { +// return err +// } + +// return ctx.PrintProto(res) +// }, +// } + +// flags.AddQueryFlagsToCmd(cmd) +// flags.AddPaginationFlagsToCmd(cmd, "borrow-stats") + +// return cmd +// } func queryAuctionParams() *cobra.Command { cmd := &cobra.Command{ diff --git a/x/lend/client/cli/tx.go b/x/lend/client/cli/tx.go index 679020e7c..4885cebf0 100644 --- a/x/lend/client/cli/tx.go +++ b/x/lend/client/cli/tx.go @@ -546,6 +546,90 @@ 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 { @@ -555,53 +639,41 @@ func NewCreateLendPool(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSe moduleName := newLendPool.ModuleName cPoolName := newLendPool.CPoolName - mainAssetID, err := strconv.ParseUint(newLendPool.MainAssetID, 10, 64) - if err != nil { - return txf, nil, err - } - - firstBridgedAssetID, err := strconv.ParseUint(newLendPool.FirstBridgedAssetID, 10, 64) - if err != nil { - return txf, nil, err - } - - secondBridgedAssetID, err := strconv.ParseUint(newLendPool.SecondBridgedAssetID, 10, 64) + reserveFunds, err := strconv.ParseUint(newLendPool.ReserveFunds, 10, 64) if err != nil { return txf, nil, err } - reserveFunds, err := strconv.ParseUint(newLendPool.ReserveFunds, 10, 64) + assetID, err := ParseUint64SliceFromString(newLendPool.AssetID, ",") if err != nil { return txf, nil, err } - assetID, err := ParseUint64SliceFromString(newLendPool.AssetID, ",") + supplyCap, err := ParseUint64SliceFromString(newLendPool.SupplyCap, ",") if err != nil { return txf, nil, err } - isBridgedAsset, err := ParseUint64SliceFromString(newLendPool.IsBridgedAsset, ",") + assetTransitType, err := ParseUint64SliceFromString(newLendPool.AssetTransitType, ",") if err != nil { return txf, nil, err } var pool types.Pool - var assetData []types.AssetDataPoolMapping + var assetData []*types.AssetDataPoolMapping for i := range assetID { - bridged := ParseBoolFromString(isBridgedAsset[i]) - assetData = append(assetData, types.AssetDataPoolMapping{ - AssetID: assetID[i], - IsBridged: bridged, - }) + assetDataNew := types.AssetDataPoolMapping{ + AssetID: assetID[i], + AssetTransitType: assetTransitType[i], + SupplyCap: supplyCap[i], + } + assetData = append(assetData, &assetDataNew) } pool = types.Pool{ - ModuleName: moduleName, - MainAssetId: mainAssetID, - FirstBridgedAssetID: firstBridgedAssetID, - SecondBridgedAssetID: secondBridgedAssetID, - CPoolName: cPoolName, - ReserveFunds: reserveFunds, - AssetData: assetData, + ModuleName: moduleName, + CPoolName: cPoolName, + ReserveFunds: reserveFunds, + AssetData: assetData, } from := clientCtx.GetFromAddress() @@ -703,10 +775,10 @@ func CmdAddAssetToPairProposal() *cobra.Command { return cmd } -func CmdAddNewAssetRatesStatsProposal() *cobra.Command { +func CmdAddNewAssetRatesParamsProposal() *cobra.Command { cmd := &cobra.Command{ - Use: "add-asset-rates-stats [flags]", - Short: "Add lend asset pairs", + Use: "add-asset-rates-params [flags]", + Short: "Add lend asset rates params", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -715,7 +787,7 @@ func CmdAddNewAssetRatesStatsProposal() *cobra.Command { } txf := tx.NewFactoryCLI(clientCtx, cmd.Flags()).WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) - txf, msg, err := NewCreateAssetRatesStats(clientCtx, txf, cmd.Flags()) + txf, msg, err := NewCreateassetRatesParams(clientCtx, txf, cmd.Flags()) if err != nil { return err } @@ -724,51 +796,51 @@ func CmdAddNewAssetRatesStatsProposal() *cobra.Command { }, } - cmd.Flags().AddFlagSet(FlagSetAddAssetRatesStatsMapping()) + cmd.Flags().AddFlagSet(FlagSetAddAssetRatesParamsMapping()) cmd.Flags().String(cli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") return cmd } -func NewCreateAssetRatesStats(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { - assetRatesStatsInput, err := parseAssetRateStatsFlags(fs) +func NewCreateassetRatesParams(clientCtx client.Context, txf tx.Factory, fs *flag.FlagSet) (tx.Factory, sdk.Msg, error) { + assetRatesParamsInput, err := parseAssetRateStatsFlags(fs) if err != nil { return txf, nil, fmt.Errorf("failed to parse asset rates stats : %w", err) } - assetID, err := strconv.ParseUint(assetRatesStatsInput.AssetID, 10, 64) + assetID, err := strconv.ParseUint(assetRatesParamsInput.AssetID, 10, 64) if err != nil { return txf, nil, err } - uOptimal := assetRatesStatsInput.UOptimal + uOptimal := assetRatesParamsInput.UOptimal - base := assetRatesStatsInput.Base + base := assetRatesParamsInput.Base - slope1 := assetRatesStatsInput.Slope1 + slope1 := assetRatesParamsInput.Slope1 - slope2 := assetRatesStatsInput.Slope2 + slope2 := assetRatesParamsInput.Slope2 - enableStableBorrow, err := strconv.ParseUint(assetRatesStatsInput.EnableStableBorrow, 10, 64) + enableStableBorrow, err := strconv.ParseUint(assetRatesParamsInput.EnableStableBorrow, 10, 64) if err != nil { return txf, nil, err } - stableBase := assetRatesStatsInput.StableBase + stableBase := assetRatesParamsInput.StableBase - stableSlope1 := assetRatesStatsInput.StableSlope1 + stableSlope1 := assetRatesParamsInput.StableSlope1 - stableSlope2 := assetRatesStatsInput.StableSlope2 + stableSlope2 := assetRatesParamsInput.StableSlope2 - ltv := assetRatesStatsInput.LTV + ltv := assetRatesParamsInput.LTV - liquidationThreshold := assetRatesStatsInput.LiquidationThreshold + liquidationThreshold := assetRatesParamsInput.LiquidationThreshold - liquidationPenalty := assetRatesStatsInput.LiquidationPenalty + liquidationPenalty := assetRatesParamsInput.LiquidationPenalty - liquidationBonus := assetRatesStatsInput.LiquidationPenalty + liquidationBonus := assetRatesParamsInput.LiquidationBonus - reserveFactor := assetRatesStatsInput.ReserveFactor + reserveFactor := assetRatesParamsInput.ReserveFactor - cAssetID, err := strconv.ParseUint(assetRatesStatsInput.CAssetID, 10, 64) + cAssetID, err := strconv.ParseUint(assetRatesParamsInput.CAssetID, 10, 64) if err != nil { return txf, nil, err } @@ -787,7 +859,7 @@ func NewCreateAssetRatesStats(clientCtx client.Context, txf tx.Factory, fs *flag newLiquidationBonus, _ := sdk.NewDecFromStr(liquidationBonus) newReserveFactor, _ := sdk.NewDecFromStr(reserveFactor) - assetRatesStats := types.AssetRatesStats{ + assetRatesParams := types.AssetRatesParams{ AssetID: assetID, UOptimal: newUOptimal, Base: newBase, @@ -807,12 +879,12 @@ func NewCreateAssetRatesStats(clientCtx client.Context, txf tx.Factory, fs *flag from := clientCtx.GetFromAddress() - deposit, err := sdk.ParseCoinsNormalized(assetRatesStatsInput.Deposit) + deposit, err := sdk.ParseCoinsNormalized(assetRatesParamsInput.Deposit) if err != nil { return txf, nil, err } - content := types.NewAddAssetRatesStats(assetRatesStatsInput.Title, assetRatesStatsInput.Description, assetRatesStats) + content := types.NewAddassetRatesParams(assetRatesParamsInput.Title, assetRatesParamsInput.Description, assetRatesParams) msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) if err != nil { diff --git a/x/lend/client/proposal_handler.go b/x/lend/client/proposal_handler.go index 2d350914a..6337d2475 100644 --- a/x/lend/client/proposal_handler.go +++ b/x/lend/client/proposal_handler.go @@ -8,9 +8,10 @@ import ( ) var ( - AddLendPairsHandler = govclient.NewProposalHandler(cli.CmdAddNewLendPairsProposal, rest.AddNewPairsProposalRESTHandler) - AddPoolHandler = govclient.NewProposalHandler(cli.CmdAddPoolProposal, rest.AddPoolProposalRESTHandler) - AddAssetToPairHandler = govclient.NewProposalHandler(cli.CmdAddAssetToPairProposal, rest.AddAssetToPairProposalRESTHandler) - AddAssetRatesStatsHandler = govclient.NewProposalHandler(cli.CmdAddNewAssetRatesStatsProposal, rest.AddWNewAssetRatesStatsProposalRESTHandler) - AddAuctionParamsHandler = govclient.NewProposalHandler(cli.CmdAddNewAuctionParamsProposal, rest.AddNewAuctionParamsProposalRESTHandler) + 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) + AddAuctionParamsHandler = govclient.NewProposalHandler(cli.CmdAddNewAuctionParamsProposal, rest.AddNewAuctionParamsProposalRESTHandler) ) diff --git a/x/lend/client/rest/tx.go b/x/lend/client/rest/tx.go index 939857e3b..f7d6a430c 100644 --- a/x/lend/client/rest/tx.go +++ b/x/lend/client/rest/tx.go @@ -20,12 +20,12 @@ type AddNewAssetsRequest struct { } type ( - AddNewPairsRequest struct{} - UpdateNewPairRequest struct{} - AddPoolRequest struct{} - AddAssetToPairRequest struct{} - AddAssetRatesStatsRequest struct{} - AddAuctionParamsRequest struct{} + AddNewPairsRequest struct{} + UpdateNewPairRequest struct{} + AddPoolRequest struct{} + AddAssetToPairRequest struct{} + AddAssetRatesParamsRequest struct{} + AddAuctionParamsRequest struct{} ) func AddNewPairsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { @@ -35,9 +35,9 @@ func AddNewPairsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRE } } -func UpdateNewPairsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { +func UpdatePairProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "update-whitelisted-assets", + SubRoute: "update-new-pair", Handler: UpdateNewPairsRESTHandler(clientCtx), } } @@ -51,15 +51,15 @@ func AddPoolProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHa func AddAssetToPairProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "add-lend-pools", + SubRoute: "add-asset-to-pair", Handler: AddAssetToPairRESTHandler(clientCtx), } } -func AddWNewAssetRatesStatsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { +func AddNewAssetRatesParamsProposalRESTHandler(clientCtx client.Context) govrest.ProposalRESTHandler { return govrest.ProposalRESTHandler{ - SubRoute: "add-asset-rates-stats", - Handler: AddAssetRatesStatsRESTHandler(clientCtx), + SubRoute: "add-asset-rates-params", + Handler: AddAssetRatesParamsRESTHandler(clientCtx), } } @@ -110,9 +110,9 @@ func AddAssetToPairRESTHandler(clientCtx client.Context) http.HandlerFunc { } } -func AddAssetRatesStatsRESTHandler(clientCtx client.Context) http.HandlerFunc { +func AddAssetRatesParamsRESTHandler(clientCtx client.Context) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - var req AddAssetRatesStatsRequest + var req AddAssetRatesParamsRequest if !rest.ReadRESTReq(w, r, clientCtx.LegacyAmino, &req) { return diff --git a/x/lend/expected/keeper.go b/x/lend/expected/keeper.go index ce48820bd..de4bf5db3 100644 --- a/x/lend/expected/keeper.go +++ b/x/lend/expected/keeper.go @@ -29,6 +29,7 @@ type AccountKeeper interface { type MarketKeeper interface { GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) + CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) } type BandOracleKeeper interface { diff --git a/x/lend/genesis.go b/x/lend/genesis.go index c2e27b87a..5f9fa12ed 100644 --- a/x/lend/genesis.go +++ b/x/lend/genesis.go @@ -8,103 +8,104 @@ import ( ) func InitGenesis(ctx sdk.Context, k keeper.Keeper, state *types.GenesisState) { - k.SetParams(ctx, state.Params) + // k.SetParams(ctx, state.Params) - for _, item := range state.BorrowAsset { - k.SetBorrow(ctx, item) - } + // for _, item := range state.BorrowAsset { + // k.SetBorrow(ctx, item) + // } - for _, item := range state.UserBorrowIdMapping { - k.SetUserBorrows(ctx, item) - } + // for _, item := range state.UserBorrowIdMapping { + // k.SetUserBorrows(ctx, item) + // } - for _, item := range state.BorrowIdByOwnerAndPoolMapping { - k.SetBorrowIDByOwnerAndPool(ctx, item) - } + // for _, item := range state.BorrowIdByOwnerAndPoolMapping { + // k.SetBorrowIDByOwnerAndPool(ctx, item) + // } - k.SetBorrows(ctx, state.BorrowMapping) + // k.SetBorrows(ctx, state.BorrowMapping) - for _, item := range state.LendAsset { - k.SetLend(ctx, item) - } + // for _, item := range state.LendAsset { + // k.SetLend(ctx, item) + // } - for _, item := range state.Pool { - k.SetPool(ctx, item) - } + // for _, item := range state.Pool { + // k.SetPool(ctx, item) + // } - for _, item := range state.AssetToPairMapping { - k.SetAssetToPair(ctx, item) - } + // for _, item := range state.AssetToPairMapping { + // k.SetAssetToPair(ctx, item) + // } - for _, item := range state.UserLendIdMapping { - k.SetUserLends(ctx, item) - } + // for _, item := range state.UserLendIdMapping { + // k.SetUserLends(ctx, item) + // } - for _, item := range state.LendIdByOwnerAndPoolMapping { - k.SetLendIDByOwnerAndPool(ctx, item) - } + // for _, item := range state.LendIdByOwnerAndPoolMapping { + // k.SetLendIDByOwnerAndPool(ctx, item) + // } - for _, item := range state.LendIdToBorrowIdMapping { - k.SetLendIDToBorrowIDMapping(ctx, item) - } + // for _, item := range state.LendIdToBorrowIdMapping { + // k.SetLendIDToBorrowIDMapping(ctx, item) + // } - for _, item := range state.AssetStats { - k.SetAssetStatsByPoolIDAndAssetID(ctx, item) - } + // for _, item := range state.AssetStats { + // k.SetAssetStatsByPoolIDAndAssetID(ctx, item) + // } - k.SetLends(ctx, state.LendMapping) + // k.SetLends(ctx, state.LendMapping) - k.SetUserDepositStats(ctx, state.UserDepositStats) + // k.SetUserDepositStats(ctx, state.UserDepositStats) - k.SetReserveDepositStats(ctx, state.ReserveDepositStats) + // k.SetReserveDepositStats(ctx, state.ReserveDepositStats) - k.SetBuyBackDepositStats(ctx, state.BuyBackDepositStats) + // k.SetBuyBackDepositStats(ctx, state.BuyBackDepositStats) - k.SetBorrowStats(ctx, state.BorrowDepositStats) + // k.SetBorrowStats(ctx, state.BorrowDepositStats) - for _, item := range state.Extended_Pair { - k.SetLendPair(ctx, item) - } + // for _, item := range state.Extended_Pair { + // k.SetLendPair(ctx, item) + // } - for _, item := range state.AssetRatesStats { - k.SetAssetRatesStats(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 - } - } + // for _, item := range state.AuctionParams { + // err := k.AddAuctionParamsData(ctx, item) + // if err != nil { + // return + // } + // } } 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), - ) + // 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 } diff --git a/x/lend/handler.go b/x/lend/handler.go index cdcc3309b..b3a028b54 100644 --- a/x/lend/handler.go +++ b/x/lend/handler.go @@ -85,12 +85,14 @@ 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: return handleAddAssetToPairProposal(ctx, k, c) - case *types.AddAssetRatesStats: - return handleAddAssetRatesStatsProposal(ctx, k, c) + case *types.AddAssetRatesParams: + return handleAddAssetRatesParamsProposal(ctx, k, c) case *types.AddAuctionParamsProposal: return HandleAddAuctionParamsProposal(ctx, k, c) @@ -104,6 +106,10 @@ 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) } @@ -112,8 +118,8 @@ func handleAddAssetToPairProposal(ctx sdk.Context, k keeper.Keeper, p *types.Add return k.HandleAddAssetToPairRecords(ctx, p) } -func handleAddAssetRatesStatsProposal(ctx sdk.Context, k keeper.Keeper, p *types.AddAssetRatesStats) error { - return k.HandleAddAssetRatesStatsRecords(ctx, p) +func handleAddAssetRatesParamsProposal(ctx sdk.Context, k keeper.Keeper, p *types.AddAssetRatesParams) error { + return k.HandleAddAssetRatesParamsRecords(ctx, p) } func HandleAddAuctionParamsProposal(ctx sdk.Context, k keeper.Keeper, p *types.AddAuctionParamsProposal) error { diff --git a/x/lend/keeper/alias.go b/x/lend/keeper/alias.go index efd509d96..ab2a829b5 100644 --- a/x/lend/keeper/alias.go +++ b/x/lend/keeper/alias.go @@ -74,3 +74,7 @@ func (k Keeper) GetApp(ctx sdk.Context, id uint64) (assettypes.AppData, bool) { 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.Int, err error) { + return k.market.CalcAssetPrice(ctx, id, amt) +} diff --git a/x/lend/keeper/borrow.go b/x/lend/keeper/borrow.go index 7a2e332c5..b9a778677 100644 --- a/x/lend/keeper/borrow.go +++ b/x/lend/keeper/borrow.go @@ -7,10 +7,10 @@ import ( "github.com/comdex-official/comdex/x/lend/types" ) -func (k Keeper) SetUserBorrowIDHistory(ctx sdk.Context, ID uint64) { +func (k Keeper) SetUserBorrowIDCounter(ctx sdk.Context, ID uint64) { var ( store = k.Store(ctx) - key = types.BorrowHistoryIDPrefix + key = types.BorrowCounterIDPrefix value = k.cdc.MustMarshal( &protobuftypes.UInt64Value{ Value: ID, @@ -20,10 +20,10 @@ func (k Keeper) SetUserBorrowIDHistory(ctx sdk.Context, ID uint64) { store.Set(key, value) } -func (k Keeper) GetUserBorrowIDHistory(ctx sdk.Context) uint64 { +func (k Keeper) GetUserBorrowIDCounter(ctx sdk.Context) uint64 { var ( store = k.Store(ctx) - key = types.BorrowHistoryIDPrefix + key = types.BorrowCounterIDPrefix value = store.Get(key) ) @@ -92,295 +92,25 @@ func (k Keeper) DeleteBorrow(ctx sdk.Context, ID uint64) { store.Delete(key) } -func (k Keeper) SetBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID, ID uint64) { - var ( - store = k.Store(ctx) - key = types.BorrowForAddressByPair(address, pairID) - value = k.cdc.MustMarshal( - &protobuftypes.UInt64Value{ - Value: ID, - }, - ) - ) - - store.Set(key, value) -} - -func (k Keeper) HasBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) bool { - var ( - store = k.Store(ctx) - key = types.BorrowForAddressByPair(address, pairID) - ) - - return store.Has(key) -} - -func (k Keeper) DeleteBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) { - var ( - store = k.Store(ctx) - key = types.BorrowForAddressByPair(address, pairID) - ) - - store.Delete(key) -} - -func (k Keeper) UpdateUserBorrowIDMapping( - ctx sdk.Context, - lendOwner string, - borrowID uint64, - isInsert bool, -) error { - userBorrows, found := k.GetUserBorrows(ctx, lendOwner) - - if !found && isInsert { - userBorrows = types.UserBorrowIdMapping{ - Owner: lendOwner, - BorrowIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs, borrowID) - } else { - for index, id := range userBorrows.BorrowIDs { - if id == borrowID { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs[:index], userBorrows.BorrowIDs[index+1:]...) - break - } - } - } - - k.SetUserBorrows(ctx, userBorrows) - return nil -} - -func (k Keeper) GetUserBorrows(ctx sdk.Context, address string) (userBorrows types.UserBorrowIdMapping, found bool) { - var ( - store = k.Store(ctx) - key = types.UserBorrowsForAddressKey(address) - value = store.Get(key) - ) - if value == nil { - return userBorrows, false - } - k.cdc.MustUnmarshal(value, &userBorrows) - - return userBorrows, true -} - -func (k Keeper) GetAllUserBorrows(ctx sdk.Context) (userBorrowIDMapping []types.UserBorrowIdMapping) { - var ( - store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.UserBorrowsForAddressKeyPrefix) - ) - - defer func(iter sdk.Iterator) { - err := iter.Close() - if err != nil { - return - } - }(iter) - - for ; iter.Valid(); iter.Next() { - var asset types.UserBorrowIdMapping - k.cdc.MustUnmarshal(iter.Value(), &asset) - userBorrowIDMapping = append(userBorrowIDMapping, asset) - } - return userBorrowIDMapping -} - -func (k Keeper) UserBorrows(ctx sdk.Context, address string) (userBorrows []types.BorrowAsset, found bool) { - userBorrowID, _ := k.GetUserBorrows(ctx, address) - for _, v := range userBorrowID.BorrowIDs { - userBorrow, _ := k.GetBorrow(ctx, v) - userBorrows = append(userBorrows, userBorrow) - } - return userBorrows, true -} - -func (k Keeper) SetUserBorrows(ctx sdk.Context, userBorrows types.UserBorrowIdMapping) { - var ( - store = k.Store(ctx) - key = types.UserBorrowsForAddressKey(userBorrows.Owner) - value = k.cdc.MustMarshal(&userBorrows) - ) - store.Set(key, value) -} - -func (k Keeper) UpdateBorrowIDByOwnerAndPoolMapping( - ctx sdk.Context, - borrowOwner string, - borrowID uint64, - poolID uint64, - isInsert bool, -) error { - userBorrows, found := k.GetBorrowIDByOwnerAndPool(ctx, borrowOwner, poolID) - - if !found && isInsert { - userBorrows = types.BorrowIdByOwnerAndPoolMapping{ - Owner: borrowOwner, - PoolID: poolID, - BorrowIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs, borrowID) - } else { - for index, id := range userBorrows.BorrowIDs { - if id == borrowID { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs[:index], userBorrows.BorrowIDs[index+1:]...) - break - } - } - } - - k.SetBorrowIDByOwnerAndPool(ctx, userBorrows) - return nil -} - -func (k Keeper) GetBorrowIDByOwnerAndPool(ctx sdk.Context, address string, poolID uint64) (userBorrows types.BorrowIdByOwnerAndPoolMapping, found bool) { - var ( - store = k.Store(ctx) - key = types.BorrowByUserAndPoolKey(address, poolID) - value = store.Get(key) - ) - if value == nil { - return userBorrows, false - } - k.cdc.MustUnmarshal(value, &userBorrows) - - return userBorrows, true -} - -func (k Keeper) GetAllBorrowIDByOwnerAndPool(ctx sdk.Context) (borrowIDByOwnerAndPoolMapping []types.BorrowIdByOwnerAndPoolMapping) { - var ( - store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.BorrowByUserAndPoolPrefix) - ) - - defer func(iter sdk.Iterator) { - err := iter.Close() - if err != nil { - return - } - }(iter) - - for ; iter.Valid(); iter.Next() { - var asset types.BorrowIdByOwnerAndPoolMapping - k.cdc.MustUnmarshal(iter.Value(), &asset) - borrowIDByOwnerAndPoolMapping = append(borrowIDByOwnerAndPoolMapping, asset) - } - return borrowIDByOwnerAndPoolMapping -} - -func (k Keeper) BorrowIDByOwnerAndPool(ctx sdk.Context, address string, poolID uint64) (userBorrows []types.BorrowAsset, found bool) { - userLendID, _ := k.GetBorrowIDByOwnerAndPool(ctx, address, poolID) - for _, v := range userLendID.BorrowIDs { - userBorrow, _ := k.GetBorrow(ctx, v) - userBorrows = append(userBorrows, userBorrow) - } - return userBorrows, true -} - -func (k Keeper) SetBorrowIDByOwnerAndPool(ctx sdk.Context, userBorrows types.BorrowIdByOwnerAndPoolMapping) { - var ( - store = k.Store(ctx) - key = types.BorrowByUserAndPoolKey(userBorrows.Owner, userBorrows.PoolID) - value = k.cdc.MustMarshal(&userBorrows) - ) - store.Set(key, value) -} - -func (k Keeper) UpdateBorrowIdsMapping( - ctx sdk.Context, - borrowID uint64, - isInsert bool, -) error { - userBorrows, found := k.GetBorrows(ctx) - - if !found && isInsert { - userBorrows = types.BorrowMapping{ - BorrowIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs, borrowID) - } else { - for index, id := range userBorrows.BorrowIDs { - if id == borrowID { - userBorrows.BorrowIDs = append(userBorrows.BorrowIDs[:index], userBorrows.BorrowIDs[index+1:]...) - break +func (k Keeper) HasBorrowForAddressByPair(ctx sdk.Context, address string, pairID uint64) bool { + mappingData := k.GetUserTotalMappingData(ctx, address) + for _, data := range mappingData { + for _, indata := range data.BorrowId { + borrowData, _ := k.GetBorrow(ctx, indata) + if borrowData.PairID == pairID { + return true } } } - - k.SetBorrows(ctx, userBorrows) - return nil + return false } -func (k Keeper) GetBorrows(ctx sdk.Context) (userBorrows types.BorrowMapping, found bool) { - var ( - store = k.Store(ctx) - key = types.BorrowsKey - value = store.Get(key) - ) - if value == nil { - return userBorrows, false +func (k Keeper) GetBorrows(ctx sdk.Context) (borrowIds []uint64, found bool) { + assetStats := k.GetAllAssetStatsByPoolIDAndAssetID(ctx) + for _, data := range assetStats { + borrowIds = append(borrowIds, data.BorrowIds...) } - k.cdc.MustUnmarshal(value, &userBorrows) - - return userBorrows, true -} - -func (k Keeper) SetBorrows(ctx sdk.Context, userBorrows types.BorrowMapping) { - var ( - store = k.Store(ctx) - key = types.BorrowsKey - value = k.cdc.MustMarshal(&userBorrows) - ) - store.Set(key, value) -} - -func (k Keeper) SetReservePoolRecordsForBorrow(ctx sdk.Context, borrow types.ReservePoolRecordsForBorrow) { - var ( - store = k.Store(ctx) - key = types.ReservePoolRecordsForBorrowKey(borrow.ID) - value = k.cdc.MustMarshal(&borrow) - ) - - store.Set(key, value) -} - -func (k Keeper) GetReservePoolRecordsForBorrow(ctx sdk.Context, ID uint64) (borrow types.ReservePoolRecordsForBorrow, found bool) { - var ( - store = k.Store(ctx) - key = types.ReservePoolRecordsForBorrowKey(ID) - value = store.Get(key) - ) - - if value == nil { - return borrow, false - } - - k.cdc.MustUnmarshal(value, &borrow) - return borrow, true -} - -func (k Keeper) DeleteReservePoolRecordsForBorrow(ctx sdk.Context, ID uint64) { - var ( - store = k.Store(ctx) - key = types.ReservePoolRecordsForBorrowKey(ID) - ) - - store.Delete(key) + return borrowIds, true } func (k Keeper) SetBorrowInterestTracker(ctx sdk.Context, interest types.BorrowInterestTracker) { diff --git a/x/lend/keeper/funds.go b/x/lend/keeper/funds.go index 20b28ac0b..0c4f352e3 100644 --- a/x/lend/keeper/funds.go +++ b/x/lend/keeper/funds.go @@ -12,48 +12,22 @@ func (k Keeper) GetReserveFunds(_ sdk.Context, pool types.Pool) sdk.Int { func (k Keeper) UpdateReserveBalances(ctx sdk.Context, assetID uint64, moduleName string, payment sdk.Coin, inc bool) error { newAmount := payment.Amount.Quo(sdk.NewIntFromUint64(types.Uint64Two)) - buyBackStats, _ := k.GetBuyBackDepositStats(ctx) - reserveStats, _ := k.GetReserveDepositStats(ctx) - var reserveBalanceStats []types.BalanceStats + reserve, found := k.GetReserveBuybackAssetData(ctx, assetID) + if !found { + reserve.AssetID = assetID + reserve.BuybackAmount = sdk.ZeroInt() + reserve.ReserveAmount = sdk.ZeroInt() + } - var balanceStats []types.BalanceStats if inc { - for _, v := range buyBackStats.BalanceStats { - if v.AssetID == assetID { - v.Amount = v.Amount.Add(newAmount) - } - balanceStats = append(balanceStats, v) - newDepositStats := types.DepositStats{BalanceStats: balanceStats} - k.SetBuyBackDepositStats(ctx, newDepositStats) - } - for _, v := range reserveStats.BalanceStats { - if v.AssetID == assetID { - v.Amount = v.Amount.Add(newAmount) - } - reserveBalanceStats = append(reserveBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: reserveBalanceStats} - k.SetReserveDepositStats(ctx, newUserDepositStats) - } + reserve.BuybackAmount = reserve.BuybackAmount.Add(newAmount) + reserve.ReserveAmount = reserve.ReserveAmount.Add(newAmount) if err := k.bank.SendCoinsFromModuleToModule(ctx, moduleName, types.ModuleName, sdk.NewCoins(payment)); err != nil { return err } } else { - for _, v := range buyBackStats.BalanceStats { - if v.AssetID == assetID { - v.Amount = v.Amount.Sub(newAmount) - } - balanceStats = append(balanceStats, v) - newDepositStats := types.DepositStats{BalanceStats: balanceStats} - k.SetBuyBackDepositStats(ctx, newDepositStats) - } - for _, v := range reserveStats.BalanceStats { - if v.AssetID == assetID { - v.Amount = v.Amount.Sub(newAmount) - } - reserveBalanceStats = append(reserveBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: reserveBalanceStats} - k.SetReserveDepositStats(ctx, newUserDepositStats) - } + reserve.BuybackAmount = reserve.BuybackAmount.Sub(newAmount) + reserve.ReserveAmount = reserve.ReserveAmount.Sub(newAmount) if err := k.bank.SendCoinsFromModuleToModule(ctx, types.ModuleName, moduleName, sdk.NewCoins(payment)); err != nil { return err } @@ -62,94 +36,29 @@ func (k Keeper) UpdateReserveBalances(ctx sdk.Context, assetID uint64, moduleNam } func (k Keeper) UpdateLendStats(ctx sdk.Context, AssetID, PoolID uint64, amount sdk.Int, inc bool) { - assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, AssetID, PoolID) - depositStats, _ := k.GetDepositStats(ctx) - userDepositStats, _ := k.GetUserDepositStats(ctx) - var balanceStats []types.BalanceStats - var userBalanceStats []types.BalanceStats - + assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) if inc { assetStats.TotalLend = assetStats.TotalLend.Add(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) - - for _, v := range depositStats.BalanceStats { - if v.AssetID == AssetID { - v.Amount = v.Amount.Add(amount) - } - balanceStats = append(balanceStats, v) - newDepositStats := types.DepositStats{BalanceStats: balanceStats} - k.SetDepositStats(ctx, newDepositStats) - } - for _, v := range userDepositStats.BalanceStats { - if v.AssetID == AssetID { - v.Amount = v.Amount.Add(amount) - } - userBalanceStats = append(userBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: userBalanceStats} - k.SetUserDepositStats(ctx, newUserDepositStats) - } } else { assetStats.TotalLend = assetStats.TotalLend.Sub(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) - for _, v := range depositStats.BalanceStats { - if v.AssetID == AssetID { - v.Amount = v.Amount.Sub(amount) - } - balanceStats = append(balanceStats, v) - newDepositStats := types.DepositStats{BalanceStats: balanceStats} - k.SetDepositStats(ctx, newDepositStats) - } - for _, v := range userDepositStats.BalanceStats { - if v.AssetID == AssetID { - v.Amount = v.Amount.Sub(amount) - } - userBalanceStats = append(userBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: userBalanceStats} - k.SetUserDepositStats(ctx, newUserDepositStats) - } } + k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } -func (k Keeper) UpdateBorrowStats(ctx sdk.Context, pair types.Extended_Pair, borrowPos types.BorrowAsset, amount sdk.Int, inc bool) { +func (k Keeper) UpdateBorrowStats(ctx sdk.Context, pair types.Extended_Pair, isStableBorrow bool, amount sdk.Int, inc bool) { + assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) if inc { - borrowStats, _ := k.GetBorrowStats(ctx) - var userBalanceStats []types.BalanceStats - for _, v := range borrowStats.BalanceStats { - if v.AssetID == pair.AssetOut { - v.Amount = v.Amount.Add(amount) - } - userBalanceStats = append(userBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: userBalanceStats} - k.SetBorrowStats(ctx, newUserDepositStats) - } - - assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) - if borrowPos.IsStableBorrow { + if isStableBorrow { assetStats.TotalStableBorrowed = assetStats.TotalStableBorrowed.Add(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } else { assetStats.TotalBorrowed = assetStats.TotalBorrowed.Add(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } } else { - borrowStats, _ := k.GetBorrowStats(ctx) - var userBalanceStats []types.BalanceStats - for _, v := range borrowStats.BalanceStats { - if v.AssetID == pair.AssetOut { - v.Amount = v.Amount.Sub(amount) - } - userBalanceStats = append(userBalanceStats, v) - newUserDepositStats := types.DepositStats{BalanceStats: userBalanceStats} - k.SetBorrowStats(ctx, newUserDepositStats) - } - - assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) - if borrowPos.IsStableBorrow { + if isStableBorrow { assetStats.TotalStableBorrowed = assetStats.TotalStableBorrowed.Sub(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } else { assetStats.TotalBorrowed = assetStats.TotalBorrowed.Sub(amount) - k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } } + k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) } diff --git a/x/lend/keeper/gov.go b/x/lend/keeper/gov.go index 51fa952dd..1ba6443cf 100644 --- a/x/lend/keeper/gov.go +++ b/x/lend/keeper/gov.go @@ -10,6 +10,10 @@ 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) } @@ -18,8 +22,8 @@ func (k Keeper) HandleAddAssetToPairRecords(ctx sdk.Context, p *types.AddAssetTo return k.AddAssetToPair(ctx, p.AssetToPairMapping) } -func (k Keeper) HandleAddAssetRatesStatsRecords(ctx sdk.Context, p *types.AddAssetRatesStats) error { - return k.AddAssetRatesStats(ctx, p.AssetRatesStats) +func (k Keeper) HandleAddAssetRatesParamsRecords(ctx sdk.Context, p *types.AddAssetRatesParams) error { + return k.AddAssetRatesParams(ctx, p.AssetRatesParams) } func (k Keeper) HandleAddAuctionParamsRecords(ctx sdk.Context, p *types.AddAuctionParamsProposal) error { diff --git a/x/lend/keeper/grpc_query.go b/x/lend/keeper/grpc_query.go index 34ad6ba93..3fea63bd3 100644 --- a/x/lend/keeper/grpc_query.go +++ b/x/lend/keeper/grpc_query.go @@ -82,8 +82,9 @@ func (q QueryServer) QueryAllLendByOwner(c context.Context, req *types.QueryAllL return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - ctx = sdk.UnwrapSDKContext(c) - lends []types.LendAsset + ctx = sdk.UnwrapSDKContext(c) + lendIds []uint64 + lends []types.LendAsset ) _, err := sdk.AccAddressFromBech32(req.Owner) @@ -91,11 +92,18 @@ func (q QueryServer) QueryAllLendByOwner(c context.Context, req *types.QueryAllL return nil, status.Errorf(codes.NotFound, "Address is not correct") } - userVaultAssetData, found := q.UserLends(ctx, req.Owner) - if !found { + mappingData := q.GetUserTotalMappingData(ctx, req.Owner) + + for _, data := range mappingData { + lendIds = append(lendIds, data.LendId) + } + for _, lendId := range lendIds { + lend, _ := q.GetLend(ctx, lendId) + lends = append(lends, lend) + } + if len(lendIds) == 0 { return &types.QueryAllLendByOwnerResponse{}, nil } - lends = append(lends, userVaultAssetData...) return &types.QueryAllLendByOwnerResponse{ Lends: lends, @@ -107,8 +115,9 @@ func (q QueryServer) QueryAllLendByOwnerAndPool(c context.Context, req *types.Qu return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - ctx = sdk.UnwrapSDKContext(c) - lends []types.LendAsset + ctx = sdk.UnwrapSDKContext(c) + lendIds []uint64 + lends []types.LendAsset ) _, err := sdk.AccAddressFromBech32(req.Owner) @@ -116,11 +125,19 @@ func (q QueryServer) QueryAllLendByOwnerAndPool(c context.Context, req *types.Qu return nil, status.Errorf(codes.NotFound, "Address is not correct") } - userVaultAssetData, found := q.LendIDByOwnerAndPool(ctx, req.Owner, req.PoolId) - if !found { + mappingData := q.GetUserTotalMappingData(ctx, req.Owner) + for _, data := range mappingData { + if data.PoolId == req.PoolId { + lendIds = append(lendIds, data.LendId) + } + } + for _, lendId := range lendIds { + lend, _ := q.GetLend(ctx, lendId) + lends = append(lends, lend) + } + if len(lendIds) == 0 { return &types.QueryAllLendByOwnerAndPoolResponse{}, nil } - lends = append(lends, userVaultAssetData...) return &types.QueryAllLendByOwnerAndPoolResponse{ Lends: lends, @@ -132,8 +149,9 @@ func (q QueryServer) QueryAllBorrowByOwnerAndPool(c context.Context, req *types. return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - ctx = sdk.UnwrapSDKContext(c) - borrows []types.BorrowAsset + ctx = sdk.UnwrapSDKContext(c) + borrowIds []uint64 + borrows []types.BorrowAsset ) _, err := sdk.AccAddressFromBech32(req.Owner) @@ -141,11 +159,19 @@ func (q QueryServer) QueryAllBorrowByOwnerAndPool(c context.Context, req *types. return nil, status.Errorf(codes.NotFound, "Address is not correct") } - userVaultAssetData, found := q.BorrowIDByOwnerAndPool(ctx, req.Owner, req.PoolId) - if !found { + mappingData := q.GetUserTotalMappingData(ctx, req.Owner) + for _, data := range mappingData { + if data.PoolId == req.PoolId { + borrowIds = append(borrowIds, data.BorrowId...) + } + } + for _, borrowId := range borrowIds { + borrow, _ := q.GetBorrow(ctx, borrowId) + borrows = append(borrows, borrow) + } + if len(borrowIds) == 0 { return &types.QueryAllBorrowByOwnerAndPoolResponse{}, nil } - borrows = append(borrows, userVaultAssetData...) return &types.QueryAllBorrowByOwnerAndPoolResponse{ Borrows: borrows, @@ -369,8 +395,9 @@ func (q QueryServer) QueryAllBorrowByOwner(c context.Context, req *types.QueryAl return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - ctx = sdk.UnwrapSDKContext(c) - borrows []types.BorrowAsset + ctx = sdk.UnwrapSDKContext(c) + borrowIds []uint64 + borrows []types.BorrowAsset ) _, err := sdk.AccAddressFromBech32(req.Owner) @@ -378,32 +405,38 @@ func (q QueryServer) QueryAllBorrowByOwner(c context.Context, req *types.QueryAl return nil, status.Errorf(codes.NotFound, "Address is not correct") } - userVaultAssetData, found := q.UserBorrows(ctx, req.Owner) - if !found { + mappingData := q.GetUserTotalMappingData(ctx, req.Owner) + for _, data := range mappingData { + borrowIds = append(borrowIds, data.BorrowId...) + } + for _, borrowId := range borrowIds { + borrow, _ := q.GetBorrow(ctx, borrowId) + borrows = append(borrows, borrow) + } + if len(borrowIds) == 0 { return &types.QueryAllBorrowByOwnerResponse{}, nil } - borrows = append(borrows, userVaultAssetData...) return &types.QueryAllBorrowByOwnerResponse{ Borrows: borrows, }, nil } -func (q QueryServer) QueryAssetRatesStats(c context.Context, req *types.QueryAssetRatesStatsRequest) (*types.QueryAssetRatesStatsResponse, error) { +func (q QueryServer) QueryAssetRatesParams(c context.Context, req *types.QueryAssetRatesParamsRequest) (*types.QueryAssetRatesParamsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } var ( - items []types.AssetRatesStats + items []types.AssetRatesParams ctx = sdk.UnwrapSDKContext(c) ) pagination, err := query.FilteredPaginate( - prefix.NewStore(q.Store(ctx), types.AssetRatesStatsKeyPrefix), + prefix.NewStore(q.Store(ctx), types.AssetRatesParamsKeyPrefix), req.Pagination, func(_, value []byte, accumulate bool) (bool, error) { - var item types.AssetRatesStats + var item types.AssetRatesParams if err := q.cdc.Unmarshal(value, &item); err != nil { return false, err } @@ -419,30 +452,30 @@ func (q QueryServer) QueryAssetRatesStats(c context.Context, req *types.QueryAss return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAssetRatesStatsResponse{ - AssetRatesStats: items, - Pagination: pagination, + return &types.QueryAssetRatesParamsResponse{ + AssetRatesParams: items, + Pagination: pagination, }, nil } -func (q QueryServer) QueryAssetRatesStat(c context.Context, req *types.QueryAssetRatesStatRequest) (*types.QueryAssetRatesStatResponse, error) { +func (q QueryServer) QueryAssetRatesParam(c context.Context, req *types.QueryAssetRatesParamRequest) (*types.QueryAssetRatesParamResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } ctx := sdk.UnwrapSDKContext(c) - item, found := q.GetAssetRatesStats(ctx, req.Id) + item, found := q.GetAssetRatesParams(ctx, req.Id) if !found { - return &types.QueryAssetRatesStatResponse{}, nil + return &types.QueryAssetRatesParamResponse{}, nil } - return &types.QueryAssetRatesStatResponse{ - AssetRatesStat: item, + return &types.QueryAssetRatesParamResponse{ + AssetRatesparams: item, }, nil } -func (q QueryServer) QueryAssetStats(c context.Context, req *types.QueryAssetStatsRequest) (*types.QueryAssetStatsResponse, error) { +func (q QueryServer) QueryPoolAssetLBMapping(c context.Context, req *types.QueryPoolAssetLBMappingRequest) (*types.QueryPoolAssetLBMappingResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } @@ -450,107 +483,27 @@ func (q QueryServer) QueryAssetStats(c context.Context, req *types.QueryAssetSta assetStatsData, found := q.AssetStatsByPoolIDAndAssetID(ctx, req.AssetId, req.PoolId) if !found { - return &types.QueryAssetStatsResponse{}, nil - } - - return &types.QueryAssetStatsResponse{ - AssetStats: assetStatsData, - }, 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 -} - -func (q QueryServer) QueryDepositStats(c context.Context, req *types.QueryDepositStatsRequest) (*types.QueryDepositStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "request cannot be empty") - } - ctx := sdk.UnwrapSDKContext(c) - - depositStatsData, found := q.GetDepositStats(ctx) - if !found { - return &types.QueryDepositStatsResponse{}, nil - } - - return &types.QueryDepositStatsResponse{ - DepositStats: depositStatsData, - }, nil -} - -func (q QueryServer) QueryUserDepositStats(c context.Context, req *types.QueryUserDepositStatsRequest) (*types.QueryUserDepositStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "request cannot be empty") - } - ctx := sdk.UnwrapSDKContext(c) - - userDepositStatsData, found := q.GetUserDepositStats(ctx) - if !found { - return &types.QueryUserDepositStatsResponse{}, nil - } - - return &types.QueryUserDepositStatsResponse{ - UserDepositStats: userDepositStatsData, - }, nil -} - -func (q QueryServer) QueryReserveDepositStats(c context.Context, req *types.QueryReserveDepositStatsRequest) (*types.QueryReserveDepositStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "request cannot be empty") - } - ctx := sdk.UnwrapSDKContext(c) - - reserveDepositStatsData, found := q.GetReserveDepositStats(ctx) - if !found { - return &types.QueryReserveDepositStatsResponse{}, nil - } - - return &types.QueryReserveDepositStatsResponse{ - ReserveDepositStats: reserveDepositStatsData, - }, nil -} - -func (q QueryServer) QueryBuyBackDepositStats(c context.Context, req *types.QueryBuyBackDepositStatsRequest) (*types.QueryBuyBackDepositStatsResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "request cannot be empty") - } - ctx := sdk.UnwrapSDKContext(c) - - buyBackDepositStatsData, found := q.GetBuyBackDepositStats(ctx) - if !found { - return &types.QueryBuyBackDepositStatsResponse{}, nil + return &types.QueryPoolAssetLBMappingResponse{}, nil } - return &types.QueryBuyBackDepositStatsResponse{ - BuyBackDepositStats: buyBackDepositStatsData, + return &types.QueryPoolAssetLBMappingResponse{ + PoolAssetLBMapping: assetStatsData, }, nil } -func (q QueryServer) QueryBorrowStats(c context.Context, req *types.QueryBorrowStatsRequest) (*types.QueryBorrowStatsResponse, error) { +func (q QueryServer) QueryReserveBuybackAssetData(c context.Context, req *types.QueryReserveBuybackAssetDataRequest) (*types.QueryReserveBuybackAssetDataResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "request cannot be empty") } ctx := sdk.UnwrapSDKContext(c) - borrowStatsData, found := q.GetBorrowStats(ctx) + buyBackDepositStatsData, found := q.GetReserveBuybackAssetData(ctx, req.AssetId) if !found { - return &types.QueryBorrowStatsResponse{}, nil + return &types.QueryReserveBuybackAssetDataResponse{}, nil } - return &types.QueryBorrowStatsResponse{ - BorrowStats: borrowStatsData, + return &types.QueryReserveBuybackAssetDataResponse{ + ReserveBuybackAssetData: buyBackDepositStatsData, }, nil } diff --git a/x/lend/keeper/iter.go b/x/lend/keeper/iter.go index 5269b6cda..fb973cbdc 100644 --- a/x/lend/keeper/iter.go +++ b/x/lend/keeper/iter.go @@ -9,6 +9,7 @@ import ( "github.com/comdex-official/comdex/x/lend/types" ) +// To calculate pending rewards from last interaction func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { lend, _ := k.GetLend(ctx, ID) lendAPR, _ := k.GetLendAPRByAssetIDAndPoolID(ctx, lend.PoolID, lend.AssetID) @@ -30,15 +31,17 @@ func (k Keeper) IterateLends(ctx sdk.Context, ID uint64) (sdk.Dec, error) { lendRewardsTracker.RewardsAccumulated = lendRewardsTracker.RewardsAccumulated.Sub(newRewardDec) } k.SetLendRewardTracker(ctx, lendRewardsTracker) + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, lend.PoolID, lend.AssetID) + if newInterestPerBlock.GT(poolAssetLBMappingData.TotalInterestAccumulated) { + return sdk.Dec{}, types.ErrorInsufficientCTokensForRewards + } if newInterestPerBlock.GT(sdk.ZeroInt()) { - lend.UpdatedAmountIn = lend.UpdatedAmountIn.Add(newInterestPerBlock) lend.AvailableToBorrow = lend.AvailableToBorrow.Add(newInterestPerBlock) - lend.Reward_Accumulated = lend.Reward_Accumulated.Add(newInterestPerBlock) pool, _ := k.GetPool(ctx, lend.PoolID) asset, _ := k.GetAsset(ctx, lend.AssetID) Amount := sdk.NewCoin(asset.Denom, newInterestPerBlock) - assetRatesStat, _ := k.GetAssetRatesStats(ctx, lend.AssetID) + assetRatesStat, _ := k.GetAssetRatesParams(ctx, lend.AssetID) cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, Amount.Amount) @@ -67,46 +70,29 @@ func (k Keeper) IterateBorrow(ctx sdk.Context, ID uint64) (sdk.Dec, sdk.Dec, err if err != nil { return sdk.ZeroDec(), sdk.ZeroDec(), err } - borrowInterestTracker, found := k.GetBorrowInterestTracker(ctx, borrow.ID) - if !found { - borrowInterestTracker = types.BorrowInterestTracker{ - BorrowingId: borrow.ID, - InterestAccumulated: sdk.ZeroDec(), - } - } + if !borrow.IsStableBorrow { - borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Add(interestPerBlock) + borrow.InterestAccumulated = borrow.InterestAccumulated.Add(interestPerBlock) } else { stableInterestPerBlock, err := k.CalculateStableInterest(ctx, borrow.AmountOut.Amount.String(), borrow) if err != nil { return sdk.ZeroDec(), sdk.ZeroDec(), err } - borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Add(stableInterestPerBlock) + borrow.InterestAccumulated = borrow.InterestAccumulated.Add(stableInterestPerBlock) } - newInterestPerBlock := sdk.ZeroInt() - if borrowInterestTracker.InterestAccumulated.GTE(sdk.OneDec()) { - newInterestPerBlock = borrowInterestTracker.InterestAccumulated.TruncateInt() - newRewardDec := sdk.NewDec(newInterestPerBlock.Int64()) - borrowInterestTracker.InterestAccumulated = borrowInterestTracker.InterestAccumulated.Sub(newRewardDec) - } - k.SetBorrowInterestTracker(ctx, borrowInterestTracker) - reservePoolRecords, found := k.GetReservePoolRecordsForBorrow(ctx, borrow.ID) + reservePoolRecords, found := k.GetBorrowInterestTracker(ctx, borrow.ID) if !found { - reservePoolRecords = types.ReservePoolRecordsForBorrow{ - ID: borrow.ID, - InterestAccumulated: sdk.ZeroDec(), + reservePoolRecords = types.BorrowInterestTracker{ + BorrowingId: borrow.ID, + ReservePoolInterest: sdk.ZeroDec(), } } if reservePoolAmountPerBlock.GT(sdk.ZeroDec()) { - reservePoolRecords.InterestAccumulated = reservePoolRecords.InterestAccumulated.Add(reservePoolAmountPerBlock) - } - k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) - if newInterestPerBlock.GT(sdk.ZeroInt()) { - borrow.UpdatedAmountOut = borrow.UpdatedAmountOut.Add(newInterestPerBlock) - borrow.Interest_Accumulated = borrow.Interest_Accumulated.Add(newInterestPerBlock) - k.SetBorrow(ctx, borrow) + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Add(reservePoolAmountPerBlock) } + k.SetBorrowInterestTracker(ctx, reservePoolRecords) + k.SetBorrow(ctx, borrow) return indexGlobalCurrent, reserveGlobalIndex, nil } @@ -193,32 +179,34 @@ func (k Keeper) CalculateBorrowInterest(ctx sdk.Context, amount string, rate, re func (k Keeper) ReBalanceStableRates(ctx sdk.Context) error { borrows, _ := k.GetBorrows(ctx) - for _, v := range borrows.BorrowIDs { + for _, v := range borrows { borrowPos, found := k.GetBorrow(ctx, v) if !found { continue } - 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) + 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) + } } } } diff --git a/x/lend/keeper/keeper.go b/x/lend/keeper/keeper.go index d28dad603..9de57f46d 100644 --- a/x/lend/keeper/keeper.go +++ b/x/lend/keeper/keeper.go @@ -4,6 +4,8 @@ import ( "fmt" "strconv" + liquidationtypes "github.com/comdex-official/comdex/x/liquidation/types" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -15,7 +17,7 @@ import ( esmtypes "github.com/comdex-official/comdex/x/esm/types" "github.com/comdex-official/comdex/x/lend/expected" "github.com/comdex-official/comdex/x/lend/types" - liquidationtypes "github.com/comdex-official/comdex/x/liquidation/types" + // liquidationtypes "github.com/comdex-official/comdex/x/liquidation/types" ) type ( @@ -69,7 +71,7 @@ func (k Keeper) ModuleBalance(ctx sdk.Context, moduleName string, denom string) return k.bank.GetBalance(ctx, authtypes.NewModuleAddress(moduleName), denom).Amount } -func uint64InAssetData(a uint64, list []types.AssetDataPoolMapping) bool { +func uint64InAssetData(a uint64, list []*types.AssetDataPoolMapping) bool { for _, b := range list { if b.AssetID == a { return true @@ -78,6 +80,31 @@ func uint64InAssetData(a uint64, list []types.AssetDataPoolMapping) bool { return false } +func (k Keeper) CheckSupplyCap(ctx sdk.Context, assetID, poolID uint64, amt sdk.Int) (bool, error) { + var supplyCap uint64 + assetStats, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) + + currentSupply, err := k.CalcAssetPrice(ctx, assetID, assetStats.TotalLend.Add(amt)) + if err != nil { + return false, err + } + pool, found := k.GetPool(ctx, poolID) + if !found { + return false, types.ErrPoolNotFound + } + + for _, v := range pool.AssetData { + if assetID == v.AssetID { + supplyCap = v.SupplyCap + } + } + if currentSupply.Uint64() <= supplyCap { + return true, nil + } else { + return false, nil + } +} + func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Amount sdk.Coin, PoolID, AppID uint64) error { killSwitchParams, _ := k.GetKillSwitchData(ctx, AppID) if killSwitchParams.BreakerEnable { @@ -108,40 +135,48 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am return sdkerrors.Wrap(types.ErrInvalidAssetIDForPool, strconv.FormatUint(AssetID, 10)) } + found, err := k.CheckSupplyCap(ctx, AssetID, PoolID, Amount.Amount) + if err != nil { + return err + } + if !found { + return types.ErrorSupplyCapExceeds + } + addr, _ := sdk.AccAddressFromBech32(lenderAddr) - if k.HasLendForAddressByAsset(ctx, addr, AssetID, PoolID) { + if k.HasLendForAddressByAsset(ctx, lenderAddr, AssetID, PoolID) { return types.ErrorDuplicateLend } loanTokens := sdk.NewCoins(Amount) - assetRatesStat, found := k.GetAssetRatesStats(ctx, AssetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(AssetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10)) } cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, Amount.Amount) - if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, loanTokens); err != nil { + if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, loanTokens); err != nil { return err } // mint c/Token and set new total cToken supply cTokens := sdk.NewCoins(cToken) - if err := k.bank.MintCoins(ctx, pool.ModuleName, cTokens); err != nil { + if err = k.bank.MintCoins(ctx, pool.ModuleName, cTokens); err != nil { return err } - err := k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, cTokens) + err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, cTokens) if err != nil { return err } - lendID := k.GetUserLendIDHistory(ctx) + lendID := k.GetUserLendIDCounter(ctx) var globalIndex sdk.Dec - assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, AssetID, PoolID) + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) if assetStats.LendApr.IsZero() { globalIndex = sdk.OneDec() } else { @@ -155,30 +190,26 @@ func (k Keeper) LendAsset(ctx sdk.Context, lenderAddr string, AssetID uint64, Am Owner: lenderAddr, AmountIn: Amount, LendingTime: ctx.BlockTime(), - UpdatedAmountIn: Amount.Amount, AvailableToBorrow: Amount.Amount, - Reward_Accumulated: sdk.ZeroInt(), AppID: AppID, GlobalIndex: globalIndex, LastInteractionTime: ctx.BlockTime(), CPoolName: pool.CPoolName, } k.UpdateLendStats(ctx, AssetID, PoolID, Amount.Amount, true) - k.SetUserLendIDHistory(ctx, lendPos.ID) + k.SetUserLendIDCounter(ctx, lendPos.ID) k.SetLend(ctx, lendPos) - k.SetLendForAddressByAsset(ctx, addr, lendPos.AssetID, lendPos.ID, lendPos.PoolID) - err = k.UpdateUserLendIDMapping(ctx, lenderAddr, lendPos.ID, true) - if err != nil { - return err - } - err = k.UpdateLendIDByOwnerAndPoolMapping(ctx, lenderAddr, lendPos.ID, lendPos.PoolID, true) - if err != nil { - return err - } - err = k.UpdateLendIDsMapping(ctx, lendPos.ID, true) - if err != nil { - return err - } + + var mappingData types.UserAssetLendBorrowMapping + mappingData.Owner = lendPos.Owner + mappingData.LendId = lendPos.ID + mappingData.PoolId = PoolID + mappingData.BorrowId = nil + k.SetUserLendBorrowMapping(ctx, mappingData) + + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) + poolAssetLBMappingData.LendIds = append(poolAssetLBMappingData.LendIds, lendPos.ID) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) return nil } @@ -192,6 +223,14 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd if !found { return types.ErrLendNotFound } + + if withdrawal.Amount.Equal(lendPos.AvailableToBorrow) { + err = k.CloseLend(ctx, addr, lendID) + if err != nil { + return err + } + return nil + } killSwitchParams, _ := k.GetKillSwitchData(ctx, lendPos.AppID) if killSwitchParams.BreakerEnable { return esmtypes.ErrCircuitBreakerEnabled @@ -208,7 +247,7 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd pool, _ := k.GetPool(ctx, lendPos.PoolID) if lendPos.Owner != addr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } if withdrawal.Amount.GT(lendPos.AvailableToBorrow) { @@ -222,17 +261,13 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd reservedAmount := k.GetReserveFunds(ctx, pool) availableAmount := k.ModuleBalance(ctx, pool.ModuleName, withdrawal.Denom) - if withdrawal.Amount.GT(lendPos.AmountIn.Amount) { - return sdkerrors.Wrap(types.ErrWithdrawalAmountExceeds, withdrawal.String()) - } - if withdrawal.Amount.GT(availableAmount.Sub(reservedAmount)) { return sdkerrors.Wrap(types.ErrLendingPoolInsufficient, withdrawal.String()) } - assetRatesStat, found := k.GetAssetRatesStats(ctx, lendPos.AssetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, lendPos.AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, withdrawal.Amount) @@ -242,56 +277,41 @@ func (k Keeper) WithdrawAsset(ctx sdk.Context, addr string, lendID uint64, withd if err != nil { return err } + if withdrawal.Amount.LT(lendPos.AmountIn.Amount) { + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + return err + } + // burn c/Token + err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) + if err != nil { + return err + } - if withdrawal.Amount.LT(lendPos.UpdatedAmountIn) { - if withdrawal.Amount.GTE(lendPos.AmountIn.Amount) { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { - return err - } - - // burn c/Token - err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) - if err != nil { - return err - } - - if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { - return err - } - subtractionFactor := lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) - subtractionAmount := lendPos.AmountIn.Amount.Sub(subtractionFactor) - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, subtractionAmount, false) - lendPos.Reward_Accumulated = sdk.ZeroInt() - lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(subtractionAmount) - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) - lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) - k.SetLend(ctx, lendPos) - } else { - if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { - return err - } - // burn c/Token - err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) - if err != nil { - return err - } - - if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { - return err - } - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, withdrawal.Amount, false) - if withdrawal.Amount.GTE(lendPos.Reward_Accumulated) { - lendPos.Reward_Accumulated = sdk.ZeroInt() - } else { - lendPos.Reward_Accumulated = lendPos.Reward_Accumulated.Sub(withdrawal.Amount) - } - lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(withdrawal.Amount) - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(withdrawal.Amount) - lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) - k.SetLend(ctx, lendPos) + if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { + return err } + k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, withdrawal.Amount, false) + lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(withdrawal.Amount) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) + k.SetLend(ctx, lendPos) } else { - return types.ErrWithdrawAmountLimitExceeds + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { + return err + } + // burn c/Token + err = k.bank.BurnCoins(ctx, pool.ModuleName, cTokens) + if err != nil { + return err + } + + if err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, lenderAddr, tokens); err != nil { + return err + } + + k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, withdrawal.Amount, false) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(withdrawal.Amount) + lendPos.AmountIn.Amount = sdk.ZeroInt() + k.SetLend(ctx, lendPos) } return nil } @@ -321,13 +341,21 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi getAsset, _ := k.GetAsset(ctx, lendPos.AssetID) pool, _ := k.GetPool(ctx, lendPos.PoolID) + found, err = k.CheckSupplyCap(ctx, lendPos.AssetID, lendPos.PoolID, deposit.Amount) + if err != nil { + return err + } + if !found { + return types.ErrorSupplyCapExceeds + } + if deposit.Denom != getAsset.Denom { return sdkerrors.Wrap(types.ErrBadOfferCoinAmount, deposit.Denom) } - assetRatesStat, found := k.GetAssetRatesStats(ctx, lendPos.AssetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, lendPos.AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, deposit.Amount) @@ -348,7 +376,6 @@ func (k Keeper) DepositAsset(ctx sdk.Context, addr string, lendID uint64, deposi } lendPos.AmountIn = lendPos.AmountIn.Add(deposit) - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Add(deposit.Amount) lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Add(deposit.Amount) k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, deposit.Amount, true) @@ -382,27 +409,27 @@ func (k Keeper) CloseLend(ctx sdk.Context, addr string, lendID uint64) error { pool, _ := k.GetPool(ctx, lendPos.PoolID) if lendPos.Owner != addr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } - lendIDToBorrowIDMapping, _ := k.GetLendIDToBorrowIDMapping(ctx, lendID) - if lendIDToBorrowIDMapping.BorrowingID != nil { + lendIDToBorrowIDMapping, _ := k.GetUserLendBorrowMapping(ctx, lendPos.Owner, lendID) + if lendIDToBorrowIDMapping.BorrowId != nil { return types.ErrBorrowingPositionOpen } reservedAmount := k.GetReserveFunds(ctx, pool) availableAmount := k.ModuleBalance(ctx, pool.ModuleName, lendPos.AmountIn.Denom) - if lendPos.UpdatedAmountIn.GT(availableAmount.Sub(reservedAmount)) { - return sdkerrors.Wrap(types.ErrLendingPoolInsufficient, lendPos.UpdatedAmountIn.String()) + if lendPos.AvailableToBorrow.GT(availableAmount.Sub(reservedAmount)) { + return sdkerrors.Wrap(types.ErrLendingPoolInsufficient, lendPos.AvailableToBorrow.String()) } - tokens := sdk.NewCoins(sdk.NewCoin(lendPos.AmountIn.Denom, lendPos.UpdatedAmountIn)) - assetRatesStat, found := k.GetAssetRatesStats(ctx, lendPos.AssetID) + tokens := sdk.NewCoins(sdk.NewCoin(lendPos.AmountIn.Denom, lendPos.AvailableToBorrow)) + assetRatesStat, found := k.GetAssetRatesParams(ctx, lendPos.AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) - cToken := sdk.NewCoin(cAsset.Denom, lendPos.UpdatedAmountIn) + cToken := sdk.NewCoin(cAsset.Denom, lendPos.AvailableToBorrow) if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, pool.ModuleName, cToken); err != nil { return err @@ -418,21 +445,11 @@ func (k Keeper) CloseLend(ctx sdk.Context, addr string, lendID uint64) error { return err } - k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, lendPos.AmountIn.Amount, false) - k.DeleteLendForAddressByAsset(ctx, lenderAddr, lendPos.AssetID, lendPos.PoolID) + k.UpdateLendStats(ctx, lendPos.AssetID, lendPos.PoolID, lendPos.AvailableToBorrow, false) + k.DeleteLendForAddressByAsset(ctx, lenderAddr.String(), lendPos.ID) + + k.DeleteIDFromAssetStatsMapping(ctx, lendPos.PoolID, lendPos.AssetID, lendID, true) - err = k.UpdateUserLendIDMapping(ctx, addr, lendPos.ID, false) - if err != nil { - return err - } - err = k.UpdateLendIDByOwnerAndPoolMapping(ctx, addr, lendPos.ID, lendPos.PoolID, false) - if err != nil { - return err - } - err = k.UpdateLendIDsMapping(ctx, lendPos.ID, false) - if err != nil { - return err - } k.DeleteLend(ctx, lendPos.ID) return nil @@ -462,7 +479,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, } if lendPos.Owner != addr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } pair, found := k.GetLendPair(ctx, pairID) @@ -483,7 +500,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, if !found { return assettypes.ErrorAssetDoesNotExist } - assetInRatesStats, found := k.GetAssetRatesStats(ctx, pair.AssetIn) + assetInRatesStats, found := k.GetAssetRatesParams(ctx, pair.AssetIn) if !found { return types.ErrAssetStatsNotFound } @@ -496,7 +513,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return types.ErrBadOfferCoinType } - if k.HasBorrowForAddressByPair(ctx, lenderAddr, pairID) { + if k.HasBorrowForAddressByPair(ctx, addr, pairID) { return types.ErrorDuplicateBorrow } @@ -504,6 +521,10 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return types.ErrAvailableToBorrowInsufficient } + if loan.Denom != assetOut.Denom { + return types.ErrInvalidAsset + } + AssetInPool, found := k.GetPool(ctx, lendPos.PoolID) if !found { return types.ErrPoolNotFound @@ -517,11 +538,11 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return sdkerrors.Wrap(types.ErrStableBorrowDisabled, loan.String()) } - err := k.VerifyCollaterlizationRatio(ctx, AmountIn.Amount, assetIn, loan.Amount, assetOut, assetInRatesStats.Ltv) + err := k.VerifyCollateralizationRatio(ctx, AmountIn.Amount, assetIn, loan.Amount, assetOut, assetInRatesStats.Ltv) if err != nil { return err } - borrowID := k.GetUserBorrowIDHistory(ctx) + borrowID := k.GetUserBorrowIDCounter(ctx) reservedAmount := k.GetReserveFunds(ctx, AssetOutPool) availableAmount := k.ModuleBalance(ctx, AssetOutPool.ModuleName, loan.Denom) @@ -529,14 +550,19 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, if loan.Amount.GT(availableAmount.Sub(reservedAmount)) { return sdkerrors.Wrap(types.ErrBorrowingPoolInsufficient, loan.String()) } - assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) reserveGlobalIndex, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) if err != nil { reserveGlobalIndex = sdk.OneDec() } globalIndex := assetStats.BorrowApr + AmountOut := loan + // There are 3 possible cases of borrowing + // a. When the borrow is done from the same pool in which the user has lent Asset + // b. When the borrow is from different pool using First Transit Asset + // c. When the borrow is from different pool using Second Transit Asset + // else the borrowing pool is not having sufficient tokens to loan if !pair.IsInterPool { - AmountOut := loan // take c/Tokens from the user if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { return err @@ -557,89 +583,83 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, } borrowPos := types.BorrowAsset{ - ID: borrowID + 1, - LendingID: lendID, - PairID: pairID, - AmountIn: AmountIn, - AmountOut: AmountOut, - BridgedAssetAmount: sdk.NewCoin(loan.Denom, sdk.NewInt(0)), - IsStableBorrow: IsStableBorrow, - StableBorrowRate: StableBorrowRate, - BorrowingTime: ctx.BlockTime(), - UpdatedAmountOut: AmountOut.Amount, - Interest_Accumulated: sdk.ZeroInt(), - GlobalIndex: globalIndex, - ReserveGlobalIndex: reserveGlobalIndex, - LastInteractionTime: ctx.BlockTime(), - CPoolName: AssetOutPool.CPoolName, - } - k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) - err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, true) - if err != nil { - return err + ID: borrowID + 1, + LendingID: lendID, + PairID: pairID, + AmountIn: AmountIn, + AmountOut: AmountOut, + BridgedAssetAmount: sdk.NewCoin(loan.Denom, sdk.NewInt(0)), + IsStableBorrow: IsStableBorrow, + StableBorrowRate: StableBorrowRate, + BorrowingTime: ctx.BlockTime(), + InterestAccumulated: sdk.ZeroDec(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), + CPoolName: AssetOutPool.CPoolName, + 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) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) k.SetLend(ctx, lendPos) - k.SetUserBorrowIDHistory(ctx, borrowPos.ID) + k.SetUserBorrowIDCounter(ctx, borrowPos.ID) k.SetBorrow(ctx, borrowPos) - k.SetBorrowForAddressByPair(ctx, lenderAddr, pairID, borrowPos.ID) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, true) + + mappingData, _ := k.GetUserLendBorrowMapping(ctx, addr, lendID) + mappingData.BorrowId = append(mappingData.BorrowId, borrowPos.ID) + k.SetUserLendBorrowMapping(ctx, mappingData) + } else { + updatedAmtIn := AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) + updatedAmtInPrice, err := k.CalcAssetPrice(ctx, lendPos.AssetID, updatedAmtIn.TruncateInt()) if err != nil { return err } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, true) + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range AssetInPool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } + } + firstTransitAsset, _ := k.GetAsset(ctx, firstTransitAssetID) + secondTransitAsset, _ := k.GetAsset(ctx, secondTransitAssetID) + + unitAmountFirstTransitAsset, err := k.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) if err != nil { return err } - err = k.UpdateLendIDToBorrowIDMapping(ctx, borrowPos.LendingID, borrowPos.ID, true) + unitAmountSecondTransitAsset, err := k.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) if err != nil { return err } - } else { - updatedAmtIn := AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) - priceAssetIn, found := k.GetPriceForAsset(ctx, pair.AssetIn) - if !found { - return types.ErrorPriceDoesNotExist - } - amtIn := updatedAmtIn.TruncateInt().Mul(sdk.NewIntFromUint64(priceAssetIn)) - priceFirstBridgedAsset, found := k.GetPriceForAsset(ctx, AssetInPool.FirstBridgedAssetID) - if !found { - return types.ErrorPriceDoesNotExist - } - priceSecondBridgedAsset, found := k.GetPriceForAsset(ctx, AssetInPool.SecondBridgedAssetID) - if !found { - return types.ErrorPriceDoesNotExist - } - firstBridgedAsset, found := k.GetAsset(ctx, AssetInPool.FirstBridgedAssetID) - if !found { - return assettypes.ErrorAssetDoesNotExist - } - secondBridgedAsset, found := k.GetAsset(ctx, AssetInPool.SecondBridgedAssetID) - if !found { - return assettypes.ErrorAssetDoesNotExist - } // qty of first and second bridged asset to be sent over different pool according to the borrow Pool - if priceFirstBridgedAsset == types.Uint64Zero || priceSecondBridgedAsset == types.Uint64Zero { - return types.ErrorPriceDoesNotExist - } - - firstBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceFirstBridgedAsset)) - firstBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, firstBridgedAsset.Denom) - secondBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceSecondBridgedAsset)) - secondBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, secondBridgedAsset.Denom) + firstBridgedAssetQty := updatedAmtInPrice.Quo(unitAmountFirstTransitAsset) + firstBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, firstTransitAsset.Denom) + secondBridgedAssetQty := updatedAmtInPrice.Quo(unitAmountSecondTransitAsset) + secondBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, secondTransitAsset.Denom) - firstBridgedAssetRatesStats, found := k.GetAssetRatesStats(ctx, AssetInPool.FirstBridgedAssetID) + firstBridgedAssetRatesStats, found := k.GetAssetRatesParams(ctx, firstTransitAsset.Id) if !found { return types.ErrAssetStatsNotFound } - secondBridgedAssetRatesStats, found := k.GetAssetRatesStats(ctx, AssetInPool.SecondBridgedAssetID) + secondBridgedAssetRatesStats, found := k.GetAssetRatesParams(ctx, secondTransitAsset.Id) if !found { return types.ErrAssetStatsNotFound } if firstBridgedAssetQty.LT(firstBridgedAssetBal) { - err = k.VerifyCollaterlizationRatio(ctx, firstBridgedAssetQty, firstBridgedAsset, loan.Amount, assetOut, firstBridgedAssetRatesStats.Ltv) + err = k.VerifyCollateralizationRatio(ctx, firstBridgedAssetQty, firstTransitAsset, loan.Amount, assetOut, firstBridgedAssetRatesStats.Ltv) if err != nil { return err } @@ -647,7 +667,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { return err } - bridgedAssetAmount := sdk.NewCoin(firstBridgedAsset.Denom, firstBridgedAssetQty) + bridgedAssetAmount := sdk.NewCoin(firstTransitAsset.Denom, firstBridgedAssetQty) if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { return err } @@ -656,8 +676,6 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return err } - AmountOut := loan - var StableBorrowRate sdk.Dec if assetInRatesStats.EnableStableBorrow && IsStableBorrow { StableBorrowRate, err = k.GetBorrowAPRByAssetID(ctx, AssetOutPool.PoolID, pair.AssetOut, IsStableBorrow) @@ -669,47 +687,37 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, } borrowPos := types.BorrowAsset{ - ID: borrowID + 1, - LendingID: lendID, - PairID: pairID, - AmountIn: AmountIn, - AmountOut: AmountOut, - BridgedAssetAmount: bridgedAssetAmount, - IsStableBorrow: IsStableBorrow, - StableBorrowRate: StableBorrowRate, - BorrowingTime: ctx.BlockTime(), - UpdatedAmountOut: AmountOut.Amount, - Interest_Accumulated: sdk.ZeroInt(), - GlobalIndex: globalIndex, - ReserveGlobalIndex: reserveGlobalIndex, - LastInteractionTime: ctx.BlockTime(), - CPoolName: AssetOutPool.CPoolName, + ID: borrowID + 1, + LendingID: lendID, + PairID: pairID, + AmountIn: AmountIn, + AmountOut: AmountOut, + BridgedAssetAmount: bridgedAssetAmount, + IsStableBorrow: IsStableBorrow, + StableBorrowRate: StableBorrowRate, + BorrowingTime: ctx.BlockTime(), + InterestAccumulated: sdk.ZeroDec(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), + CPoolName: AssetOutPool.CPoolName, + IsLiquidated: false, } - k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, AmountOut.Amount, true) + + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + poolAssetLBMappingData.BorrowIds = append(poolAssetLBMappingData.BorrowIds, borrowPos.ID) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) - err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, true) - if err != nil { - return err - } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) k.SetLend(ctx, lendPos) - k.SetUserBorrowIDHistory(ctx, borrowPos.ID) + k.SetUserBorrowIDCounter(ctx, borrowPos.ID) k.SetBorrow(ctx, borrowPos) - k.SetBorrowForAddressByPair(ctx, lenderAddr, pairID, borrowPos.ID) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, true) - if err != nil { - return err - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, true) - if err != nil { - return err - } - err = k.UpdateLendIDToBorrowIDMapping(ctx, borrowPos.LendingID, borrowPos.ID, true) - if err != nil { - return err - } + mappingData, _ := k.GetUserLendBorrowMapping(ctx, addr, lendID) + mappingData.BorrowId = append(mappingData.BorrowId, borrowPos.ID) + k.SetUserLendBorrowMapping(ctx, mappingData) } else if secondBridgedAssetQty.LT(secondBridgedAssetBal) { - err = k.VerifyCollaterlizationRatio(ctx, secondBridgedAssetQty, secondBridgedAsset, loan.Amount, assetOut, secondBridgedAssetRatesStats.Ltv) + err = k.VerifyCollateralizationRatio(ctx, secondBridgedAssetQty, secondTransitAsset, loan.Amount, assetOut, secondBridgedAssetRatesStats.Ltv) if err != nil { return err } @@ -718,7 +726,7 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return err } - bridgedAssetAmount := sdk.NewCoin(secondBridgedAsset.Denom, secondBridgedAssetQty) + bridgedAssetAmount := sdk.NewCoin(secondTransitAsset.Denom, secondBridgedAssetQty) if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(bridgedAssetAmount)); err != nil { return err } @@ -727,8 +735,6 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, return err } - AmountOut := loan - var StableBorrowRate sdk.Dec if assetInRatesStats.EnableStableBorrow && IsStableBorrow { StableBorrowRate, err = k.GetBorrowAPRByAssetID(ctx, AssetOutPool.PoolID, pair.AssetOut, IsStableBorrow) @@ -740,44 +746,36 @@ func (k Keeper) BorrowAsset(ctx sdk.Context, addr string, lendID, pairID uint64, } borrowPos := types.BorrowAsset{ - ID: borrowID + 1, - LendingID: lendID, - PairID: pairID, - AmountIn: AmountIn, - AmountOut: AmountOut, - BridgedAssetAmount: bridgedAssetAmount, - IsStableBorrow: IsStableBorrow, - StableBorrowRate: StableBorrowRate, - BorrowingTime: ctx.BlockTime(), - UpdatedAmountOut: AmountOut.Amount, - Interest_Accumulated: sdk.ZeroInt(), - GlobalIndex: globalIndex, - ReserveGlobalIndex: reserveGlobalIndex, - LastInteractionTime: ctx.BlockTime(), - CPoolName: AssetOutPool.CPoolName, - } - k.UpdateBorrowStats(ctx, pair, borrowPos, AmountOut.Amount, true) - err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, true) - if err != nil { - return err + ID: borrowID + 1, + LendingID: lendID, + PairID: pairID, + AmountIn: AmountIn, + AmountOut: AmountOut, + BridgedAssetAmount: bridgedAssetAmount, + IsStableBorrow: IsStableBorrow, + StableBorrowRate: StableBorrowRate, + BorrowingTime: ctx.BlockTime(), + InterestAccumulated: sdk.ZeroDec(), + GlobalIndex: globalIndex, + ReserveGlobalIndex: reserveGlobalIndex, + LastInteractionTime: ctx.BlockTime(), + CPoolName: AssetOutPool.CPoolName, + IsLiquidated: false, } + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, AmountOut.Amount, true) + + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + poolAssetLBMappingData.BorrowIds = append(poolAssetLBMappingData.BorrowIds, borrowPos.ID) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) k.SetLend(ctx, lendPos) - k.SetUserBorrowIDHistory(ctx, borrowPos.ID) + k.SetUserBorrowIDCounter(ctx, borrowPos.ID) k.SetBorrow(ctx, borrowPos) - k.SetBorrowForAddressByPair(ctx, lenderAddr, pairID, borrowPos.ID) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, true) - if err != nil { - return err - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, true) - if err != nil { - return err - } - err = k.UpdateLendIDToBorrowIDMapping(ctx, borrowPos.LendingID, borrowPos.ID, true) - if err != nil { - return err - } + + mappingData, _ := k.GetUserLendBorrowMapping(ctx, addr, lendID) + mappingData.BorrowId = append(mappingData.BorrowId, borrowPos.ID) + k.SetUserLendBorrowMapping(ctx, mappingData) } else { return types.ErrBorrowingPoolInsufficient } @@ -790,12 +788,24 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string if !found { return types.ErrBorrowNotFound } + if borrowPos.IsLiquidated { + return types.ErrorBorrowPosLiquidated + } + + if payment.Amount.Equal(borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt())) { + err := k.CloseBorrow(ctx, borrowerAddr, borrowID) + if err != nil { + return err + } + return nil + } + addr, _ := sdk.AccAddressFromBech32(borrowerAddr) pair, found := k.GetLendPair(ctx, borrowPos.PairID) if !found { return types.ErrorPairNotFound } - assetStats, found := k.GetAssetRatesStats(ctx, pair.AssetOut) + assetStats, found := k.GetAssetRatesParams(ctx, pair.AssetOut) if !found { return types.ErrAssetStatsNotFound } @@ -818,7 +828,7 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string } if lendPos.Owner != borrowerAddr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) if err != nil { @@ -831,92 +841,116 @@ func (k Keeper) RepayAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string if borrowPos.AmountOut.Denom != payment.Denom { return types.ErrBadOfferCoinAmount } + if payment.Amount.GT(borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.Ceil().RoundInt())) { + return types.ErrInvalidRepayment + } borrowPos.GlobalIndex = indexGlobalCurrent borrowPos.ReserveGlobalIndex = reserveGlobalIndex borrowPos.LastInteractionTime = ctx.BlockTime() + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) - if payment.Amount.LT(borrowPos.UpdatedAmountOut) { - if payment.Amount.LTE(borrowPos.Interest_Accumulated) { - // sending repayment to moduleAcc from borrower - if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { - return err + if payment.Amount.LTE(borrowPos.InterestAccumulated.TruncateInt()) { + // sending repayment to moduleAcc from borrower + if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { + return err + } + borrowPos.InterestAccumulated = borrowPos.InterestAccumulated.Sub(sdk.NewDecFromInt(payment.Amount)) + + reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) + amtToReservePool := reservePoolRecords.ReservePoolInterest + + if amtToReservePool.TruncateInt().LTE(payment.Amount) { + if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { + return types.ErrReserveRatesNotFound } - borrowPos.UpdatedAmountOut = borrowPos.UpdatedAmountOut.Sub(payment.Amount) - reservePoolRecords, _ := k.GetReservePoolRecordsForBorrow(ctx, borrowID) - amtToReservePool := reservePoolRecords.InterestAccumulated - if amtToReservePool.TruncateInt().LTE(payment.Amount) { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound - } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err := k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } - } - if borrowPos.Interest_Accumulated.GT(amtToReservePool.TruncateInt()) { - err := k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, payment.Amount.Sub(amtToReservePool.TruncateInt()))) - if err != nil { - return err - } - } - reservePoolRecords.InterestAccumulated = sdk.ZeroDec() - k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) - } else { - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { - return types.ErrReserveRatesNotFound + if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { + amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) + err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + if err != nil { + return err } - if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { - amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err := k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) - if err != nil { - return err - } + } + amtBackToPool := payment.Amount.Sub(amtToReservePool.TruncateInt()) + if amtBackToPool.GT(sdk.ZeroInt()) { + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtBackToPool)) + if err != nil { + return err } - reservePoolRecords.InterestAccumulated = sdk.Dec(reservePoolRecords.InterestAccumulated.TruncateInt().Sub(payment.Amount)) - k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(amtBackToPool) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(amtBackToPool) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) } - borrowPos.Interest_Accumulated = borrowPos.Interest_Accumulated.Sub(payment.Amount) - k.SetBorrow(ctx, borrowPos) + + reservePoolRecords.ReservePoolInterest = sdk.ZeroDec() + k.SetBorrowInterestTracker(ctx, reservePoolRecords) } else { - // sending repayment to moduleAcc from borrower - if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { - return err + if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { + return types.ErrReserveRatesNotFound } - borrowPos.UpdatedAmountOut = borrowPos.UpdatedAmountOut.Sub(payment.Amount) - amtOut := borrowPos.AmountOut.Amount.Sub(payment.Amount) - amountOut := amtOut.Add(borrowPos.Interest_Accumulated) - borrowPos.AmountOut.Amount = amountOut + if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { + amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) + err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + if err != nil { + return err + } + } + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(payment.Amount.ToDec()) + k.SetBorrowInterestTracker(ctx, reservePoolRecords) + } + } else { + if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, sdk.NewCoins(payment)); err != nil { + return err + } - reservePoolRecords, _ := k.GetReservePoolRecordsForBorrow(ctx, borrowID) - amtToReservePool := reservePoolRecords.InterestAccumulated + borrowPos.AmountOut.Amount = borrowPos.AmountOut.Amount.Sub(payment.Amount).Add(borrowPos.InterestAccumulated.TruncateInt()) + + reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) + amtToReservePool := reservePoolRecords.ReservePoolInterest + + if amtToReservePool.TruncateInt().LTE(payment.Amount) { if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { return types.ErrReserveRatesNotFound } if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) - err := k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) if err != nil { return err } } - if borrowPos.Interest_Accumulated.GT(amtToReservePool.TruncateInt()) { - err := k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, borrowPos.Interest_Accumulated.Sub(amtToReservePool.TruncateInt()))) + amtBackToPool := payment.Amount.Sub(amtToReservePool.TruncateInt()) + if amtBackToPool.GT(sdk.ZeroInt()) { + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtBackToPool)) if err != nil { return err } + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(amtBackToPool) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(amtBackToPool) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) } - amtBorrowStats := payment.Amount.Sub(borrowPos.Interest_Accumulated) - borrowPos.Interest_Accumulated = sdk.ZeroInt() - reservePoolRecords.InterestAccumulated = sdk.ZeroDec() - k.SetReservePoolRecordsForBorrow(ctx, reservePoolRecords) - k.UpdateBorrowStats(ctx, pair, borrowPos, amtBorrowStats, false) - k.SetBorrow(ctx, borrowPos) + + reservePoolRecords.ReservePoolInterest = sdk.ZeroDec() + k.SetBorrowInterestTracker(ctx, reservePoolRecords) + } else { + if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { + return types.ErrReserveRatesNotFound + } + if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { + amount := sdk.NewCoin(payment.Denom, amtToReservePool.TruncateInt()) + err = k.SetReserveBalances(ctx, pool.ModuleName, pair.AssetOut, amount) + if err != nil { + return err + } + } + reservePoolRecords.ReservePoolInterest = reservePoolRecords.ReservePoolInterest.Sub(payment.Amount.ToDec()) + k.SetBorrowInterestTracker(ctx, reservePoolRecords) } - } else { - return types.ErrInvalidRepayment + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, payment.Amount.Sub(borrowPos.InterestAccumulated.TruncateInt()), false) + borrowPos.InterestAccumulated = sdk.ZeroDec() } + + k.SetBorrow(ctx, borrowPos) + return nil } @@ -925,6 +959,11 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string if !found { return types.ErrBorrowNotFound } + + if borrowPos.IsLiquidated { + return types.ErrorBorrowPosLiquidated + } + lendID := borrowPos.LendingID pairID := borrowPos.PairID lenderAddr, _ := sdk.AccAddressFromBech32(addr) @@ -940,7 +979,7 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string } if lendPos.Owner != addr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) if err != nil { @@ -953,9 +992,9 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string borrowPos.GlobalIndex = indexGlobalCurrent borrowPos.ReserveGlobalIndex = reserveGlobalIndex borrowPos.LastInteractionTime = ctx.BlockTime() - assetRatesStat, found := k.GetAssetRatesStats(ctx, lendPos.AssetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, lendPos.AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(lendPos.AssetID, 10)) } cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) if !found { @@ -981,7 +1020,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.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) @@ -989,66 +1028,68 @@ func (k Keeper) DepositBorrowAsset(ctx sdk.Context, borrowID uint64, addr string borrowPos.AmountIn = borrowPos.AmountIn.Add(AmountIn) k.SetBorrow(ctx, borrowPos) } else { - assetIn := lendPos.UpdatedAmountIn - priceAssetIn, found := k.GetPriceForAsset(ctx, pair.AssetIn) - if !found { - return types.ErrorPriceDoesNotExist + amtIn, err := k.CalcAssetPrice(ctx, pair.AssetIn, (sdk.NewDecFromInt(AmountIn.Amount).Mul(assetRatesStat.Ltv)).TruncateInt()) + if err != nil { + return err } - amtIn := assetIn.Mul(sdk.NewIntFromUint64(priceAssetIn)) - priceFirstBridgedAsset, found := k.GetPriceForAsset(ctx, AssetInPool.FirstBridgedAssetID) - if !found { - return types.ErrorPriceDoesNotExist - } - priceSecondBridgedAsset, found := k.GetPriceForAsset(ctx, AssetInPool.SecondBridgedAssetID) - if !found { - return types.ErrorPriceDoesNotExist + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range AssetInPool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } } - firstBridgedAsset, found := k.GetAsset(ctx, AssetInPool.FirstBridgedAssetID) - if !found { - return assettypes.ErrorAssetDoesNotExist + firstTransitAsset, _ := k.GetAsset(ctx, firstTransitAssetID) + secondTransitAsset, _ := k.GetAsset(ctx, secondTransitAssetID) + + unitAmountFirstTransitAsset, err := k.CalcAssetPrice(ctx, firstTransitAssetID, sdk.OneInt()) + if err != nil { + return err } - secondBridgedAsset, found := k.GetAsset(ctx, AssetInPool.SecondBridgedAssetID) - if !found { - return assettypes.ErrorAssetDoesNotExist + unitAmountSecondTransitAsset, err := k.CalcAssetPrice(ctx, secondTransitAssetID, sdk.OneInt()) + if err != nil { + return err } // qty of first and second bridged asset to be sent over different pool according to the borrow Pool - firstBridgedAssetq := amtIn.Quo(sdk.NewIntFromUint64(priceFirstBridgedAsset)) - firstBridgedAssetQty := firstBridgedAssetq.ToDec().Mul(assetRatesStat.Ltv) - firstBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, firstBridgedAsset.Denom) - secondBridgedAssetq := amtIn.Quo(sdk.NewIntFromUint64(priceSecondBridgedAsset)) - secondBridgedAssetQty := secondBridgedAssetq.ToDec().Mul(assetRatesStat.Ltv) - secondBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, secondBridgedAsset.Denom) + firstBridgedAssetQty := amtIn.Quo(unitAmountFirstTransitAsset) + firstBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, firstTransitAsset.Denom) + secondBridgedAssetQty := amtIn.Quo(unitAmountSecondTransitAsset) + secondBridgedAssetBal := k.ModuleBalance(ctx, AssetInPool.ModuleName, secondTransitAsset.Denom) + + // qty of first and second bridged asset to be sent over different pool according to the borrow Pool - if borrowPos.BridgedAssetAmount.Denom == firstBridgedAsset.Denom && firstBridgedAssetQty.LT(firstBridgedAssetBal.ToDec()) { + if borrowPos.BridgedAssetAmount.Denom == firstTransitAsset.Denom && firstBridgedAssetQty.LT(firstBridgedAssetBal) { // take c/Tokens from the user - if err := k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { return err } - if err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(firstBridgedAsset.Denom, firstBridgedAssetQty.TruncateInt()))); err != nil { + if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(firstTransitAsset.Denom, firstBridgedAssetQty))); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) k.SetLend(ctx, lendPos) borrowPos.AmountIn = borrowPos.AmountIn.Add(AmountIn) - borrowPos.BridgedAssetAmount.Amount = borrowPos.BridgedAssetAmount.Amount.Add(firstBridgedAssetQty.TruncateInt()) + borrowPos.BridgedAssetAmount.Amount = borrowPos.BridgedAssetAmount.Amount.Add(firstBridgedAssetQty) k.SetBorrow(ctx, borrowPos) - } else if secondBridgedAssetQty.LT(secondBridgedAssetBal.ToDec()) { + } else if secondBridgedAssetQty.LT(secondBridgedAssetBal) { // take c/Tokens from the user - if err := k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { + if err = k.SendCoinFromAccountToModule(ctx, lenderAddr, AssetInPool.ModuleName, AmountIn); err != nil { return err } - if err := k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(secondBridgedAsset.Denom, secondBridgedAssetQty.TruncateInt()))); err != nil { + if err = k.SendCoinFromModuleToModule(ctx, AssetInPool.ModuleName, AssetOutPool.ModuleName, sdk.NewCoins(sdk.NewCoin(secondTransitAsset.Denom, secondBridgedAssetQty))); err != nil { return err } lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(AmountIn.Amount) k.SetLend(ctx, lendPos) borrowPos.AmountIn = borrowPos.AmountIn.Add(AmountIn) - borrowPos.BridgedAssetAmount.Amount = borrowPos.BridgedAssetAmount.Amount.Add(secondBridgedAssetQty.TruncateInt()) + borrowPos.BridgedAssetAmount.Amount = borrowPos.BridgedAssetAmount.Amount.Add(secondBridgedAssetQty) k.SetBorrow(ctx, borrowPos) } else { return types.ErrBridgeAssetQtyInsufficient @@ -1062,6 +1103,11 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if !found { return types.ErrBorrowNotFound } + + if borrowPos.IsLiquidated { + return types.ErrorBorrowPosLiquidated + } + addr, _ := sdk.AccAddressFromBech32(borrowerAddr) pair, found := k.GetLendPair(ctx, borrowPos.PairID) if !found { @@ -1082,7 +1128,7 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, } if lendPos.Owner != borrowerAddr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) if err != nil { @@ -1106,21 +1152,20 @@ func (k Keeper) DrawAsset(ctx sdk.Context, borrowID uint64, borrowerAddr string, if !found { return assettypes.ErrorAssetDoesNotExist } - assetRatesStats, found := k.GetAssetRatesStats(ctx, pair.AssetIn) + assetRatesStats, found := k.GetAssetRatesParams(ctx, pair.AssetIn) if !found { return types.ErrorAssetStatsNotFound } - err = k.VerifyCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut.Add(amount.Amount), assetOut, assetRatesStats.Ltv) + err = k.VerifyCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()).Add(amount.Amount), assetOut, assetRatesStats.Ltv) if err != nil { return err } if err = k.SendCoinFromModuleToAccount(ctx, pool.ModuleName, addr, amount); err != nil { return err } - borrowPos.UpdatedAmountOut = borrowPos.UpdatedAmountOut.Add(amount.Amount) borrowPos.AmountOut = borrowPos.AmountOut.Add(amount) k.SetBorrow(ctx, borrowPos) - k.UpdateBorrowStats(ctx, pair, borrowPos, amount.Amount, true) + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, amount.Amount, true) return nil } @@ -1135,7 +1180,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 if !found { return types.ErrorPairNotFound } - assetStats, found := k.GetAssetRatesStats(ctx, pair.AssetOut) + assetStats, found := k.GetAssetRatesParams(ctx, pair.AssetOut) if !found { return types.ErrAssetStatsNotFound } @@ -1156,7 +1201,7 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 return esmtypes.ErrCircuitBreakerEnabled } if lendPos.Owner != borrowerAddr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) if err != nil { @@ -1178,10 +1223,9 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 return assettypes.ErrorAssetDoesNotExist } lenderAddr, _ := sdk.AccAddressFromBech32(lendPos.Owner) - if borrowPos.UpdatedAmountOut.LTE(sdk.ZeroInt()) { - return types.ErrInsufficientFunds - } - amt := sdk.NewCoins(sdk.NewCoin(assetOut.Denom, borrowPos.UpdatedAmountOut)) + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, pair.AssetOutPoolID, pair.AssetOut) + + amt := sdk.NewCoins(sdk.NewCoin(assetOut.Denom, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()))) if err = k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, amt); err != nil { return err } @@ -1189,9 +1233,9 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 return err } - reservePoolRecords, _ := k.GetReservePoolRecordsForBorrow(ctx, borrowID) - amtToReservePool := reservePoolRecords.InterestAccumulated - if amtToReservePool.TruncateInt().LT(sdk.ZeroInt()) { + reservePoolRecords, _ := k.GetBorrowInterestTracker(ctx, borrowID) + amtToReservePool := reservePoolRecords.ReservePoolInterest + if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { return types.ErrReserveRatesNotFound } if amtToReservePool.TruncateInt().GT(sdk.ZeroInt()) { @@ -1201,28 +1245,15 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 return err } } - if borrowPos.Interest_Accumulated.GT(amtToReservePool.TruncateInt()) { - err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, borrowPos.Interest_Accumulated.Sub(amtToReservePool.TruncateInt()))) + amtToMint := borrowPos.InterestAccumulated.TruncateInt().Sub(amtToReservePool.TruncateInt()) + if amtToMint.GT(sdk.ZeroInt()) { + err = k.MintCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, amtToMint)) if err != nil { return err } - } - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, false) - if err != nil { - return err - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, false) - if err != nil { - return err - } - err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, false) - if err != nil { - return err - } - k.DeleteBorrowForAddressByPair(ctx, addr, borrowPos.PairID) - err = k.UpdateLendIDToBorrowIDMapping(ctx, borrowPos.LendingID, borrowPos.ID, false) - if err != nil { - return err + poolAssetLBMappingData.TotalInterestAccumulated = poolAssetLBMappingData.TotalInterestAccumulated.Add(amtToMint) + poolAssetLBMappingData.TotalLend = poolAssetLBMappingData.TotalLend.Add(amtToMint) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) } if pair.IsInterPool { @@ -1231,10 +1262,12 @@ func (k Keeper) CloseBorrow(ctx sdk.Context, borrowerAddr string, borrowID uint6 } } - k.UpdateBorrowStats(ctx, pair, borrowPos, borrowPos.AmountOut.Amount, false) + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, borrowPos.AmountOut.Amount, false) lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Add(borrowPos.AmountIn.Amount) k.SetLend(ctx, lendPos) + k.DeleteIDFromAssetStatsMapping(ctx, pair.AssetOutPoolID, pair.AssetOut, borrowID, false) + k.DeleteBorrowIDFromUserMapping(ctx, lendPos.Owner, lendPos.ID, borrowID) k.DeleteBorrow(ctx, borrowID) return nil @@ -1253,10 +1286,13 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo if !found { return types.ErrPoolNotFound } - _, found = k.GetApp(ctx, AppID) + appMapping, found := k.GetApp(ctx, AppID) if !found { return types.ErrorAppMappingDoesNotExist } + if appMapping.Name != types.AppName { + return types.ErrorAppMappingIDMismatch + } if AmountIn.Denom != asset.Denom { return sdkerrors.Wrap(types.ErrBadOfferCoinAmount, AmountIn.Denom) @@ -1267,22 +1303,27 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo return sdkerrors.Wrap(types.ErrInvalidAssetIDForPool, strconv.FormatUint(AssetID, 10)) } + found, err := k.CheckSupplyCap(ctx, AssetID, PoolID, AmountIn.Amount) + if err != nil { + return err + } + if !found { + return types.ErrorSupplyCapExceeds + } + addr, _ := sdk.AccAddressFromBech32(lenderAddr) - if k.HasLendForAddressByAsset(ctx, addr, AssetID, PoolID) { + if k.HasLendForAddressByAsset(ctx, lenderAddr, AssetID, PoolID) { return types.ErrorDuplicateLend } loanTokens := sdk.NewCoins(AmountIn) - assetRatesStat, found := k.GetAssetRatesStats(ctx, AssetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, AssetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(AssetID, 10)) - } - cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) - if !found { - return assettypes.ErrorAssetDoesNotExist + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(AssetID, 10)) } + cAsset, _ := k.GetAsset(ctx, assetRatesStat.CAssetID) cToken := sdk.NewCoin(cAsset.Denom, AmountIn.Amount) if err := k.bank.SendCoinsFromAccountToModule(ctx, addr, pool.ModuleName, loanTokens); err != nil { @@ -1295,15 +1336,15 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo return err } - err := k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, cTokens) + err = k.bank.SendCoinsFromModuleToAccount(ctx, pool.ModuleName, addr, cTokens) if err != nil { return err } - lendID := k.GetUserLendIDHistory(ctx) + lendID := k.GetUserLendIDCounter(ctx) var globalIndex sdk.Dec - assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, AssetID, PoolID) + assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) if assetStats.LendApr.IsZero() { globalIndex = sdk.OneDec() } else { @@ -1317,30 +1358,25 @@ func (k Keeper) BorrowAlternate(ctx sdk.Context, lenderAddr string, AssetID, Poo Owner: lenderAddr, AmountIn: AmountIn, LendingTime: ctx.BlockTime(), - UpdatedAmountIn: AmountIn.Amount, AvailableToBorrow: AmountIn.Amount, - Reward_Accumulated: sdk.ZeroInt(), AppID: AppID, GlobalIndex: globalIndex, LastInteractionTime: ctx.BlockTime(), CPoolName: pool.CPoolName, } k.UpdateLendStats(ctx, AssetID, PoolID, AmountIn.Amount, true) - k.SetUserLendIDHistory(ctx, lendPos.ID) + k.SetUserLendIDCounter(ctx, lendPos.ID) k.SetLend(ctx, lendPos) - k.SetLendForAddressByAsset(ctx, addr, lendPos.AssetID, lendPos.ID, lendPos.PoolID) - err = k.UpdateUserLendIDMapping(ctx, lenderAddr, lendPos.ID, true) - if err != nil { - return err - } - err = k.UpdateLendIDByOwnerAndPoolMapping(ctx, lenderAddr, lendPos.ID, lendPos.PoolID, true) - if err != nil { - return err - } - err = k.UpdateLendIDsMapping(ctx, lendPos.ID, true) - if err != nil { - return err - } + + var mappingData types.UserAssetLendBorrowMapping + mappingData.Owner = lendPos.Owner + mappingData.LendId = lendPos.ID + mappingData.PoolId = PoolID + k.SetUserLendBorrowMapping(ctx, mappingData) + + poolAssetLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, PoolID, AssetID) + poolAssetLBMappingData.LendIds = append(poolAssetLBMappingData.LendIds, lendPos.ID) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolAssetLBMappingData) err = k.BorrowAsset(ctx, lenderAddr, lendPos.ID, PairID, IsStableBorrow, cToken, AmountOut) if err != nil { @@ -1364,9 +1400,9 @@ func (k Keeper) FundModAcc(ctx sdk.Context, moduleName string, assetID uint64, l return types.ErrBadOfferCoinType } - assetRatesStat, found := k.GetAssetRatesStats(ctx, assetID) + assetRatesStat, found := k.GetAssetRatesParams(ctx, assetID) if !found { - return sdkerrors.Wrap(types.ErrorAssetRatesStatsNotFound, strconv.FormatUint(assetID, 10)) + return sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, strconv.FormatUint(assetID, 10)) } cAsset, found := k.GetAsset(ctx, assetRatesStat.CAssetID) if !found { @@ -1378,16 +1414,6 @@ func (k Keeper) FundModAcc(ctx sdk.Context, moduleName string, assetID uint64, l if err != nil { return err } - depositStats, _ := k.GetDepositStats(ctx) - var balanceStats []types.BalanceStats - for _, v := range depositStats.BalanceStats { - if v.AssetID == assetID { - v.Amount = v.Amount.Add(payment.Amount) - } - balanceStats = append(balanceStats, v) - newDepositStats := types.DepositStats{BalanceStats: balanceStats} - k.SetDepositStats(ctx, newDepositStats) - } return nil } @@ -1406,47 +1432,38 @@ func (k Keeper) Store(ctx sdk.Context) sdk.KVStore { func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) { kind := liqBorrow.GetBorrowMetaData() - borrowID := k.GetUserBorrowIDHistory(ctx) + pair, _ := k.GetLendPair(ctx, liqBorrow.ExtendedPairId) - AssetOut, _ := k.GetAsset(ctx, pair.AssetOut) - assetInRatesStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) - AssetRatesStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) - cAssetIn, _ := k.GetAsset(ctx, AssetRatesStats.CAssetID) - AssetOutPool, _ := k.GetPool(ctx, pair.AssetOutPoolID) lendPos, _ := k.GetLend(ctx, kind.LendingId) + borrowPos, _ := k.GetBorrow(ctx, liqBorrow.OriginalVaultId) + AssetInPool, _ := k.GetPool(ctx, lendPos.PoolID) - assetStats, _ := k.AssetStatsByPoolIDAndAssetID(ctx, pair.AssetOut, pair.AssetOutPoolID) - reserveGlobalIndex, err := k.GetReserveRate(ctx, pair.AssetOutPoolID, pair.AssetOut) - if err != nil { - reserveGlobalIndex = sdk.OneDec() - } - globalIndex := assetStats.BorrowApr + AssetOutPool, _ := k.GetPool(ctx, pair.AssetOutPoolID) + assetInRatesStats, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) + borrowPos.IsLiquidated = false + + amoutOutDiff := borrowPos.AmountOut.Amount.Sub(liqBorrow.AmountOut) + borrowPos.AmountOut.Amount = liqBorrow.AmountOut + borrowPos.AmountIn.Amount = liqBorrow.AmountIn - borrowPos := types.BorrowAsset{ - ID: borrowID + 1, - LendingID: kind.LendingId, - PairID: liqBorrow.ExtendedPairId, - AmountIn: sdk.NewCoin(cAssetIn.Denom, liqBorrow.AmountIn), - AmountOut: sdk.NewCoin(AssetOut.Denom, liqBorrow.AmountOut), - BridgedAssetAmount: kind.BridgedAssetAmount, - IsStableBorrow: kind.IsStableBorrow, - StableBorrowRate: kind.StableBorrowRate, - BorrowingTime: ctx.BlockTime(), - UpdatedAmountOut: liqBorrow.AmountOut, - Interest_Accumulated: sdk.ZeroInt(), - GlobalIndex: globalIndex, - ReserveGlobalIndex: reserveGlobalIndex, - LastInteractionTime: ctx.BlockTime(), - CPoolName: AssetOutPool.CPoolName, + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range AssetInPool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } } + // Adjusting bridged asset qty after auctions - if kind.BridgedAssetAmount.Amount != sdk.ZeroInt() { + if !kind.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { priceAssetIn, _ := k.GetPriceForAsset(ctx, pair.AssetIn) adjustedBridgedAssetAmt := borrowPos.AmountIn.Amount.ToDec().Mul(assetInRatesStats.Ltv) amtIn := adjustedBridgedAssetAmt.TruncateInt().Mul(sdk.NewIntFromUint64(priceAssetIn)) - priceFirstBridgedAsset, _ := k.GetPriceForAsset(ctx, AssetInPool.FirstBridgedAssetID) - priceSecondBridgedAsset, _ := k.GetPriceForAsset(ctx, AssetInPool.SecondBridgedAssetID) - firstBridgedAsset, _ := k.GetAsset(ctx, AssetInPool.FirstBridgedAssetID) + priceFirstBridgedAsset, _ := k.GetPriceForAsset(ctx, firstTransitAssetID) + priceSecondBridgedAsset, _ := k.GetPriceForAsset(ctx, secondTransitAssetID) + firstBridgedAsset, _ := k.GetAsset(ctx, firstTransitAssetID) if kind.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { firstBridgedAssetQty := amtIn.Quo(sdk.NewIntFromUint64(priceFirstBridgedAsset)) @@ -1488,30 +1505,9 @@ func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.Locke } } } - OriginalBorrowID := liqBorrow.OriginalVaultId - err = k.UpdateLendIDToBorrowIDMapping(ctx, kind.LendingId, OriginalBorrowID, false) - if err != nil { - return - } - k.UpdateBorrowStats(ctx, pair, borrowPos, borrowPos.AmountOut.Amount, true) + + k.UpdateBorrowStats(ctx, pair, borrowPos.IsStableBorrow, amoutOutDiff, false) k.SetBorrow(ctx, borrowPos) - k.SetUserBorrowIDHistory(ctx, borrowPos.ID) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, true) - if err != nil { - return - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowPos.ID, pair.AssetOutPoolID, true) - if err != nil { - return - } - err = k.UpdateBorrowIdsMapping(ctx, borrowPos.ID, true) - if err != nil { - return - } - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowPos.ID, true) - if err != nil { - return - } } func (k Keeper) MsgCalculateBorrowInterest(ctx sdk.Context, borrowerAddr string, borrowID uint64) error { @@ -1529,7 +1525,7 @@ func (k Keeper) MsgCalculateBorrowInterest(ctx sdk.Context, borrowerAddr string, return esmtypes.ErrCircuitBreakerEnabled } if lendPos.Owner != borrowerAddr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } indexGlobalCurrent, reserveGlobalIndex, err := k.IterateBorrow(ctx, borrowID) if err != nil { @@ -1564,7 +1560,7 @@ func (k Keeper) MsgCalculateLendRewards(ctx sdk.Context, addr string, lendID uin lendPos.GlobalIndex = indexGlobalCurrent lendPos.LastInteractionTime = ctx.BlockTime() if lendPos.Owner != addr { - return types.ErrLendAccessUnauthorised + return types.ErrLendAccessUnauthorized } k.SetLend(ctx, lendPos) return nil diff --git a/x/lend/keeper/keeper_test.go b/x/lend/keeper/keeper_test.go index db6a06a9c..ca0bfa0d9 100644 --- a/x/lend/keeper/keeper_test.go +++ b/x/lend/keeper/keeper_test.go @@ -6,7 +6,6 @@ import ( assettypes "github.com/comdex-official/comdex/x/asset/types" markettypes "github.com/comdex-official/comdex/x/market/types" - protobuftypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -76,18 +75,18 @@ func newDec(i string) sdk.Dec { return dec } -func (s *KeeperTestSuite) SetOraclePrice(symbol string, price uint64) { - var ( - store = s.app.MarketKeeper.Store(s.ctx) - key = markettypes.PriceForMarketKey(symbol) - ) - value := s.app.AppCodec().MustMarshal( - &protobuftypes.UInt64Value{ - Value: price, - }, - ) - store.Set(key, value) -} +//func (s *KeeperTestSuite) SetOraclePrice(symbol string, price uint64) { +// var ( +// store = s.app.MarketKeeper.Store(s.ctx) +// key = markettypes.PriceForMarketKey(symbol) +// ) +// value := s.app.AppCodec().MustMarshal( +// &protobuftypes.UInt64Value{ +// Value: price, +// }, +// ) +// store.Set(key, value) +//} func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) uint64 { err := s.app.AssetKeeper.AddAssetRecords(s.ctx, assettypes.Asset{ @@ -108,42 +107,70 @@ func (s *KeeperTestSuite) CreateNewAsset(name, denom string, price uint64) uint6 } s.Require().NotZero(assetID) - market := markettypes.Market{ - Symbol: name, - ScriptID: 12, - Rates: price, + //market := markettypes.Market{ + // Symbol: name, + // ScriptID: 12, + // Rates: price, + //} + //s.app.MarketKeeper.SetMarket(s.ctx, market) + + // exists := s.app.MarketKeeper.HasMarketForAsset(s.ctx, assetID) + + twa1 := markettypes.TimeWeightedAverage{ + AssetID: 1, + ScriptID: 10, + Twa: 1000000, + CurrentIndex: 1, + IsPriceActive: true, + PriceValue: nil, + } + twa2 := markettypes.TimeWeightedAverage{ + AssetID: 2, + ScriptID: 10, + Twa: 1000000, + CurrentIndex: 1, + IsPriceActive: true, + PriceValue: nil, + } + twa3 := markettypes.TimeWeightedAverage{ + AssetID: 3, + ScriptID: 10, + Twa: 1000000, + CurrentIndex: 1, + IsPriceActive: true, + PriceValue: nil, + } + twa4 := markettypes.TimeWeightedAverage{ + AssetID: 4, + ScriptID: 10, + Twa: 1000000, + CurrentIndex: 1, + IsPriceActive: true, + PriceValue: nil, } - s.app.MarketKeeper.SetMarket(s.ctx, market) - exists := s.app.MarketKeeper.HasMarketForAsset(s.ctx, assetID) - s.Suite.Require().False(exists) + s.app.MarketKeeper.SetTwa(s.ctx, twa1) + s.app.MarketKeeper.SetTwa(s.ctx, twa2) + 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) - exists = s.app.MarketKeeper.HasMarketForAsset(s.ctx, assetID) - s.Suite.Require().True(exists) - - s.SetOraclePrice(name, price) return assetID } -func (s *KeeperTestSuite) CreateNewPool(moduleName, cPoolName string, mainAssetID, firstBridgedAssetID, secondBridgedAssetID uint64, assetData []types.AssetDataPoolMapping) uint64 { +func (s *KeeperTestSuite) CreateNewPool(moduleName, cPoolName string, assetData []*types.AssetDataPoolMapping) uint64 { err := s.app.LendKeeper.AddPoolRecords(s.ctx, types.Pool{ - ModuleName: moduleName, - MainAssetId: mainAssetID, - FirstBridgedAssetID: firstBridgedAssetID, - SecondBridgedAssetID: secondBridgedAssetID, - CPoolName: cPoolName, - AssetData: assetData, + ModuleName: moduleName, + CPoolName: cPoolName, + AssetData: assetData, }) s.Require().NoError(err) pools := s.app.LendKeeper.GetPools(s.ctx) var poolID uint64 for _, pool := range pools { - if pool.MainAssetId == mainAssetID { - poolID = pool.PoolID - break - } + poolID = pool.PoolID } s.Require().NotZero(poolID) @@ -151,7 +178,7 @@ func (s *KeeperTestSuite) CreateNewPool(moduleName, cPoolName string, mainAssetI } func (s *KeeperTestSuite) AddAssetRatesStats(AssetID uint64, UOptimal, Base, Slope1, Slope2 sdk.Dec, EnableStableBorrow bool, StableBase, StableSlope1, StableSlope2, LTV, LiquidationThreshold, LiquidationPenalty, LiquidationBonus, ReserveFactor sdk.Dec, CAssetID uint64) uint64 { - err := s.app.LendKeeper.AddAssetRatesStats(s.ctx, types.AssetRatesStats{ + err := s.app.LendKeeper.AddAssetRatesParams(s.ctx, types.AssetRatesParams{ AssetID: AssetID, UOptimal: UOptimal, Base: Base, diff --git a/x/lend/keeper/lend.go b/x/lend/keeper/lend.go index a8a3c2a4f..8983dbf15 100644 --- a/x/lend/keeper/lend.go +++ b/x/lend/keeper/lend.go @@ -1,16 +1,18 @@ package keeper import ( + "sort" + sdk "github.com/cosmos/cosmos-sdk/types" protobuftypes "github.com/gogo/protobuf/types" "github.com/comdex-official/comdex/x/lend/types" ) -func (k Keeper) SetUserLendIDHistory(ctx sdk.Context, id uint64) { +func (k Keeper) SetUserLendIDCounter(ctx sdk.Context, id uint64) { var ( store = k.Store(ctx) - key = types.LendHistoryIDPrefix + key = types.LendCounterIDPrefix value = k.cdc.MustMarshal( &protobuftypes.UInt64Value{ Value: id, @@ -20,10 +22,10 @@ func (k Keeper) SetUserLendIDHistory(ctx sdk.Context, id uint64) { store.Set(key, value) } -func (k Keeper) GetUserLendIDHistory(ctx sdk.Context) uint64 { +func (k Keeper) GetUserLendIDCounter(ctx sdk.Context) uint64 { var ( store = k.Store(ctx) - key = types.LendHistoryIDPrefix + key = types.LendCounterIDPrefix value = store.Get(key) ) @@ -215,175 +217,35 @@ func (k Keeper) GetAllAssetToPair(ctx sdk.Context) (assetToPairMapping []types.A return assetToPairMapping } -func (k Keeper) SetLendForAddressByAsset(ctx sdk.Context, address sdk.AccAddress, assetID, id, poolID uint64) { +func (k Keeper) SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, PoolAssetLBMapping types.PoolAssetLBMapping) { var ( store = k.Store(ctx) - key = types.LendForAddressByAsset(address, assetID, poolID) - value = k.cdc.MustMarshal( - &protobuftypes.UInt64Value{ - Value: id, - }, - ) + key = types.SetAssetStatsByPoolIDAndAssetID(PoolAssetLBMapping.PoolID, PoolAssetLBMapping.AssetID) + value = k.cdc.MustMarshal(&PoolAssetLBMapping) ) store.Set(key, value) } -func (k Keeper) HasLendForAddressByAsset(ctx sdk.Context, address sdk.AccAddress, assetID, poolID uint64) bool { - var ( - store = k.Store(ctx) - key = types.LendForAddressByAsset(address, assetID, poolID) - ) - - return store.Has(key) -} - -func (k Keeper) DeleteLendForAddressByAsset(ctx sdk.Context, address sdk.AccAddress, assetID, poolID uint64) { +func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBMapping types.PoolAssetLBMapping, found bool) { var ( store = k.Store(ctx) - key = types.LendForAddressByAsset(address, assetID, poolID) - ) - - store.Delete(key) -} - -func (k Keeper) UpdateUserLendIDMapping( - ctx sdk.Context, - lendOwner string, - lendID uint64, - isInsert bool, -) error { - userVaults, found := k.GetUserLends(ctx, lendOwner) - - if !found && isInsert { - userVaults = types.UserLendIdMapping{ - Owner: lendOwner, - LendIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userVaults.LendIDs = append(userVaults.LendIDs, lendID) - } else { - for index, id := range userVaults.LendIDs { - if id == lendID { - userVaults.LendIDs = append(userVaults.LendIDs[:index], userVaults.LendIDs[index+1:]...) - break - } - } - } - - k.SetUserLends(ctx, userVaults) - return nil -} - -func (k Keeper) GetUserLends(ctx sdk.Context, address string) (userVaults types.UserLendIdMapping, found bool) { - var ( - store = k.Store(ctx) - key = types.UserLendsForAddressKey(address) + key = types.SetAssetStatsByPoolIDAndAssetID(poolID, assetID) value = store.Get(key) ) - if value == nil { - return userVaults, false - } - k.cdc.MustUnmarshal(value, &userVaults) - - return userVaults, true -} - -func (k Keeper) GetAllUserLends(ctx sdk.Context) (userLendIDMapping []types.UserLendIdMapping) { - var ( - store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.UserLendsForAddressKeyPrefix) - ) - - defer func(iter sdk.Iterator) { - err := iter.Close() - if err != nil { - return - } - }(iter) - - for ; iter.Valid(); iter.Next() { - var asset types.UserLendIdMapping - k.cdc.MustUnmarshal(iter.Value(), &asset) - userLendIDMapping = append(userLendIDMapping, asset) - } - return userLendIDMapping -} - -func (k Keeper) UserLends(ctx sdk.Context, address string) (userLends []types.LendAsset, found bool) { - userLendID, _ := k.GetUserLends(ctx, address) - for _, v := range userLendID.LendIDs { - userLend, _ := k.GetLend(ctx, v) - userLends = append(userLends, userLend) - } - return userLends, true -} - -func (k Keeper) SetUserLends(ctx sdk.Context, userVaults types.UserLendIdMapping) { - var ( - store = k.Store(ctx) - key = types.UserLendsForAddressKey(userVaults.Owner) - value = k.cdc.MustMarshal(&userVaults) - ) - store.Set(key, value) -} - -func (k Keeper) UpdateLendIDByOwnerAndPoolMapping( - ctx sdk.Context, - lendOwner string, - lendID uint64, - poolID uint64, - isInsert bool, -) error { - userLends, found := k.GetLendIDByOwnerAndPool(ctx, lendOwner, poolID) - - if !found && isInsert { - userLends = types.LendIdByOwnerAndPoolMapping{ - Owner: lendOwner, - PoolID: poolID, - LendIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userLends.LendIDs = append(userLends.LendIDs, lendID) - } else { - for index, id := range userLends.LendIDs { - if id == lendID { - userLends.LendIDs = append(userLends.LendIDs[:index], userLends.LendIDs[index+1:]...) - break - } - } - } - k.SetLendIDByOwnerAndPool(ctx, userLends) - return nil -} - -func (k Keeper) GetLendIDByOwnerAndPool(ctx sdk.Context, address string, poolID uint64) (userLends types.LendIdByOwnerAndPoolMapping, found bool) { - var ( - store = k.Store(ctx) - key = types.LendByUserAndPoolKey(address, poolID) - value = store.Get(key) - ) if value == nil { - return userLends, false + return PoolAssetLBMapping, false } - k.cdc.MustUnmarshal(value, &userLends) - return userLends, true + k.cdc.MustUnmarshal(value, &PoolAssetLBMapping) + return PoolAssetLBMapping, true } -func (k Keeper) GetAllLendIDByOwnerAndPool(ctx sdk.Context) (lendIDByOwnerAndPoolMapping []types.LendIdByOwnerAndPoolMapping) { +func (k Keeper) GetAllAssetStatsByPoolIDAndAssetID(ctx sdk.Context) (assetStats []types.PoolAssetLBMapping) { var ( store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.LendByUserAndPoolPrefix) + iter = sdk.KVStorePrefixIterator(store, types.AssetStatsByPoolIDAndAssetIDKeyPrefix) ) defer func(iter sdk.Iterator) { @@ -394,147 +256,77 @@ func (k Keeper) GetAllLendIDByOwnerAndPool(ctx sdk.Context) (lendIDByOwnerAndPoo }(iter) for ; iter.Valid(); iter.Next() { - var asset types.LendIdByOwnerAndPoolMapping + var asset types.PoolAssetLBMapping k.cdc.MustUnmarshal(iter.Value(), &asset) - lendIDByOwnerAndPoolMapping = append(lendIDByOwnerAndPoolMapping, asset) + assetStats = append(assetStats, asset) } - return lendIDByOwnerAndPoolMapping + return assetStats } -func (k Keeper) LendIDByOwnerAndPool(ctx sdk.Context, address string, poolID uint64) (userLends []types.LendAsset, found bool) { - userLendID, _ := k.GetLendIDByOwnerAndPool(ctx, address, poolID) - for _, v := range userLendID.LendIDs { - userLend, _ := k.GetLend(ctx, v) - userLends = append(userLends, userLend) +func (k Keeper) AssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBMapping types.PoolAssetLBMapping, found bool) { + PoolAssetLBMapping, found = k.UpdateAPR(ctx, poolID, assetID) + if !found { + return PoolAssetLBMapping, false } - return userLends, true + return PoolAssetLBMapping, true } -func (k Keeper) SetLendIDByOwnerAndPool(ctx sdk.Context, userLends types.LendIdByOwnerAndPoolMapping) { - var ( - store = k.Store(ctx) - key = types.LendByUserAndPoolKey(userLends.Owner, userLends.PoolID) - value = k.cdc.MustMarshal(&userLends) - ) - store.Set(key, value) -} - -func (k Keeper) SetLendIDToBorrowIDMapping(ctx sdk.Context, lendIDToBorrowIDMapping types.LendIdToBorrowIdMapping) { +func (k Keeper) SetLendRewardTracker(ctx sdk.Context, rewards types.LendRewardsTracker) { var ( store = k.Store(ctx) - key = types.LendIDToBorrowIDMappingKey(lendIDToBorrowIDMapping.LendingID) - value = k.cdc.MustMarshal(&lendIDToBorrowIDMapping) + key = types.LendRewardsTrackerKey(rewards.LendingId) + value = k.cdc.MustMarshal(&rewards) ) store.Set(key, value) } -func (k Keeper) UpdateLendIDToBorrowIDMapping( - ctx sdk.Context, - lendID uint64, - borrowID uint64, - isInsert bool, -) error { - lendIDToBorrowIDMapping, found := k.GetLendIDToBorrowIDMapping(ctx, lendID) - - if !found && isInsert { - lendIDToBorrowIDMapping = types.LendIdToBorrowIdMapping{ - LendingID: lendID, - BorrowingID: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - lendIDToBorrowIDMapping.BorrowingID = append(lendIDToBorrowIDMapping.BorrowingID, borrowID) - } else { - for index, id := range lendIDToBorrowIDMapping.BorrowingID { - if id == borrowID { - lendIDToBorrowIDMapping.BorrowingID = append(lendIDToBorrowIDMapping.BorrowingID[:index], lendIDToBorrowIDMapping.BorrowingID[index+1:]...) - break - } - } - } - - k.SetLendIDToBorrowIDMapping(ctx, lendIDToBorrowIDMapping) - return nil -} - -func (k Keeper) GetLendIDToBorrowIDMapping(ctx sdk.Context, id uint64) (lendIDToBorrowIDMapping types.LendIdToBorrowIdMapping, found bool) { +func (k Keeper) GetLendRewardTracker(ctx sdk.Context, id uint64) (rewards types.LendRewardsTracker, found bool) { var ( store = k.Store(ctx) - key = types.LendIDToBorrowIDMappingKey(id) + key = types.LendRewardsTrackerKey(id) value = store.Get(key) ) if value == nil { - return lendIDToBorrowIDMapping, false - } - - k.cdc.MustUnmarshal(value, &lendIDToBorrowIDMapping) - return lendIDToBorrowIDMapping, true -} - -func (k Keeper) GetAllLendIDToBorrowIDMapping(ctx sdk.Context) (lendIDToBorrowIdMapping []types.LendIdToBorrowIdMapping) { - var ( - store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.LendIDToBorrowIDMappingKeyPrefix) - ) - - defer func(iter sdk.Iterator) { - err := iter.Close() - if err != nil { - return - } - }(iter) - - for ; iter.Valid(); iter.Next() { - var asset types.LendIdToBorrowIdMapping - k.cdc.MustUnmarshal(iter.Value(), &asset) - lendIDToBorrowIdMapping = append(lendIDToBorrowIdMapping, asset) + return rewards, false } - return lendIDToBorrowIdMapping -} - -func (k Keeper) DeleteLendIDToBorrowIDMapping(ctx sdk.Context, lendingID uint64) { - var ( - store = k.Store(ctx) - key = types.LendIDToBorrowIDMappingKey(lendingID) - ) - store.Delete(key) + k.cdc.MustUnmarshal(value, &rewards) + return rewards, true } -func (k Keeper) SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, AssetStats types.AssetStats) { +// only called while borrowing +func (k Keeper) SetUserLendBorrowMapping(ctx sdk.Context, userMapping types.UserAssetLendBorrowMapping) { var ( store = k.Store(ctx) - key = types.SetAssetStatsByPoolIDAndAssetID(AssetStats.AssetID, AssetStats.PoolID) - value = k.cdc.MustMarshal(&AssetStats) + key = types.UserLendBorrowMappingKey(userMapping.Owner, userMapping.LendId) + value = k.cdc.MustMarshal(&userMapping) ) store.Set(key, value) } -func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID uint64) (AssetStats types.AssetStats, found bool) { +func (k Keeper) GetUserLendBorrowMapping(ctx sdk.Context, owner string, lendID uint64) (userMapping types.UserAssetLendBorrowMapping, found bool) { var ( store = k.Store(ctx) - key = types.SetAssetStatsByPoolIDAndAssetID(assetID, poolID) + key = types.UserLendBorrowMappingKey(owner, lendID) value = store.Get(key) ) if value == nil { - return AssetStats, false + return userMapping, false } - k.cdc.MustUnmarshal(value, &AssetStats) - return AssetStats, true + k.cdc.MustUnmarshal(value, &userMapping) + return userMapping, true } -func (k Keeper) GetAllAssetStatsByPoolIDAndAssetID(ctx sdk.Context) (assetStats []types.AssetStats) { +func (k Keeper) GetUserTotalMappingData(ctx sdk.Context, address string) (mappingData []types.UserAssetLendBorrowMapping) { var ( store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.AssetStatsByPoolIDAndAssetIDKeyPrefix) + key = types.UserLendBorrowKey(address) + iter = sdk.KVStorePrefixIterator(store, key) ) defer func(iter sdk.Iterator) { @@ -545,214 +337,92 @@ func (k Keeper) GetAllAssetStatsByPoolIDAndAssetID(ctx sdk.Context) (assetStats }(iter) for ; iter.Valid(); iter.Next() { - var asset types.AssetStats - k.cdc.MustUnmarshal(iter.Value(), &asset) - assetStats = append(assetStats, asset) + var mapData types.UserAssetLendBorrowMapping + k.cdc.MustUnmarshal(iter.Value(), &mapData) + mappingData = append(mappingData, mapData) } - return assetStats -} -func (k Keeper) AssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID uint64) (AssetStats types.AssetStats, found bool) { - AssetStats, found = k.UpdateAPR(ctx, poolID, assetID) - if !found { - return AssetStats, false - } - return AssetStats, true + return mappingData } -func (k Keeper) UpdateLendIDsMapping( - ctx sdk.Context, - lendID uint64, - isInsert bool, -) error { - userVaults, found := k.GetLends(ctx) - - if !found && isInsert { - userVaults = types.LendMapping{ - LendIDs: nil, - } - } else if !found && !isInsert { - return types.ErrorLendOwnerNotFound - } - - if isInsert { - userVaults.LendIDs = append(userVaults.LendIDs, lendID) - } else { - for index, id := range userVaults.LendIDs { - if id == lendID { - userVaults.LendIDs = append(userVaults.LendIDs[:index], userVaults.LendIDs[index+1:]...) - break +func (k Keeper) HasLendForAddressByAsset(ctx sdk.Context, address string, assetID, poolID uint64) bool { + mappingData := k.GetUserTotalMappingData(ctx, address) + for _, data := range mappingData { + if data.PoolId == poolID { + lend, _ := k.GetLend(ctx, data.LendId) + if lend.AssetID == assetID { + return true } } } - - k.SetLends(ctx, userVaults) - return nil + return false } -func (k Keeper) GetLends(ctx sdk.Context) (userVaults types.LendMapping, found bool) { +func (k Keeper) DeleteLendForAddressByAsset(ctx sdk.Context, address string, lendingID uint64) { var ( store = k.Store(ctx) - key = types.LendsKey - value = store.Get(key) - ) - if value == nil { - return userVaults, false - } - k.cdc.MustUnmarshal(value, &userVaults) - - return userVaults, true -} - -func (k Keeper) SetLends(ctx sdk.Context, userLends types.LendMapping) { - var ( - store = k.Store(ctx) - key = types.LendsKey - value = k.cdc.MustMarshal(&userLends) - ) - store.Set(key, value) -} - -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.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 -} - -func (k Keeper) SetUserDepositStats(ctx sdk.Context, depositStats types.DepositStats) { - var ( - store = k.Store(ctx) - key = types.UserDepositStatsPrefix - value = k.cdc.MustMarshal(&depositStats) - ) - - store.Set(key, value) -} - -func (k Keeper) GetUserDepositStats(ctx sdk.Context) (depositStats types.DepositStats, found bool) { - var ( - store = k.Store(ctx) - key = types.UserDepositStatsPrefix - value = store.Get(key) + key = types.UserLendBorrowMappingKey(address, lendingID) ) - if value == nil { - return depositStats, false - } - - k.cdc.MustUnmarshal(value, &depositStats) - return depositStats, true + store.Delete(key) } -func (k Keeper) SetReserveDepositStats(ctx sdk.Context, depositStats types.DepositStats) { - var ( - store = k.Store(ctx) - key = types.ReserveDepositStatsPrefix - value = k.cdc.MustMarshal(&depositStats) - ) - - store.Set(key, value) -} +func (k Keeper) DeleteIDFromAssetStatsMapping(ctx sdk.Context, poolID, assetID, id uint64, typeOfId bool) { + poolLBMappingData, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) + if typeOfId { + lengthOfIDs := len(poolLBMappingData.LendIds) -func (k Keeper) GetReserveDepositStats(ctx sdk.Context) (depositStats types.DepositStats, found bool) { - var ( - store = k.Store(ctx) - key = types.ReserveDepositStatsPrefix - value = store.Get(key) - ) + dataIndex := sort.Search(lengthOfIDs, func(i int) bool { return poolLBMappingData.LendIds[i] >= id }) - if value == nil { - return depositStats, false - } - - k.cdc.MustUnmarshal(value, &depositStats) - return depositStats, true -} - -func (k Keeper) SetBuyBackDepositStats(ctx sdk.Context, depositStats types.DepositStats) { - var ( - store = k.Store(ctx) - key = types.BuyBackDepositStatsPrefix - value = k.cdc.MustMarshal(&depositStats) - ) - - store.Set(key, value) -} + if dataIndex < lengthOfIDs && poolLBMappingData.LendIds[dataIndex] == id { + poolLBMappingData.LendIds = append(poolLBMappingData.LendIds[:dataIndex], poolLBMappingData.LendIds[dataIndex+1:]...) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolLBMappingData) + } + } else { + lengthOfIDs := len(poolLBMappingData.BorrowIds) -func (k Keeper) GetBuyBackDepositStats(ctx sdk.Context) (depositStats types.DepositStats, found bool) { - var ( - store = k.Store(ctx) - key = types.BuyBackDepositStatsPrefix - value = store.Get(key) - ) + dataIndex := sort.Search(lengthOfIDs, func(i int) bool { return poolLBMappingData.BorrowIds[i] >= id }) - if value == nil { - return depositStats, false + if dataIndex < lengthOfIDs && poolLBMappingData.BorrowIds[dataIndex] == id { + poolLBMappingData.BorrowIds = append(poolLBMappingData.BorrowIds[:dataIndex], poolLBMappingData.BorrowIds[dataIndex+1:]...) + k.SetAssetStatsByPoolIDAndAssetID(ctx, poolLBMappingData) + } } - - k.cdc.MustUnmarshal(value, &depositStats) - return depositStats, true } -func (k Keeper) SetBorrowStats(ctx sdk.Context, borrowStats types.DepositStats) { +func (k Keeper) SetReserveBuybackAssetData(ctx sdk.Context, reserve types.ReserveBuybackAssetData) { var ( store = k.Store(ctx) - key = types.BorrowStatsPrefix - value = k.cdc.MustMarshal(&borrowStats) + key = types.ReserveBuybackAssetDataKey(reserve.AssetID) + value = k.cdc.MustMarshal(&reserve) ) store.Set(key, value) } -func (k Keeper) GetBorrowStats(ctx sdk.Context) (borrowStats types.DepositStats, found bool) { +func (k Keeper) GetReserveBuybackAssetData(ctx sdk.Context, id uint64) (reserve types.ReserveBuybackAssetData, found bool) { var ( store = k.Store(ctx) - key = types.BorrowStatsPrefix + key = types.ReserveBuybackAssetDataKey(id) value = store.Get(key) ) if value == nil { - return borrowStats, false + return reserve, false } - k.cdc.MustUnmarshal(value, &borrowStats) - return borrowStats, true + k.cdc.MustUnmarshal(value, &reserve) + return reserve, true } -func (k Keeper) SetLendRewardTracker(ctx sdk.Context, rewards types.LendRewardsTracker) { - var ( - store = k.Store(ctx) - key = types.LendRewardsTrackerKey(rewards.LendingId) - value = k.cdc.MustMarshal(&rewards) - ) +func (k Keeper) DeleteBorrowIDFromUserMapping(ctx sdk.Context, owner string, lendID, borrowID uint64) { + userData, _ := k.GetUserLendBorrowMapping(ctx, owner, lendID) + lengthOfIDs := len(userData.BorrowId) - store.Set(key, value) -} + dataIndex := sort.Search(lengthOfIDs, func(i int) bool { return userData.BorrowId[i] >= borrowID }) -func (k Keeper) GetLendRewardTracker(ctx sdk.Context, id uint64) (rewards types.LendRewardsTracker, found bool) { - var ( - store = k.Store(ctx) - key = types.LendRewardsTrackerKey(id) - value = store.Get(key) - ) - - if value == nil { - return rewards, false + if dataIndex < lengthOfIDs && userData.BorrowId[dataIndex] == borrowID { + userData.BorrowId = append(userData.BorrowId[:dataIndex], userData.BorrowId[dataIndex+1:]...) + k.SetUserLendBorrowMapping(ctx, userData) } - - k.cdc.MustUnmarshal(value, &rewards) - return rewards, true } diff --git a/x/lend/keeper/maths.go b/x/lend/keeper/maths.go index 1a2121bb6..0cb2cb524 100644 --- a/x/lend/keeper/maths.go +++ b/x/lend/keeper/maths.go @@ -10,7 +10,7 @@ func (k Keeper) GetUtilisationRatioByPoolIDAndAssetID(ctx sdk.Context, poolID, a pool, _ := k.GetPool(ctx, poolID) asset, _ := k.GetAsset(ctx, assetID) moduleBalance := k.ModuleBalance(ctx, pool.ModuleName, asset.Denom) - assetStats, found := k.GetAssetStatsByPoolIDAndAssetID(ctx, assetID, poolID) + assetStats, found := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) if !found { return sdk.ZeroDec(), types.ErrAssetStatsNotFound } @@ -22,7 +22,7 @@ func (k Keeper) GetUtilisationRatioByPoolIDAndAssetID(ctx sdk.Context, poolID, a } func (k Keeper) GetBorrowAPRByAssetID(ctx sdk.Context, poolID, assetID uint64, IsStableBorrow bool) (borrowAPY sdk.Dec, err error) { - assetRatesStats, found := k.GetAssetRatesStats(ctx, assetID) + assetRatesStats, found := k.GetAssetRatesParams(ctx, assetID) if !found { return sdk.ZeroDec(), types.ErrorAssetStatsNotFound } @@ -59,7 +59,7 @@ func (k Keeper) GetBorrowAPRByAssetID(ctx sdk.Context, poolID, assetID uint64, I } func (k Keeper) GetLendAPRByAssetIDAndPoolID(ctx sdk.Context, poolID, assetID uint64) (lendAPY sdk.Dec, err error) { - assetRatesStats, found := k.GetAssetRatesStats(ctx, assetID) + assetRatesStats, found := k.GetAssetRatesParams(ctx, assetID) if !found { return sdk.ZeroDec(), types.ErrorAssetStatsNotFound } @@ -92,7 +92,10 @@ func (k Keeper) GetAverageBorrowRate(ctx sdk.Context, poolID, assetID uint64) (s } func (k Keeper) GetSavingRate(ctx sdk.Context, poolID, assetID uint64) (savingRate sdk.Dec, err error) { - assetRatesStats, _ := k.GetAssetRatesStats(ctx, assetID) + assetRatesStats, found := k.GetAssetRatesParams(ctx, assetID) + if !found { + return sdk.ZeroDec(), types.ErrorAssetRatesParamsNotFound + } averageBorrowRate, err := k.GetAverageBorrowRate(ctx, poolID, assetID) if err != nil { return sdk.Dec{}, err @@ -122,25 +125,27 @@ func (k Keeper) GetReserveRate(ctx sdk.Context, poolID, assetID uint64) (reserve return sdk.ZeroDec(), nil } -func (k Keeper) UpdateAPR(ctx sdk.Context, poolID, assetID uint64) (AssetStats types.AssetStats, found bool) { - assetStats, found := k.GetAssetStatsByPoolIDAndAssetID(ctx, assetID, poolID) +func (k Keeper) UpdateAPR(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBData types.PoolAssetLBMapping, found bool) { + poolAssetLBData, found := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) if !found { - return assetStats, false + return poolAssetLBData, false } lendAPR, _ := k.GetLendAPRByAssetIDAndPoolID(ctx, poolID, assetID) borrowAPR, _ := k.GetBorrowAPRByAssetID(ctx, poolID, assetID, false) stableBorrowAPR, _ := k.GetBorrowAPRByAssetID(ctx, poolID, assetID, true) currentUtilisationRatio, _ := k.GetUtilisationRatioByPoolIDAndAssetID(ctx, poolID, assetID) - AssetStats = types.AssetStats{ - PoolID: assetStats.PoolID, - AssetID: assetStats.AssetID, - TotalBorrowed: assetStats.TotalBorrowed, - TotalStableBorrowed: assetStats.TotalStableBorrowed, - TotalLend: assetStats.TotalLend, + PoolAssetLBData = types.PoolAssetLBMapping{ + PoolID: poolAssetLBData.PoolID, + AssetID: poolAssetLBData.AssetID, + LendIds: poolAssetLBData.LendIds, + BorrowIds: poolAssetLBData.BorrowIds, + TotalBorrowed: poolAssetLBData.TotalBorrowed, + TotalStableBorrowed: poolAssetLBData.TotalStableBorrowed, + TotalLend: poolAssetLBData.TotalLend, LendApr: lendAPR, BorrowApr: borrowAPR, StableBorrowApr: stableBorrowAPR, UtilisationRatio: currentUtilisationRatio, } - return AssetStats, true + return PoolAssetLBData, true } diff --git a/x/lend/keeper/msg_server.go b/x/lend/keeper/msg_server.go index 3dbc0293d..111a3e259 100644 --- a/x/lend/keeper/msg_server.go +++ b/x/lend/keeper/msg_server.go @@ -157,7 +157,7 @@ func (m msgServer) FundModuleAccounts(goCtx context.Context, accounts *types.Msg 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.ModuleName, accounts.AssetId, lenderAddr, accounts.Amount); err != nil { return nil, err } diff --git a/x/lend/keeper/msg_server_test.go b/x/lend/keeper/msg_server_test.go index f71389fd5..3aeb4b7a6 100644 --- a/x/lend/keeper/msg_server_test.go +++ b/x/lend/keeper/msg_server_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "time" "github.com/comdex-official/comdex/x/lend/types" @@ -9,41 +10,44 @@ import ( ) func (s *KeeperTestSuite) TestMsgLend() { - assetOneID := s.CreateNewAsset("ASSET1", "uasset1", 1000000) - assetTwoID := s.CreateNewAsset("ASSET2", "uasset2", 2000000) - assetThreeID := s.CreateNewAsset("ASSET3", "uasset3", 2000000) - assetFourID := s.CreateNewAsset("ASSET4", "uasset4", 2000000) - cAssetOneID := s.CreateNewAsset("CASSET1", "ucasset1", 1000000) - cAssetTwoID := s.CreateNewAsset("CASSET2", "ucasset2", 2000000) - cAssetThreeID := s.CreateNewAsset("CASSET3", "ucasset3", 2000000) - // cAssetFourID := s.CreateNewAsset("CASSET4", "ucasset4", 2000000) + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) var ( - assetDataPoolOne []types.AssetDataPoolMapping - assetDataPoolTwo []types.AssetDataPoolMapping + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping ) - assetDataPoolOneAssetOne := types.AssetDataPoolMapping{ - AssetID: assetOneID, - IsBridged: false, + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), } - assetDataPoolOneAssetTwo := types.AssetDataPoolMapping{ - AssetID: assetTwoID, - IsBridged: true, + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), } - assetDataPoolOneAssetThree := types.AssetDataPoolMapping{ - AssetID: assetThreeID, - IsBridged: true, + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), } - assetDataPoolTwoAssetFour := types.AssetDataPoolMapping{ - AssetID: assetFourID, - IsBridged: true, + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), } - assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) - poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetOneID, assetTwoID, assetThreeID, assetDataPoolOne) - poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetFourID, assetTwoID, assetThreeID, assetDataPoolTwo) + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) @@ -79,6 +83,31 @@ 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(300)), poolOneID, appOneID) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, err := s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + fmt.Println("err", err) + testCases := []struct { Name string Msg types.MsgLend @@ -145,7 +174,7 @@ func (s *KeeperTestSuite) TestMsgLend() { { Name: "Asset Rates Stats not found", Msg: *types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetFourID, sdk.NewCoin("uasset4", sdk.NewInt(100)), poolTwoID, appOneID), - ExpErr: sdkerrors.Wrapf(types.ErrorAssetRatesStatsNotFound, "4"), + ExpErr: sdkerrors.Wrapf(types.ErrorAssetRatesParamsNotFound, "4"), ExpResp: nil, QueryResponseIndex: 0, QueryResponse: nil, @@ -153,22 +182,39 @@ func (s *KeeperTestSuite) TestMsgLend() { }, { Name: "success valid case", - Msg: *types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), poolOneID, appOneID), + Msg: *types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), poolTwoID, appOneID), + ExpErr: nil, + ExpResp: &types.MsgLendResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.LendAsset{ + ID: 2, + AssetID: assetOneID, + PoolID: poolTwoID, + Owner: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + AmountIn: sdk.NewCoin("uasset1", sdk.NewInt(100)), + LendingTime: time.Time{}, + AvailableToBorrow: sdk.NewInt(100), + AppID: appOneID, + CPoolName: "OSMO-ATOM-CMST", + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("ucasset1", newInt(100))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgLend("cosmos14edpcw6ptcqd2vct9rkjf7lgyvrlwdtd0rqrtx", assetTwoID, sdk.NewCoin("uasset2", sdk.NewInt(100)), poolOneID, appOneID), ExpErr: nil, ExpResp: &types.MsgLendResponse{}, QueryResponseIndex: 0, QueryResponse: &types.LendAsset{ - ID: 1, - AssetID: assetOneID, - PoolID: poolOneID, - Owner: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", - AmountIn: sdk.NewCoin("uasset1", sdk.NewInt(100)), - LendingTime: time.Time{}, - UpdatedAmountIn: sdk.NewInt(100), - AvailableToBorrow: sdk.NewInt(100), - Reward_Accumulated: sdk.NewInt(0), - AppID: appOneID, - CPoolName: "OSMO-ATOM-CMST", + ID: 3, + AssetID: assetOneID, + PoolID: poolOneID, + Owner: "cosmos14edpcw6ptcqd2vct9rkjf7lgyvrlwdtd0rqrtx", + AmountIn: sdk.NewCoin("uasset1", sdk.NewInt(100)), + LendingTime: time.Time{}, + AvailableToBorrow: sdk.NewInt(100), + AppID: appOneID, + CPoolName: "OSMO-ATOM-CMST", }, AvailableBalance: sdk.NewCoins(sdk.NewCoin("ucasset1", newInt(100))), }, @@ -187,7 +233,7 @@ func (s *KeeperTestSuite) TestMsgLend() { s.Run(tc.Name, func() { // add funds to acount for valid case if tc.ExpErr == nil { - s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Lender), sdk.NewCoins(sdk.NewCoin("uasset1", tc.Msg.Amount.Amount))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Lender), sdk.NewCoins(sdk.NewCoin("uasset1", tc.Msg.Amount.Amount), sdk.NewCoin("uasset2", tc.Msg.Amount.Amount))) } ctx := sdk.WrapSDKContext(s.ctx) @@ -201,8 +247,8 @@ func (s *KeeperTestSuite) TestMsgLend() { s.Require().NotNil(resp) s.Require().Equal(tc.ExpResp, resp) - availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) - s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) } }) } @@ -211,39 +257,43 @@ func (s *KeeperTestSuite) TestMsgLend() { func (s *KeeperTestSuite) TestMsgWithdraw() { assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) - assetThreeID := s.CreateNewAsset("ASSETHREE", "uasset3", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) - cAssetOneID := s.CreateNewAsset("CASSET1", "ucasset1", 1000000) - cAssetTwoID := s.CreateNewAsset("CASSET2", "ucasset2", 2000000) - cAssetThreeID := s.CreateNewAsset("CASSET3", "ucasset3", 2000000) - // cAssetFourID := s.CreateNewAsset("CASSET4", "ucasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) var ( - assetDataPoolOne []types.AssetDataPoolMapping - assetDataPoolTwo []types.AssetDataPoolMapping + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping ) - assetDataPoolOneAssetOne := types.AssetDataPoolMapping{ - AssetID: assetOneID, - IsBridged: false, + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), } - assetDataPoolOneAssetTwo := types.AssetDataPoolMapping{ - AssetID: assetTwoID, - IsBridged: true, + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), } - assetDataPoolOneAssetThree := types.AssetDataPoolMapping{ - AssetID: assetThreeID, - IsBridged: true, + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), } - assetDataPoolTwoAssetFour := types.AssetDataPoolMapping{ - AssetID: assetFourID, - IsBridged: true, + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), } assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) - poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetOneID, assetTwoID, assetThreeID, assetDataPoolOne) - poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetFourID, assetTwoID, assetThreeID, assetDataPoolTwo) + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) @@ -279,8 +329,12 @@ func (s *KeeperTestSuite) TestMsgWithdraw() { appOneID := s.CreateNewApp("commodo", "cmmdo") msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(100)), poolOneID, appOneID) + msg2 := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetTwoID, sdk.NewCoin("uasset2", newInt(100)), poolOneID, appOneID) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100)))) - s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg2) testCases := []struct { Name string @@ -288,18 +342,192 @@ func (s *KeeperTestSuite) TestMsgWithdraw() { ExpErr error ExpResp *types.MsgWithdrawResponse QueryResponseIndex uint64 - QueryResponse *types.LendAsset + QueryResponse *types.MsgWithdraw AvailableBalance sdk.Coins }{ + { + Name: "Lend Position not found", + Msg: *types.NewMsgWithdraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 3, sdk.NewCoin("uasset1", sdk.NewInt(100))), + ExpErr: types.ErrLendNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgWithdraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", sdk.NewInt(10))), + ExpErr: sdkerrors.Wrap(types.ErrBadOfferCoinAmount, "uasset2"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + }, { Name: "Withdraw Amount Limit Exceeded", - Msg: *types.NewMsgWithdraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset1", sdk.NewInt(100))), + Msg: *types.NewMsgWithdraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset1", sdk.NewInt(101))), ExpErr: types.ErrWithdrawAmountLimitExceeds, ExpResp: nil, QueryResponseIndex: 0, QueryResponse: nil, + }, + { + Name: "success valid case", + Msg: *types.NewMsgWithdraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset1", sdk.NewInt(10))), + ExpErr: nil, + ExpResp: &types.MsgWithdrawResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgWithdraw{ + Lender: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + Amount: sdk.NewCoin("uasset1", sdk.NewInt(10)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(10)), sdk.NewCoin("ucasset1", newInt(90)), sdk.NewCoin("ucasset2", newInt(100))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + //if tc.ExpErr == nil { + // s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Lender), sdk.NewCoins(sdk.NewCoin("uasset1", tc.Msg.Amount.Amount))) + //} + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.Withdraw(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgDeposit() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + // s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(100)), poolOneID, appOneID) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + + testCases := []struct { + Name string + Msg types.MsgDeposit + ExpErr error + ExpResp *types.MsgDepositResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgDeposit + AvailableBalance sdk.Coins + }{ + { + Name: "Lend Position not found", + Msg: *types.NewMsgDeposit("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2, sdk.NewCoin("uasset1", sdk.NewInt(100))), + ExpErr: types.ErrLendNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgDeposit("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", sdk.NewInt(100))), + ExpErr: sdkerrors.Wrap(types.ErrBadOfferCoinAmount, "uasset2"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), }, + { + Name: "success valid case", + Msg: *types.NewMsgDeposit("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset1", sdk.NewInt(10))), + ExpErr: nil, + ExpResp: &types.MsgDepositResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgDeposit{ + Lender: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + Amount: sdk.NewCoin("uasset2", sdk.NewInt(10)), + }, + // AvailableBalance: sdk.NewCoins(sdk.NewCoin("ucasset1", newInt(90))), + }, } for _, tc := range testCases { tc := tc @@ -310,7 +538,7 @@ func (s *KeeperTestSuite) TestMsgWithdraw() { } ctx := sdk.WrapSDKContext(s.ctx) - resp, err := s.msgServer.Withdraw(ctx, &tc.Msg) + resp, err := s.msgServer.Deposit(ctx, &tc.Msg) if tc.ExpErr != nil { s.Require().Error(err) s.Require().EqualError(err, tc.ExpErr.Error()) @@ -320,8 +548,1687 @@ func (s *KeeperTestSuite) TestMsgWithdraw() { s.Require().NotNil(resp) s.Require().Equal(tc.ExpResp, resp) - availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) - s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgCloseLend() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + // s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + msg := types.NewMsgLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, sdk.NewCoin("uasset1", newInt(100)), poolOneID, appOneID) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + + testCases := []struct { + Name string + Msg types.MsgCloseLend + ExpErr error + ExpResp *types.MsgCloseLendResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgCloseLend + AvailableBalance sdk.Coins + }{ + { + Name: "Lend Position not found", + Msg: *types.NewMsgCloseLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2), + ExpErr: types.ErrLendNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgCloseLend("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1), + ExpErr: nil, + ExpResp: &types.MsgCloseLendResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgCloseLend{ + Lender: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + }, + // AvailableBalance: sdk.NewCoins(sdk.NewCoin("ucasset1", newInt(90))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Lender), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(100)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.CloseLend(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgBorrow() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(1000000000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(1000000000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(1000000000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(1000000000000000)))) + + 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))) + + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + + testCases := []struct { + Name string + Msg types.MsgBorrow + ExpErr error + ExpResp *types.MsgBorrowResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgBorrow + AvailableBalance sdk.Coins + }{ + { + Name: "Pair Not Found", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 90, false, sdk.NewCoin("uasset2", newInt(100)), sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrorPairNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Pair Not Found", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 18, false, sdk.NewCoin("uasset2", newInt(100)), sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrorPairNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid offer coin Type", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 1, false, sdk.NewCoin("uasset2", newInt(100)), sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrBadOfferCoinType, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Duplicate borrow Position", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))), + ExpErr: types.ErrorDuplicateBorrow, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Available To Borrow Insufficient", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 4, false, sdk.NewCoin("ucasset1", newInt(201)), sdk.NewCoin("uasset3", newInt(10))), + ExpErr: types.ErrAvailableToBorrowInsufficient, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid asset", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 4, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset1", newInt(10))), + ExpErr: types.ErrInvalidAsset, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Stable Borrow Rate Not Enabled for This Asset", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 4, true, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset3", newInt(10))), + ExpErr: sdkerrors.Wrap(types.ErrStableBorrowDisabled, "10uasset3"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Error Invalid Collaterallization Ratio", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 4, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset3", newInt(100))), + ExpErr: types.ErrorInvalidCollateralizationRatio, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Unauthorized User", + Msg: *types.NewMsgBorrow("cosmos14edpcw6ptcqd2vct9rkjf7lgyvrlwdtd0rqrtx", 1, 4, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset3", newInt(100))), + ExpErr: types.ErrLendAccessUnauthorized, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 4, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset3", newInt(10))), + ExpErr: nil, + ExpResp: &types.MsgBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + PairId: 4, + IsStableBorrow: false, + AmountIn: sdk.NewCoin("ucasset1", newInt(100)), + AmountOut: sdk.NewCoin("uasset3", newInt(10)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case 2", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 15, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset4", newInt(10))), + ExpErr: nil, + ExpResp: &types.MsgBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + PairId: 15, + IsStableBorrow: false, + AmountIn: sdk.NewCoin("ucasset1", newInt(100)), + AmountOut: sdk.NewCoin("uasset4", newInt(10)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case 3", + Msg: *types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2, 13, false, sdk.NewCoin("ucasset2", newInt(1000000000)), sdk.NewCoin("uasset4", newInt(100000000))), + ExpErr: nil, + ExpResp: &types.MsgBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 2, + PairId: 13, + IsStableBorrow: false, + AmountIn: sdk.NewCoin("ucasset2", newInt(1000000000)), + AmountOut: sdk.NewCoin("uasset4", newInt(100000000)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(300)))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("ucasset2", sdk.NewIntFromUint64(1000000000)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.Borrow(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgRepay() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + + testCases := []struct { + Name string + Msg types.MsgRepay + ExpErr error + ExpResp *types.MsgRepayResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgRepay + AvailableBalance sdk.Coins + }{ + { + Name: "Borrow Not Found", + Msg: *types.NewMsgRepay("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2, sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrBorrowNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgRepay("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset3", newInt(100))), + ExpErr: types.ErrBadOfferCoinAmount, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid repayment", + Msg: *types.NewMsgRepay("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrInvalidRepayment, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "different user", + Msg: *types.NewMsgRepay("cosmos14edpcw6ptcqd2vct9rkjf7lgyvrlwdtd0rqrtx", 1, sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrLendAccessUnauthorized, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgRepay("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", newInt(5))), + ExpErr: nil, + ExpResp: &types.MsgRepayResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgRepay{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + Amount: sdk.NewCoin("uasset2", newInt(5)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgRepay("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", newInt(5))), + ExpErr: nil, + ExpResp: &types.MsgRepayResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgRepay{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + Amount: sdk.NewCoin("uasset2", newInt(5)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(300)))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("ucasset2", sdk.NewIntFromUint64(1000000000)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.Repay(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgDepositBorrow() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + msgBorrow2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 15, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset4", newInt(10))) + + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msgBorrow2) + + testCases := []struct { + Name string + Msg types.MsgDepositBorrow + ExpErr error + ExpResp *types.MsgDepositBorrowResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgDepositBorrow + AvailableBalance sdk.Coins + }{ + { + Name: "Borrow Not Found", + Msg: *types.NewMsgDepositBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 12, sdk.NewCoin("ucasset1", newInt(100))), + ExpErr: types.ErrBorrowNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgDepositBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset3", newInt(100))), + ExpErr: sdkerrors.Wrap(types.ErrBadOfferCoinAmount, "uasset3"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Available To Borrow Insufficient", + Msg: *types.NewMsgDepositBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("ucasset1", newInt(201))), + ExpErr: types.ErrAvailableToBorrowInsufficient, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgDepositBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("ucasset1", newInt(5))), + ExpErr: nil, + ExpResp: &types.MsgDepositBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgDepositBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + Amount: sdk.NewCoin("uasset2", newInt(5)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case 2", + Msg: *types.NewMsgDepositBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2, sdk.NewCoin("ucasset1", newInt(5))), + ExpErr: nil, + ExpResp: &types.MsgDepositBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgDepositBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 2, + Amount: sdk.NewCoin("uasset1", newInt(5)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(300)))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("ucasset2", sdk.NewIntFromUint64(1000000000)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.DepositBorrow(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgDraw() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + + testCases := []struct { + Name string + Msg types.MsgDraw + ExpErr error + ExpResp *types.MsgDrawResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgDraw + AvailableBalance sdk.Coins + }{ + { + Name: "Borrow Not Found", + Msg: *types.NewMsgDraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2, sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrBorrowNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgDraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset3", newInt(100))), + ExpErr: types.ErrBadOfferCoinAmount, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Error Invalid Collaterallization Ratio", + Msg: *types.NewMsgDraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", newInt(100))), + ExpErr: types.ErrorInvalidCollateralizationRatio, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgDraw("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, sdk.NewCoin("uasset2", newInt(1))), + ExpErr: nil, + ExpResp: &types.MsgDrawResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgDraw{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + Amount: sdk.NewCoin("uasset2", newInt(1)), + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(300)))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("ucasset2", sdk.NewIntFromUint64(1000000000)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.Draw(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgCloseBorrow() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetOne, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + borrowMsg3 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 15, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset4", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), borrowMsg3) + + testCases := []struct { + Name string + Msg types.MsgCloseBorrow + ExpErr error + ExpResp *types.MsgCloseBorrowResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgCloseBorrow + AvailableBalance sdk.Coins + }{ + { + Name: "Borrow Not Found", + Msg: *types.NewMsgCloseBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 12), + ExpErr: types.ErrBorrowNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Different user", + Msg: *types.NewMsgCloseBorrow("cosmos14edpcw6ptcqd2vct9rkjf7lgyvrlwdtd0rqrtx", 1), + ExpErr: types.ErrLendAccessUnauthorized, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgCloseBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1), + ExpErr: nil, + ExpResp: &types.MsgCloseBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgCloseBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success valid case 2", + Msg: *types.NewMsgCloseBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 2), + ExpErr: nil, + ExpResp: &types.MsgCloseBorrowResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgCloseBorrow{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + }, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("uasset1", sdk.NewIntFromUint64(300)))) + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Borrower), sdk.NewCoins(sdk.NewCoin("ucasset2", sdk.NewIntFromUint64(1000000000)))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.CloseBorrow(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgBorrowAlternate() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + // cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + // s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + // s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + testCases := []struct { + Name string + Msg types.MsgBorrowAlternate + ExpErr error + ExpResp *types.MsgBorrowAlternateResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgBorrowAlternate + AvailableBalance sdk.Coins + }{ + { + Name: "asset does not exist", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 10, poolOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), pairOneID, false, sdk.NewCoin("uasset1", sdk.NewInt(100)), appOneID), + ExpErr: types.ErrorAssetDoesNotExist, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "Pool Not Found", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, 3, sdk.NewCoin("uasset1", sdk.NewInt(100)), pairOneID, false, sdk.NewCoin("uasset1", sdk.NewInt(100)), appOneID), + ExpErr: types.ErrPoolNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "App Mapping Id does not exists", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, poolOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), pairOneID, false, sdk.NewCoin("uasset1", sdk.NewInt(100)), 3), + ExpErr: types.ErrorAppMappingDoesNotExist, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "App Mapping Id mismatch, use the correct App Mapping ID in request", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, poolOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), pairThreeID, false, sdk.NewCoin("uasset2", sdk.NewInt(10)), appTwoID), + ExpErr: types.ErrorAppMappingIDMismatch, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100))), + }, + { + Name: "invalid offer coin amount", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, poolOneID, sdk.NewCoin("uasset2", sdk.NewInt(100)), pairThreeID, false, sdk.NewCoin("uasset2", sdk.NewInt(10)), appOneID), + ExpErr: sdkerrors.Wrapf(types.ErrBadOfferCoinAmount, "uasset2"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100))), + }, + { + Name: "Duplicate lend Position", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetThreeID, poolOneID, sdk.NewCoin("uasset3", sdk.NewInt(100)), pairFiveID, false, sdk.NewCoin("uasset2", sdk.NewInt(10)), appOneID), + ExpErr: types.ErrorDuplicateLend, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100))), + }, + { + Name: "Asset Id not defined in the pool", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetFourID, poolOneID, sdk.NewCoin("uasset4", sdk.NewInt(100)), pairSevenID, false, sdk.NewCoin("uasset3", sdk.NewInt(10)), appOneID), + ExpErr: sdkerrors.Wrap(types.ErrInvalidAssetIDForPool, "4"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100))), + }, + { + Name: "Asset Rates Stats not found", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetFourID, poolTwoID, sdk.NewCoin("uasset4", sdk.NewInt(100)), pairSevenID, false, sdk.NewCoin("uasset3", sdk.NewInt(10)), appOneID), + ExpErr: sdkerrors.Wrap(types.ErrorAssetRatesParamsNotFound, "4"), + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100))), + }, + { + Name: "success valid case", + Msg: *types.NewMsgBorrowAlternate("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", assetOneID, poolOneID, sdk.NewCoin("uasset1", sdk.NewInt(100)), pairThreeID, false, sdk.NewCoin("uasset2", sdk.NewInt(10)), appOneID), + ExpErr: nil, + ExpResp: &types.MsgBorrowAlternateResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgBorrowAlternate{ + Lender: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + AssetId: assetOneID, + PoolId: poolOneID, + AmountIn: sdk.NewCoin("uasset1", sdk.NewInt(100)), + PairId: pairThreeID, + IsStableBorrow: false, + AmountOut: sdk.NewCoin("uasset2", sdk.NewInt(10)), + AppId: appOneID, + }, + // AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset2", newInt(90000000010))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + // add funds to acount for valid case + if tc.ExpErr == nil { + s.fundAddr(sdk.MustAccAddressFromBech32(tc.Msg.Lender), sdk.NewCoins(sdk.NewCoin("uasset1", tc.Msg.AmountIn.Amount))) + } + + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.BorrowAlternate(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // fmt.Println("availableBalances", availableBalances) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgCalculateBorrowInterest() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + // s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + // appTwoID := s.CreateNewApp("cswap", "cswap") + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + + testCases := []struct { + Name string + Msg types.MsgCalculateBorrowInterest + ExpErr error + ExpResp *types.MsgCalculateBorrowInterestResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgCalculateBorrowInterest + AvailableBalance sdk.Coins + }{ + { + Name: "Borrow Position not found", + Msg: *types.NewMsgCalculateBorrowInterest("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 10), + ExpErr: types.ErrBorrowNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success Valid case", + Msg: *types.NewMsgCalculateBorrowInterest("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1), + ExpErr: nil, + ExpResp: &types.MsgCalculateBorrowInterestResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgCalculateBorrowInterest{ + Borrower: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + BorrowId: 1, + }, + // AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.CalculateBorrowInterest(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // fmt.Println("availableBalances", availableBalances) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) + } + }) + } +} + +func (s *KeeperTestSuite) TestMsgCalculateLendRewards() { + assetOneID := s.CreateNewAsset("ASSETONE", "uasset1", 1000000) + assetTwoID := s.CreateNewAsset("ASSETTWO", "uasset2", 2000000) + assetThreeID := s.CreateNewAsset("ASSETTHREE", "uasset3", 2000000) + assetFourID := s.CreateNewAsset("ASSETFOUR", "uasset4", 2000000) + cAssetOneID := s.CreateNewAsset("CASSETONE", "ucasset1", 1000000) + cAssetTwoID := s.CreateNewAsset("CASSETTWO", "ucasset2", 2000000) + cAssetThreeID := s.CreateNewAsset("CASSETTHRE", "ucasset3", 2000000) + // cAssetFourID := s.CreateNewAsset("CASSETFOUR", "ucasset4", 2000000) + + var ( + assetDataPoolOne []*types.AssetDataPoolMapping + assetDataPoolTwo []*types.AssetDataPoolMapping + ) + assetDataPoolOneAssetOne := &types.AssetDataPoolMapping{ + AssetID: assetOneID, + AssetTransitType: 3, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolOneAssetTwo := &types.AssetDataPoolMapping{ + AssetID: assetTwoID, + AssetTransitType: 1, + SupplyCap: uint64(1000000000000000000), + } + assetDataPoolOneAssetThree := &types.AssetDataPoolMapping{ + AssetID: assetThreeID, + AssetTransitType: 2, + SupplyCap: uint64(5000000000000000000), + } + assetDataPoolTwoAssetFour := &types.AssetDataPoolMapping{ + AssetID: assetFourID, + AssetTransitType: 1, + SupplyCap: uint64(3000000000000000000), + } + + assetDataPoolOne = append(assetDataPoolOne, assetDataPoolOneAssetOne, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + assetDataPoolTwo = append(assetDataPoolOne, assetDataPoolTwoAssetFour, assetDataPoolOneAssetTwo, assetDataPoolOneAssetThree) + + poolOneID := s.CreateNewPool("cmdx", "CMDX-ATOM-CMST", assetDataPoolOne) + poolTwoID := s.CreateNewPool("osmo", "OSMO-ATOM-CMST", assetDataPoolTwo) + + s.AddAssetRatesStats(assetThreeID, newDec("0.8"), newDec("0.002"), newDec("0.06"), newDec("0.6"), true, newDec("0.04"), newDec("0.04"), newDec("0.06"), newDec("0.8"), newDec("0.85"), newDec("0.025"), newDec("0.025"), newDec("0.1"), cAssetThreeID) + s.AddAssetRatesStats(assetOneID, newDec("0.75"), newDec("0.002"), newDec("0.07"), newDec("1.25"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.7"), newDec("0.75"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetOneID) + // s.AddAssetRatesStats(assetFourID, newDec("0.65"), newDec("0.002"), newDec("0.08"), newDec("1.5"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.6"), newDec("0.65"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetFourID) + s.AddAssetRatesStats(assetTwoID, newDec("0.5"), newDec("0.002"), newDec("0.08"), newDec("2.0"), false, newDec("0.0"), newDec("0.0"), newDec("0.0"), newDec("0.5"), newDec("0.55"), newDec("0.05"), newDec("0.05"), newDec("0.2"), cAssetTwoID) + + pairOneID := s.AddExtendedLendPair(assetTwoID, assetThreeID, false, poolOneID, 1000000) + pairTwoID := s.AddExtendedLendPair(assetTwoID, assetOneID, false, poolOneID, 1000000) + pairThreeID := s.AddExtendedLendPair(assetOneID, assetTwoID, false, poolOneID, 1000000) + pairFourID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolOneID, 1000000) + pairFiveID := s.AddExtendedLendPair(assetThreeID, assetTwoID, false, poolOneID, 1000000) + pairSixID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolOneID, 1000000) + pairSevenID := s.AddExtendedLendPair(assetFourID, assetThreeID, false, poolTwoID, 1000000) + pairEightID := s.AddExtendedLendPair(assetFourID, assetOneID, false, poolTwoID, 1000000) + pairNineID := s.AddExtendedLendPair(assetOneID, assetFourID, false, poolTwoID, 1000000) + pairTenID := s.AddExtendedLendPair(assetOneID, assetThreeID, false, poolTwoID, 1000000) + pairElevenID := s.AddExtendedLendPair(assetThreeID, assetFourID, false, poolTwoID, 1000000) + pairTwelveID := s.AddExtendedLendPair(assetThreeID, assetOneID, false, poolTwoID, 1000000) + pairThirteenID := s.AddExtendedLendPair(assetTwoID, assetFourID, true, poolTwoID, 1000000) + pairFourteenID := s.AddExtendedLendPair(assetThreeID, assetFourID, true, poolTwoID, 1000000) + pairFifteenID := s.AddExtendedLendPair(assetOneID, assetFourID, true, poolTwoID, 1000000) + pairSixteenID := s.AddExtendedLendPair(assetFourID, assetTwoID, true, poolOneID, 1000000) + pairSeventeenID := s.AddExtendedLendPair(assetThreeID, assetTwoID, true, poolOneID, 1000000) + pairEighteenID := s.AddExtendedLendPair(assetOneID, assetTwoID, true, poolOneID, 1000000) + + s.AddAssetToPair(assetOneID, poolOneID, []uint64{pairThreeID, pairFourID, pairFifteenID}) + s.AddAssetToPair(assetTwoID, poolOneID, []uint64{pairOneID, pairTwoID, pairThirteenID}) + s.AddAssetToPair(assetThreeID, poolOneID, []uint64{pairFiveID, pairSixID, pairFourteenID}) + s.AddAssetToPair(assetFourID, poolTwoID, []uint64{pairSevenID, pairEightID, pairSixteenID}) + s.AddAssetToPair(assetOneID, poolTwoID, []uint64{pairNineID, pairTenID, pairEighteenID}) + s.AddAssetToPair(assetThreeID, poolTwoID, []uint64{pairElevenID, pairTwelveID, pairSeventeenID}) + + appOneID := s.CreateNewApp("commodo", "cmmdo") + // appTwoID := s.CreateNewApp("cswap", "cswap") + 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))) + + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset1", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset2", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset3", newInt(100000000000)))) + s.fundAddr(sdk.MustAccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t"), sdk.NewCoins(sdk.NewCoin("uasset4", newInt(100000000000)))) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msg) + _, _ = s.msgServer.Lend(sdk.WrapSDKContext(s.ctx), msgLend2) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg3) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg4) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg5) + //_, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg6) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg7) + _, _ = s.msgServer.FundModuleAccounts(sdk.WrapSDKContext(s.ctx), msg8) + + msg2 := types.NewMsgBorrow("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1, 3, false, sdk.NewCoin("ucasset1", newInt(100)), sdk.NewCoin("uasset2", newInt(10))) + _, _ = s.msgServer.Borrow(sdk.WrapSDKContext(s.ctx), msg2) + + testCases := []struct { + Name string + Msg types.MsgCalculateLendRewards + ExpErr error + ExpResp *types.MsgCalculateLendRewardsResponse + QueryResponseIndex uint64 + QueryResponse *types.MsgCalculateLendRewards + AvailableBalance sdk.Coins + }{ + { + Name: "Lend Position not found", + Msg: *types.NewMsgCalculateLendRewards("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 10), + ExpErr: types.ErrLendNotFound, + ExpResp: nil, + QueryResponseIndex: 0, + QueryResponse: nil, + AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + { + Name: "success Valid case", + Msg: *types.NewMsgCalculateLendRewards("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", 1), + ExpErr: nil, + ExpResp: &types.MsgCalculateLendRewardsResponse{}, + QueryResponseIndex: 0, + QueryResponse: &types.MsgCalculateLendRewards{ + Lender: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", + LendId: 1, + }, + // AvailableBalance: sdk.NewCoins(sdk.NewCoin("uasset1", newInt(0))), + }, + } + for _, tc := range testCases { + tc := tc + s.Run(tc.Name, func() { + ctx := sdk.WrapSDKContext(s.ctx) + resp, err := s.msgServer.CalculateLendRewards(ctx, &tc.Msg) + if tc.ExpErr != nil { + s.Require().Error(err) + s.Require().EqualError(err, tc.ExpErr.Error()) + s.Require().Equal(tc.ExpResp, resp) + } else { + s.Require().NoError(err) + s.Require().NotNil(resp) + s.Require().Equal(tc.ExpResp, resp) + + // availableBalances := s.getBalances(sdk.MustAccAddressFromBech32(tc.Msg.Lender)) + // fmt.Println("availableBalances", availableBalances) + // s.Require().True(tc.AvailableBalance.IsEqual(availableBalances)) } }) } diff --git a/x/lend/keeper/pair.go b/x/lend/keeper/pair.go index 35ee5f9c4..5f4a0594f 100644 --- a/x/lend/keeper/pair.go +++ b/x/lend/keeper/pair.go @@ -13,6 +13,9 @@ func (k Keeper) AddLendPairsRecords(ctx sdk.Context, records ...types.Extended_P if found { return types.ErrorDuplicateLendPair } + if msg.AssetIn == msg.AssetOut { + return types.ErrorAssetsCanNotBeSame + } var ( id = k.GetLendPairID(ctx) @@ -32,6 +35,33 @@ 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) @@ -39,66 +69,23 @@ func (k Keeper) AddPoolRecords(ctx sdk.Context, pool types.Pool) error { return types.ErrorAssetDoesNotExist } } - depositStats, found := k.GetDepositStats(ctx) - userDepositStats, _ := k.GetUserDepositStats(ctx) - ReserveDepositStats, _ := k.GetReserveDepositStats(ctx) - BuyBackDepositStats, _ := k.GetBuyBackDepositStats(ctx) - BorrowStats, _ := k.GetBorrowStats(ctx) - var balanceStats []types.BalanceStats - if !found { - for _, v := range pool.AssetData { - balanceStat := types.BalanceStats{ - AssetID: v.AssetID, - Amount: sdk.ZeroInt(), - } - balanceStats = append(balanceStats, balanceStat) - depositStats = types.DepositStats{BalanceStats: balanceStats} - userDepositStats = types.DepositStats{BalanceStats: balanceStats} - ReserveDepositStats = types.DepositStats{BalanceStats: balanceStats} - BuyBackDepositStats = types.DepositStats{BalanceStats: balanceStats} - BorrowStats = types.DepositStats{BalanceStats: balanceStats} - k.SetDepositStats(ctx, depositStats) - k.SetUserDepositStats(ctx, userDepositStats) - k.SetReserveDepositStats(ctx, ReserveDepositStats) - k.SetBuyBackDepositStats(ctx, BuyBackDepositStats) - k.SetBorrowStats(ctx, BorrowStats) - } - } else { - balanceStat := types.BalanceStats{ - AssetID: pool.MainAssetId, - Amount: sdk.ZeroInt(), - } - balanceStats = append(depositStats.BalanceStats, balanceStat) - depositStats = types.DepositStats{BalanceStats: balanceStats} - userDepositStats = types.DepositStats{BalanceStats: balanceStats} - ReserveDepositStats = types.DepositStats{BalanceStats: balanceStats} - BuyBackDepositStats = types.DepositStats{BalanceStats: balanceStats} - BorrowStats = types.DepositStats{BalanceStats: balanceStats} - k.SetDepositStats(ctx, depositStats) - k.SetUserDepositStats(ctx, userDepositStats) - k.SetReserveDepositStats(ctx, ReserveDepositStats) - k.SetBuyBackDepositStats(ctx, BuyBackDepositStats) - k.SetBorrowStats(ctx, BorrowStats) - } poolID := k.GetPoolID(ctx) newPool := types.Pool{ - PoolID: poolID + 1, - ModuleName: pool.ModuleName, - MainAssetId: pool.MainAssetId, - FirstBridgedAssetID: pool.FirstBridgedAssetID, - SecondBridgedAssetID: pool.SecondBridgedAssetID, - CPoolName: pool.CPoolName, - ReserveFunds: pool.ReserveFunds, - AssetData: pool.AssetData, + PoolID: poolID + 1, + ModuleName: pool.ModuleName, + CPoolName: pool.CPoolName, + ReserveFunds: pool.ReserveFunds, + AssetData: pool.AssetData, } for _, v := range pool.AssetData { - var assetStats types.AssetStats + 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() k.SetAssetStatsByPoolIDAndAssetID(ctx, assetStats) k.UpdateAPR(ctx, newPool.PoolID, v.AssetID) } @@ -206,14 +193,14 @@ func (k Keeper) GetLendPairID(ctx sdk.Context) uint64 { return count.GetValue() } -func (k Keeper) AddAssetRatesStats(ctx sdk.Context, records ...types.AssetRatesStats) error { +func (k Keeper) AddAssetRatesParams(ctx sdk.Context, records ...types.AssetRatesParams) error { for _, msg := range records { - _, found := k.GetAssetRatesStats(ctx, msg.AssetID) + _, found := k.GetAssetRatesParams(ctx, msg.AssetID) if found { - return types.ErrorDuplicateAssetRatesStats + return types.ErrorAssetRatesParamsNotFound } - assetRatesStats := types.AssetRatesStats{ + assetRatesParams := types.AssetRatesParams{ AssetID: msg.AssetID, UOptimal: msg.UOptimal, Base: msg.Base, @@ -231,7 +218,7 @@ func (k Keeper) AddAssetRatesStats(ctx sdk.Context, records ...types.AssetRatesS CAssetID: msg.CAssetID, } - k.SetAssetRatesStats(ctx, assetRatesStats) + k.SetAssetRatesParams(ctx, assetRatesParams) } return nil } @@ -284,35 +271,35 @@ func (k Keeper) GetAllAddAuctionParamsData(ctx sdk.Context) (auctionParams []typ return auctionParams } -func (k Keeper) SetAssetRatesStats(ctx sdk.Context, assetRatesStats types.AssetRatesStats) { +func (k Keeper) SetAssetRatesParams(ctx sdk.Context, assetRatesParams types.AssetRatesParams) { var ( store = k.Store(ctx) - key = types.AssetRatesStatsKey(assetRatesStats.AssetID) - value = k.cdc.MustMarshal(&assetRatesStats) + key = types.AssetRatesParamsKey(assetRatesParams.AssetID) + value = k.cdc.MustMarshal(&assetRatesParams) ) store.Set(key, value) } -func (k Keeper) GetAssetRatesStats(ctx sdk.Context, assetID uint64) (assetRatesStats types.AssetRatesStats, found bool) { +func (k Keeper) GetAssetRatesParams(ctx sdk.Context, assetID uint64) (assetRatesParams types.AssetRatesParams, found bool) { var ( store = k.Store(ctx) - key = types.AssetRatesStatsKey(assetID) + key = types.AssetRatesParamsKey(assetID) value = store.Get(key) ) if value == nil { - return assetRatesStats, false + return assetRatesParams, false } - k.cdc.MustUnmarshal(value, &assetRatesStats) - return assetRatesStats, true + k.cdc.MustUnmarshal(value, &assetRatesParams) + return assetRatesParams, true } -func (k Keeper) GetAllAssetRatesStats(ctx sdk.Context) (assetRatesStats []types.AssetRatesStats) { +func (k Keeper) GetAllAssetRatesParams(ctx sdk.Context) (assetRatesParams []types.AssetRatesParams) { var ( store = k.Store(ctx) - iter = sdk.KVStorePrefixIterator(store, types.AssetRatesStatsKeyPrefix) + iter = sdk.KVStorePrefixIterator(store, types.AssetRatesParamsKeyPrefix) ) defer func(iter sdk.Iterator) { @@ -323,34 +310,9 @@ func (k Keeper) GetAllAssetRatesStats(ctx sdk.Context) (assetRatesStats []types. }(iter) for ; iter.Valid(); iter.Next() { - var asset types.AssetRatesStats + var asset types.AssetRatesParams k.cdc.MustUnmarshal(iter.Value(), &asset) - assetRatesStats = append(assetRatesStats, asset) + assetRatesParams = append(assetRatesParams, asset) } - return assetRatesStats -} - -func (k Keeper) SetDepositStats(ctx sdk.Context, depositStats types.DepositStats) { - var ( - store = k.Store(ctx) - key = types.DepositStatsPrefix - value = k.cdc.MustMarshal(&depositStats) - ) - - store.Set(key, value) -} - -func (k Keeper) GetDepositStats(ctx sdk.Context) (depositStats types.DepositStats, found bool) { - var ( - store = k.Store(ctx) - key = types.DepositStatsPrefix - value = store.Get(key) - ) - - if value == nil { - return depositStats, false - } - - k.cdc.MustUnmarshal(value, &depositStats) - return depositStats, true + return assetRatesParams } diff --git a/x/lend/keeper/rates.go b/x/lend/keeper/rates.go index 5f7b2758a..a21320934 100644 --- a/x/lend/keeper/rates.go +++ b/x/lend/keeper/rates.go @@ -7,7 +7,7 @@ import ( "github.com/comdex-official/comdex/x/lend/types" ) -func (k Keeper) VerifyCollaterlizationRatio( +func (k Keeper) VerifyCollateralizationRatio( ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, @@ -15,44 +15,33 @@ func (k Keeper) VerifyCollaterlizationRatio( assetOut assettypes.Asset, liquidationThreshold sdk.Dec, ) error { - collaterlizationRatio, err := k.CalculateCollaterlizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) + collateralizationRatio, err := k.CalculateCollateralizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) if err != nil { return err } - if collaterlizationRatio.GT(liquidationThreshold) { + if collateralizationRatio.GT(liquidationThreshold) { return types.ErrorInvalidCollateralizationRatio } return nil } -func (k Keeper) CalculateCollaterlizationRatio( +func (k Keeper) CalculateCollateralizationRatio( ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, ) (sdk.Dec, error) { - assetInPrice, found := k.GetPriceForAsset(ctx, assetIn.Id) - if !found { - return sdk.ZeroDec(), types.ErrorPriceInDoesNotExist - } - - assetOutPrice, found := k.GetPriceForAsset(ctx, assetOut.Id) - if !found { - return sdk.ZeroDec(), types.ErrorPriceOutDoesNotExist - } - - totalIn := amountIn.Mul(sdk.NewIntFromUint64(assetInPrice)).ToDec() - if totalIn.LTE(sdk.ZeroDec()) { - return sdk.ZeroDec(), types.ErrorInvalidAmountIn + totalIn, err := k.CalcAssetPrice(ctx, assetIn.Id, amountIn) + if err != nil { + return sdk.ZeroDec(), err } - - totalOut := amountOut.Mul(sdk.NewIntFromUint64(assetOutPrice)).ToDec() - if totalOut.LTE(sdk.ZeroDec()) { - return sdk.ZeroDec(), types.ErrorInvalidAmountOut + totalOut, err := k.CalcAssetPrice(ctx, assetOut.Id, amountOut) + if err != nil { + return sdk.ZeroDec(), err } - return totalOut.Quo(totalIn), nil + return sdk.NewDecFromInt(totalOut).Quo(sdk.NewDecFromInt(totalIn)), nil } diff --git a/x/lend/types/codec.go b/x/lend/types/codec.go index fcb20bf51..a17234e30 100644 --- a/x/lend/types/codec.go +++ b/x/lend/types/codec.go @@ -22,9 +22,10 @@ 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(&AddAssetRatesStats{}, "comdex/lend/AddAssetRatesStats", nil) + cdc.RegisterConcrete(&AddAssetRatesParams{}, "comdex/lend/AddAssetRatesParams", nil) cdc.RegisterConcrete(&AddAuctionParamsProposal{}, "comdex/lend/AddAuctionParamsProposal", nil) cdc.RegisterConcrete(&MsgCalculateBorrowInterest{}, "comdex/lend/MsgCalculateBorrowInterest", nil) cdc.RegisterConcrete(&MsgCalculateLendRewards{}, "comdex/lend/MsgCalculateLendRewards", nil) @@ -34,9 +35,10 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations( (*govtypes.Content)(nil), &LendPairsProposal{}, + &UpdateLendPairsProposal{}, &AddPoolsProposal{}, &AddAssetToPairProposal{}, - &AddAssetRatesStats{}, + &AddAssetRatesParams{}, &AddAuctionParamsProposal{}, ) registry.RegisterImplementations( diff --git a/x/lend/types/errors.go b/x/lend/types/errors.go index 767413139..af255e281 100644 --- a/x/lend/types/errors.go +++ b/x/lend/types/errors.go @@ -21,9 +21,9 @@ var ( ErrorLendOwnerNotFound = sdkerrors.Register(ModuleName, 1128, "Lend Owner not found") ErrLendNotFound = sdkerrors.Register(ModuleName, 1129, "Lend Position not found") ErrWithdrawalAmountExceeds = sdkerrors.Register(ModuleName, 1130, "Withdrawal Amount Exceeds") - ErrLendAccessUnauthorised = sdkerrors.Register(ModuleName, 1131, "Unauthorized user for the tx") + ErrLendAccessUnauthorized = sdkerrors.Register(ModuleName, 1131, "Unauthorized user for the tx") ErrorPairNotFound = sdkerrors.Register(ModuleName, 1132, "Pair Not Found") - ErrorInvalidCollateralizationRatio = sdkerrors.Register(ModuleName, 1133, "Error Invalid Collaterallization Ratio") + ErrorInvalidCollateralizationRatio = sdkerrors.Register(ModuleName, 1133, "Error Invalid Collateralization Ratio") ErrorPriceInDoesNotExist = sdkerrors.Register(ModuleName, 1134, "Error Price In Does Not Exist") ErrorPriceOutDoesNotExist = sdkerrors.Register(ModuleName, 1135, "Error Price Out Does Not Exist") ErrorInvalidAmountIn = sdkerrors.Register(ModuleName, 1136, "Error Invalid Amount In") @@ -36,7 +36,7 @@ var ( ErrorDuplicateAssetRatesStats = sdkerrors.Register(ModuleName, 1143, "Duplicate Asset Rates Stats") ErrorAssetStatsNotFound = sdkerrors.Register(ModuleName, 1144, "Asset Stats Not Found") ErrInvalidAssetIDForPool = sdkerrors.Register(ModuleName, 1145, "Asset Id not defined in the pool") - ErrorAssetRatesStatsNotFound = sdkerrors.Register(ModuleName, 1146, "Asset Rates Stats not found") + ErrorAssetRatesParamsNotFound = sdkerrors.Register(ModuleName, 1146, "Asset Rates Params not found") ErrPoolNotFound = sdkerrors.Register(ModuleName, 1147, "Pool Not Found") ErrAvailableToBorrowInsufficient = sdkerrors.Register(ModuleName, 1148, "Available To Borrow Insufficient") ErrStableBorrowDisabled = sdkerrors.Register(ModuleName, 1149, "Stable Borrow Rate Not Enabled for This Asset") @@ -55,4 +55,8 @@ var ( ErrAverageBorrowRate = sdkerrors.Register(ModuleName, 1162, "Average Borrow Rate Error") ErrInsufficientFunds = sdkerrors.Register(ModuleName, 1163, "Insufficient Funds") ErrorAppMappingIDMismatch = sdkerrors.Register(ModuleName, 1164, "App Mapping Id mismatch, use the correct App Mapping ID in request") + ErrorAssetsCanNotBeSame = sdkerrors.Register(ModuleName, 1165, "asset ID of assetIn and assetOut can not be same") + 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") ) diff --git a/x/lend/types/genesis.go b/x/lend/types/genesis.go index 8e0ee2788..f8950844c 100644 --- a/x/lend/types/genesis.go +++ b/x/lend/types/genesis.go @@ -1,52 +1,52 @@ package types -func NewGenesisState(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 DepositStats, reservedepositStats DepositStats, buybackdepositStats DepositStats, borrowdepositStats DepositStats, extended_Pair []Extended_Pair, assetRatesStats []AssetRatesStats, auctionParams []AuctionParams, params Params) *GenesisState { +func NewGenesisState() *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, + // 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, } } 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{}, + // []UserBorrowIdMapping{}, + // []BorrowIdByOwnerAndPoolMapping{}, + // BorrowMapping{}, + // []LendAsset{}, + // []Pool{}, + // []AssetToPairMapping{}, + // []UserLendIdMapping{}, + // []LendIdByOwnerAndPoolMapping{}, + // []LendIdToBorrowIdMapping{}, + // []AssetStats{}, + // LendMapping{}, + // DepositStats{}, + // DepositStats{}, + // DepositStats{}, + // DepositStats{}, + // []Extended_Pair{}, + // []AssetRatesStats{}, + // []AuctionParams{}, + // DefaultParams(), ) } diff --git a/x/lend/types/genesis.pb.go b/x/lend/types/genesis.pb.go index ac76c3f50..f54089a29 100644 --- a/x/lend/types/genesis.pb.go +++ b/x/lend/types/genesis.pb.go @@ -24,26 +24,6 @@ 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"` - UserBorrowIdMapping []UserBorrowIdMapping `protobuf:"bytes,2,rep,name=userBorrowIdMapping,proto3" json:"userBorrowIdMapping" yaml:"userBorrowIdMapping"` - BorrowIdByOwnerAndPoolMapping []BorrowIdByOwnerAndPoolMapping `protobuf:"bytes,3,rep,name=borrowIdByOwnerAndPoolMapping,proto3" json:"borrowIdByOwnerAndPoolMapping" yaml:"borrowIdByOwnerAndPoolMapping"` - BorrowMapping BorrowMapping `protobuf:"bytes,4,opt,name=borrowMapping,proto3" json:"borrowMapping" yaml:"borrowMapping"` - LendAsset []LendAsset `protobuf:"bytes,5,rep,name=lendAsset,proto3" json:"lendAsset" yaml:"lendAsset"` - Pool []Pool `protobuf:"bytes,6,rep,name=pool,proto3" json:"pool" yaml:"pool"` - AssetToPairMapping []AssetToPairMapping `protobuf:"bytes,7,rep,name=assetToPairMapping,proto3" json:"assetToPairMapping" yaml:"assetToPairMapping"` - UserLendIdMapping []UserLendIdMapping `protobuf:"bytes,8,rep,name=userLendIdMapping,proto3" json:"userLendIdMapping" yaml:"userLendIdMapping"` - LendIdByOwnerAndPoolMapping []LendIdByOwnerAndPoolMapping `protobuf:"bytes,9,rep,name=lendIdByOwnerAndPoolMapping,proto3" json:"lendIdByOwnerAndPoolMapping" yaml:"lendIdByOwnerAndPoolMapping"` - LendIdToBorrowIdMapping []LendIdToBorrowIdMapping `protobuf:"bytes,10,rep,name=lendIdToBorrowIdMapping,proto3" json:"lendIdToBorrowIdMapping" yaml:"lendIdToBorrowIdMapping"` - AssetStats []AssetStats `protobuf:"bytes,11,rep,name=assetStats,proto3" json:"assetStats" yaml:"assetStats"` - LendMapping LendMapping `protobuf:"bytes,12,opt,name=lendMapping,proto3" json:"lendMapping" yaml:"lendMapping"` - UserDepositStats DepositStats `protobuf:"bytes,13,opt,name=userDepositStats,proto3" json:"userDepositStats" yaml:"userDepositStats"` - ReserveDepositStats DepositStats `protobuf:"bytes,14,opt,name=reserveDepositStats,proto3" json:"reserveDepositStats" yaml:"reserveDepositStats"` - BuyBackDepositStats DepositStats `protobuf:"bytes,15,opt,name=buyBackDepositStats,proto3" json:"buyBackDepositStats" yaml:"buyBackDepositStats"` - BorrowDepositStats DepositStats `protobuf:"bytes,16,opt,name=borrowDepositStats,proto3" json:"borrowDepositStats" yaml:"borrowDepositStats"` - Extended_Pair []Extended_Pair `protobuf:"bytes,17,rep,name=extended_Pair,json=extendedPair,proto3" json:"extended_Pair" yaml:"extended_Pair"` - AssetRatesStats []AssetRatesStats `protobuf:"bytes,18,rep,name=assetRatesStats,proto3" json:"assetRatesStats" yaml:"assetRatesStats"` - AuctionParams []AuctionParams `protobuf:"bytes,19,rep,name=auctionParams,proto3" json:"auctionParams" yaml:"auctionParams"` - Params Params `protobuf:"bytes,20,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -79,146 +59,6 @@ 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) GetUserBorrowIdMapping() []UserBorrowIdMapping { - if m != nil { - return m.UserBorrowIdMapping - } - return nil -} - -func (m *GenesisState) GetBorrowIdByOwnerAndPoolMapping() []BorrowIdByOwnerAndPoolMapping { - if m != nil { - return m.BorrowIdByOwnerAndPoolMapping - } - return nil -} - -func (m *GenesisState) GetBorrowMapping() BorrowMapping { - if m != nil { - return m.BorrowMapping - } - return BorrowMapping{} -} - -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) GetUserLendIdMapping() []UserLendIdMapping { - if m != nil { - return m.UserLendIdMapping - } - return nil -} - -func (m *GenesisState) GetLendIdByOwnerAndPoolMapping() []LendIdByOwnerAndPoolMapping { - if m != nil { - return m.LendIdByOwnerAndPoolMapping - } - return nil -} - -func (m *GenesisState) GetLendIdToBorrowIdMapping() []LendIdToBorrowIdMapping { - if m != nil { - return m.LendIdToBorrowIdMapping - } - return nil -} - -func (m *GenesisState) GetAssetStats() []AssetStats { - if m != nil { - return m.AssetStats - } - return nil -} - -func (m *GenesisState) GetLendMapping() LendMapping { - if m != nil { - return m.LendMapping - } - return LendMapping{} -} - -func (m *GenesisState) GetUserDepositStats() DepositStats { - if m != nil { - return m.UserDepositStats - } - return DepositStats{} -} - -func (m *GenesisState) GetReserveDepositStats() DepositStats { - if m != nil { - return m.ReserveDepositStats - } - return DepositStats{} -} - -func (m *GenesisState) GetBuyBackDepositStats() DepositStats { - if m != nil { - return m.BuyBackDepositStats - } - return DepositStats{} -} - -func (m *GenesisState) GetBorrowDepositStats() DepositStats { - if m != nil { - return m.BorrowDepositStats - } - return DepositStats{} -} - -func (m *GenesisState) GetExtended_Pair() []Extended_Pair { - if m != nil { - return m.Extended_Pair - } - return nil -} - -func (m *GenesisState) GetAssetRatesStats() []AssetRatesStats { - if m != nil { - return m.AssetRatesStats - } - return nil -} - -func (m *GenesisState) GetAuctionParams() []AuctionParams { - if m != nil { - return m.AuctionParams - } - return nil -} - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - func init() { proto.RegisterType((*GenesisState)(nil), "comdex.lend.v1beta1.GenesisState") } @@ -226,57 +66,19 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/genesis.proto", fileDescriptor_4df703d992154ae9) } var fileDescriptor_4df703d992154ae9 = []byte{ - // 791 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x96, 0xdf, 0x4e, 0x13, 0x4d, - 0x18, 0xc6, 0xbb, 0x1f, 0x7c, 0x7c, 0x1f, 0x53, 0x10, 0x3a, 0x25, 0xb2, 0x14, 0xdd, 0x96, 0x09, - 0x41, 0x62, 0xb0, 0x15, 0x3c, 0xd2, 0xb3, 0x4e, 0x34, 0x6a, 0xa2, 0x91, 0x8c, 0xe8, 0x01, 0x07, - 0x9a, 0x6d, 0x3b, 0xd4, 0x8d, 0x65, 0xa7, 0xd9, 0xdd, 0x02, 0xf5, 0xc0, 0x4b, 0x30, 0x5e, 0x81, - 0x87, 0x5e, 0x0b, 0x67, 0x72, 0xe8, 0x11, 0x31, 0x70, 0x07, 0x5e, 0x81, 0x99, 0x3f, 0xcb, 0xce, - 0xee, 0xce, 0x36, 0xc4, 0xb3, 0x6e, 0xe7, 0x99, 0xdf, 0xf3, 0xbc, 0x9d, 0x77, 0xdf, 0x0e, 0x58, - 0xeb, 0xb2, 0xc3, 0x1e, 0x3d, 0x69, 0x0d, 0xa8, 0xdf, 0x6b, 0x1d, 0x6d, 0x77, 0x68, 0xe4, 0x6e, - 0xb7, 0xfa, 0xd4, 0xa7, 0xa1, 0x17, 0x36, 0x87, 0x01, 0x8b, 0x18, 0xac, 0x4a, 0x49, 0x93, 0x4b, - 0x9a, 0x4a, 0x52, 0x5b, 0xea, 0xb3, 0x3e, 0x13, 0xeb, 0x2d, 0xfe, 0x49, 0x4a, 0x6b, 0x8e, 0x89, - 0x26, 0xf6, 0xc9, 0xf5, 0x86, 0x69, 0x7d, 0xe8, 0x06, 0xee, 0xa1, 0x32, 0x43, 0x3f, 0x2a, 0x60, - 0xee, 0xa9, 0xb4, 0x7f, 0x1d, 0xb9, 0x11, 0x85, 0xef, 0x40, 0xb9, 0xc3, 0x82, 0x80, 0x1d, 0xb7, - 0xc3, 0x90, 0x46, 0xb6, 0xd5, 0x98, 0xda, 0x2c, 0xef, 0x34, 0x9a, 0x86, 0x4c, 0x4d, 0x9c, 0xe8, - 0x70, 0xed, 0xf4, 0xbc, 0x5e, 0xfa, 0x7d, 0x5e, 0x87, 0x63, 0xf7, 0x70, 0xf0, 0x08, 0x69, 0x08, - 0x44, 0x74, 0x20, 0xfc, 0x0c, 0xaa, 0xa3, 0x90, 0x06, 0x72, 0xef, 0xf3, 0xde, 0x4b, 0x77, 0x38, - 0xf4, 0xfc, 0xbe, 0xfd, 0x8f, 0xf0, 0xd9, 0x34, 0xfa, 0xbc, 0xc9, 0xeb, 0x31, 0x52, 0x7e, 0x35, - 0xe9, 0x67, 0x40, 0x22, 0x62, 0x32, 0x82, 0xdf, 0x2d, 0x70, 0xbb, 0xa3, 0xbe, 0xc3, 0xe3, 0x57, - 0xc7, 0x3e, 0x0d, 0xda, 0x7e, 0x6f, 0x97, 0xb1, 0x41, 0x1c, 0x65, 0x4a, 0x44, 0xd9, 0x99, 0x50, - 0x72, 0xc1, 0x4e, 0xbc, 0xa5, 0x42, 0xad, 0xeb, 0x3f, 0x42, 0x81, 0x18, 0x91, 0xc9, 0x31, 0xe0, - 0x01, 0x98, 0x97, 0x82, 0x38, 0xd7, 0x74, 0xc3, 0xda, 0x2c, 0xef, 0xa0, 0x09, 0xb9, 0xe2, 0x1c, - 0xb7, 0x54, 0x8e, 0x25, 0x3d, 0xc7, 0x95, 0x6f, 0x1a, 0x0b, 0xdf, 0x82, 0x59, 0x8e, 0x92, 0xc7, - 0xfd, 0xaf, 0xa8, 0xdd, 0x31, 0x7a, 0xbc, 0x88, 0x55, 0xd8, 0x56, 0xfc, 0x45, 0xc9, 0xbf, 0xda, - 0x8e, 0x48, 0x82, 0x82, 0x18, 0x4c, 0x0f, 0x19, 0x1b, 0xd8, 0x33, 0x02, 0xb9, 0x62, 0x44, 0xf2, - 0x7a, 0x71, 0x55, 0xd1, 0xca, 0x92, 0xc6, 0x37, 0x21, 0x22, 0xf6, 0xc2, 0x4f, 0x00, 0xba, 0x1c, - 0xb6, 0xc7, 0x76, 0x5d, 0x2f, 0x88, 0x7f, 0x88, 0xff, 0x04, 0xf1, 0x8e, 0x91, 0xd8, 0xce, 0xc9, - 0xf1, 0x9a, 0xe2, 0xaf, 0x48, 0x7e, 0x1e, 0x88, 0x88, 0xc1, 0x05, 0x1e, 0x81, 0x0a, 0xef, 0x1f, - 0x5e, 0x75, 0xd2, 0xa6, 0xff, 0x0b, 0xeb, 0x8d, 0xc2, 0x36, 0x4d, 0xa9, 0x71, 0x43, 0x39, 0xdb, - 0x49, 0x93, 0xa6, 0x04, 0x88, 0xe4, 0x2d, 0xe0, 0x37, 0x0b, 0xac, 0x0e, 0xc4, 0x37, 0xe6, 0xf6, - 0x9c, 0x15, 0x11, 0xee, 0x17, 0x1e, 0x51, 0x51, 0x73, 0xde, 0x55, 0x61, 0x50, 0x72, 0x68, 0x85, - 0xad, 0x39, 0x29, 0x00, 0xfc, 0x62, 0x81, 0x65, 0xb9, 0xbe, 0xc7, 0xb2, 0xaf, 0x31, 0x10, 0xe1, - 0xb6, 0x26, 0x84, 0xcb, 0xed, 0xc1, 0x1b, 0x2a, 0x98, 0xa3, 0x07, 0xcb, 0xc9, 0x10, 0x29, 0x32, - 0x85, 0xfb, 0x00, 0x88, 0xf3, 0xe3, 0x03, 0x2c, 0xb4, 0xcb, 0x22, 0x42, 0xbd, 0xb8, 0x3b, 0x84, - 0x0c, 0xaf, 0x28, 0xd7, 0x8a, 0xd6, 0x15, 0x62, 0x05, 0x11, 0x8d, 0xc6, 0xc7, 0x21, 0x27, 0xc4, - 0xf5, 0xcd, 0x89, 0x77, 0xb0, 0x51, 0x58, 0x5f, 0x5c, 0x53, 0x66, 0x1c, 0x6a, 0x08, 0x44, 0x74, - 0x20, 0xf4, 0xc1, 0x22, 0x6f, 0x81, 0xc7, 0x74, 0xc8, 0x42, 0x4f, 0x55, 0x30, 0x2f, 0x4c, 0xd6, - 0x8c, 0x26, 0xba, 0x10, 0xd7, 0x95, 0xcb, 0x72, 0xd2, 0x5f, 0xfa, 0x3a, 0x22, 0x39, 0x36, 0x3c, - 0x06, 0xd5, 0x80, 0x86, 0x34, 0x38, 0xa2, 0x29, 0xcb, 0x1b, 0xd7, 0xb5, 0xcc, 0xcc, 0x5d, 0x03, - 0x0b, 0x11, 0x93, 0x03, 0x37, 0xee, 0x8c, 0xc6, 0xd8, 0xed, 0x7e, 0x4c, 0x19, 0x2f, 0xfc, 0xa5, - 0xb1, 0x81, 0x85, 0x88, 0xc9, 0x01, 0x46, 0x00, 0xca, 0x81, 0x97, 0xf2, 0x5d, 0xbc, 0xae, 0x6f, - 0x66, 0x7a, 0xe4, 0x51, 0x88, 0x18, 0xf8, 0x90, 0x82, 0x79, 0x7a, 0x12, 0x51, 0xbf, 0x47, 0x7b, - 0xef, 0xf9, 0x54, 0xb1, 0x2b, 0xa2, 0x2d, 0xcd, 0xd3, 0xfb, 0x89, 0xae, 0xcc, 0x4e, 0xef, 0x14, - 0x06, 0x91, 0xb9, 0xf8, 0x99, 0x3f, 0x42, 0x1f, 0x2c, 0x88, 0x66, 0x25, 0x6e, 0x44, 0x43, 0x59, - 0x19, 0x14, 0x46, 0xeb, 0xc5, 0xfd, 0x9f, 0x68, 0xb1, 0xa3, 0xac, 0x6e, 0x6a, 0x2f, 0x41, 0xb2, - 0x8c, 0x48, 0x16, 0xce, 0xff, 0x94, 0xdc, 0x51, 0x37, 0xf2, 0x98, 0xbf, 0x2b, 0x6e, 0x11, 0x76, - 0x75, 0x42, 0x59, 0x6d, 0x5d, 0x99, 0x2d, 0x2b, 0x85, 0x41, 0x24, 0x8d, 0x85, 0x0f, 0xc1, 0x8c, - 0xbc, 0xa6, 0xd8, 0x4b, 0xe2, 0xa0, 0x56, 0xcd, 0x7f, 0x1f, 0x92, 0x3c, 0xcd, 0xc9, 0x44, 0x6d, - 0xc0, 0xcf, 0x4e, 0x2f, 0x1c, 0xeb, 0xec, 0xc2, 0xb1, 0x7e, 0x5d, 0x38, 0xd6, 0xd7, 0x4b, 0xa7, - 0x74, 0x76, 0xe9, 0x94, 0x7e, 0x5e, 0x3a, 0xa5, 0xfd, 0x66, 0xdf, 0x8b, 0x3e, 0x8c, 0x3a, 0x1c, - 0xd5, 0x92, 0xb8, 0x7b, 0xec, 0xe0, 0xc0, 0xeb, 0x7a, 0xee, 0x40, 0x3d, 0xb7, 0xd4, 0x55, 0x29, - 0x1a, 0x0f, 0x69, 0xd8, 0x99, 0x11, 0x57, 0xa4, 0x07, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xd5, - 0x70, 0x7a, 0xe4, 0xb4, 0x09, 0x00, 0x00, + // 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, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -299,268 +101,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa2 - 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] = 0x1 - i-- - dAtA[i] = 0x9a - } - } - if len(m.AssetRatesStats) > 0 { - for iNdEx := len(m.AssetRatesStats) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AssetRatesStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x92 - } - } - 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] = 0x1 - i-- - dAtA[i] = 0x8a - } - } - { - size, err := m.BorrowDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - { - size, err := m.BuyBackDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - { - size, err := m.ReserveDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - { - size, err := m.UserDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - { - size, err := m.LendMapping.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - if len(m.AssetStats) > 0 { - for iNdEx := len(m.AssetStats) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AssetStats[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.LendIdToBorrowIdMapping) > 0 { - for iNdEx := len(m.LendIdToBorrowIdMapping) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LendIdToBorrowIdMapping[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.LendIdByOwnerAndPoolMapping) > 0 { - for iNdEx := len(m.LendIdByOwnerAndPoolMapping) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LendIdByOwnerAndPoolMapping[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.UserLendIdMapping) > 0 { - for iNdEx := len(m.UserLendIdMapping) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UserLendIdMapping[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.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] = 0x3a - } - } - 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] = 0x32 - } - } - 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] = 0x2a - } - } - { - size, err := m.BorrowMapping.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.BorrowIdByOwnerAndPoolMapping) > 0 { - for iNdEx := len(m.BorrowIdByOwnerAndPoolMapping) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BorrowIdByOwnerAndPoolMapping[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.UserBorrowIdMapping) > 0 { - for iNdEx := len(m.UserBorrowIdMapping) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UserBorrowIdMapping[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 } @@ -581,98 +121,6 @@ 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.UserBorrowIdMapping) > 0 { - for _, e := range m.UserBorrowIdMapping { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.BorrowIdByOwnerAndPoolMapping) > 0 { - for _, e := range m.BorrowIdByOwnerAndPoolMapping { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - l = m.BorrowMapping.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.UserLendIdMapping) > 0 { - for _, e := range m.UserLendIdMapping { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.LendIdByOwnerAndPoolMapping) > 0 { - for _, e := range m.LendIdByOwnerAndPoolMapping { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.LendIdToBorrowIdMapping) > 0 { - for _, e := range m.LendIdToBorrowIdMapping { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.AssetStats) > 0 { - for _, e := range m.AssetStats { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - l = m.LendMapping.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.UserDepositStats.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.ReserveDepositStats.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.BuyBackDepositStats.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.BorrowDepositStats.Size() - n += 2 + l + sovGenesis(uint64(l)) - if len(m.Extended_Pair) > 0 { - for _, e := range m.Extended_Pair { - l = e.Size() - n += 2 + l + sovGenesis(uint64(l)) - } - } - if len(m.AssetRatesStats) > 0 { - for _, e := range m.AssetRatesStats { - l = e.Size() - n += 2 + l + sovGenesis(uint64(l)) - } - } - if len(m.AuctionParams) > 0 { - for _, e := range m.AuctionParams { - l = e.Size() - n += 2 + l + sovGenesis(uint64(l)) - } - } - l = m.Params.Size() - n += 2 + l + sovGenesis(uint64(l)) return n } @@ -711,679 +159,6 @@ 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 UserBorrowIdMapping", 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.UserBorrowIdMapping = append(m.UserBorrowIdMapping, UserBorrowIdMapping{}) - if err := m.UserBorrowIdMapping[len(m.UserBorrowIdMapping)-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 BorrowIdByOwnerAndPoolMapping", 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.BorrowIdByOwnerAndPoolMapping = append(m.BorrowIdByOwnerAndPoolMapping, BorrowIdByOwnerAndPoolMapping{}) - if err := m.BorrowIdByOwnerAndPoolMapping[len(m.BorrowIdByOwnerAndPoolMapping)-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 BorrowMapping", 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 - } - if err := m.BorrowMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - 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 6: - 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 7: - 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 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserLendIdMapping", 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.UserLendIdMapping = append(m.UserLendIdMapping, UserLendIdMapping{}) - if err := m.UserLendIdMapping[len(m.UserLendIdMapping)-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 LendIdByOwnerAndPoolMapping", 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.LendIdByOwnerAndPoolMapping = append(m.LendIdByOwnerAndPoolMapping, LendIdByOwnerAndPoolMapping{}) - if err := m.LendIdByOwnerAndPoolMapping[len(m.LendIdByOwnerAndPoolMapping)-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 LendIdToBorrowIdMapping", 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.LendIdToBorrowIdMapping = append(m.LendIdToBorrowIdMapping, LendIdToBorrowIdMapping{}) - if err := m.LendIdToBorrowIdMapping[len(m.LendIdToBorrowIdMapping)-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 AssetStats", 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.AssetStats = append(m.AssetStats, AssetStats{}) - if err := m.AssetStats[len(m.AssetStats)-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 LendMapping", 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 - } - if err := m.LendMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserDepositStats", 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 - } - if err := m.UserDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReserveDepositStats", 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 - } - if err := m.ReserveDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BuyBackDepositStats", 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 - } - if err := m.BuyBackDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowDepositStats", 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 - } - if err := m.BorrowDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 17: - 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 18: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesStats", 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.AssetRatesStats = append(m.AssetRatesStats, AssetRatesStats{}) - if err := m.AssetRatesStats[len(m.AssetRatesStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 19: - 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 20: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 - } - if err := m.Params.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 6c15de33b..ea59b898d 100644 --- a/x/lend/types/gov.go +++ b/x/lend/types/gov.go @@ -5,31 +5,35 @@ import ( ) var ( - ProposalAddLendPairs = "ProposalAddLendPairs" - ProposalAddPool = "ProposalAddPool" - ProposalAddAssetToPair = "ProposalAddAssetToPair" - ProposalAddAssetRatesStats = "ProposalAddAssetRatesStats" - ProposalAddAuctionParams = "ProposalAddAuctionParams" + ProposalAddLendPairs = "ProposalAddLendPairs" + ProposalUpdateLendPairs = "ProposalUpdateLendPairs" + ProposalAddPool = "ProposalAddPool" + ProposalAddAssetToPair = "ProposalAddAssetToPair" + ProposalAddAssetRatesParams = "ProposalAddAssetRatesParams" + ProposalAddAuctionParams = "ProposalAddAuctionParams" ) 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) govtypes.RegisterProposalTypeCodec(&AddAssetToPairProposal{}, "comdex/AddAssetToPairProposal") - govtypes.RegisterProposalType(ProposalAddAssetRatesStats) - govtypes.RegisterProposalTypeCodec(&AddAssetRatesStats{}, "comdex/AddAssetRatesStats") + govtypes.RegisterProposalType(ProposalAddAssetRatesParams) + govtypes.RegisterProposalTypeCodec(&AddAssetRatesParams{}, "comdex/AddAssetRatesParams") govtypes.RegisterProposalType(ProposalAddAuctionParams) govtypes.RegisterProposalTypeCodec(&AddAuctionParamsProposal{}, "comdex/AddAuctionParamsProposal") } var ( _ govtypes.Content = &LendPairsProposal{} + _ govtypes.Content = &UpdateLendPairsProposal{} _ govtypes.Content = &AddPoolsProposal{} _ govtypes.Content = &AddAssetToPairProposal{} - _ govtypes.Content = &AddAssetRatesStats{} + _ govtypes.Content = &AddAssetRatesParams{} _ govtypes.Content = &AddAuctionParamsProposal{} ) @@ -58,6 +62,31 @@ 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, @@ -118,29 +147,29 @@ func (p *AddAssetToPairProposal) ValidateBasic() error { return nil } -func NewAddAssetRatesStats(title, description string, AssetRatesStats AssetRatesStats) govtypes.Content { - return &AddAssetRatesStats{ - Title: title, - Description: description, - AssetRatesStats: AssetRatesStats, +func NewAddassetRatesParams(title, description string, AssetRatesParams AssetRatesParams) govtypes.Content { + return &AddAssetRatesParams{ + Title: title, + Description: description, + AssetRatesParams: AssetRatesParams, } } -func (p *AddAssetRatesStats) ProposalRoute() string { +func (p *AddAssetRatesParams) ProposalRoute() string { return RouterKey } -func (p *AddAssetRatesStats) ProposalType() string { - return ProposalAddAssetRatesStats +func (p *AddAssetRatesParams) ProposalType() string { + return ProposalAddAssetRatesParams } -func (p *AddAssetRatesStats) ValidateBasic() error { +func (p *AddAssetRatesParams) ValidateBasic() error { err := govtypes.ValidateAbstract(p) if err != nil { return err } - if err := p.AssetRatesStats.Validate(); err != nil { + if err = p.AssetRatesParams.Validate(); err != nil { return err } diff --git a/x/lend/types/gov.pb.go b/x/lend/types/gov.pb.go index fe09d5790..7d6ab5b01 100644 --- a/x/lend/types/gov.pb.go +++ b/x/lend/types/gov.pb.go @@ -143,6 +143,66 @@ 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"` @@ -153,7 +213,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{2} + return fileDescriptor_4c877ba3eefc3a22, []int{3} } func (m *AddAssetToPairProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,24 +263,24 @@ func (m *AddAssetToPairProposal) GetAssetToPairMapping() AssetToPairMapping { return AssetToPairMapping{} } -type AddAssetRatesStats 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"` - AssetRatesStats AssetRatesStats `protobuf:"bytes,3,opt,name=AssetRatesStats,proto3" json:"AssetRatesStats"` +type AddAssetRatesParams 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"` + AssetRatesParams AssetRatesParams `protobuf:"bytes,3,opt,name=AssetRatesParams,proto3" json:"AssetRatesParams"` } -func (m *AddAssetRatesStats) Reset() { *m = AddAssetRatesStats{} } -func (m *AddAssetRatesStats) String() string { return proto.CompactTextString(m) } -func (*AddAssetRatesStats) ProtoMessage() {} -func (*AddAssetRatesStats) Descriptor() ([]byte, []int) { - return fileDescriptor_4c877ba3eefc3a22, []int{3} +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} } -func (m *AddAssetRatesStats) XXX_Unmarshal(b []byte) error { +func (m *AddAssetRatesParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *AddAssetRatesStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AddAssetRatesParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_AddAssetRatesStats.Marshal(b, m, deterministic) + return xxx_messageInfo_AddAssetRatesParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -230,37 +290,37 @@ func (m *AddAssetRatesStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *AddAssetRatesStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_AddAssetRatesStats.Merge(m, src) +func (m *AddAssetRatesParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_AddAssetRatesParams.Merge(m, src) } -func (m *AddAssetRatesStats) XXX_Size() int { +func (m *AddAssetRatesParams) XXX_Size() int { return m.Size() } -func (m *AddAssetRatesStats) XXX_DiscardUnknown() { - xxx_messageInfo_AddAssetRatesStats.DiscardUnknown(m) +func (m *AddAssetRatesParams) XXX_DiscardUnknown() { + xxx_messageInfo_AddAssetRatesParams.DiscardUnknown(m) } -var xxx_messageInfo_AddAssetRatesStats proto.InternalMessageInfo +var xxx_messageInfo_AddAssetRatesParams proto.InternalMessageInfo -func (m *AddAssetRatesStats) GetTitle() string { +func (m *AddAssetRatesParams) GetTitle() string { if m != nil { return m.Title } return "" } -func (m *AddAssetRatesStats) GetDescription() string { +func (m *AddAssetRatesParams) GetDescription() string { if m != nil { return m.Description } return "" } -func (m *AddAssetRatesStats) GetAssetRatesStats() AssetRatesStats { +func (m *AddAssetRatesParams) GetAssetRatesParams() AssetRatesParams { if m != nil { - return m.AssetRatesStats + return m.AssetRatesParams } - return AssetRatesStats{} + return AssetRatesParams{} } type AddAuctionParamsProposal struct { @@ -273,7 +333,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{4} + return fileDescriptor_4c877ba3eefc3a22, []int{5} } func (m *AddAuctionParamsProposal) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,42 +386,44 @@ 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((*AddAssetRatesStats)(nil), "comdex.lend.v1beta1.AddAssetRatesStats") + proto.RegisterType((*AddAssetRatesParams)(nil), "comdex.lend.v1beta1.AddAssetRatesParams") proto.RegisterType((*AddAuctionParamsProposal)(nil), "comdex.lend.v1beta1.AddAuctionParamsProposal") } func init() { proto.RegisterFile("comdex/lend/v1beta1/gov.proto", fileDescriptor_4c877ba3eefc3a22) } var fileDescriptor_4c877ba3eefc3a22 = []byte{ - // 424 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, 0x6b, 0x94, 0x12, 0x0b, 0xa6, 0x65, 0x10, 0xed, 0xc5, - 0x84, 0xda, 0x8b, 0x78, 0x10, 0x5a, 0x10, 0x3c, 0xa8, 0x84, 0xd8, 0x93, 0x20, 0x32, 0xcd, 0x4c, - 0xe3, 0x40, 0x9a, 0x09, 0x99, 0x69, 0x69, 0xdf, 0x62, 0x5f, 0x63, 0x1f, 0x60, 0xdf, 0xa1, 0x87, - 0x3d, 0xf4, 0xb8, 0x7b, 0x29, 0x4b, 0xfb, 0x06, 0x7d, 0x82, 0x65, 0x92, 0x59, 0xb6, 0xed, 0x66, - 0xf7, 0x98, 0x5b, 0x92, 0xef, 0xfb, 0xff, 0xbf, 0xef, 0x07, 0x99, 0x81, 0x6f, 0x03, 0x3e, 0x21, - 0x74, 0xee, 0x46, 0x34, 0x26, 0xee, 0xac, 0x3b, 0xa2, 0x12, 0x77, 0xdd, 0x90, 0xcf, 0x9c, 0x24, - 0xe5, 0x92, 0x9b, 0xaf, 0x72, 0xd9, 0x51, 0xb2, 0xa3, 0xe5, 0xe6, 0xeb, 0x90, 0x87, 0x3c, 0xd3, - 0x5d, 0xf5, 0x94, 0x5b, 0x9b, 0x76, 0xd1, 0xa6, 0x6c, 0x2e, 0xd3, 0xd1, 0x19, 0x80, 0x2f, 0x7f, - 0xd0, 0x98, 0x78, 0x98, 0xa5, 0xc2, 0x4b, 0x79, 0xc2, 0x05, 0x8e, 0xcc, 0xf7, 0xb0, 0x2a, 0x99, - 0x8c, 0xa8, 0x05, 0xda, 0xa0, 0xf3, 0x74, 0x50, 0xdf, 0xad, 0x5b, 0xcf, 0x16, 0x78, 0x12, 0x7d, - 0x41, 0xd9, 0x67, 0xe4, 0xe7, 0xb2, 0xf9, 0x19, 0xd6, 0x08, 0x15, 0x41, 0xca, 0x12, 0xc9, 0x78, - 0x6c, 0x3d, 0xca, 0xdc, 0x8d, 0xdd, 0xba, 0x65, 0xe6, 0xee, 0x3d, 0x11, 0xf9, 0xfb, 0x56, 0xf3, - 0x2b, 0xac, 0x26, 0x2a, 0xd2, 0x7a, 0xdc, 0x06, 0x9d, 0xda, 0x27, 0xe4, 0x14, 0x20, 0x39, 0xdf, - 0xe6, 0x92, 0xc6, 0x84, 0x92, 0x7f, 0xaa, 0xdd, 0xa0, 0xb2, 0x5c, 0xb7, 0x0c, 0x3f, 0x1f, 0x43, - 0xa7, 0x00, 0xd6, 0xfb, 0x84, 0x78, 0x9c, 0x47, 0x65, 0xd6, 0xee, 0xc1, 0x8a, 0x8a, 0xd4, 0xad, - 0xdf, 0x14, 0xb6, 0x56, 0x06, 0x5d, 0x36, 0x33, 0xa3, 0x4b, 0x00, 0x1b, 0x7d, 0x42, 0xfa, 0x42, - 0x50, 0x39, 0xe4, 0x8a, 0xa5, 0xc4, 0xc6, 0x7f, 0xa1, 0xb9, 0x17, 0xfc, 0x13, 0x27, 0x09, 0x8b, - 0x43, 0xdd, 0xff, 0x43, 0x61, 0xff, 0xbb, 0x76, 0x4d, 0x53, 0xb0, 0x08, 0x9d, 0x03, 0x68, 0xde, - 0xb0, 0xf9, 0x58, 0x52, 0xf1, 0x5b, 0x62, 0x29, 0x4a, 0xe0, 0x1a, 0xc2, 0x17, 0x47, 0xa1, 0x1a, - 0xea, 0xdd, 0xfd, 0x50, 0xb7, 0x5e, 0x4d, 0x74, 0xbc, 0x42, 0xe1, 0x58, 0x0a, 0x67, 0x1a, 0xa8, - 0x10, 0x0f, 0xa7, 0x78, 0x52, 0xe6, 0xef, 0xf5, 0x0b, 0x3e, 0x3f, 0x88, 0x7e, 0xf0, 0x74, 0x1c, - 0x38, 0x35, 0xd0, 0xe1, 0xf8, 0xe0, 0xfb, 0x72, 0x63, 0x83, 0xd5, 0xc6, 0x06, 0x57, 0x1b, 0x1b, - 0x9c, 0x6c, 0x6d, 0x63, 0xb5, 0xb5, 0x8d, 0x8b, 0xad, 0x6d, 0xfc, 0x71, 0x42, 0x26, 0xff, 0x4f, - 0x47, 0x6a, 0xb1, 0x9b, 0x2f, 0xff, 0xc8, 0xc7, 0x63, 0x16, 0x30, 0x1c, 0xe9, 0x77, 0x57, 0x5f, - 0x1a, 0x72, 0x91, 0x50, 0x31, 0x7a, 0x92, 0x5d, 0x17, 0xbd, 0xeb, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x2b, 0x07, 0x84, 0x86, 0x9a, 0x04, 0x00, 0x00, + // 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, 0x62, 0xb3, 0xeb, 0x59, 0x61, 0x31, 0x86, 0xbe, 0x00, + 0xd8, 0x1a, 0x13, 0x12, 0x70, 0x9e, 0xd4, 0x59, 0x7b, 0x04, 0x2f, 0x74, 0xa4, 0x69, 0x7d, 0xb7, + 0xb2, 0xb5, 0x36, 0x98, 0xb2, 0xb9, 0x19, 0x7d, 0x03, 0xf0, 0xce, 0x5b, 0x41, 0xb0, 0xa2, 0x97, + 0xf1, 0x49, 0xff, 0x04, 0xb0, 0x33, 0x26, 0x64, 0x2c, 0x25, 0x55, 0x6f, 0xb8, 0xd6, 0x6b, 0x2c, + 0xff, 0x01, 0xda, 0xa5, 0xe0, 0x57, 0x58, 0x08, 0x96, 0xc6, 0x86, 0xe4, 0x61, 0x25, 0xc9, 0xb9, + 0xdd, 0xe0, 0x54, 0x2c, 0x42, 0x5b, 0x00, 0xdb, 0x7f, 0xd8, 0x42, 0xac, 0xa8, 0x0c, 0x70, 0x86, + 0xe7, 0xb2, 0x06, 0xb0, 0x77, 0xb0, 0xf5, 0x77, 0xaa, 0xc1, 0xba, 0xff, 0x6f, 0xac, 0x92, 0xd9, + 0x40, 0x9d, 0x2d, 0x41, 0xdf, 0x01, 0x74, 0x34, 0xd2, 0x22, 0xd2, 0x39, 0xc5, 0x61, 0x8d, 0x2f, + 0xec, 0x35, 0xbc, 0x79, 0x12, 0xfd, 0xdf, 0xaf, 0xee, 0xc4, 0x69, 0x88, 0x4e, 0xc7, 0x27, 0x2f, + 0x36, 0x7b, 0x17, 0x6c, 0xf7, 0x2e, 0xf8, 0xb5, 0x77, 0xc1, 0xe7, 0x83, 0x6b, 0x6d, 0x0f, 0xae, + 0xf5, 0xe3, 0xe0, 0x5a, 0xef, 0xbd, 0x98, 0xa9, 0x4f, 0x8b, 0xa9, 0x5e, 0xec, 0x17, 0xcb, 0x1f, + 0xf1, 0xd9, 0x8c, 0x45, 0x0c, 0x27, 0xe6, 0xbf, 0x6f, 0xae, 0x3d, 0xb5, 0x16, 0x54, 0x4e, 0xaf, + 0xe5, 0x17, 0xde, 0xe8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x01, 0x98, 0xb8, 0xe2, 0x5c, 0x05, + 0x00, 0x00, } func (m *LendPairsProposal) Marshal() (dAtA []byte, err error) { @@ -458,6 +520,53 @@ 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) @@ -505,7 +614,7 @@ func (m *AddAssetToPairProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *AddAssetRatesStats) Marshal() (dAtA []byte, err error) { +func (m *AddAssetRatesParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -515,18 +624,18 @@ func (m *AddAssetRatesStats) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AddAssetRatesStats) MarshalTo(dAtA []byte) (int, error) { +func (m *AddAssetRatesParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AddAssetRatesStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AddAssetRatesParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.AssetRatesStats.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AssetRatesParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -648,6 +757,25 @@ 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 @@ -667,7 +795,7 @@ func (m *AddAssetToPairProposal) Size() (n int) { return n } -func (m *AddAssetRatesStats) Size() (n int) { +func (m *AddAssetRatesParams) Size() (n int) { if m == nil { return 0 } @@ -681,7 +809,7 @@ func (m *AddAssetRatesStats) Size() (n int) { if l > 0 { n += 1 + l + sovGov(uint64(l)) } - l = m.AssetRatesStats.Size() + l = m.AssetRatesParams.Size() n += 1 + l + sovGov(uint64(l)) return n } @@ -1005,6 +1133,153 @@ 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 @@ -1152,7 +1427,7 @@ func (m *AddAssetToPairProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *AddAssetRatesStats) Unmarshal(dAtA []byte) error { +func (m *AddAssetRatesParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1175,10 +1450,10 @@ func (m *AddAssetRatesStats) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AddAssetRatesStats: wiretype end group for non-group") + return fmt.Errorf("proto: AddAssetRatesParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AddAssetRatesStats: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AddAssetRatesParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1247,7 +1522,7 @@ func (m *AddAssetRatesStats) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1274,7 +1549,7 @@ func (m *AddAssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AssetRatesStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.AssetRatesParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lend/types/keys.go b/x/lend/types/keys.go index 953e2a70f..11c0aa6a5 100644 --- a/x/lend/types/keys.go +++ b/x/lend/types/keys.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -51,48 +49,25 @@ var ( PoolKeyPrefix = []byte{0x13} LendUserPrefix = []byte{0x15} - LendHistoryIDPrefix = []byte{0x16} + LendCounterIDPrefix = []byte{0x16} PoolIDPrefix = []byte{0x17} LendPairIDKey = []byte{0x18} LendPairKeyPrefix = []byte{0x19} - BorrowHistoryIDPrefix = []byte{0x25} + BorrowCounterIDPrefix = []byte{0x25} BorrowPairKeyPrefix = []byte{0x26} - LendsKey = []byte{0x32} - BorrowsKey = []byte{0x33} - BorrowStatsPrefix = []byte{0x40} AuctionParamPrefix = []byte{0x41} AssetToPairMappingKeyPrefix = []byte{0x20} LendForAddressByAssetKeyPrefix = []byte{0x22} - UserLendsForAddressKeyPrefix = []byte{0x23} BorrowForAddressByPairKeyPrefix = []byte{0x24} - UserBorrowsForAddressKeyPrefix = []byte{0x27} - LendIDToBorrowIDMappingKeyPrefix = []byte{0x28} AssetStatsByPoolIDAndAssetIDKeyPrefix = []byte{0x29} - AssetRatesStatsKeyPrefix = []byte{0x30} - LendByUserAndPoolPrefix = []byte{0x34} - BorrowByUserAndPoolPrefix = []byte{0x35} - DepositStatsPrefix = []byte{0x36} - UserDepositStatsPrefix = []byte{0x37} - ReserveDepositStatsPrefix = []byte{0x38} - BuyBackDepositStatsPrefix = []byte{0x39} - ReservePoolRecordsForBorrowKeyPrefix = []byte{0x42} + AssetRatesParamsKeyPrefix = []byte{0x30} LendRewardsTrackerKeyPrefix = []byte{0x43} BorrowInterestTrackerKeyPrefix = []byte{0x44} + UserLendBorrowMappingKeyPrefix = []byte{0x45} + ReserveBuybackAssetDataKeyPrefix = []byte{0x46} ) -func ReserveFundsKey(tokenDenom string) []byte { - key := CreateReserveAmountKeyNoDenom() - key = append(key, []byte(tokenDenom)...) - return append(key, 0) // append 0 for null-termination -} - -func CreateReserveAmountKeyNoDenom() []byte { - var key []byte - key = append(key, KeyPrefixReserveAmount...) - return key -} - func LendUserKey(ID uint64) []byte { return append(LendUserPrefix, sdk.Uint64ToBigEndian(ID)...) } @@ -109,51 +84,18 @@ func AuctionParamKey(ID uint64) []byte { return append(AuctionParamPrefix, sdk.Uint64ToBigEndian(ID)...) } -func AssetRatesStatsKey(ID uint64) []byte { - return append(AssetRatesStatsKeyPrefix, sdk.Uint64ToBigEndian(ID)...) +func AssetRatesParamsKey(ID uint64) []byte { + return append(AssetRatesParamsKeyPrefix, sdk.Uint64ToBigEndian(ID)...) } func BorrowUserKey(ID uint64) []byte { return append(BorrowPairKeyPrefix, sdk.Uint64ToBigEndian(ID)...) } -func ReservePoolRecordsForBorrowKey(ID uint64) []byte { - return append(ReservePoolRecordsForBorrowKeyPrefix, sdk.Uint64ToBigEndian(ID)...) -} - func AssetToPairMappingKey(assetID, poolID uint64) []byte { return append(append(AssetToPairMappingKeyPrefix, sdk.Uint64ToBigEndian(assetID)...), sdk.Uint64ToBigEndian(poolID)...) } -func LendForAddressByAsset(address sdk.AccAddress, assetID, poolID uint64) []byte { - v := append(LendForAddressByAssetKeyPrefix, address.Bytes()...) - if len(v) != 1+20 { - panic(fmt.Errorf("invalid key length %d; expected %d", len(v), 1+20)) - } - return append(append(v, sdk.Uint64ToBigEndian(assetID)...), sdk.Uint64ToBigEndian(poolID)...) -} - -func BorrowForAddressByPair(address sdk.AccAddress, pairID uint64) []byte { - v := append(BorrowForAddressByPairKeyPrefix, address.Bytes()...) - if len(v) != 1+20 { - panic(fmt.Errorf("invalid key length %d; expected %d", len(v), 1+20)) - } - - return append(v, sdk.Uint64ToBigEndian(pairID)...) -} - -func UserLendsForAddressKey(address string) []byte { - return append(UserLendsForAddressKeyPrefix, address...) -} - -func UserBorrowsForAddressKey(address string) []byte { - return append(UserBorrowsForAddressKeyPrefix, address...) -} - -func LendIDToBorrowIDMappingKey(ID uint64) []byte { - return append(LendIDToBorrowIDMappingKeyPrefix, sdk.Uint64ToBigEndian(ID)...) -} - func LendRewardsTrackerKey(ID uint64) []byte { return append(LendRewardsTrackerKeyPrefix, sdk.Uint64ToBigEndian(ID)...) } @@ -167,10 +109,14 @@ func SetAssetStatsByPoolIDAndAssetID(assetID, pairID uint64) []byte { return append(v, sdk.Uint64ToBigEndian(pairID)...) } -func LendByUserAndPoolKey(owner string, ID uint64) []byte { - return append(append(LendByUserAndPoolPrefix, sdk.Uint64ToBigEndian(ID)...), owner...) +func UserLendBorrowMappingKey(owner string, lendID uint64) []byte { + return append(append(UserLendBorrowMappingKeyPrefix, owner...), sdk.Uint64ToBigEndian(lendID)...) +} + +func UserLendBorrowKey(owner string) []byte { + return append(UserLendBorrowMappingKeyPrefix, owner...) } -func BorrowByUserAndPoolKey(owner string, ID uint64) []byte { - return append(append(BorrowByUserAndPoolPrefix, sdk.Uint64ToBigEndian(ID)...), owner...) +func ReserveBuybackAssetDataKey(ID uint64) []byte { + return append(ReserveBuybackAssetDataKeyPrefix, sdk.Uint64ToBigEndian(ID)...) } diff --git a/x/lend/types/lend.pb.go b/x/lend/types/lend.pb.go index f309d3b88..a369db1b2 100644 --- a/x/lend/types/lend.pb.go +++ b/x/lend/types/lend.pb.go @@ -36,13 +36,11 @@ type LendAsset struct { 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"` + AvailableToBorrow github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=available_to_borrow,json=availableToBorrow,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"available_to_borrow" yaml:"available_to_borrow"` + AppID uint64 `protobuf:"varint,8,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` + GlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,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,10,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,11,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` } func (m *LendAsset) Reset() { *m = LendAsset{} } @@ -142,21 +140,21 @@ func (m *LendAsset) GetCPoolName() string { } type BorrowAsset 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"` + 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"` + InterestAccumulated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=interest_accumulated,json=interestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"interest_accumulated" yaml:"interest_accumulated"` + 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"` + ReserveGlobalIndex github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,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,13,opt,name=last_interaction_time,json=lastInteractionTime,proto3,stdtime" json:"last_interaction_time" yaml:"last_interaction_time"` + CPoolName string `protobuf:"bytes,14,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` + IsLiquidated bool `protobuf:"varint,15,opt,name=is_liquidated,json=isLiquidated,proto3" json:"is_liquidated,omitempty" yaml:"is_liquidated"` } func (m *BorrowAsset) Reset() { *m = BorrowAsset{} } @@ -262,15 +260,19 @@ func (m *BorrowAsset) GetCPoolName() string { return "" } +func (m *BorrowAsset) GetIsLiquidated() bool { + if m != nil { + return m.IsLiquidated + } + return false +} + type Pool 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 []AssetDataPoolMapping `protobuf:"bytes,8,rep,name=asset_data,json=assetData,proto3" json:"asset_data" yaml:"asset_data"` + 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"` + CPoolName string `protobuf:"bytes,3,opt,name=cpool_name,json=cpoolName,proto3" json:"cpool_name,omitempty" yaml:"cpool_name"` + ReserveFunds uint64 `protobuf:"varint,4,opt,name=reserve_funds,json=reserveFunds,proto3" json:"reserve_funds,omitempty" yaml:"reserve_funds"` + AssetData []*AssetDataPoolMapping `protobuf:"bytes,5,rep,name=asset_data,json=assetData,proto3" json:"asset_data,omitempty" yaml:"asset_data"` } func (m *Pool) Reset() { *m = Pool{} } @@ -320,58 +322,108 @@ func (m *Pool) GetModuleName() string { return "" } -func (m *Pool) GetMainAssetId() uint64 { +func (m *Pool) GetCPoolName() string { if m != nil { - return m.MainAssetId + return m.CPoolName } - return 0 + return "" } -func (m *Pool) GetFirstBridgedAssetID() uint64 { +func (m *Pool) GetReserveFunds() uint64 { if m != nil { - return m.FirstBridgedAssetID + return m.ReserveFunds } return 0 } -func (m *Pool) GetSecondBridgedAssetID() uint64 { +func (m *Pool) GetAssetData() []*AssetDataPoolMapping { if m != nil { - return m.SecondBridgedAssetID + return m.AssetData } - return 0 + return nil } -func (m *Pool) GetCPoolName() string { +type UserAssetLendBorrowMapping struct { + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` + //to check if poool id is needed + LendId uint64 `protobuf:"varint,2,opt,name=lend_id,json=lendId,proto3" json:"lend_id,omitempty" yaml:"lend_id"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + BorrowId []uint64 `protobuf:"varint,4,rep,packed,name=borrow_id,json=borrowId,proto3" json:"borrow_id,omitempty" yaml:"borrow_id"` +} + +func (m *UserAssetLendBorrowMapping) Reset() { *m = UserAssetLendBorrowMapping{} } +func (m *UserAssetLendBorrowMapping) String() string { return proto.CompactTextString(m) } +func (*UserAssetLendBorrowMapping) ProtoMessage() {} +func (*UserAssetLendBorrowMapping) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{3} +} +func (m *UserAssetLendBorrowMapping) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UserAssetLendBorrowMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UserAssetLendBorrowMapping.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 *UserAssetLendBorrowMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_UserAssetLendBorrowMapping.Merge(m, src) +} +func (m *UserAssetLendBorrowMapping) XXX_Size() int { + return m.Size() +} +func (m *UserAssetLendBorrowMapping) XXX_DiscardUnknown() { + xxx_messageInfo_UserAssetLendBorrowMapping.DiscardUnknown(m) +} + +var xxx_messageInfo_UserAssetLendBorrowMapping proto.InternalMessageInfo + +func (m *UserAssetLendBorrowMapping) GetOwner() string { if m != nil { - return m.CPoolName + return m.Owner } return "" } -func (m *Pool) GetReserveFunds() uint64 { +func (m *UserAssetLendBorrowMapping) GetLendId() uint64 { if m != nil { - return m.ReserveFunds + return m.LendId } return 0 } -func (m *Pool) GetAssetData() []AssetDataPoolMapping { +func (m *UserAssetLendBorrowMapping) GetPoolId() uint64 { if m != nil { - return m.AssetData + return m.PoolId + } + return 0 +} + +func (m *UserAssetLendBorrowMapping) GetBorrowId() []uint64 { + if m != nil { + return m.BorrowId } return nil } type AssetDataPoolMapping 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"` + AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + // 1 for main_asset, 2 for 1st transit_asset, 3 for 2nd transit_asset + AssetTransitType uint64 `protobuf:"varint,2,opt,name=asset_transit_type,json=assetTransitType,proto3" json:"asset_transit_type,omitempty" yaml:"asset_transit_type"` + SupplyCap uint64 `protobuf:"varint,3,opt,name=supply_cap,json=supplyCap,proto3" json:"supply_cap,omitempty" yaml:"supply_cap"` } func (m *AssetDataPoolMapping) Reset() { *m = AssetDataPoolMapping{} } func (m *AssetDataPoolMapping) String() string { return proto.CompactTextString(m) } func (*AssetDataPoolMapping) ProtoMessage() {} func (*AssetDataPoolMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{3} + return fileDescriptor_b87bb4bef8334ddd, []int{4} } func (m *AssetDataPoolMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -407,11 +459,18 @@ func (m *AssetDataPoolMapping) GetAssetID() uint64 { return 0 } -func (m *AssetDataPoolMapping) GetIsBridged() bool { +func (m *AssetDataPoolMapping) GetAssetTransitType() uint64 { if m != nil { - return m.IsBridged + return m.AssetTransitType } - return false + return 0 +} + +func (m *AssetDataPoolMapping) GetSupplyCap() uint64 { + if m != nil { + return m.SupplyCap + } + return 0 } type Extended_Pair struct { @@ -427,7 +486,7 @@ func (m *Extended_Pair) Reset() { *m = Extended_Pair{} } func (m *Extended_Pair) String() string { return proto.CompactTextString(m) } func (*Extended_Pair) ProtoMessage() {} func (*Extended_Pair) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{4} + return fileDescriptor_b87bb4bef8334ddd, []int{5} } func (m *Extended_Pair) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -499,8 +558,8 @@ func (m *Extended_Pair) GetMinUsdValueLeft() uint64 { } type AssetToPairMapping struct { - AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` - PoolID uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` PairID []uint64 `protobuf:"varint,3,rep,packed,name=pair_id,json=pairId,proto3" json:"pair_id,omitempty" yaml:"pair_id"` } @@ -508,7 +567,7 @@ func (m *AssetToPairMapping) Reset() { *m = AssetToPairMapping{} } func (m *AssetToPairMapping) String() string { return proto.CompactTextString(m) } func (*AssetToPairMapping) ProtoMessage() {} func (*AssetToPairMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{5} + return fileDescriptor_b87bb4bef8334ddd, []int{6} } func (m *AssetToPairMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -537,16 +596,16 @@ func (m *AssetToPairMapping) XXX_DiscardUnknown() { var xxx_messageInfo_AssetToPairMapping proto.InternalMessageInfo -func (m *AssetToPairMapping) GetAssetID() uint64 { +func (m *AssetToPairMapping) GetPoolID() uint64 { if m != nil { - return m.AssetID + return m.PoolID } return 0 } -func (m *AssetToPairMapping) GetPoolID() uint64 { +func (m *AssetToPairMapping) GetAssetID() uint64 { if m != nil { - return m.PoolID + return m.AssetID } return 0 } @@ -558,23 +617,33 @@ func (m *AssetToPairMapping) GetPairID() []uint64 { return nil } -type UserLendIdMapping struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - LendIDs []uint64 `protobuf:"varint,2,rep,packed,name=lend_ids,json=lendIds,proto3" json:"lend_ids,omitempty" yaml:"lend_ids"` -} - -func (m *UserLendIdMapping) Reset() { *m = UserLendIdMapping{} } -func (m *UserLendIdMapping) String() string { return proto.CompactTextString(m) } -func (*UserLendIdMapping) ProtoMessage() {} -func (*UserLendIdMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{6} +type PoolAssetLBMapping struct { + PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + LendIds []uint64 `protobuf:"varint,3,rep,packed,name=lend_ids,json=lendIds,proto3" json:"lend_ids,omitempty" yaml:"lend_ids"` + BorrowIds []uint64 `protobuf:"varint,4,rep,packed,name=borrow_ids,json=borrowIds,proto3" json:"borrow_ids,omitempty" yaml:"borrow_ids"` + TotalBorrowed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=total_borrowed,json=totalBorrowed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_borrowed" yaml:"total_borrowed"` + TotalStableBorrowed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=total_stable_borrowed,json=totalStableBorrowed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_stable_borrowed" yaml:"total_stable_borrowed"` + TotalLend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=total_lend,json=totalLend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_lend" yaml:"total_lend"` + TotalInterestAccumulated github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,8,opt,name=total_interest_accumulated,json=totalInterestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_interest_accumulated" yaml:"total_interest_accumulated"` + LendApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=lend_apr,json=lendApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"lend_apr" yaml:"lend_apr"` + BorrowApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=borrow_apr,json=borrowApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"borrow_apr" yaml:"borrow_apr"` + StableBorrowApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=stable_borrow_apr,json=stableBorrowApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_borrow_apr" yaml:"stable_borrow_apr"` + UtilisationRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=utilisation_ratio,json=utilisationRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"utilisation_ratio" yaml:"utilisation_ratio"` +} + +func (m *PoolAssetLBMapping) Reset() { *m = PoolAssetLBMapping{} } +func (m *PoolAssetLBMapping) String() string { return proto.CompactTextString(m) } +func (*PoolAssetLBMapping) ProtoMessage() {} +func (*PoolAssetLBMapping) Descriptor() ([]byte, []int) { + return fileDescriptor_b87bb4bef8334ddd, []int{7} } -func (m *UserLendIdMapping) XXX_Unmarshal(b []byte) error { +func (m *PoolAssetLBMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *UserLendIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PoolAssetLBMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_UserLendIdMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_PoolAssetLBMapping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -584,110 +653,76 @@ func (m *UserLendIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *UserLendIdMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserLendIdMapping.Merge(m, src) +func (m *PoolAssetLBMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_PoolAssetLBMapping.Merge(m, src) } -func (m *UserLendIdMapping) XXX_Size() int { +func (m *PoolAssetLBMapping) XXX_Size() int { return m.Size() } -func (m *UserLendIdMapping) XXX_DiscardUnknown() { - xxx_messageInfo_UserLendIdMapping.DiscardUnknown(m) +func (m *PoolAssetLBMapping) XXX_DiscardUnknown() { + xxx_messageInfo_PoolAssetLBMapping.DiscardUnknown(m) } -var xxx_messageInfo_UserLendIdMapping proto.InternalMessageInfo - -func (m *UserLendIdMapping) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} +var xxx_messageInfo_PoolAssetLBMapping proto.InternalMessageInfo -func (m *UserLendIdMapping) GetLendIDs() []uint64 { +func (m *PoolAssetLBMapping) GetPoolID() uint64 { if m != nil { - return m.LendIDs - } - return nil -} - -type LendIdByOwnerAndPoolMapping struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - PoolID uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - LendIDs []uint64 `protobuf:"varint,3,rep,packed,name=lendIds,proto3" json:"lendIds,omitempty" yaml:"lend_ids"` -} - -func (m *LendIdByOwnerAndPoolMapping) Reset() { *m = LendIdByOwnerAndPoolMapping{} } -func (m *LendIdByOwnerAndPoolMapping) String() string { return proto.CompactTextString(m) } -func (*LendIdByOwnerAndPoolMapping) ProtoMessage() {} -func (*LendIdByOwnerAndPoolMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{7} -} -func (m *LendIdByOwnerAndPoolMapping) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LendIdByOwnerAndPoolMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LendIdByOwnerAndPoolMapping.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + return m.PoolID } + return 0 } -func (m *LendIdByOwnerAndPoolMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_LendIdByOwnerAndPoolMapping.Merge(m, src) -} -func (m *LendIdByOwnerAndPoolMapping) XXX_Size() int { - return m.Size() -} -func (m *LendIdByOwnerAndPoolMapping) XXX_DiscardUnknown() { - xxx_messageInfo_LendIdByOwnerAndPoolMapping.DiscardUnknown(m) -} - -var xxx_messageInfo_LendIdByOwnerAndPoolMapping proto.InternalMessageInfo -func (m *LendIdByOwnerAndPoolMapping) GetOwner() string { +func (m *PoolAssetLBMapping) GetAssetID() uint64 { if m != nil { - return m.Owner + return m.AssetID } - return "" + return 0 } -func (m *LendIdByOwnerAndPoolMapping) GetPoolID() uint64 { +func (m *PoolAssetLBMapping) GetLendIds() []uint64 { if m != nil { - return m.PoolID + return m.LendIds } - return 0 + return nil } -func (m *LendIdByOwnerAndPoolMapping) GetLendIDs() []uint64 { +func (m *PoolAssetLBMapping) GetBorrowIds() []uint64 { if m != nil { - return m.LendIDs + return m.BorrowIds } return nil } -type BorrowIdByOwnerAndPoolMapping struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - PoolID uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - BorrowIDs []uint64 `protobuf:"varint,3,rep,packed,name=borrowIds,proto3" json:"borrowIds,omitempty" yaml:"borrow_ids"` +type AssetRatesParams struct { + AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + UOptimal github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=u_optimal,json=uOptimal,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"u_optimal" yaml:"u_optimal"` + Base github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base" yaml:"base"` + Slope1 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=slope1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slope1" yaml:"slope1"` + Slope2 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slope2,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slope2" yaml:"slope2"` + EnableStableBorrow bool `protobuf:"varint,6,opt,name=enable_stable_borrow,json=enableStableBorrow,proto3" json:"enable_stable_borrow,omitempty" yaml:"enable_stable_borrow"` + StableBase github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=stable_base,json=stableBase,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_base" yaml:"stable_base"` + StableSlope1 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=stable_slope1,json=stableSlope1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_slope1" yaml:"stable_slope1"` + StableSlope2 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=stable_slope2,json=stableSlope2,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_slope2" yaml:"stable_slope2"` + Ltv github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=ltv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ltv" yaml:"ltv"` + LiquidationThreshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=liquidation_threshold,json=liquidationThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_threshold" yaml:"liquidation_threshold"` + LiquidationPenalty github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_penalty" yaml:"liquidation_penalty"` + LiquidationBonus github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=liquidation_bonus,json=liquidationBonus,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_bonus" yaml:"liquidation_bonus"` + ReserveFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=reserve_factor,json=reserveFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reserve_factor" yaml:"reserve_factor"` + CAssetID uint64 `protobuf:"varint,15,opt,name=c_asset_id,json=cAssetId,proto3" json:"c_asset_id,omitempty" yaml:"c_asset_id"` } -func (m *BorrowIdByOwnerAndPoolMapping) Reset() { *m = BorrowIdByOwnerAndPoolMapping{} } -func (m *BorrowIdByOwnerAndPoolMapping) String() string { return proto.CompactTextString(m) } -func (*BorrowIdByOwnerAndPoolMapping) ProtoMessage() {} -func (*BorrowIdByOwnerAndPoolMapping) Descriptor() ([]byte, []int) { +func (m *AssetRatesParams) Reset() { *m = AssetRatesParams{} } +func (m *AssetRatesParams) String() string { return proto.CompactTextString(m) } +func (*AssetRatesParams) ProtoMessage() {} +func (*AssetRatesParams) Descriptor() ([]byte, []int) { return fileDescriptor_b87bb4bef8334ddd, []int{8} } -func (m *BorrowIdByOwnerAndPoolMapping) XXX_Unmarshal(b []byte) error { +func (m *AssetRatesParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BorrowIdByOwnerAndPoolMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AssetRatesParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BorrowIdByOwnerAndPoolMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_AssetRatesParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -697,56 +732,55 @@ func (m *BorrowIdByOwnerAndPoolMapping) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *BorrowIdByOwnerAndPoolMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_BorrowIdByOwnerAndPoolMapping.Merge(m, src) +func (m *AssetRatesParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_AssetRatesParams.Merge(m, src) } -func (m *BorrowIdByOwnerAndPoolMapping) XXX_Size() int { +func (m *AssetRatesParams) XXX_Size() int { return m.Size() } -func (m *BorrowIdByOwnerAndPoolMapping) XXX_DiscardUnknown() { - xxx_messageInfo_BorrowIdByOwnerAndPoolMapping.DiscardUnknown(m) +func (m *AssetRatesParams) XXX_DiscardUnknown() { + xxx_messageInfo_AssetRatesParams.DiscardUnknown(m) } -var xxx_messageInfo_BorrowIdByOwnerAndPoolMapping proto.InternalMessageInfo +var xxx_messageInfo_AssetRatesParams proto.InternalMessageInfo -func (m *BorrowIdByOwnerAndPoolMapping) GetOwner() string { +func (m *AssetRatesParams) GetAssetID() uint64 { if m != nil { - return m.Owner + return m.AssetID } - return "" + return 0 } -func (m *BorrowIdByOwnerAndPoolMapping) GetPoolID() uint64 { +func (m *AssetRatesParams) GetEnableStableBorrow() bool { if m != nil { - return m.PoolID + return m.EnableStableBorrow } - return 0 + return false } -func (m *BorrowIdByOwnerAndPoolMapping) GetBorrowIDs() []uint64 { +func (m *AssetRatesParams) GetCAssetID() uint64 { if m != nil { - return m.BorrowIDs + return m.CAssetID } - return nil + return 0 } -type UserBorrowIdMapping struct { - Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` - BorrowIDs []uint64 `protobuf:"varint,2,rep,packed,name=borrow_ids,json=borrowIds,proto3" json:"borrow_ids,omitempty" yaml:"borrow_ids"` +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 *UserBorrowIdMapping) Reset() { *m = UserBorrowIdMapping{} } -func (m *UserBorrowIdMapping) String() string { return proto.CompactTextString(m) } -func (*UserBorrowIdMapping) ProtoMessage() {} -func (*UserBorrowIdMapping) Descriptor() ([]byte, []int) { +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 *UserBorrowIdMapping) XXX_Unmarshal(b []byte) error { +func (m *StableBorrowMapping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *UserBorrowIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *StableBorrowMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_UserBorrowIdMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_StableBorrowMapping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -756,49 +790,43 @@ func (m *UserBorrowIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *UserBorrowIdMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserBorrowIdMapping.Merge(m, src) +func (m *StableBorrowMapping) XXX_Merge(src proto.Message) { + xxx_messageInfo_StableBorrowMapping.Merge(m, src) } -func (m *UserBorrowIdMapping) XXX_Size() int { +func (m *StableBorrowMapping) XXX_Size() int { return m.Size() } -func (m *UserBorrowIdMapping) XXX_DiscardUnknown() { - xxx_messageInfo_UserBorrowIdMapping.DiscardUnknown(m) +func (m *StableBorrowMapping) XXX_DiscardUnknown() { + xxx_messageInfo_StableBorrowMapping.DiscardUnknown(m) } -var xxx_messageInfo_UserBorrowIdMapping proto.InternalMessageInfo - -func (m *UserBorrowIdMapping) GetOwner() string { - if m != nil { - return m.Owner - } - return "" -} +var xxx_messageInfo_StableBorrowMapping proto.InternalMessageInfo -func (m *UserBorrowIdMapping) GetBorrowIDs() []uint64 { +func (m *StableBorrowMapping) GetStableBorrowIDs() []uint64 { if m != nil { - return m.BorrowIDs + return m.StableBorrowIDs } return nil } -type LendIdToBorrowIdMapping struct { - LendingID uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` - BorrowingID []uint64 `protobuf:"varint,2,rep,packed,name=borrowing_id,json=borrowingId,proto3" json:"borrowing_id,omitempty" yaml:"borrowing_id"` +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"` + BuybackAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=buyback_amount,json=buybackAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"buyback_amount" yaml:"buyback_amount"` } -func (m *LendIdToBorrowIdMapping) Reset() { *m = LendIdToBorrowIdMapping{} } -func (m *LendIdToBorrowIdMapping) String() string { return proto.CompactTextString(m) } -func (*LendIdToBorrowIdMapping) ProtoMessage() {} -func (*LendIdToBorrowIdMapping) Descriptor() ([]byte, []int) { +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} } -func (m *LendIdToBorrowIdMapping) XXX_Unmarshal(b []byte) error { +func (m *ReserveBuybackAssetData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *LendIdToBorrowIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ReserveBuybackAssetData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_LendIdToBorrowIdMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_ReserveBuybackAssetData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -808,56 +836,48 @@ func (m *LendIdToBorrowIdMapping) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *LendIdToBorrowIdMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_LendIdToBorrowIdMapping.Merge(m, src) +func (m *ReserveBuybackAssetData) XXX_Merge(src proto.Message) { + xxx_messageInfo_ReserveBuybackAssetData.Merge(m, src) } -func (m *LendIdToBorrowIdMapping) XXX_Size() int { +func (m *ReserveBuybackAssetData) XXX_Size() int { return m.Size() } -func (m *LendIdToBorrowIdMapping) XXX_DiscardUnknown() { - xxx_messageInfo_LendIdToBorrowIdMapping.DiscardUnknown(m) +func (m *ReserveBuybackAssetData) XXX_DiscardUnknown() { + xxx_messageInfo_ReserveBuybackAssetData.DiscardUnknown(m) } -var xxx_messageInfo_LendIdToBorrowIdMapping proto.InternalMessageInfo +var xxx_messageInfo_ReserveBuybackAssetData proto.InternalMessageInfo -func (m *LendIdToBorrowIdMapping) GetLendingID() uint64 { +func (m *ReserveBuybackAssetData) GetAssetID() uint64 { if m != nil { - return m.LendingID + return m.AssetID } return 0 } -func (m *LendIdToBorrowIdMapping) GetBorrowingID() []uint64 { - if m != nil { - return m.BorrowingID - } - return nil -} - -type AssetStats struct { - PoolID uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - AssetID uint64 `protobuf:"varint,2,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` - TotalBorrowed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=total_borrowed,json=totalBorrowed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_borrowed" yaml:"total_borrowed"` - TotalStableBorrowed github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=total_stable_borrowed,json=totalStableBorrowed,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_stable_borrowed" yaml:"total_stable_borrowed"` - TotalLend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=total_lend,json=totalLend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_lend" yaml:"total_lend"` - LendApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=lend_apr,json=lendApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"lend_apr" yaml:"lend_apr"` - BorrowApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=borrow_apr,json=borrowApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"borrow_apr" yaml:"borrow_apr"` - StableBorrowApr github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=stable_borrow_apr,json=stableBorrowApr,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_borrow_apr" yaml:"stable_borrow_apr"` - UtilisationRatio github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=utilisation_ratio,json=utilisationRatio,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"utilisation_ratio" yaml:"utilisation_ratio"` +type AuctionParams struct { + AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` + AuctionDurationSeconds uint64 `protobuf:"varint,2,opt,name=auction_duration_seconds,json=auctionDurationSeconds,proto3" json:"auction_duration_seconds,omitempty" yaml:"auction_duration_seconds"` + Buffer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=buffer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"buffer" yaml:"buffer"` + Cusp github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=cusp,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"cusp" yaml:"cusp"` + Step github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=step,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"step" yaml:"step"` + PriceFunctionType uint64 `protobuf:"varint,6,opt,name=price_function_type,json=priceFunctionType,proto3" json:"price_function_type,omitempty" yaml:"price_function_type"` + DutchId uint64 `protobuf:"varint,7,opt,name=dutch_id,json=dutchId,proto3" json:"dutch_id,omitempty" yaml:"dutch_id"` + BidDurationSeconds uint64 `protobuf:"varint,8,opt,name=bid_duration_seconds,json=bidDurationSeconds,proto3" json:"bid_duration_seconds,omitempty" yaml:"bid_duration_seconds"` } -func (m *AssetStats) Reset() { *m = AssetStats{} } -func (m *AssetStats) String() string { return proto.CompactTextString(m) } -func (*AssetStats) ProtoMessage() {} -func (*AssetStats) Descriptor() ([]byte, []int) { +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} } -func (m *AssetStats) XXX_Unmarshal(b []byte) error { +func (m *AuctionParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *AssetStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *AuctionParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_AssetStats.Marshal(b, m, deterministic) + return xxx_messageInfo_AuctionParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -867,120 +887,70 @@ func (m *AssetStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *AssetStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssetStats.Merge(m, src) +func (m *AuctionParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuctionParams.Merge(m, src) } -func (m *AssetStats) XXX_Size() int { +func (m *AuctionParams) XXX_Size() int { return m.Size() } -func (m *AssetStats) XXX_DiscardUnknown() { - xxx_messageInfo_AssetStats.DiscardUnknown(m) +func (m *AuctionParams) XXX_DiscardUnknown() { + xxx_messageInfo_AuctionParams.DiscardUnknown(m) } -var xxx_messageInfo_AssetStats proto.InternalMessageInfo +var xxx_messageInfo_AuctionParams proto.InternalMessageInfo -func (m *AssetStats) GetPoolID() uint64 { +func (m *AuctionParams) GetAppId() uint64 { if m != nil { - return m.PoolID + return m.AppId } return 0 } -func (m *AssetStats) GetAssetID() uint64 { +func (m *AuctionParams) GetAuctionDurationSeconds() uint64 { if m != nil { - return m.AssetID + return m.AuctionDurationSeconds } return 0 } -type AssetRatesStats struct { - AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` - UOptimal github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=u_optimal,json=uOptimal,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"u_optimal" yaml:"u_optimal"` - Base github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=base,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base" yaml:"base"` - Slope1 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=slope1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slope1" yaml:"slope1"` - Slope2 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=slope2,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"slope2" yaml:"slope2"` - EnableStableBorrow bool `protobuf:"varint,6,opt,name=enable_stable_borrow,json=enableStableBorrow,proto3" json:"enable_stable_borrow,omitempty" yaml:"enable_stable_borrow"` - StableBase github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=stable_base,json=stableBase,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_base" yaml:"stable_base"` - StableSlope1 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=stable_slope1,json=stableSlope1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_slope1" yaml:"stable_slope1"` - StableSlope2 github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=stable_slope2,json=stableSlope2,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stable_slope2" yaml:"stable_slope2"` - Ltv github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=ltv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ltv" yaml:"ltv"` - LiquidationThreshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,11,opt,name=liquidation_threshold,json=liquidationThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_threshold" yaml:"liquidation_threshold"` - LiquidationPenalty github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=liquidation_penalty,json=liquidationPenalty,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_penalty" yaml:"liquidation_penalty"` - LiquidationBonus github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=liquidation_bonus,json=liquidationBonus,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidation_bonus" yaml:"liquidation_bonus"` - ReserveFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=reserve_factor,json=reserveFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reserve_factor" yaml:"reserve_factor"` - CAssetID uint64 `protobuf:"varint,15,opt,name=c_asset_id,json=cAssetId,proto3" json:"c_asset_id,omitempty" yaml:"c_asset_id"` -} - -func (m *AssetRatesStats) Reset() { *m = AssetRatesStats{} } -func (m *AssetRatesStats) String() string { return proto.CompactTextString(m) } -func (*AssetRatesStats) ProtoMessage() {} -func (*AssetRatesStats) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{12} -} -func (m *AssetRatesStats) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AssetRatesStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AssetRatesStats.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 *AssetRatesStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_AssetRatesStats.Merge(m, src) -} -func (m *AssetRatesStats) XXX_Size() int { - return m.Size() -} -func (m *AssetRatesStats) XXX_DiscardUnknown() { - xxx_messageInfo_AssetRatesStats.DiscardUnknown(m) -} - -var xxx_messageInfo_AssetRatesStats proto.InternalMessageInfo - -func (m *AssetRatesStats) GetAssetID() uint64 { +func (m *AuctionParams) GetPriceFunctionType() uint64 { if m != nil { - return m.AssetID + return m.PriceFunctionType } return 0 } -func (m *AssetRatesStats) GetEnableStableBorrow() bool { +func (m *AuctionParams) GetDutchId() uint64 { if m != nil { - return m.EnableStableBorrow + return m.DutchId } - return false + return 0 } -func (m *AssetRatesStats) GetCAssetID() uint64 { +func (m *AuctionParams) GetBidDurationSeconds() uint64 { if m != nil { - return m.CAssetID + return m.BidDurationSeconds } return 0 } -type LendMapping struct { - LendIDs []uint64 `protobuf:"varint,1,rep,packed,name=lend_ids,json=lendIds,proto3" json:"lend_ids,omitempty" yaml:"lend_ids"` +type BorrowInterestTracker struct { + BorrowingId uint64 `protobuf:"varint,1,opt,name=borrowing_id,json=borrowingId,proto3" json:"borrowing_id,omitempty" yaml:"borrowing_id"` + ReservePoolInterest github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=reserve_pool_interest,json=reservePoolInterest,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reserve_pool_interest" yaml:"reserve_pool_interest"` } -func (m *LendMapping) Reset() { *m = LendMapping{} } -func (m *LendMapping) String() string { return proto.CompactTextString(m) } -func (*LendMapping) ProtoMessage() {} -func (*LendMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{13} +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} } -func (m *LendMapping) XXX_Unmarshal(b []byte) error { +func (m *BorrowInterestTracker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *LendMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *BorrowInterestTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_LendMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_BorrowInterestTracker.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -990,41 +960,42 @@ func (m *LendMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *LendMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_LendMapping.Merge(m, src) +func (m *BorrowInterestTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_BorrowInterestTracker.Merge(m, src) } -func (m *LendMapping) XXX_Size() int { +func (m *BorrowInterestTracker) XXX_Size() int { return m.Size() } -func (m *LendMapping) XXX_DiscardUnknown() { - xxx_messageInfo_LendMapping.DiscardUnknown(m) +func (m *BorrowInterestTracker) XXX_DiscardUnknown() { + xxx_messageInfo_BorrowInterestTracker.DiscardUnknown(m) } -var xxx_messageInfo_LendMapping proto.InternalMessageInfo +var xxx_messageInfo_BorrowInterestTracker proto.InternalMessageInfo -func (m *LendMapping) GetLendIDs() []uint64 { +func (m *BorrowInterestTracker) GetBorrowingId() uint64 { if m != nil { - return m.LendIDs + return m.BorrowingId } - return nil + return 0 } -type BorrowMapping struct { - BorrowIDs []uint64 `protobuf:"varint,1,rep,packed,name=borrow_ids,json=borrowIds,proto3" json:"borrow_ids,omitempty" yaml:"borrow_ids"` +type LendRewardsTracker struct { + LendingId uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` + RewardsAccumulated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rewards_accumulated,json=rewardsAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rewards_accumulated" yaml:"interest_accumulated"` } -func (m *BorrowMapping) Reset() { *m = BorrowMapping{} } -func (m *BorrowMapping) String() string { return proto.CompactTextString(m) } -func (*BorrowMapping) ProtoMessage() {} -func (*BorrowMapping) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{14} +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} } -func (m *BorrowMapping) XXX_Unmarshal(b []byte) error { +func (m *LendRewardsTracker) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *BorrowMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *LendRewardsTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_BorrowMapping.Marshal(b, m, deterministic) + return xxx_messageInfo_LendRewardsTracker.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1034,676 +1005,511 @@ func (m *BorrowMapping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return b[:n], nil } } -func (m *BorrowMapping) XXX_Merge(src proto.Message) { - xxx_messageInfo_BorrowMapping.Merge(m, src) +func (m *LendRewardsTracker) XXX_Merge(src proto.Message) { + xxx_messageInfo_LendRewardsTracker.Merge(m, src) } -func (m *BorrowMapping) XXX_Size() int { +func (m *LendRewardsTracker) XXX_Size() int { return m.Size() } -func (m *BorrowMapping) XXX_DiscardUnknown() { - xxx_messageInfo_BorrowMapping.DiscardUnknown(m) +func (m *LendRewardsTracker) XXX_DiscardUnknown() { + xxx_messageInfo_LendRewardsTracker.DiscardUnknown(m) } -var xxx_messageInfo_BorrowMapping proto.InternalMessageInfo +var xxx_messageInfo_LendRewardsTracker proto.InternalMessageInfo -func (m *BorrowMapping) GetBorrowIDs() []uint64 { +func (m *LendRewardsTracker) GetLendingId() uint64 { if m != nil { - return m.BorrowIDs + return m.LendingId } - return nil + 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 init() { + proto.RegisterType((*LendAsset)(nil), "comdex.lend.v1beta1.LendAsset") + proto.RegisterType((*BorrowAsset)(nil), "comdex.lend.v1beta1.BorrowAsset") + proto.RegisterType((*Pool)(nil), "comdex.lend.v1beta1.Pool") + proto.RegisterType((*UserAssetLendBorrowMapping)(nil), "comdex.lend.v1beta1.UserAssetLendBorrowMapping") + proto.RegisterType((*AssetDataPoolMapping)(nil), "comdex.lend.v1beta1.AssetDataPoolMapping") + proto.RegisterType((*Extended_Pair)(nil), "comdex.lend.v1beta1.Extended_Pair") + 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") } -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{15} -} -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) -} +func init() { proto.RegisterFile("comdex/lend/v1beta1/lend.proto", fileDescriptor_b87bb4bef8334ddd) } -var xxx_messageInfo_StableBorrowMapping proto.InternalMessageInfo +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, 0x9e, 0x9d, 0x19, 0xa6, 0x67, 0x64, 0xab, 0x80, + 0x40, 0xc1, 0x95, 0x43, 0xb8, 0x70, 0xe1, 0x6f, 0x70, 0xe5, 0x4a, 0xe5, 0xc0, 0x21, 0xdc, 0xa8, + 0x1c, 0x16, 0x58, 0x1f, 0xa8, 0xe2, 0xa8, 0xa2, 0x38, 0x70, 0xa2, 0xba, 0xfb, 0xcd, 0xd7, 0x6a, + 0xfd, 0x31, 0x12, 0x21, 0xa7, 0xdd, 0x7e, 0xef, 0xf5, 0x7b, 0xaf, 0xdf, 0x57, 0xbf, 0xd7, 0x83, + 0x36, 0xec, 0x60, 0xe0, 0xf0, 0x27, 0x5b, 0x1e, 0xf7, 0x9d, 0xad, 0xe3, 0xeb, 0x7d, 0x1e, 0xb3, + 0xeb, 0x6a, 0xd1, 0x09, 0xa3, 0x20, 0x0e, 0x70, 0x53, 0xe3, 0x3b, 0x0a, 0x04, 0xf8, 0xf5, 0xd6, + 0x51, 0x70, 0x14, 0x28, 0xfc, 0x96, 0xfc, 0xa7, 0x49, 0xd7, 0xcd, 0xa3, 0x20, 0x38, 0xf2, 0xf8, + 0x96, 0x5a, 0xf5, 0x93, 0xc3, 0xad, 0xd8, 0x1d, 0x70, 0x11, 0xb3, 0x41, 0x08, 0x04, 0x1b, 0x76, + 0x20, 0x06, 0x81, 0xd8, 0xea, 0x33, 0xc1, 0x33, 0x59, 0x76, 0xe0, 0xfa, 0x1a, 0x4f, 0x7e, 0x3b, + 0x8f, 0xea, 0xfb, 0xdc, 0x77, 0x76, 0x84, 0xe0, 0x31, 0xbe, 0x81, 0x90, 0x14, 0xea, 0xfa, 0x47, + 0x96, 0xeb, 0xb4, 0x8d, 0xab, 0xc6, 0xe6, 0x4c, 0xf7, 0xd5, 0xd1, 0xd0, 0x9c, 0xea, 0xed, 0x9d, + 0x0e, 0xcd, 0xd5, 0x13, 0x36, 0xf0, 0x6e, 0x90, 0x9c, 0x82, 0xd0, 0x3a, 0x2c, 0x7a, 0x0e, 0xfe, + 0x06, 0xaa, 0x31, 0xc9, 0x44, 0xee, 0x9c, 0x52, 0x3b, 0x37, 0x46, 0x43, 0x73, 0x5e, 0x31, 0x56, + 0xdb, 0x97, 0xf5, 0xf6, 0x94, 0x88, 0xd0, 0x79, 0xf5, 0xb7, 0xe7, 0xe0, 0xaf, 0xa3, 0xf9, 0x30, + 0x08, 0x3c, 0xb9, 0x73, 0x5a, 0xed, 0xbc, 0x32, 0x1a, 0x9a, 0x73, 0xf7, 0x83, 0xc0, 0x53, 0x1b, + 0x97, 0xf4, 0x46, 0x20, 0x21, 0x74, 0x4e, 0xfe, 0xeb, 0x39, 0xf8, 0x75, 0x34, 0x1b, 0x3c, 0xf6, + 0x79, 0xd4, 0x9e, 0xb9, 0x6a, 0x6c, 0xd6, 0xbb, 0x2b, 0xa7, 0x43, 0x73, 0x41, 0x93, 0x2a, 0x30, + 0xa1, 0x1a, 0x8d, 0x7f, 0x82, 0xea, 0x6c, 0x10, 0x24, 0x7e, 0x6c, 0xb9, 0x7e, 0x7b, 0xf6, 0xaa, + 0xb1, 0xd9, 0xd8, 0x7e, 0xa5, 0xa3, 0xed, 0xd2, 0x91, 0x76, 0x49, 0x6d, 0xdc, 0xd9, 0x0d, 0x5c, + 0xbf, 0xbb, 0xfb, 0xf1, 0xd0, 0xbc, 0x74, 0x3a, 0x34, 0x57, 0x40, 0xdd, 0x74, 0x27, 0xf9, 0xcf, + 0xd0, 0xfc, 0xf2, 0x91, 0x1b, 0x3f, 0x4c, 0xfa, 0x1d, 0x3b, 0x18, 0x6c, 0x81, 0x61, 0xf5, 0xcf, + 0x1b, 0xc2, 0x79, 0xb4, 0x15, 0x9f, 0x84, 0x5c, 0x28, 0x26, 0xb4, 0xa6, 0xb7, 0xf5, 0x7c, 0xfc, + 0x23, 0xb4, 0x90, 0x1a, 0x4c, 0xfa, 0xa6, 0x3d, 0xa7, 0xe4, 0xaf, 0x77, 0xb4, 0xe3, 0x3a, 0xa9, + 0xe3, 0x3a, 0x07, 0xa9, 0xe3, 0xba, 0x26, 0x28, 0xd0, 0x2c, 0x9b, 0x5b, 0xee, 0x26, 0x1f, 0xfd, + 0xd5, 0x34, 0x68, 0x03, 0x40, 0x72, 0x0b, 0xfe, 0x29, 0x6a, 0xb2, 0x63, 0xe6, 0x7a, 0xac, 0xef, + 0x71, 0x2b, 0x0e, 0xac, 0x7e, 0x10, 0x45, 0xc1, 0xe3, 0xf6, 0xbc, 0x32, 0xc9, 0xbe, 0x64, 0xf5, + 0xe9, 0xd0, 0x7c, 0xfd, 0x25, 0xf4, 0xee, 0xf9, 0xf1, 0xe9, 0xd0, 0x5c, 0x87, 0x53, 0x9f, 0x65, + 0x49, 0xe8, 0x6a, 0x06, 0x3d, 0x08, 0xba, 0x0a, 0x86, 0xaf, 0xa3, 0x39, 0x16, 0x86, 0xd2, 0x71, + 0x35, 0xe5, 0xb8, 0xf5, 0xd1, 0xd0, 0x9c, 0xdd, 0x09, 0x43, 0xe5, 0xb7, 0x45, 0xe0, 0xa5, 0x08, + 0x08, 0x9d, 0x65, 0x61, 0xd8, 0x73, 0xf0, 0x43, 0xb4, 0x70, 0xe4, 0x05, 0x7d, 0xe6, 0x59, 0xae, + 0xef, 0xf0, 0x27, 0xed, 0xba, 0xd2, 0xf4, 0x56, 0x05, 0x4d, 0xf7, 0xb8, 0x9d, 0x9b, 0xa7, 0xc8, + 0x8b, 0xd0, 0x86, 0x5e, 0xf6, 0xe4, 0x0a, 0x3f, 0x41, 0x6b, 0x1e, 0x13, 0xd2, 0x77, 0x31, 0x8f, + 0x98, 0x1d, 0xbb, 0x81, 0xaf, 0x7d, 0x80, 0x5e, 0xe8, 0x83, 0x4d, 0xf0, 0xc1, 0x15, 0xf0, 0xc1, + 0x24, 0x36, 0xda, 0x19, 0x4d, 0x89, 0xeb, 0xe5, 0x28, 0xe5, 0x94, 0x1d, 0x84, 0x6c, 0x15, 0xae, + 0x3e, 0x1b, 0xf0, 0x76, 0x43, 0x9d, 0x90, 0x8c, 0x86, 0x66, 0x7d, 0x57, 0x06, 0xf5, 0x3d, 0x36, + 0xe0, 0x79, 0x3a, 0xe5, 0x84, 0x84, 0xd6, 0xd5, 0x42, 0xe2, 0xc9, 0xbf, 0x1b, 0xa8, 0xa1, 0x8d, + 0xac, 0x53, 0xf3, 0x9b, 0x68, 0x41, 0xfb, 0xa1, 0x94, 0x9c, 0xaf, 0x65, 0xc9, 0x09, 0xe6, 0x28, + 0xd2, 0x10, 0xda, 0xc8, 0x96, 0x3d, 0x47, 0x2a, 0x55, 0x48, 0x6e, 0x9d, 0xa2, 0x4a, 0xa9, 0x7d, + 0xc8, 0xe1, 0x17, 0xe7, 0xf8, 0x2d, 0xb4, 0xe2, 0x0a, 0x4b, 0xc4, 0x2a, 0x32, 0x20, 0xd2, 0x64, + 0xc6, 0xd6, 0xba, 0xaf, 0x9e, 0x0e, 0xcd, 0xcb, 0x7a, 0xef, 0x38, 0x05, 0xa1, 0x4b, 0xae, 0x78, + 0xa0, 0x20, 0x10, 0x35, 0x32, 0xdf, 0x99, 0x1b, 0x49, 0x35, 0x66, 0x0a, 0xf9, 0xce, 0xdc, 0xa8, + 0x94, 0xef, 0x9a, 0x44, 0xe6, 0xbb, 0xc4, 0x38, 0x9f, 0x6f, 0x1e, 0x7f, 0x88, 0x10, 0xb0, 0x08, + 0x92, 0x18, 0xb2, 0xf8, 0x39, 0xd2, 0xf7, 0x40, 0xfa, 0x6a, 0x49, 0x7a, 0x90, 0xc4, 0x95, 0xc4, + 0xc3, 0x79, 0xdf, 0x4b, 0x62, 0xfc, 0x3b, 0x03, 0xb5, 0xfa, 0x91, 0xeb, 0x1c, 0x71, 0xc7, 0xd2, + 0x25, 0x54, 0xe3, 0x54, 0xa6, 0x3f, 0x57, 0x95, 0x7b, 0xa0, 0xca, 0xab, 0x10, 0x21, 0x13, 0x98, + 0x54, 0x52, 0x0a, 0x03, 0x07, 0x15, 0x97, 0x3b, 0x6a, 0x3f, 0x76, 0xd0, 0x52, 0x1e, 0x79, 0x2a, + 0xc7, 0x6a, 0x2f, 0xcc, 0xb1, 0x6b, 0xa0, 0xd7, 0xda, 0x78, 0xe4, 0xe6, 0xc9, 0xb5, 0x98, 0x01, + 0x55, 0x5a, 0x9d, 0x20, 0x5c, 0x8a, 0x2c, 0x2b, 0x62, 0x31, 0x87, 0x02, 0xf2, 0x6e, 0xe5, 0x02, + 0xf2, 0x8a, 0x96, 0x7b, 0x96, 0x23, 0xa1, 0x2b, 0xa2, 0x10, 0xae, 0x94, 0xc5, 0x1c, 0xff, 0xc2, + 0x40, 0x2d, 0x55, 0x00, 0xb8, 0x88, 0x2d, 0x66, 0xdb, 0xc9, 0x20, 0xf1, 0x58, 0xcc, 0x1d, 0x55, + 0x4b, 0xea, 0xdd, 0xbb, 0x95, 0xa5, 0x83, 0x37, 0x26, 0xf1, 0x24, 0xb4, 0x99, 0x82, 0x77, 0x72, + 0xe8, 0x99, 0xc2, 0xd9, 0xf8, 0xcc, 0x0a, 0xe7, 0xcf, 0x51, 0x2b, 0xe2, 0x82, 0x47, 0xc7, 0xdc, + 0x2a, 0x49, 0x5c, 0xb8, 0xd8, 0x59, 0x27, 0xf1, 0x24, 0x14, 0x03, 0xf8, 0xce, 0xcb, 0x54, 0xee, + 0xc5, 0xff, 0x6f, 0xe5, 0x5e, 0x3a, 0x47, 0xe5, 0xc6, 0x37, 0xd1, 0xa2, 0x2b, 0x2c, 0xcf, 0xfd, + 0x71, 0xe2, 0x3a, 0x2a, 0x44, 0x96, 0x55, 0x85, 0x6c, 0x9f, 0x0e, 0xcd, 0x56, 0x56, 0x21, 0x73, + 0x34, 0xa1, 0x0b, 0xae, 0xd8, 0xcf, 0x97, 0xff, 0x9a, 0x42, 0x33, 0x52, 0x56, 0xb1, 0x2b, 0x32, + 0x2a, 0x74, 0x45, 0xb7, 0x50, 0x63, 0x10, 0x38, 0x89, 0xc7, 0xf5, 0x11, 0xa6, 0xd4, 0x11, 0xbe, + 0x34, 0x1a, 0x9a, 0xe8, 0xae, 0x02, 0xc3, 0x19, 0xb0, 0xde, 0x5e, 0x20, 0x25, 0x14, 0x0d, 0x32, + 0x8a, 0x31, 0x43, 0x4c, 0x9f, 0xd3, 0x10, 0xa9, 0xcb, 0x0f, 0x13, 0xdf, 0x11, 0x50, 0xec, 0x0b, + 0x86, 0x28, 0xa1, 0x09, 0x5d, 0x80, 0xf5, 0x6d, 0xb9, 0xc4, 0x1e, 0x42, 0xba, 0x46, 0x39, 0x2c, + 0x66, 0xed, 0xd9, 0xab, 0xd3, 0x9b, 0x8d, 0xed, 0xaf, 0x74, 0x26, 0xf4, 0xc6, 0x1d, 0x55, 0x89, + 0xf6, 0x58, 0xcc, 0xa4, 0x6a, 0x77, 0x59, 0x18, 0xba, 0xfe, 0x91, 0x56, 0x36, 0xc3, 0x14, 0x4a, + 0x71, 0xc6, 0x93, 0xd0, 0x3a, 0x4b, 0xf1, 0xe4, 0xcf, 0x06, 0x5a, 0xff, 0x40, 0xf0, 0x48, 0xed, + 0x90, 0x37, 0xa2, 0x4e, 0x7e, 0xe0, 0x96, 0xf7, 0x9a, 0xc6, 0xf3, 0x7b, 0xcd, 0xaf, 0xa2, 0x79, + 0xa9, 0x5a, 0x7e, 0xc3, 0xe2, 0xdc, 0x55, 0x80, 0x20, 0x74, 0x4e, 0xfe, 0xeb, 0x39, 0x92, 0xb8, + 0xdc, 0xf7, 0xe2, 0xe7, 0xf8, 0xf5, 0x3a, 0xaa, 0x43, 0x8d, 0x52, 0xd7, 0xe6, 0xf4, 0xe6, 0x4c, + 0xb7, 0x95, 0x5f, 0x6f, 0x19, 0x8a, 0xd0, 0x9a, 0xfe, 0xdf, 0x73, 0xc8, 0xdf, 0x0d, 0xd4, 0x9a, + 0x64, 0x9b, 0x52, 0xaf, 0x6e, 0x54, 0xeb, 0xd5, 0xdf, 0x45, 0x58, 0x43, 0xe3, 0x88, 0xf9, 0xc2, + 0x8d, 0x2d, 0x99, 0xe8, 0x70, 0xd6, 0xd7, 0xf2, 0xaa, 0x7a, 0x96, 0x86, 0xd0, 0x15, 0x05, 0x3c, + 0xd0, 0xb0, 0x83, 0x93, 0x50, 0x05, 0x99, 0x48, 0xc2, 0xd0, 0x3b, 0xb1, 0x6c, 0x16, 0x82, 0x0d, + 0x94, 0xdf, 0x1e, 0x28, 0xe8, 0x2e, 0x0b, 0x73, 0xbf, 0xe5, 0x84, 0x84, 0xd6, 0x45, 0x8a, 0x27, + 0xff, 0x98, 0x42, 0x8b, 0xb7, 0x9e, 0xc4, 0xdc, 0x77, 0xb8, 0x63, 0xc9, 0x16, 0x02, 0x2f, 0xa1, + 0xa9, 0xf4, 0x58, 0x74, 0xca, 0x75, 0x70, 0x27, 0x3b, 0xac, 0x0f, 0x7a, 0x36, 0xcf, 0x9c, 0xd0, + 0xcf, 0x4e, 0xe8, 0x4b, 0x43, 0x6b, 0xa8, 0xbc, 0xe8, 0xb5, 0x4e, 0x05, 0x43, 0x67, 0x28, 0x42, + 0x35, 0x5b, 0x79, 0x39, 0xbf, 0xa5, 0x52, 0x5e, 0x95, 0x19, 0x4b, 0xba, 0x4b, 0x45, 0xfa, 0x78, + 0xca, 0xe7, 0x68, 0x42, 0x1b, 0xae, 0x50, 0x95, 0x47, 0x25, 0xfa, 0x77, 0xd1, 0x6a, 0xc6, 0xd5, + 0x4a, 0x03, 0x62, 0x56, 0x09, 0xee, 0x8c, 0x86, 0xe6, 0xd2, 0x0e, 0x88, 0xc9, 0x52, 0xbf, 0x3d, + 0xa6, 0x8a, 0x95, 0x05, 0xcb, 0x12, 0x2b, 0xd2, 0x3a, 0xf8, 0x1d, 0x84, 0x07, 0xae, 0x6f, 0x25, + 0xc2, 0xb1, 0x8e, 0x99, 0x97, 0x70, 0xcb, 0xe3, 0x87, 0xba, 0x7b, 0x29, 0x79, 0xeb, 0x2c, 0x0d, + 0xa1, 0xcb, 0x03, 0xd7, 0xff, 0x40, 0x38, 0xdf, 0x96, 0xa0, 0x7d, 0x09, 0xf9, 0x83, 0x81, 0xb0, + 0x52, 0xe5, 0x20, 0x90, 0x76, 0x4e, 0x63, 0xe9, 0x9c, 0x65, 0xea, 0x82, 0xe3, 0x22, 0xb4, 0x8f, + 0xd3, 0x2a, 0x0f, 0x5e, 0xaa, 0x7d, 0x24, 0xbf, 0xae, 0x23, 0x2c, 0xd5, 0xd2, 0x19, 0xde, 0xfd, + 0xfc, 0xf4, 0xef, 0xa0, 0x1a, 0x94, 0x02, 0x01, 0x07, 0x28, 0x04, 0x64, 0x8a, 0x21, 0x74, 0x5e, + 0x57, 0x09, 0x81, 0xdf, 0x44, 0x28, 0x4b, 0x6f, 0x01, 0xa9, 0xbf, 0x96, 0x27, 0x46, 0x8e, 0x23, + 0xb4, 0x9e, 0xe6, 0xbe, 0xc0, 0x3e, 0x5a, 0x8a, 0x83, 0x98, 0x79, 0xd0, 0xd9, 0x70, 0x1d, 0x52, + 0xf5, 0xee, 0x9d, 0xca, 0x33, 0x21, 0x34, 0x68, 0x65, 0x6e, 0x84, 0x2e, 0x2a, 0x40, 0x17, 0xd6, + 0xf8, 0x97, 0x06, 0x5a, 0xd3, 0x24, 0xa5, 0x8e, 0x8a, 0x3b, 0x2a, 0xdc, 0xea, 0xba, 0x0d, 0xad, + 0x24, 0xf7, 0x4a, 0x51, 0xee, 0x18, 0x53, 0x42, 0x9b, 0x0a, 0x5e, 0x9c, 0x2b, 0xb8, 0x83, 0xfb, + 0x08, 0x69, 0x72, 0x69, 0x3b, 0x18, 0x82, 0x77, 0x2b, 0x0b, 0x5e, 0x2d, 0x0a, 0x96, 0x9c, 0x08, + 0xad, 0xab, 0x85, 0xbc, 0x17, 0xf0, 0x6f, 0x0c, 0xb4, 0xae, 0x51, 0x13, 0x1b, 0xc2, 0x9a, 0x12, + 0xfa, 0xa0, 0xb2, 0xd0, 0x6b, 0x45, 0xa1, 0x93, 0xdb, 0xc2, 0xb6, 0x42, 0xf6, 0x26, 0xf4, 0x86, + 0x3f, 0x80, 0x90, 0x62, 0x61, 0x04, 0xfd, 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, + 0x4e, 0x5d, 0xf8, 0x66, 0x3e, 0xec, 0x4c, 0xa2, 0x22, 0x14, 0x6b, 0x70, 0xe9, 0x35, 0x84, 0xa3, + 0x46, 0x4a, 0x25, 0xcd, 0xab, 0x8b, 0xd6, 0x5e, 0x65, 0x85, 0x71, 0x39, 0xe6, 0x95, 0x95, 0x11, + 0x44, 0xbb, 0xb4, 0xf5, 0x23, 0xb4, 0x08, 0x38, 0x30, 0xb9, 0x2e, 0x54, 0xb7, 0x2b, 0x0b, 0x6a, + 0x95, 0x04, 0xa5, 0x96, 0x5f, 0xd0, 0xeb, 0x07, 0xda, 0xfe, 0x63, 0xc2, 0xb6, 0xa1, 0x28, 0xfd, + 0x4f, 0x84, 0x6d, 0x97, 0x85, 0x6d, 0xe3, 0x7b, 0x68, 0xda, 0x8b, 0x8f, 0xa1, 0x2e, 0xbd, 0x55, + 0x59, 0x04, 0x82, 0xba, 0x17, 0x1f, 0x13, 0x2a, 0x19, 0xe1, 0x5f, 0x19, 0x68, 0x2d, 0x9d, 0xcf, + 0xd4, 0xc8, 0xf8, 0x30, 0xe2, 0xe2, 0x61, 0xe0, 0x39, 0x50, 0x8f, 0xee, 0x55, 0x16, 0x91, 0x0e, + 0xa3, 0x93, 0x98, 0x12, 0xda, 0x2a, 0xc0, 0x0f, 0x52, 0x30, 0xfe, 0x19, 0x6a, 0x16, 0xe9, 0x43, + 0xee, 0x33, 0x2f, 0x3e, 0x81, 0xd2, 0xb4, 0x5f, 0x59, 0x85, 0xf5, 0xb3, 0x2a, 0x00, 0x4b, 0x42, + 0x71, 0x01, 0x7a, 0x5f, 0x03, 0x65, 0x5d, 0x2c, 0xd2, 0xf6, 0x03, 0x3f, 0x11, 0x6a, 0xfc, 0xbe, + 0x40, 0x5d, 0x3c, 0xc3, 0x90, 0xd0, 0x95, 0x02, 0xac, 0x2b, 0x41, 0xb2, 0x6f, 0xc9, 0xc6, 0x42, + 0x66, 0xc7, 0x41, 0x04, 0x53, 0xf8, 0x9d, 0xca, 0x52, 0xd7, 0xc6, 0x86, 0x4c, 0xc5, 0x8d, 0xd0, + 0x74, 0x28, 0xbd, 0xad, 0xd6, 0xf8, 0x6d, 0x84, 0x6c, 0x2b, 0x2b, 0xba, 0xcb, 0xaa, 0xe8, 0x5e, + 0x1b, 0x0d, 0xcd, 0xda, 0x6e, 0x5e, 0x75, 0xd3, 0x39, 0xd7, 0xca, 0xeb, 0x6e, 0xcd, 0xd6, 0x68, + 0x87, 0x44, 0xa8, 0x59, 0xcc, 0xe7, 0xb4, 0xaf, 0xfc, 0xfe, 0xf8, 0x85, 0x26, 0x9b, 0x37, 0x43, + 0x35, 0x6f, 0x5b, 0xa3, 0xa1, 0xb9, 0x5c, 0xdc, 0xd3, 0xdb, 0x13, 0xcf, 0xba, 0xb5, 0x54, 0x5b, + 0x57, 0xba, 0xb5, 0x7a, 0x8e, 0x20, 0xbf, 0x9f, 0x42, 0x97, 0xa9, 0x3e, 0x46, 0x37, 0x39, 0xe9, + 0x33, 0xfb, 0x51, 0x36, 0xe7, 0x5d, 0xe4, 0x0e, 0x29, 0xd8, 0x1e, 0x5e, 0x17, 0xa7, 0x2e, 0xd6, + 0x33, 0x96, 0xb9, 0xe5, 0xb6, 0x87, 0x67, 0x43, 0x1f, 0x2d, 0xf5, 0xb5, 0xfa, 0xa9, 0xbc, 0xe9, + 0x8b, 0xc9, 0x2b, 0x73, 0x23, 0x74, 0x11, 0x00, 0x5a, 0x1e, 0xf9, 0xe7, 0x0c, 0x5a, 0xdc, 0x49, + 0xd4, 0x6b, 0x0f, 0x5c, 0xb8, 0x9b, 0xd9, 0x07, 0x0c, 0x6d, 0xaa, 0xd5, 0x67, 0x7e, 0xb7, 0xf8, + 0x21, 0x6a, 0x33, 0xbd, 0xd5, 0x72, 0x92, 0x48, 0x07, 0xb1, 0xe0, 0x76, 0xe0, 0x3b, 0x02, 0x06, + 0x80, 0x2f, 0x9e, 0x0e, 0x4d, 0x13, 0xf6, 0x3e, 0x83, 0x92, 0xd0, 0x2f, 0x00, 0x6a, 0x0f, 0x30, + 0x0f, 0x34, 0x42, 0xde, 0x58, 0xfd, 0xe4, 0xf0, 0x90, 0x47, 0x60, 0x82, 0x73, 0xdf, 0x58, 0x9a, + 0x0b, 0xa1, 0xc0, 0x4e, 0x5e, 0xdb, 0x76, 0x22, 0x42, 0xb8, 0x61, 0xcf, 0x7d, 0x6d, 0x4b, 0x1e, + 0x84, 0x2a, 0x56, 0x92, 0xa5, 0x88, 0x79, 0x08, 0x77, 0xeb, 0xcd, 0xca, 0xce, 0x6a, 0xa4, 0x81, + 0xce, 0x25, 0x4b, 0xf9, 0x83, 0xef, 0xa1, 0x66, 0x18, 0xb9, 0xb6, 0x7a, 0x0a, 0x82, 0x87, 0xba, + 0x93, 0x90, 0xc3, 0xa4, 0xba, 0x91, 0xd7, 0xaf, 0x09, 0x44, 0x84, 0xae, 0x2a, 0xe8, 0x6d, 0x00, + 0xaa, 0x97, 0x85, 0x0e, 0xaa, 0x39, 0x49, 0x6c, 0x3f, 0x94, 0x9e, 0x9d, 0x1f, 0x1f, 0xfa, 0x53, + 0x0c, 0xa1, 0xf3, 0xea, 0x6f, 0xcf, 0x91, 0xf7, 0x7a, 0xdf, 0x75, 0xce, 0x7a, 0x56, 0x7f, 0xd6, + 0x2a, 0xdc, 0xeb, 0x93, 0xa8, 0x08, 0xc5, 0x7d, 0xd7, 0x19, 0xf3, 0x28, 0xf9, 0xd4, 0x40, 0x97, + 0xbb, 0x90, 0xc4, 0x69, 0x3b, 0x1f, 0x47, 0xcc, 0x7e, 0xc4, 0x23, 0x7c, 0x63, 0xe2, 0xd7, 0x9c, + 0xcb, 0x2f, 0xf5, 0x1d, 0x47, 0x0e, 0x5a, 0x69, 0x5e, 0xe9, 0xb1, 0x14, 0xb8, 0x43, 0xe4, 0x9c, + 0xfb, 0x7a, 0x9a, 0xc8, 0x94, 0xd0, 0x26, 0xc0, 0xd5, 0x48, 0x9c, 0x42, 0xff, 0x64, 0xa0, 0x96, + 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, +} -func (m *StableBorrowMapping) GetStableBorrowIDs() []uint64 { - if m != nil { - return m.StableBorrowIDs +func (m *LendAsset) 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 nil + return dAtA[:n], nil } -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 *LendAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -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{16} -} -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 +func (m *LendAsset) 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] = 0x5a + } + 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] = 0x52 + { + size := m.GlobalIndex.Size() + i -= size + if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - return b[:n], nil + i = encodeVarintLend(dAtA, i, uint64(size)) } -} -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 + i-- + dAtA[i] = 0x4a + if m.AppID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AppID)) + i-- + dAtA[i] = 0x40 } - return 0 -} - -func (m *ModuleBalance) GetModuleBalanceStats() []ModuleBalanceStats { - if m != nil { - return m.ModuleBalanceStats + { + size := m.AvailableToBorrow.Size() + i -= size + if _, err := m.AvailableToBorrow.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - 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{17} -} -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) + 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 nil, err + return 0, err } - return b[:n], nil + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) } -} -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 + 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 } - return 0 -} - -func (m *ModuleBalanceStats) GetBalance() github_com_cosmos_cosmos_sdk_types.Coin { - if m != nil { - return m.Balance + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x18 } - return github_com_cosmos_cosmos_sdk_types.Coin{} -} - -type BalanceStats 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"` -} - -func (m *BalanceStats) Reset() { *m = BalanceStats{} } -func (m *BalanceStats) String() string { return proto.CompactTextString(m) } -func (*BalanceStats) ProtoMessage() {} -func (*BalanceStats) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{18} -} -func (m *BalanceStats) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BalanceStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BalanceStats.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x10 } -} -func (m *BalanceStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_BalanceStats.Merge(m, src) -} -func (m *BalanceStats) XXX_Size() int { - return m.Size() -} -func (m *BalanceStats) XXX_DiscardUnknown() { - xxx_messageInfo_BalanceStats.DiscardUnknown(m) + if m.ID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } -var xxx_messageInfo_BalanceStats proto.InternalMessageInfo - -func (m *BalanceStats) GetAssetID() uint64 { - if m != nil { - return m.AssetID +func (m *BorrowAsset) 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 0 + return dAtA[:n], nil } -type DepositStats struct { - BalanceStats []BalanceStats `protobuf:"bytes,1,rep,name=balance_stats,json=balanceStats,proto3" json:"balance_stats" yaml:"balance_stats"` +func (m *BorrowAsset) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DepositStats) Reset() { *m = DepositStats{} } -func (m *DepositStats) String() string { return proto.CompactTextString(m) } -func (*DepositStats) ProtoMessage() {} -func (*DepositStats) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{19} -} -func (m *DepositStats) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DepositStats) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DepositStats.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) +func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsLiquidated { + i-- + if m.IsLiquidated { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x78 + } + 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] = 0x72 + } + 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] = 0x6a + { + 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] = 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 + { + size := m.InterestAccumulated.Size() + i -= size + if _, err := m.InterestAccumulated.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 nil, err + return 0, err } - return b[:n], nil + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) } -} -func (m *DepositStats) XXX_Merge(src proto.Message) { - xxx_messageInfo_DepositStats.Merge(m, src) -} -func (m *DepositStats) XXX_Size() int { - return m.Size() -} -func (m *DepositStats) XXX_DiscardUnknown() { - xxx_messageInfo_DepositStats.DiscardUnknown(m) -} - -var xxx_messageInfo_DepositStats proto.InternalMessageInfo - -func (m *DepositStats) GetBalanceStats() []BalanceStats { - if m != nil { - return m.BalanceStats + 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)) } - return nil -} - -type AuctionParams struct { - AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty" yaml:"app_id"` - AuctionDurationSeconds uint64 `protobuf:"varint,2,opt,name=auction_duration_seconds,json=auctionDurationSeconds,proto3" json:"auction_duration_seconds,omitempty" yaml:"auction_duration_seconds"` - Buffer github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=buffer,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"buffer" yaml:"buffer"` - Cusp github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=cusp,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"cusp" yaml:"cusp"` - Step github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=step,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"step" yaml:"step"` - PriceFunctionType uint64 `protobuf:"varint,6,opt,name=price_function_type,json=priceFunctionType,proto3" json:"price_function_type,omitempty" yaml:"price_function_type"` - DutchId uint64 `protobuf:"varint,7,opt,name=dutch_id,json=dutchId,proto3" json:"dutch_id,omitempty" yaml:"dutch_id"` - BidDurationSeconds uint64 `protobuf:"varint,8,opt,name=bid_duration_seconds,json=bidDurationSeconds,proto3" json:"bid_duration_seconds,omitempty" yaml:"bid_duration_seconds"` -} - -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{20} -} -func (m *AuctionParams) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *AuctionParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_AuctionParams.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) + i-- + dAtA[i] = 0x32 + { + size, err := m.AmountIn.MarshalToSizedBuffer(dAtA[:i]) if err != nil { - return nil, err + return 0, err } - return b[:n], nil + i -= size + i = encodeVarintLend(dAtA, i, uint64(size)) } -} -func (m *AuctionParams) XXX_Merge(src proto.Message) { - xxx_messageInfo_AuctionParams.Merge(m, src) -} -func (m *AuctionParams) XXX_Size() int { - return m.Size() -} -func (m *AuctionParams) XXX_DiscardUnknown() { - xxx_messageInfo_AuctionParams.DiscardUnknown(m) -} - -var xxx_messageInfo_AuctionParams proto.InternalMessageInfo - -func (m *AuctionParams) GetAppId() uint64 { - if m != nil { - return m.AppId + i-- + dAtA[i] = 0x2a + if m.PairID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PairID)) + i-- + dAtA[i] = 0x20 } - return 0 -} - -func (m *AuctionParams) GetAuctionDurationSeconds() uint64 { - if m != nil { - return m.AuctionDurationSeconds + if m.IsStableBorrow { + i-- + if m.IsStableBorrow { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 } - return 0 -} - -func (m *AuctionParams) GetPriceFunctionType() uint64 { - if m != nil { - return m.PriceFunctionType + if m.LendingID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.LendingID)) + i-- + dAtA[i] = 0x10 } - return 0 -} - -func (m *AuctionParams) GetDutchId() uint64 { - if m != nil { - return m.DutchId + if m.ID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ID)) + i-- + dAtA[i] = 0x8 } - return 0 + return len(dAtA) - i, nil } -func (m *AuctionParams) GetBidDurationSeconds() uint64 { - if m != nil { - return m.BidDurationSeconds +func (m *Pool) 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 0 + return dAtA[:n], nil } -type ReservePoolRecordsForBorrow struct { - ID uint64 `protobuf:"varint,1,opt,name=borrowing_id,json=borrowingId,proto3" json:"borrowing_id,omitempty" yaml:"borrowing_id"` - InterestAccumulated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=interest_accumulated,json=interestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"interest_accumulated" yaml:"interest_accumulated"` +func (m *Pool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ReservePoolRecordsForBorrow) Reset() { *m = ReservePoolRecordsForBorrow{} } -func (m *ReservePoolRecordsForBorrow) String() string { return proto.CompactTextString(m) } -func (*ReservePoolRecordsForBorrow) ProtoMessage() {} -func (*ReservePoolRecordsForBorrow) Descriptor() ([]byte, []int) { - return fileDescriptor_b87bb4bef8334ddd, []int{21} -} -func (m *ReservePoolRecordsForBorrow) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ReservePoolRecordsForBorrow) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ReservePoolRecordsForBorrow.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err +func (m *Pool) 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] = 0x2a } - return b[:n], nil } -} -func (m *ReservePoolRecordsForBorrow) XXX_Merge(src proto.Message) { - xxx_messageInfo_ReservePoolRecordsForBorrow.Merge(m, src) -} -func (m *ReservePoolRecordsForBorrow) XXX_Size() int { - return m.Size() -} -func (m *ReservePoolRecordsForBorrow) XXX_DiscardUnknown() { - xxx_messageInfo_ReservePoolRecordsForBorrow.DiscardUnknown(m) -} - -var xxx_messageInfo_ReservePoolRecordsForBorrow proto.InternalMessageInfo - -func (m *ReservePoolRecordsForBorrow) GetID() uint64 { - if m != nil { - return m.ID + if m.ReserveFunds != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.ReserveFunds)) + i-- + dAtA[i] = 0x20 } - return 0 -} - -type BorrowInterestTracker struct { - BorrowingId uint64 `protobuf:"varint,1,opt,name=borrowing_id,json=borrowingId,proto3" json:"borrowing_id,omitempty" yaml:"borrowing_id"` - InterestAccumulated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=interest_accumulated,json=interestAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"interest_accumulated" yaml:"interest_accumulated"` -} - -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{22} -} -func (m *BorrowInterestTracker) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BorrowInterestTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BorrowInterestTracker.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 *BorrowInterestTracker) XXX_Merge(src proto.Message) { - xxx_messageInfo_BorrowInterestTracker.Merge(m, src) -} -func (m *BorrowInterestTracker) XXX_Size() int { - return m.Size() -} -func (m *BorrowInterestTracker) XXX_DiscardUnknown() { - xxx_messageInfo_BorrowInterestTracker.DiscardUnknown(m) -} - -var xxx_messageInfo_BorrowInterestTracker proto.InternalMessageInfo - -func (m *BorrowInterestTracker) GetBorrowingId() uint64 { - if m != nil { - return m.BorrowingId + 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] = 0x1a } - return 0 -} - -type LendRewardsTracker struct { - LendingId uint64 `protobuf:"varint,1,opt,name=lending_id,json=lendingId,proto3" json:"lending_id,omitempty" yaml:"lending_id"` - RewardsAccumulated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=rewards_accumulated,json=rewardsAccumulated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rewards_accumulated" yaml:"interest_accumulated"` -} - -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{23} -} -func (m *LendRewardsTracker) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LendRewardsTracker) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LendRewardsTracker.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil + 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 } -} -func (m *LendRewardsTracker) XXX_Merge(src proto.Message) { - xxx_messageInfo_LendRewardsTracker.Merge(m, src) -} -func (m *LendRewardsTracker) XXX_Size() int { - return m.Size() -} -func (m *LendRewardsTracker) XXX_DiscardUnknown() { - xxx_messageInfo_LendRewardsTracker.DiscardUnknown(m) -} - -var xxx_messageInfo_LendRewardsTracker proto.InternalMessageInfo - -func (m *LendRewardsTracker) GetLendingId() uint64 { - if m != nil { - return m.LendingId + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x8 } - return 0 -} - -func init() { - proto.RegisterType((*LendAsset)(nil), "comdex.lend.v1beta1.LendAsset") - proto.RegisterType((*BorrowAsset)(nil), "comdex.lend.v1beta1.BorrowAsset") - proto.RegisterType((*Pool)(nil), "comdex.lend.v1beta1.Pool") - proto.RegisterType((*AssetDataPoolMapping)(nil), "comdex.lend.v1beta1.AssetDataPoolMapping") - proto.RegisterType((*Extended_Pair)(nil), "comdex.lend.v1beta1.Extended_Pair") - proto.RegisterType((*AssetToPairMapping)(nil), "comdex.lend.v1beta1.AssetToPairMapping") - proto.RegisterType((*UserLendIdMapping)(nil), "comdex.lend.v1beta1.UserLendIdMapping") - proto.RegisterType((*LendIdByOwnerAndPoolMapping)(nil), "comdex.lend.v1beta1.LendIdByOwnerAndPoolMapping") - proto.RegisterType((*BorrowIdByOwnerAndPoolMapping)(nil), "comdex.lend.v1beta1.BorrowIdByOwnerAndPoolMapping") - proto.RegisterType((*UserBorrowIdMapping)(nil), "comdex.lend.v1beta1.UserBorrowIdMapping") - proto.RegisterType((*LendIdToBorrowIdMapping)(nil), "comdex.lend.v1beta1.LendIdToBorrowIdMapping") - proto.RegisterType((*AssetStats)(nil), "comdex.lend.v1beta1.AssetStats") - proto.RegisterType((*AssetRatesStats)(nil), "comdex.lend.v1beta1.AssetRatesStats") - proto.RegisterType((*LendMapping)(nil), "comdex.lend.v1beta1.LendMapping") - proto.RegisterType((*BorrowMapping)(nil), "comdex.lend.v1beta1.BorrowMapping") - proto.RegisterType((*StableBorrowMapping)(nil), "comdex.lend.v1beta1.StableBorrowMapping") - proto.RegisterType((*ModuleBalance)(nil), "comdex.lend.v1beta1.ModuleBalance") - proto.RegisterType((*ModuleBalanceStats)(nil), "comdex.lend.v1beta1.ModuleBalanceStats") - proto.RegisterType((*BalanceStats)(nil), "comdex.lend.v1beta1.BalanceStats") - proto.RegisterType((*DepositStats)(nil), "comdex.lend.v1beta1.DepositStats") - proto.RegisterType((*AuctionParams)(nil), "comdex.lend.v1beta1.AuctionParams") - proto.RegisterType((*ReservePoolRecordsForBorrow)(nil), "comdex.lend.v1beta1.ReservePoolRecordsForBorrow") - proto.RegisterType((*BorrowInterestTracker)(nil), "comdex.lend.v1beta1.Borrow_interest_tracker") - proto.RegisterType((*LendRewardsTracker)(nil), "comdex.lend.v1beta1.Lend_rewards_tracker") -} - -func init() { proto.RegisterFile("comdex/lend/v1beta1/lend.proto", fileDescriptor_b87bb4bef8334ddd) } - -var fileDescriptor_b87bb4bef8334ddd = []byte{ - // 2646 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x5a, 0x4d, 0x6c, 0x1b, 0xc7, - 0x15, 0xf6, 0xca, 0xfa, 0x21, 0x1f, 0x49, 0x49, 0x1c, 0x52, 0x31, 0x23, 0xd9, 0x5a, 0x67, 0x52, - 0x38, 0xea, 0x21, 0x14, 0xac, 0xa6, 0x40, 0x62, 0x24, 0x48, 0x48, 0xcb, 0x4a, 0x98, 0xd8, 0xb2, - 0x33, 0x76, 0x1a, 0xf4, 0x77, 0x31, 0xe4, 0x8e, 0xe4, 0x85, 0x97, 0xbb, 0x9b, 0xdd, 0xa5, 0x6c, - 0xf5, 0xc7, 0x0d, 0xda, 0x43, 0x81, 0x9c, 0x72, 0xef, 0xad, 0x97, 0xdc, 0x7b, 0xe8, 0xad, 0x40, - 0x2f, 0x6d, 0x73, 0xe8, 0x21, 0xc7, 0xa0, 0x07, 0xb6, 0xa0, 0x0f, 0x05, 0x7a, 0xd4, 0xb1, 0xa7, - 0x62, 0x7e, 0xf6, 0x8f, 0x64, 0x6c, 0x2d, 0xed, 0x34, 0xe8, 0x49, 0x9c, 0x99, 0x37, 0xdf, 0x7b, - 0x33, 0xf3, 0xe6, 0x9b, 0xf7, 0xde, 0x0a, 0x36, 0x7b, 0x6e, 0xdf, 0x64, 0x0f, 0xb6, 0x6d, 0xe6, - 0x98, 0xdb, 0x47, 0x97, 0xbb, 0x2c, 0xa4, 0x97, 0x45, 0xa3, 0xe9, 0xf9, 0x6e, 0xe8, 0xa2, 0x9a, - 0x1c, 0x6f, 0x8a, 0x2e, 0x35, 0xbe, 0x5e, 0x3f, 0x74, 0x0f, 0x5d, 0x31, 0xbe, 0xcd, 0x7f, 0x49, - 0xd1, 0x75, 0xfd, 0xd0, 0x75, 0x0f, 0x6d, 0xb6, 0x2d, 0x5a, 0xdd, 0xc1, 0xc1, 0x76, 0x68, 0xf5, - 0x59, 0x10, 0xd2, 0xbe, 0xa7, 0x04, 0x36, 0x7b, 0x6e, 0xd0, 0x77, 0x83, 0xed, 0x2e, 0x0d, 0x58, - 0xac, 0xab, 0xe7, 0x5a, 0x8e, 0x1c, 0xc7, 0x9f, 0x14, 0xa1, 0x78, 0x9d, 0x39, 0x66, 0x2b, 0x08, - 0x58, 0x88, 0xae, 0x00, 0x70, 0xa5, 0x96, 0x73, 0x68, 0x58, 0x66, 0x43, 0xbb, 0xa8, 0x6d, 0xcd, - 0xb7, 0x37, 0x46, 0x43, 0x7d, 0xae, 0xb3, 0x7b, 0x32, 0xd4, 0xab, 0xc7, 0xb4, 0x6f, 0x5f, 0xc1, - 0x89, 0x04, 0x26, 0x45, 0xd5, 0xe8, 0x98, 0xe8, 0x35, 0x28, 0x50, 0x0e, 0xc2, 0x67, 0xce, 0x89, - 0x99, 0x9b, 0xa3, 0xa1, 0xbe, 0x24, 0x80, 0xc5, 0xf4, 0x15, 0x39, 0x3d, 0x12, 0xc2, 0x64, 0x49, - 0xfc, 0xec, 0x98, 0xe8, 0xbb, 0xb0, 0xe4, 0xb9, 0xae, 0xcd, 0x67, 0x9e, 0x15, 0x33, 0xcf, 0x8f, - 0x86, 0xfa, 0xe2, 0x2d, 0xd7, 0xb5, 0xc5, 0xc4, 0x65, 0x39, 0x51, 0x89, 0x60, 0xb2, 0xc8, 0x7f, - 0x75, 0x4c, 0x74, 0x09, 0x16, 0xdc, 0xfb, 0x0e, 0xf3, 0x1b, 0xf3, 0x17, 0xb5, 0xad, 0x62, 0x7b, - 0xf5, 0x64, 0xa8, 0x97, 0xa5, 0xa8, 0xe8, 0xc6, 0x44, 0x0e, 0xa3, 0x9f, 0x41, 0x91, 0xf6, 0xdd, - 0x81, 0x13, 0x1a, 0x96, 0xd3, 0x58, 0xb8, 0xa8, 0x6d, 0x95, 0x76, 0x9e, 0x6f, 0xca, 0x7d, 0x69, - 0xf2, 0x7d, 0x89, 0xf6, 0xb8, 0x79, 0xd5, 0xb5, 0x9c, 0xf6, 0xd5, 0xcf, 0x87, 0xfa, 0x99, 0x93, - 0xa1, 0xbe, 0xaa, 0xcc, 0x8d, 0x66, 0xe2, 0xff, 0x0c, 0xf5, 0x97, 0x0e, 0xad, 0xf0, 0xee, 0xa0, - 0xdb, 0xec, 0xb9, 0xfd, 0x6d, 0xb5, 0xb1, 0xf2, 0xcf, 0xcb, 0x81, 0x79, 0x6f, 0x3b, 0x3c, 0xf6, - 0x58, 0x20, 0x40, 0x48, 0x41, 0x4e, 0xeb, 0x38, 0xe8, 0x27, 0x50, 0x8e, 0x36, 0x8c, 0x9f, 0x4d, - 0x63, 0x51, 0xe8, 0x5f, 0x6f, 0xca, 0x83, 0x6b, 0x46, 0x07, 0xd7, 0xbc, 0x13, 0x1d, 0x5c, 0x5b, - 0x57, 0x06, 0xd4, 0xb2, 0xdb, 0xcd, 0x67, 0xe3, 0x4f, 0xff, 0xa1, 0x6b, 0xa4, 0xa4, 0xba, 0xf8, - 0x14, 0x74, 0x04, 0xd5, 0x81, 0x67, 0xd2, 0x90, 0x99, 0x46, 0xb2, 0xc8, 0x25, 0xb1, 0x21, 0xef, - 0x72, 0xa0, 0xbf, 0x0f, 0xf5, 0x4b, 0xa7, 0xb0, 0xba, 0xe3, 0x84, 0x27, 0x43, 0xbd, 0x21, 0x55, - 0x4e, 0x00, 0x62, 0xb2, 0xa2, 0xfa, 0x5a, 0xd1, 0xba, 0x7e, 0x0e, 0x35, 0x7a, 0x44, 0x2d, 0x9b, - 0x76, 0x6d, 0x66, 0x84, 0xae, 0xd1, 0x75, 0x7d, 0xdf, 0xbd, 0xdf, 0x28, 0x08, 0xcd, 0xd7, 0x73, - 0x6b, 0x5e, 0x57, 0xbb, 0x3d, 0x09, 0x89, 0x49, 0x35, 0xee, 0xbd, 0xe3, 0xb6, 0x45, 0x1f, 0xfa, - 0x29, 0x20, 0x9f, 0xdd, 0xa7, 0xbe, 0x69, 0xb4, 0x7a, 0xbd, 0x41, 0x7f, 0x60, 0x73, 0xdb, 0x1a, - 0x45, 0xa1, 0xfc, 0xbd, 0xdc, 0xca, 0x9f, 0x97, 0xca, 0x15, 0x22, 0x4d, 0x10, 0x31, 0xa9, 0xca, - 0xce, 0x94, 0x16, 0x74, 0x19, 0x16, 0xa9, 0xe7, 0x71, 0x67, 0x05, 0xe1, 0xac, 0xeb, 0xa3, 0xa1, - 0xbe, 0xd0, 0xf2, 0x3c, 0xe1, 0xab, 0x15, 0xb5, 0x0e, 0x21, 0x80, 0xc9, 0x02, 0xf5, 0xbc, 0x8e, - 0x89, 0xee, 0x42, 0xf9, 0xd0, 0x76, 0xbb, 0xd4, 0x36, 0x2c, 0xc7, 0x64, 0x0f, 0x1a, 0x25, 0x61, - 0xe8, 0xb5, 0x1c, 0x86, 0xee, 0xb2, 0x5e, 0xe2, 0x12, 0x69, 0x2c, 0x4c, 0x4a, 0xb2, 0xd9, 0xe1, - 0x2d, 0xf4, 0x00, 0xd6, 0x6c, 0x1a, 0xf0, 0x33, 0x0b, 0x99, 0x4f, 0x7b, 0xa1, 0xe5, 0x3a, 0xd2, - 0xef, 0xca, 0x4f, 0xf4, 0xbb, 0x2d, 0xe5, 0x77, 0xe7, 0x95, 0xdf, 0x4d, 0x83, 0x91, 0x0e, 0x58, - 0xe3, 0x63, 0x9d, 0x64, 0x48, 0x38, 0x62, 0x0b, 0xa0, 0x27, 0xae, 0xa8, 0x43, 0xfb, 0xac, 0x51, - 0x11, 0x2b, 0xc4, 0xa3, 0xa1, 0x5e, 0xbc, 0xca, 0x2f, 0xf2, 0x3e, 0xed, 0xb3, 0x84, 0x42, 0x12, - 0x41, 0x4c, 0x8a, 0xa2, 0xc1, 0xc7, 0xf1, 0xef, 0xcb, 0x50, 0x92, 0x07, 0x2c, 0xe9, 0xe8, 0x2d, - 0x28, 0x4b, 0x1f, 0xc8, 0x10, 0xd2, 0x85, 0x98, 0x90, 0xd4, 0x76, 0xa4, 0x65, 0x30, 0x29, 0xc5, - 0xcd, 0x8e, 0xc9, 0x8d, 0x4a, 0x11, 0x9a, 0xa4, 0x25, 0x61, 0xd4, 0x75, 0xc5, 0x5b, 0x4f, 0xe6, - 0xb5, 0x6b, 0xb0, 0x6a, 0x05, 0x46, 0x10, 0x0a, 0xaf, 0x54, 0x5e, 0xce, 0x59, 0xaa, 0xd0, 0xde, - 0x38, 0x19, 0xea, 0xe7, 0xe4, 0xdc, 0x71, 0x09, 0x4c, 0x96, 0xad, 0xe0, 0xb6, 0xe8, 0x51, 0x1e, - 0xcb, 0x39, 0x8e, 0x5a, 0x3e, 0x37, 0x63, 0x3e, 0xc5, 0x71, 0xd4, 0xf2, 0x33, 0x1c, 0x27, 0x45, - 0x38, 0xc7, 0xf1, 0x11, 0xf3, 0x9b, 0xe5, 0xae, 0x87, 0x00, 0x0a, 0xc2, 0x1d, 0x84, 0x8a, 0xb9, - 0x1e, 0xa3, 0x7d, 0x57, 0x69, 0xaf, 0x66, 0xb4, 0xbb, 0x83, 0x30, 0x97, 0x7a, 0xb5, 0xde, 0x9b, - 0x83, 0x10, 0xfd, 0x56, 0x83, 0x7a, 0xd7, 0xb7, 0xcc, 0x43, 0xce, 0x45, 0xe2, 0xd9, 0x90, 0x63, - 0x82, 0xdf, 0x1e, 0x6b, 0xca, 0xbe, 0x32, 0x65, 0x43, 0x79, 0xc8, 0x14, 0x90, 0x5c, 0x46, 0x21, - 0x85, 0x20, 0xfc, 0x52, 0x72, 0x20, 0x32, 0x61, 0x39, 0xf1, 0x3c, 0x71, 0xc7, 0x0a, 0x4f, 0xbc, - 0x63, 0x2f, 0x28, 0xbb, 0xd6, 0xc6, 0x3d, 0x37, 0xb9, 0x5c, 0x95, 0xb8, 0x53, 0x5c, 0xab, 0x63, - 0x40, 0x19, 0xcf, 0x32, 0x7c, 0x1a, 0xb2, 0x19, 0x98, 0x4e, 0x12, 0x88, 0x62, 0xba, 0x49, 0x44, - 0x4c, 0x56, 0x83, 0x94, 0xbb, 0x12, 0x1a, 0x0a, 0xd5, 0x63, 0x2f, 0x01, 0x77, 0x03, 0x78, 0x3a, - 0x92, 0x9d, 0x44, 0xc4, 0x64, 0x35, 0xf3, 0xb8, 0xf0, 0x93, 0xff, 0x58, 0x83, 0xba, 0xe0, 0x1e, - 0x16, 0x84, 0x19, 0x8a, 0x97, 0xcc, 0x79, 0x23, 0xb7, 0x76, 0xe5, 0x08, 0x31, 0x66, 0x86, 0xe4, - 0x6b, 0x51, 0x77, 0x9a, 0xe6, 0xc7, 0x39, 0xbb, 0xfc, 0xb5, 0x71, 0xf6, 0x2f, 0xa1, 0xee, 0xb3, - 0x80, 0xf9, 0x47, 0xcc, 0xc8, 0x68, 0xac, 0xe4, 0x5e, 0xab, 0xd4, 0xb8, 0x11, 0x3d, 0x67, 0x93, - 0x98, 0x98, 0x20, 0xd5, 0xfd, 0xf6, 0x69, 0x1e, 0x8d, 0xe5, 0xff, 0xed, 0xa3, 0xb1, 0x32, 0xcb, - 0xa3, 0xf1, 0xd9, 0x02, 0xcc, 0x73, 0xe1, 0x74, 0x14, 0xa9, 0xe5, 0x88, 0x22, 0xaf, 0x41, 0xa9, - 0xef, 0x9a, 0x03, 0x9b, 0x49, 0x1b, 0xe6, 0x84, 0x0d, 0xdf, 0x1a, 0x0d, 0x75, 0xb8, 0x21, 0xba, - 0x95, 0x11, 0x48, 0x4e, 0x4f, 0x89, 0x62, 0x02, 0xfd, 0x58, 0x02, 0xbd, 0x07, 0x95, 0x3e, 0xb5, - 0x1c, 0x23, 0x8e, 0x81, 0x65, 0x24, 0xfb, 0xd2, 0x68, 0xa8, 0x97, 0x6e, 0x50, 0xcb, 0x91, 0x71, - 0xb0, 0x79, 0x32, 0xd4, 0xeb, 0x0a, 0x29, 0x2d, 0x8d, 0x49, 0xa9, 0x9f, 0x08, 0xa1, 0x3e, 0x3c, - 0x77, 0x60, 0xf9, 0x41, 0x68, 0x64, 0x89, 0x2b, 0x7e, 0x3b, 0x5e, 0x1d, 0x0d, 0xf5, 0xda, 0x1e, - 0x97, 0x68, 0xa7, 0x78, 0x49, 0x2c, 0xf3, 0x82, 0x44, 0x9f, 0x3e, 0x1d, 0x93, 0xda, 0xc1, 0xc4, - 0x2c, 0x13, 0x7d, 0x04, 0xe7, 0x02, 0xd6, 0x73, 0x1d, 0x73, 0x52, 0xdf, 0x82, 0xd0, 0x77, 0x65, - 0x34, 0xd4, 0xeb, 0xb7, 0x85, 0xc8, 0x84, 0xc2, 0x4d, 0x45, 0x29, 0xd3, 0x01, 0x30, 0xa9, 0x07, - 0x93, 0xf3, 0xcc, 0xb1, 0x83, 0x5f, 0x9c, 0xe1, 0xe0, 0xd1, 0x1b, 0x50, 0x89, 0x5c, 0xfc, 0x60, - 0xe0, 0x98, 0x81, 0x78, 0x15, 0xe6, 0xdb, 0x8d, 0x64, 0x8b, 0x33, 0xc3, 0x98, 0x94, 0x55, 0x7b, - 0x8f, 0x37, 0x91, 0x07, 0x20, 0x8d, 0x34, 0x69, 0x48, 0x1b, 0x85, 0x8b, 0x67, 0xb7, 0x4a, 0x3b, - 0xdf, 0x6e, 0x4e, 0x49, 0xbd, 0x9a, 0xc2, 0xe6, 0x5d, 0x1a, 0x52, 0x6e, 0xda, 0x0d, 0xea, 0x79, - 0x96, 0x73, 0xd8, 0xbe, 0xc4, 0x1d, 0x9f, 0x1b, 0x1c, 0x8f, 0xa6, 0x5e, 0xbe, 0x18, 0x17, 0x93, - 0x22, 0x8d, 0xc6, 0xf1, 0x6f, 0x34, 0xa8, 0x4f, 0xc3, 0xca, 0xa4, 0x4e, 0x5a, 0xbe, 0xd4, 0xe9, - 0x15, 0x00, 0x2b, 0x88, 0x76, 0x5d, 0x38, 0x6f, 0xa1, 0xbd, 0x96, 0x58, 0x92, 0x8c, 0x61, 0x52, - 0xb4, 0x02, 0x75, 0x08, 0xf8, 0x5f, 0x73, 0x50, 0xb9, 0xf6, 0x20, 0x64, 0x8e, 0xc9, 0x4c, 0x83, - 0xc7, 0x20, 0x68, 0x19, 0xe6, 0x22, 0xe5, 0x64, 0xce, 0x32, 0x51, 0x33, 0x36, 0xc9, 0x51, 0x61, - 0x53, 0x6d, 0xc2, 0x0e, 0x27, 0xb6, 0xc3, 0x41, 0x97, 0x41, 0x2e, 0x54, 0x3c, 0x11, 0xd2, 0xf5, - 0xeb, 0xa9, 0x40, 0x24, 0x1a, 0xc2, 0x44, 0xc2, 0x72, 0x8e, 0x7f, 0x1d, 0x2a, 0x56, 0x20, 0xc9, - 0xc2, 0xe0, 0x87, 0x2a, 0x7c, 0xbb, 0x90, 0x3e, 0xbf, 0xcc, 0x30, 0x26, 0x25, 0x2b, 0x10, 0xfc, - 0x21, 0x6e, 0xfb, 0xf7, 0xa1, 0x1a, 0xa3, 0x1a, 0xd1, 0xbd, 0x97, 0xde, 0xda, 0x1c, 0x0d, 0xf5, - 0xe5, 0x96, 0x52, 0x13, 0xdf, 0xff, 0xc6, 0x98, 0x29, 0x46, 0xcc, 0x04, 0xcb, 0x34, 0x2d, 0x6b, - 0xa2, 0x77, 0x01, 0xf5, 0x2d, 0xc7, 0x18, 0x04, 0xa6, 0x71, 0x44, 0xed, 0x01, 0x33, 0x6c, 0x76, - 0x20, 0xc3, 0x9f, 0xf9, 0xf6, 0x85, 0xe4, 0x25, 0x9b, 0x94, 0xc1, 0x64, 0xa5, 0x6f, 0x39, 0x1f, - 0x04, 0xe6, 0xf7, 0x78, 0xd7, 0x75, 0xde, 0xf3, 0x47, 0x0d, 0x90, 0x30, 0xe5, 0x8e, 0xcb, 0xf7, - 0xf9, 0x19, 0x9c, 0x78, 0x8a, 0xe6, 0xe6, 0x72, 0xd0, 0x5c, 0x2a, 0xfe, 0x3c, 0x7b, 0xf1, 0xec, - 0x69, 0xe3, 0x4f, 0x7c, 0x04, 0xd5, 0x0f, 0x02, 0xe6, 0xf3, 0x70, 0xb9, 0x63, 0x46, 0xd6, 0xc7, - 0x89, 0xb7, 0xf6, 0xf8, 0xc4, 0xfb, 0x35, 0x28, 0xf0, 0x8b, 0x64, 0x58, 0x66, 0xd0, 0x98, 0x13, - 0x4a, 0xc5, 0x2a, 0x05, 0xd8, 0x6e, 0x90, 0xac, 0x32, 0x12, 0xc2, 0x64, 0xc9, 0x16, 0x8a, 0x02, - 0xfc, 0x07, 0x0d, 0x36, 0xa4, 0xd2, 0xf6, 0xf1, 0x4d, 0x0e, 0xd6, 0x72, 0xcc, 0xf4, 0x95, 0x39, - 0xad, 0x09, 0x33, 0xee, 0xd6, 0xab, 0x10, 0x59, 0xa2, 0x76, 0xeb, 0xd4, 0x86, 0xff, 0x49, 0x83, - 0x0b, 0x32, 0x86, 0xfa, 0x86, 0x4c, 0x7f, 0x0b, 0x8a, 0x5d, 0xa5, 0x3f, 0x32, 0x5e, 0x10, 0xab, - 0x32, 0x4a, 0x98, 0x5f, 0x4d, 0x87, 0x9f, 0x72, 0x01, 0xc9, 0x24, 0xfc, 0xb1, 0x06, 0x35, 0x7e, - 0xe8, 0xd1, 0x32, 0xf2, 0x1a, 0xde, 0x02, 0x48, 0x90, 0xd5, 0xc1, 0xe7, 0x34, 0xe1, 0x33, 0x0d, - 0xce, 0xc9, 0xe3, 0x8f, 0x52, 0xfe, 0xc4, 0x8c, 0xd6, 0x94, 0x22, 0x55, 0xce, 0x9c, 0xae, 0x33, - 0x96, 0x58, 0x4a, 0x1b, 0x2f, 0xf1, 0xb7, 0xba, 0x1d, 0x67, 0x8f, 0xa7, 0xca, 0x30, 0xf1, 0x27, - 0x4b, 0x00, 0xe2, 0xda, 0xde, 0x0e, 0x69, 0x18, 0xcc, 0x1a, 0x84, 0x3c, 0x45, 0xf1, 0xcc, 0x81, - 0xe5, 0xd0, 0x0d, 0xa9, 0xad, 0xa2, 0x79, 0x26, 0x23, 0x8f, 0x62, 0xfb, 0xed, 0xdc, 0x31, 0xb2, - 0x4a, 0x4a, 0xb2, 0x68, 0x98, 0x54, 0x44, 0x47, 0x5b, 0xb5, 0xd1, 0xaf, 0x34, 0x58, 0x93, 0x22, - 0x99, 0x2c, 0x82, 0x99, 0xaa, 0x0c, 0xb7, 0x9f, 0x5b, 0xef, 0xf9, 0xb4, 0xde, 0x31, 0x50, 0x4c, - 0x6a, 0xa2, 0x3f, 0x9d, 0x4b, 0x33, 0x13, 0x75, 0x01, 0xa4, 0x38, 0x3f, 0x53, 0x41, 0xfb, 0x45, - 0x99, 0xfc, 0xe6, 0x52, 0x5c, 0x4d, 0x2b, 0xe6, 0x48, 0x98, 0x14, 0x45, 0x83, 0x7b, 0x12, 0xfa, - 0x91, 0x62, 0x2f, 0xea, 0xf9, 0x2a, 0x40, 0x69, 0xe5, 0x0e, 0xc5, 0xd3, 0x3c, 0x41, 0x3d, 0x5f, - 0xf1, 0x44, 0xcb, 0xf3, 0xf9, 0x0a, 0x94, 0xef, 0x73, 0xfc, 0xa5, 0xdc, 0x2b, 0x90, 0xf8, 0xd9, - 0x5b, 0x24, 0x34, 0xa8, 0x5b, 0xc4, 0x75, 0x1c, 0x41, 0x35, 0x9b, 0xe9, 0x71, 0x55, 0x85, 0xdc, - 0xb5, 0x41, 0xa9, 0xaa, 0x31, 0x2d, 0x75, 0x14, 0x1a, 0x57, 0xd2, 0x99, 0x23, 0xd7, 0x7b, 0x1f, - 0xaa, 0x83, 0xd0, 0xb2, 0xad, 0x80, 0x8a, 0x1c, 0xc0, 0xe7, 0x7f, 0x54, 0xca, 0x3a, 0xb3, 0xde, - 0x09, 0x40, 0x9e, 0x36, 0x26, 0x7d, 0x44, 0x74, 0xfd, 0xb9, 0x04, 0x2b, 0xe2, 0xce, 0xf0, 0xfc, - 0x35, 0x90, 0x37, 0xf2, 0x29, 0x9e, 0x5a, 0x03, 0x8a, 0x03, 0xc3, 0xf5, 0x42, 0xab, 0x4f, 0x6d, - 0x95, 0x18, 0xb4, 0x73, 0xdb, 0xaf, 0x42, 0xa0, 0x18, 0x08, 0x93, 0xc2, 0xe0, 0xa6, 0xfc, 0x89, - 0xde, 0x87, 0xf9, 0x2e, 0x0d, 0x98, 0xba, 0xb1, 0x6f, 0xe4, 0xc6, 0x2e, 0xa9, 0xe3, 0xa7, 0x01, - 0xc3, 0x44, 0x40, 0xa1, 0x0f, 0x61, 0x31, 0xb0, 0x5d, 0x8f, 0x5d, 0x56, 0xd7, 0xf1, 0xcd, 0xdc, - 0xa0, 0xaa, 0x84, 0x29, 0x51, 0x30, 0x51, 0x70, 0x31, 0xf0, 0x8e, 0xba, 0x6e, 0x4f, 0x07, 0xbc, - 0x13, 0x01, 0xef, 0xa0, 0xf7, 0xa1, 0xce, 0x1c, 0xe1, 0x54, 0xd9, 0x22, 0xdb, 0xa2, 0x08, 0x07, - 0xf5, 0x24, 0xa1, 0x9d, 0x26, 0x85, 0x09, 0x92, 0xdd, 0x99, 0x62, 0x1b, 0x83, 0x52, 0x24, 0xc5, - 0xb7, 0x57, 0xde, 0xae, 0xdd, 0xdc, 0x06, 0xa3, 0xac, 0xcb, 0x8b, 0x5d, 0x06, 0xe5, 0xec, 0x7c, - 0xaf, 0xef, 0x41, 0x45, 0x8d, 0xa9, 0x2d, 0x97, 0x77, 0x6b, 0x2f, 0xb7, 0xa2, 0x7a, 0x46, 0x51, - 0xb4, 0xf3, 0x65, 0xd9, 0xbe, 0x2d, 0xf7, 0x7f, 0x4c, 0xd9, 0x8e, 0xba, 0x50, 0xcf, 0x44, 0xd9, - 0x4e, 0x56, 0xd9, 0x0e, 0xda, 0x87, 0xb3, 0x76, 0x78, 0xa4, 0x6a, 0x3d, 0xaf, 0xe7, 0x56, 0x01, - 0x8a, 0xf6, 0xc2, 0x23, 0x4c, 0x38, 0x10, 0xfa, 0xb5, 0x06, 0x6b, 0xb6, 0xf5, 0xd1, 0xc0, 0x32, - 0xe5, 0x0d, 0x0e, 0xef, 0xfa, 0x2c, 0xb8, 0xeb, 0xda, 0x51, 0x41, 0x67, 0x3f, 0xb7, 0x8a, 0xa8, - 0xe0, 0x30, 0x0d, 0x14, 0x93, 0x7a, 0xaa, 0xff, 0x4e, 0xd4, 0x8d, 0x7e, 0x01, 0xb5, 0xb4, 0xbc, - 0xc7, 0x1c, 0x6a, 0x87, 0xc7, 0xaa, 0xb2, 0x73, 0x3d, 0xb7, 0x09, 0xeb, 0x93, 0x26, 0x28, 0x48, - 0x4c, 0x50, 0xaa, 0xf7, 0x96, 0xec, 0xe4, 0xb4, 0x98, 0x96, 0xed, 0xba, 0xce, 0x20, 0x50, 0x45, - 0x9e, 0x99, 0x69, 0x71, 0x02, 0x10, 0x93, 0xd5, 0x54, 0x5f, 0x9b, 0x77, 0xf1, 0x10, 0x21, 0x4e, - 0x85, 0x69, 0x2f, 0x74, 0x7d, 0x51, 0xd8, 0xc9, 0x17, 0x22, 0x48, 0xad, 0x6b, 0x63, 0x89, 0xb5, - 0x40, 0xc3, 0x24, 0x4a, 0xc4, 0xf7, 0x44, 0x1b, 0xbd, 0x09, 0xd0, 0x4b, 0x4a, 0x08, 0x2b, 0x82, - 0x74, 0x5f, 0x18, 0x0d, 0xf5, 0xc2, 0xd5, 0x84, 0x75, 0xa3, 0xdc, 0x3e, 0x55, 0x29, 0x28, 0xf4, - 0x54, 0x75, 0x00, 0xbf, 0x03, 0x25, 0xfe, 0x04, 0xa7, 0xb2, 0xa5, 0x38, 0x8f, 0xd0, 0xf2, 0x85, - 0xe3, 0x04, 0x2a, 0x92, 0x13, 0x52, 0xd1, 0x63, 0x2a, 0x38, 0xd5, 0x66, 0x09, 0x4e, 0x7d, 0xa8, - 0xa5, 0xd9, 0x26, 0x42, 0xfe, 0xe1, 0xf8, 0x6b, 0x9b, 0x28, 0xd8, 0x1e, 0x0d, 0xf5, 0x95, 0xf4, - 0x1c, 0xa9, 0x66, 0xea, 0x93, 0x2a, 0xb4, 0x65, 0x9e, 0x54, 0xae, 0xf3, 0x2f, 0x1a, 0x54, 0x64, - 0x3d, 0xaa, 0x4d, 0x6d, 0xea, 0xf4, 0xd8, 0xac, 0x91, 0xe6, 0x43, 0xa8, 0xab, 0x1a, 0x56, 0x57, - 0x02, 0x71, 0x3e, 0x0d, 0x65, 0x98, 0x5e, 0xda, 0x79, 0x69, 0x6a, 0x01, 0x24, 0xa3, 0x58, 0xbc, - 0xaa, 0xed, 0x17, 0xb3, 0x05, 0xf6, 0x69, 0x90, 0x98, 0xa0, 0xfe, 0xc4, 0x44, 0xfc, 0x57, 0x0d, - 0xd0, 0x24, 0xde, 0xd3, 0xbc, 0xd2, 0x47, 0xb0, 0xa4, 0xf4, 0x8a, 0x37, 0xfa, 0xb1, 0xdf, 0x05, - 0x5a, 0xca, 0xec, 0xe5, 0xe8, 0xe1, 0x14, 0xf3, 0x72, 0x7d, 0x0a, 0x88, 0x94, 0xe1, 0xdf, 0x69, - 0x50, 0x7e, 0x56, 0x6b, 0xf8, 0x10, 0x16, 0xd5, 0xa7, 0x8d, 0xb9, 0xdc, 0x8f, 0xab, 0x8c, 0x65, - 0x2b, 0xe9, 0x8f, 0x2e, 0x98, 0x28, 0x38, 0x1c, 0x42, 0x79, 0x97, 0x79, 0x6e, 0x60, 0xa9, 0xfc, - 0xc4, 0x84, 0x4a, 0xf6, 0xdc, 0x35, 0x71, 0xee, 0x2f, 0x4c, 0x3d, 0xf7, 0xcc, 0x89, 0x9f, 0x57, - 0x5b, 0x57, 0xcf, 0x6c, 0x5d, 0x74, 0xd4, 0xe5, 0x6e, 0xfa, 0x90, 0xff, 0x3d, 0x0f, 0x95, 0xd6, - 0x40, 0x94, 0x79, 0x6f, 0x51, 0x9f, 0xf6, 0x03, 0xb4, 0x15, 0x7f, 0x34, 0x95, 0x3b, 0x53, 0xfd, - 0xca, 0x6f, 0xa5, 0x3f, 0x86, 0x06, 0x95, 0x53, 0x0d, 0x73, 0xe0, 0x4b, 0x66, 0x93, 0x25, 0xc4, - 0x40, 0xa5, 0x46, 0x2f, 0x9e, 0x0c, 0x75, 0x5d, 0xcd, 0xfd, 0x0a, 0x49, 0x4c, 0x9e, 0x53, 0x43, - 0xbb, 0x6a, 0x44, 0x56, 0x2f, 0x03, 0xbe, 0xd3, 0xdd, 0xc1, 0xc1, 0x01, 0xf3, 0x55, 0xd0, 0x35, - 0x73, 0x18, 0x23, 0x51, 0x30, 0x51, 0x70, 0x3c, 0x96, 0xeb, 0x0d, 0x02, 0x4f, 0x85, 0x5d, 0x33, - 0xc7, 0x72, 0x1c, 0x03, 0x13, 0x01, 0xc5, 0x21, 0x83, 0x90, 0x79, 0x2a, 0xe0, 0x7a, 0x23, 0xb7, - 0x4f, 0x94, 0x22, 0x7e, 0x61, 0x1c, 0x92, 0xff, 0x41, 0xfb, 0x50, 0xf3, 0x7c, 0xab, 0x27, 0x6a, - 0xa2, 0xaa, 0x42, 0x7f, 0xec, 0x31, 0x55, 0xdc, 0xda, 0x4c, 0x1e, 0xb5, 0x29, 0x42, 0x98, 0x54, - 0x45, 0xef, 0x9e, 0xea, 0xbc, 0x73, 0xec, 0x31, 0xd4, 0x84, 0x82, 0x39, 0x08, 0x7b, 0x77, 0xf9, - 0xc9, 0x2e, 0x8d, 0xd7, 0x09, 0xa3, 0x11, 0x4c, 0x96, 0xc4, 0xcf, 0x8e, 0xc9, 0x83, 0xbd, 0xae, - 0x65, 0x4e, 0x9e, 0x6c, 0x41, 0xcc, 0x4d, 0x05, 0x7b, 0xd3, 0xa4, 0x30, 0x41, 0x5d, 0xcb, 0x1c, - 0x3b, 0x51, 0x3c, 0xd2, 0x60, 0x83, 0xc8, 0xf7, 0x87, 0xb3, 0x1f, 0x61, 0x3d, 0xd7, 0x37, 0x83, - 0x3d, 0x57, 0xd5, 0x2f, 0x9e, 0xc1, 0x57, 0xe4, 0xcc, 0xd7, 0xa8, 0xd4, 0x97, 0x23, 0x75, 0x59, - 0x67, 0xfe, 0x42, 0x73, 0xfa, 0xaf, 0x51, 0xf8, 0x4b, 0x0d, 0xce, 0xb5, 0xd5, 0x03, 0x11, 0xcd, - 0x0a, 0x7d, 0xda, 0xbb, 0xc7, 0x7c, 0x74, 0x65, 0xea, 0x02, 0xcf, 0xfd, 0xbf, 0x2c, 0xed, 0x6f, - 0x1a, 0xd4, 0xf9, 0x53, 0x6e, 0xc8, 0x7f, 0xb5, 0x08, 0xe2, 0x75, 0xbd, 0x32, 0xa5, 0xd0, 0xb3, - 0xf6, 0xc4, 0xda, 0xce, 0x43, 0xa8, 0x45, 0x40, 0x5f, 0xfb, 0x7a, 0xd4, 0x3f, 0xa1, 0x04, 0xa9, - 0xe5, 0xb4, 0xdf, 0xf9, 0x7c, 0xb4, 0xa9, 0x7d, 0x31, 0xda, 0xd4, 0xfe, 0x39, 0xda, 0xd4, 0x3e, - 0x7d, 0xb4, 0x79, 0xe6, 0x8b, 0x47, 0x9b, 0x67, 0xbe, 0x7c, 0xb4, 0x79, 0xe6, 0x07, 0xcd, 0x8c, - 0x52, 0x4e, 0xb7, 0x2f, 0xbb, 0x07, 0x07, 0x56, 0xcf, 0xa2, 0xb6, 0x6a, 0x6f, 0xab, 0x7f, 0x0a, - 0x13, 0x06, 0x74, 0x17, 0xc5, 0xf7, 0xb6, 0xef, 0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x0e, 0x6b, - 0xa6, 0xb6, 0x30, 0x26, 0x00, 0x00, + return len(dAtA) - i, nil } -func (m *LendAsset) Marshal() (dAtA []byte, err error) { +func (m *UserAssetLendBorrowMapping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1713,120 +1519,93 @@ func (m *LendAsset) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *LendAsset) MarshalTo(dAtA []byte) (int, error) { +func (m *UserAssetLendBorrowMapping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *LendAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *UserAssetLendBorrowMapping) 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 + if len(m.BorrowId) > 0 { + dAtA10 := make([]byte, len(m.BorrowId)*10) + var j9 int + for _, num := range m.BorrowId { + for num >= 1<<7 { + dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j9++ + } + dAtA10[j9] = uint8(num) + j9++ } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - if m.AppID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AppID)) + i -= j9 + copy(dAtA[i:], dAtA10[:j9]) + i = encodeVarintLend(dAtA, i, uint64(j9)) 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)) + dAtA[i] = 0x22 } - 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 + if m.PoolId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x18 } - 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)) + if m.LendId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.LendId)) + i-- + dAtA[i] = 0x10 } - 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 + dAtA[i] = 0xa } - if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + return len(dAtA) - i, nil +} + +func (m *AssetDataPoolMapping) 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 *AssetDataPoolMapping) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetDataPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SupplyCap != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.SupplyCap)) i-- dAtA[i] = 0x18 } - if m.AssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + if m.AssetTransitType != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetTransitType)) i-- dAtA[i] = 0x10 } - if m.ID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.ID)) + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *BorrowAsset) Marshal() (dAtA []byte, err error) { +func (m *Extended_Pair) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1836,45 +1615,129 @@ func (m *BorrowAsset) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *BorrowAsset) MarshalTo(dAtA []byte) (int, error) { +func (m *Extended_Pair) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Extended_Pair) 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))) + if m.MinUsdValueLeft != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.MinUsdValueLeft)) i-- - dAtA[i] = 0x7a + dAtA[i] = 0x30 } - 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 + if m.AssetOutPoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetOutPoolID)) + i-- + dAtA[i] = 0x28 } - 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 + if m.IsInterPool { + i-- + if m.IsInterPool { + dAtA[i] = 1 + } else { + dAtA[i] = 0 } - i = encodeVarintLend(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x20 } - i-- - dAtA[i] = 0x6a + if m.AssetOut != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetOut)) + i-- + dAtA[i] = 0x18 + } + if m.AssetIn != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetIn)) + 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 *AssetToPairMapping) 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 *AssetToPairMapping) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AssetToPairMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PairID) > 0 { + dAtA12 := make([]byte, len(m.PairID)*10) + var j11 int + for _, num := range m.PairID { + for num >= 1<<7 { + dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j11++ + } + dAtA12[j11] = uint8(num) + j11++ + } + i -= j11 + copy(dAtA[i:], dAtA12[:j11]) + i = encodeVarintLend(dAtA, i, uint64(j11)) + i-- + dAtA[i] = 0x1a + } + if m.AssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x10 + } + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *PoolAssetLBMapping) 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 *PoolAssetLBMapping) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PoolAssetLBMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l { - size := m.GlobalIndex.Size() + size := m.UtilisationRatio.Size() i -= size - if _, err := m.GlobalIndex.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.UtilisationRatio.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintLend(dAtA, i, uint64(size)) @@ -1882,9 +1745,9 @@ func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x62 { - size := m.Interest_Accumulated.Size() + size := m.StableBorrowApr.Size() i -= size - if _, err := m.Interest_Accumulated.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.StableBorrowApr.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintLend(dAtA, i, uint64(size)) @@ -1892,9 +1755,9 @@ func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x5a { - size := m.UpdatedAmountOut.Size() + size := m.BorrowApr.Size() i -= size - if _, err := m.UpdatedAmountOut.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.BorrowApr.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintLend(dAtA, i, uint64(size)) @@ -1902,82 +1765,105 @@ func (m *BorrowAsset) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x52 { - size := m.StableBorrowRate.Size() + size := m.LendApr.Size() i -= size - if _, err := m.StableBorrowRate.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.LendApr.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 + { + size := m.TotalInterestAccumulated.Size() + i -= size + if _, err := m.TotalInterestAccumulated.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - i -= n5 - i = encodeVarintLend(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x42 { - size, err := m.BridgedAssetAmount.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.TotalLend.Size() + i -= size + if _, err := m.TotalLend.MarshalTo(dAtA[i:]); 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 { + size := m.TotalStableBorrowed.Size() + i -= size + if _, err := m.TotalStableBorrowed.MarshalTo(dAtA[i:]); 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 { + size := m.TotalBorrowed.Size() + i -= size + if _, err := m.TotalBorrowed.MarshalTo(dAtA[i:]); 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)) + if len(m.BorrowIds) > 0 { + dAtA14 := make([]byte, len(m.BorrowIds)*10) + var j13 int + for _, num := range m.BorrowIds { + for num >= 1<<7 { + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j13++ + } + dAtA14[j13] = uint8(num) + j13++ + } + i -= j13 + copy(dAtA[i:], dAtA14[:j13]) + i = encodeVarintLend(dAtA, i, uint64(j13)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x22 } - if m.IsStableBorrow { - i-- - if m.IsStableBorrow { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + if len(m.LendIds) > 0 { + dAtA16 := make([]byte, len(m.LendIds)*10) + var j15 int + for _, num := range m.LendIds { + for num >= 1<<7 { + dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j15++ + } + dAtA16[j15] = uint8(num) + j15++ } + i -= j15 + copy(dAtA[i:], dAtA16[:j15]) + i = encodeVarintLend(dAtA, i, uint64(j15)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x1a } - if m.LendingID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.LendingID)) + 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)) + if m.PoolID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *Pool) Marshal() (dAtA []byte, err error) { +func (m *AssetRatesParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1987,73 +1873,160 @@ func (m *Pool) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Pool) MarshalTo(dAtA []byte) (int, error) { +func (m *AssetRatesParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AssetRatesParams) 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)) + if m.CAssetID != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.CAssetID)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x78 } - 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 + { + size := m.ReserveFactor.Size() + i -= size + if _, err := m.ReserveFactor.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.SecondBridgedAssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.SecondBridgedAssetID)) - i-- - dAtA[i] = 0x28 + i-- + dAtA[i] = 0x72 + { + size := m.LiquidationBonus.Size() + i -= size + if _, err := m.LiquidationBonus.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.FirstBridgedAssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.FirstBridgedAssetID)) - i-- - dAtA[i] = 0x20 + i-- + dAtA[i] = 0x6a + { + size := m.LiquidationPenalty.Size() + i -= size + if _, err := m.LiquidationPenalty.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.MainAssetId != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.MainAssetId)) - i-- - dAtA[i] = 0x18 + i-- + dAtA[i] = 0x62 + { + size := m.LiquidationThreshold.Size() + i -= size + if _, err := m.LiquidationThreshold.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - 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 + i-- + dAtA[i] = 0x5a + { + size := m.Ltv.Size() + i -= size + if _, err := m.Ltv.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + i-- + dAtA[i] = 0x52 + { + size := m.StableSlope2.Size() + i -= size + if _, err := m.StableSlope2.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + { + size := m.StableSlope1.Size() + i -= size + if _, err := m.StableSlope1.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + { + size := m.StableBase.Size() + i -= size + if _, err := m.StableBase.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + if m.EnableStableBorrow { + i-- + if m.EnableStableBorrow { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x30 + } + { + size := m.Slope2.Size() + i -= size + if _, err := m.Slope2.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.Slope1.Size() + i -= size + if _, err := m.Slope1.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.Base.Size() + i -= size + if _, err := m.Base.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.UOptimal.Size() + i -= size + if _, err := m.UOptimal.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + 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 (m *AssetDataPoolMapping) Marshal() (dAtA []byte, err error) { +func (m *StableBorrowMapping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2063,35 +2036,38 @@ func (m *AssetDataPoolMapping) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AssetDataPoolMapping) MarshalTo(dAtA []byte) (int, error) { +func (m *StableBorrowMapping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AssetDataPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *StableBorrowMapping) 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 + 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] = 0x10 - } - if m.AssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) - i-- - dAtA[i] = 0x8 + dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *Extended_Pair) Marshal() (dAtA []byte, err error) { +func (m *ReserveBuybackAssetData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2101,55 +2077,45 @@ func (m *Extended_Pair) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Extended_Pair) MarshalTo(dAtA []byte) (int, error) { +func (m *ReserveBuybackAssetData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Extended_Pair) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ReserveBuybackAssetData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.MinUsdValueLeft != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.MinUsdValueLeft)) - i-- - dAtA[i] = 0x30 - } - if m.AssetOutPoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetOutPoolID)) - i-- - dAtA[i] = 0x28 - } - if m.IsInterPool { - i-- - if m.IsInterPool { - dAtA[i] = 1 - } else { - dAtA[i] = 0 + { + size := m.BuybackAmount.Size() + i -= size + if _, err := m.BuybackAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i-- - dAtA[i] = 0x20 - } - if m.AssetOut != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetOut)) - i-- - dAtA[i] = 0x18 + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.AssetIn != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetIn)) - i-- - dAtA[i] = 0x10 + i-- + dAtA[i] = 0x1a + { + size := m.ReserveAmount.Size() + i -= size + if _, err := m.ReserveAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) } - if m.Id != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.Id)) + 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 (m *AssetToPairMapping) Marshal() (dAtA []byte, err error) { +func (m *AuctionParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2159,48 +2125,75 @@ func (m *AssetToPairMapping) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *AssetToPairMapping) MarshalTo(dAtA []byte) (int, error) { +func (m *AuctionParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *AssetToPairMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *AuctionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PairID) > 0 { - dAtA10 := make([]byte, len(m.PairID)*10) - var j9 int - for _, num := range m.PairID { - for num >= 1<<7 { - dAtA10[j9] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j9++ - } - dAtA10[j9] = uint8(num) - j9++ - } - i -= j9 - copy(dAtA[i:], dAtA10[:j9]) - i = encodeVarintLend(dAtA, i, uint64(j9)) + if m.BidDurationSeconds != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.BidDurationSeconds)) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x40 } - if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) + if m.DutchId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.DutchId)) + i-- + dAtA[i] = 0x38 + } + if m.PriceFunctionType != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.PriceFunctionType)) + i-- + dAtA[i] = 0x30 + } + { + size := m.Step.Size() + i -= size + if _, err := m.Step.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.Cusp.Size() + i -= size + if _, err := m.Cusp.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.Buffer.Size() + i -= size + if _, err := m.Buffer.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintLend(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if m.AuctionDurationSeconds != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AuctionDurationSeconds)) i-- dAtA[i] = 0x10 } - if m.AssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) + if m.AppId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.AppId)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *UserLendIdMapping) Marshal() (dAtA []byte, err error) { +func (m *BorrowInterestTracker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2210,45 +2203,35 @@ func (m *UserLendIdMapping) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UserLendIdMapping) MarshalTo(dAtA []byte) (int, error) { +func (m *BorrowInterestTracker) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *UserLendIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *BorrowInterestTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.LendIDs) > 0 { - dAtA12 := make([]byte, len(m.LendIDs)*10) - var j11 int - for _, num := range m.LendIDs { - for num >= 1<<7 { - dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j11++ - } - dAtA12[j11] = uint8(num) - j11++ + { + size := m.ReservePoolInterest.Size() + i -= size + if _, err := m.ReservePoolInterest.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i -= j11 - copy(dAtA[i:], dAtA12[:j11]) - i = encodeVarintLend(dAtA, i, uint64(j11)) - i-- - dAtA[i] = 0x12 + i = encodeVarintLend(dAtA, i, uint64(size)) } - 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] = 0x1a + if m.BorrowingId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.BorrowingId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *LendIdByOwnerAndPoolMapping) Marshal() (dAtA []byte, err error) { +func (m *LendRewardsTracker) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2258,2416 +2241,436 @@ func (m *LendIdByOwnerAndPoolMapping) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *LendIdByOwnerAndPoolMapping) MarshalTo(dAtA []byte) (int, error) { +func (m *LendRewardsTracker) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *LendIdByOwnerAndPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *LendRewardsTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.LendIDs) > 0 { - dAtA14 := make([]byte, len(m.LendIDs)*10) - var j13 int - for _, num := range m.LendIDs { - for num >= 1<<7 { - dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j13++ - } - dAtA14[j13] = uint8(num) - j13++ + { + size := m.RewardsAccumulated.Size() + i -= size + if _, err := m.RewardsAccumulated.MarshalTo(dAtA[i:]); err != nil { + return 0, err } - i -= j13 - copy(dAtA[i:], dAtA14[:j13]) - i = encodeVarintLend(dAtA, i, uint64(j13)) - i-- - dAtA[i] = 0x1a - } - if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) - i-- - dAtA[i] = 0x10 + i = encodeVarintLend(dAtA, i, uint64(size)) } - 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] = 0x12 + if m.LendingId != 0 { + i = encodeVarintLend(dAtA, i, uint64(m.LendingId)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *BorrowIdByOwnerAndPoolMapping) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +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++ } - return dAtA[:n], nil -} - -func (m *BorrowIdByOwnerAndPoolMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *BorrowIdByOwnerAndPoolMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *LendAsset) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.BorrowIDs) > 0 { - dAtA16 := make([]byte, len(m.BorrowIDs)*10) - var j15 int - for _, num := range m.BorrowIDs { - for num >= 1<<7 { - dAtA16[j15] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j15++ - } - dAtA16[j15] = uint8(num) - j15++ - } - i -= j15 - copy(dAtA[i:], dAtA16[:j15]) - i = encodeVarintLend(dAtA, i, uint64(j15)) - i-- - dAtA[i] = 0x1a + if m.ID != 0 { + n += 1 + sovLend(uint64(m.ID)) + } + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) } if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) - i-- - dAtA[i] = 0x10 + n += 1 + sovLend(uint64(m.PoolID)) } - 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] = 0xa + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) } - return len(dAtA) - i, nil -} - -func (m *UserBorrowIdMapping) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + 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.AvailableToBorrow.Size() + n += 1 + l + sovLend(uint64(l)) + if m.AppID != 0 { + n += 1 + sovLend(uint64(m.AppID)) } - return dAtA[:n], nil -} - -func (m *UserBorrowIdMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + 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 *UserBorrowIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *BorrowAsset) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.BorrowIDs) > 0 { - dAtA18 := make([]byte, len(m.BorrowIDs)*10) - var j17 int - for _, num := range m.BorrowIDs { - 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] = 0x12 + if m.ID != 0 { + n += 1 + sovLend(uint64(m.ID)) } - 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] = 0xa + if m.LendingID != 0 { + n += 1 + sovLend(uint64(m.LendingID)) } - return len(dAtA) - i, nil -} - -func (m *LendIdToBorrowIdMapping) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.IsStableBorrow { + n += 2 } - return dAtA[:n], nil -} - -func (m *LendIdToBorrowIdMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + 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.InterestAccumulated.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)) + } + if m.IsLiquidated { + n += 2 + } + return n } -func (m *LendIdToBorrowIdMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *Pool) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if len(m.BorrowingID) > 0 { - dAtA20 := make([]byte, len(m.BorrowingID)*10) - var j19 int - for _, num := range m.BorrowingID { - for num >= 1<<7 { - dAtA20[j19] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j19++ - } - dAtA20[j19] = uint8(num) - j19++ - } - i -= j19 - copy(dAtA[i:], dAtA20[:j19]) - i = encodeVarintLend(dAtA, i, uint64(j19)) - i-- - dAtA[i] = 0x12 + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) } - if m.LendingID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.LendingID)) - i-- - dAtA[i] = 0x8 + l = len(m.ModuleName) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) } - return len(dAtA) - i, nil + 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 *AssetStats) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *UserAssetLendBorrowMapping) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovLend(uint64(l)) + } + if m.LendId != 0 { + n += 1 + sovLend(uint64(m.LendId)) + } + if m.PoolId != 0 { + n += 1 + sovLend(uint64(m.PoolId)) + } + if len(m.BorrowId) > 0 { + l = 0 + for _, e := range m.BorrowId { + l += sovLend(uint64(e)) + } + n += 1 + sovLend(uint64(l)) + l + } + return n } -func (m *AssetStats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *AssetDataPoolMapping) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) + } + if m.AssetTransitType != 0 { + n += 1 + sovLend(uint64(m.AssetTransitType)) + } + if m.SupplyCap != 0 { + n += 1 + sovLend(uint64(m.SupplyCap)) + } + return n } -func (m *AssetStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *Extended_Pair) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size := m.UtilisationRatio.Size() - i -= size - if _, err := m.UtilisationRatio.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.Id != 0 { + n += 1 + sovLend(uint64(m.Id)) } - i-- - dAtA[i] = 0x4a - { - size := m.StableBorrowApr.Size() - i -= size - if _, err := m.StableBorrowApr.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.AssetIn != 0 { + n += 1 + sovLend(uint64(m.AssetIn)) } - i-- - dAtA[i] = 0x42 - { - size := m.BorrowApr.Size() - i -= size - if _, err := m.BorrowApr.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.AssetOut != 0 { + n += 1 + sovLend(uint64(m.AssetOut)) } - i-- - dAtA[i] = 0x3a - { - size := m.LendApr.Size() - i -= size - if _, err := m.LendApr.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.IsInterPool { + n += 2 } - i-- - dAtA[i] = 0x32 - { - size := m.TotalLend.Size() - i -= size - if _, err := m.TotalLend.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.AssetOutPoolID != 0 { + n += 1 + sovLend(uint64(m.AssetOutPoolID)) } - i-- - dAtA[i] = 0x2a - { - size := m.TotalStableBorrowed.Size() - i -= size - if _, err := m.TotalStableBorrowed.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.MinUsdValueLeft != 0 { + n += 1 + sovLend(uint64(m.MinUsdValueLeft)) } - i-- - dAtA[i] = 0x22 - { - size := m.TotalBorrowed.Size() - i -= size - if _, err := m.TotalBorrowed.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + return n +} + +func (m *AssetToPairMapping) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) } - i-- - dAtA[i] = 0x1a if m.AssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AssetID)) - i-- - dAtA[i] = 0x10 + n += 1 + sovLend(uint64(m.AssetID)) } - if m.PoolID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PoolID)) - i-- - dAtA[i] = 0x8 + if len(m.PairID) > 0 { + l = 0 + for _, e := range m.PairID { + l += sovLend(uint64(e)) + } + n += 1 + sovLend(uint64(l)) + l } - return len(dAtA) - i, nil + return n } -func (m *AssetRatesStats) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *PoolAssetLBMapping) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *AssetRatesStats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AssetRatesStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - if m.CAssetID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.CAssetID)) - i-- - dAtA[i] = 0x78 + if m.PoolID != 0 { + n += 1 + sovLend(uint64(m.PoolID)) } - { - size := m.ReserveFactor.Size() - i -= size - if _, err := m.ReserveFactor.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) } - i-- - dAtA[i] = 0x72 - { - size := m.LiquidationBonus.Size() - i -= size - if _, err := m.LiquidationBonus.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.LendIds) > 0 { + l = 0 + for _, e := range m.LendIds { + l += sovLend(uint64(e)) } - i = encodeVarintLend(dAtA, i, uint64(size)) + n += 1 + sovLend(uint64(l)) + l } - i-- - dAtA[i] = 0x6a - { - size := m.LiquidationPenalty.Size() - i -= size - if _, err := m.LiquidationPenalty.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if len(m.BorrowIds) > 0 { + l = 0 + for _, e := range m.BorrowIds { + l += sovLend(uint64(e)) } - i = encodeVarintLend(dAtA, i, uint64(size)) + n += 1 + sovLend(uint64(l)) + l } - i-- - dAtA[i] = 0x62 - { - size := m.LiquidationThreshold.Size() - i -= size - if _, err := m.LiquidationThreshold.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + l = m.TotalBorrowed.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.TotalStableBorrowed.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.TotalLend.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.TotalInterestAccumulated.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.LendApr.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.BorrowApr.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.StableBorrowApr.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.UtilisationRatio.Size() + n += 1 + l + sovLend(uint64(l)) + return n +} + +func (m *AssetRatesParams) Size() (n int) { + if m == nil { + return 0 } - i-- - dAtA[i] = 0x5a - { - size := m.Ltv.Size() - i -= size - if _, err := m.Ltv.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) } - i-- - dAtA[i] = 0x52 - { - size := m.StableSlope2.Size() - i -= size - if _, err := m.StableSlope2.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) + l = m.UOptimal.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Base.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Slope1.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Slope2.Size() + n += 1 + l + sovLend(uint64(l)) + if m.EnableStableBorrow { + n += 2 } - i-- - dAtA[i] = 0x4a - { - size := m.StableSlope1.Size() - i -= size - if _, err := m.StableSlope1.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x42 - { - size := m.StableBase.Size() - i -= size - if _, err := m.StableBase.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - if m.EnableStableBorrow { - i-- - if m.EnableStableBorrow { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } - { - size := m.Slope2.Size() - i -= size - if _, err := m.Slope2.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.Slope1.Size() - i -= size - if _, err := m.Slope1.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.Base.Size() - i -= size - if _, err := m.Base.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.UOptimal.Size() - i -= size - if _, err := m.UOptimal.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - 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 (m *LendMapping) 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 *LendMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LendMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.LendIDs) > 0 { - dAtA22 := make([]byte, len(m.LendIDs)*10) - var j21 int - for _, num := range m.LendIDs { - for num >= 1<<7 { - dAtA22[j21] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j21++ - } - dAtA22[j21] = uint8(num) - j21++ - } - i -= j21 - copy(dAtA[i:], dAtA22[:j21]) - i = encodeVarintLend(dAtA, i, uint64(j21)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *BorrowMapping) 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 *BorrowMapping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BorrowMapping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BorrowIDs) > 0 { - dAtA24 := make([]byte, len(m.BorrowIDs)*10) - var j23 int - for _, num := range m.BorrowIDs { - for num >= 1<<7 { - dAtA24[j23] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j23++ - } - dAtA24[j23] = uint8(num) - j23++ - } - i -= j23 - copy(dAtA[i:], dAtA24[:j23]) - i = encodeVarintLend(dAtA, i, uint64(j23)) - i-- - dAtA[i] = 0xa - } - 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 { - dAtA26 := make([]byte, len(m.StableBorrowIDs)*10) - var j25 int - for _, num := range m.StableBorrowIDs { - for num >= 1<<7 { - dAtA26[j25] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j25++ - } - dAtA26[j25] = uint8(num) - j25++ - } - i -= j25 - copy(dAtA[i:], dAtA26[:j25]) - i = encodeVarintLend(dAtA, i, uint64(j25)) - i-- - dAtA[i] = 0xa - } - 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 + l = m.StableBase.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.StableSlope1.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.StableSlope2.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Ltv.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.LiquidationThreshold.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.LiquidationPenalty.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.LiquidationBonus.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.ReserveFactor.Size() + n += 1 + l + sovLend(uint64(l)) + if m.CAssetID != 0 { + n += 1 + sovLend(uint64(m.CAssetID)) } - return dAtA[:n], nil -} - -func (m *ModuleBalanceStats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return n } -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 +func (m *StableBorrowMapping) Size() (n int) { + if m == nil { + return 0 } - return len(dAtA) - i, nil -} - -func (m *BalanceStats) 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 *BalanceStats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BalanceStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - 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 (m *DepositStats) 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 *DepositStats) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DepositStats) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BalanceStats) > 0 { - for iNdEx := len(m.BalanceStats) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.BalanceStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *AuctionParams) 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 *AuctionParams) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *AuctionParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.BidDurationSeconds != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.BidDurationSeconds)) - i-- - dAtA[i] = 0x40 - } - if m.DutchId != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.DutchId)) - i-- - dAtA[i] = 0x38 - } - if m.PriceFunctionType != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.PriceFunctionType)) - i-- - dAtA[i] = 0x30 - } - { - size := m.Step.Size() - i -= size - if _, err := m.Step.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.Cusp.Size() - i -= size - if _, err := m.Cusp.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.Buffer.Size() - i -= size - if _, err := m.Buffer.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.AuctionDurationSeconds != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AuctionDurationSeconds)) - i-- - dAtA[i] = 0x10 - } - if m.AppId != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.AppId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *ReservePoolRecordsForBorrow) 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 *ReservePoolRecordsForBorrow) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ReservePoolRecordsForBorrow) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.InterestAccumulated.Size() - i -= size - if _, err := m.InterestAccumulated.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.ID != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.ID)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *BorrowInterestTracker) 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 *BorrowInterestTracker) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BorrowInterestTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.InterestAccumulated.Size() - i -= size - if _, err := m.InterestAccumulated.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.BorrowingId != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.BorrowingId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *LendRewardsTracker) 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 *LendRewardsTracker) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LendRewardsTracker) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.RewardsAccumulated.Size() - i -= size - if _, err := m.RewardsAccumulated.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintLend(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.LendingId != 0 { - i = encodeVarintLend(dAtA, i, uint64(m.LendingId)) - 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 *LendAsset) 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 *BorrowAsset) 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 *Pool) 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 *AssetDataPoolMapping) 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 (m *Extended_Pair) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovLend(uint64(m.Id)) - } - if m.AssetIn != 0 { - n += 1 + sovLend(uint64(m.AssetIn)) - } - if m.AssetOut != 0 { - n += 1 + sovLend(uint64(m.AssetOut)) - } - if m.IsInterPool { - n += 2 - } - if m.AssetOutPoolID != 0 { - n += 1 + sovLend(uint64(m.AssetOutPoolID)) - } - if m.MinUsdValueLeft != 0 { - n += 1 + sovLend(uint64(m.MinUsdValueLeft)) - } - return n -} - -func (m *AssetToPairMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AssetID != 0 { - n += 1 + sovLend(uint64(m.AssetID)) - } - if m.PoolID != 0 { - n += 1 + sovLend(uint64(m.PoolID)) - } - if len(m.PairID) > 0 { - l = 0 - for _, e := range m.PairID { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *UserLendIdMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovLend(uint64(l)) - } - if len(m.LendIDs) > 0 { - l = 0 - for _, e := range m.LendIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *LendIdByOwnerAndPoolMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovLend(uint64(l)) - } - if m.PoolID != 0 { - n += 1 + sovLend(uint64(m.PoolID)) - } - if len(m.LendIDs) > 0 { - l = 0 - for _, e := range m.LendIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *BorrowIdByOwnerAndPoolMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovLend(uint64(l)) - } - if m.PoolID != 0 { - n += 1 + sovLend(uint64(m.PoolID)) - } - if len(m.BorrowIDs) > 0 { - l = 0 - for _, e := range m.BorrowIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *UserBorrowIdMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovLend(uint64(l)) - } - if len(m.BorrowIDs) > 0 { - l = 0 - for _, e := range m.BorrowIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *LendIdToBorrowIdMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.LendingID != 0 { - n += 1 + sovLend(uint64(m.LendingID)) - } - if len(m.BorrowingID) > 0 { - l = 0 - for _, e := range m.BorrowingID { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *AssetStats) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolID != 0 { - n += 1 + sovLend(uint64(m.PoolID)) - } - if m.AssetID != 0 { - n += 1 + sovLend(uint64(m.AssetID)) - } - l = m.TotalBorrowed.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.TotalStableBorrowed.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.TotalLend.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.LendApr.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.BorrowApr.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.StableBorrowApr.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.UtilisationRatio.Size() - n += 1 + l + sovLend(uint64(l)) - return n -} - -func (m *AssetRatesStats) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AssetID != 0 { - n += 1 + sovLend(uint64(m.AssetID)) - } - l = m.UOptimal.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Base.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Slope1.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Slope2.Size() - n += 1 + l + sovLend(uint64(l)) - if m.EnableStableBorrow { - n += 2 - } - l = m.StableBase.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.StableSlope1.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.StableSlope2.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Ltv.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.LiquidationThreshold.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.LiquidationPenalty.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.LiquidationBonus.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.ReserveFactor.Size() - n += 1 + l + sovLend(uint64(l)) - if m.CAssetID != 0 { - n += 1 + sovLend(uint64(m.CAssetID)) - } - return n -} - -func (m *LendMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.LendIDs) > 0 { - l = 0 - for _, e := range m.LendIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - return n -} - -func (m *BorrowMapping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BorrowIDs) > 0 { - l = 0 - for _, e := range m.BorrowIDs { - l += sovLend(uint64(e)) - } - n += 1 + sovLend(uint64(l)) + l - } - 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 *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 (m *BalanceStats) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AssetID != 0 { - n += 1 + sovLend(uint64(m.AssetID)) - } - l = m.Amount.Size() - n += 1 + l + sovLend(uint64(l)) - return n -} - -func (m *DepositStats) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.BalanceStats) > 0 { - for _, e := range m.BalanceStats { - l = e.Size() - n += 1 + l + sovLend(uint64(l)) - } - } - return n -} - -func (m *AuctionParams) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AppId != 0 { - n += 1 + sovLend(uint64(m.AppId)) - } - if m.AuctionDurationSeconds != 0 { - n += 1 + sovLend(uint64(m.AuctionDurationSeconds)) - } - l = m.Buffer.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Cusp.Size() - n += 1 + l + sovLend(uint64(l)) - l = m.Step.Size() - n += 1 + l + sovLend(uint64(l)) - if m.PriceFunctionType != 0 { - n += 1 + sovLend(uint64(m.PriceFunctionType)) - } - if m.DutchId != 0 { - n += 1 + sovLend(uint64(m.DutchId)) - } - if m.BidDurationSeconds != 0 { - n += 1 + sovLend(uint64(m.BidDurationSeconds)) - } - return n -} - -func (m *ReservePoolRecordsForBorrow) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ID != 0 { - n += 1 + sovLend(uint64(m.ID)) - } - l = m.InterestAccumulated.Size() - n += 1 + l + sovLend(uint64(l)) - return n -} - -func (m *BorrowInterestTracker) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.BorrowingId != 0 { - n += 1 + sovLend(uint64(m.BorrowingId)) - } - l = m.InterestAccumulated.Size() - n += 1 + l + sovLend(uint64(l)) - return n -} - -func (m *LendRewardsTracker) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.LendingId != 0 { - n += 1 + sovLend(uint64(m.LendingId)) - } - l = m.RewardsAccumulated.Size() - n += 1 + l + sovLend(uint64(l)) - 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 *LendAsset) 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: LendAsset: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LendAsset: 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 *BorrowAsset) 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: BorrowAsset: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BorrowAsset: 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 + 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 +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *ReserveBuybackAssetData) Size() (n int) { + if m == nil { + return 0 } - return nil + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovLend(uint64(m.AssetID)) + } + l = m.ReserveAmount.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.BuybackAmount.Size() + n += 1 + l + sovLend(uint64(l)) + return n } -func (m *Pool) Unmarshal(dAtA []byte) error { + +func (m *AuctionParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AppId != 0 { + n += 1 + sovLend(uint64(m.AppId)) + } + if m.AuctionDurationSeconds != 0 { + n += 1 + sovLend(uint64(m.AuctionDurationSeconds)) + } + l = m.Buffer.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Cusp.Size() + n += 1 + l + sovLend(uint64(l)) + l = m.Step.Size() + n += 1 + l + sovLend(uint64(l)) + if m.PriceFunctionType != 0 { + n += 1 + sovLend(uint64(m.PriceFunctionType)) + } + if m.DutchId != 0 { + n += 1 + sovLend(uint64(m.DutchId)) + } + if m.BidDurationSeconds != 0 { + n += 1 + sovLend(uint64(m.BidDurationSeconds)) + } + return n +} + +func (m *BorrowInterestTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BorrowingId != 0 { + n += 1 + sovLend(uint64(m.BorrowingId)) + } + l = m.ReservePoolInterest.Size() + n += 1 + l + sovLend(uint64(l)) + return n +} + +func (m *LendRewardsTracker) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.LendingId != 0 { + n += 1 + sovLend(uint64(m.LendingId)) + } + l = m.RewardsAccumulated.Size() + n += 1 + l + sovLend(uint64(l)) + 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 *LendAsset) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4690,17 +2693,17 @@ func (m *Pool) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Pool: wiretype end group for non-group") + return fmt.Errorf("proto: LendAsset: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: LendAsset: 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) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - m.PoolID = 0 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4710,16 +2713,16 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint64(b&0x7F) << shift + m.ID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - 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 AssetID", wireType) } - var stringLen uint64 + m.AssetID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4729,29 +2732,16 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetID |= 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) + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) } - m.MainAssetId = 0 + m.PoolID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4761,16 +2751,16 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MainAssetId |= uint64(b&0x7F) << shift + m.PoolID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FirstBridgedAssetID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) } - m.FirstBridgedAssetID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4780,16 +2770,29 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.FirstBridgedAssetID |= uint64(b&0x7F) << shift + 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 != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SecondBridgedAssetID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountIn", wireType) } - m.SecondBridgedAssetID = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4799,16 +2802,30 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SecondBridgedAssetID |= uint64(b&0x7F) << shift + 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 CPoolName", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LendingTime", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4818,29 +2835,30 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthLend } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthLend } if postIndex > l { return io.ErrUnexpectedEOF } - m.CPoolName = string(dAtA[iNdEx:postIndex]) + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LendingTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReserveFunds", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailableToBorrow", wireType) } - m.ReserveFunds = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4850,16 +2868,31 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.ReserveFunds |= uint64(b&0x7F) << shift + 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 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetData", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AppID", wireType) } - var msglen int + m.AppID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4869,81 +2902,50 @@ func (m *Pool) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.AppID |= uint64(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, AssetDataPoolMapping{}) - 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 + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GlobalIndex", wireType) } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AssetDataPoolMapping) 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 + 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 + } } - if iNdEx >= l { + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.GlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AssetDataPoolMapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AssetDataPoolMapping: 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) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) } - m.AssetID = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -4953,16 +2955,30 @@ func (m *AssetDataPoolMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetID |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsBridged", wireType) + if msglen < 0 { + return ErrInvalidLengthLend } - var v int + 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 11: + 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 @@ -4972,12 +2988,24 @@ func (m *AssetDataPoolMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsBridged = bool(v != 0) + 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:]) @@ -4999,7 +3027,7 @@ func (m *AssetDataPoolMapping) Unmarshal(dAtA []byte) error { } return nil } -func (m *Extended_Pair) Unmarshal(dAtA []byte) error { +func (m *BorrowAsset) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5022,17 +3050,17 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Extended_Pair: wiretype end group for non-group") + return fmt.Errorf("proto: BorrowAsset: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Extended_Pair: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: BorrowAsset: 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) + return fmt.Errorf("proto: wrong wireType = %d for field ID", wireType) } - m.Id = 0 + m.ID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5042,16 +3070,16 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Id |= uint64(b&0x7F) << shift + m.ID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetIn", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LendingID", wireType) } - m.AssetIn = 0 + m.LendingID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5061,16 +3089,16 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetIn |= uint64(b&0x7F) << shift + m.LendingID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetOut", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IsStableBorrow", wireType) } - m.AssetOut = 0 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5080,16 +3108,17 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetOut |= uint64(b&0x7F) << shift + 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 IsInterPool", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) } - var v int + m.PairID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5099,17 +3128,16 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - v |= int(b&0x7F) << shift + m.PairID |= uint64(b&0x7F) << shift if b < 0x80 { break } } - m.IsInterPool = bool(v != 0) case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetOutPoolID", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountIn", wireType) } - m.AssetOutPoolID = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5119,16 +3147,30 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetOutPoolID |= uint64(b&0x7F) << shift + 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 != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MinUsdValueLeft", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AmountOut", wireType) } - m.MinUsdValueLeft = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5138,66 +3180,63 @@ func (m *Extended_Pair) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MinUsdValueLeft |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { - return err + if msglen < 0 { + return ErrInvalidLengthLend } - if (skippy < 0) || (iNdEx+skippy) < 0 { + postIndex := iNdEx + msglen + if postIndex < 0 { return ErrInvalidLengthLend } - if (iNdEx + skippy) > l { + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *AssetToPairMapping) 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 err := m.AmountOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if iNdEx >= l { + 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.BridgedAssetAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: AssetToPairMapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: AssetToPairMapping: 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) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowingTime", wireType) } - m.AssetID = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5207,16 +3246,30 @@ func (m *AssetToPairMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetID |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + if msglen < 0 { + return ErrInvalidLengthLend } - m.PoolID = 0 + 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 @@ -5226,140 +3279,29 @@ func (m *AssetToPairMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 3: - 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.PairID = append(m.PairID, 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.PairID) == 0 { - m.PairID = 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.PairID = append(m.PairID, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthLend } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UserLendIdMapping) 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 + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.StableBorrowRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: UserLendIdMapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UserLendIdMapping: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field InterestAccumulated", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5387,137 +3329,47 @@ func (m *UserLendIdMapping) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Owner = string(dAtA[iNdEx:postIndex]) + if err := m.InterestAccumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: - 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.LendIDs = append(m.LendIDs, 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 + 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 postIndex > l { + if iNdEx >= 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.LendIDs) == 0 { - m.LendIDs = 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.LendIDs = append(m.LendIDs, v) + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field LendIDs", wireType) } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthLend } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LendIdByOwnerAndPoolMapping) 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 + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthLend } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if postIndex > l { + return io.ErrUnexpectedEOF } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LendIdByOwnerAndPoolMapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LendIdByOwnerAndPoolMapping: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + 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 Owner", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReserveGlobalIndex", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5545,13 +3397,15 @@ func (m *LendIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Owner = string(dAtA[iNdEx:postIndex]) + if err := m.ReserveGlobalIndex.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastInteractionTime", wireType) } - m.PoolID = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5561,87 +3415,77 @@ func (m *LendIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 3: - 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 - } + 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 14: + 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 } - m.LendIDs = append(m.LendIDs, 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 iNdEx >= l { + return io.ErrUnexpectedEOF } - if packedLen < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + } + 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 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsLiquidated", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - if postIndex > l { + if iNdEx >= 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.LendIDs) == 0 { - m.LendIDs = 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.LendIDs = append(m.LendIDs, v) + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field LendIDs", wireType) } + m.IsLiquidated = bool(v != 0) default: iNdEx = preIndex skippy, err := skipLend(dAtA[iNdEx:]) @@ -5663,7 +3507,7 @@ func (m *LendIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { } return nil } -func (m *BorrowIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { +func (m *Pool) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5686,15 +3530,34 @@ func (m *BorrowIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BorrowIdByOwnerAndPoolMapping: wiretype end group for non-group") + return fmt.Errorf("proto: Pool: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BorrowIdByOwnerAndPoolMapping: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Pool: 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 Owner", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ModuleName", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -5722,13 +3585,13 @@ func (m *BorrowIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Owner = string(dAtA[iNdEx:postIndex]) + m.ModuleName = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CPoolName", wireType) } - m.PoolID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -5738,87 +3601,77 @@ func (m *BorrowIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 3: - 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 - } + 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 4: + 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 } - m.BorrowIDs = append(m.BorrowIDs, 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 iNdEx >= l { + return io.ErrUnexpectedEOF } - if packedLen < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + m.ReserveFunds |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + } + case 5: + 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 postIndex > l { + if iNdEx >= 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.BorrowIDs) == 0 { - m.BorrowIDs = 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.BorrowIDs = append(m.BorrowIDs, v) + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowIDs", wireType) } + if msglen < 0 { + return ErrInvalidLengthLend + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthLend + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AssetData = append(m.AssetData, &AssetDataPoolMapping{}) + 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:]) @@ -5840,7 +3693,7 @@ func (m *BorrowIdByOwnerAndPoolMapping) Unmarshal(dAtA []byte) error { } return nil } -func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { +func (m *UserAssetLendBorrowMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5863,10 +3716,10 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserBorrowIdMapping: wiretype end group for non-group") + return fmt.Errorf("proto: UserAssetLendBorrowMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserBorrowIdMapping: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UserAssetLendBorrowMapping: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5902,6 +3755,44 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { m.Owner = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field LendId", wireType) + } + m.LendId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.LendId |= 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 == 0 { var v uint64 for shift := uint(0); ; shift += 7 { @@ -5918,7 +3809,7 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { break } } - m.BorrowIDs = append(m.BorrowIDs, v) + m.BorrowId = append(m.BorrowId, v) } else if wireType == 2 { var packedLen int for shift := uint(0); ; shift += 7 { @@ -5953,8 +3844,8 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { } } elementCount = count - if elementCount != 0 && len(m.BorrowIDs) == 0 { - m.BorrowIDs = make([]uint64, 0, elementCount) + if elementCount != 0 && len(m.BorrowId) == 0 { + m.BorrowId = make([]uint64, 0, elementCount) } for iNdEx < postIndex { var v uint64 @@ -5972,10 +3863,10 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { break } } - m.BorrowIDs = append(m.BorrowIDs, v) + m.BorrowId = append(m.BorrowId, v) } } else { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowIDs", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BorrowId", wireType) } default: iNdEx = preIndex @@ -5998,7 +3889,7 @@ func (m *UserBorrowIdMapping) Unmarshal(dAtA []byte) error { } return nil } -func (m *LendIdToBorrowIdMapping) Unmarshal(dAtA []byte) error { +func (m *AssetDataPoolMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6021,17 +3912,17 @@ func (m *LendIdToBorrowIdMapping) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LendIdToBorrowIdMapping: wiretype end group for non-group") + return fmt.Errorf("proto: AssetDataPoolMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LendIdToBorrowIdMapping: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AssetDataPoolMapping: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field LendingID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } - m.LendingID = 0 + m.AssetID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6041,86 +3932,48 @@ func (m *LendIdToBorrowIdMapping) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.LendingID |= uint64(b&0x7F) << shift + m.AssetID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - 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 - } + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetTransitType", wireType) + } + m.AssetTransitType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - m.BorrowingID = append(m.BorrowingID, 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 iNdEx >= l { + return io.ErrUnexpectedEOF } - if packedLen < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + m.AssetTransitType |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SupplyCap", wireType) + } + m.SupplyCap = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - if postIndex > l { + if iNdEx >= 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.BorrowingID) == 0 { - m.BorrowingID = 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.BorrowingID = append(m.BorrowingID, v) + b := dAtA[iNdEx] + iNdEx++ + m.SupplyCap |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowingID", wireType) } default: iNdEx = preIndex @@ -6143,7 +3996,7 @@ func (m *LendIdToBorrowIdMapping) Unmarshal(dAtA []byte) error { } return nil } -func (m *AssetStats) Unmarshal(dAtA []byte) error { +func (m *Extended_Pair) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6166,89 +4019,17 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AssetStats: wiretype end group for non-group") + return fmt.Errorf("proto: Extended_Pair: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AssetStats: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Extended_Pair: 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 != 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 != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalBorrowed", 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.TotalBorrowed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalStableBorrowed", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var stringLen uint64 + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6258,31 +4039,16 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.Id |= 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.TotalStableBorrowed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TotalLend", wireType) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetIn", wireType) } - var stringLen uint64 + m.AssetIn = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6292,31 +4058,16 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetIn |= 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.TotalLend.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LendApr", wireType) + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetOut", wireType) } - var stringLen uint64 + m.AssetOut = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6326,31 +4077,16 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetOut |= 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.LendApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowApr", wireType) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsInterPool", wireType) } - var stringLen uint64 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6360,31 +4096,17 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + v |= int(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.BorrowApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableBorrowApr", wireType) + m.IsInterPool = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetOutPoolID", wireType) } - var stringLen uint64 + m.AssetOutPoolID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6394,31 +4116,16 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetOutPoolID |= 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.StableBorrowApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UtilisationRatio", wireType) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinUsdValueLeft", wireType) } - var stringLen uint64 + m.MinUsdValueLeft = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6428,26 +4135,11 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.MinUsdValueLeft |= 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.UtilisationRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipLend(dAtA[iNdEx:]) @@ -6469,7 +4161,7 @@ func (m *AssetStats) Unmarshal(dAtA []byte) error { } return nil } -func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { +func (m *AssetToPairMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6492,17 +4184,17 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AssetRatesStats: wiretype end group for non-group") + return fmt.Errorf("proto: AssetToPairMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AssetRatesStats: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AssetToPairMapping: 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) + return fmt.Errorf("proto: wrong wireType = %d for field PoolID", wireType) } - m.AssetID = 0 + m.PoolID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6512,16 +4204,16 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetID |= uint64(b&0x7F) << shift + m.PoolID |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UOptimal", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } - var stringLen uint64 + m.AssetID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6531,65 +4223,142 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetID |= 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.UOptimal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend + 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 + } } - if iNdEx >= l { + m.PairID = append(m.PairID, 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 } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.PairID) == 0 { + m.PairID = 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.PairID = append(m.PairID, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PairID", wireType) } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthLend + default: + iNdEx = preIndex + skippy, err := skipLend(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthLend } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - if err := m.Base.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PoolAssetLBMapping) 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 } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Slope1", wireType) + if iNdEx >= l { + return io.ErrUnexpectedEOF } - var stringLen uint64 + 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: PoolAssetLBMapping: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PoolAssetLBMapping: 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 @@ -6599,31 +4368,16 @@ func (m *AssetRatesStats) 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 ErrInvalidLengthLend - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthLend - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Slope1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Slope2", wireType) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetID", wireType) } - var stringLen uint64 + m.AssetID = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -6633,49 +4387,166 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.AssetID |= 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.Slope2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EnableStableBorrow", wireType) + case 3: + 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.LendIds = append(m.LendIds, 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.LendIds) == 0 { + m.LendIds = 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.LendIds = append(m.LendIds, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field LendIds", wireType) } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend + case 4: + 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 + } } - if iNdEx >= l { + m.BorrowIds = append(m.BorrowIds, 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 } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.BorrowIds) == 0 { + m.BorrowIds = 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.BorrowIds = append(m.BorrowIds, v) } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field BorrowIds", wireType) } - m.EnableStableBorrow = bool(v != 0) - case 7: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableBase", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalBorrowed", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6703,13 +4574,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StableBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalBorrowed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 8: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableSlope1", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalStableBorrowed", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6737,13 +4608,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StableSlope1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalStableBorrowed.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 9: + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableSlope2", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalLend", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6771,13 +4642,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StableSlope2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalLend.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 10: + case 8: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ltv", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TotalInterestAccumulated", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6805,13 +4676,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Ltv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TotalInterestAccumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 11: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationThreshold", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field LendApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6839,13 +4710,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.LiquidationThreshold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.LendApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 12: + case 10: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPenalty", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BorrowApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6873,13 +4744,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.LiquidationPenalty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BorrowApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 13: + case 11: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidationBonus", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StableBorrowApr", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6907,13 +4778,13 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.LiquidationBonus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.StableBorrowApr.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 14: + case 12: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReserveFactor", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field UtilisationRatio", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6941,29 +4812,10 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ReserveFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.UtilisationRatio.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 15: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CAssetID", wireType) - } - m.CAssetID = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowLend - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CAssetID |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipLend(dAtA[iNdEx:]) @@ -6985,7 +4837,7 @@ func (m *AssetRatesStats) Unmarshal(dAtA []byte) error { } return nil } -func (m *LendMapping) Unmarshal(dAtA []byte) error { +func (m *AssetRatesParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7008,395 +4860,396 @@ func (m *LendMapping) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: LendMapping: wiretype end group for non-group") + return fmt.Errorf("proto: AssetRatesParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: LendMapping: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: AssetRatesParams: 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 - } + 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 } - m.LendIDs = append(m.LendIDs, 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 iNdEx >= l { + return io.ErrUnexpectedEOF } - if packedLen < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + m.AssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UOptimal", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - if postIndex > l { + if iNdEx >= l { return io.ErrUnexpectedEOF } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - elementCount = count - if elementCount != 0 && len(m.LendIDs) == 0 { - m.LendIDs = make([]uint64, 0, elementCount) + } + 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.UOptimal.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Base", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - 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.LendIDs = append(m.LendIDs, v) + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field LendIDs", wireType) } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { + 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.Base.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slope1", 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.Slope1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - if (skippy < 0) || (iNdEx+skippy) < 0 { + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slope2", 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 (iNdEx + skippy) > l { + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *BorrowMapping) 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 + if err := m.Slope2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EnableStableBorrow", wireType) } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: BorrowMapping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BorrowMapping: 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 - } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - m.BorrowIDs = append(m.BorrowIDs, 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 iNdEx >= l { + return io.ErrUnexpectedEOF } - if packedLen < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + } + m.EnableStableBorrow = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StableBase", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - if postIndex > l { + if iNdEx >= 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.BorrowIDs) == 0 { - m.BorrowIDs = 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.BorrowIDs = append(m.BorrowIDs, v) + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowIDs", wireType) } - default: - iNdEx = preIndex - skippy, err := skipLend(dAtA[iNdEx:]) - if err != nil { - return err + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend } - if (skippy < 0) || (iNdEx+skippy) < 0 { + postIndex := iNdEx + intStringLen + if postIndex < 0 { return ErrInvalidLengthLend } - if (iNdEx + skippy) > l { + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *StableBorrowMapping) 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 err := m.StableBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if iNdEx >= l { + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StableSlope1", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.StableSlope1.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: StableBorrowMapping: 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 - } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StableSlope2", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - if packedLen < 0 { - return ErrInvalidLengthLend + if iNdEx >= l { + return io.ErrUnexpectedEOF } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthLend + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - if postIndex > l { + } + 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.StableSlope2.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ltv", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - elementCount = count - if elementCount != 0 && len(m.StableBorrowIDs) == 0 { - m.StableBorrowIDs = make([]uint64, 0, elementCount) + } + 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.Ltv.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationThreshold", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend } - 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) + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - } 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 + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthLend } - if (skippy < 0) || (iNdEx+skippy) < 0 { + postIndex := iNdEx + intStringLen + if postIndex < 0 { return ErrInvalidLengthLend } - if (iNdEx + skippy) > l { + if postIndex > l { return io.ErrUnexpectedEOF } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - 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 err := m.LiquidationThreshold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - if iNdEx >= l { + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationPenalty", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := m.LiquidationPenalty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err } - } - 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) + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidationBonus", wireType) } - m.PoolID = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -7406,16 +5259,31 @@ func (m *ModuleBalance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolID |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 2: + 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.LiquidationBonus.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 14: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ModuleBalanceStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReserveFactor", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -7425,26 +5293,45 @@ func (m *ModuleBalance) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthLend } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen 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 { + if err := m.ReserveFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CAssetID", wireType) + } + m.CAssetID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowLend + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CAssetID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipLend(dAtA[iNdEx:]) @@ -7466,7 +5353,7 @@ func (m *ModuleBalance) Unmarshal(dAtA []byte) error { } return nil } -func (m *ModuleBalanceStats) Unmarshal(dAtA []byte) error { +func (m *StableBorrowMapping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7489,64 +5376,88 @@ func (m *ModuleBalanceStats) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ModuleBalanceStats: wiretype end group for non-group") + return fmt.Errorf("proto: StableBorrowMapping: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ModuleBalanceStats: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: StableBorrowMapping: 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 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 + } } - if iNdEx >= l { - return io.ErrUnexpectedEOF + 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 + } } - b := dAtA[iNdEx] - iNdEx++ - m.AssetID |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if packedLen < 0 { + return ErrInvalidLengthLend } - } - 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 + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthLend } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break + 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) } - 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:]) @@ -7568,7 +5479,7 @@ func (m *ModuleBalanceStats) Unmarshal(dAtA []byte) error { } return nil } -func (m *BalanceStats) Unmarshal(dAtA []byte) error { +func (m *ReserveBuybackAssetData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7591,10 +5502,10 @@ func (m *BalanceStats) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: BalanceStats: wiretype end group for non-group") + return fmt.Errorf("proto: ReserveBuybackAssetData: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: BalanceStats: 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: @@ -7618,7 +5529,7 @@ func (m *BalanceStats) Unmarshal(dAtA []byte) error { } case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReserveAmount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -7646,65 +5557,15 @@ func (m *BalanceStats) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ReserveAmount.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 *DepositStats) 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: DepositStats: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DepositStats: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BalanceStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field BuybackAmount", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowLend @@ -7714,23 +5575,23 @@ func (m *DepositStats) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthLend } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthLend } if postIndex > l { return io.ErrUnexpectedEOF } - m.BalanceStats = append(m.BalanceStats, BalanceStats{}) - if err := m.BalanceStats[len(m.BalanceStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.BuybackAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8002,109 +5863,6 @@ func (m *AuctionParams) Unmarshal(dAtA []byte) error { } return nil } -func (m *ReservePoolRecordsForBorrow) 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: ReservePoolRecordsForBorrow: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ReservePoolRecordsForBorrow: 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 != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InterestAccumulated", 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.InterestAccumulated.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 *BorrowInterestTracker) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -8153,9 +5911,9 @@ func (m *BorrowInterestTracker) Unmarshal(dAtA []byte) error { break } } - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InterestAccumulated", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReservePoolInterest", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -8183,7 +5941,7 @@ func (m *BorrowInterestTracker) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.InterestAccumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ReservePoolInterest.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lend/types/pair.go b/x/lend/types/pair.go index 3217b4f35..81a5ca865 100644 --- a/x/lend/types/pair.go +++ b/x/lend/types/pair.go @@ -26,6 +26,6 @@ func (m *AssetToPairMapping) Validate() error { return nil } -func (m *AssetRatesStats) Validate() error { +func (m *AssetRatesParams) Validate() error { return nil } diff --git a/x/lend/types/query.pb.go b/x/lend/types/query.pb.go index ccf99b5a6..1ef06e90b 100644 --- a/x/lend/types/query.pb.go +++ b/x/lend/types/query.pb.go @@ -557,22 +557,22 @@ func (m *QueryPairResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryPairResponse proto.InternalMessageInfo -type QueryAssetRatesStatsRequest struct { +type QueryAssetRatesParamsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` } -func (m *QueryAssetRatesStatsRequest) Reset() { *m = QueryAssetRatesStatsRequest{} } -func (m *QueryAssetRatesStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAssetRatesStatsRequest) ProtoMessage() {} -func (*QueryAssetRatesStatsRequest) Descriptor() ([]byte, []int) { +func (m *QueryAssetRatesParamsRequest) Reset() { *m = QueryAssetRatesParamsRequest{} } +func (m *QueryAssetRatesParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAssetRatesParamsRequest) ProtoMessage() {} +func (*QueryAssetRatesParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{14} } -func (m *QueryAssetRatesStatsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryAssetRatesParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetRatesStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAssetRatesParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetRatesStatsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAssetRatesParamsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -582,35 +582,35 @@ func (m *QueryAssetRatesStatsRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryAssetRatesStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetRatesStatsRequest.Merge(m, src) +func (m *QueryAssetRatesParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetRatesParamsRequest.Merge(m, src) } -func (m *QueryAssetRatesStatsRequest) XXX_Size() int { +func (m *QueryAssetRatesParamsRequest) XXX_Size() int { return m.Size() } -func (m *QueryAssetRatesStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetRatesStatsRequest.DiscardUnknown(m) +func (m *QueryAssetRatesParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetRatesParamsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetRatesStatsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryAssetRatesParamsRequest proto.InternalMessageInfo -type QueryAssetRatesStatsResponse struct { - AssetRatesStats []AssetRatesStats `protobuf:"bytes,1,rep,name=AssetRatesStats,proto3" json:"AssetRatesStats" yaml:"asset_rates_stats"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` +type QueryAssetRatesParamsResponse struct { + AssetRatesParams []AssetRatesParams `protobuf:"bytes,1,rep,name=AssetRatesParams,proto3" json:"AssetRatesParams" yaml:"asset_rates_params"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` } -func (m *QueryAssetRatesStatsResponse) Reset() { *m = QueryAssetRatesStatsResponse{} } -func (m *QueryAssetRatesStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAssetRatesStatsResponse) ProtoMessage() {} -func (*QueryAssetRatesStatsResponse) Descriptor() ([]byte, []int) { +func (m *QueryAssetRatesParamsResponse) Reset() { *m = QueryAssetRatesParamsResponse{} } +func (m *QueryAssetRatesParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAssetRatesParamsResponse) ProtoMessage() {} +func (*QueryAssetRatesParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{15} } -func (m *QueryAssetRatesStatsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryAssetRatesParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetRatesStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAssetRatesParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetRatesStatsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAssetRatesParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -620,34 +620,34 @@ func (m *QueryAssetRatesStatsResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryAssetRatesStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetRatesStatsResponse.Merge(m, src) +func (m *QueryAssetRatesParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetRatesParamsResponse.Merge(m, src) } -func (m *QueryAssetRatesStatsResponse) XXX_Size() int { +func (m *QueryAssetRatesParamsResponse) XXX_Size() int { return m.Size() } -func (m *QueryAssetRatesStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetRatesStatsResponse.DiscardUnknown(m) +func (m *QueryAssetRatesParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetRatesParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetRatesStatsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryAssetRatesParamsResponse proto.InternalMessageInfo -type QueryAssetRatesStatRequest struct { +type QueryAssetRatesParamRequest struct { Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` } -func (m *QueryAssetRatesStatRequest) Reset() { *m = QueryAssetRatesStatRequest{} } -func (m *QueryAssetRatesStatRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAssetRatesStatRequest) ProtoMessage() {} -func (*QueryAssetRatesStatRequest) Descriptor() ([]byte, []int) { +func (m *QueryAssetRatesParamRequest) Reset() { *m = QueryAssetRatesParamRequest{} } +func (m *QueryAssetRatesParamRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAssetRatesParamRequest) ProtoMessage() {} +func (*QueryAssetRatesParamRequest) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{16} } -func (m *QueryAssetRatesStatRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryAssetRatesParamRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetRatesStatRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAssetRatesParamRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetRatesStatRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAssetRatesParamRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -657,34 +657,34 @@ func (m *QueryAssetRatesStatRequest) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryAssetRatesStatRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetRatesStatRequest.Merge(m, src) +func (m *QueryAssetRatesParamRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetRatesParamRequest.Merge(m, src) } -func (m *QueryAssetRatesStatRequest) XXX_Size() int { +func (m *QueryAssetRatesParamRequest) XXX_Size() int { return m.Size() } -func (m *QueryAssetRatesStatRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetRatesStatRequest.DiscardUnknown(m) +func (m *QueryAssetRatesParamRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetRatesParamRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetRatesStatRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryAssetRatesParamRequest proto.InternalMessageInfo -type QueryAssetRatesStatResponse struct { - AssetRatesStat AssetRatesStats `protobuf:"bytes,1,opt,name=AssetRatesStat,proto3" json:"AssetRatesStat" yaml:"asset_rates_stat"` +type QueryAssetRatesParamResponse struct { + AssetRatesparams AssetRatesParams `protobuf:"bytes,1,opt,name=AssetRatesparams,proto3" json:"AssetRatesparams" yaml:"asset_rates_params"` } -func (m *QueryAssetRatesStatResponse) Reset() { *m = QueryAssetRatesStatResponse{} } -func (m *QueryAssetRatesStatResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAssetRatesStatResponse) ProtoMessage() {} -func (*QueryAssetRatesStatResponse) Descriptor() ([]byte, []int) { +func (m *QueryAssetRatesParamResponse) Reset() { *m = QueryAssetRatesParamResponse{} } +func (m *QueryAssetRatesParamResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAssetRatesParamResponse) ProtoMessage() {} +func (*QueryAssetRatesParamResponse) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{17} } -func (m *QueryAssetRatesStatResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryAssetRatesParamResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetRatesStatResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryAssetRatesParamResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetRatesStatResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryAssetRatesParamResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -694,17 +694,17 @@ func (m *QueryAssetRatesStatResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryAssetRatesStatResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetRatesStatResponse.Merge(m, src) +func (m *QueryAssetRatesParamResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAssetRatesParamResponse.Merge(m, src) } -func (m *QueryAssetRatesStatResponse) XXX_Size() int { +func (m *QueryAssetRatesParamResponse) XXX_Size() int { return m.Size() } -func (m *QueryAssetRatesStatResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetRatesStatResponse.DiscardUnknown(m) +func (m *QueryAssetRatesParamResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAssetRatesParamResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetRatesStatResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryAssetRatesParamResponse proto.InternalMessageInfo type QueryPoolsRequest struct { Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty" yaml:"pagination"` @@ -1307,23 +1307,23 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllBorrowByOwnerAndPoolResponse proto.InternalMessageInfo -type QueryAssetStatsRequest struct { +type QueryPoolAssetLBMappingRequest struct { AssetId uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` } -func (m *QueryAssetStatsRequest) Reset() { *m = QueryAssetStatsRequest{} } -func (m *QueryAssetStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAssetStatsRequest) ProtoMessage() {} -func (*QueryAssetStatsRequest) Descriptor() ([]byte, []int) { +func (m *QueryPoolAssetLBMappingRequest) Reset() { *m = QueryPoolAssetLBMappingRequest{} } +func (m *QueryPoolAssetLBMappingRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPoolAssetLBMappingRequest) ProtoMessage() {} +func (*QueryPoolAssetLBMappingRequest) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{34} } -func (m *QueryAssetStatsRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPoolAssetLBMappingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPoolAssetLBMappingRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetStatsRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPoolAssetLBMappingRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1333,34 +1333,34 @@ func (m *QueryAssetStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *QueryAssetStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetStatsRequest.Merge(m, src) +func (m *QueryPoolAssetLBMappingRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolAssetLBMappingRequest.Merge(m, src) } -func (m *QueryAssetStatsRequest) XXX_Size() int { +func (m *QueryPoolAssetLBMappingRequest) XXX_Size() int { return m.Size() } -func (m *QueryAssetStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetStatsRequest.DiscardUnknown(m) +func (m *QueryPoolAssetLBMappingRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolAssetLBMappingRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetStatsRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPoolAssetLBMappingRequest proto.InternalMessageInfo -type QueryAssetStatsResponse struct { - AssetStats AssetStats `protobuf:"bytes,1,opt,name=AssetStats,proto3" json:"AssetStats" yaml:"asset_stats"` +type QueryPoolAssetLBMappingResponse struct { + PoolAssetLBMapping PoolAssetLBMapping `protobuf:"bytes,1,opt,name=PoolAssetLBMapping,proto3" json:"PoolAssetLBMapping" yaml:"pool_asset_lb_mapping"` } -func (m *QueryAssetStatsResponse) Reset() { *m = QueryAssetStatsResponse{} } -func (m *QueryAssetStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAssetStatsResponse) ProtoMessage() {} -func (*QueryAssetStatsResponse) Descriptor() ([]byte, []int) { +func (m *QueryPoolAssetLBMappingResponse) Reset() { *m = QueryPoolAssetLBMappingResponse{} } +func (m *QueryPoolAssetLBMappingResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPoolAssetLBMappingResponse) ProtoMessage() {} +func (*QueryPoolAssetLBMappingResponse) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{35} } -func (m *QueryAssetStatsResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPoolAssetLBMappingResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryAssetStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPoolAssetLBMappingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryAssetStatsResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPoolAssetLBMappingResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1370,34 +1370,34 @@ func (m *QueryAssetStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *QueryAssetStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAssetStatsResponse.Merge(m, src) +func (m *QueryPoolAssetLBMappingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPoolAssetLBMappingResponse.Merge(m, src) } -func (m *QueryAssetStatsResponse) XXX_Size() int { +func (m *QueryPoolAssetLBMappingResponse) XXX_Size() int { return m.Size() } -func (m *QueryAssetStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAssetStatsResponse.DiscardUnknown(m) +func (m *QueryPoolAssetLBMappingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPoolAssetLBMappingResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryAssetStatsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPoolAssetLBMappingResponse proto.InternalMessageInfo -type QueryModuleBalanceRequest struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` +type QueryReserveBuybackAssetDataRequest struct { + AssetId uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty"` } -func (m *QueryModuleBalanceRequest) Reset() { *m = QueryModuleBalanceRequest{} } -func (m *QueryModuleBalanceRequest) String() string { return proto.CompactTextString(m) } -func (*QueryModuleBalanceRequest) ProtoMessage() {} -func (*QueryModuleBalanceRequest) Descriptor() ([]byte, []int) { +func (m *QueryReserveBuybackAssetDataRequest) Reset() { *m = QueryReserveBuybackAssetDataRequest{} } +func (m *QueryReserveBuybackAssetDataRequest) String() string { return proto.CompactTextString(m) } +func (*QueryReserveBuybackAssetDataRequest) ProtoMessage() {} +func (*QueryReserveBuybackAssetDataRequest) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{36} } -func (m *QueryModuleBalanceRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryReserveBuybackAssetDataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryModuleBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryReserveBuybackAssetDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryModuleBalanceRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryReserveBuybackAssetDataRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1407,34 +1407,34 @@ func (m *QueryModuleBalanceRequest) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *QueryModuleBalanceRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryModuleBalanceRequest.Merge(m, src) +func (m *QueryReserveBuybackAssetDataRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryReserveBuybackAssetDataRequest.Merge(m, src) } -func (m *QueryModuleBalanceRequest) XXX_Size() int { +func (m *QueryReserveBuybackAssetDataRequest) XXX_Size() int { return m.Size() } -func (m *QueryModuleBalanceRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryModuleBalanceRequest.DiscardUnknown(m) +func (m *QueryReserveBuybackAssetDataRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryReserveBuybackAssetDataRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryModuleBalanceRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryReserveBuybackAssetDataRequest proto.InternalMessageInfo -type QueryModuleBalanceResponse struct { - ModuleBalance ModuleBalance `protobuf:"bytes,1,opt,name=ModuleBalance,proto3" json:"ModuleBalance" yaml:"module_balance"` +type QueryReserveBuybackAssetDataResponse struct { + ReserveBuybackAssetData ReserveBuybackAssetData `protobuf:"bytes,1,opt,name=ReserveBuybackAssetData,proto3" json:"ReserveBuybackAssetData" yaml:"reserve_buyback_asset_data"` } -func (m *QueryModuleBalanceResponse) Reset() { *m = QueryModuleBalanceResponse{} } -func (m *QueryModuleBalanceResponse) String() string { return proto.CompactTextString(m) } -func (*QueryModuleBalanceResponse) ProtoMessage() {} -func (*QueryModuleBalanceResponse) Descriptor() ([]byte, []int) { +func (m *QueryReserveBuybackAssetDataResponse) Reset() { *m = QueryReserveBuybackAssetDataResponse{} } +func (m *QueryReserveBuybackAssetDataResponse) String() string { return proto.CompactTextString(m) } +func (*QueryReserveBuybackAssetDataResponse) ProtoMessage() {} +func (*QueryReserveBuybackAssetDataResponse) Descriptor() ([]byte, []int) { return fileDescriptor_462bf3f1a3eff175, []int{37} } -func (m *QueryModuleBalanceResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryReserveBuybackAssetDataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryModuleBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryReserveBuybackAssetDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryModuleBalanceResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryReserveBuybackAssetDataResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1444,382 +1444,17 @@ func (m *QueryModuleBalanceResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *QueryModuleBalanceResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryModuleBalanceResponse.Merge(m, src) +func (m *QueryReserveBuybackAssetDataResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryReserveBuybackAssetDataResponse.Merge(m, src) } -func (m *QueryModuleBalanceResponse) XXX_Size() int { +func (m *QueryReserveBuybackAssetDataResponse) XXX_Size() int { return m.Size() } -func (m *QueryModuleBalanceResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryModuleBalanceResponse.DiscardUnknown(m) +func (m *QueryReserveBuybackAssetDataResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryReserveBuybackAssetDataResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryModuleBalanceResponse proto.InternalMessageInfo - -type QueryDepositStatsRequest struct { -} - -func (m *QueryDepositStatsRequest) Reset() { *m = QueryDepositStatsRequest{} } -func (m *QueryDepositStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryDepositStatsRequest) ProtoMessage() {} -func (*QueryDepositStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{38} -} -func (m *QueryDepositStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDepositStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDepositStatsRequest.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 *QueryDepositStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDepositStatsRequest.Merge(m, src) -} -func (m *QueryDepositStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryDepositStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDepositStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDepositStatsRequest proto.InternalMessageInfo - -type QueryDepositStatsResponse struct { - DepositStats DepositStats `protobuf:"bytes,1,opt,name=DepositStats,proto3" json:"DepositStats" yaml:"deposit_stats"` -} - -func (m *QueryDepositStatsResponse) Reset() { *m = QueryDepositStatsResponse{} } -func (m *QueryDepositStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryDepositStatsResponse) ProtoMessage() {} -func (*QueryDepositStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{39} -} -func (m *QueryDepositStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryDepositStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryDepositStatsResponse.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 *QueryDepositStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryDepositStatsResponse.Merge(m, src) -} -func (m *QueryDepositStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryDepositStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryDepositStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryDepositStatsResponse proto.InternalMessageInfo - -type QueryUserDepositStatsRequest struct { -} - -func (m *QueryUserDepositStatsRequest) Reset() { *m = QueryUserDepositStatsRequest{} } -func (m *QueryUserDepositStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryUserDepositStatsRequest) ProtoMessage() {} -func (*QueryUserDepositStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{40} -} -func (m *QueryUserDepositStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUserDepositStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUserDepositStatsRequest.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 *QueryUserDepositStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUserDepositStatsRequest.Merge(m, src) -} -func (m *QueryUserDepositStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryUserDepositStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUserDepositStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUserDepositStatsRequest proto.InternalMessageInfo - -type QueryUserDepositStatsResponse struct { - UserDepositStats DepositStats `protobuf:"bytes,1,opt,name=UserDepositStats,proto3" json:"UserDepositStats" yaml:"user_deposit_stats"` -} - -func (m *QueryUserDepositStatsResponse) Reset() { *m = QueryUserDepositStatsResponse{} } -func (m *QueryUserDepositStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryUserDepositStatsResponse) ProtoMessage() {} -func (*QueryUserDepositStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{41} -} -func (m *QueryUserDepositStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUserDepositStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUserDepositStatsResponse.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 *QueryUserDepositStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUserDepositStatsResponse.Merge(m, src) -} -func (m *QueryUserDepositStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryUserDepositStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUserDepositStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUserDepositStatsResponse proto.InternalMessageInfo - -type QueryReserveDepositStatsRequest struct { -} - -func (m *QueryReserveDepositStatsRequest) Reset() { *m = QueryReserveDepositStatsRequest{} } -func (m *QueryReserveDepositStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryReserveDepositStatsRequest) ProtoMessage() {} -func (*QueryReserveDepositStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{42} -} -func (m *QueryReserveDepositStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryReserveDepositStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryReserveDepositStatsRequest.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 *QueryReserveDepositStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryReserveDepositStatsRequest.Merge(m, src) -} -func (m *QueryReserveDepositStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryReserveDepositStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryReserveDepositStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryReserveDepositStatsRequest proto.InternalMessageInfo - -type QueryReserveDepositStatsResponse struct { - ReserveDepositStats DepositStats `protobuf:"bytes,1,opt,name=ReserveDepositStats,proto3" json:"ReserveDepositStats" yaml:"reserve_deposit_stats"` -} - -func (m *QueryReserveDepositStatsResponse) Reset() { *m = QueryReserveDepositStatsResponse{} } -func (m *QueryReserveDepositStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryReserveDepositStatsResponse) ProtoMessage() {} -func (*QueryReserveDepositStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{43} -} -func (m *QueryReserveDepositStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryReserveDepositStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryReserveDepositStatsResponse.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 *QueryReserveDepositStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryReserveDepositStatsResponse.Merge(m, src) -} -func (m *QueryReserveDepositStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryReserveDepositStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryReserveDepositStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryReserveDepositStatsResponse proto.InternalMessageInfo - -type QueryBuyBackDepositStatsRequest struct { -} - -func (m *QueryBuyBackDepositStatsRequest) Reset() { *m = QueryBuyBackDepositStatsRequest{} } -func (m *QueryBuyBackDepositStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBuyBackDepositStatsRequest) ProtoMessage() {} -func (*QueryBuyBackDepositStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{44} -} -func (m *QueryBuyBackDepositStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBuyBackDepositStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBuyBackDepositStatsRequest.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 *QueryBuyBackDepositStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBuyBackDepositStatsRequest.Merge(m, src) -} -func (m *QueryBuyBackDepositStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryBuyBackDepositStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBuyBackDepositStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBuyBackDepositStatsRequest proto.InternalMessageInfo - -type QueryBuyBackDepositStatsResponse struct { - BuyBackDepositStats DepositStats `protobuf:"bytes,1,opt,name=BuyBackDepositStats,proto3" json:"BuyBackDepositStats" yaml:"buy_back_deposit_stats"` -} - -func (m *QueryBuyBackDepositStatsResponse) Reset() { *m = QueryBuyBackDepositStatsResponse{} } -func (m *QueryBuyBackDepositStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBuyBackDepositStatsResponse) ProtoMessage() {} -func (*QueryBuyBackDepositStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{45} -} -func (m *QueryBuyBackDepositStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBuyBackDepositStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBuyBackDepositStatsResponse.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 *QueryBuyBackDepositStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBuyBackDepositStatsResponse.Merge(m, src) -} -func (m *QueryBuyBackDepositStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryBuyBackDepositStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBuyBackDepositStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBuyBackDepositStatsResponse proto.InternalMessageInfo - -type QueryBorrowStatsRequest struct { -} - -func (m *QueryBorrowStatsRequest) Reset() { *m = QueryBorrowStatsRequest{} } -func (m *QueryBorrowStatsRequest) String() string { return proto.CompactTextString(m) } -func (*QueryBorrowStatsRequest) ProtoMessage() {} -func (*QueryBorrowStatsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{46} -} -func (m *QueryBorrowStatsRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBorrowStatsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBorrowStatsRequest.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 *QueryBorrowStatsRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBorrowStatsRequest.Merge(m, src) -} -func (m *QueryBorrowStatsRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryBorrowStatsRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBorrowStatsRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBorrowStatsRequest proto.InternalMessageInfo - -type QueryBorrowStatsResponse struct { - BorrowStats DepositStats `protobuf:"bytes,1,opt,name=BorrowStats,proto3" json:"BorrowStats" yaml:"borrow_stats"` -} - -func (m *QueryBorrowStatsResponse) Reset() { *m = QueryBorrowStatsResponse{} } -func (m *QueryBorrowStatsResponse) String() string { return proto.CompactTextString(m) } -func (*QueryBorrowStatsResponse) ProtoMessage() {} -func (*QueryBorrowStatsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{47} -} -func (m *QueryBorrowStatsResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryBorrowStatsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryBorrowStatsResponse.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 *QueryBorrowStatsResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryBorrowStatsResponse.Merge(m, src) -} -func (m *QueryBorrowStatsResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryBorrowStatsResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryBorrowStatsResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryBorrowStatsResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryReserveBuybackAssetDataResponse proto.InternalMessageInfo type QueryAuctionParamRequest struct { AppId uint64 `protobuf:"varint,1,opt,name=app_id,json=appId,proto3" json:"app_id,omitempty"` @@ -1829,7 +1464,7 @@ func (m *QueryAuctionParamRequest) Reset() { *m = QueryAuctionParamReque func (m *QueryAuctionParamRequest) String() string { return proto.CompactTextString(m) } func (*QueryAuctionParamRequest) ProtoMessage() {} func (*QueryAuctionParamRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{48} + return fileDescriptor_462bf3f1a3eff175, []int{38} } func (m *QueryAuctionParamRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1866,7 +1501,7 @@ func (m *QueryAuctionParamResponse) Reset() { *m = QueryAuctionParamResp func (m *QueryAuctionParamResponse) String() string { return proto.CompactTextString(m) } func (*QueryAuctionParamResponse) ProtoMessage() {} func (*QueryAuctionParamResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_462bf3f1a3eff175, []int{49} + return fileDescriptor_462bf3f1a3eff175, []int{39} } func (m *QueryAuctionParamResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1910,10 +1545,10 @@ func init() { proto.RegisterType((*QueryPairsResponse)(nil), "comdex.lend.v1beta1.QueryPairsResponse") proto.RegisterType((*QueryPairRequest)(nil), "comdex.lend.v1beta1.QueryPairRequest") proto.RegisterType((*QueryPairResponse)(nil), "comdex.lend.v1beta1.QueryPairResponse") - proto.RegisterType((*QueryAssetRatesStatsRequest)(nil), "comdex.lend.v1beta1.QueryAssetRatesStatsRequest") - proto.RegisterType((*QueryAssetRatesStatsResponse)(nil), "comdex.lend.v1beta1.QueryAssetRatesStatsResponse") - proto.RegisterType((*QueryAssetRatesStatRequest)(nil), "comdex.lend.v1beta1.QueryAssetRatesStatRequest") - proto.RegisterType((*QueryAssetRatesStatResponse)(nil), "comdex.lend.v1beta1.QueryAssetRatesStatResponse") + proto.RegisterType((*QueryAssetRatesParamsRequest)(nil), "comdex.lend.v1beta1.QueryAssetRatesParamsRequest") + proto.RegisterType((*QueryAssetRatesParamsResponse)(nil), "comdex.lend.v1beta1.QueryAssetRatesParamsResponse") + proto.RegisterType((*QueryAssetRatesParamRequest)(nil), "comdex.lend.v1beta1.QueryAssetRatesParamRequest") + proto.RegisterType((*QueryAssetRatesParamResponse)(nil), "comdex.lend.v1beta1.QueryAssetRatesParamResponse") proto.RegisterType((*QueryPoolsRequest)(nil), "comdex.lend.v1beta1.QueryPoolsRequest") proto.RegisterType((*QueryPoolsResponse)(nil), "comdex.lend.v1beta1.QueryPoolsResponse") proto.RegisterType((*QueryPoolRequest)(nil), "comdex.lend.v1beta1.QueryPoolRequest") @@ -1930,20 +1565,10 @@ func init() { proto.RegisterType((*QueryAllBorrowByOwnerResponse)(nil), "comdex.lend.v1beta1.QueryAllBorrowByOwnerResponse") proto.RegisterType((*QueryAllBorrowByOwnerAndPoolRequest)(nil), "comdex.lend.v1beta1.QueryAllBorrowByOwnerAndPoolRequest") proto.RegisterType((*QueryAllBorrowByOwnerAndPoolResponse)(nil), "comdex.lend.v1beta1.QueryAllBorrowByOwnerAndPoolResponse") - proto.RegisterType((*QueryAssetStatsRequest)(nil), "comdex.lend.v1beta1.QueryAssetStatsRequest") - proto.RegisterType((*QueryAssetStatsResponse)(nil), "comdex.lend.v1beta1.QueryAssetStatsResponse") - proto.RegisterType((*QueryModuleBalanceRequest)(nil), "comdex.lend.v1beta1.QueryModuleBalanceRequest") - proto.RegisterType((*QueryModuleBalanceResponse)(nil), "comdex.lend.v1beta1.QueryModuleBalanceResponse") - proto.RegisterType((*QueryDepositStatsRequest)(nil), "comdex.lend.v1beta1.QueryDepositStatsRequest") - proto.RegisterType((*QueryDepositStatsResponse)(nil), "comdex.lend.v1beta1.QueryDepositStatsResponse") - proto.RegisterType((*QueryUserDepositStatsRequest)(nil), "comdex.lend.v1beta1.QueryUserDepositStatsRequest") - proto.RegisterType((*QueryUserDepositStatsResponse)(nil), "comdex.lend.v1beta1.QueryUserDepositStatsResponse") - proto.RegisterType((*QueryReserveDepositStatsRequest)(nil), "comdex.lend.v1beta1.QueryReserveDepositStatsRequest") - proto.RegisterType((*QueryReserveDepositStatsResponse)(nil), "comdex.lend.v1beta1.QueryReserveDepositStatsResponse") - proto.RegisterType((*QueryBuyBackDepositStatsRequest)(nil), "comdex.lend.v1beta1.QueryBuyBackDepositStatsRequest") - proto.RegisterType((*QueryBuyBackDepositStatsResponse)(nil), "comdex.lend.v1beta1.QueryBuyBackDepositStatsResponse") - proto.RegisterType((*QueryBorrowStatsRequest)(nil), "comdex.lend.v1beta1.QueryBorrowStatsRequest") - proto.RegisterType((*QueryBorrowStatsResponse)(nil), "comdex.lend.v1beta1.QueryBorrowStatsResponse") + proto.RegisterType((*QueryPoolAssetLBMappingRequest)(nil), "comdex.lend.v1beta1.QueryPoolAssetLBMappingRequest") + proto.RegisterType((*QueryPoolAssetLBMappingResponse)(nil), "comdex.lend.v1beta1.QueryPoolAssetLBMappingResponse") + proto.RegisterType((*QueryReserveBuybackAssetDataRequest)(nil), "comdex.lend.v1beta1.QueryReserveBuybackAssetDataRequest") + proto.RegisterType((*QueryReserveBuybackAssetDataResponse)(nil), "comdex.lend.v1beta1.QueryReserveBuybackAssetDataResponse") proto.RegisterType((*QueryAuctionParamRequest)(nil), "comdex.lend.v1beta1.QueryAuctionParamRequest") proto.RegisterType((*QueryAuctionParamResponse)(nil), "comdex.lend.v1beta1.QueryAuctionParamResponse") } @@ -1951,139 +1576,119 @@ func init() { func init() { proto.RegisterFile("comdex/lend/v1beta1/query.proto", fileDescriptor_462bf3f1a3eff175) } var fileDescriptor_462bf3f1a3eff175 = []byte{ - // 2102 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x5a, 0xed, 0x6f, 0x1c, 0x47, - 0x19, 0xf7, 0xb8, 0xb6, 0x43, 0xc7, 0x6e, 0x92, 0xce, 0xd9, 0x4d, 0xbc, 0xb6, 0xef, 0xec, 0x89, - 0x63, 0x3b, 0x89, 0x7d, 0x5b, 0x3b, 0x0d, 0xa5, 0x55, 0x41, 0x78, 0xd5, 0x88, 0x06, 0x11, 0xd5, - 0x2c, 0x20, 0x24, 0xde, 0x8e, 0xbd, 0xdb, 0xcd, 0x71, 0xea, 0xf9, 0x76, 0x7b, 0x7b, 0x97, 0xf6, - 0x70, 0x2d, 0x95, 0x97, 0x7e, 0x40, 0xf0, 0x01, 0xc4, 0x37, 0x24, 0x2a, 0x24, 0x84, 0x54, 0xa9, - 0x20, 0x3e, 0xf1, 0x29, 0x20, 0xf1, 0x31, 0x42, 0x08, 0x05, 0xe5, 0x03, 0x04, 0x09, 0x0b, 0x1c, - 0xfe, 0x00, 0x94, 0xbf, 0x00, 0xed, 0xcc, 0x33, 0xb7, 0x3b, 0x7b, 0xb3, 0x2f, 0x87, 0xe2, 0x13, - 0xe1, 0x53, 0x2e, 0x3b, 0xcf, 0xcb, 0xef, 0x79, 0x99, 0x67, 0xe6, 0x79, 0xc6, 0xb8, 0x54, 0x73, - 0xf7, 0x6d, 0xe7, 0x6d, 0xbd, 0xe9, 0xb4, 0x6c, 0xfd, 0xf6, 0x76, 0xd5, 0xe9, 0x58, 0xdb, 0xfa, - 0x9b, 0x5d, 0xa7, 0xdd, 0x2b, 0x7b, 0x6d, 0xb7, 0xe3, 0x92, 0x02, 0x27, 0x28, 0x07, 0x04, 0x65, - 0x20, 0xd0, 0x2e, 0xd7, 0x5c, 0x7f, 0xdf, 0xf5, 0xf5, 0xaa, 0xe5, 0x3b, 0x9c, 0xba, 0xcf, 0xeb, - 0x59, 0xf5, 0x46, 0xcb, 0xea, 0x34, 0xdc, 0x16, 0x17, 0xa0, 0xcd, 0xd6, 0xdd, 0xba, 0xcb, 0x7e, - 0xea, 0xc1, 0x2f, 0xf8, 0xba, 0x58, 0x77, 0xdd, 0x7a, 0xd3, 0xd1, 0x2d, 0xaf, 0xa1, 0x5b, 0xad, - 0x96, 0xdb, 0x61, 0x2c, 0x3e, 0xac, 0x16, 0x55, 0xa8, 0x18, 0x02, 0xbe, 0xbe, 0xac, 0x5a, 0xf7, - 0xac, 0xb6, 0xb5, 0x0f, 0x12, 0xe8, 0x2c, 0x26, 0x9f, 0x0d, 0x70, 0xed, 0xb1, 0x8f, 0xa6, 0xf3, - 0x66, 0xd7, 0xf1, 0x3b, 0x74, 0x0f, 0x17, 0xa4, 0xaf, 0xbe, 0xe7, 0xb6, 0x7c, 0x87, 0xbc, 0x84, - 0xa7, 0x38, 0xf3, 0x79, 0xb4, 0x8c, 0x36, 0xa6, 0x77, 0x16, 0xca, 0x0a, 0xa3, 0xcb, 0x9c, 0xc9, - 0x98, 0xb8, 0x7b, 0x54, 0x1a, 0x33, 0x81, 0x81, 0xb6, 0xf1, 0xb3, 0x4c, 0xe2, 0x67, 0x9c, 0x96, - 0x2d, 0xd4, 0x90, 0xaf, 0x62, 0x1c, 0xba, 0x01, 0x64, 0xae, 0x95, 0xb9, 0xcf, 0xca, 0x81, 0xcf, - 0xca, 0xdc, 0xc3, 0xa1, 0xe4, 0xba, 0x03, 0xbc, 0xc6, 0xdc, 0xa3, 0xa3, 0xd2, 0xb3, 0x3d, 0x6b, - 0xbf, 0xf9, 0x32, 0x0d, 0x65, 0x50, 0x33, 0x22, 0x90, 0xfe, 0x1e, 0x81, 0x71, 0xa0, 0x14, 0xac, - 0xf8, 0x34, 0x9e, 0x0c, 0xf0, 0x06, 0x46, 0x3c, 0xb5, 0x31, 0xbd, 0x53, 0x54, 0x1a, 0x11, 0xb0, - 0xec, 0xfa, 0xbe, 0xd3, 0x31, 0x66, 0x03, 0x3b, 0x1e, 0x1d, 0x95, 0x66, 0xb8, 0x32, 0xc6, 0x4a, - 0x4d, 0x2e, 0x82, 0x7c, 0x4d, 0xb2, 0x60, 0x9c, 0x59, 0xb0, 0x9e, 0x69, 0x01, 0x07, 0x92, 0xc7, - 0x04, 0x8a, 0xcf, 0xf6, 0x2d, 0x10, 0x5e, 0x3b, 0x8d, 0xc7, 0x1b, 0x36, 0xf3, 0xd6, 0x84, 0x39, - 0xde, 0xb0, 0xe9, 0x57, 0x22, 0xae, 0xed, 0x1b, 0xf9, 0x29, 0x3c, 0x11, 0x20, 0x04, 0xa7, 0x66, - 0xd9, 0x58, 0x00, 0x1b, 0xa7, 0x43, 0x1b, 0xa9, 0xc9, 0x04, 0xd0, 0x9f, 0x23, 0xac, 0x31, 0xf1, - 0xbb, 0xcd, 0x66, 0xc0, 0x60, 0xf4, 0x5e, 0x7f, 0xab, 0xe5, 0xb4, 0x05, 0x98, 0x35, 0x3c, 0xe9, - 0x06, 0xff, 0x67, 0x8a, 0x9e, 0x36, 0xce, 0x86, 0x8e, 0x62, 0x9f, 0xa9, 0xc9, 0x97, 0x63, 0xa1, - 0x1e, 0x7f, 0xdc, 0xa1, 0xfe, 0x23, 0xc2, 0x0b, 0x4a, 0x94, 0xe0, 0x8e, 0x9b, 0xc3, 0xc5, 0xfc, - 0x1c, 0xf8, 0xe3, 0x4c, 0xe8, 0x8f, 0x4a, 0x63, 0x84, 0x61, 0xff, 0x0b, 0xc2, 0x2b, 0x0a, 0x73, - 0x76, 0x5b, 0xf6, 0x9e, 0xeb, 0x36, 0x87, 0xf5, 0xfd, 0x15, 0x7c, 0xca, 0x73, 0xdd, 0x66, 0xa5, - 0x61, 0x33, 0xa8, 0x13, 0x06, 0x79, 0x74, 0x54, 0x3a, 0x0d, 0x08, 0xf8, 0x02, 0x35, 0xa7, 0x82, - 0x5f, 0x37, 0xec, 0x58, 0xa0, 0x9e, 0x7a, 0xdc, 0x81, 0xba, 0x87, 0x30, 0x4d, 0xb3, 0xec, 0x09, - 0xdc, 0xa3, 0xa2, 0xb4, 0xed, 0x59, 0x8d, 0xf6, 0xa8, 0x4a, 0xdb, 0xdf, 0x51, 0xbf, 0x6e, 0x33, - 0xa5, 0xe0, 0xb6, 0x3a, 0x7e, 0xc6, 0x79, 0xbb, 0xe3, 0xb4, 0x6c, 0xc7, 0x66, 0x0b, 0xe0, 0x3e, - 0xaa, 0x74, 0xdf, 0x75, 0xa0, 0xac, 0x04, 0xa4, 0xc6, 0x12, 0xb8, 0x70, 0x8e, 0x2b, 0x16, 0x62, - 0x2a, 0x5e, 0x20, 0x87, 0x9a, 0xb2, 0xdc, 0x91, 0xd5, 0xbd, 0x40, 0x5b, 0x52, 0xdd, 0xeb, 0x45, - 0xfc, 0xde, 0xf7, 0x80, 0x8d, 0x67, 0xae, 0x47, 0x90, 0x82, 0xe7, 0xf3, 0x38, 0x60, 0x11, 0x1c, - 0x30, 0xab, 0x70, 0x00, 0x35, 0x25, 0xa9, 0xf4, 0x1d, 0x51, 0x6d, 0x82, 0xec, 0x33, 0xad, 0x8e, - 0xe3, 0x7f, 0xae, 0x63, 0x75, 0x46, 0x15, 0xfc, 0x7f, 0x23, 0xbc, 0xa8, 0x56, 0x0f, 0x4e, 0xf0, - 0xf0, 0x99, 0xd8, 0x12, 0x24, 0xc2, 0xaa, 0xd2, 0x0f, 0x31, 0x5a, 0x63, 0x19, 0x3c, 0x71, 0x9e, - 0xc3, 0xb0, 0x82, 0xe5, 0x4a, 0x3b, 0x58, 0xaf, 0xf8, 0x01, 0x01, 0x35, 0xe3, 0xe2, 0x4f, 0x3c, - 0x1f, 0x36, 0xc5, 0x21, 0x24, 0xe9, 0x4d, 0xca, 0x8c, 0x1f, 0x20, 0x65, 0x7c, 0xfa, 0xfe, 0xd9, - 0xc7, 0xa7, 0xe5, 0x15, 0x88, 0x51, 0x3e, 0xf7, 0x94, 0xc0, 0x3d, 0xe7, 0xd4, 0xee, 0xa1, 0x66, - 0x4c, 0x78, 0x58, 0x20, 0x5c, 0xb7, 0x39, 0xaa, 0x1c, 0xb9, 0xd3, 0x2f, 0x10, 0x5c, 0x29, 0x58, - 0x7e, 0x1d, 0x4f, 0x06, 0x75, 0x5e, 0xe4, 0xc3, 0xbc, 0xfa, 0x02, 0xe7, 0xba, 0xcd, 0x78, 0x49, - 0x65, 0x5c, 0xd4, 0xe4, 0xdc, 0xa3, 0xdb, 0xfe, 0x91, 0xd3, 0x2e, 0x1e, 0xe4, 0x2f, 0x46, 0xbc, - 0xda, 0xb7, 0xcf, 0xc0, 0x13, 0x01, 0x42, 0xf0, 0x67, 0x8a, 0x79, 0xb1, 0x1b, 0x4f, 0xc0, 0x44, - 0x4d, 0xc6, 0x4b, 0xdf, 0x45, 0xb8, 0x14, 0x66, 0xcf, 0xe7, 0xdd, 0x60, 0xc7, 0xdf, 0xb4, 0x3c, - 0xaf, 0xd1, 0xaa, 0x8f, 0x2a, 0x7a, 0xef, 0x8d, 0xe3, 0xe5, 0x64, 0x08, 0x60, 0xeb, 0xbb, 0x08, - 0x17, 0xac, 0xc1, 0x75, 0x08, 0xed, 0x7a, 0x72, 0x2e, 0x4b, 0xf4, 0xc6, 0x45, 0xf0, 0xc4, 0x52, - 0x34, 0x9d, 0x3b, 0x2e, 0xab, 0x7b, 0x95, 0x7d, 0x10, 0x4a, 0x4d, 0x95, 0xaa, 0x13, 0xcf, 0x83, - 0x43, 0x5c, 0x4c, 0x70, 0x83, 0x08, 0x44, 0x19, 0x7f, 0x84, 0x23, 0x16, 0xb9, 0x61, 0x14, 0xc2, - 0x7b, 0x9b, 0x58, 0xa1, 0xe6, 0x29, 0xf6, 0xf3, 0x86, 0x3d, 0xd4, 0x5d, 0x88, 0xfe, 0x2c, 0x39, - 0x13, 0xfa, 0x51, 0x38, 0xc4, 0x64, 0x70, 0x15, 0x32, 0x22, 0x77, 0x0c, 0x56, 0x21, 0x06, 0x8b, - 0x29, 0x31, 0xa0, 0xa6, 0x42, 0x11, 0xed, 0x40, 0xa7, 0x66, 0xb8, 0xed, 0xb6, 0xfb, 0xd6, 0xa8, - 0xf2, 0xf3, 0x0f, 0x08, 0xcf, 0xca, 0x6a, 0xc1, 0x1b, 0x26, 0x3e, 0x55, 0xe5, 0x9f, 0x20, 0x0d, - 0x97, 0x95, 0x2e, 0xe0, 0x6c, 0xfc, 0xee, 0xf6, 0x1c, 0xd8, 0x0e, 0x41, 0x00, 0x76, 0x6a, 0x0a, - 0x41, 0x27, 0x9e, 0x64, 0xab, 0x50, 0x29, 0x39, 0xa8, 0xa4, 0x72, 0x73, 0x4b, 0x72, 0x74, 0xdf, - 0xe0, 0xd7, 0xf1, 0x14, 0xc7, 0x09, 0x4e, 0xce, 0xb6, 0x77, 0x0e, 0xec, 0x7d, 0x26, 0x6a, 0x2f, - 0x35, 0x41, 0x0c, 0xfd, 0x45, 0xff, 0x70, 0x6f, 0x36, 0x39, 0xdb, 0xff, 0x66, 0xc7, 0x75, 0x1f, - 0xe1, 0xa5, 0x04, 0x9c, 0x4f, 0x70, 0x2e, 0x3c, 0x40, 0xf8, 0x82, 0xd2, 0xaa, 0xff, 0x83, 0xd6, - 0xeb, 0x6f, 0x08, 0xaf, 0xa6, 0xdb, 0xf6, 0x04, 0x07, 0xae, 0x8b, 0x9f, 0x0b, 0x2b, 0xb5, 0x74, - 0x19, 0x3f, 0xd1, 0x13, 0xe2, 0x36, 0x3e, 0x37, 0xa0, 0x16, 0xbc, 0xf8, 0x65, 0x8c, 0xc3, 0xaf, - 0x50, 0x1d, 0x4a, 0xc9, 0x07, 0x02, 0xbf, 0x5b, 0x6a, 0xe0, 0x47, 0x12, 0x85, 0x07, 0x97, 0xee, - 0x88, 0x38, 0xfa, 0x1a, 0x9e, 0x67, 0x7a, 0x6f, 0xba, 0x76, 0xb7, 0xe9, 0x18, 0x56, 0xd3, 0x6a, - 0xd5, 0x44, 0x2e, 0x44, 0x2d, 0x40, 0x99, 0x16, 0xbc, 0x27, 0xe6, 0x3b, 0x31, 0x51, 0x61, 0x47, - 0x29, 0x2d, 0xa4, 0x36, 0x54, 0x12, 0x65, 0xbc, 0xa3, 0xdc, 0x67, 0x8b, 0x95, 0x2a, 0x5f, 0xa5, - 0xa6, 0x2c, 0x97, 0x6a, 0xf8, 0x3c, 0x83, 0xf1, 0xaa, 0xe3, 0xb9, 0x7e, 0x43, 0x0a, 0x61, 0x70, - 0x23, 0x9b, 0x57, 0x2c, 0x02, 0xc4, 0x1a, 0x9e, 0x89, 0x7e, 0x07, 0x84, 0x2b, 0x4a, 0x84, 0x51, - 0xc2, 0x78, 0xc7, 0x67, 0xf3, 0x35, 0xe1, 0x6e, 0x49, 0x28, 0x2d, 0x42, 0x55, 0xfe, 0x82, 0xef, - 0xb4, 0x55, 0x10, 0x7f, 0x24, 0xca, 0xe1, 0x20, 0x41, 0xbf, 0x29, 0x3b, 0x1b, 0x5f, 0xcb, 0x0f, - 0x75, 0x05, 0xa0, 0xce, 0x73, 0xa8, 0x5d, 0xdf, 0x69, 0x57, 0x62, 0x78, 0x07, 0xa4, 0xd3, 0x15, - 0xb8, 0xbd, 0x98, 0x8e, 0xef, 0xb4, 0x6f, 0x3b, 0x2a, 0xd8, 0x3f, 0x45, 0x70, 0xd1, 0x54, 0xd2, - 0x00, 0xf2, 0x1e, 0x2e, 0x28, 0x96, 0xf3, 0x83, 0x8f, 0xdd, 0x6e, 0xda, 0x5c, 0x56, 0x1c, 0xbf, - 0x4a, 0x47, 0xdf, 0x04, 0xa3, 0xdb, 0x33, 0xac, 0xda, 0x1b, 0x2a, 0x13, 0xde, 0x17, 0x26, 0x28, - 0x69, 0xc0, 0x84, 0x6f, 0xe2, 0x82, 0x62, 0x39, 0xbf, 0x09, 0xb1, 0x4b, 0x72, 0xb5, 0xdb, 0xab, - 0x54, 0xad, 0xda, 0x1b, 0x03, 0x36, 0x28, 0x94, 0xd0, 0x79, 0xa8, 0x11, 0xbc, 0x5e, 0x4a, 0xd8, - 0xdf, 0x81, 0xa4, 0x97, 0x96, 0x00, 0xf2, 0xd7, 0xf1, 0x74, 0xe4, 0x73, 0x7e, 0xa8, 0x0b, 0x00, - 0xb5, 0x10, 0x2d, 0xc5, 0x02, 0x60, 0x54, 0x24, 0xdd, 0x06, 0xed, 0xbb, 0xdd, 0x5a, 0x50, 0x43, - 0xd9, 0xdc, 0x5e, 0xd4, 0x90, 0x39, 0x3c, 0x65, 0x79, 0x5e, 0xbf, 0x84, 0x98, 0x93, 0x96, 0xe7, - 0xdd, 0xb0, 0xe9, 0x77, 0xc5, 0x4e, 0x94, 0x79, 0xc2, 0x62, 0x61, 0x45, 0xbe, 0xfb, 0xa9, 0xc5, - 0x22, 0x2a, 0xc1, 0x8f, 0x17, 0x0b, 0x10, 0x53, 0x81, 0xd7, 0x03, 0x53, 0x96, 0xbb, 0xf3, 0xbb, - 0x65, 0x3c, 0xc9, 0x60, 0x90, 0x6f, 0x21, 0x8c, 0xc3, 0x19, 0x3f, 0x59, 0x53, 0xaa, 0x1a, 0x78, - 0x79, 0xd0, 0xd6, 0x33, 0xe9, 0xb8, 0x49, 0x94, 0x7e, 0xfb, 0xfe, 0xbf, 0x7e, 0x3c, 0xbe, 0x48, - 0x34, 0x3d, 0xe9, 0xa9, 0xc5, 0x27, 0xdf, 0x41, 0xf8, 0xe9, 0x3e, 0x2b, 0xb9, 0x98, 0x2e, 0x5a, - 0x20, 0x58, 0xcb, 0x22, 0x03, 0x00, 0xeb, 0x0c, 0xc0, 0x0a, 0x29, 0x25, 0x03, 0xd0, 0x0f, 0x1a, - 0xf6, 0x21, 0xf9, 0x15, 0x82, 0x1b, 0xaa, 0x3c, 0x59, 0x25, 0x7a, 0xb2, 0x22, 0xe5, 0x48, 0x5f, - 0x7b, 0x3e, 0x3f, 0x03, 0x60, 0xbc, 0xca, 0x30, 0x6e, 0x91, 0x2b, 0xc9, 0x18, 0x2b, 0xd5, 0x5e, - 0x85, 0x5d, 0x89, 0xf4, 0x03, 0xf6, 0xcf, 0x21, 0xf9, 0xb3, 0xfa, 0x61, 0x01, 0x2e, 0x23, 0xe4, - 0xa3, 0x79, 0x51, 0xc8, 0x37, 0x33, 0xed, 0xc5, 0xa1, 0xf9, 0xc0, 0x08, 0x83, 0x19, 0xf1, 0x0a, - 0x79, 0x39, 0x87, 0x11, 0x95, 0xe0, 0xf0, 0x14, 0x96, 0xe8, 0x07, 0x70, 0xa8, 0x1e, 0x06, 0x2d, - 0xf9, 0x14, 0x4f, 0x51, 0x92, 0x92, 0x61, 0xd2, 0x5b, 0x9b, 0xb6, 0x91, 0x4d, 0x08, 0x08, 0x2f, - 0x30, 0x84, 0x4b, 0x64, 0x41, 0x4f, 0x7e, 0xd6, 0x0b, 0x37, 0x04, 0x1f, 0xd4, 0xae, 0xa5, 0x49, - 0x0f, 0xe7, 0xd5, 0xda, 0x7a, 0x26, 0x5d, 0xae, 0x0d, 0xc1, 0xa6, 0xc5, 0xe1, 0x86, 0x08, 0x58, - 0xd3, 0x36, 0x44, 0x64, 0xbc, 0xab, 0xad, 0x65, 0x91, 0xe5, 0xda, 0x10, 0x0c, 0x00, 0xdf, 0x10, - 0x1f, 0x8a, 0x26, 0x35, 0x3e, 0xac, 0x4c, 0x4b, 0x70, 0xe5, 0x40, 0x57, 0xdb, 0x1e, 0x82, 0x03, - 0x60, 0x96, 0x19, 0xcc, 0x0d, 0xb2, 0xa6, 0x84, 0x39, 0x30, 0x53, 0x8d, 0x6c, 0x5f, 0x49, 0x60, - 0xea, 0xf6, 0x55, 0x0d, 0x43, 0xb5, 0xe7, 0xf3, 0x33, 0xe4, 0xda, 0xbe, 0x03, 0x50, 0xb9, 0x77, - 0xc3, 0x3c, 0x63, 0x13, 0xc1, 0xb4, 0xe8, 0x45, 0xc6, 0x9e, 0xa9, 0x79, 0x16, 0x9d, 0x54, 0x66, - 0xe5, 0x19, 0x53, 0x1a, 0xe6, 0x59, 0x50, 0x31, 0x2e, 0xa6, 0x8b, 0xce, 0x93, 0x67, 0xd1, 0x7a, - 0x90, 0x91, 0x67, 0x01, 0x00, 0xee, 0x89, 0xdf, 0x22, 0x71, 0x8e, 0x2a, 0x26, 0x64, 0x2f, 0x64, - 0x44, 0x43, 0x39, 0x5e, 0xd4, 0xae, 0x0d, 0xc9, 0x35, 0x44, 0x20, 0xe3, 0x93, 0x3d, 0xf2, 0x27, - 0x14, 0xed, 0x61, 0x24, 0xc9, 0xe4, 0xea, 0x30, 0x38, 0x04, 0xf8, 0x17, 0x86, 0x63, 0x02, 0xec, - 0xaf, 0x31, 0xec, 0x06, 0xf9, 0xe4, 0x10, 0xd8, 0xf5, 0x03, 0xd1, 0xbf, 0x45, 0x8b, 0xf0, 0xf7, - 0x10, 0x9e, 0x89, 0x0e, 0xa7, 0x48, 0x4a, 0x85, 0x95, 0xc7, 0x66, 0xda, 0xa5, 0x1c, 0x94, 0x80, - 0x77, 0x95, 0xe1, 0x2d, 0x92, 0x45, 0x25, 0x5e, 0xd1, 0xf6, 0x7e, 0x1f, 0xe1, 0xe9, 0x08, 0x7b, - 0xda, 0xa9, 0x20, 0x8d, 0x9f, 0xb4, 0x8d, 0x6c, 0x42, 0x00, 0x72, 0x89, 0x01, 0xb9, 0x40, 0x56, - 0xd2, 0x80, 0xf0, 0x4c, 0xfd, 0x0d, 0xc2, 0x73, 0xca, 0x09, 0x00, 0xd9, 0x4e, 0x3d, 0x35, 0x55, - 0x73, 0x28, 0x6d, 0x67, 0x18, 0x16, 0xc0, 0x7a, 0x8d, 0x61, 0xd5, 0xc9, 0x56, 0x1a, 0xd6, 0xc1, - 0xab, 0xc2, 0x83, 0xa4, 0x99, 0x98, 0xb8, 0x2c, 0x7c, 0x2c, 0x3f, 0x96, 0xd8, 0x75, 0xe1, 0xa5, - 0xff, 0x82, 0x13, 0x8c, 0x79, 0x95, 0x19, 0xf3, 0x09, 0xf2, 0x4a, 0x2e, 0x63, 0x92, 0xae, 0x0c, - 0x1f, 0x22, 0x7c, 0x26, 0x36, 0x42, 0x20, 0x57, 0x32, 0x76, 0x90, 0x74, 0x36, 0x6d, 0xe6, 0x23, - 0x06, 0xd0, 0x1f, 0x67, 0xa0, 0x5f, 0x24, 0xd7, 0x52, 0xb6, 0x19, 0x54, 0x79, 0xd5, 0xde, 0xfa, - 0xa5, 0x78, 0x56, 0x92, 0x9a, 0x77, 0x52, 0x4e, 0xc6, 0xa0, 0x9a, 0x50, 0x68, 0x7a, 0x6e, 0xfa, - 0x5c, 0x89, 0x23, 0x8f, 0x16, 0x22, 0x70, 0xdf, 0x47, 0xf0, 0x48, 0x14, 0xed, 0x90, 0xc8, 0x56, - 0xb2, 0x76, 0x45, 0x83, 0xa9, 0x95, 0xf3, 0x92, 0x03, 0xd6, 0xcb, 0x0c, 0xeb, 0x2a, 0xa1, 0x4a, - 0xac, 0x52, 0xc7, 0x48, 0x7e, 0x2d, 0x76, 0x64, 0xbc, 0x79, 0x4f, 0xdb, 0x91, 0x09, 0x33, 0x88, - 0xb4, 0x1d, 0x99, 0x34, 0x95, 0xa0, 0x3a, 0x03, 0x7b, 0x89, 0xac, 0x2b, 0xc1, 0x0e, 0xce, 0x19, - 0xc8, 0x1d, 0x71, 0xda, 0x29, 0xda, 0xf5, 0xb4, 0xd3, 0x2e, 0x79, 0x08, 0x91, 0x76, 0xda, 0xa5, - 0x8c, 0x25, 0xe8, 0x0e, 0x83, 0xbe, 0x49, 0x2e, 0x2b, 0xa1, 0x2b, 0xa7, 0x0c, 0xe1, 0x59, 0xad, - 0x68, 0xd4, 0xd3, 0xd0, 0x27, 0xcf, 0x1f, 0xd2, 0xd0, 0xa7, 0x4c, 0x24, 0x32, 0xce, 0x6a, 0xf5, - 0x80, 0x81, 0xfc, 0x04, 0xc1, 0xc3, 0x68, 0xa4, 0x8d, 0x27, 0x9b, 0x59, 0x47, 0x85, 0x04, 0x77, - 0x2b, 0x27, 0xf5, 0x10, 0xa7, 0x0b, 0x80, 0xfb, 0x40, 0xd4, 0x06, 0xa9, 0xb3, 0x4f, 0xdb, 0x6d, - 0x8a, 0xc1, 0x43, 0xda, 0x6e, 0x53, 0xcd, 0x1c, 0xb2, 0xee, 0x3c, 0x9c, 0x85, 0xf7, 0x46, 0xfa, - 0x01, 0x1f, 0x69, 0x1c, 0x1a, 0x7b, 0x77, 0xff, 0x59, 0x1c, 0xfb, 0xe0, 0xb8, 0x38, 0x76, 0xf7, - 0xb8, 0x88, 0xee, 0x1d, 0x17, 0xd1, 0x3f, 0x8e, 0x8b, 0xe8, 0x87, 0x0f, 0x8b, 0x63, 0xf7, 0x1e, - 0x16, 0xc7, 0xfe, 0xfa, 0xb0, 0x38, 0xf6, 0xa5, 0x72, 0xbd, 0xd1, 0xf9, 0x46, 0xb7, 0x1a, 0x80, - 0x01, 0xc1, 0x5b, 0xee, 0xad, 0x5b, 0x8d, 0x5a, 0xc3, 0x6a, 0x0a, 0x45, 0xa0, 0xaa, 0xd3, 0xf3, - 0x1c, 0xbf, 0x3a, 0xc5, 0xfe, 0x9c, 0xf2, 0xea, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x6c, - 0x2c, 0x54, 0x28, 0x2a, 0x00, 0x00, + // 1778 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, 0x9c, 0x7a, 0x79, 0xc5, 0xaa, 0xaf, 0xe6, 0x6b, 0x75, + 0xdb, 0xb5, 0x49, 0x9f, 0xd8, 0x90, 0x67, 0x1b, 0xf2, 0xb0, 0x41, 0x79, 0x74, 0xc9, 0x76, 0x96, + 0x6d, 0x47, 0x2d, 0x1a, 0x8e, 0x25, 0x76, 0xfb, 0xb2, 0x35, 0xa3, 0x54, 0xae, 0x1a, 0x6e, 0xd9, + 0xae, 0x0a, 0x05, 0x4a, 0x7f, 0xc9, 0x2e, 0xd9, 0xfc, 0xa7, 0xca, 0x7e, 0xc1, 0xd7, 0xa1, 0x92, + 0x6d, 0x97, 0x2a, 0x96, 0x6a, 0xd4, 0xca, 0xaa, 0x51, 0xad, 0xda, 0x2e, 0x17, 0x71, 0x60, 0x35, + 0x27, 0x43, 0xc5, 0x11, 0x88, 0xf5, 0x51, 0xd9, 0x7a, 0xcd, 0xa8, 0x1b, 0xcb, 0xa0, 0x81, 0xf6, + 0x63, 0xf2, 0x1c, 0xc3, 0xb5, 0xc8, 0x3f, 0xea, 0xd6, 0xe5, 0x15, 0xcb, 0x71, 0xe9, 0x22, 0xee, + 0x8b, 0x7c, 0x75, 0x6a, 0x76, 0xd5, 0xb1, 0xc8, 0x71, 0xdc, 0x23, 0x84, 0xf7, 0xa3, 0x51, 0x34, + 0xdd, 0x3b, 0x7f, 0x20, 0x2f, 0x21, 0x9d, 0x17, 0x42, 0x5a, 0xd7, 0xcd, 0x8d, 0x91, 0x0e, 0x1d, + 0x04, 0x68, 0x1d, 0xef, 0xe5, 0x1a, 0xcf, 0x5b, 0x55, 0xd3, 0x33, 0x43, 0x5e, 0xc6, 0x38, 0x70, + 0x03, 0xe8, 0x9c, 0xcc, 0x0b, 0x9f, 0xe5, 0x99, 0xcf, 0xf2, 0xc2, 0xc3, 0x81, 0xe6, 0x92, 0x05, + 0xb2, 0xda, 0xc0, 0xfd, 0x8d, 0x91, 0xbd, 0xab, 0xc6, 0x72, 0xe5, 0x04, 0x0d, 0x74, 0x50, 0x3d, + 0xa4, 0x90, 0x7e, 0x8b, 0x80, 0x1c, 0x18, 0x05, 0x16, 0xcf, 0xe2, 0x6e, 0x86, 0x97, 0x91, 0xd8, + 0x36, 0xdd, 0x3b, 0x9f, 0x93, 0x92, 0x60, 0x22, 0x0b, 0x8e, 0x63, 0xb9, 0x5a, 0x3f, 0xe3, 0x71, + 0x7f, 0x63, 0x64, 0xa7, 0x30, 0xc6, 0x45, 0xa9, 0x2e, 0x54, 0x90, 0x57, 0x22, 0x0c, 0x3a, 0x39, + 0x83, 0xa9, 0xa6, 0x0c, 0x04, 0x90, 0x2c, 0x14, 0x28, 0xde, 0xe3, 0x33, 0xf0, 0xbc, 0xb6, 0x1b, + 0x77, 0x96, 0x4d, 0xee, 0xad, 0x2e, 0xbd, 0xb3, 0x6c, 0xd2, 0x97, 0x42, 0xae, 0xf5, 0x49, 0x9e, + 0xc5, 0x5d, 0x0c, 0x21, 0x38, 0xb5, 0x19, 0xc7, 0x3e, 0xe0, 0xd8, 0x1b, 0x70, 0xa4, 0x3a, 0x57, + 0x40, 0x3f, 0x46, 0x58, 0xe1, 0xea, 0x17, 0x2a, 0x15, 0x26, 0xa0, 0xad, 0x5e, 0xbc, 0x5a, 0xb5, + 0xea, 0x1e, 0x98, 0x49, 0xdc, 0x6d, 0xb3, 0xff, 0xe7, 0x86, 0x76, 0x68, 0x7b, 0x02, 0x47, 0xf1, + 0xcf, 0x54, 0x17, 0xcb, 0xb1, 0x50, 0x77, 0x3e, 0xe8, 0x50, 0x7f, 0x8f, 0xf0, 0x01, 0x29, 0x4a, + 0x70, 0xc7, 0x85, 0xd6, 0x62, 0xbe, 0x0f, 0xfc, 0xf1, 0xff, 0xc0, 0x1f, 0x85, 0x72, 0x1b, 0xc3, + 0x7e, 0x07, 0xe1, 0x31, 0x09, 0x9d, 0x85, 0xaa, 0xb9, 0x68, 0xdb, 0x95, 0x56, 0x7d, 0x7f, 0x08, + 0x6f, 0xaf, 0xd9, 0x76, 0xa5, 0x50, 0x36, 0x39, 0xd4, 0x2e, 0x8d, 0xdc, 0xdf, 0x18, 0xd9, 0x0d, + 0x08, 0xc4, 0x02, 0xd5, 0x7b, 0xd8, 0xaf, 0x73, 0x66, 0x2c, 0x50, 0xdb, 0x1e, 0x74, 0xa0, 0x6e, + 0x21, 0x4c, 0xd3, 0x98, 0x3d, 0x84, 0x67, 0xd4, 0x2b, 0x6d, 0x8b, 0x46, 0xb9, 0xde, 0xae, 0xd2, + 0xf6, 0x2b, 0xf2, 0xeb, 0x36, 0x37, 0x0a, 0x6e, 0x2b, 0xe1, 0x5d, 0xd6, 0x35, 0xd7, 0xaa, 0x9a, + 0x96, 0xc9, 0x17, 0xc0, 0x7d, 0x54, 0xea, 0xbe, 0x33, 0xb0, 0xb3, 0xc0, 0xb6, 0x6a, 0xc3, 0xe0, + 0xc2, 0x01, 0x61, 0xd8, 0x53, 0x53, 0xa8, 0x31, 0x3d, 0x54, 0x8f, 0xea, 0x6d, 0x5b, 0xdd, 0x63, + 0xd6, 0x92, 0xea, 0xde, 0x6a, 0xc8, 0xef, 0xbe, 0x07, 0x4c, 0xbc, 0xf3, 0x4c, 0x08, 0x29, 0x78, + 0x3e, 0x8b, 0x03, 0x86, 0xc0, 0x01, 0xfd, 0x12, 0x07, 0x50, 0x3d, 0xa2, 0x95, 0xae, 0xe3, 0x21, + 0x91, 0xc4, 0x2c, 0xfb, 0x74, 0xc3, 0xb5, 0x9c, 0xc8, 0xfd, 0xb9, 0xd5, 0xd1, 0xff, 0x13, 0xe1, + 0xe1, 0x04, 0xfb, 0xe0, 0x06, 0x17, 0xef, 0x89, 0xaf, 0x41, 0x2e, 0x4c, 0x48, 0x5d, 0x11, 0xdf, + 0xac, 0x8d, 0x81, 0x37, 0x06, 0x05, 0x12, 0x83, 0xad, 0x17, 0xea, 0x6c, 0x43, 0x01, 0x6e, 0x74, + 0xbd, 0xc1, 0xc2, 0x96, 0x67, 0xc5, 0xac, 0x57, 0xe4, 0xa3, 0x86, 0x93, 0x12, 0xe4, 0x43, 0x24, + 0x0f, 0x93, 0xdc, 0x4b, 0x91, 0x97, 0xcd, 0x96, 0x78, 0x29, 0xf6, 0x14, 0x62, 0x05, 0xaf, 0x5d, + 0x19, 0xf3, 0xb5, 0x5f, 0x2f, 0x84, 0x51, 0x70, 0xc0, 0x19, 0xdc, 0xcd, 0xca, 0xbe, 0x97, 0x1b, + 0x83, 0xf2, 0xf7, 0x9c, 0x6d, 0x57, 0xe2, 0x15, 0x96, 0x4b, 0x51, 0x5d, 0x48, 0xb7, 0xaf, 0x1a, + 0x84, 0x2e, 0xbf, 0x78, 0xb0, 0x5f, 0x08, 0x79, 0xd5, 0xe7, 0xa7, 0xe1, 0x2e, 0x86, 0x10, 0xfc, + 0x99, 0x42, 0x2f, 0xf6, 0x00, 0x62, 0x42, 0x54, 0xe7, 0xb2, 0xf4, 0x3a, 0xc2, 0x23, 0x41, 0x16, + 0x3d, 0x6f, 0xb3, 0x02, 0x70, 0xc1, 0xa8, 0xd5, 0xca, 0xd5, 0x52, 0xbb, 0xa2, 0xf7, 0x76, 0x27, + 0x1e, 0x4d, 0x86, 0x00, 0x5c, 0xaf, 0x23, 0xdc, 0x67, 0x34, 0xae, 0x43, 0x68, 0xa7, 0x92, 0x13, + 0x3a, 0xb2, 0x5f, 0x9b, 0x00, 0x4f, 0x0c, 0x87, 0x53, 0xda, 0xb5, 0x79, 0x19, 0x2c, 0x2c, 0x83, + 0x52, 0xaa, 0xcb, 0x4c, 0x6d, 0x79, 0x1e, 0xac, 0xe3, 0x5c, 0x82, 0x1b, 0xbc, 0x40, 0xe4, 0xf1, + 0xff, 0x04, 0x62, 0x2f, 0x37, 0xb4, 0xbe, 0xe0, 0x19, 0xe7, 0xad, 0x50, 0x7d, 0x3b, 0xff, 0x79, + 0xce, 0x6c, 0xe9, 0x69, 0x44, 0x3f, 0x4a, 0xce, 0x04, 0x3f, 0x0a, 0xeb, 0x98, 0x34, 0xae, 0x42, + 0x46, 0x64, 0x8e, 0xc1, 0x38, 0xc4, 0x60, 0x28, 0x25, 0x06, 0x54, 0x97, 0x18, 0xa2, 0x2e, 0x34, + 0x6e, 0x9a, 0x5d, 0xaf, 0xdb, 0x57, 0xdb, 0x95, 0x9f, 0xdf, 0x21, 0xdc, 0x1f, 0x35, 0x0b, 0xde, + 0xd0, 0xf1, 0xf6, 0xa2, 0xf8, 0x04, 0x69, 0x38, 0x2a, 0x75, 0x81, 0x10, 0x13, 0x4f, 0xb9, 0x47, + 0x80, 0x3b, 0x04, 0x01, 0xc4, 0xa9, 0xee, 0x29, 0xda, 0xf2, 0x24, 0x1b, 0x87, 0x4a, 0x29, 0x40, + 0x25, 0x95, 0x9b, 0x4b, 0x11, 0x47, 0xfb, 0x84, 0x2f, 0xe2, 0x1e, 0x81, 0x13, 0x9c, 0xdc, 0x9c, + 0xef, 0x00, 0xf0, 0xdd, 0x15, 0xe6, 0x4b, 0x75, 0x50, 0x43, 0x3f, 0xf5, 0xef, 0xb0, 0x4a, 0x45, + 0x88, 0xfd, 0x3b, 0x1b, 0xb0, 0xdb, 0xfe, 0x93, 0xa4, 0x01, 0xe7, 0x43, 0x9c, 0x0b, 0x77, 0x11, + 0x3e, 0x28, 0x65, 0xf5, 0x1f, 0xe8, 0xc4, 0x7e, 0x41, 0x78, 0x3c, 0x9d, 0xdb, 0x43, 0x1c, 0x38, + 0xef, 0xa6, 0x60, 0x44, 0x38, 0xa4, 0xf3, 0xda, 0x3f, 0x72, 0x53, 0xc8, 0xec, 0x07, 0x37, 0x45, + 0xe3, 0x6a, 0xea, 0x4d, 0xd1, 0xb8, 0x3d, 0x7e, 0x53, 0x70, 0x20, 0x02, 0x7c, 0xa5, 0x18, 0xba, + 0x29, 0x1a, 0x25, 0xe9, 0x29, 0xc8, 0x6c, 0xdd, 0x72, 0xac, 0xfa, 0x15, 0x4b, 0x5b, 0x59, 0x2d, + 0x1a, 0x4b, 0xaf, 0xf1, 0x4d, 0xa7, 0x0d, 0xd7, 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, 0xd4, 0x74, 0x0b, 0x4f, 0x67, 0x9a, 0xa5, + 0x1b, 0x37, 0x1a, 0xa4, 0x1b, 0x2b, 0x1c, 0x13, 0xe9, 0xaa, 0xb3, 0xa4, 0x5b, 0xb8, 0x2c, 0x34, + 0x49, 0x37, 0x06, 0x40, 0x78, 0xe2, 0x1b, 0xe4, 0x5d, 0xa7, 0x92, 0xa9, 0xc0, 0xd1, 0x26, 0xe1, + 0x90, 0x8e, 0x54, 0x94, 0x63, 0x2d, 0x4a, 0xb5, 0x10, 0xc8, 0xf8, 0x34, 0x83, 0xfc, 0x88, 0xf0, + 0xbe, 0x04, 0xcd, 0xe4, 0x48, 0x2b, 0x38, 0x3c, 0xf0, 0x47, 0x5b, 0x13, 0x02, 0xec, 0xcf, 0x70, + 0xec, 0x1a, 0x39, 0xd5, 0x02, 0x76, 0x75, 0xcd, 0x7b, 0x9e, 0x85, 0x6b, 0xf1, 0x3b, 0x08, 0xef, + 0x0c, 0x37, 0xe4, 0x24, 0xa5, 0xd0, 0x46, 0x47, 0x05, 0xca, 0x4c, 0x86, 0x9d, 0x80, 0x77, 0x9c, + 0xe3, 0xcd, 0x91, 0x21, 0x29, 0x5e, 0xef, 0xa9, 0xff, 0x2e, 0xc2, 0xbd, 0x21, 0xf1, 0xb4, 0xcb, + 0x21, 0xd2, 0x72, 0x2b, 0xd3, 0xcd, 0x37, 0x02, 0x90, 0x19, 0x0e, 0xe4, 0x20, 0x19, 0x4b, 0x03, + 0x22, 0x32, 0xf5, 0x4b, 0xbf, 0x30, 0xc6, 0xba, 0x9e, 0xd4, 0xc2, 0x28, 0xef, 0xbd, 0x53, 0x0b, + 0x63, 0x42, 0x1b, 0x4c, 0x8f, 0x71, 0xac, 0x2a, 0x99, 0x4d, 0xc3, 0xda, 0xf8, 0x62, 0xb8, 0x9b, + 0x34, 0x07, 0xf0, 0xde, 0x0c, 0x4f, 0x66, 0xc7, 0x12, 0x7b, 0x35, 0x1c, 0xff, 0x1b, 0x92, 0x40, + 0xe6, 0x34, 0x27, 0xf3, 0x14, 0x39, 0x99, 0x89, 0x4c, 0xd2, 0xcb, 0xe1, 0x07, 0xef, 0xf8, 0x35, + 0xb6, 0x29, 0x69, 0xc7, 0x2f, 0xb1, 0xb7, 0x4b, 0x3b, 0x7e, 0xc9, 0x0d, 0x19, 0x3d, 0xcb, 0xc9, + 0x2c, 0x90, 0xa7, 0x13, 0xab, 0x5d, 0x43, 0x6b, 0x25, 0x3f, 0x7d, 0x77, 0xbc, 0x58, 0x25, 0x34, + 0x1f, 0x69, 0xb1, 0x4a, 0x6f, 0xc7, 0xd2, 0x62, 0xd5, 0xa4, 0x0b, 0x6b, 0xf2, 0xc6, 0x4b, 0x6e, + 0xa2, 0x42, 0x1c, 0xc9, 0x0d, 0xef, 0xcf, 0x08, 0x91, 0x06, 0x86, 0xcc, 0xa6, 0x64, 0x50, 0x63, + 0x7f, 0xa5, 0xe4, 0xb3, 0x6e, 0xcf, 0x56, 0xd3, 0x85, 0x88, 0x78, 0x46, 0xa8, 0x6b, 0xa2, 0x73, + 0x5b, 0xd7, 0x16, 0x6f, 0xfe, 0x9e, 0xeb, 0xb8, 0xb1, 0x99, 0xeb, 0xb8, 0xb9, 0x99, 0x43, 0xb7, + 0x36, 0x73, 0xe8, 0xb7, 0xcd, 0x1c, 0x7a, 0xef, 0x5e, 0xae, 0xe3, 0xd6, 0xbd, 0x5c, 0xc7, 0xcf, + 0xf7, 0x72, 0x1d, 0x2f, 0xe6, 0x4b, 0x65, 0xf7, 0xd5, 0x95, 0x22, 0x03, 0x03, 0x8a, 0x67, 0xed, + 0x4b, 0x97, 0xca, 0x4b, 0x65, 0xa3, 0xe2, 0x19, 0x02, 0x53, 0xee, 0x6a, 0xcd, 0x72, 0x8a, 0x3d, + 0xfc, 0x5f, 0xcc, 0x1c, 0xf9, 0x2b, 0x00, 0x00, 0xff, 0xff, 0xe3, 0xb3, 0xf4, 0x71, 0x0b, 0x24, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -2105,8 +1710,8 @@ type QueryClient interface { Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) QueryPairs(ctx context.Context, in *QueryPairsRequest, opts ...grpc.CallOption) (*QueryPairsResponse, error) QueryPair(ctx context.Context, in *QueryPairRequest, opts ...grpc.CallOption) (*QueryPairResponse, error) - QueryAssetRatesStats(ctx context.Context, in *QueryAssetRatesStatsRequest, opts ...grpc.CallOption) (*QueryAssetRatesStatsResponse, error) - QueryAssetRatesStat(ctx context.Context, in *QueryAssetRatesStatRequest, opts ...grpc.CallOption) (*QueryAssetRatesStatResponse, error) + QueryAssetRatesParams(ctx context.Context, in *QueryAssetRatesParamsRequest, opts ...grpc.CallOption) (*QueryAssetRatesParamsResponse, error) + QueryAssetRatesParam(ctx context.Context, in *QueryAssetRatesParamRequest, opts ...grpc.CallOption) (*QueryAssetRatesParamResponse, error) QueryPools(ctx context.Context, in *QueryPoolsRequest, opts ...grpc.CallOption) (*QueryPoolsResponse, error) QueryPool(ctx context.Context, in *QueryPoolRequest, opts ...grpc.CallOption) (*QueryPoolResponse, error) QueryAssetToPairMappings(ctx context.Context, in *QueryAssetToPairMappingsRequest, opts ...grpc.CallOption) (*QueryAssetToPairMappingsResponse, error) @@ -2115,13 +1720,8 @@ type QueryClient interface { QueryBorrow(ctx context.Context, in *QueryBorrowRequest, opts ...grpc.CallOption) (*QueryBorrowResponse, error) QueryAllBorrowByOwner(ctx context.Context, in *QueryAllBorrowByOwnerRequest, opts ...grpc.CallOption) (*QueryAllBorrowByOwnerResponse, error) QueryAllBorrowByOwnerAndPool(ctx context.Context, in *QueryAllBorrowByOwnerAndPoolRequest, opts ...grpc.CallOption) (*QueryAllBorrowByOwnerAndPoolResponse, error) - QueryAssetStats(ctx context.Context, in *QueryAssetStatsRequest, opts ...grpc.CallOption) (*QueryAssetStatsResponse, error) - QueryModuleBalance(ctx context.Context, in *QueryModuleBalanceRequest, opts ...grpc.CallOption) (*QueryModuleBalanceResponse, error) - QueryDepositStats(ctx context.Context, in *QueryDepositStatsRequest, opts ...grpc.CallOption) (*QueryDepositStatsResponse, error) - QueryUserDepositStats(ctx context.Context, in *QueryUserDepositStatsRequest, opts ...grpc.CallOption) (*QueryUserDepositStatsResponse, error) - QueryReserveDepositStats(ctx context.Context, in *QueryReserveDepositStatsRequest, opts ...grpc.CallOption) (*QueryReserveDepositStatsResponse, error) - QueryBuyBackDepositStats(ctx context.Context, in *QueryBuyBackDepositStatsRequest, opts ...grpc.CallOption) (*QueryBuyBackDepositStatsResponse, error) - QueryBorrowStats(ctx context.Context, in *QueryBorrowStatsRequest, opts ...grpc.CallOption) (*QueryBorrowStatsResponse, error) + 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) } @@ -2196,18 +1796,18 @@ func (c *queryClient) QueryPair(ctx context.Context, in *QueryPairRequest, opts return out, nil } -func (c *queryClient) QueryAssetRatesStats(ctx context.Context, in *QueryAssetRatesStatsRequest, opts ...grpc.CallOption) (*QueryAssetRatesStatsResponse, error) { - out := new(QueryAssetRatesStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryAssetRatesStats", in, out, opts...) +func (c *queryClient) QueryAssetRatesParams(ctx context.Context, in *QueryAssetRatesParamsRequest, opts ...grpc.CallOption) (*QueryAssetRatesParamsResponse, error) { + out := new(QueryAssetRatesParamsResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryAssetRatesParams", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryAssetRatesStat(ctx context.Context, in *QueryAssetRatesStatRequest, opts ...grpc.CallOption) (*QueryAssetRatesStatResponse, error) { - out := new(QueryAssetRatesStatResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryAssetRatesStat", in, out, opts...) +func (c *queryClient) QueryAssetRatesParam(ctx context.Context, in *QueryAssetRatesParamRequest, opts ...grpc.CallOption) (*QueryAssetRatesParamResponse, error) { + out := new(QueryAssetRatesParamResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryAssetRatesParam", in, out, opts...) if err != nil { return nil, err } @@ -2286,63 +1886,18 @@ func (c *queryClient) QueryAllBorrowByOwnerAndPool(ctx context.Context, in *Quer return out, nil } -func (c *queryClient) QueryAssetStats(ctx context.Context, in *QueryAssetStatsRequest, opts ...grpc.CallOption) (*QueryAssetStatsResponse, error) { - out := new(QueryAssetStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryAssetStats", in, out, opts...) - if err != nil { - return nil, err - } - 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 -} - -func (c *queryClient) QueryDepositStats(ctx context.Context, in *QueryDepositStatsRequest, opts ...grpc.CallOption) (*QueryDepositStatsResponse, error) { - out := new(QueryDepositStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryDepositStats", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryUserDepositStats(ctx context.Context, in *QueryUserDepositStatsRequest, opts ...grpc.CallOption) (*QueryUserDepositStatsResponse, error) { - out := new(QueryUserDepositStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryUserDepositStats", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryReserveDepositStats(ctx context.Context, in *QueryReserveDepositStatsRequest, opts ...grpc.CallOption) (*QueryReserveDepositStatsResponse, error) { - out := new(QueryReserveDepositStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryReserveDepositStats", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) QueryBuyBackDepositStats(ctx context.Context, in *QueryBuyBackDepositStatsRequest, opts ...grpc.CallOption) (*QueryBuyBackDepositStatsResponse, error) { - out := new(QueryBuyBackDepositStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryBuyBackDepositStats", in, out, opts...) +func (c *queryClient) QueryPoolAssetLBMapping(ctx context.Context, in *QueryPoolAssetLBMappingRequest, opts ...grpc.CallOption) (*QueryPoolAssetLBMappingResponse, error) { + out := new(QueryPoolAssetLBMappingResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryPoolAssetLBMapping", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) QueryBorrowStats(ctx context.Context, in *QueryBorrowStatsRequest, opts ...grpc.CallOption) (*QueryBorrowStatsResponse, error) { - out := new(QueryBorrowStatsResponse) - err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryBorrowStats", in, out, opts...) +func (c *queryClient) QueryReserveBuybackAssetData(ctx context.Context, in *QueryReserveBuybackAssetDataRequest, opts ...grpc.CallOption) (*QueryReserveBuybackAssetDataResponse, error) { + out := new(QueryReserveBuybackAssetDataResponse) + err := c.cc.Invoke(ctx, "/comdex.lend.v1beta1.Query/QueryReserveBuybackAssetData", in, out, opts...) if err != nil { return nil, err } @@ -2367,8 +1922,8 @@ type QueryServer interface { Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) QueryPairs(context.Context, *QueryPairsRequest) (*QueryPairsResponse, error) QueryPair(context.Context, *QueryPairRequest) (*QueryPairResponse, error) - QueryAssetRatesStats(context.Context, *QueryAssetRatesStatsRequest) (*QueryAssetRatesStatsResponse, error) - QueryAssetRatesStat(context.Context, *QueryAssetRatesStatRequest) (*QueryAssetRatesStatResponse, error) + QueryAssetRatesParams(context.Context, *QueryAssetRatesParamsRequest) (*QueryAssetRatesParamsResponse, error) + QueryAssetRatesParam(context.Context, *QueryAssetRatesParamRequest) (*QueryAssetRatesParamResponse, error) QueryPools(context.Context, *QueryPoolsRequest) (*QueryPoolsResponse, error) QueryPool(context.Context, *QueryPoolRequest) (*QueryPoolResponse, error) QueryAssetToPairMappings(context.Context, *QueryAssetToPairMappingsRequest) (*QueryAssetToPairMappingsResponse, error) @@ -2377,13 +1932,8 @@ type QueryServer interface { QueryBorrow(context.Context, *QueryBorrowRequest) (*QueryBorrowResponse, error) QueryAllBorrowByOwner(context.Context, *QueryAllBorrowByOwnerRequest) (*QueryAllBorrowByOwnerResponse, error) QueryAllBorrowByOwnerAndPool(context.Context, *QueryAllBorrowByOwnerAndPoolRequest) (*QueryAllBorrowByOwnerAndPoolResponse, error) - QueryAssetStats(context.Context, *QueryAssetStatsRequest) (*QueryAssetStatsResponse, error) - QueryModuleBalance(context.Context, *QueryModuleBalanceRequest) (*QueryModuleBalanceResponse, error) - QueryDepositStats(context.Context, *QueryDepositStatsRequest) (*QueryDepositStatsResponse, error) - QueryUserDepositStats(context.Context, *QueryUserDepositStatsRequest) (*QueryUserDepositStatsResponse, error) - QueryReserveDepositStats(context.Context, *QueryReserveDepositStatsRequest) (*QueryReserveDepositStatsResponse, error) - QueryBuyBackDepositStats(context.Context, *QueryBuyBackDepositStatsRequest) (*QueryBuyBackDepositStatsResponse, error) - QueryBorrowStats(context.Context, *QueryBorrowStatsRequest) (*QueryBorrowStatsResponse, error) + QueryPoolAssetLBMapping(context.Context, *QueryPoolAssetLBMappingRequest) (*QueryPoolAssetLBMappingResponse, error) + QueryReserveBuybackAssetData(context.Context, *QueryReserveBuybackAssetDataRequest) (*QueryReserveBuybackAssetDataResponse, error) QueryAuctionParams(context.Context, *QueryAuctionParamRequest) (*QueryAuctionParamResponse, error) } @@ -2412,11 +1962,11 @@ func (*UnimplementedQueryServer) QueryPairs(ctx context.Context, req *QueryPairs func (*UnimplementedQueryServer) QueryPair(ctx context.Context, req *QueryPairRequest) (*QueryPairResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryPair not implemented") } -func (*UnimplementedQueryServer) QueryAssetRatesStats(ctx context.Context, req *QueryAssetRatesStatsRequest) (*QueryAssetRatesStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAssetRatesStats not implemented") +func (*UnimplementedQueryServer) QueryAssetRatesParams(ctx context.Context, req *QueryAssetRatesParamsRequest) (*QueryAssetRatesParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAssetRatesParams not implemented") } -func (*UnimplementedQueryServer) QueryAssetRatesStat(ctx context.Context, req *QueryAssetRatesStatRequest) (*QueryAssetRatesStatResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAssetRatesStat not implemented") +func (*UnimplementedQueryServer) QueryAssetRatesParam(ctx context.Context, req *QueryAssetRatesParamRequest) (*QueryAssetRatesParamResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryAssetRatesParam not implemented") } func (*UnimplementedQueryServer) QueryPools(ctx context.Context, req *QueryPoolsRequest) (*QueryPoolsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryPools not implemented") @@ -2442,26 +1992,11 @@ func (*UnimplementedQueryServer) QueryAllBorrowByOwner(ctx context.Context, req func (*UnimplementedQueryServer) QueryAllBorrowByOwnerAndPool(ctx context.Context, req *QueryAllBorrowByOwnerAndPoolRequest) (*QueryAllBorrowByOwnerAndPoolResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAllBorrowByOwnerAndPool not implemented") } -func (*UnimplementedQueryServer) QueryAssetStats(ctx context.Context, req *QueryAssetStatsRequest) (*QueryAssetStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryAssetStats not implemented") -} -func (*UnimplementedQueryServer) QueryModuleBalance(ctx context.Context, req *QueryModuleBalanceRequest) (*QueryModuleBalanceResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryModuleBalance not implemented") -} -func (*UnimplementedQueryServer) QueryDepositStats(ctx context.Context, req *QueryDepositStatsRequest) (*QueryDepositStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryDepositStats not implemented") -} -func (*UnimplementedQueryServer) QueryUserDepositStats(ctx context.Context, req *QueryUserDepositStatsRequest) (*QueryUserDepositStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryUserDepositStats not implemented") -} -func (*UnimplementedQueryServer) QueryReserveDepositStats(ctx context.Context, req *QueryReserveDepositStatsRequest) (*QueryReserveDepositStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryReserveDepositStats not implemented") +func (*UnimplementedQueryServer) QueryPoolAssetLBMapping(ctx context.Context, req *QueryPoolAssetLBMappingRequest) (*QueryPoolAssetLBMappingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryPoolAssetLBMapping not implemented") } -func (*UnimplementedQueryServer) QueryBuyBackDepositStats(ctx context.Context, req *QueryBuyBackDepositStatsRequest) (*QueryBuyBackDepositStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryBuyBackDepositStats not implemented") -} -func (*UnimplementedQueryServer) QueryBorrowStats(ctx context.Context, req *QueryBorrowStatsRequest) (*QueryBorrowStatsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryBorrowStats not implemented") +func (*UnimplementedQueryServer) QueryReserveBuybackAssetData(ctx context.Context, req *QueryReserveBuybackAssetDataRequest) (*QueryReserveBuybackAssetDataResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryReserveBuybackAssetData not implemented") } func (*UnimplementedQueryServer) QueryAuctionParams(ctx context.Context, req *QueryAuctionParamRequest) (*QueryAuctionParamResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryAuctionParams not implemented") @@ -2597,38 +2132,38 @@ func _Query_QueryPair_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Query_QueryAssetRatesStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAssetRatesStatsRequest) +func _Query_QueryAssetRatesParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAssetRatesParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAssetRatesStats(ctx, in) + return srv.(QueryServer).QueryAssetRatesParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryAssetRatesStats", + FullMethod: "/comdex.lend.v1beta1.Query/QueryAssetRatesParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAssetRatesStats(ctx, req.(*QueryAssetRatesStatsRequest)) + return srv.(QueryServer).QueryAssetRatesParams(ctx, req.(*QueryAssetRatesParamsRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryAssetRatesStat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAssetRatesStatRequest) +func _Query_QueryAssetRatesParam_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAssetRatesParamRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAssetRatesStat(ctx, in) + return srv.(QueryServer).QueryAssetRatesParam(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryAssetRatesStat", + FullMethod: "/comdex.lend.v1beta1.Query/QueryAssetRatesParam", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAssetRatesStat(ctx, req.(*QueryAssetRatesStatRequest)) + return srv.(QueryServer).QueryAssetRatesParam(ctx, req.(*QueryAssetRatesParamRequest)) } return interceptor(ctx, in, info, handler) } @@ -2777,146 +2312,56 @@ func _Query_QueryAllBorrowByOwnerAndPool_Handler(srv interface{}, ctx context.Co return interceptor(ctx, in, info, handler) } -func _Query_QueryAssetStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAssetStatsRequest) +func _Query_QueryPoolAssetLBMapping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPoolAssetLBMappingRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryAssetStats(ctx, in) + return srv.(QueryServer).QueryPoolAssetLBMapping(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryAssetStats", + FullMethod: "/comdex.lend.v1beta1.Query/QueryPoolAssetLBMapping", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAssetStats(ctx, req.(*QueryAssetStatsRequest)) + return srv.(QueryServer).QueryPoolAssetLBMapping(ctx, req.(*QueryPoolAssetLBMappingRequest)) } 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) +func _Query_QueryReserveBuybackAssetData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryReserveBuybackAssetDataRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryModuleBalance(ctx, in) + return srv.(QueryServer).QueryReserveBuybackAssetData(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryModuleBalance", + FullMethod: "/comdex.lend.v1beta1.Query/QueryReserveBuybackAssetData", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryModuleBalance(ctx, req.(*QueryModuleBalanceRequest)) + return srv.(QueryServer).QueryReserveBuybackAssetData(ctx, req.(*QueryReserveBuybackAssetDataRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_QueryDepositStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryDepositStatsRequest) +func _Query_QueryAuctionParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAuctionParamRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).QueryDepositStats(ctx, in) + return srv.(QueryServer).QueryAuctionParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryDepositStats", + FullMethod: "/comdex.lend.v1beta1.Query/QueryAuctionParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryDepositStats(ctx, req.(*QueryDepositStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryUserDepositStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryUserDepositStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryUserDepositStats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryUserDepositStats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryUserDepositStats(ctx, req.(*QueryUserDepositStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryReserveDepositStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryReserveDepositStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryReserveDepositStats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryReserveDepositStats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryReserveDepositStats(ctx, req.(*QueryReserveDepositStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryBuyBackDepositStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBuyBackDepositStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryBuyBackDepositStats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryBuyBackDepositStats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryBuyBackDepositStats(ctx, req.(*QueryBuyBackDepositStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryBorrowStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryBorrowStatsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryBorrowStats(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryBorrowStats", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryBorrowStats(ctx, req.(*QueryBorrowStatsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_QueryAuctionParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAuctionParamRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryAuctionParams(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/comdex.lend.v1beta1.Query/QueryAuctionParams", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryAuctionParams(ctx, req.(*QueryAuctionParamRequest)) + return srv.(QueryServer).QueryAuctionParams(ctx, req.(*QueryAuctionParamRequest)) } return interceptor(ctx, in, info, handler) } @@ -2954,12 +2399,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_QueryPair_Handler, }, { - MethodName: "QueryAssetRatesStats", - Handler: _Query_QueryAssetRatesStats_Handler, + MethodName: "QueryAssetRatesParams", + Handler: _Query_QueryAssetRatesParams_Handler, }, { - MethodName: "QueryAssetRatesStat", - Handler: _Query_QueryAssetRatesStat_Handler, + MethodName: "QueryAssetRatesParam", + Handler: _Query_QueryAssetRatesParam_Handler, }, { MethodName: "QueryPools", @@ -2994,32 +2439,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_QueryAllBorrowByOwnerAndPool_Handler, }, { - MethodName: "QueryAssetStats", - Handler: _Query_QueryAssetStats_Handler, - }, - { - MethodName: "QueryModuleBalance", - Handler: _Query_QueryModuleBalance_Handler, - }, - { - MethodName: "QueryDepositStats", - Handler: _Query_QueryDepositStats_Handler, + MethodName: "QueryPoolAssetLBMapping", + Handler: _Query_QueryPoolAssetLBMapping_Handler, }, { - MethodName: "QueryUserDepositStats", - Handler: _Query_QueryUserDepositStats_Handler, - }, - { - MethodName: "QueryReserveDepositStats", - Handler: _Query_QueryReserveDepositStats_Handler, - }, - { - MethodName: "QueryBuyBackDepositStats", - Handler: _Query_QueryBuyBackDepositStats_Handler, - }, - { - MethodName: "QueryBorrowStats", - Handler: _Query_QueryBorrowStats_Handler, + MethodName: "QueryReserveBuybackAssetData", + Handler: _Query_QueryReserveBuybackAssetData_Handler, }, { MethodName: "QueryAuctionParams", @@ -3563,7 +2988,7 @@ func (m *QueryPairResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryAssetRatesStatsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAssetRatesParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3573,12 +2998,12 @@ func (m *QueryAssetRatesStatsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetRatesStatsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetRatesStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3598,7 +3023,7 @@ func (m *QueryAssetRatesStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *QueryAssetRatesStatsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAssetRatesParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3608,12 +3033,12 @@ func (m *QueryAssetRatesStatsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetRatesStatsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetRatesStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3630,10 +3055,10 @@ func (m *QueryAssetRatesStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, e i-- dAtA[i] = 0x12 } - if len(m.AssetRatesStats) > 0 { - for iNdEx := len(m.AssetRatesStats) - 1; iNdEx >= 0; iNdEx-- { + if len(m.AssetRatesParams) > 0 { + for iNdEx := len(m.AssetRatesParams) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.AssetRatesStats[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AssetRatesParams[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -3647,7 +3072,7 @@ func (m *QueryAssetRatesStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryAssetRatesStatRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAssetRatesParamRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3657,12 +3082,12 @@ func (m *QueryAssetRatesStatRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetRatesStatRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetRatesStatRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -3675,7 +3100,7 @@ func (m *QueryAssetRatesStatRequest) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryAssetRatesStatResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAssetRatesParamResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -3685,18 +3110,18 @@ func (m *QueryAssetRatesStatResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetRatesStatResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetRatesStatResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAssetRatesParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.AssetRatesStat.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AssetRatesparams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -4335,7 +3760,7 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) MarshalToSizedBuffer(dAtA []byte) return len(dAtA) - i, nil } -func (m *QueryAssetStatsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPoolAssetLBMappingRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4345,12 +3770,12 @@ func (m *QueryAssetStatsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetStatsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPoolAssetLBMappingRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPoolAssetLBMappingRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -4368,7 +3793,7 @@ func (m *QueryAssetStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryAssetStatsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPoolAssetLBMappingResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4378,18 +3803,18 @@ func (m *QueryAssetStatsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryAssetStatsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPoolAssetLBMappingResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAssetStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPoolAssetLBMappingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.AssetStats.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.PoolAssetLBMapping.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -4401,7 +3826,7 @@ func (m *QueryAssetStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryModuleBalanceRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryReserveBuybackAssetDataRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4411,25 +3836,25 @@ func (m *QueryModuleBalanceRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryModuleBalanceRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryReserveBuybackAssetDataRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryModuleBalanceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryReserveBuybackAssetDataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.PoolId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.PoolId)) + if m.AssetId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AssetId)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func (m *QueryModuleBalanceResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryReserveBuybackAssetDataResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4439,18 +3864,18 @@ func (m *QueryModuleBalanceResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryModuleBalanceResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryReserveBuybackAssetDataResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryModuleBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryReserveBuybackAssetDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.ModuleBalance.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ReserveBuybackAssetData.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -4462,7 +3887,7 @@ func (m *QueryModuleBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryDepositStatsRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryAuctionParamRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4472,20 +3897,25 @@ func (m *QueryDepositStatsRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryDepositStatsRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAuctionParamRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryDepositStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAuctionParamRequest) 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 *QueryDepositStatsResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryAuctionParamResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -4495,18 +3925,18 @@ func (m *QueryDepositStatsResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryDepositStatsResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryAuctionParamResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryDepositStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryAuctionParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size, err := m.DepositStats.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.AuctionParams.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -4518,323 +3948,223 @@ func (m *QueryDepositStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *QueryUserDepositStatsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ } - return dAtA[:n], nil -} - -func (m *QueryUserDepositStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + dAtA[offset] = uint8(v) + return base } - -func (m *QueryUserDepositStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - return len(dAtA) - i, nil + return n } -func (m *QueryUserDepositStatsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryUserDepositStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryLendsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryUserDepositStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryLendsResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size, err := m.UserDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Lends) > 0 { + for _, e := range m.Lends { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryReserveDepositStatsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return dAtA[:n], nil -} - -func (m *QueryReserveDepositStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return n } -func (m *QueryReserveDepositStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryLendRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - return len(dAtA) - i, nil + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } + return n } -func (m *QueryReserveDepositStatsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryLendResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil + var l int + _ = l + l = m.Lend.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryReserveDepositStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryAllLendByOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *QueryReserveDepositStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryAllLendByOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size, err := m.ReserveDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Lends) > 0 { + for _, e := range m.Lends { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryBuyBackDepositStatsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return dAtA[:n], nil + return n } -func (m *QueryBuyBackDepositStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBuyBackDepositStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryBuyBackDepositStatsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryAllLendByOwnerAndPoolRequest) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *QueryBuyBackDepositStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBuyBackDepositStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - { - size, err := m.BuyBackDepositStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryBorrowStatsRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) } - return dAtA[:n], nil -} - -func (m *QueryBorrowStatsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryBorrowStatsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryBorrowStatsResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return dAtA[:n], nil -} - -func (m *QueryBorrowStatsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return n } -func (m *QueryBorrowStatsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryAllLendByOwnerAndPoolResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - { - size, err := m.BorrowStats.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Lends) > 0 { + for _, e := range m.Lends { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryAuctionParamRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return dAtA[:n], nil -} - -func (m *QueryAuctionParamRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) + return n } -func (m *QueryAuctionParamRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i +func (m *QueryPairsRequest) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l - if m.AppId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.AppId)) - i-- - dAtA[i] = 0x8 + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - return len(dAtA) - i, nil + return n } -func (m *QueryAuctionParamResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +func (m *QueryPairsResponse) Size() (n int) { + if m == nil { + return 0 } - return dAtA[:n], nil -} - -func (m *QueryAuctionParamResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAuctionParamResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i var l int _ = l - { - size, err := m.AuctionParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.ExtendedPairs) > 0 { + for _, e := range m.ExtendedPairs { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) } - 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 - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - dAtA[offset] = uint8(v) - return base + return n } -func (m *QueryParamsRequest) Size() (n int) { + +func (m *QueryPairRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) + } return n } -func (m *QueryParamsResponse) Size() (n int) { +func (m *QueryPairResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Params.Size() + l = m.ExtendedPair.Size() n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryLendsRequest) Size() (n int) { +func (m *QueryAssetRatesParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -4847,14 +4177,14 @@ func (m *QueryLendsRequest) Size() (n int) { return n } -func (m *QueryLendsResponse) Size() (n int) { +func (m *QueryAssetRatesParamsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Lends) > 0 { - for _, e := range m.Lends { + if len(m.AssetRatesParams) > 0 { + for _, e := range m.AssetRatesParams { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -4866,7 +4196,7 @@ func (m *QueryLendsResponse) Size() (n int) { return n } -func (m *QueryLendRequest) Size() (n int) { +func (m *QueryAssetRatesParamRequest) Size() (n int) { if m == nil { return 0 } @@ -4878,27 +4208,23 @@ func (m *QueryLendRequest) Size() (n int) { return n } -func (m *QueryLendResponse) Size() (n int) { +func (m *QueryAssetRatesParamResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.Lend.Size() + l = m.AssetRatesparams.Size() n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryAllLendByOwnerRequest) Size() (n int) { +func (m *QueryPoolsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -4906,14 +4232,14 @@ func (m *QueryAllLendByOwnerRequest) Size() (n int) { return n } -func (m *QueryAllLendByOwnerResponse) Size() (n int) { +func (m *QueryPoolsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Lends) > 0 { - for _, e := range m.Lends { + if len(m.Pools) > 0 { + for _, e := range m.Pools { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -4925,46 +4251,30 @@ func (m *QueryAllLendByOwnerResponse) Size() (n int) { return n } -func (m *QueryAllLendByOwnerAndPoolRequest) Size() (n int) { +func (m *QueryPoolRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.Owner) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Id != 0 { + n += 1 + sovQuery(uint64(m.Id)) } return n } -func (m *QueryAllLendByOwnerAndPoolResponse) Size() (n int) { +func (m *QueryPoolResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Lends) > 0 { - for _, e := range m.Lends { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } + l = m.Pool.Size() + n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryPairsRequest) Size() (n int) { +func (m *QueryAssetToPairMappingsRequest) Size() (n int) { if m == nil { return 0 } @@ -4977,14 +4287,14 @@ func (m *QueryPairsRequest) Size() (n int) { return n } -func (m *QueryPairsResponse) Size() (n int) { +func (m *QueryAssetToPairMappingsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.ExtendedPairs) > 0 { - for _, e := range m.ExtendedPairs { + if len(m.AssetToPairMappings) > 0 { + for _, e := range m.AssetToPairMappings { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -4996,30 +4306,33 @@ func (m *QueryPairsResponse) Size() (n int) { return n } -func (m *QueryPairRequest) Size() (n int) { +func (m *QueryAssetToPairMappingRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) + if m.AssetId != 0 { + n += 1 + sovQuery(uint64(m.AssetId)) + } + if m.PoolId != 0 { + n += 1 + sovQuery(uint64(m.PoolId)) } return n } -func (m *QueryPairResponse) Size() (n int) { +func (m *QueryAssetToPairMappingResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.ExtendedPair.Size() + l = m.AssetToPairMapping.Size() n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryAssetRatesStatsRequest) Size() (n int) { +func (m *QueryBorrowsRequest) Size() (n int) { if m == nil { return 0 } @@ -5032,175 +4345,7 @@ func (m *QueryAssetRatesStatsRequest) Size() (n int) { return n } -func (m *QueryAssetRatesStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AssetRatesStats) > 0 { - for _, e := range m.AssetRatesStats { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAssetRatesStatRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } - return n -} - -func (m *QueryAssetRatesStatResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AssetRatesStat.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryPoolsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryPoolsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Pools) > 0 { - for _, e := range m.Pools { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryPoolRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovQuery(uint64(m.Id)) - } - return n -} - -func (m *QueryPoolResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Pool.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryAssetToPairMappingsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAssetToPairMappingsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.AssetToPairMappings) > 0 { - for _, e := range m.AssetToPairMappings { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryAssetToPairMappingRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AssetId != 0 { - n += 1 + sovQuery(uint64(m.AssetId)) - } - if m.PoolId != 0 { - n += 1 + sovQuery(uint64(m.PoolId)) - } - return n -} - -func (m *QueryAssetToPairMappingResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AssetToPairMapping.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryBorrowsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryBorrowsResponse) Size() (n int) { +func (m *QueryBorrowsResponse) Size() (n int) { if m == nil { return 0 } @@ -5317,7 +4462,7 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) Size() (n int) { return n } -func (m *QueryAssetStatsRequest) Size() (n int) { +func (m *QueryPoolAssetLBMappingRequest) Size() (n int) { if m == nil { return 0 } @@ -5332,1362 +4477,70 @@ func (m *QueryAssetStatsRequest) Size() (n int) { return n } -func (m *QueryAssetStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AssetStats.Size() - n += 1 + l + sovQuery(uint64(l)) - 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 (m *QueryDepositStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryDepositStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.DepositStats.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryUserDepositStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryUserDepositStatsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.UserDepositStats.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryReserveDepositStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryReserveDepositStatsResponse) Size() (n int) { +func (m *QueryPoolAssetLBMappingResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.ReserveDepositStats.Size() + l = m.PoolAssetLBMapping.Size() n += 1 + l + sovQuery(uint64(l)) return n } -func (m *QueryBuyBackDepositStatsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *QueryBuyBackDepositStatsResponse) Size() (n int) { +func (m *QueryReserveBuybackAssetDataRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.BuyBackDepositStats.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryBorrowStatsRequest) Size() (n int) { - if m == nil { - return 0 + if m.AssetId != 0 { + n += 1 + sovQuery(uint64(m.AssetId)) } - var l int - _ = l return n } -func (m *QueryBorrowStatsResponse) Size() (n int) { +func (m *QueryReserveBuybackAssetDataResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = m.BorrowStats.Size() + l = m.ReserveBuybackAssetData.Size() n += 1 + l + sovQuery(uint64(l)) return n } - -func (m *QueryAuctionParamRequest) 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 *QueryAuctionParamResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.AuctionParams.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QueryParamsRequest) 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: QueryParamsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - 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 *QueryParamsResponse) 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: QueryParamsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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.Params.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 (m *QueryLendsRequest) 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: QueryLendsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLendsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 (m *QueryLendsResponse) 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: QueryLendsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLendsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lends", 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.Lends = append(m.Lends, LendAsset{}) - if err := m.Lends[len(m.Lends)-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 Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 (m *QueryLendRequest) 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: QueryLendRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLendRequest: 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= 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 *QueryLendResponse) 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: QueryLendResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryLendResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lend", 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.Lend.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 (m *QueryAllLendByOwnerRequest) 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: QueryAllLendByOwnerRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllLendByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 (m *QueryAllLendByOwnerResponse) 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: QueryAllLendByOwnerResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllLendByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lends", 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.Lends = append(m.Lends, LendAsset{}) - if err := m.Lends[len(m.Lends)-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 Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 (m *QueryAllLendByOwnerAndPoolRequest) 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: QueryAllLendByOwnerAndPoolRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 (m *QueryAllLendByOwnerAndPoolResponse) 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: QueryAllLendByOwnerAndPoolResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lends", 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.Lends = append(m.Lends, LendAsset{}) - if err := m.Lends[len(m.Lends)-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 Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 (m *QueryPairsRequest) 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: QueryPairsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPairsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.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 (m *QueryPairsResponse) 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: QueryPairsResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPairsResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedPairs", 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.ExtendedPairs = append(m.ExtendedPairs, Extended_Pair{}) - if err := m.ExtendedPairs[len(m.ExtendedPairs)-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 Pagination", 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 m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.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 - } + +func (m *QueryAuctionParamRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AppId != 0 { + n += 1 + sovQuery(uint64(m.AppId)) } + return n +} - if iNdEx > l { - return io.ErrUnexpectedEOF +func (m *QueryAuctionParamResponse) Size() (n int) { + if m == nil { + return 0 } - return nil + var l int + _ = l + l = m.AuctionParams.Size() + n += 1 + l + sovQuery(uint64(l)) + return n } -func (m *QueryPairRequest) Unmarshal(dAtA []byte) error { + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6710,31 +4563,12 @@ func (m *QueryPairRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPairRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPairRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: 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 ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -6756,7 +4590,7 @@ func (m *QueryPairRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPairResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6779,15 +4613,15 @@ func (m *QueryPairResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPairResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPairResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtendedPair", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -6814,7 +4648,7 @@ func (m *QueryPairResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ExtendedPair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -6839,7 +4673,7 @@ func (m *QueryPairResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetRatesStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryLendsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6862,10 +4696,10 @@ func (m *QueryAssetRatesStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetRatesStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLendsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetRatesStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLendsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -6925,7 +4759,7 @@ func (m *QueryAssetRatesStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetRatesStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryLendsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -6948,15 +4782,15 @@ func (m *QueryAssetRatesStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetRatesStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLendsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetRatesStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLendsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Lends", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -6983,8 +4817,8 @@ func (m *QueryAssetRatesStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetRatesStats = append(m.AssetRatesStats, AssetRatesStats{}) - if err := m.AssetRatesStats[len(m.AssetRatesStats)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Lends = append(m.Lends, LendAsset{}) + if err := m.Lends[len(m.Lends)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7045,7 +4879,7 @@ func (m *QueryAssetRatesStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetRatesStatRequest) Unmarshal(dAtA []byte) error { +func (m *QueryLendRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7068,10 +4902,10 @@ func (m *QueryAssetRatesStatRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetRatesStatRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLendRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetRatesStatRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLendRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -7114,7 +4948,7 @@ func (m *QueryAssetRatesStatRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetRatesStatResponse) Unmarshal(dAtA []byte) error { +func (m *QueryLendResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7137,15 +4971,15 @@ func (m *QueryAssetRatesStatResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetRatesStatResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryLendResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetRatesStatResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryLendResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesStat", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Lend", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7172,7 +5006,7 @@ func (m *QueryAssetRatesStatResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AssetRatesStat.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Lend.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7197,7 +5031,7 @@ func (m *QueryAssetRatesStatResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllLendByOwnerRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7220,13 +5054,45 @@ func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllLendByOwnerRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllLendByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -7283,7 +5149,7 @@ func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllLendByOwnerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7306,15 +5172,15 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllLendByOwnerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllLendByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pools", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Lends", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7341,8 +5207,8 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Pools = append(m.Pools, Pool{}) - if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.Lends = append(m.Lends, LendAsset{}) + if err := m.Lends[len(m.Lends)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7403,7 +5269,7 @@ func (m *QueryPoolsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllLendByOwnerAndPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7426,17 +5292,49 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) } - m.Id = 0 + m.PoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -7446,11 +5344,47 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Id |= uint64(b&0x7F) << shift + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7472,7 +5406,7 @@ func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllLendByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7495,15 +5429,49 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllLendByOwnerAndPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Lends", 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.Lends = append(m.Lends, LendAsset{}) + if err := m.Lends[len(m.Lends)-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 Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7530,7 +5498,10 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7555,7 +5526,7 @@ func (m *QueryPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetToPairMappingsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPairsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7578,10 +5549,10 @@ func (m *QueryAssetToPairMappingsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetToPairMappingsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPairsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetToPairMappingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPairsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -7641,7 +5612,7 @@ func (m *QueryAssetToPairMappingsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetToPairMappingsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPairsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7664,15 +5635,15 @@ func (m *QueryAssetToPairMappingsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetToPairMappingsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPairsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetToPairMappingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPairsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetToPairMappings", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExtendedPairs", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7699,8 +5670,8 @@ func (m *QueryAssetToPairMappingsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AssetToPairMappings = append(m.AssetToPairMappings, AssetToPairMapping{}) - if err := m.AssetToPairMappings[len(m.AssetToPairMappings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ExtendedPairs = append(m.ExtendedPairs, Extended_Pair{}) + if err := m.ExtendedPairs[len(m.ExtendedPairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7761,7 +5732,7 @@ func (m *QueryAssetToPairMappingsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetToPairMappingRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPairRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7784,36 +5755,17 @@ func (m *QueryAssetToPairMappingRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetToPairMappingRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPairRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetToPairMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPairRequest: 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 ErrIntOverflowQuery - } - 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 PoolId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - m.PoolId = 0 + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -7823,7 +5775,7 @@ func (m *QueryAssetToPairMappingRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -7849,7 +5801,7 @@ func (m *QueryAssetToPairMappingRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetToPairMappingResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPairResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7872,15 +5824,15 @@ func (m *QueryAssetToPairMappingResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetToPairMappingResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPairResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetToPairMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPairResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetToPairMapping", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExtendedPair", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -7907,7 +5859,7 @@ func (m *QueryAssetToPairMappingResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AssetToPairMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ExtendedPair.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -7932,7 +5884,7 @@ func (m *QueryAssetToPairMappingResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAssetRatesParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -7955,10 +5907,10 @@ func (m *QueryBorrowsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetRatesParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetRatesParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8018,7 +5970,7 @@ func (m *QueryBorrowsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAssetRatesParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8041,15 +5993,15 @@ func (m *QueryBorrowsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetRatesParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetRatesParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Borrows", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesParams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8076,8 +6028,8 @@ func (m *QueryBorrowsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Borrows = append(m.Borrows, BorrowAsset{}) - if err := m.Borrows[len(m.Borrows)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.AssetRatesParams = append(m.AssetRatesParams, AssetRatesParams{}) + if err := m.AssetRatesParams[len(m.AssetRatesParams)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8138,7 +6090,7 @@ func (m *QueryBorrowsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAssetRatesParamRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8161,10 +6113,10 @@ func (m *QueryBorrowRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetRatesParamRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetRatesParamRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8207,7 +6159,7 @@ func (m *QueryBorrowRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAssetRatesParamResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8230,15 +6182,15 @@ func (m *QueryBorrowResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetRatesParamResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetRatesParamResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Borrow", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetRatesparams", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8265,7 +6217,7 @@ func (m *QueryBorrowResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Borrow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.AssetRatesparams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8290,7 +6242,7 @@ func (m *QueryBorrowResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPoolsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8313,17 +6265,17 @@ func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -8333,23 +6285,111 @@ func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Owner = string(dAtA[iNdEx:postIndex]) + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryPoolsResponse) 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: QueryPoolsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pools", 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.Pools = append(m.Pools, Pool{}) + if err := m.Pools[len(m.Pools)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex case 2: if wireType != 2 { @@ -8381,7 +6421,7 @@ func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Pagination == nil { - m.Pagination = &query.PageRequest{} + m.Pagination = &query.PageResponse{} } if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -8408,7 +6448,7 @@ func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8431,17 +6471,17 @@ func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Borrows", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } - var msglen int + m.Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -8451,29 +6491,64 @@ func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.Id |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthQuery + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + msglen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.Borrows = append(m.Borrows, BorrowAsset{}) - if err := m.Borrows[len(m.Borrows)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPoolResponse) 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 } - iNdEx = postIndex - case 2: + 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: QueryPoolResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pool", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8500,10 +6575,7 @@ func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Pool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8528,7 +6600,7 @@ func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllBorrowByOwnerAndPoolRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAssetToPairMappingsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8551,64 +6623,13 @@ func (m *QueryAllBorrowByOwnerAndPoolRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetToPairMappingsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetToPairMappingsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - 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 ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Owner = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - 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 - } - } - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -8665,7 +6686,7 @@ func (m *QueryAllBorrowByOwnerAndPoolRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllBorrowByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAssetToPairMappingsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8688,15 +6709,15 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetToPairMappingsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetToPairMappingsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Borrows", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetToPairMappings", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8723,8 +6744,8 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Borrows = append(m.Borrows, BorrowAsset{}) - if err := m.Borrows[len(m.Borrows)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.AssetToPairMappings = append(m.AssetToPairMappings, AssetToPairMapping{}) + if err := m.AssetToPairMappings[len(m.AssetToPairMappings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8785,7 +6806,7 @@ func (m *QueryAllBorrowByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAssetToPairMappingRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8808,10 +6829,10 @@ func (m *QueryAssetStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetToPairMappingRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetToPairMappingRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -8873,7 +6894,7 @@ func (m *QueryAssetStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAssetStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAssetToPairMappingResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8896,15 +6917,15 @@ func (m *QueryAssetStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAssetStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAssetToPairMappingResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAssetStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAssetToPairMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AssetToPairMapping", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -8931,7 +6952,7 @@ func (m *QueryAssetStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.AssetStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.AssetToPairMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -8956,7 +6977,7 @@ func (m *QueryAssetStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryModuleBalanceRequest) Unmarshal(dAtA []byte) error { +func (m *QueryBorrowsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -8979,17 +7000,17 @@ func (m *QueryModuleBalanceRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryModuleBalanceRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBorrowsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryModuleBalanceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBorrowsRequest: 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) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - m.PoolId = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -8999,11 +7020,28 @@ func (m *QueryModuleBalanceRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift + 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -9025,7 +7063,7 @@ func (m *QueryModuleBalanceRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryModuleBalanceResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBorrowsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9048,15 +7086,49 @@ func (m *QueryModuleBalanceResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryModuleBalanceResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBorrowsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryModuleBalanceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBorrowsResponse: 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) + return fmt.Errorf("proto: wrong wireType = %d for field Borrows", 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.Borrows = append(m.Borrows, BorrowAsset{}) + if err := m.Borrows[len(m.Borrows)-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 Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9083,7 +7155,10 @@ func (m *QueryModuleBalanceResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ModuleBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -9108,7 +7183,7 @@ func (m *QueryModuleBalanceResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryDepositStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryBorrowRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9131,12 +7206,31 @@ func (m *QueryDepositStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryDepositStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBorrowRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDepositStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBorrowRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Id |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -9158,7 +7252,7 @@ func (m *QueryDepositStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryDepositStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBorrowResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9181,15 +7275,15 @@ func (m *QueryDepositStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryDepositStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBorrowResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryDepositStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBorrowResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DepositStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Borrow", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9216,7 +7310,7 @@ func (m *QueryDepositStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.DepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Borrow.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -9241,7 +7335,7 @@ func (m *QueryDepositStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserDepositStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllBorrowByOwnerRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9251,25 +7345,93 @@ func (m *QueryUserDepositStatsRequest) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowQuery } - if iNdEx >= l { + 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: QueryAllBorrowByOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllBorrowByOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryUserDepositStatsRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserDepositStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -9291,7 +7453,7 @@ func (m *QueryUserDepositStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryUserDepositStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllBorrowByOwnerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9314,15 +7476,49 @@ func (m *QueryUserDepositStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryUserDepositStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllBorrowByOwnerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserDepositStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllBorrowByOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserDepositStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Borrows", 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.Borrows = append(m.Borrows, BorrowAsset{}) + if err := m.Borrows[len(m.Borrows)-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 Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9349,7 +7545,10 @@ func (m *QueryUserDepositStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.UserDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -9374,7 +7573,7 @@ func (m *QueryUserDepositStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryReserveDepositStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllBorrowByOwnerAndPoolRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9397,12 +7596,99 @@ func (m *QueryReserveDepositStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryReserveDepositStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryReserveDepositStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -9424,7 +7710,7 @@ func (m *QueryReserveDepositStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryReserveDepositStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllBorrowByOwnerAndPoolResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9447,15 +7733,49 @@ func (m *QueryReserveDepositStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryReserveDepositStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryReserveDepositStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllBorrowByOwnerAndPoolResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReserveDepositStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Borrows", 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.Borrows = append(m.Borrows, BorrowAsset{}) + if err := m.Borrows[len(m.Borrows)-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 Pagination", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9482,7 +7802,10 @@ func (m *QueryReserveDepositStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ReserveDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -9507,7 +7830,7 @@ func (m *QueryReserveDepositStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBuyBackDepositStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPoolAssetLBMappingRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9530,12 +7853,50 @@ func (m *QueryBuyBackDepositStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBuyBackDepositStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolAssetLBMappingRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBuyBackDepositStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolAssetLBMappingRequest: 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 ErrIntOverflowQuery + } + 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 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:]) @@ -9557,7 +7918,7 @@ func (m *QueryBuyBackDepositStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBuyBackDepositStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPoolAssetLBMappingResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9580,15 +7941,15 @@ func (m *QueryBuyBackDepositStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBuyBackDepositStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPoolAssetLBMappingResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBuyBackDepositStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPoolAssetLBMappingResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BuyBackDepositStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PoolAssetLBMapping", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9615,7 +7976,7 @@ func (m *QueryBuyBackDepositStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BuyBackDepositStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PoolAssetLBMapping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -9640,7 +8001,7 @@ func (m *QueryBuyBackDepositStatsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowStatsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryReserveBuybackAssetDataRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9663,12 +8024,31 @@ func (m *QueryBorrowStatsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowStatsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryReserveBuybackAssetDataRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowStatsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryReserveBuybackAssetDataRequest: 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -9690,7 +8070,7 @@ func (m *QueryBorrowStatsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryBorrowStatsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryReserveBuybackAssetDataResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -9713,15 +8093,15 @@ func (m *QueryBorrowStatsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryBorrowStatsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryReserveBuybackAssetDataResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryBorrowStatsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryReserveBuybackAssetDataResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BorrowStats", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReserveBuybackAssetData", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -9748,7 +8128,7 @@ func (m *QueryBorrowStatsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.BorrowStats.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ReserveBuybackAssetData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/lend/types/query.pb.gw.go b/x/lend/types/query.pb.gw.go index 368cd6feb..3eb6c7af3 100644 --- a/x/lend/types/query.pb.gw.go +++ b/x/lend/types/query.pb.gw.go @@ -398,43 +398,43 @@ func local_request_Query_QueryPair_0(ctx context.Context, marshaler runtime.Mars } var ( - filter_Query_QueryAssetRatesStats_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_QueryAssetRatesParams_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_QueryAssetRatesStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetRatesStatsRequest +func request_Query_QueryAssetRatesParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetRatesParamsRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAssetRatesStats_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAssetRatesParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.QueryAssetRatesStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryAssetRatesParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAssetRatesStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetRatesStatsRequest +func local_request_Query_QueryAssetRatesParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetRatesParamsRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAssetRatesStats_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QueryAssetRatesParams_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.QueryAssetRatesStats(ctx, &protoReq) + msg, err := server.QueryAssetRatesParams(ctx, &protoReq) return msg, metadata, err } -func request_Query_QueryAssetRatesStat_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetRatesStatRequest +func request_Query_QueryAssetRatesParam_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetRatesParamRequest var metadata runtime.ServerMetadata var ( @@ -455,13 +455,13 @@ func request_Query_QueryAssetRatesStat_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := client.QueryAssetRatesStat(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryAssetRatesParam(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAssetRatesStat_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetRatesStatRequest +func local_request_Query_QueryAssetRatesParam_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAssetRatesParamRequest var metadata runtime.ServerMetadata var ( @@ -482,7 +482,7 @@ func local_request_Query_QueryAssetRatesStat_0(ctx context.Context, marshaler ru return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) } - msg, err := server.QueryAssetRatesStat(ctx, &protoReq) + msg, err := server.QueryAssetRatesParam(ctx, &protoReq) return msg, metadata, err } @@ -945,8 +945,8 @@ func local_request_Query_QueryAllBorrowByOwnerAndPool_0(ctx context.Context, mar } -func request_Query_QueryAssetStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetStatsRequest +func request_Query_QueryPoolAssetLBMapping_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolAssetLBMappingRequest var metadata runtime.ServerMetadata var ( @@ -978,13 +978,13 @@ func request_Query_QueryAssetStats_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) } - msg, err := client.QueryAssetStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryPoolAssetLBMapping(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_QueryAssetStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAssetStatsRequest +func local_request_Query_QueryPoolAssetLBMapping_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPoolAssetLBMappingRequest var metadata runtime.ServerMetadata var ( @@ -1016,13 +1016,13 @@ func local_request_Query_QueryAssetStats_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) } - msg, err := server.QueryAssetStats(ctx, &protoReq) + msg, err := server.QueryPoolAssetLBMapping(ctx, &protoReq) return msg, metadata, err } -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 +func request_Query_QueryReserveBuybackAssetData_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryReserveBuybackAssetDataRequest var metadata runtime.ServerMetadata var ( @@ -1032,24 +1032,24 @@ func request_Query_QueryModuleBalance_0(ctx context.Context, marshaler runtime.M _ = err ) - val, ok = pathParams["pool_id"] + val, ok = pathParams["asset_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "asset_id") } - protoReq.PoolId, err = runtime.Uint64(val) + protoReq.AssetId, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "asset_id", err) } - msg, err := client.QueryModuleBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryReserveBuybackAssetData(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 +func local_request_Query_QueryReserveBuybackAssetData_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryReserveBuybackAssetDataRequest var metadata runtime.ServerMetadata var ( @@ -1059,108 +1059,18 @@ func local_request_Query_QueryModuleBalance_0(ctx context.Context, marshaler run _ = err ) - val, ok = pathParams["pool_id"] + val, ok = pathParams["asset_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "pool_id") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "asset_id") } - protoReq.PoolId, err = runtime.Uint64(val) + protoReq.AssetId, err = runtime.Uint64(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "pool_id", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "asset_id", err) } - msg, err := server.QueryModuleBalance(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryDepositStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryDepositStats(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryUserDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUserDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryUserDepositStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryUserDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUserDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryUserDepositStats(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryReserveDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryReserveDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryReserveDepositStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryReserveDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryReserveDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryReserveDepositStats(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryBuyBackDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBuyBackDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryBuyBackDepositStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryBuyBackDepositStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBuyBackDepositStatsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryBuyBackDepositStats(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_QueryBorrowStats_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBorrowStatsRequest - var metadata runtime.ServerMetadata - - msg, err := client.QueryBorrowStats(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryBorrowStats_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryBorrowStatsRequest - var metadata runtime.ServerMetadata - - msg, err := server.QueryBorrowStats(ctx, &protoReq) + msg, err := server.QueryReserveBuybackAssetData(ctx, &protoReq) return msg, metadata, err } @@ -1386,7 +1296,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryAssetRatesStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAssetRatesParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1397,7 +1307,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAssetRatesStats_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryAssetRatesParams_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 { @@ -1405,11 +1315,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryAssetRatesStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAssetRatesParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAssetRatesStat_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAssetRatesParam_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1420,7 +1330,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryAssetRatesStat_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryAssetRatesParam_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 { @@ -1428,7 +1338,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryAssetRatesStat_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAssetRatesParam_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1616,76 +1526,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryAssetStats_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_QueryAssetStats_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_QueryAssetStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - 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()...) - - }) - - mux.Handle("GET", pattern_Query_QueryDepositStats_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_QueryDepositStats_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_QueryDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUserDepositStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryPoolAssetLBMapping_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1696,7 +1537,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryUserDepositStats_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryPoolAssetLBMapping_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 { @@ -1704,11 +1545,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryUserDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryPoolAssetLBMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryReserveDepositStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryReserveBuybackAssetData_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -1719,7 +1560,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_QueryReserveDepositStats_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryReserveBuybackAssetData_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 { @@ -1727,53 +1568,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_QueryReserveDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryBuyBackDepositStats_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_QueryBuyBackDepositStats_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_QueryBuyBackDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryBorrowStats_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_QueryBorrowStats_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_QueryBorrowStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryReserveBuybackAssetData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -1981,7 +1776,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryAssetRatesStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAssetRatesParams_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) @@ -1990,18 +1785,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAssetRatesStats_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryAssetRatesParams_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_QueryAssetRatesStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAssetRatesParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryAssetRatesStat_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryAssetRatesParam_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) @@ -2010,14 +1805,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryAssetRatesStat_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryAssetRatesParam_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_QueryAssetRatesStat_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryAssetRatesParam_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2181,27 +1976,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryAssetStats_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_QueryAssetStats_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_QueryAssetStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryModuleBalance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryPoolAssetLBMapping_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) @@ -2210,18 +1985,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryModuleBalance_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryPoolAssetLBMapping_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()...) + forward_Query_QueryPoolAssetLBMapping_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_QueryDepositStats_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryReserveBuybackAssetData_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) @@ -2230,94 +2005,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_QueryDepositStats_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryReserveBuybackAssetData_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_QueryDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryUserDepositStats_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_QueryUserDepositStats_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_QueryUserDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryReserveDepositStats_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_QueryReserveDepositStats_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_QueryReserveDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryBuyBackDepositStats_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_QueryBuyBackDepositStats_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_QueryBuyBackDepositStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_QueryBorrowStats_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_QueryBorrowStats_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_QueryBorrowStats_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryReserveBuybackAssetData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -2359,9 +2054,9 @@ var ( pattern_Query_QueryPair_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", "pairs", "id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAssetRatesStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "asset_rates_stats"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAssetRatesParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "asset_rates_params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAssetRatesStat_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", "asset_rates_stats", "id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryAssetRatesParam_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", "asset_rates_param", "id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "pools"}, "", runtime.AssumeColonVerbOpt(false))) @@ -2379,19 +2074,9 @@ var ( pattern_Query_QueryAllBorrowByOwnerAndPool_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", "lend", "v1beta1", "borrows_by_owner_pool", "owner", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryAssetStats_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", "lend", "v1beta1", "asset_stats", "asset_id", "pool_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))) - - pattern_Query_QueryDepositStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "deposit_stats"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_QueryPoolAssetLBMapping_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", "lend", "v1beta1", "pool_asset_lb_mapping", "asset_id", "pool_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryUserDepositStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "user_deposit_stats"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryReserveDepositStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "reserve_deposit_stats"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryBuyBackDepositStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "buy_back_deposit_stats"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_QueryBorrowStats_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"comdex", "lend", "v1beta1", "borrow_stats"}, "", runtime.AssumeColonVerbOpt(false))) + 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))) ) @@ -2411,9 +2096,9 @@ var ( forward_Query_QueryPair_0 = runtime.ForwardResponseMessage - forward_Query_QueryAssetRatesStats_0 = runtime.ForwardResponseMessage + forward_Query_QueryAssetRatesParams_0 = runtime.ForwardResponseMessage - forward_Query_QueryAssetRatesStat_0 = runtime.ForwardResponseMessage + forward_Query_QueryAssetRatesParam_0 = runtime.ForwardResponseMessage forward_Query_QueryPools_0 = runtime.ForwardResponseMessage @@ -2431,19 +2116,9 @@ var ( forward_Query_QueryAllBorrowByOwnerAndPool_0 = runtime.ForwardResponseMessage - forward_Query_QueryAssetStats_0 = runtime.ForwardResponseMessage - - forward_Query_QueryModuleBalance_0 = runtime.ForwardResponseMessage - - forward_Query_QueryDepositStats_0 = runtime.ForwardResponseMessage - - forward_Query_QueryUserDepositStats_0 = runtime.ForwardResponseMessage - - forward_Query_QueryReserveDepositStats_0 = runtime.ForwardResponseMessage - - forward_Query_QueryBuyBackDepositStats_0 = runtime.ForwardResponseMessage + forward_Query_QueryPoolAssetLBMapping_0 = runtime.ForwardResponseMessage - forward_Query_QueryBorrowStats_0 = runtime.ForwardResponseMessage + forward_Query_QueryReserveBuybackAssetData_0 = runtime.ForwardResponseMessage forward_Query_QueryAuctionParams_0 = runtime.ForwardResponseMessage ) diff --git a/x/liquidation/expected/keeper.go b/x/liquidation/expected/keeper.go index 1338a4bbd..720c5424e 100644 --- a/x/liquidation/expected/keeper.go +++ b/x/liquidation/expected/keeper.go @@ -61,28 +61,23 @@ type EsmKeeper interface { } type LendKeeper interface { - GetBorrows(ctx sdk.Context) (userBorrows lendtypes.BorrowMapping, found bool) + GetBorrows(ctx sdk.Context) (userBorrows []uint64, found bool) GetBorrow(ctx sdk.Context, id uint64) (borrow lendtypes.BorrowAsset, found bool) GetLendPair(ctx sdk.Context, id uint64) (pair lendtypes.Extended_Pair, found bool) - GetAssetRatesStats(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesStats, found bool) - VerifyCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error - CalculateCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) + GetAssetRatesParams(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesParams, found bool) + VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error + CalculateCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) DeleteBorrow(ctx sdk.Context, id uint64) - DeleteBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) - UpdateUserBorrowIDMapping(ctx sdk.Context, lendOwner string, borrowID uint64, isInsert bool) error - UpdateBorrowIDByOwnerAndPoolMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, poolID uint64, isInsert bool) error - UpdateBorrowIdsMapping(ctx sdk.Context, borrowID uint64, isInsert bool) error CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found bool) - GetBorrowStats(ctx sdk.Context) (borrowStats lendtypes.DepositStats, found bool) - SetBorrowStats(ctx sdk.Context, borrowStats lendtypes.DepositStats) - GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID uint64) (AssetStats lendtypes.AssetStats, found bool) - SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, AssetStats lendtypes.AssetStats) - UpdateBorrowStats(ctx sdk.Context, pair lendtypes.Extended_Pair, borrowPos lendtypes.BorrowAsset, amount sdk.Int, inc bool) + + GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID uint64) (AssetStats lendtypes.PoolAssetLBMapping, found bool) + SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, AssetStats lendtypes.PoolAssetLBMapping) 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) } type RewardsKeeper interface { diff --git a/x/liquidation/keeper/alias.go b/x/liquidation/keeper/alias.go index 3203d0415..e10353365 100644 --- a/x/liquidation/keeper/alias.go +++ b/x/liquidation/keeper/alias.go @@ -97,7 +97,7 @@ func (k Keeper) GetESMStatus(ctx sdk.Context, id uint64) (esmtypes.ESMStatus, bo return k.esm.GetESMStatus(ctx, id) } -func (k Keeper) GetBorrows(ctx sdk.Context) (userBorrows lendtypes.BorrowMapping, found bool) { +func (k Keeper) GetBorrows(ctx sdk.Context) (userBorrows []uint64, found bool) { return k.lend.GetBorrows(ctx) } @@ -109,16 +109,16 @@ func (k Keeper) GetLendPair(ctx sdk.Context, id uint64) (pair lendtypes.Extended return k.lend.GetLendPair(ctx, id) } -func (k Keeper) GetAssetRatesStats(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesStats, found bool) { - return k.lend.GetAssetRatesStats(ctx, assetID) +func (k Keeper) GetAssetRatesParams(ctx sdk.Context, assetID uint64) (assetRatesStats lendtypes.AssetRatesParams, found bool) { + return k.lend.GetAssetRatesParams(ctx, assetID) } -func (k Keeper) VerifyCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error { - return k.lend.VerifyCollaterlizationRatio(ctx, amountIn, assetIn, amountOut, assetOut, liquidationThreshold) +func (k Keeper) VerifyCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset, liquidationThreshold sdk.Dec) error { + return k.lend.VerifyCollateralizationRatio(ctx, amountIn, assetIn, amountOut, assetOut, liquidationThreshold) } -func (k Keeper) CalculateLendCollaterlizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) { - return k.lend.CalculateCollaterlizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) +func (k Keeper) CalculateLendCollateralizationRatio(ctx sdk.Context, amountIn sdk.Int, assetIn assettypes.Asset, amountOut sdk.Int, assetOut assettypes.Asset) (sdk.Dec, error) { + return k.lend.CalculateCollateralizationRatio(ctx, amountIn, assetIn, amountOut, assetOut) } func (k Keeper) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) { @@ -129,22 +129,6 @@ func (k Keeper) DeleteBorrow(ctx sdk.Context, id uint64) { k.lend.DeleteBorrow(ctx, id) } -func (k Keeper) DeleteBorrowForAddressByPair(ctx sdk.Context, address sdk.AccAddress, pairID uint64) { - k.lend.DeleteBorrowForAddressByPair(ctx, address, pairID) -} - -func (k Keeper) UpdateUserBorrowIDMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, isInsert bool) error { - return k.lend.UpdateUserBorrowIDMapping(ctx, borrowOwner, borrowID, isInsert) -} - -func (k Keeper) UpdateBorrowIDByOwnerAndPoolMapping(ctx sdk.Context, borrowOwner string, borrowID uint64, poolID uint64, isInsert bool) error { - return k.lend.UpdateBorrowIDByOwnerAndPoolMapping(ctx, borrowOwner, borrowID, poolID, isInsert) -} - -func (k Keeper) UpdateBorrowIdsMapping(ctx sdk.Context, borrowID uint64, isInsert bool) error { - return k.lend.UpdateBorrowIdsMapping(ctx, borrowID, isInsert) -} - func (k Keeper) CreteNewBorrow(ctx sdk.Context, liqBorrow liquidationtypes.LockedVault) { k.lend.CreteNewBorrow(ctx, liqBorrow) } @@ -153,25 +137,25 @@ func (k Keeper) GetPool(ctx sdk.Context, id uint64) (pool lendtypes.Pool, found return k.lend.GetPool(ctx, id) } -func (k Keeper) GetBorrowStats(ctx sdk.Context) (borrowStats lendtypes.DepositStats, found bool) { - return k.lend.GetBorrowStats(ctx) -} - -func (k Keeper) SetBorrowStats(ctx sdk.Context, borrowStats lendtypes.DepositStats) { - k.lend.SetBorrowStats(ctx, borrowStats) -} +//func (k Keeper) GetBorrowStats(ctx sdk.Context) (borrowStats lendtypes.DepositStats, found bool) { +// return k.lend.GetBorrowStats(ctx) +//} +// +//func (k Keeper) SetBorrowStats(ctx sdk.Context, borrowStats lendtypes.DepositStats) { +// k.lend.SetBorrowStats(ctx, borrowStats) +//} -func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, assetID, poolID uint64) (AssetStats lendtypes.AssetStats, found bool) { - return k.lend.GetAssetStatsByPoolIDAndAssetID(ctx, assetID, poolID) +func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (AssetStats lendtypes.PoolAssetLBMapping, found bool) { + return k.lend.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) } -func (k Keeper) SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, AssetStats lendtypes.AssetStats) { +func (k Keeper) SetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, AssetStats lendtypes.PoolAssetLBMapping) { k.lend.SetAssetStatsByPoolIDAndAssetID(ctx, AssetStats) } -func (k Keeper) UpdateBorrowStats(ctx sdk.Context, pair lendtypes.Extended_Pair, borrowPos lendtypes.BorrowAsset, amount sdk.Int, inc bool) { - k.lend.UpdateBorrowStats(ctx, pair, borrowPos, amount, inc) -} +//func (k Keeper) UpdateBorrowStats(ctx sdk.Context, pair lendtypes.Extended_Pair, borrowPos lendtypes.BorrowAsset, amount sdk.Int, inc bool) { +// k.lend.UpdateBorrowStats(ctx, pair, borrowPos, amount, inc) +//} func (k Keeper) SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, coin sdk.Coins) error { if coin.IsZero() { @@ -212,3 +196,7 @@ func (k Keeper) DutchActivator(ctx sdk.Context, lockedVault liquidationtypes.Loc func (k Keeper) LendDutchActivator(ctx sdk.Context, lockedVault liquidationtypes.LockedVault) error { return k.auction.LendDutchActivator(ctx, lockedVault) } + +func (k Keeper) SetBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset) { + k.lend.SetBorrow(ctx, borrow) +} diff --git a/x/liquidation/keeper/liquidate_borrow.go b/x/liquidation/keeper/liquidate_borrow.go index e232b4600..a9312474d 100644 --- a/x/liquidation/keeper/liquidate_borrow.go +++ b/x/liquidation/keeper/liquidate_borrow.go @@ -18,7 +18,7 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { if !found { liquidationOffsetHolder = types.NewLiquidationOffsetHolder(lendtypes.AppID, 0) } - borrowIDs := borrows.BorrowIDs + borrowIDs := borrows start, end := types.GetSliceStartEndForLiquidations(len(borrowIDs), int(liquidationOffsetHolder.CurrentOffset), int(params.LiquidationBatchSize)) if start == end { @@ -42,85 +42,69 @@ func (k Keeper) LiquidateBorrows(ctx sdk.Context) error { assetOut, _ := k.GetAsset(ctx, lendPair.AssetOut) var currentCollateralizationRatio sdk.Dec - liqThreshold, _ := k.GetAssetRatesStats(ctx, lendPair.AssetIn) - liqThresholdBridgedAssetOne, _ := k.GetAssetRatesStats(ctx, pool.FirstBridgedAssetID) - liqThresholdBridgedAssetTwo, _ := k.GetAssetRatesStats(ctx, pool.SecondBridgedAssetID) - firstBridgedAsset, _ := k.GetAsset(ctx, pool.FirstBridgedAssetID) + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range pool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } + } + + liqThreshold, _ := k.GetAssetRatesParams(ctx, lendPair.AssetIn) + liqThresholdBridgedAssetOne, _ := k.GetAssetRatesParams(ctx, firstTransitAssetID) + liqThresholdBridgedAssetTwo, _ := k.GetAssetRatesParams(ctx, secondTransitAssetID) + firstBridgedAsset, _ := k.GetAsset(ctx, firstTransitAssetID) if borrowPos.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { - currentCollateralizationRatio, _ = k.CalculateLendCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut, assetOut) + currentCollateralizationRatio, _ = k.CalculateLendCollateralizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.AmountOut.Amount.Add(borrowPos.InterestAccumulated.TruncateInt()), assetOut) if sdk.Dec.GT(currentCollateralizationRatio, liqThreshold.LiquidationThreshold) { err := k.CreateLockedBorrow(ctx, borrowPos, currentCollateralizationRatio, lendPos.AppID) if err != nil { continue } - k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, borrowIDs[l]) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) - if err != nil { - continue - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) - if err != nil { - continue - } - err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) + borrowPos.IsLiquidated = true + k.SetBorrow(ctx, borrowPos) + lockedVaultID := k.GetLockedVaultID(ctx) + err = k.UpdateLockedBorrows(ctx, lendPos.AppID, lockedVaultID+1) if err != nil { - continue + return nil } } } else { if borrowPos.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { - currentCollateralizationRatio, _ = k.CalculateLendCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut, assetOut) + currentCollateralizationRatio, _ = k.CalculateLendCollateralizationRatio(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) if err != nil { continue } - k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, borrowIDs[l]) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) - if err != nil { - continue - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) + borrowPos.IsLiquidated = true + k.SetBorrow(ctx, borrowPos) + lockedVaultID := k.GetLockedVaultID(ctx) + err = k.UpdateLockedBorrows(ctx, lendPos.AppID, lockedVaultID+1) if err != nil { - continue - } - err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) - if err != nil { - continue + return nil } } } else { - currentCollateralizationRatio, _ = k.CalculateLendCollaterlizationRatio(ctx, borrowPos.AmountIn.Amount, assetIn, borrowPos.UpdatedAmountOut, assetOut) + currentCollateralizationRatio, _ = k.CalculateLendCollateralizationRatio(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) if err != nil { continue } - k.UpdateBorrowStats(ctx, lendPair, borrowPos, borrowPos.AmountOut.Amount, false) - k.DeleteBorrow(ctx, borrowIDs[l]) - err = k.UpdateUserBorrowIDMapping(ctx, lendPos.Owner, borrowIDs[l], false) + borrowPos.IsLiquidated = true + k.SetBorrow(ctx, borrowPos) + lockedVaultID := k.GetLockedVaultID(ctx) + err = k.UpdateLockedBorrows(ctx, lendPos.AppID, lockedVaultID+1) if err != nil { - continue - } - err = k.UpdateBorrowIDByOwnerAndPoolMapping(ctx, lendPos.Owner, borrowIDs[l], lendPair.AssetOutPoolID, false) - if err != nil { - continue - } - err = k.UpdateBorrowIdsMapping(ctx, borrowIDs[l], false) - if err != nil { - continue + return nil } } } } - lockedVaultID := k.GetLockedVaultID(ctx) - err := k.UpdateLockedBorrows(ctx, lendPos.AppID, lockedVaultID) - if err != nil { - return nil - } } liquidationOffsetHolder.CurrentOffset = uint64(end) k.SetLiquidationOffsetHolder(ctx, types.VaultLiquidationsOffsetPrefix, liquidationOffsetHolder) @@ -147,7 +131,7 @@ func (k Keeper) CreateLockedBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset Owner: lendPos.Owner, AmountIn: borrow.AmountIn.Amount, AmountOut: borrow.AmountOut.Amount, - UpdatedAmountOut: borrow.AmountOut.Amount.Add(borrow.Interest_Accumulated), + UpdatedAmountOut: borrow.AmountOut.Amount.Add(borrow.InterestAccumulated.TruncateInt()), Initiator: types.ModuleName, IsAuctionComplete: false, IsAuctionInProgress: false, @@ -156,7 +140,7 @@ func (k Keeper) CreateLockedBorrow(ctx sdk.Context, borrow lendtypes.BorrowAsset CollateralToBeAuctioned: sdk.ZeroDec(), LiquidationTimestamp: ctx.BlockTime(), SellOffHistory: nil, - InterestAccumulated: borrow.Interest_Accumulated, + InterestAccumulated: sdk.ZeroInt(), Kind: kind, } k.SetLockedVault(ctx, value) @@ -172,10 +156,20 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, appID, id uint64) error { lendPos, _ := k.GetLend(ctx, borrowMetaData.LendingId) pool, _ := k.GetPool(ctx, lendPos.PoolID) var unliquidatePointPercentage sdk.Dec - firstBridgeAsset, _ := k.GetAsset(ctx, pool.FirstBridgedAssetID) - firstBridgeAssetStats, _ := k.GetAssetRatesStats(ctx, pool.FirstBridgedAssetID) - secondBridgeAssetStats, _ := k.GetAssetRatesStats(ctx, pool.SecondBridgedAssetID) - liqThreshold, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range pool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } + } + + firstBridgeAsset, _ := k.GetAsset(ctx, firstTransitAssetID) + firstBridgeAssetStats, _ := k.GetAssetRatesParams(ctx, firstTransitAssetID) + secondBridgeAssetStats, _ := k.GetAssetRatesParams(ctx, secondTransitAssetID) + liqThreshold, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) if !borrowMetaData.BridgedAssetAmount.Amount.Equal(sdk.ZeroInt()) { if borrowMetaData.BridgedAssetAmount.Denom == firstBridgeAsset.Denom { @@ -187,14 +181,14 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, appID, id uint64) error { unliquidatePointPercentage = liqThreshold.LiquidationThreshold } - assetRatesStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) + assetRatesStats, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) if (!lockedVault.IsAuctionInProgress && !lockedVault.IsAuctionComplete) || (lockedVault.IsAuctionComplete && lockedVault.CurrentCollaterlisationRatio.GTE(unliquidatePointPercentage)) { assetIn, _ := k.GetAsset(ctx, pair.AssetIn) assetOut, _ := k.GetAsset(ctx, pair.AssetOut) - collateralizationRatio, err := k.CalculateLendCollaterlizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) + collateralizationRatio, err := k.CalculateLendCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if err != nil { return nil } @@ -243,7 +237,7 @@ func (k Keeper) UpdateLockedBorrows(ctx sdk.Context, appID, id uint64) error { cAsset, _ := k.GetAsset(ctx, assetRatesStats.CAssetID) updatedLockedVault.AmountIn = updatedLockedVault.AmountIn.Sub(sdk.NewInt(liquidationDeductionAmount.TruncateInt64())) lendPos.AmountIn.Amount = lendPos.AmountIn.Amount.Sub(sdk.NewInt(liquidationDeductionAmount.TruncateInt64())) - lendPos.UpdatedAmountIn = lendPos.UpdatedAmountIn.Sub(sdk.NewInt(liquidationDeductionAmount.TruncateInt64())) + lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Sub(sdk.NewInt(liquidationDeductionAmount.TruncateInt64())) err = k.BurnCoin(ctx, pool.ModuleName, sdk.NewCoin(cAsset.Denom, sdk.NewInt(penaltyToReserveAmount.TruncateInt64()))) if err != nil { return err @@ -276,10 +270,19 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if borrowMetadata != nil { lendPos, _ := k.GetLend(ctx, borrowMetadata.LendingId) assetInPool, _ := k.GetPool(ctx, lendPos.PoolID) - firstBridgedAsset, _ := k.GetAsset(ctx, assetInPool.FirstBridgedAssetID) + var firstTransitAssetID, secondTransitAssetID uint64 + for _, data := range assetInPool.AssetData { + if data.AssetTransitType == 2 { + firstTransitAssetID = data.AssetID + } + if data.AssetTransitType == 3 { + secondTransitAssetID = data.AssetID + } + } + firstBridgedAsset, _ := k.GetAsset(ctx, firstTransitAssetID) userAddress, _ := sdk.AccAddressFromBech32(lockedVault.Owner) pair, _ := k.GetLendPair(ctx, lockedVault.ExtendedPairId) - assetStats, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) + assetStats, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) assetIn, _ := k.GetAsset(ctx, pair.AssetIn) assetOut, _ := k.GetAsset(ctx, pair.AssetOut) cAssetIn, _ := k.GetAsset(ctx, assetStats.CAssetID) @@ -287,7 +290,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if lockedVault.IsAuctionComplete { if borrowMetadata.BridgedAssetAmount.IsZero() { // also calculate the current collaterlization ratio to ensure there is no sudden changes - liqThreshold, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) + liqThreshold, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) unliquidatePointPercentage := liqThreshold.LiquidationThreshold if lockedVault.AmountOut.IsZero() { @@ -295,7 +298,6 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) if err = k.SendCoinFromModuleToAccount(ctx, assetInPool.ModuleName, userAddress, sdk.NewCoin(cAssetIn.Denom, lockedVault.AmountIn)); err != nil { return err @@ -303,7 +305,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Add(lockedVault.AmountIn) k.SetLend(ctx, lendPos) } - newCalculatedCollateralizationRatio, _ := k.CalculateLendCollaterlizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) + newCalculatedCollateralizationRatio, _ := k.CalculateLendCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if newCalculatedCollateralizationRatio.GT(unliquidatePointPercentage) { updatedLockedVault := lockedVault updatedLockedVault.CurrentCollaterlisationRatio = newCalculatedCollateralizationRatio @@ -319,14 +321,13 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.CreteNewBorrow(ctx, lockedVault) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) } } else { if borrowMetadata.BridgedAssetAmount.Denom == firstBridgedAsset.Denom { - liqThresholdAssetIn, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) - liqThresholdFirstBridgedAsset, _ := k.GetAssetRatesStats(ctx, assetInPool.FirstBridgedAssetID) + liqThresholdAssetIn, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) + liqThresholdFirstBridgedAsset, _ := k.GetAssetRatesParams(ctx, firstTransitAssetID) liqThreshold := liqThresholdAssetIn.LiquidationThreshold.Mul(liqThresholdFirstBridgedAsset.LiquidationThreshold) unliquidatePointPercentage := liqThreshold @@ -335,7 +336,6 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) if err = k.SendCoinFromModuleToAccount(ctx, assetInPool.ModuleName, userAddress, sdk.NewCoin(cAssetIn.Denom, lockedVault.AmountIn)); err != nil { return err @@ -343,7 +343,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Add(lockedVault.AmountIn) k.SetLend(ctx, lendPos) } - newCalculatedCollateralizationRatio, _ := k.CalculateLendCollaterlizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) + newCalculatedCollateralizationRatio, _ := k.CalculateLendCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if newCalculatedCollateralizationRatio.GT(unliquidatePointPercentage) { updatedLockedVault := lockedVault updatedLockedVault.CurrentCollaterlisationRatio = newCalculatedCollateralizationRatio @@ -359,13 +359,12 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.CreteNewBorrow(ctx, lockedVault) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) } } else { - liqThresholdAssetIn, _ := k.GetAssetRatesStats(ctx, pair.AssetIn) - liqThresholdSecondBridgedAsset, _ := k.GetAssetRatesStats(ctx, assetInPool.SecondBridgedAssetID) + liqThresholdAssetIn, _ := k.GetAssetRatesParams(ctx, pair.AssetIn) + liqThresholdSecondBridgedAsset, _ := k.GetAssetRatesParams(ctx, secondTransitAssetID) liqThreshold := liqThresholdAssetIn.LiquidationThreshold.Mul(liqThresholdSecondBridgedAsset.LiquidationThreshold) unliquidatePointPercentage := liqThreshold @@ -374,7 +373,6 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) if err = k.SendCoinFromModuleToAccount(ctx, assetInPool.ModuleName, userAddress, sdk.NewCoin(cAssetIn.Denom, lockedVault.AmountIn)); err != nil { return err @@ -382,7 +380,7 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc lendPos.AvailableToBorrow = lendPos.AvailableToBorrow.Add(lockedVault.AmountIn) k.SetLend(ctx, lendPos) } - newCalculatedCollateralizationRatio, _ := k.CalculateLendCollaterlizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) + newCalculatedCollateralizationRatio, _ := k.CalculateLendCollateralizationRatio(ctx, lockedVault.AmountIn, assetIn, lockedVault.UpdatedAmountOut, assetOut) if newCalculatedCollateralizationRatio.GT(unliquidatePointPercentage) { updatedLockedVault := lockedVault updatedLockedVault.CurrentCollaterlisationRatio = newCalculatedCollateralizationRatio @@ -398,7 +396,6 @@ func (k Keeper) UnLiquidateLockedBorrows(ctx sdk.Context, appID, id uint64, dutc if err != nil { return err } - k.DeleteBorrowForAddressByPair(ctx, userAddress, lockedVault.ExtendedPairId) k.CreteNewBorrow(ctx, lockedVault) k.DeleteLockedVault(ctx, lockedVault.AppId, lockedVault.LockedVaultId) } diff --git a/x/locker/module.go b/x/locker/module.go index d3f1ab645..4d84488a5 100644 --- a/x/locker/module.go +++ b/x/locker/module.go @@ -1,6 +1,7 @@ package locker import ( + "context" "encoding/json" "fmt" @@ -73,6 +74,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } // GetTxCmd returns the capability module's root tx command. diff --git a/x/market/abci.go b/x/market/abci.go index ee9538ac9..ca2c05bff 100644 --- a/x/market/abci.go +++ b/x/market/abci.go @@ -1,35 +1,51 @@ package market 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" + bandoraclemoduletypes "github.com/comdex-official/comdex/x/bandoracle/types" "github.com/comdex-official/comdex/x/market/keeper" "github.com/comdex-official/comdex/x/market/types" + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/tendermint/tendermint/abci/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 { - block := k.GetLastBlockheight(ctx) - if block != types.Int64Zero { - if ctx.BlockHeight()%types.Int64Twenty-types.Int64One == types.Int64Zero && ctx.BlockHeight() > block+types.Int64TwentyOne { - assets := k.GetAssets(ctx) - for _, asset := range assets { - if asset.IsOraclePriceRequired { - k.SetRates(ctx, asset.Name) - k.SetMarketForAsset(ctx, asset.Id, asset.Name) - rate, _ := k.GetRates(ctx, asset.Name) - scriptID := k.GetFetchPriceMsg(ctx).OracleScriptID - market := types.Market{ - Symbol: asset.Name, - ScriptID: scriptID, - Rates: rate, + if k.GetOracleValidationResult(ctx) { + block := k.GetLastBlockheight(ctx) + if block != types.Int64Zero { + if ctx.BlockHeight()%types.Int64Twenty == types.Int64Zero && ctx.BlockHeight() != block && k.GetCheckFlag(ctx) { + assets := k.GetAssets(ctx) + id := k.GetLastFetchPriceID(ctx) + data, _ := k.GetFetchPriceResult(ctx, bandoraclemoduletypes.OracleRequestID(id)) + scriptID := k.GetFetchPriceMsg(ctx).OracleScriptID + index := -1 + length := len(data.Rates) + for _, asset := range assets { + if asset.IsOraclePriceRequired && data.Rates != nil { + index = index + 1 + if length > index { + k.UpdatePriceList(ctx, asset.Id, scriptID, data.Rates[index]) + } + + // below code to be removed + // k.SetRates(ctx, asset.Name) + // k.SetMarketForAsset(ctx, asset.Id, asset.Name) + // rate, _ := k.GetRates(ctx, asset.Name) + // scriptID := k.GetFetchPriceMsg(ctx).OracleScriptID + // var ( + // market = types.Market{ + // Symbol: asset.Name, + // ScriptID: scriptID, + // Rates: rate, + // } + // ) + // k.SetMarket(ctx, market) + // above code to be removed } - k.SetMarket(ctx, market) } } } @@ -37,3 +53,9 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { return nil }) } + +// set twa +// get 1 twa +// get all twa +// get current price for asset. - if price not active then error +// calculate asset price - if price not active then error diff --git a/x/market/expected/keeper.go b/x/market/expected/keeper.go index a106b18b8..73a36d890 100644 --- a/x/market/expected/keeper.go +++ b/x/market/expected/keeper.go @@ -28,6 +28,7 @@ type ScopedKeeper interface { } type AssetKeeper interface { + GetAsset(ctx sdk.Context, id uint64) (asset assettypes.Asset, found bool) GetAssets(ctx sdk.Context, id uint64) (assettypes.Asset, bool) GetPair(ctx sdk.Context, id uint64) (assettypes.Pair, bool) } @@ -37,4 +38,7 @@ type BandOracleKeeper interface { GetLastFetchPriceID(ctx sdk.Context) int64 GetLastBlockHeight(ctx sdk.Context) int64 GetFetchPriceMsg(ctx sdk.Context) types.MsgFetchPriceData + GetCheckFlag(ctx sdk.Context) bool + SetCheckFlag(ctx sdk.Context, flag bool) + GetOracleValidationResult(ctx sdk.Context) bool } diff --git a/x/market/keeper/alias.go b/x/market/keeper/alias.go index 826bb788a..9e5157004 100644 --- a/x/market/keeper/alias.go +++ b/x/market/keeper/alias.go @@ -24,6 +24,10 @@ func (k Keeper) GetAssets(ctx sdk.Context) (assets []types.Asset) { return k.assetKeeper.GetAssets(ctx) } +func (k Keeper) GetAsset(ctx sdk.Context, id uint64) (asset types.Asset, found bool) { + return k.assetKeeper.GetAsset(ctx, id) +} + func (k Keeper) GetLastFetchPriceID(ctx sdk.Context) int64 { return k.bandoraclekeeper.GetLastFetchPriceID(ctx) } @@ -35,3 +39,19 @@ func (k Keeper) GetLastBlockheight(ctx sdk.Context) int64 { func (k Keeper) GetFetchPriceMsg(ctx sdk.Context) bandoraclemoduletypes.MsgFetchPriceData { return k.bandoraclekeeper.GetFetchPriceMsg(ctx) } + +func (k Keeper) GetFetchPriceResult(ctx sdk.Context, id bandoraclemoduletypes.OracleRequestID) (bandoraclemoduletypes.FetchPriceResult, error) { + return k.bandoraclekeeper.GetFetchPriceResult(ctx, id) +} + +func (k Keeper) GetCheckFlag(ctx sdk.Context) bool { + return k.bandoraclekeeper.GetCheckFlag(ctx) +} + +func (k Keeper) SetCheckFlag(ctx sdk.Context, flag bool) { + k.bandoraclekeeper.SetCheckFlag(ctx, flag) +} + +func (k Keeper) GetOracleValidationResult(ctx sdk.Context) bool { + return k.bandoraclekeeper.GetOracleValidationResult(ctx) +} diff --git a/x/market/keeper/oracle.go b/x/market/keeper/oracle.go index 849a34664..d1d7f801f 100644 --- a/x/market/keeper/oracle.go +++ b/x/market/keeper/oracle.go @@ -165,18 +165,127 @@ func (k Keeper) GetMarketForAsset(ctx sdk.Context, id uint64) (market types.Mark } func (k Keeper) GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) { - if id != 3 { - market, found := k.GetMarketForAsset(ctx, id) - if !found { - return 0, false - } + market, found := k.GetMarketForAsset(ctx, id) + if !found { + return 0, false + } + + rates, found := k.GetPriceForMarket(ctx, market.Symbol) + if !found || rates == 0 { + return 0, false + } + return rates, found +} - rates, found := k.GetPriceForMarket(ctx, market.Symbol) - if !found || rates == 0 { - return 0, false +//////////// + +func (k Keeper) SetTwa(ctx sdk.Context, twa types.TimeWeightedAverage) { + var ( + store = k.Store(ctx) + key = types.TwaKey(twa.AssetID) + value = k.cdc.MustMarshal(&twa) + ) + + store.Set(key, value) +} + +func (k Keeper) GetTwa(ctx sdk.Context, id uint64) (twa types.TimeWeightedAverage, found bool) { + var ( + store = k.Store(ctx) + key = types.TwaKey(id) + value = store.Get(key) + ) + + if value == nil { + return twa, false + } + + k.cdc.MustUnmarshal(value, &twa) + return twa, true +} + +func (k Keeper) GetAllTwa(ctx sdk.Context) (twa []types.TimeWeightedAverage) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.TwaKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return } - return rates, found + }(iter) + + for ; iter.Valid(); iter.Next() { + var data types.TimeWeightedAverage + k.cdc.MustUnmarshal(iter.Value(), &data) + twa = append(twa, data) + } + + return twa +} + +func (k Keeper) UpdatePriceList(ctx sdk.Context, id, scriptID, rate uint64) { + twa, found := k.GetTwa(ctx, id) + if !found { + twa.AssetID = id + twa.ScriptID = scriptID + twa.Twa = 0 + twa.IsPriceActive = false + twa.PriceValue = append(twa.PriceValue, rate) + twa.CurrentIndex = 1 + k.SetTwa(ctx, twa) } else { - return 1000000, true + if twa.IsPriceActive { + twa.PriceValue[twa.CurrentIndex] = rate + twa.CurrentIndex = twa.CurrentIndex + 1 + twa.Twa = k.CalculateTwa(ctx, twa) + if twa.CurrentIndex == 30 { + twa.CurrentIndex = 0 + } + k.SetTwa(ctx, twa) + } else { + twa.PriceValue = append(twa.PriceValue, rate) + twa.CurrentIndex = twa.CurrentIndex + 1 + if twa.CurrentIndex == 30 { + twa.IsPriceActive = true + twa.CurrentIndex = 0 + twa.Twa = k.CalculateTwa(ctx, twa) + } + k.SetTwa(ctx, twa) + } + } +} + +func (k Keeper) CalculateTwa(ctx sdk.Context, twa types.TimeWeightedAverage) uint64 { + var sum uint64 + for _, price := range twa.PriceValue { + sum += price + } + twa.Twa = sum / 30 + return twa.Twa +} + +func (k Keeper) GetLatestPrice(ctx sdk.Context, id uint64) (price uint64, err error) { + twa, found := k.GetTwa(ctx, id) + if found && twa.IsPriceActive { + return twa.PriceValue[twa.CurrentIndex], nil + } + return 0, types.ErrorPriceNotActive +} + +func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) { + asset, found := k.GetAsset(ctx, id) + if !found { + return sdk.ZeroInt(), assetTypes.ErrorAssetDoesNotExist + } + 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))) + result := numerator.Quo(denominator) + return result.TruncateInt(), nil } + return sdk.ZeroInt(), types.ErrorPriceNotActive } diff --git a/x/market/types/errors.go b/x/market/types/errors.go index ca010792a..e997a4d14 100644 --- a/x/market/types/errors.go +++ b/x/market/types/errors.go @@ -8,4 +8,5 @@ var ( ErrorAssetDoesNotExist = errors.Register(ModuleName, 201, "asset does not exist") ErrorMarketForAssetDoesNotExist = errors.Register(ModuleName, 202, "market for asset does not exist") ErrorUnknownMsgType = errors.Register(ModuleName, 203, "unknown message type") + ErrorPriceNotActive = errors.Register(ModuleName, 204, "Price inactive") ) diff --git a/x/market/types/keys.go b/x/market/types/keys.go index 1e914aec5..10d6a1664 100644 --- a/x/market/types/keys.go +++ b/x/market/types/keys.go @@ -16,6 +16,7 @@ var ( MarketKeyPrefix = []byte{0x13} MarketForAssetKeyPrefix = []byte{0x22} PriceForMarketKeyPrefix = []byte{0x23} + TwaKeyPrefix = []byte{0x24} ) func MarketKey(symbol string) []byte { @@ -29,3 +30,7 @@ func MarketForAssetKey(id uint64) []byte { func PriceForMarketKey(symbol string) []byte { return append(PriceForMarketKeyPrefix, []byte(symbol)...) } + +func TwaKey(id uint64) []byte { + return append(TwaKeyPrefix, sdk.Uint64ToBigEndian(id)...) +} diff --git a/x/market/types/market.pb.go b/x/market/types/market.pb.go index c1533cb6b..5665d1c90 100644 --- a/x/market/types/market.pb.go +++ b/x/market/types/market.pb.go @@ -62,8 +62,51 @@ func (m *Market) XXX_DiscardUnknown() { var xxx_messageInfo_Market proto.InternalMessageInfo +type TimeWeightedAverage struct { + AssetID uint64 `protobuf:"varint,1,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` + ScriptID uint64 `protobuf:"varint,2,opt,name=script_id,json=scriptId,proto3" json:"script_id,omitempty" yaml:"script_id"` + Twa uint64 `protobuf:"varint,3,opt,name=twa,proto3" json:"twa,omitempty" yaml:"twa"` + CurrentIndex uint64 `protobuf:"varint,4,opt,name=current_index,json=currentIndex,proto3" json:"current_index,omitempty" yaml:"current_index"` + IsPriceActive bool `protobuf:"varint,5,opt,name=is_price_active,json=isPriceActive,proto3" json:"is_price_active,omitempty" yaml:"is_price_active"` + PriceValue []uint64 `protobuf:"varint,6,rep,packed,name=price_value,json=priceValue,proto3" json:"price_value,omitempty" yaml:"price_value"` +} + +func (m *TimeWeightedAverage) Reset() { *m = TimeWeightedAverage{} } +func (m *TimeWeightedAverage) String() string { return proto.CompactTextString(m) } +func (*TimeWeightedAverage) ProtoMessage() {} +func (*TimeWeightedAverage) Descriptor() ([]byte, []int) { + return fileDescriptor_c52e410514c538b6, []int{1} +} +func (m *TimeWeightedAverage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TimeWeightedAverage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TimeWeightedAverage.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 *TimeWeightedAverage) XXX_Merge(src proto.Message) { + xxx_messageInfo_TimeWeightedAverage.Merge(m, src) +} +func (m *TimeWeightedAverage) XXX_Size() int { + return m.Size() +} +func (m *TimeWeightedAverage) XXX_DiscardUnknown() { + xxx_messageInfo_TimeWeightedAverage.DiscardUnknown(m) +} + +var xxx_messageInfo_TimeWeightedAverage proto.InternalMessageInfo + func init() { proto.RegisterType((*Market)(nil), "comdex.market.v1beta1.Market") + proto.RegisterType((*TimeWeightedAverage)(nil), "comdex.market.v1beta1.TimeWeightedAverage") } func init() { @@ -71,23 +114,36 @@ func init() { } var fileDescriptor_c52e410514c538b6 = []byte{ - // 255 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0xcf, 0x4d, - 0x49, 0xad, 0xd0, 0xcf, 0x4d, 0x2c, 0xca, 0x4e, 0x2d, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, - 0x34, 0x84, 0x72, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x44, 0x21, 0x6a, 0xf4, 0xa0, 0x82, - 0x50, 0x35, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x15, 0xfa, 0x20, 0x16, 0x44, 0xb1, 0x52, - 0x07, 0x23, 0x17, 0x9b, 0x2f, 0x58, 0xa1, 0x90, 0x26, 0x17, 0x5b, 0x71, 0x65, 0x6e, 0x52, 0x7e, - 0x8e, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xe0, 0xa7, 0x7b, 0xf2, 0xbc, 0x95, 0x89, 0xb9, - 0x39, 0x56, 0x4a, 0x10, 0x71, 0xa5, 0x20, 0xa8, 0x02, 0x21, 0x5b, 0x2e, 0xce, 0xe2, 0xe4, 0xa2, - 0xcc, 0x82, 0x92, 0xf8, 0xcc, 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x16, 0x27, 0x85, 0x47, 0xf7, - 0xe4, 0x39, 0x82, 0xc1, 0x82, 0x9e, 0x2e, 0x9f, 0xee, 0xc9, 0x0b, 0x40, 0x75, 0xc2, 0x94, 0x29, - 0x05, 0x71, 0x40, 0xd8, 0x9e, 0x29, 0x42, 0x22, 0x5c, 0xac, 0x45, 0x89, 0x25, 0xa9, 0xc5, 0x12, - 0xcc, 0x20, 0xad, 0x41, 0x10, 0x8e, 0x53, 0xd0, 0x89, 0x87, 0x72, 0x0c, 0x2b, 0x1e, 0xc9, 0x31, - 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, - 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x41, 0x7a, 0x66, 0x49, 0x46, - 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc4, 0x93, 0xba, 0xf9, 0x69, 0x69, 0x99, 0xc9, 0x99, - 0x89, 0x39, 0x50, 0xbe, 0x3e, 0x3c, 0x68, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xbe, - 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0b, 0xd6, 0x78, 0xfb, 0x38, 0x01, 0x00, 0x00, + // 460 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x92, 0x41, 0x6f, 0xd3, 0x3e, + 0x18, 0xc6, 0x93, 0x7f, 0xba, 0xae, 0xf3, 0x7f, 0xd5, 0xc0, 0x74, 0x28, 0xda, 0xc1, 0x8e, 0x2c, + 0x24, 0xc2, 0x81, 0x86, 0x89, 0x13, 0x48, 0x1c, 0x1a, 0xe0, 0xd0, 0xc3, 0x24, 0x64, 0x26, 0x90, + 0xb8, 0x54, 0x6e, 0xe2, 0x65, 0x16, 0xcd, 0x12, 0x25, 0x6e, 0xbb, 0x7e, 0x03, 0x8e, 0x88, 0x4f, + 0xc1, 0x47, 0xd9, 0x71, 0x47, 0x4e, 0x16, 0xb8, 0xdf, 0x20, 0x9f, 0x00, 0xc5, 0xce, 0xa6, 0xc1, + 0x95, 0xdb, 0xfb, 0x3c, 0xfe, 0x3d, 0x7e, 0xde, 0xc3, 0x0b, 0x48, 0x52, 0xe4, 0x29, 0xbf, 0x8c, + 0x72, 0x56, 0x7d, 0xe6, 0x32, 0x5a, 0x1d, 0xcf, 0xb9, 0x64, 0xc7, 0x9d, 0x1c, 0x97, 0x55, 0x21, + 0x0b, 0x78, 0x68, 0x99, 0x71, 0x67, 0x76, 0xcc, 0xd1, 0x28, 0x2b, 0xb2, 0xc2, 0x10, 0x51, 0x3b, + 0x59, 0x98, 0x7c, 0x71, 0x41, 0xff, 0xc4, 0x80, 0xf0, 0x09, 0xe8, 0xd7, 0x9b, 0x7c, 0x5e, 0x2c, + 0x7c, 0x37, 0x70, 0xc3, 0xbd, 0xf8, 0x7e, 0xa3, 0xf0, 0x70, 0xc3, 0xf2, 0xc5, 0x4b, 0x62, 0x7d, + 0x42, 0x3b, 0x00, 0xbe, 0x02, 0x7b, 0x75, 0x52, 0x89, 0x52, 0xce, 0x44, 0xea, 0xff, 0x17, 0xb8, + 0x61, 0x2f, 0x0e, 0xb4, 0xc2, 0x83, 0xf7, 0xc6, 0x9c, 0xbe, 0x69, 0x14, 0xbe, 0xd7, 0x25, 0x6f, + 0x30, 0x42, 0x07, 0x76, 0x9e, 0xa6, 0x70, 0x04, 0x76, 0x2a, 0x26, 0x79, 0xed, 0x7b, 0x6d, 0x94, + 0x5a, 0x41, 0xbe, 0x79, 0xe0, 0xc1, 0xa9, 0xc8, 0xf9, 0x47, 0x2e, 0xb2, 0x73, 0xc9, 0xd3, 0xc9, + 0x8a, 0x57, 0x2c, 0xe3, 0xf0, 0x05, 0x18, 0xb0, 0xba, 0xe6, 0xa6, 0xcb, 0x35, 0x5d, 0x48, 0x2b, + 0xbc, 0x3b, 0x69, 0x3d, 0x53, 0x75, 0x60, 0xab, 0x6e, 0x20, 0x42, 0x77, 0xcd, 0x38, 0x4d, 0xff, + 0x75, 0xcf, 0xc7, 0xc0, 0x93, 0x6b, 0x66, 0xb7, 0x8c, 0x0f, 0xb5, 0xc2, 0xde, 0xe9, 0x9a, 0x35, + 0x0a, 0x03, 0x9b, 0x91, 0x6b, 0x46, 0x68, 0x4b, 0xc0, 0x13, 0x30, 0x4c, 0x96, 0x55, 0xc5, 0x2f, + 0xe4, 0x4c, 0x5c, 0xa4, 0xfc, 0xd2, 0xef, 0x99, 0x48, 0xa8, 0x15, 0xde, 0x7f, 0x6d, 0x1f, 0xa6, + 0xad, 0xdf, 0x28, 0x3c, 0xb2, 0xd9, 0x3f, 0x70, 0x42, 0xf7, 0x93, 0x3b, 0x14, 0x8c, 0xc1, 0x81, + 0xa8, 0x67, 0x65, 0x25, 0x12, 0x3e, 0x63, 0x89, 0x14, 0x2b, 0xee, 0xef, 0x04, 0x6e, 0x38, 0x88, + 0x8f, 0x1a, 0x85, 0x1f, 0xda, 0x0f, 0xfe, 0x02, 0x08, 0x1d, 0x8a, 0xfa, 0x5d, 0x6b, 0x4c, 0x8c, + 0x86, 0x6f, 0xc1, 0xff, 0xf6, 0x7d, 0xc5, 0x16, 0x4b, 0xee, 0xf7, 0x03, 0x2f, 0xec, 0xc5, 0x8f, + 0xb4, 0xc2, 0xc0, 0x50, 0x1f, 0x5a, 0xb7, 0x51, 0x18, 0xda, 0xdf, 0xee, 0xa0, 0x84, 0x82, 0xf2, + 0x96, 0x88, 0xe9, 0xd5, 0x2f, 0xe4, 0x7c, 0xd7, 0xc8, 0xb9, 0xd2, 0xc8, 0xbd, 0xd6, 0xc8, 0xfd, + 0xa9, 0x91, 0xfb, 0x75, 0x8b, 0x9c, 0xeb, 0x2d, 0x72, 0x7e, 0x6c, 0x91, 0xf3, 0xe9, 0x59, 0x26, + 0xe4, 0xf9, 0x72, 0x3e, 0x4e, 0x8a, 0x3c, 0xb2, 0x97, 0xf7, 0xb4, 0x38, 0x3b, 0x13, 0x89, 0x60, + 0x8b, 0x4e, 0x47, 0xb7, 0xf7, 0x2a, 0x37, 0x25, 0xaf, 0xe7, 0x7d, 0x73, 0x7a, 0xcf, 0x7f, 0x07, + 0x00, 0x00, 0xff, 0xff, 0x00, 0x58, 0x61, 0x4c, 0xcd, 0x02, 0x00, 0x00, } func (m *Market) Marshal() (dAtA []byte, err error) { @@ -130,6 +186,77 @@ func (m *Market) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TimeWeightedAverage) 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 *TimeWeightedAverage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TimeWeightedAverage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PriceValue) > 0 { + dAtA2 := make([]byte, len(m.PriceValue)*10) + var j1 int + for _, num := range m.PriceValue { + for num >= 1<<7 { + dAtA2[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA2[j1] = uint8(num) + j1++ + } + i -= j1 + copy(dAtA[i:], dAtA2[:j1]) + i = encodeVarintMarket(dAtA, i, uint64(j1)) + i-- + dAtA[i] = 0x32 + } + if m.IsPriceActive { + i-- + if m.IsPriceActive { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.CurrentIndex != 0 { + i = encodeVarintMarket(dAtA, i, uint64(m.CurrentIndex)) + i-- + dAtA[i] = 0x20 + } + if m.Twa != 0 { + i = encodeVarintMarket(dAtA, i, uint64(m.Twa)) + i-- + dAtA[i] = 0x18 + } + if m.ScriptID != 0 { + i = encodeVarintMarket(dAtA, i, uint64(m.ScriptID)) + i-- + dAtA[i] = 0x10 + } + if m.AssetID != 0 { + i = encodeVarintMarket(dAtA, i, uint64(m.AssetID)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintMarket(dAtA []byte, offset int, v uint64) int { offset -= sovMarket(v) base := offset @@ -160,6 +287,37 @@ func (m *Market) Size() (n int) { return n } +func (m *TimeWeightedAverage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AssetID != 0 { + n += 1 + sovMarket(uint64(m.AssetID)) + } + if m.ScriptID != 0 { + n += 1 + sovMarket(uint64(m.ScriptID)) + } + if m.Twa != 0 { + n += 1 + sovMarket(uint64(m.Twa)) + } + if m.CurrentIndex != 0 { + n += 1 + sovMarket(uint64(m.CurrentIndex)) + } + if m.IsPriceActive { + n += 2 + } + if len(m.PriceValue) > 0 { + l = 0 + for _, e := range m.PriceValue { + l += sovMarket(uint64(e)) + } + n += 1 + sovMarket(uint64(l)) + l + } + return n +} + func sovMarket(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -286,6 +444,228 @@ func (m *Market) Unmarshal(dAtA []byte) error { } return nil } +func (m *TimeWeightedAverage) 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 ErrIntOverflowMarket + } + 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: TimeWeightedAverage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TimeWeightedAverage: 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 ErrIntOverflowMarket + } + 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 ScriptID", wireType) + } + m.ScriptID = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ScriptID |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Twa", wireType) + } + m.Twa = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Twa |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentIndex", wireType) + } + m.CurrentIndex = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentIndex |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsPriceActive", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsPriceActive = bool(v != 0) + case 6: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PriceValue = append(m.PriceValue, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthMarket + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthMarket + } + 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.PriceValue) == 0 { + m.PriceValue = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMarket + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.PriceValue = append(m.PriceValue, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field PriceValue", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipMarket(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMarket + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipMarket(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/market/types/params.go b/x/market/types/params.go index 6e6aec273..64a21c639 100644 --- a/x/market/types/params.go +++ b/x/market/types/params.go @@ -9,6 +9,7 @@ var _ paramstypes.ParamSet = (*Params)(nil) const ( Int64Twenty = int64(20) Int64TwentyOne = int64(21) + Int64Ten = int64(10) Int64One = int64(1) Int64Zero = int64(0) ) diff --git a/x/rewards/abci.go b/x/rewards/abci.go index 572b0faf5..91692f133 100644 --- a/x/rewards/abci.go +++ b/x/rewards/abci.go @@ -24,6 +24,10 @@ func BeginBlocker(ctx sdk.Context, _ abci.RequestBeginBlock, k keeper.Keeper) { if err != nil { ctx.Logger().Error("error in DistributeExtRewardVault") } + err = k.DistributeExtRewardLend(ctx) + if err != nil { + ctx.Logger().Error("error in DistributeExtRewardLend") + } return nil }) } diff --git a/x/rewards/expected/keeper.go b/x/rewards/expected/keeper.go index 42f6c533f..57d2a1e8e 100644 --- a/x/rewards/expected/keeper.go +++ b/x/rewards/expected/keeper.go @@ -1,6 +1,7 @@ package expected import ( + lendtypes "github.com/comdex-official/comdex/x/lend/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -37,6 +38,7 @@ type AssetKeeper interface { type MarketKeeper interface { GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) + CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) } type LockerKeeper interface { @@ -92,3 +94,9 @@ type EsmKeeper interface { GetKillSwitchData(ctx sdk.Context, appID uint64) (esmtypes.KillSwitchParams, bool) GetESMStatus(ctx sdk.Context, id uint64) (esmStatus esmtypes.ESMStatus, found bool) } + +type LendKeeper interface { + GetBorrow(ctx sdk.Context, id uint64) (borrow lendtypes.BorrowAsset, found bool) + GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) + GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBMapping lendtypes.PoolAssetLBMapping, found bool) +} diff --git a/x/rewards/keeper/alias.go b/x/rewards/keeper/alias.go index 5d164457a..e6adeeea2 100644 --- a/x/rewards/keeper/alias.go +++ b/x/rewards/keeper/alias.go @@ -1,6 +1,7 @@ package keeper import ( + lendtypes "github.com/comdex-official/comdex/x/lend/types" sdk "github.com/cosmos/cosmos-sdk/types" assettypes "github.com/comdex-official/comdex/x/asset/types" @@ -177,3 +178,19 @@ func (k Keeper) GetLockerLookupTable(ctx sdk.Context, appID, assetID uint64) (lo func (k Keeper) GetAppExtendedPairVaultMappingData(ctx sdk.Context, appMappingID uint64, pairVaultID uint64) (appExtendedPairVaultData vaulttypes.AppExtendedPairVaultMappingData, found bool) { return k.vault.GetAppExtendedPairVaultMappingData(ctx, appMappingID, pairVaultID) } + +func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) { + return k.marketKeeper.CalcAssetPrice(ctx, id, amt) +} + +func (k Keeper) GetBorrow(ctx sdk.Context, id uint64) (borrow lendtypes.BorrowAsset, found bool) { + return k.lend.GetBorrow(ctx, id) +} + +func (k Keeper) GetLend(ctx sdk.Context, id uint64) (lend lendtypes.LendAsset, found bool) { + return k.lend.GetLend(ctx, id) +} + +func (k Keeper) GetAssetStatsByPoolIDAndAssetID(ctx sdk.Context, poolID, assetID uint64) (PoolAssetLBMapping lendtypes.PoolAssetLBMapping, found bool) { + return k.lend.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) +} diff --git a/x/rewards/keeper/iter.go b/x/rewards/keeper/iter.go index 0cb5b2f5a..5b0672085 100644 --- a/x/rewards/keeper/iter.go +++ b/x/rewards/keeper/iter.go @@ -163,3 +163,86 @@ func (k Keeper) CalculationOfRewards( } return newAm, nil } + +func (k Keeper) DistributeExtRewardLend(ctx sdk.Context) error { + extRewards := k.GetExternalRewardLends(ctx) + for i, v := range extRewards { + klwsParams, _ := k.GetKillSwitchData(ctx, v.AppMappingId) + if klwsParams.BreakerEnable { + return esmtypes.ErrCircuitBreakerEnabled + } + if v.IsActive { + epochTime, _ := k.GetEpochTime(ctx, v.EpochId) + et := epochTime.StartingTime + + timeNow := ctx.BlockTime().Unix() + + if et < timeNow { + if extRewards[i].IsActive { + epoch, _ := k.GetEpochTime(ctx, v.EpochId) + if epoch.Count < uint64(extRewards[i].DurationDays) { + // we will only consider the borrows of the pool and assetID defined + totalBorrowedAmt := sdk.ZeroInt() + for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { + for _, assetID := range rewardsAssetPoolData.AssetId { + borrowByPoolIDAssetID, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) + price, err := k.CalcAssetPrice(ctx, assetID, borrowByPoolIDAssetID.TotalBorrowed.Add(borrowByPoolIDAssetID.TotalStableBorrowed)) + if err != nil { + return err + } + totalBorrowedAmt = totalBorrowedAmt.Add(price) + } + } + totalRewardAmt, _ := k.CalcAssetPrice(ctx, v.RewardAssetId, v.TotalRewards.Amount) + totalAPR := sdk.NewDecFromInt(totalRewardAmt).Quo(sdk.NewDecFromInt(totalBorrowedAmt)) + var inverseRatesSum sdk.Dec + for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { + for _, assetID := range rewardsAssetPoolData.AssetId { + inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) + inverseRatesSum = inverseRatesSum.Add(inverseRate) + } + } + + for _, rewardsAssetPoolData := range v.RewardsAssetPoolData { + for _, assetID := range rewardsAssetPoolData.AssetId { + borrowIDs, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, rewardsAssetPoolData.CPoolId, assetID) + for _, borrowID := range borrowIDs.BorrowIds { + borrow, _ := k.GetBorrow(ctx, borrowID) + lend, _ := k.GetLend(ctx, borrow.LendingID) + inverseRate := k.InversingRates(ctx, assetID, rewardsAssetPoolData.CPoolId, totalRewardAmt) + numerator := totalAPR.Mul(inverseRate) + finalAPR := numerator.Quo(inverseRatesSum) + finalDailyRewardsNumerator := sdk.NewDecFromInt(borrow.AmountOut.Amount).Mul(finalAPR) + daysInYear, _ := sdk.NewDecFromStr(types.DaysInYear) + finalDailyRewardsPerUser := finalDailyRewardsNumerator.Quo(daysInYear) + user, _ := sdk.AccAddressFromBech32(lend.Owner) + if finalDailyRewardsPerUser.TruncateInt().GT(sdk.ZeroInt()) { + err := k.SendCoinFromModuleToAccount(ctx, types.ModuleName, user, sdk.NewCoin(v.TotalRewards.Denom, finalDailyRewardsPerUser.TruncateInt())) + if err != nil { + continue + } + } + } + } + } + epoch.Count = epoch.Count + types.UInt64One + epoch.StartingTime = timeNow + types.SecondsPerDay + k.SetEpochTime(ctx, epoch) + } else { + extRewards[i].IsActive = false + k.SetExternalRewardLend(ctx, extRewards[i]) + } + } + } + } + } + return nil +} + +func (k Keeper) InversingRates(ctx sdk.Context, assetID, poolID uint64, totalRewardAmt sdk.Int) sdk.Dec { + assetBorrowedByPoolIDandAssetID, _ := k.GetAssetStatsByPoolIDAndAssetID(ctx, poolID, assetID) + assetBorrowedByPoolIDandAssetIDAmt, _ := k.CalcAssetPrice(ctx, assetID, assetBorrowedByPoolIDandAssetID.TotalBorrowed.Add(assetBorrowedByPoolIDandAssetID.TotalStableBorrowed)) + tempRate := sdk.NewDecFromInt(assetBorrowedByPoolIDandAssetIDAmt).Quo(sdk.NewDecFromInt(totalRewardAmt)) + inverseRate := sdk.OneDec().Sub(tempRate) + return inverseRate +} diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 7bf9d8814..bd89cdd03 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -30,6 +30,7 @@ type ( liquidityKeeper expected.LiquidityKeeper marketKeeper expected.MarketKeeper esm expected.EsmKeeper + lend expected.LendKeeper } ) @@ -46,6 +47,7 @@ func NewKeeper( liquidityKeeper expected.LiquidityKeeper, marketKeeper expected.MarketKeeper, esm expected.EsmKeeper, + lend expected.LendKeeper, ) Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -65,6 +67,7 @@ func NewKeeper( liquidityKeeper: liquidityKeeper, marketKeeper: marketKeeper, esm: esm, + lend: lend, } } diff --git a/x/rewards/keeper/rewards.go b/x/rewards/keeper/rewards.go index 0882e26d2..2341456f4 100644 --- a/x/rewards/keeper/rewards.go +++ b/x/rewards/keeper/rewards.go @@ -347,6 +347,37 @@ func (k Keeper) SetExternalRewardVault(ctx sdk.Context, VaultExternalRewards typ store.Set(key, value) } +func (k Keeper) GetExternalRewardLends(ctx sdk.Context) (LendExternalRewards []types.LendExternalRewards) { + var ( + store = k.Store(ctx) + iter = sdk.KVStorePrefixIterator(store, types.ExternalRewardsLendKeyPrefix) + ) + + defer func(iter sdk.Iterator) { + err := iter.Close() + if err != nil { + return + } + }(iter) + + for ; iter.Valid(); iter.Next() { + var LendExternalReward types.LendExternalRewards + k.cdc.MustUnmarshal(iter.Value(), &LendExternalReward) + LendExternalRewards = append(LendExternalRewards, LendExternalReward) + } + + return LendExternalRewards +} + +func (k Keeper) SetExternalRewardLend(ctx sdk.Context, LendExternalRewards types.LendExternalRewards) { + var ( + store = k.Store(ctx) + key = types.ExternalRewardsLendMappingKey(LendExternalRewards.Id) + value = k.cdc.MustMarshal(&LendExternalRewards) + ) + store.Set(key, value) +} + // Wasm query checks func (k Keeper) GetRemoveWhitelistAppIDLockerRewardsCheck(ctx sdk.Context, appMappingID uint64, assetIDs uint64) (found bool, err string) { diff --git a/x/rewards/types/keys.go b/x/rewards/types/keys.go index d4590dc38..d64039599 100644 --- a/x/rewards/types/keys.go +++ b/x/rewards/types/keys.go @@ -24,6 +24,7 @@ const ( SecondsPerYear = 31557600 SecondsPerDay = 86400 + DaysInYear = "365.242" ) var ( @@ -35,6 +36,7 @@ var ( ExtRewardsVaultIDKey = []byte{0x16} EpochTimeIDKey = []byte{0x17} EpochForLockerKeyPrefix = []byte{0x20} + ExternalRewardsLendKeyPrefix = []byte{0x27} // EpochInfoByDurationKeyPrefix defines the prefix to store EpochInfo by duration. EpochInfoByDurationKeyPrefix = []byte{0x21} @@ -86,6 +88,10 @@ func ExternalRewardsVaultMappingKey(appMappingID uint64) []byte { return append(ExternalRewardsVaultKeyPrefix, sdk.Uint64ToBigEndian(appMappingID)...) } +func ExternalRewardsLendMappingKey(appMappingID uint64) []byte { + return append(ExternalRewardsLendKeyPrefix, sdk.Uint64ToBigEndian(appMappingID)...) +} + func LockerRewardsTrackerKey(id, appID uint64) []byte { return append(append(LockerRewardsTrackerKeyPrefix, sdk.Uint64ToBigEndian(id)...), sdk.Uint64ToBigEndian(appID)...) } diff --git a/x/rewards/types/rewards.pb.go b/x/rewards/types/rewards.pb.go index 27a46b3d2..adb5277b7 100644 --- a/x/rewards/types/rewards.pb.go +++ b/x/rewards/types/rewards.pb.go @@ -519,6 +519,198 @@ func (m *EpochTime) GetCount() uint64 { return 0 } +type LendExternalRewards struct { + Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty" yaml:"id"` + AppMappingId uint64 `protobuf:"varint,2,opt,name=app_mapping_id,json=appMappingId,proto3" json:"app_mapping_id,omitempty" yaml:"app_mapping_id"` + RewardsAssetPoolData []*RewardsAssetPoolData `protobuf:"bytes,3,rep,name=rewards_asset_pool_data,json=rewardsAssetPoolData,proto3" json:"rewards_asset_pool_data,omitempty" yaml:"rewards_asset_pool_data"` + TotalRewards github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,4,opt,name=total_rewards,json=totalRewards,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"total_rewards" yaml:"total_rewards"` + RewardAssetId uint64 `protobuf:"varint,5,opt,name=reward_asset_id,json=rewardAssetId,proto3" json:"reward_asset_id,omitempty" yaml:"epoch_id"` + DurationDays int64 `protobuf:"varint,6,opt,name=duration_days,json=durationDays,proto3" json:"duration_days,omitempty" yaml:"duration_days"` + IsActive bool `protobuf:"varint,7,opt,name=is_active,json=isActive,proto3" json:"is_active,omitempty" yaml:"is_active"` + AvailableRewards github_com_cosmos_cosmos_sdk_types.Coin `protobuf:"bytes,8,opt,name=available_rewards,json=availableRewards,proto3,casttype=github.com/cosmos/cosmos-sdk/types.Coin" json:"available_rewards" yaml:"available_rewards"` + Depositor string `protobuf:"bytes,9,opt,name=depositor,proto3" json:"depositor,omitempty" yaml:"depositor"` + StartTimestamp time.Time `protobuf:"bytes,10,opt,name=start_timestamp,json=startTimestamp,proto3,stdtime" json:"start_timestamp" yaml:"start_timestamp"` + EndTimestamp time.Time `protobuf:"bytes,11,opt,name=end_timestamp,json=endTimestamp,proto3,stdtime" json:"end_timestamp" yaml:"end_timestamp"` + MinLockupTimeSeconds int64 `protobuf:"varint,12,opt,name=min_lockup_time_seconds,json=minLockupTimeSeconds,proto3" json:"min_lockup_time_seconds,omitempty" yaml:"min_lockup_time_seconds"` + EpochId uint64 `protobuf:"varint,13,opt,name=epoch_id,json=epochId,proto3" json:"epoch_id,omitempty" yaml:"epoch_id"` +} + +func (m *LendExternalRewards) Reset() { *m = LendExternalRewards{} } +func (m *LendExternalRewards) String() string { return proto.CompactTextString(m) } +func (*LendExternalRewards) ProtoMessage() {} +func (*LendExternalRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_d29f449503627a2b, []int{6} +} +func (m *LendExternalRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LendExternalRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LendExternalRewards.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 *LendExternalRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_LendExternalRewards.Merge(m, src) +} +func (m *LendExternalRewards) XXX_Size() int { + return m.Size() +} +func (m *LendExternalRewards) XXX_DiscardUnknown() { + xxx_messageInfo_LendExternalRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_LendExternalRewards proto.InternalMessageInfo + +func (m *LendExternalRewards) GetId() uint64 { + if m != nil { + return m.Id + } + return 0 +} + +func (m *LendExternalRewards) GetAppMappingId() uint64 { + if m != nil { + return m.AppMappingId + } + return 0 +} + +func (m *LendExternalRewards) GetRewardsAssetPoolData() []*RewardsAssetPoolData { + if m != nil { + return m.RewardsAssetPoolData + } + return nil +} + +func (m *LendExternalRewards) GetTotalRewards() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.TotalRewards + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *LendExternalRewards) GetRewardAssetId() uint64 { + if m != nil { + return m.RewardAssetId + } + return 0 +} + +func (m *LendExternalRewards) GetDurationDays() int64 { + if m != nil { + return m.DurationDays + } + return 0 +} + +func (m *LendExternalRewards) GetIsActive() bool { + if m != nil { + return m.IsActive + } + return false +} + +func (m *LendExternalRewards) GetAvailableRewards() github_com_cosmos_cosmos_sdk_types.Coin { + if m != nil { + return m.AvailableRewards + } + return github_com_cosmos_cosmos_sdk_types.Coin{} +} + +func (m *LendExternalRewards) GetDepositor() string { + if m != nil { + return m.Depositor + } + return "" +} + +func (m *LendExternalRewards) GetStartTimestamp() time.Time { + if m != nil { + return m.StartTimestamp + } + return time.Time{} +} + +func (m *LendExternalRewards) GetEndTimestamp() time.Time { + if m != nil { + return m.EndTimestamp + } + return time.Time{} +} + +func (m *LendExternalRewards) GetMinLockupTimeSeconds() int64 { + if m != nil { + return m.MinLockupTimeSeconds + } + return 0 +} + +func (m *LendExternalRewards) GetEpochId() uint64 { + if m != nil { + return m.EpochId + } + return 0 +} + +type RewardsAssetPoolData struct { + CPoolId uint64 `protobuf:"varint,1,opt,name=c_pool_id,json=cPoolId,proto3" json:"c_pool_id,omitempty" yaml:"c_pool_id"` + AssetId []uint64 `protobuf:"varint,2,rep,packed,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` +} + +func (m *RewardsAssetPoolData) Reset() { *m = RewardsAssetPoolData{} } +func (m *RewardsAssetPoolData) String() string { return proto.CompactTextString(m) } +func (*RewardsAssetPoolData) ProtoMessage() {} +func (*RewardsAssetPoolData) Descriptor() ([]byte, []int) { + return fileDescriptor_d29f449503627a2b, []int{7} +} +func (m *RewardsAssetPoolData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RewardsAssetPoolData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RewardsAssetPoolData.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 *RewardsAssetPoolData) XXX_Merge(src proto.Message) { + xxx_messageInfo_RewardsAssetPoolData.Merge(m, src) +} +func (m *RewardsAssetPoolData) XXX_Size() int { + return m.Size() +} +func (m *RewardsAssetPoolData) XXX_DiscardUnknown() { + xxx_messageInfo_RewardsAssetPoolData.DiscardUnknown(m) +} + +var xxx_messageInfo_RewardsAssetPoolData proto.InternalMessageInfo + +func (m *RewardsAssetPoolData) GetCPoolId() uint64 { + if m != nil { + return m.CPoolId + } + return 0 +} + +func (m *RewardsAssetPoolData) GetAssetId() []uint64 { + if m != nil { + return m.AssetId + } + return nil +} + func init() { proto.RegisterType((*InternalRewards)(nil), "comdex.rewards.v1beta1.Internal_rewards") proto.RegisterType((*LockerRewardsTracker)(nil), "comdex.rewards.v1beta1.Locker_rewards_tracker") @@ -526,6 +718,8 @@ func init() { proto.RegisterType((*LockerExternalRewards)(nil), "comdex.rewards.v1beta1.Locker_external_rewards") proto.RegisterType((*VaultExternalRewards)(nil), "comdex.rewards.v1beta1.Vault_external_rewards") proto.RegisterType((*EpochTime)(nil), "comdex.rewards.v1beta1.EpochTime") + proto.RegisterType((*LendExternalRewards)(nil), "comdex.rewards.v1beta1.Lend_external_rewards") + proto.RegisterType((*RewardsAssetPoolData)(nil), "comdex.rewards.v1beta1.Rewards_asset_pool_data") } func init() { @@ -533,66 +727,75 @@ func init() { } var fileDescriptor_d29f449503627a2b = []byte{ - // 933 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0x4d, 0x6f, 0x1b, 0x45, - 0x18, 0xce, 0x3a, 0x69, 0x6d, 0x4f, 0xec, 0xc4, 0x6c, 0x4c, 0xb2, 0x4d, 0x85, 0xd7, 0x1a, 0xa1, - 0x62, 0x09, 0x75, 0xad, 0x14, 0x4e, 0x95, 0x10, 0x8a, 0x71, 0x85, 0xac, 0xa6, 0x12, 0x2c, 0x08, - 0x09, 0x2e, 0xab, 0xf1, 0xce, 0xc4, 0x1d, 0xd5, 0xbb, 0xb3, 0xda, 0x1d, 0x87, 0xe6, 0x80, 0xc4, - 0x8d, 0x03, 0x1c, 0x2a, 0xf1, 0x0b, 0xf8, 0x33, 0xa8, 0xdc, 0x7a, 0x44, 0x08, 0x2d, 0xc8, 0xf9, - 0x07, 0x7b, 0xe4, 0x84, 0xe6, 0x6b, 0xfd, 0x41, 0xaa, 0x52, 0x29, 0x70, 0xca, 0x29, 0x33, 0xef, - 0xc7, 0xf3, 0xbe, 0xef, 0xb3, 0xef, 0x33, 0x8a, 0xc1, 0xdb, 0x21, 0x8b, 0x30, 0x79, 0xda, 0x4f, - 0xc9, 0xd7, 0x28, 0xc5, 0x59, 0xff, 0xec, 0x68, 0x4c, 0x38, 0x3a, 0x32, 0x77, 0x2f, 0x49, 0x19, - 0x67, 0xf6, 0xbe, 0x8a, 0xf2, 0x8c, 0x55, 0x47, 0x1d, 0xb6, 0x27, 0x6c, 0xc2, 0x64, 0x48, 0x5f, - 0x9c, 0x54, 0xf4, 0xa1, 0x3b, 0x61, 0x6c, 0x32, 0x25, 0x7d, 0x79, 0x1b, 0xcf, 0x4e, 0xfb, 0x9c, - 0x46, 0x24, 0xe3, 0x28, 0x4a, 0x74, 0x40, 0x27, 0x64, 0x59, 0xc4, 0xb2, 0xfe, 0x18, 0x65, 0xa4, - 0xac, 0x18, 0x32, 0x1a, 0x2b, 0x3f, 0xfc, 0xc9, 0x02, 0xad, 0x51, 0xcc, 0x49, 0x1a, 0xa3, 0x69, - 0xa0, 0x6b, 0xda, 0x9f, 0x82, 0x1d, 0x94, 0x24, 0x41, 0x84, 0x92, 0x84, 0xc6, 0x93, 0x60, 0x34, - 0x74, 0xac, 0xae, 0xd5, 0xdb, 0x1a, 0xbc, 0x3b, 0xcf, 0xdd, 0x9d, 0xe3, 0x15, 0x4f, 0x91, 0xbb, - 0x6f, 0x9e, 0xa3, 0x68, 0x7a, 0x1f, 0xae, 0x66, 0x40, 0xbf, 0x81, 0x92, 0xe4, 0x91, 0xba, 0x8f, - 0x86, 0xf6, 0x7d, 0x50, 0x43, 0x59, 0x46, 0xb8, 0x00, 0xab, 0x48, 0x30, 0x77, 0x9e, 0xbb, 0xb5, - 0x63, 0x6d, 0x2b, 0x72, 0x77, 0x57, 0xc3, 0x68, 0x0b, 0xf4, 0xab, 0xf2, 0x38, 0x1a, 0xc2, 0xef, - 0x2b, 0x60, 0xff, 0x84, 0x85, 0x4f, 0x48, 0x6a, 0x3a, 0x0c, 0x78, 0x8a, 0xc4, 0xdd, 0x3e, 0x02, - 0xf5, 0xa9, 0xf2, 0x50, 0xac, 0x9b, 0x6c, 0x17, 0xb9, 0xdb, 0x52, 0x58, 0xa5, 0x0b, 0xfa, 0x35, - 0x75, 0x1e, 0x61, 0xfb, 0xc3, 0xd5, 0xe1, 0x28, 0xd6, 0xfd, 0xdc, 0xba, 0x7c, 0x14, 0x91, 0xbc, - 0x3c, 0x0a, 0xb6, 0xbf, 0x01, 0x7b, 0xa6, 0x0d, 0x14, 0x86, 0xb3, 0x68, 0x36, 0x45, 0x9c, 0x60, - 0x67, 0xb3, 0x6b, 0xf5, 0xea, 0x83, 0x93, 0xe7, 0xb9, 0xbb, 0xf1, 0x5b, 0xee, 0xde, 0x99, 0x50, - 0xfe, 0x78, 0x36, 0xf6, 0x42, 0x16, 0xf5, 0xf5, 0x27, 0x50, 0x7f, 0xee, 0x66, 0xf8, 0x49, 0x9f, - 0x9f, 0x27, 0x24, 0xf3, 0x86, 0x24, 0x2c, 0x72, 0xf7, 0x50, 0xd5, 0xbc, 0x04, 0x12, 0xfa, 0xb6, - 0xb6, 0x1e, 0x2f, 0x19, 0x7f, 0xa8, 0x80, 0xfd, 0x2f, 0xd0, 0x6c, 0xca, 0x03, 0x2a, 0xbe, 0x1b, - 0xc9, 0x78, 0xc9, 0x86, 0x07, 0x6a, 0x67, 0xca, 0x63, 0xc8, 0xd8, 0x5b, 0x10, 0x6b, 0x3c, 0xd0, - 0xaf, 0xca, 0xe3, 0x55, 0x50, 0xf1, 0xad, 0x05, 0xda, 0x65, 0x17, 0xff, 0x24, 0xe3, 0xd1, 0x6b, - 0x93, 0x71, 0x5b, 0x55, 0xbd, 0x0c, 0x13, 0xfa, 0x7b, 0xc6, 0xbc, 0x4c, 0xc7, 0xcf, 0x55, 0x70, - 0xa0, 0x97, 0x83, 0x3c, 0x5d, 0xdb, 0xe3, 0xb7, 0x40, 0xa5, 0x64, 0xa2, 0x59, 0xe4, 0x6e, 0x5d, - 0xa3, 0x63, 0xe8, 0x57, 0xe8, 0x15, 0x8c, 0xef, 0x99, 0xa5, 0xa6, 0x6a, 0xe2, 0x15, 0xbe, 0x8d, - 0xa7, 0x5c, 0x64, 0x6c, 0x7f, 0x67, 0x81, 0x26, 0x67, 0x7c, 0xd1, 0xa1, 0xb3, 0xd5, 0xb5, 0x7a, - 0xdb, 0xf7, 0x6e, 0x79, 0x8a, 0x0e, 0x4f, 0xa8, 0xd4, 0x28, 0xde, 0xfb, 0x88, 0xd1, 0x78, 0xf0, - 0xb1, 0xa0, 0xb0, 0xc8, 0xdd, 0xb6, 0x02, 0x5d, 0xc9, 0x86, 0x7f, 0xe5, 0xee, 0x3b, 0xff, 0x82, - 0x5a, 0x01, 0xe4, 0x37, 0x64, 0xaa, 0xaf, 0x99, 0xf9, 0x00, 0x34, 0xf1, 0x2c, 0x45, 0x9c, 0xb2, - 0x38, 0xc0, 0xe8, 0x3c, 0x73, 0x6e, 0x74, 0xad, 0xde, 0xe6, 0xc0, 0x59, 0x54, 0x5a, 0x71, 0x43, - 0xbf, 0x61, 0xee, 0x43, 0x74, 0x9e, 0x09, 0xd9, 0x51, 0xb1, 0xaa, 0x9c, 0x9e, 0x11, 0xe7, 0x66, - 0xd7, 0xea, 0xd5, 0x96, 0x65, 0x57, 0xba, 0xa0, 0x5f, 0xa3, 0xd9, 0xb1, 0x3c, 0xda, 0x3f, 0x5a, - 0xe0, 0x0d, 0x74, 0x86, 0xe8, 0x14, 0x8d, 0xa7, 0xa4, 0x9c, 0xbf, 0xfa, 0xaa, 0xf9, 0x1f, 0xea, - 0xf9, 0x1d, 0x4d, 0xea, 0x3a, 0xc2, 0x6b, 0x71, 0xd0, 0x2a, 0xd3, 0x0d, 0x0f, 0xf7, 0x40, 0x1d, - 0x93, 0x84, 0x65, 0x94, 0xb3, 0xd4, 0xa9, 0xc9, 0xa5, 0x5d, 0x1a, 0xa4, 0x74, 0x41, 0x7f, 0x11, - 0x66, 0x4f, 0xc0, 0x6e, 0xc6, 0x51, 0xca, 0x83, 0xf2, 0xad, 0x75, 0xea, 0x72, 0x8c, 0x43, 0x4f, - 0xbd, 0xc6, 0x9e, 0x79, 0x8d, 0xbd, 0xcf, 0x4d, 0xc4, 0x00, 0xea, 0x39, 0xf6, 0x15, 0xf2, 0x1a, - 0x00, 0x7c, 0xf6, 0x87, 0x6b, 0xf9, 0x3b, 0xd2, 0x5a, 0xe6, 0xd8, 0x08, 0x34, 0x49, 0x8c, 0x97, - 0xca, 0x80, 0x57, 0x96, 0xe9, 0xae, 0xae, 0xcb, 0x4a, 0xba, 0x2a, 0xd2, 0x20, 0x31, 0x5e, 0x94, - 0xf8, 0x12, 0x1c, 0x44, 0x34, 0x0e, 0xc4, 0xe3, 0x38, 0x4b, 0x64, 0x68, 0x90, 0x91, 0x90, 0xc5, - 0x38, 0x73, 0xb6, 0xe5, 0x46, 0xc0, 0x22, 0x77, 0x3b, 0x0a, 0xec, 0x25, 0x81, 0xd0, 0x6f, 0x47, - 0x34, 0x3e, 0x91, 0x0e, 0x01, 0xfc, 0x99, 0x32, 0x0b, 0x71, 0x90, 0x84, 0x85, 0x8f, 0x85, 0x38, - 0x1a, 0xeb, 0xe2, 0x30, 0x1e, 0xe8, 0x57, 0xe5, 0x71, 0x84, 0xe1, 0xef, 0x55, 0xf3, 0xae, 0xfd, - 0xef, 0x3a, 0x7e, 0x00, 0x5a, 0xa2, 0x66, 0x8c, 0x09, 0x0e, 0x3e, 0x41, 0x34, 0x0d, 0x46, 0x46, - 0xcf, 0xb7, 0x8b, 0xdc, 0x3d, 0xd0, 0x2d, 0xaf, 0x45, 0x40, 0x7f, 0xc7, 0x98, 0x84, 0xe5, 0x5a, - 0xde, 0xd7, 0xf2, 0xbe, 0x96, 0xf7, 0xcb, 0xe5, 0xfd, 0x8b, 0x05, 0xea, 0x0f, 0xc4, 0x59, 0x80, - 0xfc, 0xe7, 0x8a, 0x7e, 0x1f, 0x34, 0x25, 0xdb, 0xc2, 0x2b, 0xa6, 0x91, 0x72, 0xde, 0x1c, 0xec, - 0x16, 0xb9, 0xbb, 0xad, 0xa5, 0x46, 0x23, 0x02, 0xfd, 0x86, 0x89, 0x92, 0x5d, 0xdd, 0x01, 0x37, - 0x42, 0x36, 0x8b, 0xb9, 0xd4, 0xed, 0xd6, 0xa0, 0x55, 0xe4, 0x6e, 0x43, 0x45, 0x4b, 0x33, 0xf4, - 0x95, 0x7b, 0xf0, 0xf0, 0xf9, 0xbc, 0x63, 0xbd, 0x98, 0x77, 0xac, 0x3f, 0xe7, 0x1d, 0xeb, 0xd9, - 0x45, 0x67, 0xe3, 0xc5, 0x45, 0x67, 0xe3, 0xd7, 0x8b, 0xce, 0xc6, 0x57, 0x47, 0x2b, 0xbb, 0x2a, - 0xfe, 0x91, 0xbf, 0xcb, 0x4e, 0x4f, 0x69, 0x48, 0xd1, 0x54, 0xdf, 0xfb, 0x8b, 0x1f, 0x00, 0x72, - 0x75, 0xc7, 0x37, 0xe5, 0x77, 0x7e, 0xef, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x34, 0x58, 0xf9, - 0x09, 0x1f, 0x0c, 0x00, 0x00, + // 1082 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xcf, 0xda, 0x4d, 0x6c, 0x4f, 0xec, 0x24, 0x6c, 0xdc, 0x64, 0x9b, 0x0a, 0xaf, 0x35, 0x42, + 0xc5, 0x12, 0xea, 0x9a, 0x04, 0x4e, 0x45, 0x08, 0xc5, 0xb8, 0x42, 0x56, 0x53, 0xa9, 0x0c, 0x08, + 0x09, 0x2e, 0xab, 0xf1, 0xee, 0xc4, 0x1d, 0x75, 0x77, 0x67, 0xe5, 0x1d, 0x87, 0x46, 0x08, 0x89, + 0x1b, 0x12, 0x70, 0xa8, 0xc4, 0x27, 0xe0, 0xcb, 0xa0, 0x72, 0xeb, 0x11, 0x21, 0xb4, 0xa0, 0xe4, + 0x1b, 0xf8, 0xc8, 0x09, 0xcd, 0xcc, 0xce, 0xfa, 0x4f, 0x1d, 0xa5, 0x2d, 0x21, 0xea, 0x21, 0xa7, + 0xcc, 0xbc, 0xf7, 0xe6, 0xbd, 0x79, 0x3f, 0xbf, 0xdf, 0x4f, 0xb3, 0x01, 0x6f, 0x79, 0x2c, 0xf4, + 0xc9, 0xe3, 0xf6, 0x90, 0x7c, 0x8d, 0x87, 0x7e, 0xd2, 0x3e, 0xda, 0xed, 0x13, 0x8e, 0x77, 0xf5, + 0xde, 0x89, 0x87, 0x8c, 0x33, 0x73, 0x4b, 0x45, 0x39, 0xda, 0x9a, 0x45, 0xed, 0xd4, 0x07, 0x6c, + 0xc0, 0x64, 0x48, 0x5b, 0xac, 0x54, 0xf4, 0x8e, 0x3d, 0x60, 0x6c, 0x10, 0x90, 0xb6, 0xdc, 0xf5, + 0x47, 0x87, 0x6d, 0x4e, 0x43, 0x92, 0x70, 0x1c, 0xc6, 0x59, 0x40, 0xc3, 0x63, 0x49, 0xc8, 0x92, + 0x76, 0x1f, 0x27, 0x24, 0xaf, 0xe8, 0x31, 0x1a, 0x29, 0x3f, 0xfc, 0xc5, 0x00, 0x1b, 0xbd, 0x88, + 0x93, 0x61, 0x84, 0x03, 0x37, 0xab, 0x69, 0x7e, 0x0a, 0xd6, 0x70, 0x1c, 0xbb, 0x21, 0x8e, 0x63, + 0x1a, 0x0d, 0xdc, 0x5e, 0xd7, 0x32, 0x9a, 0x46, 0xeb, 0x5a, 0xe7, 0x9d, 0x93, 0xd4, 0x5e, 0xdb, + 0x9f, 0xf1, 0x8c, 0x53, 0xfb, 0xfa, 0x31, 0x0e, 0x83, 0x3b, 0x70, 0xf6, 0x04, 0x44, 0x55, 0x1c, + 0xc7, 0xf7, 0xd5, 0xbe, 0xd7, 0x35, 0xef, 0x80, 0x32, 0x4e, 0x12, 0xc2, 0x45, 0xb2, 0x82, 0x4c, + 0x66, 0x9f, 0xa4, 0x76, 0x79, 0x3f, 0xb3, 0x8d, 0x53, 0x7b, 0x3d, 0x4b, 0x93, 0x59, 0x20, 0x2a, + 0xc9, 0x65, 0xaf, 0x0b, 0x7f, 0x2c, 0x80, 0xad, 0x03, 0xe6, 0x3d, 0x22, 0x43, 0x7d, 0x43, 0x97, + 0x0f, 0xb1, 0xd8, 0x9b, 0xbb, 0xa0, 0x12, 0x28, 0x0f, 0xf5, 0xb3, 0x4b, 0xd6, 0xc7, 0xa9, 0xbd, + 0xa1, 0x72, 0xe5, 0x2e, 0x88, 0xca, 0x6a, 0xdd, 0xf3, 0xcd, 0x8f, 0x66, 0x9b, 0xa3, 0x7e, 0x76, + 0x9f, 0x1b, 0x8b, 0x5b, 0x11, 0x87, 0xa7, 0x5b, 0xf1, 0xcd, 0x6f, 0xc1, 0xa6, 0xbe, 0x06, 0xf6, + 0xbc, 0x51, 0x38, 0x0a, 0x30, 0x27, 0xbe, 0x55, 0x6c, 0x1a, 0xad, 0x4a, 0xe7, 0xe0, 0x69, 0x6a, + 0x2f, 0xfd, 0x91, 0xda, 0xb7, 0x06, 0x94, 0x3f, 0x1c, 0xf5, 0x1d, 0x8f, 0x85, 0xed, 0xec, 0x27, + 0x50, 0x7f, 0x6e, 0x27, 0xfe, 0xa3, 0x36, 0x3f, 0x8e, 0x49, 0xe2, 0x74, 0x89, 0x37, 0x4e, 0xed, + 0x1d, 0x55, 0x73, 0x41, 0x4a, 0x88, 0xcc, 0xcc, 0xba, 0x3f, 0x65, 0xfc, 0xa9, 0x00, 0xb6, 0xbe, + 0xc0, 0xa3, 0x80, 0xbb, 0x54, 0xfc, 0x6e, 0x24, 0xe1, 0x39, 0x1a, 0x0e, 0x28, 0x1f, 0x29, 0x8f, + 0x06, 0x63, 0x73, 0x02, 0xac, 0xf6, 0x40, 0x54, 0x92, 0xcb, 0x8b, 0x80, 0xe2, 0x3b, 0x03, 0xd4, + 0xf3, 0x5b, 0x3c, 0x0f, 0xc6, 0xfd, 0x97, 0x06, 0xe3, 0xa6, 0xaa, 0xba, 0x28, 0x27, 0x44, 0x9b, + 0xda, 0x3c, 0x0d, 0xc7, 0xaf, 0x25, 0xb0, 0x9d, 0x0d, 0x07, 0x79, 0x3c, 0x37, 0xc7, 0x6f, 0x82, + 0x42, 0x8e, 0x44, 0x6d, 0x9c, 0xda, 0x95, 0x2c, 0xbb, 0x0f, 0x51, 0x81, 0x5e, 0x40, 0xfb, 0x8e, + 0x1e, 0x6a, 0xaa, 0x3a, 0x9e, 0xc1, 0x5b, 0x7b, 0xf2, 0x41, 0xf6, 0xcd, 0xef, 0x0d, 0x50, 0xe3, + 0x8c, 0x4f, 0x6e, 0x68, 0x5d, 0x6b, 0x1a, 0xad, 0xd5, 0xbd, 0x1b, 0x8e, 0x82, 0xc3, 0x11, 0x2c, + 0xd5, 0x8c, 0x77, 0x3e, 0x66, 0x34, 0xea, 0x7c, 0x22, 0x20, 0x1c, 0xa7, 0x76, 0x5d, 0x25, 0x9d, + 0x39, 0x0d, 0xff, 0x49, 0xed, 0xb7, 0x5f, 0x00, 0x5a, 0x91, 0x08, 0x55, 0xe5, 0x51, 0x94, 0x21, + 0xf3, 0x21, 0xa8, 0xf9, 0xa3, 0x21, 0xe6, 0x94, 0x45, 0xae, 0x8f, 0x8f, 0x13, 0x6b, 0xb9, 0x69, + 0xb4, 0x8a, 0x1d, 0x6b, 0x52, 0x69, 0xc6, 0x0d, 0x51, 0x55, 0xef, 0xbb, 0xf8, 0x38, 0x11, 0xb4, + 0xa3, 0x62, 0x54, 0x39, 0x3d, 0x22, 0xd6, 0x4a, 0xd3, 0x68, 0x95, 0xa7, 0x69, 0x97, 0xbb, 0x20, + 0x2a, 0xd3, 0x64, 0x5f, 0x2e, 0xcd, 0x9f, 0x0d, 0xf0, 0x06, 0x3e, 0xc2, 0x34, 0xc0, 0xfd, 0x80, + 0xe4, 0xfd, 0x97, 0xce, 0xeb, 0xff, 0x5e, 0xd6, 0xbf, 0x95, 0x81, 0x3a, 0x9f, 0xe1, 0xa5, 0x30, + 0xd8, 0xc8, 0x8f, 0x6b, 0x1c, 0xf6, 0x40, 0xc5, 0x27, 0x31, 0x4b, 0x28, 0x67, 0x43, 0xab, 0x2c, + 0x87, 0x76, 0xaa, 0x91, 0xdc, 0x05, 0xd1, 0x24, 0xcc, 0x1c, 0x80, 0xf5, 0x84, 0xe3, 0x21, 0x77, + 0x73, 0xad, 0xb5, 0x2a, 0xb2, 0x8d, 0x1d, 0x47, 0xa9, 0xb1, 0xa3, 0xd5, 0xd8, 0xf9, 0x5c, 0x47, + 0x74, 0x60, 0xd6, 0xc7, 0x96, 0xca, 0x3c, 0x97, 0x00, 0x3e, 0xf9, 0xcb, 0x36, 0xd0, 0x9a, 0xb4, + 0xe6, 0x67, 0x4c, 0x0c, 0x6a, 0x24, 0xf2, 0xa7, 0xca, 0x80, 0x73, 0xcb, 0x34, 0x67, 0xc7, 0x65, + 0xe6, 0xb8, 0x2a, 0x52, 0x25, 0x91, 0x3f, 0x29, 0xf1, 0x25, 0xd8, 0x0e, 0x69, 0xe4, 0x0a, 0x71, + 0x1c, 0xc5, 0x32, 0xd4, 0x4d, 0x88, 0xc7, 0x22, 0x3f, 0xb1, 0x56, 0xe5, 0x44, 0xc0, 0x71, 0x6a, + 0x37, 0x54, 0xb2, 0x33, 0x02, 0x21, 0xaa, 0x87, 0x34, 0x3a, 0x90, 0x0e, 0x91, 0xf8, 0x33, 0x65, + 0x16, 0xe4, 0x20, 0x31, 0xf3, 0x1e, 0x0a, 0x72, 0x54, 0xe7, 0xc9, 0xa1, 0x3d, 0x10, 0x95, 0xe4, + 0xb2, 0xe7, 0xc3, 0x3f, 0x4b, 0x5a, 0xd7, 0x2e, 0x9d, 0xc7, 0x77, 0xc1, 0x86, 0xa8, 0x19, 0xf9, + 0xc4, 0x77, 0x1f, 0x60, 0x3a, 0x74, 0x7b, 0x9a, 0xcf, 0x37, 0xc7, 0xa9, 0xbd, 0x9d, 0x5d, 0x79, + 0x2e, 0x02, 0xa2, 0x35, 0x6d, 0x12, 0x96, 0x2b, 0x7a, 0x5f, 0xd1, 0xfb, 0x8a, 0xde, 0x67, 0xd3, + 0xfb, 0x37, 0x03, 0x54, 0xee, 0x8a, 0xb5, 0x48, 0xf2, 0xbf, 0x33, 0xfa, 0x7d, 0x50, 0x93, 0x68, + 0x0b, 0xaf, 0xe8, 0x46, 0xd2, 0xb9, 0xd8, 0x59, 0x1f, 0xa7, 0xf6, 0x6a, 0x46, 0x35, 0x1a, 0x12, + 0x88, 0xaa, 0x3a, 0x4a, 0xde, 0xea, 0x16, 0x58, 0xf6, 0xd8, 0x28, 0xe2, 0x92, 0xb7, 0xd7, 0x3a, + 0x1b, 0xe3, 0xd4, 0xae, 0xaa, 0x68, 0x69, 0x86, 0x48, 0xb9, 0x61, 0x5a, 0x06, 0xd7, 0x0f, 0x04, + 0xf8, 0x97, 0xae, 0x54, 0x3f, 0x18, 0x60, 0x3b, 0x7f, 0x29, 0xca, 0x07, 0x46, 0xcc, 0x58, 0xe0, + 0xfa, 0x98, 0x63, 0xab, 0xd8, 0x2c, 0xb6, 0x56, 0xf7, 0xda, 0xce, 0xe2, 0x0f, 0x08, 0x07, 0x2d, + 0x3e, 0x36, 0x3d, 0x02, 0x67, 0x64, 0x86, 0xa8, 0xae, 0xdf, 0xa1, 0xc2, 0xf1, 0x80, 0xb1, 0xa0, + 0x8b, 0x39, 0x7e, 0x8d, 0xf4, 0xee, 0x03, 0xb0, 0xae, 0x92, 0xb8, 0xf9, 0x7b, 0x6c, 0xf9, 0xec, + 0x99, 0xac, 0xa9, 0xd8, 0xfd, 0xec, 0x55, 0xf6, 0x9c, 0x58, 0xae, 0xbc, 0xba, 0x58, 0x96, 0xfe, + 0x83, 0x58, 0x96, 0x5f, 0x27, 0xb1, 0xac, 0xbc, 0xb2, 0x58, 0x82, 0xcb, 0x11, 0xcb, 0xd5, 0xcb, + 0x14, 0xcb, 0xea, 0x05, 0x8a, 0x65, 0xed, 0x05, 0xc4, 0xf2, 0x1b, 0xb0, 0x7d, 0x06, 0x5d, 0xcd, + 0x77, 0x41, 0xc5, 0x53, 0xdb, 0x45, 0x5f, 0xbc, 0xb9, 0x0b, 0xa2, 0x92, 0x27, 0x88, 0x3a, 0xf7, + 0x95, 0x52, 0x68, 0x16, 0xcf, 0xfb, 0x4a, 0xe9, 0xdc, 0x7b, 0x7a, 0xd2, 0x30, 0x9e, 0x9d, 0x34, + 0x8c, 0xbf, 0x4f, 0x1a, 0xc6, 0x93, 0xd3, 0xc6, 0xd2, 0xb3, 0xd3, 0xc6, 0xd2, 0xef, 0xa7, 0x8d, + 0xa5, 0xaf, 0x76, 0x67, 0x86, 0x4b, 0xa8, 0xcc, 0x6d, 0x76, 0x78, 0x48, 0x3d, 0x8a, 0x83, 0x6c, + 0xdf, 0x9e, 0xfc, 0x7b, 0x43, 0xce, 0x5a, 0x7f, 0x45, 0xfe, 0x30, 0xef, 0xfd, 0x1b, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xb6, 0x16, 0x3f, 0xfd, 0x10, 0x00, 0x00, } func (m *InternalRewards) Marshal() (dAtA []byte, err error) { @@ -969,6 +1172,172 @@ func (m *EpochTime) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LendExternalRewards) 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 *LendExternalRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LendExternalRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.EpochId != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.EpochId)) + i-- + dAtA[i] = 0x68 + } + if m.MinLockupTimeSeconds != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.MinLockupTimeSeconds)) + i-- + dAtA[i] = 0x60 + } + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTimestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTimestamp):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintRewards(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x5a + n10, err10 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTimestamp, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimestamp):]) + if err10 != nil { + return 0, err10 + } + i -= n10 + i = encodeVarintRewards(dAtA, i, uint64(n10)) + i-- + dAtA[i] = 0x52 + if len(m.Depositor) > 0 { + i -= len(m.Depositor) + copy(dAtA[i:], m.Depositor) + i = encodeVarintRewards(dAtA, i, uint64(len(m.Depositor))) + i-- + dAtA[i] = 0x4a + } + { + size, err := m.AvailableRewards.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRewards(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + if m.IsActive { + i-- + if m.IsActive { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if m.DurationDays != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.DurationDays)) + i-- + dAtA[i] = 0x30 + } + if m.RewardAssetId != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.RewardAssetId)) + i-- + dAtA[i] = 0x28 + } + { + size, err := m.TotalRewards.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRewards(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.RewardsAssetPoolData) > 0 { + for iNdEx := len(m.RewardsAssetPoolData) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RewardsAssetPoolData[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintRewards(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.AppMappingId != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.AppMappingId)) + i-- + dAtA[i] = 0x10 + } + if m.Id != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.Id)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RewardsAssetPoolData) 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 *RewardsAssetPoolData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RewardsAssetPoolData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AssetId) > 0 { + dAtA14 := make([]byte, len(m.AssetId)*10) + var j13 int + for _, num := range m.AssetId { + for num >= 1<<7 { + dAtA14[j13] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j13++ + } + dAtA14[j13] = uint8(num) + j13++ + } + i -= j13 + copy(dAtA[i:], dAtA14[:j13]) + i = encodeVarintRewards(dAtA, i, uint64(j13)) + i-- + dAtA[i] = 0x12 + } + if m.CPoolId != 0 { + i = encodeVarintRewards(dAtA, i, uint64(m.CPoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintRewards(dAtA []byte, offset int, v uint64) int { offset -= sovRewards(v) base := offset @@ -1134,19 +1503,86 @@ func (m *EpochTime) Size() (n int) { return n } -func sovRewards(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozRewards(x uint64) (n int) { - return sovRewards(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *InternalRewards) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { +func (m *LendExternalRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Id != 0 { + n += 1 + sovRewards(uint64(m.Id)) + } + if m.AppMappingId != 0 { + n += 1 + sovRewards(uint64(m.AppMappingId)) + } + if len(m.RewardsAssetPoolData) > 0 { + for _, e := range m.RewardsAssetPoolData { + l = e.Size() + n += 1 + l + sovRewards(uint64(l)) + } + } + l = m.TotalRewards.Size() + n += 1 + l + sovRewards(uint64(l)) + if m.RewardAssetId != 0 { + n += 1 + sovRewards(uint64(m.RewardAssetId)) + } + if m.DurationDays != 0 { + n += 1 + sovRewards(uint64(m.DurationDays)) + } + if m.IsActive { + n += 2 + } + l = m.AvailableRewards.Size() + n += 1 + l + sovRewards(uint64(l)) + l = len(m.Depositor) + if l > 0 { + n += 1 + l + sovRewards(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTimestamp) + n += 1 + l + sovRewards(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTimestamp) + n += 1 + l + sovRewards(uint64(l)) + if m.MinLockupTimeSeconds != 0 { + n += 1 + sovRewards(uint64(m.MinLockupTimeSeconds)) + } + if m.EpochId != 0 { + n += 1 + sovRewards(uint64(m.EpochId)) + } + return n +} + +func (m *RewardsAssetPoolData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CPoolId != 0 { + n += 1 + sovRewards(uint64(m.CPoolId)) + } + if len(m.AssetId) > 0 { + l = 0 + for _, e := range m.AssetId { + l += sovRewards(uint64(e)) + } + n += 1 + sovRewards(uint64(l)) + l + } + return n +} + +func sovRewards(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozRewards(x uint64) (n int) { + return sovRewards(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *InternalRewards) 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 ErrIntOverflowRewards } @@ -1450,7 +1886,355 @@ func (m *VaultInterestTracker) Unmarshal(dAtA []byte) error { if err := m.InterestAccumulated.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - iNdEx = postIndex + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipRewards(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRewards + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LockerExternalRewards) 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 ErrIntOverflowRewards + } + 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: Locker_external_rewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Locker_external_rewards: 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 ErrIntOverflowRewards + } + 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 AppMappingId", wireType) + } + m.AppMappingId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppMappingId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + 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 ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TotalRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TotalRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field DurationDays", wireType) + } + m.DurationDays = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.DurationDays |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsActive", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsActive = bool(v != 0) + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AvailableRewards", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AvailableRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Depositor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + 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 ErrInvalidLengthRewards + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Depositor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StartTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTimestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EndTimestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.EndTimestamp, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinLockupTimeSeconds", wireType) + } + m.MinLockupTimeSeconds = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinLockupTimeSeconds |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochId", wireType) + } + m.EpochId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EpochId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipRewards(dAtA[iNdEx:]) @@ -1472,7 +2256,7 @@ func (m *VaultInterestTracker) Unmarshal(dAtA []byte) error { } return nil } -func (m *LockerExternalRewards) Unmarshal(dAtA []byte) error { +func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1495,10 +2279,10 @@ func (m *LockerExternalRewards) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Locker_external_rewards: wiretype end group for non-group") + return fmt.Errorf("proto: Vault_external_rewards: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Locker_external_rewards: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Vault_external_rewards: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1541,9 +2325,9 @@ func (m *LockerExternalRewards) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Extended_Pair_Id", wireType) } - m.AssetId = 0 + m.Extended_Pair_Id = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRewards @@ -1553,7 +2337,7 @@ func (m *LockerExternalRewards) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.AssetId |= uint64(b&0x7F) << shift + m.Extended_Pair_Id |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1820,7 +2604,7 @@ func (m *LockerExternalRewards) Unmarshal(dAtA []byte) error { } return nil } -func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { +func (m *EpochTime) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1843,10 +2627,10 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Vault_external_rewards: wiretype end group for non-group") + return fmt.Errorf("proto: EpochTime: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Vault_external_rewards: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: EpochTime: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1889,9 +2673,9 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Extended_Pair_Id", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StartingTime", wireType) } - m.Extended_Pair_Id = 0 + m.StartingTime = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRewards @@ -1901,11 +2685,152 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Extended_Pair_Id |= uint64(b&0x7F) << shift + m.StartingTime |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) + } + m.Count = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Count |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipRewards(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthRewards + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *LendExternalRewards) 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 ErrIntOverflowRewards + } + 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: Lend_external_rewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Lend_external_rewards: 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 ErrIntOverflowRewards + } + 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 AppMappingId", wireType) + } + m.AppMappingId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AppMappingId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardsAssetPoolData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } + if msglen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardsAssetPoolData = append(m.RewardsAssetPoolData, &RewardsAssetPoolData{}) + if err := m.RewardsAssetPoolData[len(m.RewardsAssetPoolData)-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 TotalRewards", wireType) @@ -1940,6 +2865,25 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardAssetId", wireType) + } + m.RewardAssetId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.RewardAssetId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DurationDays", wireType) } @@ -1958,7 +2902,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field IsActive", wireType) } @@ -1978,7 +2922,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } } m.IsActive = bool(v != 0) - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AvailableRewards", wireType) } @@ -2011,7 +2955,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Depositor", wireType) } @@ -2043,7 +2987,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } m.Depositor = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StartTimestamp", wireType) } @@ -2076,7 +3020,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 10: + case 11: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EndTimestamp", wireType) } @@ -2109,7 +3053,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 11: + case 12: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MinLockupTimeSeconds", wireType) } @@ -2128,7 +3072,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { break } } - case 12: + case 13: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field EpochId", wireType) } @@ -2168,7 +3112,7 @@ func (m *VaultExternalRewards) Unmarshal(dAtA []byte) error { } return nil } -func (m *EpochTime) Unmarshal(dAtA []byte) error { +func (m *RewardsAssetPoolData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2191,17 +3135,17 @@ func (m *EpochTime) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: EpochTime: wiretype end group for non-group") + return fmt.Errorf("proto: Rewards_asset_pool_data: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: EpochTime: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Rewards_asset_pool_data: 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) + return fmt.Errorf("proto: wrong wireType = %d for field CPoolId", wireType) } - m.Id = 0 + m.CPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowRewards @@ -2211,67 +3155,86 @@ func (m *EpochTime) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Id |= uint64(b&0x7F) << shift + m.CPoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AppMappingId", wireType) - } - m.AppMappingId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRewards - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AppMappingId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field StartingTime", wireType) - } - m.StartingTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRewards - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.StartingTime |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Count", wireType) - } - m.Count = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRewards - } - if iNdEx >= l { + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AssetId = append(m.AssetId, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthRewards + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthRewards + } + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - m.Count |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.AssetId) == 0 { + m.AssetId = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRewards + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AssetId = append(m.AssetId, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field AssetId", wireType) } default: iNdEx = preIndex diff --git a/x/vault/expected/keeper.go b/x/vault/expected/keeper.go index 427a61868..ed0b2ec58 100644 --- a/x/vault/expected/keeper.go +++ b/x/vault/expected/keeper.go @@ -30,6 +30,7 @@ type AssetKeeper interface { type MarketKeeper interface { GetPriceForAsset(ctx sdk.Context, id uint64) (uint64, bool) + CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) } type CollectorKeeper interface { diff --git a/x/vault/keeper/alias.go b/x/vault/keeper/alias.go index 36f72d112..2d8b289dc 100644 --- a/x/vault/keeper/alias.go +++ b/x/vault/keeper/alias.go @@ -103,3 +103,7 @@ func (k Keeper) CalculateVaultInterest(ctx sdk.Context, appID, assetID, lockerID func (k Keeper) DeleteVaultInterestTracker(ctx sdk.Context, vault rewardstypes.VaultInterestTracker) { k.rewards.DeleteVaultInterestTracker(ctx, vault) } + +func (k Keeper) CalcAssetPrice(ctx sdk.Context, id uint64, amt sdk.Int) (price sdk.Int, err error) { + return k.oracle.CalcAssetPrice(ctx, id, amt) +} diff --git a/x/vault/keeper/vault.go b/x/vault/keeper/vault.go index b79fa8bd4..e76805ac6 100644 --- a/x/vault/keeper/vault.go +++ b/x/vault/keeper/vault.go @@ -282,50 +282,55 @@ func (k Keeper) CalculateCollaterlizationRatio(ctx sdk.Context, extendedPairVaul if !found { return sdk.ZeroDec(), types.ErrorAssetDoesNotExist } - - assetInPrice, found := k.GetPriceForAsset(ctx, assetInData.Id) - if !found { - return sdk.ZeroDec(), types.ErrorPriceDoesNotExist + // calculating price of the asset_in + assetInTotalPrice, err := k.CalcAssetPrice(ctx, assetInData.Id, amountIn) + if err != nil { + return sdk.ZeroDec(), err } esmStatus, found := k.GetESMStatus(ctx, extendedPairVault.AppId) statusEsm := false if found { statusEsm = esmStatus.Status } + + // check to get calc asset price from esm if statusEsm && esmStatus.SnapshotStatus { + // TODO: function update + price, found := k.GetSnapshotOfPrices(ctx, extendedPairVault.AppId, assetInData.Id) if !found { return sdk.ZeroDec(), types.ErrorPriceDoesNotExist } - assetInPrice = price + assetInTotalPrice = sdk.NewIntFromUint64(price) } - var assetOutPrice uint64 + var assetOutTotalPrice sdk.Int if extendedPairVault.AssetOutOraclePrice { // If oracle Price required for the assetOut if statusEsm && esmStatus.SnapshotStatus { + // TODO: function update price, found := k.GetSnapshotOfPrices(ctx, extendedPairVault.AppId, assetOutData.Id) if !found { return sdk.ZeroDec(), types.ErrorPriceDoesNotExist } - assetOutPrice = price + assetInTotalPrice = sdk.NewIntFromUint64(price) } else { - assetOutPrice, found = k.GetPriceForAsset(ctx, assetOutData.Id) - if !found { - return sdk.ZeroDec(), types.ErrorPriceDoesNotExist + assetOutTotalPrice, err = k.CalcAssetPrice(ctx, assetOutData.Id, amountOut) + if err != nil { + return sdk.ZeroDec(), err } } } else { // If oracle Price is not required for the assetOut - assetOutPrice = extendedPairVault.AssetOutPrice + assetOutTotalPrice = (sdk.NewIntFromUint64(extendedPairVault.AssetOutPrice).Mul(amountOut)).Quo(sdk.NewIntFromUint64(uint64(assetOutData.Decimals))) } - totalIn := amountIn.Mul(sdk.NewIntFromUint64(assetInPrice)).ToDec() + totalIn := sdk.NewDecFromInt(assetInTotalPrice) if totalIn.LTE(sdk.ZeroDec()) { return sdk.ZeroDec(), types.ErrorInvalidAmountIn } - totalOut := amountOut.Mul(sdk.NewIntFromUint64(assetOutPrice)).ToDec() + totalOut := sdk.NewDecFromInt(assetOutTotalPrice) if totalOut.LTE(sdk.ZeroDec()) { return sdk.ZeroDec(), types.ErrorInvalidAmountOut }