Skip to content

Commit

Permalink
use erc4626
Browse files Browse the repository at this point in the history
  • Loading branch information
julianmrodri committed Nov 4, 2024
1 parent 2339fbe commit ffbb2a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 2 additions & 3 deletions contracts/plugins/assets/sky/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ This plugin allows `sUSDS` (Sky) holders to use their tokens as collateral in th

These `sUSDS` tokens serve as a digital record of any value accrued to a specific position. The Sky Protocol dynamically and automatically adds USDS tokens to the entire pool of USDS supplied to the module every few seconds, in accordance with the Sky Savings Rate. As a result of the tokens auto-accumulating in the pool over time, the value tends to accrue within the sUSDS being held.

Since it is ERC4626, the redeemable USDS amount can be gotten by dividing `sUSDS.totalAssets()` by `sUSDS.totalSupply()`. However, the same rate can be read out more directly by calling `sUSDS.chi()`.

Since it is ERC4626, the redeemable USDS amount can be gotten by dividing `sUSDS.totalAssets()` by `sUSDS.totalSupply()`.
`sUSDS` contract: <https://etherscan.io/address/0xdC035D45d973E3EC169d2276DDab16f1e407384F#code>

Sky Money: https://sky.money/
Expand All @@ -26,4 +25,4 @@ Sky Money: https://sky.money/

#### refPerTok {ref/tok}

`return shiftl_toFix(susds.chi(), -27);`
`return shiftl_toFix(IERC4626(address(erc20)).convertToAssets(oneShare), -refDecimals, FLOOR);`
16 changes: 3 additions & 13 deletions contracts/plugins/assets/sky/SUSDSCollateral.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// SPDX-License-Identifier: BlueOak-1.0.0
pragma solidity 0.8.19;

import "../../../libraries/Fixed.sol";
import "../AppreciatingFiatCollateral.sol";
import "./vendor/ISUsds.sol";
import "../ERC4626FiatCollateral.sol";

/**
* @title SUSDS Collateral
Expand All @@ -13,19 +11,11 @@ import "./vendor/ISUsds.sol";
* tar = USD
* UoA = USD
*/
contract SUSDSCollateral is AppreciatingFiatCollateral {
using OracleLib for AggregatorV3Interface;
using FixLib for uint192;

contract SUSDSCollateral is ERC4626FiatCollateral {
/// @param config.chainlinkFeed {UoA/ref} price of USDS in USD terms
constructor(CollateralConfig memory config, uint192 revenueHiding)
AppreciatingFiatCollateral(config, revenueHiding)
ERC4626FiatCollateral(config, revenueHiding)
{
require(config.defaultThreshold != 0, "defaultThreshold zero");
}

/// @return {ref/tok} Actual quantity of whole reference units per whole collateral tokens
function underlyingRefPerTok() public view override returns (uint192) {
return shiftl_toFix(ISUsds(address(erc20)).chi(), -27, FLOOR);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ const opts = {
collateralName: 'SUSDSCollateral',
chainlinkDefaultAnswer,
itIsPricedByPeg: true,
toleranceDivisor: bn('1e8'),
}

collateralTests(opts)

0 comments on commit ffbb2a8

Please sign in to comment.