Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions deployments/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Arbitrum_Adapter": { "address": "0x937958992799bF4A9a656E6596FD10d7Da5c2216", "blockNumber": 14704380 },
"Boba_Adapter": { "address": "0x33B0Ec794c15D6Cc705818E70d4CaCe7bCfB5Af3", "blockNumber": 14716798 },
"Ethereum_Adapter": { "address": "0x527E872a5c3f0C7c24Fe33F2593cFB890a285084", "blockNumber": 14704381 },
"Ethereum_SpokePool": { "address": "0x931A43528779034ac9eb77df799d133557406176", "blockNumber": 14704425 },
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrice32 see the changes made here.

"SpokePool": { "address": "0x931A43528779034ac9eb77df799d133557406176", "blockNumber": 14704425 },
"HubPool": { "address": "0x6Bb9910c5529Cb3b32c4f0e13E8bC38F903b2534", "blockNumber": 14704308 },
"LpTokenFactory": { "address": "0x7dB69eb9F52eD773E9b03f5068A1ea0275b2fD9d", "blockNumber": 14704307 },
"Optimism_Adapter": { "address": "0x22eD83A9eE26236486F57cE8385A247E5bFB71fF", "blockNumber": 14704379 },
Expand All @@ -14,7 +14,7 @@
"4": {
"Arbitrum_Adapter": { "address": "0x18F4D98C7CeA6Ab934F2976c2a98009A529d8F49", "blockNumber": 10367195 },
"Ethereum_Adapter": { "address": "0x682DEa71e7246910A4dec2396a53B24291EB0AD8", "blockNumber": 10365602 },
"Ethereum_SpokePool": { "address": "0xB078bBb35f8E24c2431b9d2a88C0bC0c26CC1F92", "blockNumber": 10485193 },
"SpokePool": { "address": "0xB078bBb35f8E24c2431b9d2a88C0bC0c26CC1F92", "blockNumber": 10485193 },
"HubPool": { "address": "0xa1b6DA4AaE90fA16F3A3338c8d1Dc70B4926FCa7", "blockNumber": 10365599 },
"LpTokenFactory": { "address": "0x0668ab3839346ebf95d969b3e18B2a96b1CC2b02", "blockNumber": 10365598 },
"Optimism_Adapter": { "address": "0x277C7ecB45851dcB49c494fB4D0d9d8228037f0C", "blockNumber": 10365600 },
Expand All @@ -25,35 +25,31 @@
"5": {
"AcrossConfigStore": { "address": "0x3215e3C91f87081757d0c41EF0CB77738123Be83", "blockNumber": 6860550 },
"Ethereum_Adapter": { "address": "0xB88690461dDbaB6f04Dfad7df66B7725942FEb9C", "blockNumber": 6860541 },
"Ethereum_SpokePool": { "address": "0x1Ae1d80e1725A478f5e653bF79f8Ee4aB5B34719", "blockNumber": 6860543 },
"SpokePool": { "address": "0x1Ae1d80e1725A478f5e653bF79f8Ee4aB5B34719", "blockNumber": 6860543 },
"HubPool": { "address": "0xA44A832B994f796452e4FaF191a041F791AD8A0A", "blockNumber": 6860535 },
"LpTokenFactory": { "address": "0xe2a742453614Cb3597bc92242487436A54D1B385", "blockNumber": 6860534 },
"PolygonTokenBridger": { "address": "0x97f102f2f73717e203f964Ad9940e4C2e79b8597", "blockNumber": 6860545 },
"Polygon_Adapter": { "address": "0x5ed9C283F44f961deB73048a807629672b1f1F15", "blockNumber": 6860547 }
},
"10": { "Optimism_SpokePool": { "address": "0x59485d57EEcc4058F7831f46eE83a7078276b4AE", "blockNumber": 6979967 } },
"10": { "SpokePool": { "address": "0x59485d57EEcc4058F7831f46eE83a7078276b4AE", "blockNumber": 6979967 } },
"42": {
"AcrossConfigStore": { "address": "0xDd74f7603e3fDA6435aEc91F8960a6b8b40415f3", "blockNumber": 31457380 },
"Ethereum_Adapter": { "address": "0x5b0539e0ED5273604bf13b4A30050d475E586a64", "blockNumber": 31457390 },
"Ethereum_SpokePool": { "address": "0x90bab3160d417B4cd791Db5f8C4E79704e67bd49", "blockNumber": 31457386 },
"SpokePool": { "address": "0x90bab3160d417B4cd791Db5f8C4E79704e67bd49", "blockNumber": 31457386 },
"HubPool": { "address": "0x8d84F51710dfa9D409027B167371bBd79e0539e5", "blockNumber": 31457369 },
"LpTokenFactory": { "address": "0x4E894576a20C61871D53d043953582DDc6a76c5C", "blockNumber": 31457365 },
"Optimism_Adapter": { "address": "0x97E35F92a4de9Ec4950EAf7581B3ed54efbFc207", "blockNumber": 31457371 }
},
"69": { "Optimism_SpokePool": { "address": "0x1954D4A36ac4fD8BEde42E59368565A92290E705", "blockNumber": 2537971 } },
"69": { "SpokePool": { "address": "0x1954D4A36ac4fD8BEde42E59368565A92290E705", "blockNumber": 2537971 } },
"137": {
"PolygonTokenBridger": { "address": "0x48d990AbDA20afa1fD1da713AbC041B60a922c65", "blockNumber": 27875886 },
"Polygon_SpokePool": { "address": "0xD3ddAcAe5aFb00F9B9cD36EF0Ed7115d7f0b584c", "blockNumber": 27875891 }
},
"288": { "Boba_SpokePool": { "address": "0x7229405a2f0c550Ce35182EE1658302B65672443", "blockNumber": 551955 } },
"42161": {
"Arbitrum_SpokePool": { "address": "0xe1C367e2b576Ac421a9f46C9cC624935730c36aa", "blockNumber": 11102271 }
"SpokePool": { "address": "0xD3ddAcAe5aFb00F9B9cD36EF0Ed7115d7f0b584c", "blockNumber": 27875891 }
},
"288": { "SpokePool": { "address": "0x7229405a2f0c550Ce35182EE1658302B65672443", "blockNumber": 551955 } },
"42161": { "SpokePool": { "address": "0xe1C367e2b576Ac421a9f46C9cC624935730c36aa", "blockNumber": 11102271 } },
"80001": {
"PolygonTokenBridger": { "address": "0x97f102f2f73717e203f964Ad9940e4C2e79b8597", "blockNumber": 26276246 },
"Polygon_SpokePool": { "address": "0x45fF03629D024b7763275e732a2d80202c18b31C", "blockNumber": 26276253 }
"SpokePool": { "address": "0x45fF03629D024b7763275e732a2d80202c18b31C", "blockNumber": 26276253 }
},
"421611": {
"Arbitrum_SpokePool": { "address": "0x3BED21dAe767e4Df894B31b14aD32369cE4bad8b", "blockNumber": 10523275 }
}
"421611": { "SpokePool": { "address": "0x3BED21dAe767e4Df894B31b14aD32369cE4bad8b", "blockNumber": 10523275 } }
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@across-protocol/contracts-v2",
"version": "0.0.53",
"version": "0.0.55",
"author": "UMA Team",
"license": "AGPL-3.0",
"repository": {
Expand Down
1 change: 1 addition & 0 deletions scripts/processHardhatExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export async function run(): Promise<void> {
if (!processedOutput[chainId]) processedOutput[chainId] = {};
const address = castExport[chainId][0]?.contracts[contractName].address;
const blockNumber = findDeploymentBlockNumber(castExport[chainId][0].name, contractName);
if (/.*_SpokePool/.test(contractName)) contractName = "SpokePool"; // Strip the network name from the spoke pool in the contractName.
Copy link
Member Author

@chrismaree chrismaree May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to modify the export without changing the artefacts.

processedOutput[chainId][contractName] = { address, blockNumber };
});
});
Expand Down
27 changes: 23 additions & 4 deletions src/DeploymentUtils.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import * as deployments from "../deployments/deployments.json";
import * as deployments_ from "../deployments/deployments.json";
interface DeploymentExport {
[chainId: string]: { [contractName: string]: { address: string; blockNumber: number } };
}
const deployments: DeploymentExport = deployments_ as any;

// Returns the deployed address of any contract on any network.
export function getDeployedAddress(contractName: string, networkId: number): string {
try {
return (deployments as any)[networkId.toString()][contractName].address;
return deployments[networkId.toString()][contractName].address;
} catch (_) {
throw new Error(`Contract ${contractName} not found on ${networkId} in deployments.json`);
}
}

// Returns the deployment block number of any contract on any network.
export function getDeployedBlockNumber(contractName: string, networkId: number): string {
export function getDeployedBlockNumber(contractName: string, networkId: number): number {
try {
return (deployments as any)[networkId.toString()][contractName].blockNumber;
return deployments[networkId.toString()][contractName].blockNumber;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should have the same behavior as getDeployedAddress. imo we might just want a way to look up the correct contract name, then you dont have to modify thsese 2 functions at all

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. see above comments

} catch (_) {
throw new Error(`Contract ${contractName} not found on ${networkId} in deployments.json`);
}
}

// Returns the chainId and contract name for a given contract address.
export function getContractInfoFromAddress(contractAddress: string): { chainId: Number; contractName: string } {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like this solves my issues since im usually given the contract address and chain ( at least for spoke pools). It would be a problem if hubpools also had different names, but they dont currently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye, this method assumes that the deployment addresses on each chain are unique enabling you to go backwards from a known address to the contract name and chainId.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the PolygonTokenBridger break this? It has the same address on multiple chains

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ye that contract would not work with this method but that's ok. This method is only used in the bots to enhance logs and the bots never directly call those polygon contracts so it won't be an issue.

I'll add an error that is thrown if multiple addresses are found to prevent any confusion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. Makes sense.

let returnValue: { chainId: number; contractName: string }[] = [];

Object.keys(deployments).forEach((_chainId) =>
Object.keys(deployments[_chainId]).forEach((_contractName) => {
if (deployments[_chainId][_contractName].address == contractAddress)
returnValue.push({ chainId: Number(_chainId), contractName: _contractName });
})
);
if (returnValue.length == 0) throw new Error(`Contract ${contractAddress} not found in deployments.json`);
if (returnValue.length > 1) throw new Error(`Multiple deployments found for ${contractAddress}`);
return returnValue[0];
}