@@ -5,7 +5,7 @@ import {ISolaxy} from "./interfaces/ISolaxy.sol";
5
5
import {ERC20 } from "solady/tokens/ERC20.sol " ;
6
6
import {ReentrancyGuard} from "solady/utils/ReentrancyGuard.sol " ;
7
7
import {SafeTransferLib} from "solady/utils/SafeTransferLib.sol " ;
8
- import {UD60x18,
ud60x18 }
from "@prb/[email protected] /src/UD60x18.sol " ;
8
+ import {UD60x18,
ud }
from "@prb/[email protected] /src/UD60x18.sol " ;
9
9
10
10
/**
11
11
* @title Solaxy
@@ -66,11 +66,11 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
66
66
}
67
67
68
68
function convertToShares (uint256 assets ) external view returns (uint256 shares ) {
69
- shares = ud60x18 (assets).div (ud60x18 (2 * totalSupply ()).mul (SEMI_SLOPE)).intoUint256 ();
69
+ shares = ud (assets).div (ud (2 * totalSupply ()).mul (SEMI_SLOPE)).unwrap ();
70
70
}
71
71
72
72
function convertToAssets (uint256 shares ) external view returns (uint256 assets ) {
73
- assets = ud60x18 (shares).mul (ud60x18 (2 * totalSupply ()).mul (SEMI_SLOPE)).intoUint256 ();
73
+ assets = ud (shares).mul (ud (2 * totalSupply ()).mul (SEMI_SLOPE)).unwrap ();
74
74
}
75
75
76
76
function maxWithdraw (address owner ) external view returns (uint256 maxAssets ) {
@@ -132,8 +132,8 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
132
132
* @return shares The calculated number of shares minted for the deposited assets.
133
133
*/
134
134
function previewDeposit (uint256 assets ) public view returns (uint256 shares ) {
135
- UD60x18 totalShares = ud60x18 (totalSupply ());
136
- shares = totalShares.powu (2 ). add ( ud60x18 ( assets).div (SEMI_SLOPE)) .sqrt (). sub ( totalShares).intoUint256 ();
135
+ UD60x18 totalShares = ud (totalSupply ());
136
+ shares = ( totalShares.powu (2 ) + ud ( assets).div (SEMI_SLOPE).sqrt () - totalShares).unwrap ();
137
137
}
138
138
139
139
/**
@@ -143,8 +143,8 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
143
143
* @return shares The calculated number of shares to be burned in the withdrawal.
144
144
*/
145
145
function previewWithdraw (uint256 assets ) public view returns (uint256 shares ) {
146
- UD60x18 totalShares = ud60x18 (totalSupply ());
147
- shares = totalShares. sub (totalShares.powu (2 ). sub ( ud60x18 (assets).div (SEMI_SLOPE)).sqrt ()).intoUint256 ();
146
+ UD60x18 totalShares = ud (totalSupply ());
147
+ shares = ( totalShares - (totalShares.powu (2 ) - ( ud (assets).div (SEMI_SLOPE))) .sqrt ()).unwrap ();
148
148
}
149
149
150
150
/**
@@ -156,8 +156,8 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
156
156
* @return assets The computed assets.
157
157
*/
158
158
function previewMint (uint256 shares ) public view returns (uint256 assets ) {
159
- UD60x18 totalShares = ud60x18 (totalSupply ());
160
- assets = SEMI_SLOPE.mul ((totalShares + ud60x18 (shares)).powu (2 ). sub ( totalShares.powu (2 ))). intoUint256 ();
159
+ UD60x18 totalShares = ud (totalSupply ());
160
+ assets = SEMI_SLOPE.mul ((totalShares + ud (shares)).powu (2 ) - totalShares.powu (2 )). unwrap ();
161
161
}
162
162
163
163
/**
@@ -169,8 +169,8 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
169
169
* @return assets The computed assets.
170
170
*/
171
171
function previewRedeem (uint256 shares ) public view returns (uint256 assets ) {
172
- UD60x18 totalShares = ud60x18 (totalSupply ());
173
- assets = SEMI_SLOPE.mul (totalShares.powu (2 ). sub (totalShares. sub ( ud60x18 ( shares)).powu (2 ))). intoUint256 ();
172
+ UD60x18 totalShares = ud (totalSupply ());
173
+ assets = SEMI_SLOPE.mul (totalShares.powu (2 ) - (totalShares - ud ( shares)).powu (2 )). unwrap ();
174
174
}
175
175
176
176
/**
@@ -200,10 +200,7 @@ contract Solaxy is ISolaxy, ERC20, ReentrancyGuard {
200
200
*/
201
201
function _dump (address receiver , address owner , uint256 assets , uint256 shares ) private nonReentrant {
202
202
(uint256 initialAssets , uint256 initialShares ) = (totalAssets (), totalSupply ());
203
-
204
- uint256 tip = ud60x18 (7 ).div (ud60x18 (186 )).mul (ud60x18 (assets)).div (
205
- SEMI_SLOPE.mul (ud60x18 (initialShares).sub (ud60x18 (shares)))
206
- ).intoUint256 ();
203
+ uint256 tip = ud (7 ).div (ud (186 )).mul (ud (assets)).div (SEMI_SLOPE.mul (ud (initialShares) - ud (shares))).unwrap ();
207
204
208
205
if (assets == 0 ) revert CannotBeZero ();
209
206
if (shares == 0 ) revert CannotBeZero ();
0 commit comments