Skip to content

Commit

Permalink
Merge branch 'master' into working-tree
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd authored Dec 13, 2023
2 parents f3e075b + 8119016 commit 2923d0b
Show file tree
Hide file tree
Showing 6 changed files with 706 additions and 17 deletions.
10 changes: 5 additions & 5 deletions src/adapters/debridgedln/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ const constructParams = (chain: SupportedChains) => {
mapTokens: { "0x0000000000000000000000000000000000000000": token },
};

const finalWithdrawParams = {
...withdrawParams,
mapTokens: { "0x0000000000000000000000000000000000000000": token },
};
// const finalWithdrawParams = {
// ...withdrawParams,
// mapTokens: { "0x0000000000000000000000000000000000000000": token },
// };

eventParams.push(finalDepositParams, finalWithdrawParams);
eventParams.push(finalDepositParams);

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("debridgedln", chain, fromBlock, toBlock, eventParams);
Expand Down
7 changes: 3 additions & 4 deletions src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ import axelarsatellite from "./axelar-satellite";
import manta from "./manta";
import squidrouter from "./squid";
import eywa from "./eywa";
<<<<<<< HEAD
import rhinofi from "./rhinofi";
=======
import rhinofi from './rhinofi';
import pepeteam_bridge from './pepeteam-bridge';
import pnetwork from './pnetwork';
>>>>>>> origin
import interport from './interport-finance';


export default {
polygon,
Expand Down Expand Up @@ -86,6 +84,7 @@ export default {
rhinofi,
pepeteam_bridge,
pnetwork,
interport,
} as {
[bridge: string]: BridgeAdapter;
};
54 changes: 54 additions & 0 deletions src/adapters/interport-finance/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
export const VAULT_TYPE_USDC = 1;
export const VAULT_TYPE_USDT = 2;

export const ACTION_EXECUTOR_ADDRESSES = {
ethereum: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
arbitrum: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
bsc: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
era: "0xdF3E4dA3EE75F1018d277222967ce3D69F3271D9",
base: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
scroll: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
linea: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
polygon: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
polygon_zkevm: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
optimism: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
opbnb: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
avax: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
eon: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
fantom: "0x7b2E3FC7510D1A51b3bef735F985446589219354",
} as const;

export const VAULT_ASSET_ADDRESSES = {
[VAULT_TYPE_USDC]: {
ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
arbitrum: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
bsc: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
era: '0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4',
base: '0xd9aAEc86B65D86f6A7B5B1b0c42FFA531710b6CA',
scroll: '0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4',
linea: '0x176211869cA2b568f2A7D4EE941E073a821EE1ff',
polygon: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
polygon_zkevm: '0xA8CE8aee21bC2A48a5EF670afCc9274C7bbbC035',
optimism: '0x7F5c764cBc14f9669B88837ca1490cCa17c31607',
opbnb: undefined,
avax: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E',
eon: '0xCc44eB064CD32AAfEEb2ebb2a47bE0B882383b53',
fantom: '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75',
},
[VAULT_TYPE_USDT]: {
ethereum: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
arbitrum: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
bsc: '0x55d398326f99059fF775485246999027B3197955',
era: undefined,
base: undefined,
scroll: '0xf55BEC9cafDbE8730f096Aa55dad6D22d44099Df',
linea: '0xA219439258ca9da29E9Cc4cE5596924745e12B93',
polygon: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
polygon_zkevm: '0x1E4a5963aBFD975d8c9021ce480b42188849D41d',
optimism: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
opbnb: '0x9e5aac1ba1a2e6aed6b32689dfcf62a509ca96f3',
avax: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7',
eon: '0xA167bcAb6791304EDa9B636C8beEC75b3D2829E6',
fantom: '0x049d68029688eAbF473097a2fC38ef61633A3C7A',
},
};
149 changes: 149 additions & 0 deletions src/adapters/interport-finance/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import { BridgeAdapter, PartialContractEventParams } from "../../helpers/bridgeAdapter.type";
import { BigNumber } from "ethers";
import { getTxDataFromEVMEventLogsCustom } from "./processTransactionsCustom";
import {ACTION_EXECUTOR_ADDRESSES, VAULT_TYPE_USDC, VAULT_TYPE_USDT, VAULT_ASSET_ADDRESSES} from "./constants";

type SupportedChains = keyof typeof ACTION_EXECUTOR_ADDRESSES;

const depositParams = (chain: SupportedChains): PartialContractEventParams => {
const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES[chain];

return {
target: actionExecutorAddress,
topic: "SourceProcessed(uint256,bool,address,uint256,address,address,uint256,uint256)",
abi: [
"event SourceProcessed(uint256 indexed actionId, bool indexed isLocal, address indexed sender, uint256 routerType, address fromTokenAddress, address toTokenAddress, uint256 fromAmount, uint256 resultAmount)"
],
isDeposit: true,
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
token: "toTokenAddress",
from: "sender",
amount: "resultAmount",
},
fixedEventData: {
to: actionExecutorAddress,
},
filter: {
includeArg: [{ isLocal: false as unknown as string }],
},
};
};

const withdrawParams = (chain: SupportedChains): PartialContractEventParams => {
const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES[chain];

return {
target: actionExecutorAddress,
topic: "TargetProcessed(uint256,address,uint256,address,address,uint256,uint256)",
abi: [
"event TargetProcessed(uint256 indexed actionId, address indexed recipient, uint256 routerType, address fromTokenAddress, address toTokenAddress, uint256 fromAmount, uint256 resultAmount)"
],
isDeposit: false,
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
token: "fromTokenAddress",
to: "recipient",
amount: "fromAmount",
},
fixedEventData: {
from: actionExecutorAddress,
},
};
};

const variableBalanceUsdcParams = (chain: SupportedChains): PartialContractEventParams => {
const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES[chain];

return {
target: actionExecutorAddress,
topic: "VariableBalanceAllocated(uint256,address,uint256,uint256)",
abi: [
"event VariableBalanceAllocated(uint256 indexed actionId, address indexed recipient, uint256 vaultType, uint256 amount)"
],
isDeposit: false,
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
amount: "amount",
to: "recipient",
},
fixedEventData: {
token: VAULT_ASSET_ADDRESSES[VAULT_TYPE_USDC][chain],
from: actionExecutorAddress,
},
filter: {
includeArg: [{ vaultType: BigNumber.from(VAULT_TYPE_USDC) as unknown as string }],
},
};
};

const variableBalanceUsdtParams = (chain: SupportedChains): PartialContractEventParams => {
const actionExecutorAddress = ACTION_EXECUTOR_ADDRESSES[chain];

return {
target: actionExecutorAddress,
topic: "VariableBalanceAllocated(uint256,address,uint256,uint256)",
abi: [
"event VariableBalanceAllocated(uint256 indexed actionId, address indexed recipient, uint256 vaultType, uint256 amount)"
],
isDeposit: false,
logKeys: {
blockNumber: "blockNumber",
txHash: "transactionHash",
},
argKeys: {
amount: "amount",
to: "recipient",
},
fixedEventData: {
token: VAULT_ASSET_ADDRESSES[VAULT_TYPE_USDT][chain],
from: actionExecutorAddress,
},
filter: {
includeArg: [{ vaultType: BigNumber.from(VAULT_TYPE_USDT) as unknown as string }],
},
};
};

const constructParams = (chain: SupportedChains) => {
const eventParams = [depositParams(chain), withdrawParams(chain)];

if (VAULT_ASSET_ADDRESSES[VAULT_TYPE_USDC][chain]) {
eventParams.push(variableBalanceUsdcParams(chain));
}

if (VAULT_ASSET_ADDRESSES[VAULT_TYPE_USDT][chain]) {
eventParams.push(variableBalanceUsdtParams(chain));
}

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogsCustom("interport", chain, fromBlock, toBlock, eventParams);
};

const adapter: BridgeAdapter = {
ethereum: constructParams("ethereum"),
arbitrum: constructParams("arbitrum"),
bsc: constructParams("bsc"),
"zksync era": constructParams("era"),
base: constructParams("base"),
scroll: constructParams("scroll"),
linea: constructParams("linea"),
polygon: constructParams("polygon"),
"polygon zkevm": constructParams("polygon_zkevm"),
optimism: constructParams("optimism"),
opbnb: constructParams("opbnb"),
avalanche: constructParams("avax"),
eon: constructParams("eon"),
fantom: constructParams("fantom"),
};

export default adapter;
Loading

0 comments on commit 2923d0b

Please sign in to comment.