Skip to content

Commit 72f1a35

Browse files
committed
fix: remove pointer from state configuration
1 parent 0113994 commit 72f1a35

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

internal/usecases/liquidity_provider/transfer_excess_to_cold_wallet.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ func (useCase *TransferExcessToColdWalletUseCase) calculateExcessForBothNetworks
260260

261261
// publishBtcTransferEvent emits a BTC cold wallet transfer event to the event bus, distinguishing
262262
// between threshold-triggered and time-forced transfers.
263-
func (useCase *TransferExcessToColdWalletUseCase) publishBtcTransferEvent(txResult *internalTxResult, isTimeForcingTransfer bool) {
263+
func (useCase *TransferExcessToColdWalletUseCase) publishBtcTransferEvent(txResult internalTxResult, isTimeForcingTransfer bool) {
264264
if isTimeForcingTransfer {
265265
useCase.eventBus.Publish(cold_wallet.BtcTransferredDueToTimeForcingEvent{
266266
Event: entities.NewBaseEvent(cold_wallet.BtcTransferredDueToTimeForcingEventId),
@@ -317,7 +317,7 @@ func (useCase *TransferExcessToColdWalletUseCase) handleBtcTransfer(excess *enti
317317

318318
// publishRskTransferEvent emits an RBTC cold wallet transfer event to the event bus, distinguishing
319319
// between threshold-triggered and time-forced transfers.
320-
func (useCase *TransferExcessToColdWalletUseCase) publishRskTransferEvent(txResult *internalTxResult, isTimeForcingTransfer bool) {
320+
func (useCase *TransferExcessToColdWalletUseCase) publishRskTransferEvent(txResult internalTxResult, isTimeForcingTransfer bool) {
321321
if isTimeForcingTransfer {
322322
useCase.eventBus.Publish(cold_wallet.RbtcTransferredDueToTimeForcingEvent{
323323
Event: entities.NewBaseEvent(cold_wallet.RbtcTransferredDueToTimeForcingEventId),
@@ -435,26 +435,26 @@ func (useCase *TransferExcessToColdWalletUseCase) calculateExcess(
435435

436436
// executeBtcTransfer estimates the BTC transaction fee, verifies the transfer is economical
437437
// (amount >= fee * multiplier), and sends the funds to the cold wallet.
438-
func (useCase *TransferExcessToColdWalletUseCase) executeBtcTransfer(amount *entities.Wei) (*internalTxResult, error) {
438+
func (useCase *TransferExcessToColdWalletUseCase) executeBtcTransfer(amount *entities.Wei) (internalTxResult, error) {
439439
coldBtcAddress := useCase.coldWallet.GetBtcAddress()
440440

441441
feeEstimation, err := useCase.btcWallet.EstimateTxFees(coldBtcAddress, amount)
442442
if err != nil {
443-
return nil, err
443+
return internalTxResult{}, err
444444
}
445445

446446
// Check if transfer is economical: amount >= fee * multiplier
447447
minWorthwhileAmount := new(entities.Wei).Mul(feeEstimation.Value, entities.NewUWei(useCase.btcMinTransferFeeMultiplier))
448448
if amount.Cmp(minWorthwhileAmount) < 0 {
449-
return nil, TransferNotEconomicalError
449+
return internalTxResult{}, TransferNotEconomicalError
450450
}
451451

452452
txResult, err := useCase.btcWallet.Send(coldBtcAddress, amount)
453453
if err != nil {
454-
return nil, err
454+
return internalTxResult{}, err
455455
}
456456

457-
return &internalTxResult{
457+
return internalTxResult{
458458
TxHash: txResult.Hash,
459459
Amount: amount,
460460
Fee: feeEstimation.Value,
@@ -463,12 +463,12 @@ func (useCase *TransferExcessToColdWalletUseCase) executeBtcTransfer(amount *ent
463463

464464
// executeRskTransfer estimates gas costs, subtracts them from the amount, verifies the transfer is economical
465465
// (net amount >= gasCost * multiplier), and sends the RBTC to the cold wallet.
466-
func (useCase *TransferExcessToColdWalletUseCase) executeRskTransfer(ctx context.Context, amount *entities.Wei) (*internalTxResult, error) {
466+
func (useCase *TransferExcessToColdWalletUseCase) executeRskTransfer(ctx context.Context, amount *entities.Wei) (internalTxResult, error) {
467467
coldRskAddress := useCase.coldWallet.GetRskAddress()
468468

469469
gasPrice, err := useCase.rpc.Rsk.GasPrice(ctx)
470470
if err != nil {
471-
return nil, err
471+
return internalTxResult{}, err
472472
}
473473

474474
gasCost := new(entities.Wei).Mul(gasPrice, entities.NewWei(SimpleTransferGasLimit))
@@ -479,19 +479,19 @@ func (useCase *TransferExcessToColdWalletUseCase) executeRskTransfer(ctx context
479479
// Check if transfer is economical: amountToTransfer >= gasCost * multiplier
480480
minWorthwhileAmount := new(entities.Wei).Mul(gasCost, entities.NewUWei(useCase.rbtcMinTransferFeeMultiplier))
481481
if amountToTransfer.Cmp(minWorthwhileAmount) < 0 {
482-
return nil, TransferNotEconomicalError
482+
return internalTxResult{}, TransferNotEconomicalError
483483
}
484484

485485
config := blockchain.NewTransactionConfig(amountToTransfer, SimpleTransferGasLimit, gasPrice)
486486

487487
receipt, err := useCase.rskWallet.SendRbtc(ctx, config, coldRskAddress)
488488
if err != nil {
489-
return nil, err
489+
return internalTxResult{}, err
490490
}
491491

492492
actualFee := new(entities.Wei).Mul(receipt.GasPrice, entities.NewUWei(receipt.GasUsed.Uint64()))
493493

494-
return &internalTxResult{
494+
return internalTxResult{
495495
TxHash: receipt.TransactionHash,
496496
Amount: amountToTransfer,
497497
Fee: actualFee,

0 commit comments

Comments
 (0)