Skip to content

Commit 6d40726

Browse files
committed
Add sell direction to moonpay
1 parent f008263 commit 6d40726

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/partners/moonpay.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,22 @@ export function processMoonpayTx(rawTx: unknown): StandardTx {
202202
const tx: MoonpayTx = asMoonpayTx(rawTx)
203203
const isoDate = tx.createdAt.toISOString()
204204
const timestamp = tx.createdAt.getTime()
205+
206+
const direction = tx.baseCurrency.type === 'fiat' ? 'buy' : 'sell'
207+
205208
const standardTx: StandardTx = {
206209
status: 'complete',
207210
orderId: tx.id,
208211

209212
countryCode: tx.country,
210-
depositTxid: undefined,
213+
depositTxid: direction === 'sell' ? tx.cryptoTransactionId : undefined,
211214
depositAddress: undefined,
212215
depositCurrency: tx.baseCurrency.code.toUpperCase(),
213216
depositAmount: tx.baseCurrencyAmount,
214-
direction: 'buy',
217+
direction,
215218
exchangeType: 'fiat',
216219
paymentType: getFiatPaymentType(tx),
217-
payoutTxid: tx.cryptoTransactionId,
220+
payoutTxid: direction === 'buy' ? tx.cryptoTransactionId : undefined,
218221
payoutAddress: tx.walletAddress,
219222
payoutCurrency: tx.currency.code.toUpperCase(),
220223
payoutAmount: tx.quoteCurrencyAmount,

0 commit comments

Comments
 (0)