@venusprotocol/oracle 2.8.0-dev.2 → 2.8.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deployments/bscmainnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025.json +368 -0
- package/deployments/bscmainnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025_Implementation.json +329 -0
- package/deployments/bscmainnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025_Proxy.json +224 -0
- package/deployments/bscmainnet/SolvBTC.BBN_OneJumpRedStoneOracle.json +295 -0
- package/deployments/bscmainnet/SolvBTC.BBN_OneJumpRedStoneOracle_Implementation.json +204 -0
- package/deployments/bscmainnet/SolvBTC.BBN_OneJumpRedStoneOracle_Proxy.json +213 -0
- package/deployments/bscmainnet/solcInputs/0bebc4f35e59fb8446bd3ebaaccae910.json +64 -0
- package/deployments/bscmainnet/solcInputs/6aede02a1ea73715bd2f7f2e6dad96c7.json +64 -0
- package/deployments/bscmainnet.json +2439 -1370
- package/deployments/bscmainnet_addresses.json +6 -0
- package/deployments/bsctestnet/MockPendlePtOracle.json +354 -0
- package/deployments/bsctestnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025.json +368 -0
- package/deployments/bsctestnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025_Implementation.json +329 -0
- package/deployments/bsctestnet/PendleOracle-PT-SolvBTC.BBN-27MAR2025_Proxy.json +224 -0
- package/deployments/bsctestnet/SolvBTC.BBN_OneJumpRedStoneOracle.json +295 -0
- package/deployments/bsctestnet/SolvBTC.BBN_OneJumpRedStoneOracle_Implementation.json +204 -0
- package/deployments/bsctestnet/SolvBTC.BBN_OneJumpRedStoneOracle_Proxy.json +213 -0
- package/deployments/bsctestnet/solcInputs/0bebc4f35e59fb8446bd3ebaaccae910.json +64 -0
- package/deployments/bsctestnet/solcInputs/6aede02a1ea73715bd2f7f2e6dad96c7.json +64 -0
- package/deployments/bsctestnet.json +2473 -1166
- package/deployments/bsctestnet_addresses.json +7 -0
- package/dist/deploy/16-deploy-SolvBTC.BBN-pendle-oracles.d.ts +4 -0
- package/dist/deploy/16-deploy-SolvBTC.BBN-pendle-oracles.d.ts.map +1 -0
- package/dist/deploy/16-deploy-SolvBTC.BBN-pendle-oracles.js +55 -0
- package/dist/deploy/16-deploy-SolvBTC.BBN-pendle-oracles.js.map +1 -0
- package/dist/deploy/7-dependencies-pendle-oracle.js +2 -2
- package/dist/deploy/7-dependencies-pendle-oracle.js.map +1 -1
- package/dist/helpers/deploymentConfig.d.ts.map +1 -1
- package/dist/helpers/deploymentConfig.js +8 -0
- package/dist/helpers/deploymentConfig.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "Solidity",
|
|
3
|
+
"sources": {
|
|
4
|
+
"@openzeppelin/contracts/access/Ownable.sol": {
|
|
5
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
|
|
6
|
+
},
|
|
7
|
+
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
|
|
8
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
|
|
9
|
+
},
|
|
10
|
+
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
|
|
11
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
|
|
12
|
+
},
|
|
13
|
+
"@openzeppelin/contracts/utils/Context.sol": {
|
|
14
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n function _contextSuffixLength() internal view virtual returns (uint256) {\n return 0;\n }\n}\n"
|
|
15
|
+
},
|
|
16
|
+
"@venusprotocol/solidity-utilities/contracts/validators.sol": {
|
|
17
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n"
|
|
18
|
+
},
|
|
19
|
+
"contracts/interfaces/IPendlePtOracle.sol": {
|
|
20
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\ninterface IPendlePtOracle {\n function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);\n\n function getPtToSyRate(address market, uint32 duration) external view returns (uint256);\n\n function getOracleState(\n address market,\n uint32 duration\n )\n external\n view\n returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied);\n}\n"
|
|
21
|
+
},
|
|
22
|
+
"contracts/interfaces/OracleInterface.sol": {
|
|
23
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n"
|
|
24
|
+
},
|
|
25
|
+
"contracts/oracles/common/CorrelatedTokenOracle.sol": {
|
|
26
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @title CorrelatedTokenOracle\n * @notice This oracle fetches the price of a token that is correlated to another token.\n */\nabstract contract CorrelatedTokenOracle is OracleInterface {\n /// @notice Address of the correlated token\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable CORRELATED_TOKEN;\n\n /// @notice Address of the underlying token\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable UNDERLYING_TOKEN;\n\n /// @notice Address of Resilient Oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n OracleInterface public immutable RESILIENT_ORACLE;\n\n /// @notice Thrown if the token address is invalid\n error InvalidTokenAddress();\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address correlatedToken, address underlyingToken, address resilientOracle) {\n ensureNonzeroAddress(correlatedToken);\n ensureNonzeroAddress(underlyingToken);\n ensureNonzeroAddress(resilientOracle);\n CORRELATED_TOKEN = correlatedToken;\n UNDERLYING_TOKEN = underlyingToken;\n RESILIENT_ORACLE = OracleInterface(resilientOracle);\n }\n\n /**\n * @notice Fetches the price of the correlated token\n * @param asset Address of the correlated token\n * @return price The price of the correlated token in scaled decimal places\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (asset != CORRELATED_TOKEN) revert InvalidTokenAddress();\n\n // get underlying token amount for 1 correlated token scaled by underlying token decimals\n uint256 underlyingAmount = _getUnderlyingAmount();\n\n // oracle returns (36 - asset decimal) scaled price\n uint256 underlyingUSDPrice = RESILIENT_ORACLE.getPrice(UNDERLYING_TOKEN);\n\n IERC20Metadata token = IERC20Metadata(CORRELATED_TOKEN);\n uint256 decimals = token.decimals();\n\n // underlyingAmount (for 1 correlated token) * underlyingUSDPrice / decimals(correlated token)\n return (underlyingAmount * underlyingUSDPrice) / (10 ** decimals);\n }\n\n /**\n * @notice Gets the underlying amount for correlated token\n * @return underlyingAmount Amount of underlying token\n */\n function _getUnderlyingAmount() internal view virtual returns (uint256);\n}\n"
|
|
27
|
+
},
|
|
28
|
+
"contracts/oracles/mocks/MockPendlePtOracle.sol": {
|
|
29
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport \"../../interfaces/IPendlePtOracle.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract MockPendlePtOracle is IPendlePtOracle, Ownable {\n mapping(address => mapping(uint32 => uint256)) public ptToAssetRate;\n mapping(address => mapping(uint32 => uint256)) public ptToSyRate;\n\n constructor() Ownable() {}\n\n function setPtToAssetRate(address market, uint32 duration, uint256 rate) external onlyOwner {\n ptToAssetRate[market][duration] = rate;\n }\n\n function setPtToSyRate(address market, uint32 duration, uint256 rate) external onlyOwner {\n ptToSyRate[market][duration] = rate;\n }\n\n function getPtToAssetRate(address market, uint32 duration) external view returns (uint256) {\n return ptToAssetRate[market][duration];\n }\n\n function getPtToSyRate(address market, uint32 duration) external view returns (uint256) {\n return ptToSyRate[market][duration];\n }\n\n function getOracleState(\n address /* market */,\n uint32 /* duration */\n )\n external\n pure\n returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied)\n {\n return (false, 0, true);\n }\n}\n"
|
|
30
|
+
},
|
|
31
|
+
"contracts/oracles/PendleOracle.sol": {
|
|
32
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { IPendlePtOracle } from \"../interfaces/IPendlePtOracle.sol\";\nimport { CorrelatedTokenOracle } from \"./common/CorrelatedTokenOracle.sol\";\nimport { ensureNonzeroAddress, ensureNonzeroValue } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\n\n/**\n * @title PendleOracle\n * @author Venus\n * @notice This oracle fetches the price of a pendle token\n */\ncontract PendleOracle is CorrelatedTokenOracle {\n /// @notice Which asset to use as a base for the returned PT\n /// price. Can be either a standardized yield token (SY), in\n /// this case PT/SY price is returned, or the underlying\n /// asset directly. Note that using PT_TO_ASSET rate assumes\n /// that the yield token can be seamlessly redeemed for the\n /// underlying asset. In reality, this might not always be\n /// the case. For more details, see\n /// https://docs.pendle.finance/Developers/Contracts/StandardizedYield\n enum RateKind {\n PT_TO_ASSET,\n PT_TO_SY\n }\n\n /// @notice Address of the PT oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IPendlePtOracle public immutable PT_ORACLE;\n\n /// @notice Whether to use PT/SY (standardized yield token) rate\n /// or PT/underlying asset rate\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n RateKind public immutable RATE_KIND;\n\n /// @notice Address of the market\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable MARKET;\n\n /// @notice Twap duration for the oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint32 public immutable TWAP_DURATION;\n\n /// @notice Thrown if the duration is invalid\n error InvalidDuration();\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address market,\n address ptOracle,\n RateKind rateKind,\n address ptToken,\n address underlyingToken,\n address resilientOracle,\n uint32 twapDuration\n ) CorrelatedTokenOracle(ptToken, underlyingToken, resilientOracle) {\n ensureNonzeroAddress(market);\n ensureNonzeroAddress(ptOracle);\n ensureNonzeroValue(twapDuration);\n\n MARKET = market;\n PT_ORACLE = IPendlePtOracle(ptOracle);\n RATE_KIND = rateKind;\n TWAP_DURATION = twapDuration;\n\n (bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = PT_ORACLE.getOracleState(\n MARKET,\n TWAP_DURATION\n );\n if (increaseCardinalityRequired || !oldestObservationSatisfied) {\n revert InvalidDuration();\n }\n }\n\n /**\n * @notice Fetches the amount of underlying or SY token for 1 pendle token\n * @return amount The amount of underlying or SY token for pendle token\n */\n function _getUnderlyingAmount() internal view override returns (uint256) {\n if (RATE_KIND == RateKind.PT_TO_SY) {\n return PT_ORACLE.getPtToSyRate(MARKET, TWAP_DURATION);\n }\n return PT_ORACLE.getPtToAssetRate(MARKET, TWAP_DURATION);\n }\n}\n"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"settings": {
|
|
36
|
+
"optimizer": {
|
|
37
|
+
"enabled": true,
|
|
38
|
+
"runs": 200,
|
|
39
|
+
"details": {
|
|
40
|
+
"yul": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"evmVersion": "paris",
|
|
44
|
+
"outputSelection": {
|
|
45
|
+
"*": {
|
|
46
|
+
"*": [
|
|
47
|
+
"storageLayout",
|
|
48
|
+
"abi",
|
|
49
|
+
"evm.bytecode",
|
|
50
|
+
"evm.deployedBytecode",
|
|
51
|
+
"evm.methodIdentifiers",
|
|
52
|
+
"metadata",
|
|
53
|
+
"devdoc",
|
|
54
|
+
"userdoc",
|
|
55
|
+
"evm.gasEstimates"
|
|
56
|
+
],
|
|
57
|
+
"": ["ast"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"metadata": {
|
|
61
|
+
"useLiteralContent": true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"language": "Solidity",
|
|
3
|
+
"sources": {
|
|
4
|
+
"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
|
|
5
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n /**\n * @dev Returns the name of the token.\n */\n function name() external view returns (string memory);\n\n /**\n * @dev Returns the symbol of the token.\n */\n function symbol() external view returns (string memory);\n\n /**\n * @dev Returns the decimals places of the token.\n */\n function decimals() external view returns (uint8);\n}\n"
|
|
6
|
+
},
|
|
7
|
+
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
|
|
8
|
+
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
|
|
9
|
+
},
|
|
10
|
+
"@venusprotocol/solidity-utilities/contracts/constants.sol": {
|
|
11
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\n/// @dev Base unit for computations, usually used in scaling (multiplications, divisions)\nuint256 constant EXP_SCALE = 1e18;\n\n/// @dev A unit (literal one) in EXP_SCALE, usually used in additions/subtractions\nuint256 constant MANTISSA_ONE = EXP_SCALE;\n\n/// @dev The approximate number of seconds per year\nuint256 constant SECONDS_PER_YEAR = 31_536_000;\n"
|
|
12
|
+
},
|
|
13
|
+
"@venusprotocol/solidity-utilities/contracts/validators.sol": {
|
|
14
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\n/// @notice Thrown if the supplied address is a zero address where it is not allowed\nerror ZeroAddressNotAllowed();\n\n/// @notice Thrown if the supplied value is 0 where it is not allowed\nerror ZeroValueNotAllowed();\n\n/// @notice Checks if the provided address is nonzero, reverts otherwise\n/// @param address_ Address to check\n/// @custom:error ZeroAddressNotAllowed is thrown if the provided address is a zero address\nfunction ensureNonzeroAddress(address address_) pure {\n if (address_ == address(0)) {\n revert ZeroAddressNotAllowed();\n }\n}\n\n/// @notice Checks if the provided value is nonzero, reverts otherwise\n/// @param value_ Value to check\n/// @custom:error ZeroValueNotAllowed is thrown if the provided value is 0\nfunction ensureNonzeroValue(uint256 value_) pure {\n if (value_ == 0) {\n revert ZeroValueNotAllowed();\n }\n}\n"
|
|
15
|
+
},
|
|
16
|
+
"contracts/interfaces/IERC4626.sol": {
|
|
17
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\ninterface IERC4626 {\n function convertToAssets(uint256 shares) external view returns (uint256);\n function decimals() external view returns (uint8);\n}\n"
|
|
18
|
+
},
|
|
19
|
+
"contracts/interfaces/IPendlePtOracle.sol": {
|
|
20
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\ninterface IPendlePtOracle {\n function getPtToAssetRate(address market, uint32 duration) external view returns (uint256);\n\n function getPtToSyRate(address market, uint32 duration) external view returns (uint256);\n\n function getOracleState(\n address market,\n uint32 duration\n )\n external\n view\n returns (bool increaseCardinalityRequired, uint16 cardinalityRequired, bool oldestObservationSatisfied);\n}\n"
|
|
21
|
+
},
|
|
22
|
+
"contracts/interfaces/OracleInterface.sol": {
|
|
23
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity ^0.8.25;\n\ninterface OracleInterface {\n function getPrice(address asset) external view returns (uint256);\n}\n\ninterface ResilientOracleInterface is OracleInterface {\n function updatePrice(address vToken) external;\n\n function updateAssetPrice(address asset) external;\n\n function getUnderlyingPrice(address vToken) external view returns (uint256);\n}\n\ninterface TwapInterface is OracleInterface {\n function updateTwap(address asset) external returns (uint256);\n}\n\ninterface BoundValidatorInterface {\n function validatePriceWithAnchorPrice(\n address asset,\n uint256 reporterPrice,\n uint256 anchorPrice\n ) external view returns (bool);\n}\n"
|
|
24
|
+
},
|
|
25
|
+
"contracts/oracles/common/CorrelatedTokenOracle.sol": {
|
|
26
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { OracleInterface } from \"../../interfaces/OracleInterface.sol\";\nimport { ensureNonzeroAddress } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @title CorrelatedTokenOracle\n * @notice This oracle fetches the price of a token that is correlated to another token.\n */\nabstract contract CorrelatedTokenOracle is OracleInterface {\n /// @notice Address of the correlated token\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable CORRELATED_TOKEN;\n\n /// @notice Address of the underlying token\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable UNDERLYING_TOKEN;\n\n /// @notice Address of Resilient Oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n OracleInterface public immutable RESILIENT_ORACLE;\n\n /// @notice Thrown if the token address is invalid\n error InvalidTokenAddress();\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(address correlatedToken, address underlyingToken, address resilientOracle) {\n ensureNonzeroAddress(correlatedToken);\n ensureNonzeroAddress(underlyingToken);\n ensureNonzeroAddress(resilientOracle);\n CORRELATED_TOKEN = correlatedToken;\n UNDERLYING_TOKEN = underlyingToken;\n RESILIENT_ORACLE = OracleInterface(resilientOracle);\n }\n\n /**\n * @notice Fetches the price of the correlated token\n * @param asset Address of the correlated token\n * @return price The price of the correlated token in scaled decimal places\n */\n function getPrice(address asset) external view override returns (uint256) {\n if (asset != CORRELATED_TOKEN) revert InvalidTokenAddress();\n\n // get underlying token amount for 1 correlated token scaled by underlying token decimals\n uint256 underlyingAmount = _getUnderlyingAmount();\n\n // oracle returns (36 - asset decimal) scaled price\n uint256 underlyingUSDPrice = RESILIENT_ORACLE.getPrice(UNDERLYING_TOKEN);\n\n IERC20Metadata token = IERC20Metadata(CORRELATED_TOKEN);\n uint256 decimals = token.decimals();\n\n // underlyingAmount (for 1 correlated token) * underlyingUSDPrice / decimals(correlated token)\n return (underlyingAmount * underlyingUSDPrice) / (10 ** decimals);\n }\n\n /**\n * @notice Gets the underlying amount for correlated token\n * @return underlyingAmount Amount of underlying token\n */\n function _getUnderlyingAmount() internal view virtual returns (uint256);\n}\n"
|
|
27
|
+
},
|
|
28
|
+
"contracts/oracles/ERC4626Oracle.sol": {
|
|
29
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { IERC4626 } from \"../interfaces/IERC4626.sol\";\nimport { CorrelatedTokenOracle } from \"./common/CorrelatedTokenOracle.sol\";\nimport { EXP_SCALE } from \"@venusprotocol/solidity-utilities/contracts/constants.sol\";\n\n/**\n * @title ERC4626Oracle\n * @author Venus\n * @notice This oracle fetches the price of ERC4626 tokens\n */\ncontract ERC4626Oracle is CorrelatedTokenOracle {\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n constructor(\n address correlatedToken,\n address underlyingToken,\n address resilientOracle\n ) CorrelatedTokenOracle(correlatedToken, underlyingToken, resilientOracle) {}\n\n /**\n * @notice Fetches the amount of underlying token for 1 correlated token\n * @return amount The amount of underlying token for correlated token\n */\n function _getUnderlyingAmount() internal view override returns (uint256) {\n return IERC4626(CORRELATED_TOKEN).convertToAssets(EXP_SCALE);\n }\n}\n"
|
|
30
|
+
},
|
|
31
|
+
"contracts/oracles/PendleOracle.sol": {
|
|
32
|
+
"content": "// SPDX-License-Identifier: BSD-3-Clause\npragma solidity 0.8.25;\n\nimport { IPendlePtOracle } from \"../interfaces/IPendlePtOracle.sol\";\nimport { CorrelatedTokenOracle } from \"./common/CorrelatedTokenOracle.sol\";\nimport { ensureNonzeroAddress, ensureNonzeroValue } from \"@venusprotocol/solidity-utilities/contracts/validators.sol\";\nimport { IERC20Metadata } from \"@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @title PendleOracle\n * @author Venus\n * @notice This oracle fetches the price of a pendle token\n * @dev As a base price the oracle uses either the price of the Pendle\n * market's asset (in this case PT_TO_ASSET rate should be used) or\n * the price of the Pendle market's interest bearing token (e.g. wstETH\n * for stETH; in this case PT_TO_SY rate should be used). Technically,\n * interest bearing token is different from standardized yield (SY) token,\n * but since SY is a wrapper around an interest bearing token, we can safely\n * assume the prices of the two are equal. This is not always true for asset\n * price though: using PT_TO_ASSET rate assumes that the yield token can\n * be seamlessly redeemed for the underlying asset. In reality, this might\n * not always be the case. For more details, see\n * https://docs.pendle.finance/Developers/Contracts/StandardizedYield\n */\ncontract PendleOracle is CorrelatedTokenOracle {\n /// @notice Which asset to use as a base for the returned PT\n /// price. Can be either a standardized yield token (SY), in\n /// this case PT/SY price is returned, or the Pendle\n /// market's asset directly.\n enum RateKind {\n PT_TO_ASSET,\n PT_TO_SY\n }\n\n /// @notice Address of the PT oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n IPendlePtOracle public immutable PT_ORACLE;\n\n /// @notice Whether to use PT/SY (standardized yield token) rate\n /// or PT/market asset rate\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n RateKind public immutable RATE_KIND;\n\n /// @notice Address of the market\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n address public immutable MARKET;\n\n /// @notice Twap duration for the oracle\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint32 public immutable TWAP_DURATION;\n\n /// @notice Decimals of the underlying token\n /// @dev We make an assumption that the underlying decimals will\n /// not change throughout the lifetime of the Pendle market\n /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n uint8 public immutable UNDERLYING_DECIMALS;\n\n /// @notice Thrown if the duration is invalid\n error InvalidDuration();\n\n /// @notice Constructor for the implementation contract.\n /// @custom:oz-upgrades-unsafe-allow constructor\n /// @param market Pendle market\n /// @param ptOracle Pendle oracle\n /// @param rateKind Either PT_TO_ASSET or PT_TO_SY\n /// @param ptToken Pendle PT token\n /// @param underlyingToken Underlying token, can be either the market's asset or the interest bearing token\n /// @param resilientOracle Venus Oracle to get the underlying token price from\n /// @param twapDuration TWAP duration to call Pendle oracle with\n constructor(\n address market,\n address ptOracle,\n RateKind rateKind,\n address ptToken,\n address underlyingToken,\n address resilientOracle,\n uint32 twapDuration\n ) CorrelatedTokenOracle(ptToken, underlyingToken, resilientOracle) {\n ensureNonzeroAddress(market);\n ensureNonzeroAddress(ptOracle);\n ensureNonzeroValue(twapDuration);\n\n MARKET = market;\n PT_ORACLE = IPendlePtOracle(ptOracle);\n RATE_KIND = rateKind;\n TWAP_DURATION = twapDuration;\n UNDERLYING_DECIMALS = IERC20Metadata(UNDERLYING_TOKEN).decimals();\n\n (bool increaseCardinalityRequired, , bool oldestObservationSatisfied) = PT_ORACLE.getOracleState(\n MARKET,\n TWAP_DURATION\n );\n if (increaseCardinalityRequired || !oldestObservationSatisfied) {\n revert InvalidDuration();\n }\n }\n\n /// @notice Fetches the amount of underlying token for 1 PT\n /// @return amount The amount of underlying token (either the market's asset\n /// or the yield token) for 1 PT, adjusted for decimals such that the result\n /// has the same precision as the underlying token\n function _getUnderlyingAmount() internal view override returns (uint256) {\n uint256 rate;\n if (RATE_KIND == RateKind.PT_TO_SY) {\n rate = PT_ORACLE.getPtToSyRate(MARKET, TWAP_DURATION);\n } else {\n rate = PT_ORACLE.getPtToAssetRate(MARKET, TWAP_DURATION);\n }\n return ((10 ** UNDERLYING_DECIMALS) * rate) / 1e18;\n }\n}\n"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"settings": {
|
|
36
|
+
"optimizer": {
|
|
37
|
+
"enabled": true,
|
|
38
|
+
"runs": 200,
|
|
39
|
+
"details": {
|
|
40
|
+
"yul": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"evmVersion": "paris",
|
|
44
|
+
"outputSelection": {
|
|
45
|
+
"*": {
|
|
46
|
+
"*": [
|
|
47
|
+
"storageLayout",
|
|
48
|
+
"abi",
|
|
49
|
+
"evm.bytecode",
|
|
50
|
+
"evm.deployedBytecode",
|
|
51
|
+
"evm.methodIdentifiers",
|
|
52
|
+
"metadata",
|
|
53
|
+
"devdoc",
|
|
54
|
+
"userdoc",
|
|
55
|
+
"evm.gasEstimates"
|
|
56
|
+
],
|
|
57
|
+
"": ["ast"]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"metadata": {
|
|
61
|
+
"useLiteralContent": true
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|