diff --git a/src/database/repositories/event-log.repository.ts b/src/database/repositories/event-log.repository.ts index 165d4fa..8fcb433 100644 --- a/src/database/repositories/event-log.repository.ts +++ b/src/database/repositories/event-log.repository.ts @@ -72,7 +72,7 @@ export class EventLogRepository extends BaseRepository { public async getHistoriesOfUser(address: string, options) { const queryBuilder = this.createQb(); queryBuilder - .where(`${this.alias}.sender_address = :address`, { address }) + .where(`${this.alias}.sender_address = :address OR ${this.alias}.receive_address = :address`, { address }) .orderBy(`${this.alias}.id`, EDirection.DESC) .select([ `${this.alias}.id`, diff --git a/src/modules/crawler/crawler.evmbridge.ts b/src/modules/crawler/crawler.evmbridge.ts index 2e5e45e..8b43a1c 100644 --- a/src/modules/crawler/crawler.evmbridge.ts +++ b/src/modules/crawler/crawler.evmbridge.ts @@ -122,8 +122,8 @@ export class BlockchainEVMCrawler { await queryRunner.manager.update(EventLog, existLockTx.id, { status: EEventStatus.COMPLETED, txHashUnlock: event.transactionHash, - // amountReceived: event.returnValues.amount, - // protocolFee: event.returnValues.fee, + amountReceived: event.returnValues.amount, + protocolFee: event.returnValues.fee, tokenReceivedAddress: event.returnValues.token, tokenReceivedName: EAsset.ETH, }); diff --git a/src/modules/crawler/crawler.minabridge.ts b/src/modules/crawler/crawler.minabridge.ts index 41198cc..1886cd9 100644 --- a/src/modules/crawler/crawler.minabridge.ts +++ b/src/modules/crawler/crawler.minabridge.ts @@ -83,8 +83,8 @@ export class SCBridgeMinaCrawler { await queryRunner.manager.update(EventLog, existLockTx.id, { status: EEventStatus.COMPLETED, txHashUnlock: event.event.transactionInfo.transactionHash, - // amountReceived: event.event.data.amount.toString(), - // tokenReceivedAddress: event.event.data.tokenAddress, + amountReceived: event.event.data.amount.toString(), + tokenReceivedAddress: event.event.data.tokenAddress, tokenReceivedName: EAsset.WETH, }); diff --git a/src/modules/crawler/sender.evmbridge.ts b/src/modules/crawler/sender.evmbridge.ts index 9b70c1b..19f3b54 100644 --- a/src/modules/crawler/sender.evmbridge.ts +++ b/src/modules/crawler/sender.evmbridge.ts @@ -86,7 +86,7 @@ export class SenderEVMBridge { status: EEventStatus.PROCESSING, errorDetail: null, protocolFee, - amountReceived, + amountReceived: BigNumber(amountReceived).minus(protocolFee).toFixed(0).toString(), }); } else { await this.handleError(result.error, dataLock); diff --git a/src/modules/crawler/sender.minabridge.ts b/src/modules/crawler/sender.minabridge.ts index dfe1759..3cfbc13 100644 --- a/src/modules/crawler/sender.minabridge.ts +++ b/src/modules/crawler/sender.minabridge.ts @@ -128,8 +128,6 @@ export class SenderMinaBridge { const rateMINAETH = Number(rateethmina.toFixed(0)) || 2000; // refactor this - await this.eventLogRepository.update(dataLock.id, { amountReceived, protocolFee: protocolFeeAmount }); - const result = await this.callUnlockFunction(amountReceived, id, receiveAddress, protocolFeeAmount, rateMINAETH); // Update status eventLog when call function unlock if (result.success) { @@ -139,6 +137,8 @@ export class SenderMinaBridge { status: EEventStatus.PROCESSING, errorDetail: result.error, txHashUnlock: result.data, + amountReceived: BigNumber(amountReceived).minus(protocolFeeAmount).toFixed(0).toString(), + protocolFee: protocolFeeAmount, }); } else { await this.eventLogRepository.updateStatusAndRetryEvenLog({ diff --git a/src/shared/utils/bignumber.ts b/src/shared/utils/bignumber.ts index da2b2b0..8fee18b 100644 --- a/src/shared/utils/bignumber.ts +++ b/src/shared/utils/bignumber.ts @@ -11,6 +11,5 @@ export const calculateFee = (amount: string, gasFee: string | number, tipPercent .minus(BigNumber(gasFee)) .multipliedBy(tipPercent * 10) .dividedBy(1000); - return BigNumber(gasFee).plus(tip).toFixed(0, BigNumber.ROUND_UP); };