Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ocp/worker/swap/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func (p *runtime) updateBalancesForFinalizedSwap(ctx context.Context, swapRecord
}

var exchangeCurrency currency_lib.Code
var exchangeRate float64
var nativeAmountWithoutFees float64
var usdMarketValueWithoutFees float64
switch swapRecord.FundingSource {
Expand All @@ -187,7 +186,6 @@ func (p *runtime) updateBalancesForFinalizedSwap(ctx context.Context, swapRecord
}

exchangeCurrency = fundingIntentRecord.SendPublicPaymentMetadata.ExchangeCurrency
exchangeRate = fundingIntentRecord.SendPublicPaymentMetadata.ExchangeRate
nativeAmountWithoutFees = fundingIntentRecord.SendPublicPaymentMetadata.NativeAmount
usdMarketValueWithoutFees = fundingIntentRecord.SendPublicPaymentMetadata.UsdMarketValue
case swap.FundingSourceExternalWallet:
Expand All @@ -205,7 +203,6 @@ func (p *runtime) updateBalancesForFinalizedSwap(ctx context.Context, swapRecord
return 0, err
}
nativeAmountWithoutFees = usdMarketValueWithoutFees
exchangeRate = currency_util.CalculateExchangeRate(common.CoreMintAccount, swapRecord.Amount, usdMarketValueWithoutFees)
default:
return 0, errors.New("unsupported funding source")
}
Expand All @@ -223,6 +220,8 @@ func (p *runtime) updateBalancesForFinalizedSwap(ctx context.Context, swapRecord
).Float64()
}

exchangeRate := currency_util.CalculateExchangeRate(toMint, uint64(deltaQuarksIntoOmnibus), nativeAmount)

err = p.data.ExecuteInTx(ctx, sql.LevelDefault, func(ctx context.Context) error {
// For transaction history
intentRecord := &intent.Record{
Expand Down