Skip to content

Commit

Permalink
Fix taiko
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Jul 23, 2024
1 parent 8f1b274 commit c9929ea
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"ts-loader": "^9.3.1"
},
"dependencies": {
"@defillama/sdk": "^5.0.74",
"@defillama/sdk": "^5.0.76",
"@graphql-typed-document-node/core": "^3.2.0",
"@solana/web3.js": "^1.87.3",
"async-retry": "^1.3.1",
Expand Down
36 changes: 17 additions & 19 deletions src/adapters/orbiter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const eoaAddressErc = [
"0x732efacd14b0355999aebb133585787921aba3a9",
"0x34723b92ae9708ba33843120a86035d049da7dfa",
"0x095d2918b03b2e86d68551dcf11302121fb626c9",
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111"
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111",
];

const eoaAddressNative = [
Expand All @@ -54,7 +54,7 @@ const eoaAddressNative = [
"0x732efacd14b0355999aebb133585787921aba3a9",
"0x34723b92ae9708ba33843120a86035d049da7dfa",
"0x095d2918b03b2e86d68551dcf11302121fb626c9",
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111"
"0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111",
];

const nativeTokens: Record<string, string> = {
Expand All @@ -81,10 +81,10 @@ const nativeTokens: Record<string, string> = {
bouncebit: "0x7F150c293c97172C75983BD8ac084c187107eA19",
zkfair: "0x4b21b980d0Dc7D3C0C6175b0A412694F3A1c7c6b",
bsquared: "0x8dbf84c93727c85DB09478C83a8621e765D20eC2",
"tko-mainnet": "0xA51894664A773981C6C112C43ce576f315d5b1B6",
taiko: "0xA51894664A773981C6C112C43ce576f315d5b1B6",
};

const padContractsAddresses: Record<string, string[]> = {
const padContractsAddresses: Record<string, string[]> = {
ethereum: ["0x5D77b0c9855F44a8fbEf34E670e243E988682a82"],
base: ["0x5D77b0c9855F44a8fbEf34E670e243E988682a82"],
linea: ["0x5D77b0c9855F44a8fbEf34E670e243E988682a82"],
Expand All @@ -94,7 +94,7 @@ const padContractsAddresses: Record<string, string[]> = {
polygon_zkevm: ["0x5D77b0c9855F44a8fbEf34E670e243E988682a82"],
blast: ["0x176BAa4c563985209c159F3ecC7D9F09d3914dE0"],
// "bob": ['0x5D77b0c9855F44a8fbEf34E670e243E988682a82'], not support yet
"tko-mainnet": ["0x176BAa4c563985209c159F3ecC7D9F09d3914dE0"],
taiko: ["0x176BAa4c563985209c159F3ecC7D9F09d3914dE0"],
};

const nativeTokenTransferSignature = ["0x535741", "0x", "0x52346412", "0xf9c028ec"];
Expand All @@ -121,12 +121,11 @@ const constructParams = (chain: string) => {
txs = await getTxsBlockRangeMerlinScan(address, fromBlock, toBlock, {
includeSignatures: nativeTokenTransferSignature,
});
} else if(chain === "btr") {
} else if (chain === "btr") {
txs = await getTxsBlockRangeBtrScan(address, fromBlock, toBlock, {
includeSignatures: nativeTokenTransferSignature
})
}
else {
includeSignatures: nativeTokenTransferSignature,
});
} else {
txs = await getTxsBlockRangeEtherscan(chain, address, fromBlock, toBlock, {
includeSignatures: nativeTokenTransferSignature,
});
Expand All @@ -153,16 +152,15 @@ const constructParams = (chain: string) => {
const txs: any[] = await getTxsBlockRangeEtherscan(chain, address, fromBlock, toBlock, {
includeSignatures: padContractSignature,
});
const eventsRes: EventData[] = []
for( const tx of txs) {
const eventsRes: EventData[] = [];
for (const tx of txs) {
let value = BigNumber.from(0);
let isDepositTemp = true;
if(tx.value == '0') {
const {internalValue, isDeposit} = await getPadContractTxValue(chain, tx.hash);
if (tx.value == "0") {
const { internalValue, isDeposit } = await getPadContractTxValue(chain, tx.hash);
value = internalValue;
isDepositTemp = isDeposit;
}
else {
} else {
value = BigNumber.from(tx.value);
}
const event: EventData = {
Expand All @@ -178,9 +176,9 @@ const constructParams = (chain: string) => {
}
return eventsRes;
})
)
);

const allEvents: EventData[] = [...contractEvents.flat(), ...nativeEvents.flat(), ...eventLogData]
const allEvents: EventData[] = [...contractEvents.flat(), ...nativeEvents.flat(), ...eventLogData];
const filteredEvents = allEvents.filter(
(event) =>
!blackListedAddresses.includes(event?.from?.toLowerCase()) &&
Expand All @@ -205,7 +203,7 @@ const adapter: BridgeAdapter = {
merlin: constructParams("merlin"),
zklink: constructParams("zklink"),
bsc: constructParams("bsc"),
taiko: constructParams("tko-mainnet"),
taiko: constructParams("taiko"),
bitlayer: constructParams("btr"),
// mantle: constructParams("mantle"), // no etherscan
// zkfair: constructParams("zkfair"), // no etherscan
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const endpoints = {
arbitrum_nova: "https://api-nova.arbiscan.io",
era: "https://api-era.zksync.network",
zklink: "https://explorer-api.zklink.io",
"tko-mainnet": "https://api.taikoscan.io"
taiko: "https://api.taikoscan.io",
} as { [chain: string]: string };

const apiKeys = {
Expand All @@ -41,7 +41,7 @@ const apiKeys = {
arbitrum_nova: "SZZE864TZH3MGRUUDPRPUS7NF8MAFZBDAZ",
polygon_zkevm: "XKFP275U27W7AI4NGUIT7VGEQ179P4XA1S",
era: "9HJZA6X8DEJ46WHMM2UEJ5WCXPG31C7EWI",
"tko-mainnet": "DYUMJ7MP38G6TFY173JA2E9DJ9TXYI1RYD"
taiko: "DYUMJ7MP38G6TFY173JA2E9DJ9TXYI1RYD",
} as { [chain: string]: string };

export const getTxsBlockRangeEtherscan = async (
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const maxBlocksToQueryByChain = {
klaytn: 6000,
sui: 2400, // sui creates a checkpoint about every 3 seconds
solana: 18000, // solana produces slots every 400ms, so 2 hours is 18000 slotsб
"tko-mainnet": 100,
taiko: 100,
} as { [chain: string]: number };

// will be handled by the bridge adapter
Expand Down

0 comments on commit c9929ea

Please sign in to comment.