Skip to content

Commit

Permalink
stargate types
Browse files Browse the repository at this point in the history
  • Loading branch information
vrtnd committed Jun 10, 2024
1 parent 86190c6 commit f457c1a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
53 changes: 37 additions & 16 deletions src/adapters/stargate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,30 @@ const ercV2WithdrawalParams: PartialContractEventParams = {
isDeposit: false,
};

interface V2Address {
token: string;
pool: string;
}

interface V2Address {
token: string;
pool: string;
}

interface ContractAddresses {
[chain: string]: {
stg?: string;
ercs: string[];
nativeToken?: string;
etherVault?: string;
};
}

const constructParams = (chain: string) => {
let eventParams = [] as any;
let eventParams: PartialContractEventParams[] = [];

const v2Events = (
v2Addresses[chain]?.map((address: any) => {
const v2Events: PartialContractEventParams[] = (
v2Addresses[chain]?.map((address: V2Address) => {
return [
{
...ercV2DepositParams,
Expand All @@ -471,20 +490,22 @@ const constructParams = (chain: string) => {

eventParams.push(...v2Events);

const etherVault = contractAddresses[chain].etherVault;
const nativeToken = contractAddresses[chain].nativeToken;
const ercs = contractAddresses[chain].ercs;
const stg = contractAddresses[chain].stg;
const contractAddressesForChain = contractAddresses[chain] as ContractAddresses[string] | undefined;
const etherVault = contractAddressesForChain?.etherVault;
const nativeToken = contractAddressesForChain?.nativeToken;
const ercs = contractAddressesForChain?.ercs || [];
const stg = contractAddressesForChain?.stg;

if (etherVault) {
const finalEthDepositParams = {
const finalEthDepositParams: PartialContractEventParams = {
...ethDepositParams,
target: etherVault,
fixedEventData: {
token: nativeToken,
to: etherVault,
},
};
const finalEthWithdrawalParams = {
const finalEthWithdrawalParams: PartialContractEventParams = {
...ethWithdrawalParams,
target: etherVault,
fixedEventData: {
Expand All @@ -494,18 +515,19 @@ const constructParams = (chain: string) => {
};
eventParams.push(finalEthDepositParams, finalEthWithdrawalParams);
}

if (chain === "ethereum") {
eventParams.push(ethStgDepositParams, ethStgWithdrawalParams);
} else {
const finalStgDepositParams = {
} else if (stg) {
const finalStgDepositParams: PartialContractEventParams = {
...stgDepositParams,
target: stg,
fixedEventData: {
token: stg,
to: stg,
},
};
const finalStgWithdrawalParams = {
const finalStgWithdrawalParams: PartialContractEventParams = {
...stgWithdrawalParams,
target: stg,
fixedEventData: {
Expand All @@ -517,15 +539,15 @@ const constructParams = (chain: string) => {
}

for (let address of ercs) {
const finalErcDepositParams = {
const finalErcDepositParams: PartialContractEventParams = {
...ercDepositParams,
target: address,
fixedEventData: {
token: address,
to: address,
},
};
const finalErcWithdrawalParams = {
const finalErcWithdrawalParams: PartialContractEventParams = {
...ercWithdrawalParams,
target: address,
fixedEventData: {
Expand All @@ -535,10 +557,10 @@ const constructParams = (chain: string) => {
};
eventParams.push(finalErcDepositParams, finalErcWithdrawalParams);
}

return async (fromBlock: number, toBlock: number) =>
getTxDataFromEVMEventLogs("stargate", chain as Chain, fromBlock, toBlock, eventParams);
};

const adapter: BridgeAdapter = {
ethereum: constructParams("ethereum"),
polygon: constructParams("polygon"),
Expand All @@ -551,7 +573,6 @@ const adapter: BridgeAdapter = {
metis: constructParams("metis"),
klaytn: constructParams("klaytn"),
linea: constructParams("linea"),
scroll: constructParams("scroll"),
mantle: constructParams("mantle"),
base: constructParams("base"),
aurora: constructParams("aurora"),
Expand Down
15 changes: 14 additions & 1 deletion src/data/bridgeNetworkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,20 @@ export default [
iconLink: "icons:stargate",
largeTxThreshold: 10000,
url: "https://stargate.finance/",
chains: ["Ethereum", "Polygon", "Fantom", "Avalanche", "Arbitrum", "Optimism", "BSC"],
chains: [
"Ethereum",
"Polygon",
"Fantom",
"Avalanche",
"Arbitrum",
"Optimism",
"BSC",
"Aurora",
"Base",
"Kava",
"Klaytn",
"Linea",
],
chainMapping: {
avalanche: "avax", // this is needed temporarily, need to fix and remove
},
Expand Down

0 comments on commit f457c1a

Please sign in to comment.