Skip to content

Commit

Permalink
Merge pull request #96 from celer-network/update-celer-cctp
Browse files Browse the repository at this point in the history
Add Celer CCTP
  • Loading branch information
vrtnd authored Dec 21, 2023
2 parents 4eaa785 + 5b22696 commit b168d93
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/adapters/celer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import { constructTransferParams } from "../../helpers/eventParams";
0x7510792A3B1969F9307F3845CE88e39578f2bAE1 is OriginalTokenVaultV2
0x16365b45EB269B5B5dACB34B4a15399Ec79b95eB is PeggedTokenBridge
0x52E4f244f380f8fA51816c8a10A63105dd4De084 is PeggedTokenBridgeV2
0x6065a982f04f759b7d2d042d2864e569fad84214 is CircleBridgeProxy
***Polygon***
0x88DCDC47D2f83a99CF0000FDF667A468bB958a78 is Celer Network: cBridge (pool-based)
0xc1a2D967DfAa6A10f3461bc21864C23C1DD51EeA is OriginalTokenVault
0x4C882ec256823eE773B25b414d36F92ef58a7c0C is OriginalTokenVaultV2
0x4d58FDC7d0Ee9b674F49a0ADE11F26C3c9426F7A is PeggedTokenBridge
0xb51541df05DE07be38dcfc4a80c05389A54502BB is PeggedTokenBridgeV2
0xB876cc05c3C3C8ECBA65dAc4CF69CaF871F2e0DD is CircleBridgeProxy
***Fantom***
0x374B8a9f3eC5eB2D97ECA84Ea27aCa45aa1C57EF is Celer Network: cBridge (pool-based)
Expand All @@ -30,6 +32,7 @@ import { constructTransferParams } from "../../helpers/eventParams";
0xb51541df05DE07be38dcfc4a80c05389A54502BB is OriginalTokenVaultV2
0x88DCDC47D2f83a99CF0000FDF667A468bB958a78 is PeggedTokenBridge
0xb774C6f82d1d5dBD36894762330809e512feD195 is PeggedTokenBridgeV2
0x9744ae566c64B6B6f7F9A4dD50f7496Df6Fef990 is CircleBridgeProxy
***BSC***
0xdd90E5E87A2081Dcf0391920868eBc2FFB81a1aF is Celer Network: cBridge 2.0 (pool-based)
Expand All @@ -43,11 +46,13 @@ import { constructTransferParams } from "../../helpers/eventParams";
0xFe31bFc4f7C9b69246a6dc0087D91a91Cb040f76 is OriginalTokenVault
0xEA4B1b0aa3C110c55f650d28159Ce4AD43a4a58b is OriginalTokenVaultV2
0xbdd2739AE69A054895Be33A22b2D2ed71a1DE778 is PeggedTokenBridge
0x054B95b60BFFACe948Fa4548DA8eE2e212fb7C0a is CircleBridgeProxy
***Optimism***
0x9D39Fc627A6d9d9F8C831c16995b209548cc3401 is Celer Network: cBridge (pool-based)
0xbCfeF6Bb4597e724D720735d32A9249E0640aA11 is OriginalTokenVault
0x61f85fF2a2f4289Be4bb9B72Fc7010B3142B5f41 is PeggedTokenBridge
0x697aC93c9263346c5Ad0412F9356D5789a3AA687 is CircleBridgeProxy
***Gnosis***
0x3795C36e7D12A8c252A20C5a7B455f7c57b60283 is Celer Network: cBridge 2.0 (pool-based)
Expand Down Expand Up @@ -78,6 +83,9 @@ import { constructTransferParams } from "../../helpers/eventParams";
***Scroll***
0x9B36f165baB9ebe611d491180418d8De4b8f3a1f is Celer Network: cBridge 2.0 (pool-based)
***Base***
0x243b40e96c6bF21511E53d85c86F6Ec982f9a879 is CircleBridgeProxy
*/

const contractAddresses = {
Expand All @@ -87,13 +95,15 @@ const contractAddresses = {
vaultV2: ["0x7510792A3B1969F9307F3845CE88e39578f2bAE1"],
peggedV1: ["0x16365b45EB269B5B5dACB34B4a15399Ec79b95eB"],
peggedV2: ["0x52E4f244f380f8fA51816c8a10A63105dd4De084"],
celerCCTP: ["0x6065a982f04f759b7d2d042d2864e569fad84214"],
},
polygon: {
poolV1: ["0x88DCDC47D2f83a99CF0000FDF667A468bB958a78"],
vaultV1: ["0xc1a2D967DfAa6A10f3461bc21864C23C1DD51EeA"],
vaultV2: ["0x4C882ec256823eE773B25b414d36F92ef58a7c0C"],
peggedV1: ["0x4d58FDC7d0Ee9b674F49a0ADE11F26C3c9426F7A"],
peggedV2: ["0xb51541df05DE07be38dcfc4a80c05389A54502BB"],
celerCCTP: ["0xB876cc05c3C3C8ECBA65dAc4CF69CaF871F2e0DD"],
},
fantom: {
poolV1: ["0x374B8a9f3eC5eB2D97ECA84Ea27aCa45aa1C57EF"],
Expand All @@ -107,6 +117,7 @@ const contractAddresses = {
vaultV2: ["0xb51541df05DE07be38dcfc4a80c05389A54502BB"],
peggedV1: ["0x88DCDC47D2f83a99CF0000FDF667A468bB958a78"],
peggedV2: ["0xb774C6f82d1d5dBD36894762330809e512feD195"],
celerCCTP: ["0x9744ae566c64B6B6f7F9A4dD50f7496Df6Fef990"],
},
bsc: {
poolV1: ["0xdd90E5E87A2081Dcf0391920868eBc2FFB81a1aF"],
Expand All @@ -120,11 +131,13 @@ const contractAddresses = {
vaultV1: ["0xFe31bFc4f7C9b69246a6dc0087D91a91Cb040f76"],
vaultV2: ["0xEA4B1b0aa3C110c55f650d28159Ce4AD43a4a58b"],
peggedV1: ["0xbdd2739AE69A054895Be33A22b2D2ed71a1DE778"],
celerCCTP: ["0x054B95b60BFFACe948Fa4548DA8eE2e212fb7C0a"],
},
optimism: {
poolV1: ["0x9D39Fc627A6d9d9F8C831c16995b209548cc3401"],
vaultV1: ["0xbCfeF6Bb4597e724D720735d32A9249E0640aA11"],
peggedV1: ["0x61f85fF2a2f4289Be4bb9B72Fc7010B3142B5f41"],
celerCCTP: ["0x697aC93c9263346c5Ad0412F9356D5789a3AA687"],
},
xdai: {
poolV2: ["0x3795C36e7D12A8c252A20C5a7B455f7c57b60283"],
Expand Down Expand Up @@ -155,6 +168,9 @@ const contractAddresses = {
},
scroll: {
poolV2: ["0x9B36f165baB9ebe611d491180418d8De4b8f3a1f"],
},
base: {
celerCCTP: ["0x243b40e96c6bF21511E53d85c86F6Ec982f9a879"],
}
} as {
[chain: string]: {
Expand All @@ -164,6 +180,7 @@ const contractAddresses = {
vaultV2?: string[];
peggedV1?: string[];
peggedV2?: string[];
celerCCTP?: string[];
};
};

Expand Down Expand Up @@ -354,6 +371,36 @@ const peggedV2DepositParams: PartialContractEventParams = {
isDeposit: true,
};

// CCTP Deposit
const cctpDepositParams: PartialContractEventParams = {
target: "",
topic: "Deposited(address,bytes32,uint64,uint256,uint256,uint256,uint64)",
abi: [
"event Deposited(address sender, bytes32 recipient, uint64 dstChid, uint256 amount, uint256 txFee, uint256 percFee, uint64 nonce)",
],
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
amount: "amount",
from: "sender",
},
fixedEventData: {
to: "",
},
inputDataExtraction: {
inputDataABI: [
"function depositForBurn(uint256 _amount, uint64 _dstChid, bytes32 _mintRecipient, address _burnToken)",
],
inputDataFnName: "depositForBurn",
inputDataKeys: {
token: "_burnToken",
},
},
isDeposit: true,
};

// TODO: needs refactoring, obviously
const constructParams = (chain: string) => {
let eventParams = [] as any;
Expand Down Expand Up @@ -472,6 +519,18 @@ const constructParams = (chain: string) => {
eventParams.push(finalPeggedWithdrawalParams, finalPeggedV2DepositParams);
});
}
if (chainAddresses.celerCCTP) {
chainAddresses.celerCCTP.map((address: string) => {
const finalCCTPDepositParams = {
...cctpDepositParams,
target: address,
fixedEventData: {
to: address,
},
};
eventParams.push(finalCCTPDepositParams);
});
}
return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("celer", chain as Chain, fromBlock, toBlock, eventParams);
};
Expand All @@ -492,6 +551,7 @@ const adapter: BridgeAdapter = {
polygon_zkevm: constructParams("polygon_zkevm"),
linea: constructParams("linea"),
scroll: constructParams("scroll"),
base: constructParams("base"),
};

export default adapter;

0 comments on commit b168d93

Please sign in to comment.