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

[VEN-2359] Deployment of LST Oracles #183

Merged
merged 17 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 12 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
33 changes: 33 additions & 0 deletions contracts/test/MockAnkrBNB.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IAnkrBNB } from "../interfaces/IAnkrBNB.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MockAnkrBNB is ERC20, Ownable, IAnkrBNB {
uint8 private immutable _decimals;
uint256 public exchangeRate;

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) Ownable() {
_decimals = decimals_;
}

function faucet(uint256 amount) external {
_mint(msg.sender, amount);
}

function setSharesToBonds(uint256 rate) external onlyOwner {
exchangeRate = rate;
}

function sharesToBonds(uint256 amount) external view override returns (uint256) {
return (amount * exchangeRate) / (10 ** uint256(_decimals));
}

function decimals() public view virtual override(ERC20, IAnkrBNB) returns (uint8) {
return _decimals;
}
}
29 changes: 29 additions & 0 deletions contracts/test/MockWBETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { IWBETH } from "../interfaces/IWBETH.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MockWBETH is ERC20, Ownable, IWBETH {
uint8 private immutable _decimals;
uint256 public override exchangeRate;

constructor(string memory name_, string memory symbol_, uint8 decimals_) ERC20(name_, symbol_) Ownable() {
_decimals = decimals_;
}

function faucet(uint256 amount) external {
_mint(msg.sender, amount);
}

function setExchangeRate(uint256 rate) external onlyOwner {
exchangeRate = rate;
}

function decimals() public view virtual override(ERC20, IWBETH) returns (uint8) {
return _decimals;
}
}
120 changes: 120 additions & 0 deletions deploy/5-deploy-bnb-lst-oracles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import { ethers } from "hardhat";
import { DeployFunction } from "hardhat-deploy/dist/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";

import { ADDRESSES, assets } from "../helpers/deploymentConfig";

const func: DeployFunction = async ({ getNamedAccounts, deployments, network }: HardhatRuntimeEnvironment) => {
const { deploy } = deployments;
const { deployer } = await getNamedAccounts();

const oracle = await ethers.getContract("ResilientOracle");
const proxyOwnerAddress = network.live ? ADDRESSES[network.name].timelock : deployer;

const { ankrBNB, stkBNB, BNBx, BNBxStakeManager, slisBNBStakeManager, stkBNBStakePool, slisBNB, wBETH } =
ADDRESSES[network.name];
const ETH = assets[network.name].find(asset => asset.token === "ETH");

await deploy("BNBxOracle", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [BNBxStakeManager, BNBx, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});

await deploy("SlisBNBOracle", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [slisBNBStakeManager, slisBNB, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});

await deploy("StkBNBOracle", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [stkBNBStakePool, stkBNB, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});

let ankrBNBAddress = ankrBNB;
if (!ankrBNB) {
// deploy MockAnkrBNB
await deploy("MockAnkrBNB", {
from: deployer,
log: true,
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
skipIfAlreadyDeployed: true,
args: ["Ankr Staked BNB ", "ankrBNB", "18"],
});

const ankrBNBContract = await ethers.getContract("MockAnkrBNB");
ankrBNBAddress = ankrBNBContract.address;

if ((await ankrBNBContract.owner()) === deployer) {
await ankrBNBContract.transferOwnership(proxyOwnerAddress);
}
}

await deploy("AnkrBNBOracle", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [ankrBNBAddress, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});

let wBETHAddress = wBETH;
if (!wBETH) {
// deploy MockWBETH
await deploy("MockWBETH", {
from: deployer,
log: true,
autoMine: true, // speed up deployment on local network (ganache, hardhat), no effect on live networks
skipIfAlreadyDeployed: true,
args: ["Wrapped Binance Beacon ETH", "wBETH", "18"],
});

const wBETHContract = await ethers.getContract("MockWBETH");
wBETHAddress = wBETHContract.address;

if ((await wBETHContract.owner()) === deployer) {
await wBETHContract.transferOwnership(proxyOwnerAddress);
}
}

await deploy("WBETHOracle", {
from: deployer,
log: true,
deterministicDeployment: false,
args: [wBETHAddress, ETH?.address, oracle.address],
proxy: {
owner: proxyOwnerAddress,
proxyContract: "OptimizedTransparentProxy",
},
skipIfAlreadyDeployed: true,
});
};

export default func;
func.tags = ["bnb_lst"];
func.skip = async (hre: HardhatRuntimeEnvironment) =>
hre.network.name !== "bscmainnet" && hre.network.name !== "bsctestnet";
86 changes: 0 additions & 86 deletions deploy/5-deploy-lst.ts

This file was deleted.

Loading
Loading