From e907a8b976b0df191a5ae52a7a3a678b2146001e Mon Sep 17 00:00:00 2001 From: Vincent Chau <99756290+vincentwschau@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:00:15 -0400 Subject: [PATCH] Remove dependency on assets keeper. --- protocol/app/app.go | 1 - protocol/testutil/keeper/vault.go | 1 - protocol/x/vault/keeper/keeper.go | 3 --- protocol/x/vault/keeper/sweep_funds.go | 12 ++---------- protocol/x/vault/types/expected_keepers.go | 11 ----------- 5 files changed, 2 insertions(+), 26 deletions(-) diff --git a/protocol/app/app.go b/protocol/app/app.go index 7a5f350eee..70e0625b57 100644 --- a/protocol/app/app.go +++ b/protocol/app/app.go @@ -1178,7 +1178,6 @@ func New( app.VaultKeeper = *vaultmodulekeeper.NewKeeper( appCodec, keys[vaultmoduletypes.StoreKey], - app.AssetsKeeper, app.BankKeeper, app.ClobKeeper, app.DelayMsgKeeper, diff --git a/protocol/testutil/keeper/vault.go b/protocol/testutil/keeper/vault.go index e68ec78d11..01a93d22e5 100644 --- a/protocol/testutil/keeper/vault.go +++ b/protocol/testutil/keeper/vault.go @@ -62,7 +62,6 @@ func createVaultKeeper( k := keeper.NewKeeper( cdc, storeKey, - &mocks.AssetsKeeper{}, &mocks.BankKeeper{}, &mocks.ClobKeeper{}, &mocks.DelayMsgKeeper{}, diff --git a/protocol/x/vault/keeper/keeper.go b/protocol/x/vault/keeper/keeper.go index 78ae6f6170..fb95b46d3e 100644 --- a/protocol/x/vault/keeper/keeper.go +++ b/protocol/x/vault/keeper/keeper.go @@ -16,7 +16,6 @@ type ( Keeper struct { cdc codec.BinaryCodec storeKey storetypes.StoreKey - assetsKeeper types.AssetsKeeper bankKeeper types.BankKeeper clobKeeper types.ClobKeeper delayMsgKeeper types.DelayMsgKeeper @@ -32,7 +31,6 @@ type ( func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, - assetsKeeper types.AssetsKeeper, bankKeeper types.BankKeeper, clobKeeper types.ClobKeeper, delayMsgKeeper types.DelayMsgKeeper, @@ -46,7 +44,6 @@ func NewKeeper( return &Keeper{ cdc: cdc, storeKey: storeKey, - assetsKeeper: assetsKeeper, bankKeeper: bankKeeper, clobKeeper: clobKeeper, delayMsgKeeper: delayMsgKeeper, diff --git a/protocol/x/vault/keeper/sweep_funds.go b/protocol/x/vault/keeper/sweep_funds.go index 93237fd23f..86c5bbdbf5 100644 --- a/protocol/x/vault/keeper/sweep_funds.go +++ b/protocol/x/vault/keeper/sweep_funds.go @@ -12,18 +12,10 @@ import ( func (k Keeper) SweepMainVaultBankBalance( ctx sdk.Context, ) { - usdcAsset, exists := k.assetsKeeper.GetAsset(ctx, assettypes.AssetUsdc.Id) - if !exists { - log.ErrorLog( - ctx, - "SweepMainVaultBankBalance: Usdc asset not found in state", - ) - return - } mainVaultBalance := k.bankKeeper.GetBalance( ctx, types.MegavaultMainAddress, - usdcAsset.Denom, + assettypes.AssetUsdc.Denom, ) // No funds to sweep if mainVaultBalance.Amount.BigInt().Sign() <= 0 { @@ -34,7 +26,7 @@ func (k Keeper) SweepMainVaultBankBalance( ctx, types.MegavaultMainAddress, types.MegavaultMainSubaccount, - usdcAsset.Id, + assettypes.AssetUsdc.Id, mainVaultBalance.Amount.BigInt(), ) if err != nil { diff --git a/protocol/x/vault/types/expected_keepers.go b/protocol/x/vault/types/expected_keepers.go index 643d8b012e..436064bbcd 100644 --- a/protocol/x/vault/types/expected_keepers.go +++ b/protocol/x/vault/types/expected_keepers.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/dydxprotocol/v4-chain/protocol/lib/margin" - assettypes "github.com/dydxprotocol/v4-chain/protocol/x/assets/types" clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" pricestypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types" @@ -14,16 +13,6 @@ import ( satypes "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types" ) -type AssetsKeeper interface { - GetAsset( - ctx sdk.Context, - assetId uint32, - ) ( - asset assettypes.Asset, - exists bool, - ) -} - type BankKeeper interface { GetBalance( ctx context.Context,