diff --git a/core/collateral/engine.go b/core/collateral/engine.go index 41a86f1f39..ab127b47df 100644 --- a/core/collateral/engine.go +++ b/core/collateral/engine.go @@ -382,6 +382,7 @@ func (e *Engine) EnableAsset(ctx context.Context, asset types.Asset) error { // this is useful when doing a migration so we can create all asset // account for already enabled assets. func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) { + e.log.Debug("ensureAllAssetAccounts started") // then creat a new infrastructure fee account for the asset // these are fee related account only infraFeeID := e.accountID(noMarket, systemOwner, asset.ID, types.AccountTypeFeesInfrastructure) @@ -418,6 +419,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) // see https://github.com/vegaprotocol/vega/pull/2745 for more information e.addAccountToHashableSlice(externalAcc) e.broker.Send(events.NewAccountEvent(ctx, *externalAcc)) + e.log.Info("event emitted for new account", logging.String("accID", externalID)) } // when an asset is enabled a staking reward account is created for it @@ -436,6 +438,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) e.accs[rewardID] = rewardAcc e.addAccountToHashableSlice(rewardAcc) e.broker.Send(events.NewAccountEvent(ctx, *rewardAcc)) + e.log.Info("event emitted for new account", logging.String("accID", rewardID)) } } @@ -453,6 +456,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) e.accs[netTreasury] = ntAcc e.addAccountToHashableSlice(ntAcc) e.broker.Send(events.NewAccountEvent(ctx, *ntAcc)) + e.log.Info("event emitted for new account", logging.String("accID", netTreasury)) } // global insurance for the asset @@ -469,6 +473,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) e.accs[globalInsurance] = giAcc e.addAccountToHashableSlice(giAcc) e.broker.Send(events.NewAccountEvent(ctx, *giAcc)) + e.log.Info("event emitted for new account", logging.String("accID", globalInsurance)) } // pending transfers account @@ -486,6 +491,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) e.accs[pendingTransfersID] = pendingTransfersAcc e.addAccountToHashableSlice(pendingTransfersAcc) e.broker.Send(events.NewAccountEvent(ctx, *pendingTransfersAcc)) + e.log.Info("event emitted for new account", logging.String("accID", pendingTransfersID)) } pendingFeeReferrerRewardID := e.accountID(noMarket, systemOwner, asset.ID, types.AccountTypePendingFeeReferralReward) @@ -502,6 +508,7 @@ func (e *Engine) ensureAllAssetAccounts(ctx context.Context, asset types.Asset) e.accs[pendingFeeReferrerRewardID] = pendingFeeReferrerRewardAcc e.addAccountToHashableSlice(pendingFeeReferrerRewardAcc) e.broker.Send(events.NewAccountEvent(ctx, *pendingFeeReferrerRewardAcc)) + e.log.Info("event emitted for new account", logging.String("accID", pendingFeeReferrerRewardID)) } } @@ -2006,7 +2013,7 @@ func (e *Engine) getFeeTransferRequest( makerFee, infraFee, liquiFee *types.Account, marketID, assetID string, ) (*types.TransferRequest, error) { - getAccount := func(marketID, owner string, accountType vega.AccountType) (*types.Account, error) { + getAccountLogError := func(marketID, owner string, accountType vega.AccountType) (*types.Account, error) { acc, err := e.GetAccountByID(e.accountID(marketID, owner, assetID, accountType)) if err != nil { e.log.Error( @@ -2030,16 +2037,23 @@ func (e *Engine) getFeeTransferRequest( } marginAccount := func() (*types.Account, error) { - return getAccount(marketID, t.Owner, types.AccountTypeMargin) + return getAccountLogError(marketID, t.Owner, types.AccountTypeMargin) } referralPendingRewardAccount := func() (*types.Account, error) { - return getAccount(noMarket, systemOwner, types.AccountTypePendingFeeReferralReward) + return getAccountLogError(noMarket, systemOwner, types.AccountTypePendingFeeReferralReward) } - general, err := getAccount(noMarket, t.Owner, types.AccountTypeGeneral) + general, err := e.GetAccountByID(e.accountID(noMarket, t.Owner, assetID, types.AccountTypeGeneral)) if err != nil { - return nil, err + generalID, err := e.CreatePartyGeneralAccount(ctx, t.Owner, assetID) + if err != nil { + return nil, err + } + general, err = e.GetAccountByID(generalID) + if err != nil { + return nil, err + } } treq := &types.TransferRequest{