Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update multicall script #255

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
57 changes: 57 additions & 0 deletions contracts/BIFI/infra/BeefyMulticall.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT

pragma solidity >=0.5.0;
pragma experimental ABIEncoderV2;

/// @title Multicall - Aggregate results from multiple read-only function calls
/// @author Michael Elliot <[email protected]>
/// @author Joshua Levine <[email protected]>
/// @author Nick Johnson <[email protected]>
/// @author Bogdan Dumitru <[email protected]>

contract Multicall {
struct Call {
address target;
bytes callData;
}
struct Return {
bool success;
bytes data;
}
function aggregate(
Call[] memory calls,
bool strict
) public returns (uint256 blockNumber, Return[] memory returnData) {
blockNumber = block.number;
returnData = new Return[](calls.length);
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);
if (strict) {
require(success);
}
returnData[i] = Return(success, ret);
}
}
// Helper functions
function getEthBalance(address addr) public view returns (uint256 balance) {
balance = addr.balance;
}
function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {
blockHash = blockhash(blockNumber);
}
function getLastBlockHash() public view returns (bytes32 blockHash) {
blockHash = blockhash(block.number - 1);
}
function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {
timestamp = block.timestamp;
}
function getCurrentBlockDifficulty() public view returns (uint256 difficulty) {
difficulty = block.difficulty;
}
function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {
gaslimit = block.gaslimit;
}
function getCurrentBlockCoinbase() public view returns (address coinbase) {
coinbase = block.coinbase;
}
}
22 changes: 14 additions & 8 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const config: DeploymentConfig = {
url: "https://public-node.rsk.co",
chainId: 30,
accounts,
gasPrice: 72000000
gasPrice: 72000000,
},
manta: {
url: process.env.MANTA_RPC || "https://manta-pacific.drpc.org",
Expand All @@ -201,7 +201,12 @@ const config: DeploymentConfig = {
url: process.env.SEI_RPC || "https://evm-rpc.sei-apis.com",
chainId: 1329,
accounts,
}
},
sonic: {
url: process.env.SONIC_RPC || "https://rpc.soniclabs.com",
chainId: 146,
accounts,
},
},
etherscan: {
// Your API key for Etherscan
Expand All @@ -223,10 +228,11 @@ const config: DeploymentConfig = {
fraxtal: process.env.FRAXTAL_API_KEY!,
mode: "api key is not required by the Kava explorer, but can't be empty",
scroll: process.env.SCROLL_API_KEY!,
rootstock: 'abc',
rootstock: "abc",
avax: process.env.AVAX_API_KEY!,
manta: 'someKey',
sei: 'sei',
manta: "someKey",
sei: "sei",
sonic: process.env.SONIC_API_KEY!,
},
customChains: [
{
Expand Down Expand Up @@ -322,7 +328,7 @@ const config: DeploymentConfig = {
chainId: 30,
urls: {
apiURL: "https://rootstock.blockscout.com/api",
browserURL: "https://rootstock.blockscout.com/"
browserURL: "https://rootstock.blockscout.com/",
},
},
{
Expand All @@ -338,8 +344,8 @@ const config: DeploymentConfig = {
chainId: 1329,
urls: {
apiURL: "https://seitrace.com/pacific-1/api",
browserURL: "https://seitrace.com"
}
browserURL: "https://seitrace.com",
},
},
],
},
Expand Down
11 changes: 8 additions & 3 deletions scripts/infra/deployAppMulticall.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ const ethers = hardhat.ethers;
async function main() {
await hardhat.run("compile");

const Multicall = await ethers.getContractFactory("BeefyV2AppMulticall");
const MulticallV2 = await ethers.getContractFactory("BeefyV2AppMulticall");
const Multicall = await ethers.getContractFactory("Multicall");

const multicallV2 = await MulticallV2.deploy();
const multicall = await Multicall.deploy();

await multicallV2.deployed();
await multicall.deployed();

console.log("App v2 multicall deployed:", multicall.address);
console.log("Multicall deployed:", multicall.address);
console.log("App v2 multicall deployed:", multicallV2.address);
}

main()
.then(() => process.exit(0))
.catch((error) => {
.catch(error => {
console.error(error);
process.exit(1);
});
Loading