Skip to content

Commit 2ebf5cd

Browse files
authored
Merge pull request #183 from VenusProtocol/feat/lst-deployment
[VEN-2359] Deployment of LST Oracles
2 parents 09759ac + 3ec2d87 commit 2ebf5cd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+18879
-4403
lines changed

contracts/test/MockAnkrBNB.sol

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
7+
import { IAnkrBNB } from "../interfaces/IAnkrBNB.sol";
8+
import "@openzeppelin/contracts/access/Ownable.sol";
9+
10+
contract MockAnkrBNB is ERC20, Ownable, IAnkrBNB {
11+
uint8 private immutable _decimals;
12+
uint256 public exchangeRate;
13+
14+
constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) Ownable() {
15+
_decimals = decimals_;
16+
}
17+
18+
function faucet(uint256 amount) external {
19+
_mint(msg.sender, amount);
20+
}
21+
22+
function setSharesToBonds(uint256 rate) external onlyOwner {
23+
exchangeRate = rate;
24+
}
25+
26+
function sharesToBonds(uint256 amount) external view override returns (uint256) {
27+
return (amount * exchangeRate) / (10 ** uint256(_decimals));
28+
}
29+
30+
function decimals() public view virtual override(ERC20, IAnkrBNB) returns (uint8) {
31+
return _decimals;
32+
}
33+
}

contracts/test/MockWBETH.sol

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// SPDX-License-Identifier: MIT
2+
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)
3+
4+
pragma solidity ^0.8.0;
5+
6+
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
7+
import { IWBETH } from "../interfaces/IWBETH.sol";
8+
import "@openzeppelin/contracts/access/Ownable.sol";
9+
10+
contract MockWBETH is ERC20, Ownable, IWBETH {
11+
uint8 private immutable _decimals;
12+
uint256 public override exchangeRate;
13+
14+
constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) Ownable() {
15+
_decimals = decimals_;
16+
}
17+
18+
function faucet(uint256 amount) external {
19+
_mint(msg.sender, amount);
20+
}
21+
22+
function setExchangeRate(uint256 rate) external onlyOwner {
23+
exchangeRate = rate;
24+
}
25+
26+
function decimals() public view virtual override(ERC20, IWBETH) returns (uint8) {
27+
return _decimals;
28+
}
29+
}

deploy/5-deploy-bnb-lst-oracles.ts

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import { ethers } from "hardhat";
2+
import { DeployFunction } from "hardhat-deploy/dist/types";
3+
import { HardhatRuntimeEnvironment } from "hardhat/types";
4+
5+
import { ADDRESSES, assets } from "../helpers/deploymentConfig";
6+
7+
const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
8+
const { deploy } = deployments;
9+
const { deployer } = await getNamedAccounts();
10+
11+
const oracle = await ethers.getContract("ResilientOracle");
12+
const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;
13+
14+
const { ankrBNB, stkBNB, BNBx, BNBxStakeManager, slisBNBStakeManager, stkBNBStakePool, slisBNB, wBETH } =
15+
ADDRESSES[network.name];
16+
const ETH = assets[network.name].find(asset => asset.token === "ETH");
17+
18+
await deploy("BNBxOracle", {
19+
from: deployer,
20+
log: true,
21+
deterministicDeployment: false,
22+
args: [BNBxStakeManager, BNBx, oracle.address],
23+
proxy: {
24+
owner: proxyOwnerAddress,
25+
proxyContract: "OptimizedTransparentProxy",
26+
},
27+
skipIfAlreadyDeployed: true,
28+
});
29+
30+
await deploy("SlisBNBOracle", {
31+
from: deployer,
32+
log: true,
33+
deterministicDeployment: false,
34+
args: [slisBNBStakeManager, slisBNB, oracle.address],
35+
proxy: {
36+
owner: proxyOwnerAddress,
37+
proxyContract: "OptimizedTransparentProxy",
38+
},
39+
skipIfAlreadyDeployed: true,
40+
});
41+
42+
await deploy("StkBNBOracle", {
43+
from: deployer,
44+
log: true,
45+
deterministicDeployment: false,
46+
args: [stkBNBStakePool, stkBNB, oracle.address],
47+
proxy: {
48+
owner: proxyOwnerAddress,
49+
proxyContract: "OptimizedTransparentProxy",
50+
},
51+
skipIfAlreadyDeployed: true,
52+
});
53+
54+
let ankrBNBAddress = ankrBNB;
55+
if (!ankrBNB) {
56+
// deploy MockAnkrBNB
57+
await deploy("MockAnkrBNB", {
58+
from: deployer,
59+
log: true,
60+
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
61+
skipIfAlreadyDeployed: true,
62+
args: ["Ankr Staked BNB ", "ankrBNB", "18"],
63+
});
64+
65+
const ankrBNBContract = await ethers.getContract("MockAnkrBNB");
66+
ankrBNBAddress = ankrBNBContract.address;
67+
68+
if ((await ankrBNBContract.owner()) === deployer) {
69+
await ankrBNBContract.transferOwnership(proxyOwnerAddress);
70+
}
71+
}
72+
73+
await deploy("AnkrBNBOracle", {
74+
from: deployer,
75+
log: true,
76+
deterministicDeployment: false,
77+
args: [ankrBNBAddress, oracle.address],
78+
proxy: {
79+
owner: proxyOwnerAddress,
80+
proxyContract: "OptimizedTransparentProxy",
81+
},
82+
skipIfAlreadyDeployed: true,
83+
});
84+
85+
let wBETHAddress = wBETH;
86+
if (!wBETH) {
87+
// deploy MockWBETH
88+
await deploy("MockWBETH", {
89+
from: deployer,
90+
log: true,
91+
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
92+
skipIfAlreadyDeployed: true,
93+
args: ["Wrapped Binance Beacon ETH", "wBETH", "18"],
94+
});
95+
96+
const wBETHContract = await ethers.getContract("MockWBETH");
97+
wBETHAddress = wBETHContract.address;
98+
99+
if ((await wBETHContract.owner()) === deployer) {
100+
await wBETHContract.transferOwnership(proxyOwnerAddress);
101+
}
102+
}
103+
104+
await deploy("WBETHOracle", {
105+
from: deployer,
106+
log: true,
107+
deterministicDeployment: false,
108+
args: [wBETHAddress, ETH?.address, oracle.address],
109+
proxy: {
110+
owner: proxyOwnerAddress,
111+
proxyContract: "OptimizedTransparentProxy",
112+
},
113+
skipIfAlreadyDeployed: true,
114+
});
115+
};
116+
117+
export default func;
118+
func.tags = ["bnb_lst"];
119+
func.skip = async (hre: HardhatRuntimeEnvironment) =>
120+
hre.network.name !== "bscmainnet" && hre.network.name !== "bsctestnet";

deploy/5-deploy-lst.ts

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)