From 7e20a9fbc596481f06088fc120bd9076f553dd76 Mon Sep 17 00:00:00 2001 From: franz Date: Thu, 30 Jan 2025 14:38:10 +0100 Subject: [PATCH 1/4] wip --- rate-providers/woSonicRateprovider.md | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 rate-providers/woSonicRateprovider.md diff --git a/rate-providers/woSonicRateprovider.md b/rate-providers/woSonicRateprovider.md new file mode 100644 index 0000000..cd7bcac --- /dev/null +++ b/rate-providers/woSonicRateprovider.md @@ -0,0 +1,74 @@ +# Rate Provider: `ERC4626RateProvider` + +## Details +- Reviewed by: @franzns +- Checked by: +- Deployed at: + - [sonic:0xfbcee1fcaa2db776b4b575a8da3e8c93ea5eef53](https://sonicscan.org/address/0xfbcee1fcaa2db776b4b575a8da3e8c93ea5eef53#code) +- Audits: + - [Origin Eth](https://github.com/beefyfinance/beefy-audits/blob/master/2023-08-03-Beefy-Zellic-4626-Wrapper-Audit.pdf) + + +## Context +The ERC4626 Rate Provider fetches the rate of wrapped OS via the deposited into Silo v2. The rate provider was created using the ERC4626 Rateprovider factory which calls convertToAssets on the ERC4626 to expose the rate. The rate of the ERC4626 is calculated by `shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding)`. + +## Review Checklist: Bare Minimum Compatibility +Each of the items below represents an absolute requirement for the Rate Provider. If any of these is unchecked, the Rate Provider is unfit to use. + +- [x] Implements the [`IRateProvider`](https://github.com/balancer/balancer-v2-monorepo/blob/bc3b3fee6e13e01d2efe610ed8118fdb74dfc1f2/pkg/interfaces/contracts/pool-utils/IRateProvider.sol) interface. +- [x] `getRate` returns an 18-decimal fixed point number (i.e., 1 == 1e18) regardless of underlying token decimals. + +## Review Checklist: Common Findings +Each of the items below represents a common red flag found in Rate Provider contracts. + +If none of these is checked, then this might be a pretty great Rate Provider! If any of these is checked, we must thoroughly elaborate on the conditions that lead to the potential issue. Decision points are not binary; a Rate Provider can be safe despite these boxes being checked. A check simply indicates that thorough vetting is required in a specific area, and this vetting should be used to inform a holistic analysis of the Rate Provider. + +### Administrative Privileges +- [ ] The Rate Provider is upgradeable (e.g., via a proxy architecture or an `onlyOwner` function that updates the price source address). + + +- [x] Some other portion of the price pipeline is upgradeable (e.g., the token itself, an oracle, or some piece of a larger system that tracks the price). + + + +### Oracles +- [ ] Price data is provided by an off-chain source (e.g., a Chainlink oracle, a multisig, or a network of nodes). + +- [ ] Price data is expected to be volatile (e.g., because it represents an open market price instead of a (mostly) monotonically increasing price). + +### Common Manipulation Vectors +- [x] The Rate Provider is susceptible to donation attacks. + - comment: The ERC4626 wrapper calls the vaults balance for totalAssets() which is part of the `totalAssets` used in the `converToAssets` call and therefore in the `getRate` calculation. + + ```solidity + /** + * @notice Fetches the total assets held by the vault + * @dev Returns the total assets held by the vault, not only the wrapper + * @return totalAssets the total balance of assets held by the vault + */ + function totalAssets() public view virtual override returns (uint256) { + return IVault(vault).balance(); + } + ``` + The vault calculates it based on underlying balance inside the vault plus the balance inside the strategy. + ```solidity + /** + * @dev It calculates the total underlying value of {token} held by the system. + * It takes into account the vault contract balance, the strategy contract balance + * and the balance deployed in other contracts as part of the strategy. + */ + function balance() public view returns (uint) { + return want().balanceOf(address(this)) + IStrategyV7(strategy).balanceOf(); + } + ``` + + The underlying balance can be inflated by donating underlying assets to the vault. + +## Additional Findings +To save time, we do not bother pointing out low-severity/informational issues or gas optimizations (unless the gas usage is particularly egregious). Instead, we focus only on high- and medium-severity findings which materially impact the contract's functionality and could harm users. + + +## Conclusion +**Summary judgment: SAFE** + +Overall this Rate Provider should work well in pool operations with Balancer pools. From 00ba5210ebc4873b3cd0c223217ed6f22efd8590 Mon Sep 17 00:00:00 2001 From: franz Date: Thu, 30 Jan 2025 14:48:18 +0100 Subject: [PATCH 2/4] wip --- rate-providers/woSonicRateprovider.md | 32 ++++++++------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/rate-providers/woSonicRateprovider.md b/rate-providers/woSonicRateprovider.md index cd7bcac..75e49f2 100644 --- a/rate-providers/woSonicRateprovider.md +++ b/rate-providers/woSonicRateprovider.md @@ -10,7 +10,7 @@ ## Context -The ERC4626 Rate Provider fetches the rate of wrapped OS via the deposited into Silo v2. The rate provider was created using the ERC4626 Rateprovider factory which calls convertToAssets on the ERC4626 to expose the rate. The rate of the ERC4626 is calculated by `shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding)`. + The rate provider was created using the ERC4626 Rateprovider factory which calls convertToAssets on the wOS ERC4626 contract to expose the rate. The rate of the ERC4626 is calculated by `(supply == 0) ? (shares * 10**_asset.decimals()) / 10**decimals() : (shares * totalAssets()) / supply`. ## Review Checklist: Bare Minimum Compatibility Each of the items below represents an absolute requirement for the Rate Provider. If any of these is unchecked, the Rate Provider is unfit to use. @@ -26,9 +26,11 @@ If none of these is checked, then this might be a pretty great Rate Provider! If ### Administrative Privileges - [ ] The Rate Provider is upgradeable (e.g., via a proxy architecture or an `onlyOwner` function that updates the price source address). - -- [x] Some other portion of the price pipeline is upgradeable (e.g., the token itself, an oracle, or some piece of a larger system that tracks the price). - +- [x] Some other portion of the price pipeline is upgradeable (e.g., the token itself, an oracle, or some piece of a larger system that tracks the price). + - Both [woS](https://sonicscan.org/address/0x9F0dF7799f6FDAd409300080cfF680f5A23df4b1) and [oS](https://sonicscan.org/address/0xb1e25689D55734FD3ffFc939c4C3Eb52DFf8A794) are upgradable: + - admin address: [sonic:0x31a91336414d3B955E494E7d485a6B06b55FC8fB](https://sonicscan.org/address/0x31a91336414d3B955E494E7d485a6B06b55FC8fB) + - admin type: Timelock (24 hrs) / 0xaddea7933db7d83855786eb43a238111c69b00b6 + - Timelock proposer/executor: 5/8 Multisig [sonic:0xaddea7933db7d83855786eb43a238111c69b00b6](https://sonicscan.org/address/0xaddea7933db7d83855786eb43a238111c69b00b6) ### Oracles @@ -41,31 +43,15 @@ If none of these is checked, then this might be a pretty great Rate Provider! If - comment: The ERC4626 wrapper calls the vaults balance for totalAssets() which is part of the `totalAssets` used in the `converToAssets` call and therefore in the `getRate` calculation. ```solidity - /** - * @notice Fetches the total assets held by the vault - * @dev Returns the total assets held by the vault, not only the wrapper - * @return totalAssets the total balance of assets held by the vault - */ + /** @dev See {IERC4262-totalAssets} */ function totalAssets() public view virtual override returns (uint256) { - return IVault(vault).balance(); - } - ``` - The vault calculates it based on underlying balance inside the vault plus the balance inside the strategy. - ```solidity - /** - * @dev It calculates the total underlying value of {token} held by the system. - * It takes into account the vault contract balance, the strategy contract balance - * and the balance deployed in other contracts as part of the strategy. - */ - function balance() public view returns (uint) { - return want().balanceOf(address(this)) + IStrategyV7(strategy).balanceOf(); + return _asset.balanceOf(address(this)); } ``` The underlying balance can be inflated by donating underlying assets to the vault. -## Additional Findings -To save time, we do not bother pointing out low-severity/informational issues or gas optimizations (unless the gas usage is particularly egregious). Instead, we focus only on high- and medium-severity findings which materially impact the contract's functionality and could harm users. +## Additional Finding ## Conclusion From eeb5de36ae84fe356168792d1bc1b136298b4fee Mon Sep 17 00:00:00 2001 From: franz Date: Thu, 30 Jan 2025 15:02:38 +0100 Subject: [PATCH 3/4] woS review --- rate-providers/registry.json | 18 ++++++++++++++++-- rate-providers/woSonicRateprovider.md | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/rate-providers/registry.json b/rate-providers/registry.json index c29776f..4c98283 100644 --- a/rate-providers/registry.json +++ b/rate-providers/registry.json @@ -3071,7 +3071,7 @@ "warnings": [""], "factory": "0x00de97829d01815346e58372be55aefd84ca2457", "upgradeableComponents": [] - }, + }, "0x9d2d4351c1b3718d7a65ef21f54c86c665964670": { "asset": "0x87178fe8698C7eDa8aA207083C3d66aEa569aB98", "name": "Silo bSolvBTC Rateprovider", @@ -3081,6 +3081,20 @@ "factory": "0x00de97829d01815346e58372be55aefd84ca2457", "upgradeableComponents": [] }, + "0xfbcee1fcaa2db776b4b575a8da3e8c93ea5eef53": { + "asset": "0x9F0dF7799f6FDAd409300080cfF680f5A23df4b1", + "name": "Wrapped Origin Sonic Rateprovider", + "summary": "safe", + "review": "./woSonicRateprovider.md", + "warnings": [""], + "factory": "0x00de97829d01815346e58372be55aefd84ca2457", + "upgradeableComponents": [ + { + "entrypoint": "0x9F0dF7799f6FDAd409300080cfF680f5A23df4b1", + "implementationReviewed": "0xb9fa01cbd690dfd5be3d8d667c54bbdd9e41e57d" + } + ] + }, "0x9CB622FC4757386dc8e79d1cC66FC912dD4bBf57": { "asset": "0x5E362eb2c0706Bd1d134689eC75176018385430B", "name": "VaultRateOracle", @@ -3096,4 +3110,4 @@ ] } } -} \ No newline at end of file +} diff --git a/rate-providers/woSonicRateprovider.md b/rate-providers/woSonicRateprovider.md index 75e49f2..523aa4f 100644 --- a/rate-providers/woSonicRateprovider.md +++ b/rate-providers/woSonicRateprovider.md @@ -40,16 +40,16 @@ If none of these is checked, then this might be a pretty great Rate Provider! If ### Common Manipulation Vectors - [x] The Rate Provider is susceptible to donation attacks. - - comment: The ERC4626 wrapper calls the vaults balance for totalAssets() which is part of the `totalAssets` used in the `converToAssets` call and therefore in the `getRate` calculation. + - comment: The ERC4626 uses `balancerOf(address(this))` to calculate `totalAssets()` which is used in the `converToAssets` call and therefore in the `getRate` calculation. ```solidity - /** @dev See {IERC4262-totalAssets} */ + /** @dev See {IERC4626-totalAssets}. */ function totalAssets() public view virtual override returns (uint256) { return _asset.balanceOf(address(this)); } ``` - The underlying balance can be inflated by donating underlying assets to the vault. + The underlying balance can be inflated by donating underlying assets to the wrapped asset. ## Additional Finding From d1647a67226405b0b215c7ecf8296ce308391560 Mon Sep 17 00:00:00 2001 From: franz Date: Thu, 30 Jan 2025 15:04:43 +0100 Subject: [PATCH 4/4] add audits --- rate-providers/woSonicRateprovider.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rate-providers/woSonicRateprovider.md b/rate-providers/woSonicRateprovider.md index 523aa4f..c6ee6e7 100644 --- a/rate-providers/woSonicRateprovider.md +++ b/rate-providers/woSonicRateprovider.md @@ -6,7 +6,7 @@ - Deployed at: - [sonic:0xfbcee1fcaa2db776b4b575a8da3e8c93ea5eef53](https://sonicscan.org/address/0xfbcee1fcaa2db776b4b575a8da3e8c93ea5eef53#code) - Audits: - - [Origin Eth](https://github.com/beefyfinance/beefy-audits/blob/master/2023-08-03-Beefy-Zellic-4626-Wrapper-Audit.pdf) + - [Origin Eth](https://docs.originprotocol.com/security-and-risk/audits) (same code as Origin S) ## Context