diff --git a/apollo/src/aggregation/aggregation.resolver.ts b/apollo/src/aggregation/aggregation.resolver.ts index 02aaee74..d2061ac4 100644 --- a/apollo/src/aggregation/aggregation.resolver.ts +++ b/apollo/src/aggregation/aggregation.resolver.ts @@ -79,8 +79,8 @@ export class AggregationResolver { const isValid = (item) => !Object.values(item).some((value) => isUndefined(value) || isNull(value) || value === ''); - const accFilters = [{ sender }, { recipient }].filter(isValid); - const relayerFilters = [{ relayer }, { needWithdrawLiquidity }].filter(isValid); + const accFilters = [{ sender: sender.toLowerCase() }, { recipient }].filter(isValid); + const relayerFilters = [{ relayer: relayer.toLowerCase() }, { needWithdrawLiquidity }].filter(isValid); const accountCondition = accFilters.length ? { OR: accFilters } : {}; const relayerCondition = relayerFilters.length ? { AND: relayerFilters } : {}; const resultCondition = results && results.length ? { result: { in: results } } : {}; @@ -89,7 +89,7 @@ export class AggregationResolver { const toChainCondition = toChains && toChains.length ? { toChain: { in: toChains } } : {}; const bridgeCondition = bridges && bridges.length ? { bridge: { in: bridges } } : {}; const recvTokenCondition = - recvTokenAddress && recvTokenAddress.length ? { recvTokenAddress: recvTokenAddress } : {}; + recvTokenAddress && recvTokenAddress.length ? { recvTokenAddress: recvTokenAddress.toLowerCase() } : {}; const chainConditions = { AND: { ...resultCondition, diff --git a/apollo/src/lnv3/lnv3.service.ts b/apollo/src/lnv3/lnv3.service.ts index e2cf4a4e..180139de 100644 --- a/apollo/src/lnv3/lnv3.service.ts +++ b/apollo/src/lnv3/lnv3.service.ts @@ -183,7 +183,7 @@ export class Lnv3Service implements OnModuleInit { if (record.endTxHash === '') { const toChain = this.getDestChain(dstChainId); - const query = `query { lnv3RelayRecord(id: "${transferId}") { id, relayer, timestamp, transactionHash, slashed, requestWithdrawTimestamp }}`; + const query = `query { lnv3RelayRecord(id: "${transferId}") { id, relayer, timestamp, transactionHash, slashed, requestWithdrawTimestamp, fee }}`; const relayRecord = await axios .post(toChain.url, { query: query, @@ -216,6 +216,25 @@ export class Lnv3Service implements OnModuleInit { where: { id: record.id }, data: updateData, }); + + const cost = relayRecord.slashed ? relayRecord.fee : 0; + const profit = relayRecord.slashed ? record.fee : 0; + const providerId = this.genRelayInfoID( + transfer.chainId, + toChain.chainId, + record.relayer, + record.sendTokenAddress + ); + const relayerInfo = await this.aggregationService.queryLnBridgeRelayInfoById({ + id: providerId, + }); + await this.aggregationService.updateLnBridgeRelayInfo({ + where: { id: providerId }, + data: { + cost: (BigInt(relayerInfo.cost) + BigInt(cost)).toString(), + profit: (BigInt(relayerInfo.profit) + BigInt(profit)).toString(), + }, + }); this.logger.log( `lnv3 [${transfer.chain}->${toChain.chain}] new status id: ${record.id} relayed responseTxHash: ${relayRecord.transactionHash}`