@@ -167,10 +167,12 @@ describe("RolloverVault", function () {
167167 expect ( await vault . vaultAssetBalance ( await vault . earnedAt ( 0 ) ) ) . to . eq ( 0 ) ;
168168 } ) ;
169169
170- describe ( "#getTVL " , function ( ) {
170+ describe ( "get asset value " , function ( ) {
171171 describe ( "when vault is empty" , function ( ) {
172- it ( "should return 0" , async function ( ) {
172+ it ( "should return 0 vaule " , async function ( ) {
173173 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( 0 ) ;
174+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( 0 ) ;
175+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( 0 ) ;
174176 } ) ;
175177 } ) ;
176178
@@ -181,6 +183,10 @@ describe("RolloverVault", function () {
181183 it ( "should return tvl" , async function ( ) {
182184 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
183185 } ) ;
186+ it ( "should return asset value" , async function ( ) {
187+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
188+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( 0 ) ;
189+ } ) ;
184190 } ) ;
185191
186192 describe ( "when vault has only deployed balance" , function ( ) {
@@ -199,6 +205,11 @@ describe("RolloverVault", function () {
199205 it ( "should return tvl" , async function ( ) {
200206 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
201207 } ) ;
208+ it ( "should return asset value" , async function ( ) {
209+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( 0 ) ;
210+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
211+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( 0 ) ;
212+ } ) ;
202213 } ) ;
203214
204215 describe ( "when vault has only earned balance" , function ( ) {
@@ -208,6 +219,10 @@ describe("RolloverVault", function () {
208219 it ( "should return tvl" , async function ( ) {
209220 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
210221 } ) ;
222+ it ( "should return asset value" , async function ( ) {
223+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( 0 ) ;
224+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
225+ } ) ;
211226 } ) ;
212227
213228 describe ( "when vault has many balances" , function ( ) {
@@ -220,6 +235,14 @@ describe("RolloverVault", function () {
220235 it ( "should return tvl" , async function ( ) {
221236 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "2200" ) ) ;
222237 } ) ;
238+ it ( "should return asset value" , async function ( ) {
239+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
240+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
241+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
242+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "600" ) ) ;
243+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 2 ] . address ) ) . to . eq ( toFixedPtAmt ( "1000" ) ) ;
244+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
245+ } ) ;
223246 } ) ;
224247
225248 describe ( "when vault has many balances and rebases up" , function ( ) {
@@ -233,6 +256,14 @@ describe("RolloverVault", function () {
233256 it ( "should return tvl" , async function ( ) {
234257 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "2410" ) ) ;
235258 } ) ;
259+ it ( "should return asset value" , async function ( ) {
260+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( toFixedPtAmt ( "110" ) ) ;
261+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
262+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
263+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "600" ) ) ;
264+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 2 ] . address ) ) . to . eq ( toFixedPtAmt ( "1200" ) ) ;
265+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
266+ } ) ;
236267 } ) ;
237268
238269 describe ( "when vault has many balances and rebases down" , function ( ) {
@@ -246,6 +277,14 @@ describe("RolloverVault", function () {
246277 it ( "should return tvl" , async function ( ) {
247278 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "1990" ) ) ;
248279 } ) ;
280+ it ( "should return asset value" , async function ( ) {
281+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( toFixedPtAmt ( "90" ) ) ;
282+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
283+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "200" ) ) ;
284+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "600" ) ) ;
285+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 2 ] . address ) ) . to . eq ( toFixedPtAmt ( "800" ) ) ;
286+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
287+ } ) ;
249288 } ) ;
250289
251290 describe ( "when vault has many balances and rebases down below threshold" , function ( ) {
@@ -287,6 +326,17 @@ describe("RolloverVault", function () {
287326 it ( "should return tvl" , async function ( ) {
288327 expect ( await vault . callStatic . getTVL ( ) ) . to . eq ( toFixedPtAmt ( "390" ) ) ;
289328 } ) ;
329+
330+ it ( "should return asset value" , async function ( ) {
331+ expect ( await vault . callStatic . getVaultAssetValue ( collateralToken . address ) ) . to . eq ( toFixedPtAmt ( "10" ) ) ;
332+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "100" ) ) ;
333+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "0" ) ) ;
334+ expect ( await vault . callStatic . getVaultAssetValue ( reserveTranches [ 2 ] . address ) ) . to . eq ( toFixedPtAmt ( "0" ) ) ;
335+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 0 ] . address ) ) . to . eq ( toFixedPtAmt ( "250" ) ) ;
336+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 1 ] . address ) ) . to . eq ( toFixedPtAmt ( "0" ) ) ;
337+ expect ( await vault . callStatic . getVaultAssetValue ( rolloverInTranches [ 2 ] . address ) ) . to . eq ( toFixedPtAmt ( "0" ) ) ;
338+ expect ( await vault . callStatic . getVaultAssetValue ( perp . address ) ) . to . eq ( toFixedPtAmt ( "30" ) ) ;
339+ } ) ;
290340 } ) ;
291341 } ) ;
292342
0 commit comments