flash-sdk 1.0.13 → 1.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -168,7 +168,7 @@ export class PoolAccount implements Pool {
168
168
  ) : BN {
169
169
  if(isEntry){
170
170
  const current_price = this.getEntryPrice(token_price, token_ema_price, side, custody);
171
- console.log("getEntryPrice current_price:",current_price.toString())
171
+ // console.log("getEntryPrice current_price:",current_price.toString())
172
172
  // TODO:: checked USE
173
173
  let spread_i = checkedDecimalCeilMul(
174
174
  current_price,
@@ -177,7 +177,7 @@ export class PoolAccount implements Pool {
177
177
  new BN(-1 * BPS_DECIMALS),
178
178
  new BN(-1*PRICE_DECIMALS),
179
179
  );
180
- console.log("getPriceAfterSlippage spread_i:",spread_i.toString());
180
+ // console.log("getPriceAfterSlippage spread_i:",spread_i.toString());
181
181
 
182
182
  if (isVariant(side, 'long')) {
183
183
  return current_price.add(spread_i);
@@ -191,7 +191,7 @@ export class PoolAccount implements Pool {
191
191
  } else {
192
192
  // Opp in during close
193
193
  const current_price = this.getExitPrice(token_price, token_ema_price, side, custody);
194
- console.log("getExitPrice current_price:",current_price.toString())
194
+ // console.log("getExitPrice current_price:",current_price.toString())
195
195
  // TODO:: checked USE
196
196
  let spread_i = checkedDecimalCeilMul(
197
197
  current_price,
@@ -200,7 +200,7 @@ export class PoolAccount implements Pool {
200
200
  new BN(-1 * BPS_DECIMALS),
201
201
  new BN(-1*PRICE_DECIMALS),
202
202
  );
203
- console.log("spread_i:",spread_i);
203
+ // console.log("spread_i:",spread_i);
204
204
  if (isVariant(side, 'long')) {
205
205
  if (spread_i.lt(current_price) ){
206
206
  return current_price.sub(spread_i)
@@ -221,7 +221,7 @@ export class PoolAccount implements Pool {
221
221
  spread: BN,
222
222
  ) : OraclePrice {
223
223
  if (isVariant(side, 'long')) {
224
- console.log("inside long")
224
+ // console.log("inside long")
225
225
  let max_price : OraclePrice;
226
226
  if (token_price.cmp(token_ema_price)) {
227
227
  max_price = token_price;
@@ -236,14 +236,14 @@ export class PoolAccount implements Pool {
236
236
  new BN(-1 * BPS_DECIMALS),
237
237
  max_price.exponent,
238
238
  );
239
- console.log("getPrice spread_i:",spread_i.toString());
239
+ // console.log("getPrice spread_i:",spread_i.toString());
240
240
 
241
241
  return new OraclePrice({
242
242
  price : max_price.price.add(spread_i),
243
243
  exponent : max_price.exponent,
244
244
  })
245
245
  } else {
246
- console.log("inside short ")
246
+ // console.log("inside short ")
247
247
  let min_price:OraclePrice;
248
248
  if (token_price.cmp(token_ema_price) ) {
249
249
  min_price = token_ema_price;
@@ -258,7 +258,7 @@ export class PoolAccount implements Pool {
258
258
  new BN(-1 * BPS_DECIMALS),
259
259
  min_price.exponent,
260
260
  );
261
- console.log("spread_i:",spread_i.toString())
261
+ // console.log("spread_i:",spread_i.toString())
262
262
 
263
263
  let price : BN;
264
264
  if (spread_i.lt(min_price.price) ){
@@ -300,11 +300,11 @@ export class PoolAccount implements Pool {
300
300
 
301
301
 
302
302
  let exit_price = PoolAccount.getExitPrice(token_price, token_ema_price, position.side, custody);
303
- console.log("exit_price:",exit_price, exit_price?.toString())
303
+ // console.log("exit_price:",exit_price, exit_price?.toString())
304
304
 
305
305
 
306
306
  let size = token_ema_price.getTokenAmount(position.sizeUsd, custody.decimals);
307
- console.log("size:",size, size?.toString())
307
+ // console.log("size:",size, size?.toString())
308
308
 
309
309
  let exit_fee :BN;
310
310
  if (liquidation) {
@@ -312,16 +312,16 @@ export class PoolAccount implements Pool {
312
312
  } else {
313
313
  exit_fee = this.getExitFee(size, custody)
314
314
  };
315
- console.log("exit_fee:",exit_fee.toString())
315
+ // console.log("exit_fee:",exit_fee.toString())
316
316
 
317
317
  let exit_fee_usd = token_ema_price.getAssetAmountUsd(exit_fee, custody.decimals);
318
- console.log("exit_fee_usd:",exit_fee_usd.toString())
318
+ // console.log("exit_fee_usd:",exit_fee_usd.toString())
319
319
 
320
320
  let interest_usd = custody.getInterestAmountUsd(position, curtime);
321
- console.log("interest_usd:",interest_usd.toString())
321
+ // console.log("interest_usd:",interest_usd.toString())
322
322
 
323
323
  let unrealized_loss_usd = (exit_fee_usd.add(interest_usd)).add(position.unrealizedLossUsd);
324
- console.log("unrealized_loss_usd:",unrealized_loss_usd.toString())
324
+ // console.log("unrealized_loss_usd:",unrealized_loss_usd.toString())
325
325
 
326
326
  let price_diff_profit, price_diff_loss ;
327
327
  if (isVariant(position.side, 'long')) {
@@ -339,8 +339,8 @@ export class PoolAccount implements Pool {
339
339
  price_diff_profit = BN_ZERO;
340
340
  price_diff_loss = exit_price.sub(position.price);
341
341
  };
342
- console.log("1 price_diff_profit:",price_diff_profit.toString())
343
- console.log("2 price_diff_loss:",price_diff_loss.toString())
342
+ // console.log("1 price_diff_profit:",price_diff_profit.toString())
343
+ // console.log("2 price_diff_loss:",price_diff_loss.toString())
344
344
 
345
345
 
346
346
  let position_price = scaleToExponent(
@@ -348,14 +348,14 @@ export class PoolAccount implements Pool {
348
348
  new BN(-1 * PRICE_DECIMALS),
349
349
  new BN(-1 * USD_DECIMALS ),
350
350
  );
351
- console.log("position_price:",position_price.toString())
351
+ // console.log("position_price:",position_price.toString())
352
352
 
353
353
  if (price_diff_profit.gt(BN_ZERO)) {
354
354
 
355
355
  let potential_profit_usd = (position.sizeUsd.mul(price_diff_profit)).div(position_price);
356
356
 
357
357
  potential_profit_usd = potential_profit_usd.add(position.unrealizedProfitUsd);
358
- console.log("potential_profit_usd:",potential_profit_usd.toString())
358
+ // console.log("potential_profit_usd:",potential_profit_usd.toString())
359
359
 
360
360
 
361
361
  if (potential_profit_usd.gte(unrealized_loss_usd)) {
@@ -363,8 +363,8 @@ export class PoolAccount implements Pool {
363
363
  let max_profit_usd =
364
364
  min_price.getAssetAmountUsd(position.lockedAmount, custody.decimals);
365
365
 
366
- console.log("cur_profit_usd:",cur_profit_usd.toString())
367
- console.log("max_profit_usd:",max_profit_usd.toString())
366
+ // console.log("cur_profit_usd:",cur_profit_usd.toString())
367
+ // console.log("max_profit_usd:",max_profit_usd.toString())
368
368
 
369
369
  return {
370
370
  profit: BN.min(max_profit_usd, cur_profit_usd),
@@ -372,8 +372,8 @@ export class PoolAccount implements Pool {
372
372
  exitFee: exit_fee
373
373
  }
374
374
  } else {
375
- console.log(" -- unrealized_loss_usd:",unrealized_loss_usd.toString())
376
- console.log(" -- potential_profit_usd:",potential_profit_usd.toString())
375
+ // console.log(" -- unrealized_loss_usd:",unrealized_loss_usd.toString())
376
+ // console.log(" -- potential_profit_usd:",potential_profit_usd.toString())
377
377
 
378
378
  return {
379
379
  profit: BN_ZERO,
@@ -388,11 +388,11 @@ export class PoolAccount implements Pool {
388
388
  );
389
389
 
390
390
  potential_loss_usd = potential_loss_usd.add(unrealized_loss_usd);
391
- console.log("potential_loss_usd:",potential_loss_usd.toString())
391
+ // console.log("potential_loss_usd:",potential_loss_usd.toString())
392
392
 
393
393
 
394
394
  if ( potential_loss_usd.gte(position.unrealizedProfitUsd) ) {
395
- console.log("position.unrealizedProfitUsd:",position.unrealizedProfitUsd.toString())
395
+ // console.log("position.unrealizedProfitUsd:",position.unrealizedProfitUsd.toString())
396
396
 
397
397
  return {
398
398
  profit: BN_ZERO,
@@ -402,8 +402,8 @@ export class PoolAccount implements Pool {
402
402
  } else {
403
403
  let cur_profit_usd = position.unrealizedProfitUsd.sub(potential_loss_usd);
404
404
  let max_profit_usd = min_price.getAssetAmountUsd(position.lockedAmount, custody.decimals);
405
- console.log("cur_profit_usd:",cur_profit_usd.toString())
406
- console.log("max_profit_usd:",max_profit_usd.toString())
405
+ // console.log("cur_profit_usd:",cur_profit_usd.toString())
406
+ // console.log("max_profit_usd:",max_profit_usd.toString())
407
407
 
408
408
  return {
409
409
  profit: BN.min(max_profit_usd, cur_profit_usd),
@@ -31,6 +31,13 @@
31
31
  "isStable": false,
32
32
  "pythTicker" : "Crypto.SOL/USD"
33
33
  },
34
+ {
35
+ "symbol": "WSOL",
36
+ "mintKey": "So11111111111111111111111111111111111111112",
37
+ "decimals": 9,
38
+ "isStable": false,
39
+ "pythTicker" : "Crypto.SOL/USD"
40
+ },
34
41
  {
35
42
  "symbol": "BTC",
36
43
  "mintKey": "B8DYqbh57aEPRbUq7reyueY6jaYoN75js5YsiM84tFfP",
@@ -1,130 +0,0 @@
1
- export type LimitOrderCpi = {
2
- "version": "0.1.0";
3
- "name": "limit_order_cpi";
4
- "instructions": [
5
- {
6
- "name": "processMarketOrder";
7
- "accounts": [
8
- {
9
- "name": "keeper";
10
- "isMut": true;
11
- "isSigner": true;
12
- },
13
- {
14
- "name": "pdaAccount";
15
- "isMut": true;
16
- "isSigner": false;
17
- },
18
- {
19
- "name": "pdaTokenVault";
20
- "isMut": true;
21
- "isSigner": false;
22
- },
23
- {
24
- "name": "transferAuthority";
25
- "isMut": false;
26
- "isSigner": false;
27
- },
28
- {
29
- "name": "perpetuals";
30
- "isMut": false;
31
- "isSigner": false;
32
- },
33
- {
34
- "name": "pool";
35
- "isMut": true;
36
- "isSigner": false;
37
- },
38
- {
39
- "name": "position";
40
- "isMut": true;
41
- "isSigner": false;
42
- },
43
- {
44
- "name": "custody";
45
- "isMut": true;
46
- "isSigner": false;
47
- },
48
- {
49
- "name": "custodyOracleAccount";
50
- "isMut": false;
51
- "isSigner": false;
52
- },
53
- {
54
- "name": "custodyTokenAccount";
55
- "isMut": true;
56
- "isSigner": false;
57
- },
58
- {
59
- "name": "systemProgram";
60
- "isMut": false;
61
- "isSigner": false;
62
- },
63
- {
64
- "name": "tokenProgram";
65
- "isMut": false;
66
- "isSigner": false;
67
- },
68
- {
69
- "name": "flashProgram";
70
- "isMut": false;
71
- "isSigner": false;
72
- }
73
- ];
74
- "args": [
75
- {
76
- "name": "params";
77
- "type": {
78
- "defined": "OpenPositionParams";
79
- };
80
- }
81
- ];
82
- }
83
- ];
84
- "types": [
85
- {
86
- "name": "OpenPositionParams";
87
- "type": {
88
- "kind": "struct";
89
- "fields": [
90
- {
91
- "name": "price";
92
- "type": "u64";
93
- },
94
- {
95
- "name": "collateral";
96
- "type": "u64";
97
- },
98
- {
99
- "name": "size";
100
- "type": "u64";
101
- },
102
- {
103
- "name": "side";
104
- "type": {
105
- "defined": "Side";
106
- };
107
- }
108
- ];
109
- };
110
- },
111
- {
112
- "name": "Side";
113
- "type": {
114
- "kind": "enum";
115
- "variants": [
116
- {
117
- "name": "None";
118
- },
119
- {
120
- "name": "Long";
121
- },
122
- {
123
- "name": "Short";
124
- }
125
- ];
126
- };
127
- }
128
- ];
129
- };
130
- export declare const IDL: LimitOrderCpi;
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IDL = void 0;
4
- exports.IDL = {
5
- "version": "0.1.0",
6
- "name": "limit_order_cpi",
7
- "instructions": [
8
- {
9
- "name": "processMarketOrder",
10
- "accounts": [
11
- {
12
- "name": "keeper",
13
- "isMut": true,
14
- "isSigner": true
15
- },
16
- {
17
- "name": "pdaAccount",
18
- "isMut": true,
19
- "isSigner": false
20
- },
21
- {
22
- "name": "pdaTokenVault",
23
- "isMut": true,
24
- "isSigner": false
25
- },
26
- {
27
- "name": "transferAuthority",
28
- "isMut": false,
29
- "isSigner": false
30
- },
31
- {
32
- "name": "perpetuals",
33
- "isMut": false,
34
- "isSigner": false
35
- },
36
- {
37
- "name": "pool",
38
- "isMut": true,
39
- "isSigner": false
40
- },
41
- {
42
- "name": "position",
43
- "isMut": true,
44
- "isSigner": false
45
- },
46
- {
47
- "name": "custody",
48
- "isMut": true,
49
- "isSigner": false
50
- },
51
- {
52
- "name": "custodyOracleAccount",
53
- "isMut": false,
54
- "isSigner": false
55
- },
56
- {
57
- "name": "custodyTokenAccount",
58
- "isMut": true,
59
- "isSigner": false
60
- },
61
- {
62
- "name": "systemProgram",
63
- "isMut": false,
64
- "isSigner": false
65
- },
66
- {
67
- "name": "tokenProgram",
68
- "isMut": false,
69
- "isSigner": false
70
- },
71
- {
72
- "name": "flashProgram",
73
- "isMut": false,
74
- "isSigner": false
75
- }
76
- ],
77
- "args": [
78
- {
79
- "name": "params",
80
- "type": {
81
- "defined": "OpenPositionParams"
82
- }
83
- }
84
- ]
85
- }
86
- ],
87
- "types": [
88
- {
89
- "name": "OpenPositionParams",
90
- "type": {
91
- "kind": "struct",
92
- "fields": [
93
- {
94
- "name": "price",
95
- "type": "u64"
96
- },
97
- {
98
- "name": "collateral",
99
- "type": "u64"
100
- },
101
- {
102
- "name": "size",
103
- "type": "u64"
104
- },
105
- {
106
- "name": "side",
107
- "type": {
108
- "defined": "Side"
109
- }
110
- }
111
- ]
112
- }
113
- },
114
- {
115
- "name": "Side",
116
- "type": {
117
- "kind": "enum",
118
- "variants": [
119
- {
120
- "name": "None"
121
- },
122
- {
123
- "name": "Long"
124
- },
125
- {
126
- "name": "Short"
127
- }
128
- ]
129
- }
130
- }
131
- ]
132
- };