1
- import { IDataStore } from ' ../storage' ;
2
- import { Wallet , BalanceSummary , CurrentState } from ' ../domain' ;
3
- import * as moment from ' moment' ;
1
+ import { IDataStore } from " ../storage" ;
2
+ import { Wallet , BalanceSummary , CurrentState } from " ../domain" ;
3
+ import * as moment from " moment" ;
4
4
5
5
export class WalletSummary {
6
6
totalBTC ;
@@ -14,9 +14,9 @@ export class WalletSummary {
14
14
}
15
15
16
16
const investments = {
17
- xbt : 500 ,
17
+ xbt : 1000 ,
18
18
eth : 0 ,
19
- btc : 500
19
+ btc : 0
20
20
} ;
21
21
22
22
const fees = {
@@ -59,9 +59,9 @@ export class WalletService {
59
59
60
60
async getCurrentWalletBalances ( ) : Promise < Wallet [ ] > {
61
61
let exchangeWallets = [
62
- await this . getWalletPerformance ( ' Luno' , ' xbt' , [ ' XBTZAR' ] ) ,
63
- await this . getWalletPerformance ( ' Bitfinex' , ' eth' , [ ' ethbtc' , ' XBTZAR' ] ) ,
64
- await this . getWalletPerformance ( ' Bitfinex' , ' btc' , [ ' XBTZAR' ] )
62
+ await this . getWalletPerformance ( " Luno" , " xbt" , [ " XBTZAR" ] ) ,
63
+ await this . getWalletPerformance ( " Bitfinex" , " eth" , [ " ethbtc" , " XBTZAR" ] ) ,
64
+ await this . getWalletPerformance ( " Bitfinex" , " btc" , [ " XBTZAR" ] )
65
65
] . filter ( wallet => wallet . baseValue > 0 ) ;
66
66
exchangeWallets . push ( await this . getOfflineWalletPerformance ( ) ) ;
67
67
return exchangeWallets ;
@@ -83,8 +83,8 @@ export class WalletService {
83
83
await this . store . getDailyRate (
84
84
pair ,
85
85
moment ( )
86
- . add ( - 1 , ' days' )
87
- . startOf ( ' day' )
86
+ . add ( - 1 , " days" )
87
+ . startOf ( " day" )
88
88
. toDate ( )
89
89
)
90
90
)
@@ -95,7 +95,7 @@ export class WalletService {
95
95
1
96
96
) ;
97
97
let openingPrice = openingPrices . reduce (
98
- ( price , rate ) => price * ( rate ? rate . close : 0 ) ,
98
+ ( price , rate ) => price * ( rate ? rate . close : 0 ) ,
99
99
1
100
100
) ;
101
101
@@ -116,19 +116,19 @@ export class WalletService {
116
116
}
117
117
118
118
async getOfflineWalletPerformance ( ) : Promise < Wallet > {
119
- let wallet = new Wallet ( ' Mycellium' , offlineWallet , ' btc' , new Date ( ) ) ;
119
+ let wallet = new Wallet ( " Mycellium" , offlineWallet , " btc" , new Date ( ) ) ;
120
120
let currentPrices = await Promise . all (
121
- [ ' XBTZAR' ] . map ( async pair => await this . store . getLatestPrice ( pair ) )
121
+ [ " XBTZAR" ] . map ( async pair => await this . store . getLatestPrice ( pair ) )
122
122
) ;
123
123
124
124
let openingPrices = await Promise . all (
125
- [ ' XBTZAR' ] . map (
125
+ [ " XBTZAR" ] . map (
126
126
async pair =>
127
127
await this . store . getDailyRate (
128
128
pair ,
129
129
moment ( )
130
- . add ( - 1 , ' days' )
131
- . startOf ( ' day' )
130
+ . add ( - 1 , " days" )
131
+ . startOf ( " day" )
132
132
. toDate ( )
133
133
)
134
134
)
@@ -139,7 +139,7 @@ export class WalletService {
139
139
1
140
140
) ;
141
141
let openingPrice = openingPrices . reduce (
142
- ( price , rate ) => price * ( rate ? rate . close : 0 ) ,
142
+ ( price , rate ) => price * ( rate ? rate . close : 0 ) ,
143
143
1
144
144
) ;
145
145
@@ -155,29 +155,30 @@ export class WalletService {
155
155
currentPrice * wallet . baseValue - walletInvestment ;
156
156
wallet . changeSinceStartPercent =
157
157
wallet . changeSinceStartRand / walletInvestment ;
158
- wallet . url = 'https://www.blocktrail.com/BTC/address/19fedXKZdPGdUavsCydbvdYZ37NhjLW7A4' ;
158
+ wallet . url =
159
+ "https://www.blocktrail.com/BTC/address/19fedXKZdPGdUavsCydbvdYZ37NhjLW7A4" ;
159
160
return wallet ;
160
161
}
161
162
162
163
async getSummary ( ) : Promise < BalanceSummary > {
163
- let btcBalanceLuno = await this . getWalletPerformance ( ' Luno' , ' xbt' , [
164
- ' XBTZAR'
164
+ let btcBalanceLuno = await this . getWalletPerformance ( " Luno" , " xbt" , [
165
+ " XBTZAR"
165
166
] ) ;
166
167
let btcBalanceBitfinex = await this . getWalletPerformance (
167
- ' Bitfinex' ,
168
- ' btc' ,
169
- [ ' XBTZAR' ]
168
+ " Bitfinex" ,
169
+ " btc" ,
170
+ [ " XBTZAR" ]
170
171
) ;
171
172
172
- let ethBalance = await this . getWalletPerformance ( ' Bitfinex' , ' eth' , [
173
- ' ethbtc' ,
174
- ' XBTZAR'
173
+ let ethBalance = await this . getWalletPerformance ( " Bitfinex" , " eth" , [
174
+ " ethbtc" ,
175
+ " XBTZAR"
175
176
] ) ;
176
177
177
178
let mycelliumBalance = await this . getOfflineWalletPerformance ( ) ;
178
179
179
- let ethbtcRate = ( await this . store . getLatestPrice ( ' ethbtc' ) ) . price ;
180
- let btczarRate = ( await this . store . getLatestPrice ( ' XBTZAR' ) ) . price ;
180
+ let ethbtcRate = ( await this . store . getLatestPrice ( " ethbtc" ) ) . price ;
181
+ let btczarRate = ( await this . store . getLatestPrice ( " XBTZAR" ) ) . price ;
181
182
let ethzarRate = ethbtcRate * btczarRate ;
182
183
183
184
let summary = new WalletSummary ( ) ;
0 commit comments