From 6203798625c72d9acc505242b6a157b406aeb599 Mon Sep 17 00:00:00 2001 From: ponyjackal Date: Fri, 10 May 2024 10:04:05 -0700 Subject: [PATCH] feat: extract abi for acrossProtocol --- .../abis/AcrossProtcolRelayer.ts | 169 +++++++++++++++++ .../bridges/acrossProtocol/constants.ts | 174 +----------------- .../bridges/acrossProtocol/destination.ts | 9 +- .../bridges/acrossProtocol/source.ts | 6 +- 4 files changed, 182 insertions(+), 176 deletions(-) create mode 100644 src/contextualizers/bridges/acrossProtocol/abis/AcrossProtcolRelayer.ts diff --git a/src/contextualizers/bridges/acrossProtocol/abis/AcrossProtcolRelayer.ts b/src/contextualizers/bridges/acrossProtocol/abis/AcrossProtcolRelayer.ts new file mode 100644 index 00000000..e9d01a19 --- /dev/null +++ b/src/contextualizers/bridges/acrossProtocol/abis/AcrossProtcolRelayer.ts @@ -0,0 +1,169 @@ +const abi = [ + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'originChainId', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint256', + name: 'destinationChainId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'int64', + name: 'relayerFeePct', + type: 'int64', + }, + { + indexed: true, + internalType: 'uint32', + name: 'depositId', + type: 'uint32', + }, + { + indexed: false, + internalType: 'uint32', + name: 'quoteTimestamp', + type: 'uint32', + }, + { + indexed: false, + internalType: 'address', + name: 'originToken', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'depositor', + type: 'address', + }, + { indexed: false, internalType: 'bytes', name: 'message', type: 'bytes' }, + ], + name: 'FundsDeposited', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'totalFilledAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'fillAmount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'repaymentChainId', + type: 'uint256', + }, + { + indexed: true, + internalType: 'uint256', + name: 'originChainId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'destinationChainId', + type: 'uint256', + }, + { + indexed: false, + internalType: 'int64', + name: 'relayerFeePct', + type: 'int64', + }, + { + indexed: false, + internalType: 'int64', + name: 'realizedLpFeePct', + type: 'int64', + }, + { + indexed: true, + internalType: 'uint32', + name: 'depositId', + type: 'uint32', + }, + { + indexed: false, + internalType: 'address', + name: 'destinationToken', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'relayer', + type: 'address', + }, + { + indexed: true, + internalType: 'address', + name: 'depositor', + type: 'address', + }, + { + indexed: false, + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { indexed: false, internalType: 'bytes', name: 'message', type: 'bytes' }, + { + components: [ + { internalType: 'address', name: 'recipient', type: 'address' }, + { internalType: 'bytes', name: 'message', type: 'bytes' }, + { internalType: 'int64', name: 'relayerFeePct', type: 'int64' }, + { internalType: 'bool', name: 'isSlowRelay', type: 'bool' }, + { + internalType: 'int256', + name: 'payoutAdjustmentPct', + type: 'int256', + }, + ], + indexed: false, + internalType: 'struct SpokePool.RelayExecutionInfo', + name: 'updatableRelayData', + type: 'tuple', + }, + ], + name: 'FilledRelay', + type: 'event', + }, +] as const; + +export default abi; diff --git a/src/contextualizers/bridges/acrossProtocol/constants.ts b/src/contextualizers/bridges/acrossProtocol/constants.ts index a7396386..54cbbb77 100644 --- a/src/contextualizers/bridges/acrossProtocol/constants.ts +++ b/src/contextualizers/bridges/acrossProtocol/constants.ts @@ -1,173 +1,7 @@ -// Across Protocol event hashes and sigs -export const FUNDS_DEPOSITED_EVENT_ABI = [ - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'originChainId', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'destinationChainId', - type: 'uint256', - }, - { - indexed: false, - internalType: 'int64', - name: 'relayerFeePct', - type: 'int64', - }, - { - indexed: true, - internalType: 'uint32', - name: 'depositId', - type: 'uint32', - }, - { - indexed: false, - internalType: 'uint32', - name: 'quoteTimestamp', - type: 'uint32', - }, - { - indexed: false, - internalType: 'address', - name: 'originToken', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'depositor', - type: 'address', - }, - { indexed: false, internalType: 'bytes', name: 'message', type: 'bytes' }, - ], - name: 'FundsDeposited', - type: 'event', - }, -]; -export const FILLED_RELAY_EVENT_ABI = [ - { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'amount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'totalFilledAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'fillAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'repaymentChainId', - type: 'uint256', - }, - { - indexed: true, - internalType: 'uint256', - name: 'originChainId', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'destinationChainId', - type: 'uint256', - }, - { - indexed: false, - internalType: 'int64', - name: 'relayerFeePct', - type: 'int64', - }, - { - indexed: false, - internalType: 'int64', - name: 'realizedLpFeePct', - type: 'int64', - }, - { - indexed: true, - internalType: 'uint32', - name: 'depositId', - type: 'uint32', - }, - { - indexed: false, - internalType: 'address', - name: 'destinationToken', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'relayer', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'depositor', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'recipient', - type: 'address', - }, - { indexed: false, internalType: 'bytes', name: 'message', type: 'bytes' }, - { - components: [ - { internalType: 'address', name: 'recipient', type: 'address' }, - { internalType: 'bytes', name: 'message', type: 'bytes' }, - { internalType: 'int64', name: 'relayerFeePct', type: 'int64' }, - { internalType: 'bool', name: 'isSlowRelay', type: 'bool' }, - { - internalType: 'int256', - name: 'payoutAdjustmentPct', - type: 'int256', - }, - ], - indexed: false, - internalType: 'struct SpokePool.RelayExecutionInfo', - name: 'updatableRelayData', - type: 'tuple', - }, - ], - name: 'FilledRelay', - type: 'event', - }, -]; +import relayerAbi from './abis/AcrossProtcolRelayer'; + +export const ACROSS_PROTOCOL_RELAYER_ABI = relayerAbi; + export const ACROSS_PROTOCOL_RELAYERS = { 1: '0x5c7bcd6e7de5423a257d81b442095a1a6ced35c5', // ethereum 8453: '0x09aea4b2242abc8bb4bb78d537a67a245a7bec64', // base diff --git a/src/contextualizers/bridges/acrossProtocol/destination.ts b/src/contextualizers/bridges/acrossProtocol/destination.ts index 233000ae..404b18f0 100644 --- a/src/contextualizers/bridges/acrossProtocol/destination.ts +++ b/src/contextualizers/bridges/acrossProtocol/destination.ts @@ -6,7 +6,10 @@ import { HeuristicContextActionEnum, Log, } from '../../../types'; -import { FILLED_RELAY_EVENT_ABI, ACROSS_PROTOCOL_RELAYERS } from './constants'; +import { + ACROSS_PROTOCOL_RELAYER_ABI, + ACROSS_PROTOCOL_RELAYERS, +} from './constants'; import { decodeLog } from '../../../helpers/utils'; export function contextualize(transaction: Transaction): Transaction { @@ -30,7 +33,7 @@ export function detect(transaction: Transaction): boolean { if (log.address !== ACROSS_PROTOCOL_RELAYERS[originChainId]) return false; const decoded = decodeLog( - FILLED_RELAY_EVENT_ABI as Abi, + ACROSS_PROTOCOL_RELAYER_ABI as Abi, log.data as Hex, [log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics, ); @@ -53,7 +56,7 @@ export function generate(transaction: Transaction): Transaction { if (log.address !== ACROSS_PROTOCOL_RELAYERS[originChainId]) return false; const decoded = decodeLog( - FILLED_RELAY_EVENT_ABI as Abi, + ACROSS_PROTOCOL_RELAYER_ABI as Abi, log.data as Hex, [log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics, ); diff --git a/src/contextualizers/bridges/acrossProtocol/source.ts b/src/contextualizers/bridges/acrossProtocol/source.ts index 23fd3029..17e38f9d 100644 --- a/src/contextualizers/bridges/acrossProtocol/source.ts +++ b/src/contextualizers/bridges/acrossProtocol/source.ts @@ -7,7 +7,7 @@ import { Log, } from '../../../types'; import { - FUNDS_DEPOSITED_EVENT_ABI, + ACROSS_PROTOCOL_RELAYER_ABI, ACROSS_PROTOCOL_RELAYERS, } from './constants'; import { decodeLog } from '../../../helpers/utils'; @@ -33,7 +33,7 @@ export function detect(transaction: Transaction): boolean { if (log.address !== ACROSS_PROTOCOL_RELAYERS[originChainId]) return false; const decoded = decodeLog( - FUNDS_DEPOSITED_EVENT_ABI as Abi, + ACROSS_PROTOCOL_RELAYER_ABI as Abi, log.data as Hex, [log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics, ); @@ -57,7 +57,7 @@ export function generate(transaction: Transaction): Transaction { if (log.address !== ACROSS_PROTOCOL_RELAYERS[originChainId]) return false; const decoded = decodeLog( - FUNDS_DEPOSITED_EVENT_ABI as Abi, + ACROSS_PROTOCOL_RELAYER_ABI as Abi, log.data as Hex, [log.topic0, log.topic1, log.topic2, log.topic3] as EventLogTopics, );