Created
December 27, 2024 12:26
-
-
Save m-waqas88/521e8178e25da65cf615dfd8441a5b06 to your computer and use it in GitHub Desktop.
Autonomint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: UNLICENSED | |
pragma solidity 0.8.22; | |
import {Test, console2, console} from "forge-std/Test.sol"; | |
contract Playground { | |
function play() public view { | |
_verifyLRTYieldCalculation(); | |
} | |
function _verifyLRTYieldCalculation() private view { | |
// amount deposited by borrower as collateral | |
uint256 weETHAmount = 2000e18; | |
// CDS depositor's share in liquidation amount 30% | |
uint256 userShare = 3; | |
// user's share of deposited collateral | |
uint256 weETHAmountUserShare = weETHAmount * userShare / 10; | |
/////// weETHAmountUserShare = 600000000000000000000 | |
uint256 ethPrice1 = 3376.96e6; // ETH price at T0 | |
uint256 weEthPrice1 = 3558.37e6; // weETH price at T0 | |
uint256 exchangeRate1 = (weEthPrice1 * 1e18 / ethPrice1); // exchangeRate at T0 | |
/////// exchangeRate1 = 1053719913768596607 | |
// ETH value of collateral at T0 | |
uint256 weETHAmountInEthValue1 = weETHAmountUserShare * exchangeRate1 / 1e18; | |
/////// weETHAmountInEthValue1 = 632231948261157964200 | |
uint256 ethPrice2 = 3375.96e6; // ETH price at T1 | |
uint256 weEthPrice2 = 3557.37e6; // weETH price at T1 | |
uint256 exchangeRate2 = (weEthPrice2 * 1e18 / ethPrice2); // exchangeRate at T1 | |
/////// exchangeRate2 = 1053735826253865567 | |
// amount computed at T1 | |
uint256 weETHAmountRevertedOnNewRate = weETHAmountInEthValue1 * 1e18 / exchangeRate2; | |
// weETHAmountRevertedOnNewRate = 599990939388294959781 | |
uint256 amount = weETHAmountUserShare - ((weETHAmountInEthValue1 * 1 ether) / exchangeRate2); | |
/////// amount = 9060611705040219 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment