@@ -3,10 +3,7 @@ import {
3
3
AddysPositionsResponse ,
4
4
Borrow ,
5
5
Claimable ,
6
- Deposit ,
7
- NativeDisplay ,
8
6
Position ,
9
- PositionAsset ,
10
7
PositionsTotals ,
11
8
RainbowBorrow ,
12
9
RainbowClaimable ,
@@ -21,66 +18,58 @@ import { chainsIdByName } from '@/chains';
21
18
22
19
export const parsePosition = ( position : Position , currency : NativeCurrencyKey ) : RainbowPosition => {
23
20
let totalDeposits = '0' ;
24
- const parsedDeposits = position . deposits ?. map ( ( deposit : Deposit ) : RainbowDeposit => {
25
- deposit . underlying = deposit . underlying ?. map (
26
- ( underlying : {
27
- asset : PositionAsset ;
28
- quantity : string ;
29
- } ) : {
30
- asset : PositionAsset ;
31
- quantity : string ;
32
- native : NativeDisplay ;
33
- } => {
21
+ const parsedDeposits = position . deposits ?. map ( ( deposit ) : RainbowDeposit => {
22
+ return {
23
+ ...deposit ,
24
+ underlying : deposit . underlying ?. map ( underlying => {
34
25
const nativeDisplay = convertRawAmountToNativeDisplay (
35
26
underlying . quantity ,
36
27
underlying . asset . decimals ,
37
28
underlying . asset . price ?. value ! ,
38
29
currency
39
30
) ;
40
- totalDeposits = add ( totalDeposits , nativeDisplay . amount ) ;
31
+ if ( ! deposit . omit_from_total ) {
32
+ totalDeposits = add ( totalDeposits , nativeDisplay . amount ) ;
33
+ }
41
34
42
35
return {
43
36
...underlying ,
44
37
native : nativeDisplay ,
45
38
} ;
46
- }
47
- ) ;
48
- return deposit as RainbowDeposit ;
39
+ } ) ,
40
+ } ;
49
41
} ) ;
50
42
51
43
let totalBorrows = '0' ;
52
44
53
45
const parsedBorrows = position . borrows ?. map ( ( borrow : Borrow ) : RainbowBorrow => {
54
- borrow . underlying = borrow . underlying . map (
55
- ( underlying : {
56
- asset : PositionAsset ;
57
- quantity : string ;
58
- } ) : {
59
- asset : PositionAsset ;
60
- quantity : string ;
61
- native : NativeDisplay ;
62
- } => {
46
+ return {
47
+ ...borrow ,
48
+ underlying : borrow . underlying . map ( underlying => {
63
49
const nativeDisplay = convertRawAmountToNativeDisplay (
64
50
underlying . quantity ,
65
51
underlying . asset . decimals ,
66
52
underlying . asset . price ?. value ! ,
67
53
currency
68
54
) ;
69
- totalBorrows = add ( totalBorrows , nativeDisplay . amount ) ;
55
+ if ( ! borrow . omit_from_total ) {
56
+ totalBorrows = add ( totalBorrows , nativeDisplay . amount ) ;
57
+ }
70
58
71
59
return {
72
60
...underlying ,
73
61
native : nativeDisplay ,
74
62
} ;
75
- }
76
- ) ;
77
- return borrow as RainbowBorrow ;
63
+ } ) ,
64
+ } ;
78
65
} ) ;
79
66
80
67
let totalClaimables = '0' ;
81
68
const parsedClaimables = position . claimables ?. map ( ( claim : Claimable ) : RainbowClaimable => {
82
69
const nativeDisplay = convertRawAmountToNativeDisplay ( claim . quantity , claim . asset . decimals , claim . asset . price ?. value ! , currency ) ;
83
- totalClaimables = add ( totalClaimables , nativeDisplay . amount ) ;
70
+ if ( ! claim . omit_from_total ) {
71
+ totalClaimables = add ( totalClaimables , nativeDisplay . amount ) ;
72
+ }
84
73
return {
85
74
asset : claim . asset ,
86
75
quantity : claim . quantity ,
0 commit comments