good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
contracts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
interest protocol
contracts
Commits
331185af
Commit
331185af
authored
Jan 16, 2024
by
Jake Barber
Browse files
Options
Downloads
Patches
Plain Diff
fixed bpt oracle
parent
33db640b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
contracts/oracle/External/BPTstablePoolOracle.sol
+3
-1
3 additions, 1 deletion
contracts/oracle/External/BPTstablePoolOracle.sol
test/cap/cappedBPT/OracleTesting.ts
+75
-6
75 additions, 6 deletions
test/cap/cappedBPT/OracleTesting.ts
util/addresser.ts
+1
-0
1 addition, 0 deletions
util/addresser.ts
with
79 additions
and
7 deletions
contracts/oracle/External/BPTstablePoolOracle.sol
+
3
−
1
View file @
331185af
...
@@ -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);
...
...
This diff is collapsed.
Click to expand it.
test/cap/cappedBPT/OracleTesting.ts
+
75
−
6
View file @
331185af
...
@@ -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()))
})
})
})
})
This diff is collapsed.
Click to expand it.
util/addresser.ts
+
1
−
0
View file @
331185af
...
@@ -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
()
{
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment