Skip to content

Commit

Permalink
add notsumbited field
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoch05 committed Apr 12, 2024
1 parent 726d13b commit b2fb9d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion apollo/src/aggregation/aggregation.history.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ type HealthInfo {
type Query {
historyRecordById(id: String): HistoryRecord
historyRecordByTxHash(txHash: String): HistoryRecord
firstHistoryRecord(fromChain: String, toChain: String, bridge: String, results: [Int], relayer: String, token: String, order: String): HistoryRecord
firstHistoryRecord(fromChain: String, toChain: String, bridge: String, results: [Int], relayer: String, token: String, order: String, notsubmited: Boolean): HistoryRecord
queryDailyStatistics(timepast: Int!, first: Int, from: String, to: String, bridge: String, token: String): [DailyStatistics]
historyRecords(sender: String, recipient: String, relayer: String, needWithdrawLiquidity: Boolean, fromChains: [String], toChains: [String], bridges: [String], row: Int, page: Int, results: [Int], recvTokenAddress: String, order: String): HistoryRecords
checkLnBridgeExist(fromChainId: Int, toChainId: Int, fromToken: String, toToken: String, version: String): Boolean
Expand Down
21 changes: 13 additions & 8 deletions apollo/src/aggregation/aggregation.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export class AggregationResolver {
@Args('results') results: number[],
@Args('relayer') relayer: string,
@Args('token') token: string,
@Args('order') order: string
@Args('order') order: string,
@Args('notsubmited') notsubmited: boolean,
) {
const orderCondition = order?.split('_');
const orderBy =
orderCondition && orderCondition.length == 2
? { [orderCondition[0]]: orderCondition[1] }
: { startTime: Prisma.SortOrder.desc };
const resultCondition = results && results.length ? { result: { in: results } } : {};
const submitCondition = notsubmited ? { confirmedBlocks: { search: '!0x' } } : {};

return this.aggregationService.queryHistoryRecordFirst(
{
AND: {
Expand All @@ -47,6 +50,7 @@ export class AggregationResolver {
bridge: bridge,
relayer: relayer,
sendTokenAddress: token,
...submitCondition,
...resultCondition,
},
},
Expand Down Expand Up @@ -395,14 +399,18 @@ export class AggregationResolver {
console.log(`get softTransferLimit failed ${record.id}, exception: ${e}`);
continue;
}
const providerFee = BigInt(amount) * BigInt(record.liquidityFeeRate) / BigInt(100000) + BigInt(record.baseFee);
if (limit < BigInt(amount) + providerFee + BigInt(record.protocolFee) || record.paused) {
continue;
}
// offline
if (record.heartbeatTimestamp + this.heartbeatTimeout < now) {
continue;
}

if (limit > transferLimit) {
transferLimit = limit;
}
const providerFee = BigInt(amount) * BigInt(record.liquidityFeeRate) / BigInt(100000) + BigInt(record.baseFee);
if (limit < BigInt(amount) + providerFee + BigInt(record.protocolFee) || record.paused) {
continue;
}
const point = await this.aggregationService.calculateLnBridgeRelayerPoint(
sendToken,
BigInt(amount),
Expand All @@ -412,9 +420,6 @@ export class AggregationResolver {
if (point == null) {
continue;
}
if (limit > transferLimit) {
transferLimit = limit;
}
sortedRelayers.push({ record, point });
}
return {
Expand Down
2 changes: 1 addition & 1 deletion apollo/src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export abstract class IQuery {

abstract historyRecordByTxHash(txHash?: Nullable<string>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;

abstract firstHistoryRecord(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, results?: Nullable<Nullable<number>[]>, relayer?: Nullable<string>, token?: Nullable<string>, order?: Nullable<string>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;
abstract firstHistoryRecord(fromChain?: Nullable<string>, toChain?: Nullable<string>, bridge?: Nullable<string>, results?: Nullable<Nullable<number>[]>, relayer?: Nullable<string>, token?: Nullable<string>, order?: Nullable<string>, notsubmited?: Nullable<boolean>): Nullable<HistoryRecord> | Promise<Nullable<HistoryRecord>>;

abstract queryDailyStatistics(timepast: number, first?: Nullable<number>, from?: Nullable<string>, to?: Nullable<string>, bridge?: Nullable<string>, token?: Nullable<string>): Nullable<Nullable<DailyStatistics>[]> | Promise<Nullable<Nullable<DailyStatistics>[]>>;

Expand Down

0 comments on commit b2fb9d7

Please sign in to comment.