Skip to content

Commit

Permalink
Remove dependency on assets keeper.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau committed Sep 19, 2024
1 parent 716603a commit e907a8b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 26 deletions.
1 change: 0 additions & 1 deletion protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,6 @@ func New(
app.VaultKeeper = *vaultmodulekeeper.NewKeeper(
appCodec,
keys[vaultmoduletypes.StoreKey],
app.AssetsKeeper,
app.BankKeeper,
app.ClobKeeper,
app.DelayMsgKeeper,
Expand Down
1 change: 0 additions & 1 deletion protocol/testutil/keeper/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func createVaultKeeper(
k := keeper.NewKeeper(
cdc,
storeKey,
&mocks.AssetsKeeper{},
&mocks.BankKeeper{},
&mocks.ClobKeeper{},
&mocks.DelayMsgKeeper{},
Expand Down
3 changes: 0 additions & 3 deletions protocol/x/vault/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -46,7 +44,6 @@ func NewKeeper(
return &Keeper{
cdc: cdc,
storeKey: storeKey,
assetsKeeper: assetsKeeper,
bankKeeper: bankKeeper,
clobKeeper: clobKeeper,
delayMsgKeeper: delayMsgKeeper,
Expand Down
12 changes: 2 additions & 10 deletions protocol/x/vault/keeper/sweep_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -34,7 +26,7 @@ func (k Keeper) SweepMainVaultBankBalance(
ctx,
types.MegavaultMainAddress,
types.MegavaultMainSubaccount,
usdcAsset.Id,
assettypes.AssetUsdc.Id,
mainVaultBalance.Amount.BigInt(),
)
if err != nil {
Expand Down
11 changes: 0 additions & 11 deletions protocol/x/vault/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,13 @@ 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"
sendingtypes "github.com/dydxprotocol/v4-chain/protocol/x/sending/types"
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,
Expand Down

0 comments on commit e907a8b

Please sign in to comment.