@@ -360,7 +360,7 @@ export class User {
360360 return ZERO ;
361361 }
362362 return getTokenAmount (
363- perpPosition . isolatedPositionScaledBalance ,
363+ perpPosition . isolatedPositionScaledBalance ?? ZERO , //TODO remove ? later
364364 spotMarket ,
365365 SpotBalanceType . DEPOSIT
366366 ) ;
@@ -655,7 +655,7 @@ export class User {
655655 ! pos . baseAssetAmount . eq ( ZERO ) ||
656656 ! pos . quoteAssetAmount . eq ( ZERO ) ||
657657 ! ( pos . openOrders == 0 ) ||
658- pos . isolatedPositionScaledBalance . gt ( ZERO )
658+ pos . isolatedPositionScaledBalance ? .gt ( ZERO )
659659 ) ;
660660 }
661661
@@ -1654,7 +1654,7 @@ export class User {
16541654 ) ;
16551655
16561656 const spotAssetValue = getStrictTokenValue (
1657- perpPosition . isolatedPositionScaledBalance ,
1657+ perpPosition . isolatedPositionScaledBalance ?? ZERO , //TODO remove ? later
16581658 quoteSpotMarket . decimals ,
16591659 strictOracle
16601660 ) ;
@@ -4372,7 +4372,8 @@ export class User {
43724372 if ( isIsolated ) {
43734373 // derive isolated quote deposit value, mirroring on-chain logic
43744374 let depositValue = ZERO ;
4375- if ( marketPosition . isolatedPositionScaledBalance . gt ( ZERO ) ) {
4375+ // TODO this field(isolatedPositionScaledBalance) should not be undefined in the future, remove ? later
4376+ if ( marketPosition . isolatedPositionScaledBalance ?. gt ( ZERO ) ) {
43764377 const quoteSpotMarket = this . driftClient . getSpotMarketAccount (
43774378 market . quoteSpotMarketIndex
43784379 ) ;
@@ -4386,7 +4387,7 @@ export class User {
43864387 : undefined
43874388 ) ;
43884389 const quoteTokenAmount = getTokenAmount (
4389- marketPosition . isolatedPositionScaledBalance ,
4390+ marketPosition . isolatedPositionScaledBalance ?? ZERO , //TODO remove ? later
43904391 quoteSpotMarket ,
43914392 SpotBalanceType . DEPOSIT
43924393 ) ;
0 commit comments