Skip to content

Commit

Permalink
Merge pull request #371 from Once-Upon/feature/ou-2182-extract-across…
Browse files Browse the repository at this point in the history
…-protocol-abi-snippet-consts-into-an-abis-dir

feat: extract abi for acrossProtocol
  • Loading branch information
pcowgill authored May 13, 2024
2 parents bfc7cda + 6203798 commit 862f242
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 176 deletions.
Original file line number Diff line number Diff line change
@@ -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;
174 changes: 4 additions & 170 deletions src/contextualizers/bridges/acrossProtocol/constants.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/contextualizers/bridges/acrossProtocol/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
);
Expand All @@ -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,
);
Expand Down
Loading

0 comments on commit 862f242

Please sign in to comment.