-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
459 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; | ||
|
||
|
||
abstract contract ERC1967ProxyAcc is ERC1967Proxy {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
|
||
abstract contract TransparentUpgradeableProxyAcc is TransparentUpgradeableProxy {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { forkNetwork } from "./fork"; | ||
import * as ethers from "ethers"; | ||
|
||
|
||
export const forkRpcUrlBase = "https://rpc.tenderly.co/fork"; | ||
|
||
export const createPlayground = async ({ | ||
networkId = "1", | ||
blockNumber = 14537885, | ||
} = {}) => { | ||
const forkId = await forkNetwork({ | ||
networkId, | ||
blockNumber, | ||
}); | ||
|
||
const forkURL = `${forkRpcUrlBase}/${forkId}`; | ||
|
||
return new ethers.providers.JsonRpcProvider(forkURL); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { deleteFork, forkNetwork } from "./fork"; | ||
|
||
// Arguments for direct execution: | ||
// no argument or "new" - to create a new fork | ||
// "del" + "forkURL" - to delete the fork | ||
const operation = process.argv[2]; | ||
|
||
if (operation === "new" || !operation) { | ||
forkNetwork() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
} else if (operation === "del") { | ||
const forkURL = process.argv[3]; | ||
if (!forkURL) { | ||
console.error("Fork URL is required to delete a fork"); | ||
process.exit(1); | ||
} | ||
|
||
deleteFork(forkURL) | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
} else { | ||
console.error("Invalid operation. Make sure you pass the correct arguments."); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// TODO: Move all the Tenderly related logic from here to it's own repo/package | ||
|
||
import axios from "axios"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
const { | ||
TENDERLY_ACCOUNT_ID, | ||
TENDERLY_PROJECT_SLUG, | ||
TENDERLY_ACCESS_KEY, | ||
} = process.env; | ||
|
||
const TENDERLY_FORK_API = | ||
`http://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_ID}/project/${TENDERLY_PROJECT_SLUG}/fork`; | ||
|
||
const opts = { | ||
headers: { | ||
"X-Access-Key": TENDERLY_ACCESS_KEY as string, | ||
}, | ||
}; | ||
|
||
|
||
export const forkNetwork = async ({ | ||
networkId = "1", | ||
blockNumber = 14537885, | ||
} = {}) => { | ||
const body = { | ||
"network_id": networkId, | ||
"block_number": blockNumber, | ||
}; | ||
|
||
const { | ||
data: { | ||
simulation_fork: { | ||
id: forkId, | ||
}, | ||
}, | ||
} = await axios.post(TENDERLY_FORK_API, body, opts); | ||
|
||
const forkURL = `${TENDERLY_FORK_API}/${forkId}`; | ||
console.log(`FORK URL: ${forkURL}`); | ||
|
||
return forkId; | ||
}; | ||
|
||
export const deleteFork = async (forkURL : string) => | ||
axios.delete(forkURL, opts); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ethers } from "ethers"; | ||
|
||
export const getEther = async ( | ||
walletAddress : string, | ||
amountHex = ethers.utils.hexValue(100), // hex encoded wei amount | ||
provider : ethers.providers.JsonRpcProvider, | ||
) : Promise<void> => { | ||
const params = [ | ||
[walletAddress], | ||
amountHex, | ||
]; | ||
|
||
await provider.send("tenderly_addBalance", params); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { BigNumber } from "ethers"; | ||
|
||
|
||
export const ethMultiplier = BigNumber.from(10).pow(18); | ||
|
||
export const calcGasCostInCurrency = ( | ||
gas : string, | ||
gasPriceInGwei : string, | ||
ethPriceInUSD : string, | ||
) => { | ||
let cost; | ||
let currency = "WEI"; | ||
cost = BigNumber.from(gas) | ||
.mul(BigNumber.from(gasPriceInGwei)) | ||
.mul(ethMultiplier) | ||
.div(BigNumber.from(10).pow(9)); | ||
|
||
if (!!ethPriceInUSD) { | ||
currency = "USD WEI"; | ||
cost = cost.mul(BigNumber.from(ethPriceInUSD)); | ||
} | ||
|
||
return { cost, currency }; | ||
}; | ||
|
||
|
||
// Execute | ||
const [ | ||
gasArg, | ||
gasPriceArg, | ||
ethPriceArg, | ||
] = process.argv.slice(2); | ||
|
||
const { | ||
cost: totalCost, | ||
currency: costCurrency, | ||
} = calcGasCostInCurrency(gasArg, gasPriceArg, ethPriceArg); | ||
|
||
console.log(`Total cost: ${totalCost.toString()} ${costCurrency}`); | ||
|
||
// register (14 gwei, $1856) = $8.84 (ENS = $8.49) | ||
// reclaim (14 gwei, $1856) = $1.71 | ||
// revoke (14 gwei, $1856) = $3.03 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.