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-2358] Custom oracles for BNBx, ankrBNB, stkBNB, slisBNB, WBETH, weETH, sFRAX #165

Merged
merged 111 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
da240d4
fix: added oracle for BNBx
web3rover Feb 12, 2024
3cc3c7f
fix: added stkBNB oracle
web3rover Feb 12, 2024
a6287da
fix: fixed stkBNB exchange rate and added slisBNBOracle
web3rover Feb 12, 2024
c2bfcee
fix: added wBETH oracle
web3rover Feb 12, 2024
b5db7ff
fix: added ankrBNB oracle
web3rover Feb 13, 2024
f925897
fix: fixed lint
web3rover Feb 13, 2024
6f60296
fix: added tests for ankrBNB
web3rover Feb 13, 2024
4bddd1a
fix: added tests for stkBNBOracle
web3rover Feb 13, 2024
3dd876a
fix: added BNBxOracle tests
web3rover Feb 13, 2024
8e845a3
fix: added SlisBNBOracle tests
web3rover Feb 13, 2024
9ebd366
fix: added WBETHOracle tests
web3rover Feb 13, 2024
b0db26a
fix: fixed tests
web3rover Feb 13, 2024
e44fc69
fix: deployed testnet oracles
web3rover Feb 13, 2024
d353312
feat: updating deployment files
Narayanprusty Feb 13, 2024
6db3b36
fix: prevent duplicate declaration
web3rover Feb 13, 2024
81144e8
Merge branch 'feat/derivative-prices' of github.com:VenusProtocol/ora…
web3rover Feb 13, 2024
304ae50
fix: revert accounts config
web3rover Feb 19, 2024
c0504a8
fix: updated styling
web3rover Feb 21, 2024
bc9c5ef
fix: resolved conflict
web3rover Feb 21, 2024
7315afa
feat: updating deployment files
Narayanprusty Feb 21, 2024
9f6fafa
fix: added sFrax and sfraxETH oracle
web3rover Feb 26, 2024
4dfdcb7
Merge branch 'feat/derivative-prices' of github.com:VenusProtocol/ora…
web3rover Feb 26, 2024
95f7c8c
fix: fixed interface
web3rover Feb 26, 2024
059ae93
fix: added ether.fi oracle
web3rover Feb 26, 2024
7a4d864
fix: remove duplicate
web3rover Feb 26, 2024
a105329
fix: added tests for frax oracle
web3rover Feb 26, 2024
46f5292
fix: added tests for etherfi oracle
web3rover Feb 26, 2024
30bf180
fix: fix EtherFi oracle file name
web3rover Feb 27, 2024
f7ac84e
fix: fixed casing
web3rover Feb 27, 2024
a259232
fix: fixed casing
web3rover Feb 27, 2024
7ba3858
fix: switch to eETH oracle when depegged
web3rover Feb 27, 2024
58e01aa
fix: handle frxETH depeg scenario
web3rover Feb 27, 2024
542d139
fix: use abstract contract for ankrBNB
web3rover Feb 29, 2024
55161c7
fix: use abstract contract for BNBxOracle
web3rover Feb 29, 2024
ff2b48c
fix: use abstract for stkBNB, WBETH and sFRAX
web3rover Feb 29, 2024
f972055
fix: use abstract contract for SFraxETHOracle
web3rover Feb 29, 2024
c8b960c
fix: use abstract contract for weETH oracle
web3rover Feb 29, 2024
89c7e8f
chore: lint fix
web3rover Feb 29, 2024
6ba9144
Merge branch 'develop' into feat/derivative-prices
web3rover Feb 29, 2024
571a6a1
fix: use abstract contract for wstETH oracle
web3rover Feb 29, 2024
f44977a
fix: updated commented
web3rover Mar 1, 2024
0549767
fix: use abstract contract for slisBNB
web3rover Mar 1, 2024
9e39ab4
fix: remove unused imports
web3rover Mar 1, 2024
ed8081e
fix: renamed fraxETH to frxETH
web3rover Mar 1, 2024
9f53486
fix: added missing frxETH oracle
web3rover Mar 1, 2024
9d35818
fix: use underlying decimals
web3rover Mar 1, 2024
827911d
fix: removed WrappedLiquidStakedTokenOracle
web3rover Mar 1, 2024
8e734b7
fix: added PendleOracle
web3rover Mar 1, 2024
bf4dbcd
fix: use generic names
web3rover Mar 1, 2024
85f7c3f
fix: added OneJumpOracle
web3rover Mar 4, 2024
9c5a853
fix: fixed decimals calculation
web3rover Mar 5, 2024
e2bf880
fix: removed native token addr
web3rover Mar 5, 2024
b13ee7a
fix: fixed netspec
web3rover Mar 5, 2024
fdbfa2c
fix: fixed tests
web3rover Mar 5, 2024
2a2f311
fix: prevent saving deployments during coverage
web3rover Mar 6, 2024
90ea2b1
fix: POV-01
web3rover Mar 14, 2024
423c552
fix: SBB-01
web3rover Mar 14, 2024
12e9d52
fix: SFO-01
web3rover Mar 14, 2024
c167681
fix: VPB-02
web3rover Mar 14, 2024
0854636
fix: VPB-03
web3rover Mar 14, 2024
f0f5ed0
fix: VPB-04
web3rover Mar 14, 2024
5c4a531
fix: CTO-01
web3rover Mar 14, 2024
b14b832
fix: VPB-05
web3rover Mar 14, 2024
ac18ad7
fix: VPB-01
web3rover Mar 18, 2024
3e86e32
Merge pull request #172 from VenusProtocol/fix/certik-audit-fixes
web3rover Mar 19, 2024
50e3e5b
fix: reset deployments
web3rover Apr 4, 2024
192e35a
feat: updating deployment files
Narayanprusty Apr 4, 2024
2587bc0
fix: removed deployments
web3rover Apr 4, 2024
2462e7b
Merge branch 'feat/derivative-prices' of github.com:VenusProtocol/ora…
web3rover Apr 4, 2024
6cfdcf5
fix: removed addresses
web3rover Apr 4, 2024
c56c638
fix: added MockEtherFiLiquidityPool
web3rover Apr 4, 2024
4ca37b9
fix: added deployment script for ethereum mainnet
web3rover Apr 4, 2024
4e4f605
fix: remove MockEtherFiLiquidityPool
web3rover Apr 4, 2024
6145e08
Merge branch 'feat/derivative-prices' into feat/deploy-weETH-oracle
web3rover Apr 4, 2024
8a43973
fix: added MockEtherFiLiquidityPool
web3rover Apr 4, 2024
c1164e8
fix: wip for deploying oracle
web3rover Apr 4, 2024
4b0a2d7
fix: deployed weETH oracle
web3rover Apr 4, 2024
8b80c1c
fix: fixed end of line
web3rover Apr 9, 2024
30baca8
fix: remove skipIfAlreadyDeployed
web3rover Apr 9, 2024
0ac8a93
fix: added skipIfAlreadyDeployed
web3rover Apr 9, 2024
1a3466a
fix: added comment for calculations
web3rover Apr 9, 2024
da6e458
fix: reverted account change
web3rover Apr 9, 2024
d67e28e
Merge branch 'develop' into feat/derivative-prices
web3rover Apr 10, 2024
16e8733
Merge branch 'feat/derivative-prices' into feat/deploy-weETH-oracle
web3rover Apr 10, 2024
524fe52
fix: best-practices-4
web3rover Apr 9, 2024
6356a75
fix: best-practices-5
web3rover Apr 9, 2024
93778bd
Merge branch 'feat/deploy-weETH-oracle' into fix/quantstamp-audit-fixes
web3rover Apr 10, 2024
752da30
fix: ven-cor-4
web3rover Apr 10, 2024
6055f9c
Merge pull request #176 from VenusProtocol/fix/quantstamp-audit-fixes
chechu Apr 10, 2024
cbff0bf
fix: redeployed oracle
web3rover Apr 10, 2024
82347e5
fix: fixed test name
web3rover Apr 12, 2024
0e7f175
fix: fixed netspec comment
web3rover Apr 12, 2024
4bc86e5
Merge pull request #175 from VenusProtocol/feat/deploy-weETH-oracle
web3rover Apr 12, 2024
9918745
feat: updating deployment files
Narayanprusty Apr 12, 2024
d05c131
fix: added legacy WstETHOracle
web3rover Apr 12, 2024
9a29657
fix: fixed lint
web3rover Apr 12, 2024
36d1147
fix: deployed weETH oracles on ethereum mainnet
web3rover Apr 12, 2024
75a8601
feat: updating deployment files
Narayanprusty Apr 12, 2024
6f84648
fix: fixed netspec comment
web3rover Apr 12, 2024
fa59be3
fix: fixed netspec comment
web3rover Apr 12, 2024
9efcae3
fix: fix OneJumpOracle decimals returned
web3rover Apr 12, 2024
eeab989
fix: updated netspec
web3rover Apr 12, 2024
cd98b1c
Merge branch 'feat/derivative-prices' into feat/mainnet-weETHOracle-d…
web3rover Apr 12, 2024
59ab566
Merge branch 'feat/mainnet-weETHOracle-deploy' of github.com:VenusPro…
web3rover Apr 12, 2024
8d9a5d7
fix: wip - redeployment
web3rover Apr 12, 2024
afcf5d0
fix: fixed deployment
web3rover Apr 12, 2024
080a1a4
fix: fixed deployment
web3rover Apr 12, 2024
4faaceb
fix: uncommented
web3rover Apr 15, 2024
5822205
Merge pull request #180 from VenusProtocol/feat/mainnet-weETHOracle-d…
web3rover Apr 15, 2024
cfac0ef
feat: updating deployment files
Narayanprusty Apr 15, 2024
5cd5297
docs: add audit reports for correlated token oracles
chechu Apr 15, 2024
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
2 changes: 1 addition & 1 deletion .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"arrowParens": avoid,
"bracketSpacing": true,
"endOfLine": "auto",
"endOfLine": "lf",
"importOrder": ["module-alias/register", "<THIRD_PARTY_MODULES>", "^[./]"],
"importOrderParserPlugins": ["typescript"],
"importOrderSeparation": true,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions contracts/interfaces/IAnkrBNB.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IAnkrBNB {
function sharesToBonds(uint256 amount) external view returns (uint256);
function decimals() external view returns (uint8);
}
6 changes: 6 additions & 0 deletions contracts/interfaces/IEtherFiLiquidityPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IEtherFiLiquidityPool {
function amountForShare(uint256 _share) external view returns (uint256);
}
14 changes: 14 additions & 0 deletions contracts/interfaces/IPStakePool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IPStakePool {
struct Data {
uint256 totalWei;
uint256 poolTokenSupply;
}

/**
* @dev The current exchange rate for converting stkBNB to BNB.
*/
function exchangeRate() external view returns (Data memory);
}
13 changes: 13 additions & 0 deletions contracts/interfaces/IPendlePtOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IPendlePtOracle {
function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);
function getOracleState(
address market,
uint32 duration
)
external
view
returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied);
}
7 changes: 7 additions & 0 deletions contracts/interfaces/ISFrax.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface ISFrax {
function convertToAssets(uint256 shares) external view returns (uint256);
function decimals() external view returns (uint8);
}
7 changes: 7 additions & 0 deletions contracts/interfaces/ISfrxETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface ISfrxETH {
function convertToAssets(uint256 shares) external view returns (uint256);
function decimals() external view returns (uint8);
}
1 change: 1 addition & 0 deletions contracts/interfaces/IStETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ pragma solidity ^0.8.25;

interface IStETH {
function getPooledEthByShares(uint256 _sharesAmount) external view returns (uint256);
function decimals() external view returns (uint8);
}
6 changes: 6 additions & 0 deletions contracts/interfaces/IStaderStakeManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IStaderStakeManager {
function convertBnbXToBnb(uint256 _amount) external view returns (uint256);
}
6 changes: 6 additions & 0 deletions contracts/interfaces/ISynclubStakeManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface ISynclubStakeManager {
function convertSnBnbToBnb(uint256 _amount) external view returns (uint256);
}
7 changes: 7 additions & 0 deletions contracts/interfaces/IWBETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

interface IWBETH {
function exchangeRate() external view returns (uint256);
function decimals() external view returns (uint8);
}
31 changes: 31 additions & 0 deletions contracts/oracles/AnkrBNBOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { IAnkrBNB } from "../interfaces/IAnkrBNB.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol";

/**
* @title AnkrBNBOracle
* @author Venus
* @notice This oracle fetches the price of ankrBNB asset
*/
contract AnkrBNBOracle is CorrelatedTokenOracle {
/// @notice This is used as token address of BNB on BSC
address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address ankrBNB,
address resilientOracle
) CorrelatedTokenOracle(ankrBNB, NATIVE_TOKEN_ADDR, resilientOracle) {}

/**
* @notice Fetches the amount of BNB for 1 ankrBNB
* @return amount The amount of BNB for ankrBNB
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return IAnkrBNB(CORRELATED_TOKEN).sharesToBonds(EXP_SCALE);
}
}
40 changes: 40 additions & 0 deletions contracts/oracles/BNBxOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { IStaderStakeManager } from "../interfaces/IStaderStakeManager.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";

/**
* @title BNBxOracle
* @author Venus
* @notice This oracle fetches the price of BNBx asset
*/
contract BNBxOracle is CorrelatedTokenOracle {
/// @notice This is used as token address of BNB on BSC
address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;

/// @notice Address of StakeManager
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IStaderStakeManager public immutable STAKE_MANAGER;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address stakeManager,
address bnbx,
address resilientOracle
) CorrelatedTokenOracle(bnbx, NATIVE_TOKEN_ADDR, resilientOracle) {
ensureNonzeroAddress(stakeManager);
STAKE_MANAGER = IStaderStakeManager(stakeManager);
}

/**
* @notice Fetches the amount of BNB for 1 BNBx
* @return price The amount of BNB for BNBx
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return STAKE_MANAGER.convertBnbXToBnb(EXP_SCALE);
}
}
43 changes: 43 additions & 0 deletions contracts/oracles/OneJumpOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";
import { OracleInterface } from "../interfaces/OracleInterface.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";

/**
* @title OneJumpOracle
* @author Venus
* @notice This oracle fetches the price of an asset in through an intermediate asset
*/
contract OneJumpOracle is CorrelatedTokenOracle {
/// @notice Address of the intermediate oracle
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
OracleInterface public immutable INTERMEDIATE_ORACLE;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address correlatedToken,
address underlyingToken,
address resilientOracle,
address intermediateOracle
) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {
ensureNonzeroAddress(intermediateOracle);
INTERMEDIATE_ORACLE = OracleInterface(intermediateOracle);
}

/**
* @notice Fetches the amount of the underlying token for 1 correlated token, using the intermediate oracle
* @return amount The amount of the underlying token for 1 correlated token scaled by the underlying token decimals
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
uint256 underlyingDecimals = IERC20Metadata(UNDERLYING_TOKEN).decimals();
uint256 correlatedDecimals = IERC20Metadata(CORRELATED_TOKEN).decimals();

uint256 underlyingAmount = INTERMEDIATE_ORACLE.getPrice(CORRELATED_TOKEN);

return (underlyingAmount * (10 ** correlatedDecimals)) / (10 ** (36 - underlyingDecimals));
}
}
63 changes: 63 additions & 0 deletions contracts/oracles/PendleOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { IPendlePtOracle } from "../interfaces/IPendlePtOracle.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { ensureNonzeroAddress, ensureNonzeroValue } from "@venusprotocol/solidity-utilities/contracts/validators.sol";

/**
* @title PendleOracle
* @author Venus
* @notice This oracle fetches the price of a pendle token
*/
contract PendleOracle is CorrelatedTokenOracle {
/// @notice Address of the PT oracle
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IPendlePtOracle public immutable PT_ORACLE;

/// @notice Address of the market
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
address public immutable MARKET;

/// @notice Twap duration for the oracle
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
uint32 public immutable TWAP_DURATION;

/// @notice Thrown if the duration is invalid
error InvalidDuration();

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address market,
address ptOracle,
address ptToken,
address underlyingToken,
address resilientOracle,
uint32 twapDuration
) CorrelatedTokenOracle(ptToken, underlyingToken, resilientOracle) {
ensureNonzeroAddress(market);
ensureNonzeroAddress(ptOracle);
ensureNonzeroValue(twapDuration);

MARKET = market;
PT_ORACLE = IPendlePtOracle(ptOracle);
TWAP_DURATION = twapDuration;

(bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = PT_ORACLE.getOracleState(
MARKET,
TWAP_DURATION
);
if (increaseCardinalityRequired || !oldestObservationSatisfied) {
revert InvalidDuration();
}
}

/**
* @notice Fetches the amount of underlying token for 1 pendle token
* @return amount The amount of underlying token for pendle token
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return PT_ORACLE.getPtToAssetRate(MARKET, TWAP_DURATION);
}
}
29 changes: 29 additions & 0 deletions contracts/oracles/SFraxOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { ISFrax } from "../interfaces/ISFrax.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol";

/**
* @title SFraxOracle
* @author Venus
* @notice This oracle fetches the price of sFrax
*/
contract SFraxOracle is CorrelatedTokenOracle {
/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address sFrax,
address frax,
address resilientOracle
) CorrelatedTokenOracle(sFrax, frax, resilientOracle) {}

/**
* @notice Fetches the amount of FRAX for 1 sFrax
* @return amount The amount of FRAX for sFrax
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return ISFrax(CORRELATED_TOKEN).convertToAssets(EXP_SCALE);
}
}
29 changes: 29 additions & 0 deletions contracts/oracles/SFrxETHOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { ISfrxETH } from "../interfaces/ISfrxETH.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol";

/**
* @title SFrxETHOracle
* @author Venus
* @notice This oracle fetches the price of sfrxETH
*/
contract SFrxETHOracle is CorrelatedTokenOracle {
/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address sfrxETH,
address frxETH,
address resilientOracle
) CorrelatedTokenOracle(sfrxETH, frxETH, resilientOracle) {}

/**
* @notice Gets the frxETH for 1 sfrxETH
* @return amount Amount of frxETH
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return ISfrxETH(CORRELATED_TOKEN).convertToAssets(EXP_SCALE);
}
}
40 changes: 40 additions & 0 deletions contracts/oracles/SlisBNBOracle.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: BSD-3-Clause
pragma solidity 0.8.25;

import { ISynclubStakeManager } from "../interfaces/ISynclubStakeManager.sol";
import { ensureNonzeroAddress } from "@venusprotocol/solidity-utilities/contracts/validators.sol";
import { CorrelatedTokenOracle } from "./common/CorrelatedTokenOracle.sol";
import { EXP_SCALE } from "@venusprotocol/solidity-utilities/contracts/constants.sol";

/**
* @title SlisBNBOracle
* @author Venus
* @notice This oracle fetches the price of slisBNB asset
*/
contract SlisBNBOracle is CorrelatedTokenOracle {
/// @notice This is used as token address of BNB on BSC
address public constant NATIVE_TOKEN_ADDR = 0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB;

/// @notice Address of StakeManager
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
ISynclubStakeManager public immutable STAKE_MANAGER;

/// @notice Constructor for the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor(
address stakeManager,
address slisBNB,
address resilientOracle
) CorrelatedTokenOracle(slisBNB, NATIVE_TOKEN_ADDR, resilientOracle) {
ensureNonzeroAddress(stakeManager);
STAKE_MANAGER = ISynclubStakeManager(stakeManager);
}

/**
* @notice Fetches the amount of BNB for 1 slisBNB
* @return amount The amount of BNB for slisBNB
*/
function _getUnderlyingAmount() internal view override returns (uint256) {
return STAKE_MANAGER.convertSnBnbToBnb(EXP_SCALE);
}
}
Loading
Loading