good morning!!!!

Skip to content
Snippets Groups Projects
Commit 331185af authored by Jake Barber's avatar Jake Barber
Browse files

fixed bpt oracle

parent 33db640b
No related branches found
No related tags found
No related merge requests found
...@@ -71,7 +71,9 @@ contract BPTstablePoolOracle is IOracleRelay { ...@@ -71,7 +71,9 @@ contract BPTstablePoolOracle is IOracleRelay {
(IERC20[] memory tokens, uint256[] memory balances /**uint256 lastChangeBlock */, ) = VAULT.getPoolTokens(_poolId); (IERC20[] memory tokens, uint256[] memory balances /**uint256 lastChangeBlock */, ) = VAULT.getPoolTokens(_poolId);
uint256 tokenAmountIn = 1000e18; //updated 1/2024
//tokenAmountIn == 1% of BPT total supply
uint256 tokenAmountIn = (_priceFeed.totalSupply() * 1e16) / 1e18;
uint256 outGivenIn = getOutGivenIn(balances, tokenAmountIn); uint256 outGivenIn = getOutGivenIn(balances, tokenAmountIn);
......
...@@ -2,13 +2,16 @@ import { s } from "../scope"; ...@@ -2,13 +2,16 @@ import { s } from "../scope";
import { d } from "../DeploymentInfo"; import { d } from "../DeploymentInfo";
import { ethers, network } from "hardhat"; import { ethers, network } from "hardhat";
import { BN } from "../../../util/number"; import { BN } from "../../../util/number";
import { currentBlock, mineBlock, reset } from "../../../util/block"; import { currentBlock, mineBlock, reset, resetCurrent } from "../../../util/block";
import { expect } from "chai"; import { expect } from "chai";
import { IERC20__factory, VaultController__factory, USDI__factory, OracleMaster__factory, ProxyAdmin__factory, IBalancerVault__factory, VotingVaultController__factory, IGauge__factory, IOracleRelay__factory, WstETHRelay__factory, BPTstablePoolOracle__factory, StablePoolShowcase__factory, IOracleRelay, StablePoolShowcase, UniswapV3TokenOracleRelay__factory, BPT_WEIGHTED_ORACLE__factory, ChainlinkOracleRelay__factory, UniswapV3OracleRelay__factory, BPTstablePoolOracle } from "../../../typechain-types"; import { IERC20__factory, VaultController__factory, USDI__factory, OracleMaster__factory, ProxyAdmin__factory, IBalancerVault__factory, VotingVaultController__factory, IGauge__factory, IOracleRelay__factory, WstETHRelay__factory, BPTstablePoolOracle__factory, StablePoolShowcase__factory, IOracleRelay, StablePoolShowcase, UniswapV3TokenOracleRelay__factory, BPT_WEIGHTED_ORACLE__factory, ChainlinkOracleRelay__factory, UniswapV3OracleRelay__factory, BPTstablePoolOracle } from "../../../typechain-types";
import { showBody, showBodyCyan } from "../../../util/format"; import { showBody, showBodyCyan } from "../../../util/format";
import { toNumber } from "../../../util/math"; import { toNumber } from "../../../util/math";
import { MainnetBPTaddresses } from "../../../util/addresser"; import { MainnetBPTaddresses, a } from "../../../util/addresser";
import { BigNumber } from "ethers";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { pool } from "../../../typechain-types/contracts/_external/uniswap";
/****************************************** /******************************************
* These standalone tests are meant to be a simple test for the * These standalone tests are meant to be a simple test for the
...@@ -25,11 +28,12 @@ import { MainnetBPTaddresses } from "../../../util/addresser"; ...@@ -25,11 +28,12 @@ import { MainnetBPTaddresses } from "../../../util/addresser";
const deltaBips = 200 const deltaBips = 200
let oracle: BPTstablePoolOracle let oracle: BPTstablePoolOracle
let testOracle: BPTstablePoolOracle
describe("Setup", () => { describe("Setup", () => {
it("Set hardhat network to a block after deployment", async () => { it("Set hardhat network to a block after deployment", async () => {
await reset(18486191) await resetCurrent()
//await reset(18486413)//last block current deploy is working
const block = await currentBlock() const block = await currentBlock()
showBody("Testing as of block: ", block.number) showBody("Testing as of block: ", block.number)
}) })
...@@ -45,12 +49,77 @@ describe("Setup", () => { ...@@ -45,12 +49,77 @@ describe("Setup", () => {
const addrs = new MainnetBPTaddresses() const addrs = new MainnetBPTaddresses()
oracle = BPTstablePoolOracle__factory.connect(addrs.B_stETH_STABLEPOOL_ORACLE, s.Frank) oracle = BPTstablePoolOracle__factory.connect(addrs.B_stETH_STABLEPOOL_ORACLE, s.Frank)
}) })
}) })
describe("Deploy and test oracles for underlying assets", () => { describe("Deploy and test oracles for underlying assets", () => {
it("Get live feed", async () => { let poolAddress: string
showBodyCyan(await toNumber(await oracle.currentValue())) let balancerVault: string
let tokens: string[] = [a.wstethAddress, a.wethAddress]
let oracles: string[]
let num: BigNumber
let den: BigNumber
let testNum: BigNumber
let destDenom: BigNumber
it("get deployment data", async () => {
poolAddress = await oracle._priceFeed()
balancerVault = await oracle.VAULT()
oracles = [await oracle.assetOracles(tokens[0]), await oracle.assetOracles(tokens[1])]
num = await oracle._widthNumerator()
den = await oracle._widthDenominator()
/**
console.log(poolAddress)
console.log(balancerVault)
console.log(tokens)
console.log(oracles)
console.log(num)
console.log(den)
*/
})
it("Verify values", async () => {
const wstethOracle = IOracleRelay__factory.connect(oracles[0], s.Frank)
const ethOracle = IOracleRelay__factory.connect(oracles[1], s.Frank)
showBody("wsteth price: ", await toNumber(await wstethOracle.currentValue()))
showBody("eth price: ", await toNumber(await ethOracle.currentValue()))
//get liquidity
const vault = IBalancerVault__factory.connect(balancerVault, s.Frank)
const poolTokens = await vault.getPoolTokens("0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080")
showBody("Balances 0: ", await toNumber(poolTokens.balances[0]))
showBody("Balances 1: ", await toNumber(poolTokens.balances[1]))
})
it("Deploy testing duplicate", async () => {
testOracle = await new BPTstablePoolOracle__factory(s.Frank).deploy(
poolAddress,
balancerVault,
tokens,
oracles,
num,
den
)
await testOracle.deployed()
showBodyCyan("PRICE: ", await toNumber(await testOracle.currentValue()))
})
it("Test read", async () => {
//showBodyCyan(await toNumber(await oracle.currentValue()))
}) })
}) })
...@@ -42,6 +42,7 @@ export class MainnetAddresses { ...@@ -42,6 +42,7 @@ export class MainnetAddresses {
readonly rplAddress: string = "0xD33526068D116cE69F19A9ee46F0bd304F21A51f" readonly rplAddress: string = "0xD33526068D116cE69F19A9ee46F0bd304F21A51f"
readonly oethAddress: string = "0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3" readonly oethAddress: string = "0x856c4Efb76C1D1AE02e20CEB03A2A6a08b0b8dC3"
readonly woethAddress: string = "0xDcEe70654261AF21C44c093C300eD3Bb97b78192" readonly woethAddress: string = "0xDcEe70654261AF21C44c093C300eD3Bb97b78192"
readonly wstethAddress: string = "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
constructor() { } constructor() { }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment