Skip to content

Commit

Permalink
Merge pull request #38 from DefiLlama/cc7768/across_new_chains
Browse files Browse the repository at this point in the history
Cc7768/across new chains
  • Loading branch information
vrtnd authored Aug 23, 2023
2 parents 7ba27ee + 2b2ceb2 commit 9b5c808
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 31 deletions.
73 changes: 43 additions & 30 deletions src/adapters/across/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,26 @@ For all tokens using 'spokepool' contracts:
const contracts = {
ethereum: {
spokePoolv2: "0x4D9079Bb4165aeb4084c526a32695dCfd2F77381",
spokePoolv2p5: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5"
spokePoolv2p5: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5",
},
polygon: {
spokePoolv2: "0x69B5c72837769eF1e7C164Abc6515DcFf217F920",
spokePoolv2p5: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096"
spokePoolv2p5: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
},
arbitrum: {
spokePoolv2: "0xB88690461dDbaB6f04Dfad7df66B7725942FEb9C",
spokePoolv2p5: "0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A"
spokePoolv2p5: "0xe35e9842fceaCA96570B734083f4a58e8F7C5f2A",
},
optimism: {
spokePoolv2: "0xa420b2d1c0841415A695b81E5B867BCD07Dff8C9",
spokePoolv2p5: "0x6f26Bf09B1C792e3228e5467807a900A503c0281"
}
spokePoolv2p5: "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
},
era: {
spokePoolv2p5: "0xE0B015E54d54fc84a6cB9B666099c46adE9335FF",
},
base: {
spokePoolv2p5: "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64",
},
} as const;

type SupportedChains = keyof typeof contracts;
Expand Down Expand Up @@ -111,34 +117,39 @@ const relaysParamsv2: PartialContractEventParams = {
};

const constructParams = (chain: SupportedChains) => {
// New Spoke Pools
const finalDepositParamsv2p5 = {
...depositParamsv2p5,
target: contracts[chain].spokePoolv2p5,
};
const eventParams: PartialContractEventParams[] = [];

const finalRelaysParamsv2p5 = {
...relaysParamsv2p5,
target: contracts[chain].spokePoolv2p5,
};
const chainConfig = contracts[chain];

// Old Spoke Pools
const finalDepositParamsv2 = {
...depositParamsv2,
target: contracts[chain].spokePoolv2,
};

const finalRelaysParamsv2 = {
...relaysParamsv2,
target: contracts[chain].spokePoolv2,
};

const eventParams = [
finalDepositParamsv2p5,
finalRelaysParamsv2p5,
finalDepositParamsv2,
finalRelaysParamsv2,
]
if ("spokePoolv2" in chainConfig) {
const finalDepositParamsv2 = {
...depositParamsv2,
target: chainConfig.spokePoolv2,
};
eventParams.push(finalDepositParamsv2);

const finalRelaysParamsv2 = {
...relaysParamsv2,
target: chainConfig.spokePoolv2,
};
eventParams.push(finalRelaysParamsv2);
}

// New Spoke Pools
if ("spokePoolv2p5" in chainConfig) {
const finalDepositParamsv2p5 = {
...depositParamsv2p5,
target: chainConfig.spokePoolv2p5,
};
eventParams.push(finalDepositParamsv2p5);

const finalRelaysParamsv2p5 = {
...relaysParamsv2p5,
target: chainConfig.spokePoolv2p5,
};
eventParams.push(finalRelaysParamsv2p5);
}

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("across", chain, fromBlock, toBlock, eventParams);
Expand All @@ -149,6 +160,8 @@ const adapter: BridgeAdapter = {
polygon: constructParams("polygon"),
arbitrum: constructParams("arbitrum"),
optimism: constructParams("optimism"),
"zksync era": constructParams("era"),
base: constructParams("base"),
};

export default adapter;
5 changes: 4 additions & 1 deletion src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ export default [
iconLink: "icons:across",
largeTxThreshold: 10000,
url: "",
chains: ["Ethereum", "Polygon", "Arbitrum", "Optimism"],
chains: ["Ethereum", "Polygon", "Arbitrum", "Optimism", "zkSync Era", "Base"],
chainMapping: {
"zksync era": "era",
},
},
/*
{
Expand Down

0 comments on commit 9b5c808

Please sign in to comment.