Skip to content

Commit

Permalink
add transfer events abi for arb and ftm
Browse files Browse the repository at this point in the history
  • Loading branch information
0xyijing committed Oct 11, 2023
1 parent ee5c5fa commit 5f4f5f5
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 23 deletions.
17 changes: 7 additions & 10 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ services:
FEAT_ONCHAIN_GOVERNANCE: "true"
ONCHAIN_GOVERNANCE_START_BLOCK: 16990159
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 10247094
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'

event-pipeline-bsc:
Expand Down Expand Up @@ -101,7 +100,7 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 15860129
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 5375047
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c'

event-pipeline-polygon:
depends_on:
Expand Down Expand Up @@ -135,7 +134,7 @@ services:
FEAT_META_TRANSACTION_EXECUTED_EVENT: "true"
META_TRANSACTION_EXECUTED_START_BLOCK: 39406300
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 14391480
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'

event-pipeline-avalanche:
depends_on:
Expand Down Expand Up @@ -164,7 +163,8 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 11816835
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 3601700
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7'


event-pipeline-fantom:
depends_on:
Expand Down Expand Up @@ -194,7 +194,7 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 32817445
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 18855765
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83'

event-pipeline-celo:
depends_on:
Expand All @@ -219,8 +219,6 @@ services:
MINUTES_BETWEEN_RUNS: 1
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 11820000
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 9350111

event-pipeline-optimism:
depends_on:
Expand All @@ -246,7 +244,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 4214981
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 1691335
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: "0x4200000000000000000000000000000000000006"

event-pipeline-arbitrum:
Expand All @@ -273,7 +270,7 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 4050733
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 4050733
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'

event-pipeline-base:
depends_on:
Expand All @@ -298,7 +295,7 @@ services:
KAFKA_AUTH_USER: '${KAFKA_AUTH_USER}'
KAFKA_AUTH_PASSWORD: '${KAFKA_AUTH_PASSWORD}'
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 1410394
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x4200000000000000000000000000000000000006'

token-scraper-ethereum:
depends_on:
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ services:
FEAT_ONCHAIN_GOVERNANCE: "true"
ONCHAIN_GOVERNANCE_START_BLOCK: 16990159
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 10247094
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'

event-pipeline-bsc:
Expand Down Expand Up @@ -101,7 +100,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 15860129
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 5375047
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c'

event-pipeline-polygon:
Expand Down Expand Up @@ -136,7 +134,6 @@ services:
FEAT_META_TRANSACTION_EXECUTED_EVENT: "true"
META_TRANSACTION_EXECUTED_START_BLOCK: 39406300
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 14391480
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270'

event-pipeline-avalanche:
Expand Down Expand Up @@ -166,7 +163,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 11816835
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 3601700
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7'


Expand Down Expand Up @@ -198,7 +194,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 32817445
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 18855765
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83'

event-pipeline-celo:
Expand Down Expand Up @@ -249,7 +244,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 4214981
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 1691335
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: "0x4200000000000000000000000000000000000006"

event-pipeline-arbitrum:
Expand All @@ -276,7 +270,6 @@ services:
FEAT_NFT: "true"
NFT_FEATURE_START_BLOCK: 4050733
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 4050733
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1'

event-pipeline-base:
Expand All @@ -302,7 +295,6 @@ services:
KAFKA_AUTH_USER: '${KAFKA_AUTH_USER}'
KAFKA_AUTH_PASSWORD: '${KAFKA_AUTH_PASSWORD}'
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_START_BLOCK: 1410394
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x4200000000000000000000000000000000000006'

token-scraper-ethereum:
Expand Down
12 changes: 12 additions & 0 deletions src/abis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1012,3 +1012,15 @@ export const UNWRAP_NATIVE_ABI = {
name: 'Withdrawal',
type: 'event',
};

// The ABI for the `Transfer` event of the ERC20 and ERC721 token contract.
export const TRANSFER_ABI = {
anonymous: false,
inputs: [
{ indexed: true, internalType: 'address', name: 'from', type: 'address' },
{ indexed: true, internalType: 'address', name: 'to', type: 'address' },
{ indexed: false, internalType: 'uint256', name: 'value', type: 'uint256' },
],
name: 'Transfer',
type: 'event',
};
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ export const FEAT_WRAP_UNWRAP_NATIVE_EVENT = getBoolConfig(
DEFAULT_FEAT_WRAP_UNWRAP_NATIVE_EVENT,
);

export const WRAP_UNWRAP_NATIVE_START_BLOCK = getIntConfig('WRAP_UNWRAP_NATIVE_START_BLOCK', -1);
export const WRAP_UNWRAP_NATIVE_START_BLOCK = getIntConfig('EP_DEPLOYMENT_BLOCK', -1);

validateStartBlock(
'WRAP_UNWRAP_NATIVE_START_BLOCK',
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,4 @@ export const DEFAULT_UNISWAP_V3_FACTORY_ADDRESS = '0x1f98431c8ad98523631ae4a59f2

export const WRAP_NATIVE_EVENT_TOPIC = ['0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c'];
export const UNWRAP_NATIVE_EVENT_TOPIC = ['0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65'];
export const TRANSFER_EVENT_TOPIC_0 = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
34 changes: 33 additions & 1 deletion src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ import {
ZEROEX_TREASURY_GOVERNOR_CONTRACT_ADDRESS,
WRAP_NATIVE_EVENT_TOPIC,
UNWRAP_NATIVE_EVENT_TOPIC,
TRANSFER_EVENT_TOPIC_0,
} from './constants';

import { DeleteOptions } from './utils';
Expand Down Expand Up @@ -149,7 +150,12 @@ import {
parseOnchainGovernanceCallScheduledEvent,
} from './parsers/events/onchain_governance_events';

import { parseWrapNativeEvent, parseUnwrapNativeEvent } from './parsers/events/wrap_unwrap_native_events';
import {
parseWrapNativeEvent,
parseUnwrapNativeEvent,
parseWrapNativeTransferEvent,
parseUnwrapNativeTransferEvent,
} from './parsers/events/wrap_unwrap_native_events';

import { TokenMetadataMap } from './scripts/utils/web3_utils';
import { UniV2PoolSingleton } from './uniV2PoolSingleton';
Expand Down Expand Up @@ -588,6 +594,32 @@ export const eventScrperProps: EventScraperProps[] = [
tokenMetadataMap: null,
callback: null,
},
{
enabled: FEAT_WRAP_UNWRAP_NATIVE_EVENT,
name: 'WrapNativeTransferEvent',
tType: WrapNativeEvent,
table: 'wrap_native_events',
topics: [TRANSFER_EVENT_TOPIC_0, '0x0000000000000000000000000000000000000000000000000000000000000000', null],
contractAddress: WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS,
startBlock: WRAP_UNWRAP_NATIVE_START_BLOCK,
parser: parseWrapNativeTransferEvent,
deleteOptions: {},
tokenMetadataMap: null,
callback: null,
},
{
enabled: FEAT_WRAP_UNWRAP_NATIVE_EVENT,
name: 'UnwrapNativeTransferEvent',
tType: UnwrapNativeEvent,
table: 'unwrap_native_events',
topics: [TRANSFER_EVENT_TOPIC_0, null, '0x0000000000000000000000000000000000000000000000000000000000000000'],
contractAddress: WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS,
startBlock: WRAP_UNWRAP_NATIVE_START_BLOCK,
parser: parseUnwrapNativeTransferEvent,
deleteOptions: {},
tokenMetadataMap: null,
callback: null,
},
];

for (const payment_recipient of POLYGON_RFQM_PAYMENTS_ADDRESSES) {
Expand Down
29 changes: 26 additions & 3 deletions src/parsers/events/wrap_unwrap_native_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ import { RawLogEntry } from 'ethereum-types';
import { WrapNativeEvent, UnwrapNativeEvent } from '../../entities';

import { parseEvent } from './parse_event';
import { WRAP_NATIVE_ABI, UNWRAP_NATIVE_ABI } from '../../constants';
import { WRAP_NATIVE_ABI, UNWRAP_NATIVE_ABI, TRANSFER_ABI } from '../../constants';
import { BigNumber } from '@0x/utils';

export function parseWrapNativeEvent(eventLog: RawLogEntry): WrapNativeEvent {
const wrapNativeEvent = new WrapNativeEvent();

parseEvent(eventLog, wrapNativeEvent);
// decode the basic info
//

const decodedLog = abiCoder.decodeLog(WRAP_NATIVE_ABI.inputs, eventLog.data, [eventLog.topics[1]]);

wrapNativeEvent.dst = decodedLog.dst.toLowerCase();
Expand All @@ -32,3 +30,28 @@ export function parseUnwrapNativeEvent(eventLog: RawLogEntry): UnwrapNativeEvent

return unwrapNativeEvent;
}

export function parseWrapNativeTransferEvent(eventLog: RawLogEntry): WrapNativeEvent {
const wrapNativeEvent = new WrapNativeEvent();

parseEvent(eventLog, wrapNativeEvent);
// decode the basic info
const decodedLog = abiCoder.decodeLog(TRANSFER_ABI.inputs, eventLog.data, eventLog.topics.slice(1));

wrapNativeEvent.dst = decodedLog.to.toLowerCase();
wrapNativeEvent.wad = new BigNumber(decodedLog.value);

return wrapNativeEvent;
}

export function parseUnwrapNativeTransferEvent(eventLog: RawLogEntry): UnwrapNativeEvent {
const unwrapNativeEvent = new UnwrapNativeEvent();
parseEvent(eventLog, unwrapNativeEvent);
// decode the basic info
const decodedLog = abiCoder.decodeLog(TRANSFER_ABI.inputs, eventLog.data, eventLog.topics.slice(1));

unwrapNativeEvent.src = decodedLog.from.toLowerCase();
unwrapNativeEvent.wad = new BigNumber(decodedLog.value);

return unwrapNativeEvent;
}

0 comments on commit 5f4f5f5

Please sign in to comment.