@proton/wrap-constants 0.2.10 → 0.2.14
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.
- package/dist/coins.d.ts +5 -0
- package/dist/parsers/dex.d.ts +23 -0
- package/dist/wrap-constants.cjs.development.js +67 -8
- package/dist/wrap-constants.cjs.development.js.map +1 -1
- package/dist/wrap-constants.cjs.production.min.js +1 -1
- package/dist/wrap-constants.cjs.production.min.js.map +1 -1
- package/dist/wrap-constants.esm.js +68 -9
- package/dist/wrap-constants.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/coins.ts +50 -0
- package/src/math.ts +8 -8
- package/src/parsers/dex.ts +10 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
|
-
"version": "0.2.
|
|
8
|
+
"version": "0.2.14",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"typings": "dist/index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"resolutions": {
|
|
45
45
|
"typescript": "4.5"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "4a586efe8a76b054d3406b45606b80bc79ba3e40"
|
|
48
48
|
}
|
package/src/coins.ts
CHANGED
|
@@ -69,9 +69,15 @@ export interface Wallet {
|
|
|
69
69
|
network : Networks;
|
|
70
70
|
precision : number;
|
|
71
71
|
contract : string | undefined;
|
|
72
|
+
provider : string;
|
|
72
73
|
hasWithdrawMemo: boolean;
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
export enum Providers {
|
|
77
|
+
FIREBLOCKS = "fireblocks",
|
|
78
|
+
METAL = "metal"
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
export type CoinWallet = Exclude<Coin, 'wallets'> & Wallet
|
|
76
82
|
|
|
77
83
|
export const explorerLinkByChain = {
|
|
@@ -141,6 +147,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
141
147
|
network: Networks.ERC20,
|
|
142
148
|
precision: 4,
|
|
143
149
|
contract: '0xD7EFB00D12C2C13131FD319336FDF952525DA2AF',
|
|
150
|
+
provider: Providers.FIREBLOCKS,
|
|
144
151
|
hasWithdrawMemo: false
|
|
145
152
|
},
|
|
146
153
|
{
|
|
@@ -150,6 +157,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
150
157
|
network: Networks.BEP20,
|
|
151
158
|
precision: 4,
|
|
152
159
|
contract: '0x5DE3939B2F811A61D830E6F52D13B066881412AB',
|
|
160
|
+
provider: Providers.FIREBLOCKS,
|
|
153
161
|
hasWithdrawMemo: false
|
|
154
162
|
}
|
|
155
163
|
]: []),
|
|
@@ -176,6 +184,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
176
184
|
network: Networks.ERC20,
|
|
177
185
|
precision: 6,
|
|
178
186
|
contract: '0xA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48',
|
|
187
|
+
provider: Providers.FIREBLOCKS,
|
|
179
188
|
hasWithdrawMemo: false
|
|
180
189
|
},
|
|
181
190
|
{
|
|
@@ -185,6 +194,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
185
194
|
network: Networks.BEP20,
|
|
186
195
|
precision: 18,
|
|
187
196
|
contract: '0x8AC76A51CC950D9822D68B83FE1AD97B32CD580D',
|
|
197
|
+
provider: Providers.FIREBLOCKS,
|
|
188
198
|
hasWithdrawMemo: false
|
|
189
199
|
},
|
|
190
200
|
{
|
|
@@ -194,6 +204,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
194
204
|
network: Networks.XLM,
|
|
195
205
|
precision: 7,
|
|
196
206
|
contract: undefined,
|
|
207
|
+
provider: Providers.FIREBLOCKS,
|
|
197
208
|
hasWithdrawMemo: true
|
|
198
209
|
},
|
|
199
210
|
]: []),
|
|
@@ -205,6 +216,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
205
216
|
network: Networks.Ropsten,
|
|
206
217
|
precision: 6,
|
|
207
218
|
contract: '0xA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48',
|
|
219
|
+
provider: Providers.FIREBLOCKS,
|
|
208
220
|
hasWithdrawMemo: false
|
|
209
221
|
},
|
|
210
222
|
{
|
|
@@ -214,6 +226,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
214
226
|
network: Networks.XLM,
|
|
215
227
|
precision: 7,
|
|
216
228
|
contract: undefined,
|
|
229
|
+
provider: Providers.FIREBLOCKS,
|
|
217
230
|
hasWithdrawMemo: true
|
|
218
231
|
},
|
|
219
232
|
]: [])
|
|
@@ -239,6 +252,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
239
252
|
network: Networks.ERC20,
|
|
240
253
|
precision: 8,
|
|
241
254
|
contract: '0xF433089366899D83A9F26A773D59EC7ECF30355E',
|
|
255
|
+
provider: Providers.FIREBLOCKS,
|
|
242
256
|
hasWithdrawMemo: false
|
|
243
257
|
}]: [])
|
|
244
258
|
],
|
|
@@ -263,6 +277,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
263
277
|
network: Networks.AVM,
|
|
264
278
|
precision: 9,
|
|
265
279
|
contract: '',
|
|
280
|
+
provider: Providers.METAL,
|
|
266
281
|
hasWithdrawMemo: true
|
|
267
282
|
}]: [])
|
|
268
283
|
],
|
|
@@ -287,6 +302,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
287
302
|
network: Networks.Mainnet,
|
|
288
303
|
precision: 8,
|
|
289
304
|
contract: undefined,
|
|
305
|
+
provider: Providers.FIREBLOCKS,
|
|
290
306
|
hasWithdrawMemo: false
|
|
291
307
|
}]: []),
|
|
292
308
|
...(IS_TESTNET ? [{
|
|
@@ -296,6 +312,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
296
312
|
network: Networks.Testnet,
|
|
297
313
|
precision: 8,
|
|
298
314
|
contract: undefined,
|
|
315
|
+
provider: Providers.FIREBLOCKS,
|
|
299
316
|
hasWithdrawMemo: false
|
|
300
317
|
}]: [])
|
|
301
318
|
],
|
|
@@ -320,6 +337,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
320
337
|
network: Networks.Mainnet,
|
|
321
338
|
precision: 18,
|
|
322
339
|
contract: '0x0000000000000000000000000000000000000000',
|
|
340
|
+
provider: Providers.FIREBLOCKS,
|
|
323
341
|
hasWithdrawMemo: false
|
|
324
342
|
}]: []),
|
|
325
343
|
...(IS_TESTNET ? [{
|
|
@@ -329,6 +347,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
329
347
|
network: Networks.Ropsten,
|
|
330
348
|
precision: 18,
|
|
331
349
|
contract: '0x0000000000000000000000000000000000000000',
|
|
350
|
+
provider: Providers.FIREBLOCKS,
|
|
332
351
|
hasWithdrawMemo: false
|
|
333
352
|
}]: [])
|
|
334
353
|
],
|
|
@@ -367,6 +386,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
367
386
|
network: Networks.ERC20,
|
|
368
387
|
precision: 6,
|
|
369
388
|
contract: '0xDAC17F958D2EE523A2206206994597C13D831EC7',
|
|
389
|
+
provider: Providers.FIREBLOCKS,
|
|
370
390
|
hasWithdrawMemo: false
|
|
371
391
|
}]: []),
|
|
372
392
|
...(IS_MAINNET ? [{
|
|
@@ -376,6 +396,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
376
396
|
network: Networks.BEP20,
|
|
377
397
|
precision: 18,
|
|
378
398
|
contract: '0x55d398326f99059fF775485246999027B3197955',
|
|
399
|
+
provider: Providers.FIREBLOCKS,
|
|
379
400
|
hasWithdrawMemo: false
|
|
380
401
|
}]: []),
|
|
381
402
|
...(IS_TESTNET ? [{
|
|
@@ -385,6 +406,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
385
406
|
network: Networks.Ropsten,
|
|
386
407
|
precision: 6,
|
|
387
408
|
contract: '0xDAC17F958D2EE523A2206206994597C13D831EC7',
|
|
409
|
+
provider: Providers.FIREBLOCKS,
|
|
388
410
|
hasWithdrawMemo: false
|
|
389
411
|
}]: [])
|
|
390
412
|
],
|
|
@@ -409,6 +431,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
409
431
|
network: Networks.ERC20,
|
|
410
432
|
precision: 18,
|
|
411
433
|
contract: '0x0000000000085D4780B73119B644AE5ECD22B376',
|
|
434
|
+
provider: Providers.FIREBLOCKS,
|
|
412
435
|
hasWithdrawMemo: false
|
|
413
436
|
}]: [])
|
|
414
437
|
],
|
|
@@ -433,6 +456,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
433
456
|
network: Networks.ERC20,
|
|
434
457
|
precision: 18,
|
|
435
458
|
contract: '0x8E870D67F660D95D5BE530380D0EC0BD388289E1',
|
|
459
|
+
provider: Providers.FIREBLOCKS,
|
|
436
460
|
hasWithdrawMemo: false
|
|
437
461
|
}]: [])
|
|
438
462
|
],
|
|
@@ -457,6 +481,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
457
481
|
network: Networks.ERC20,
|
|
458
482
|
precision: 18,
|
|
459
483
|
contract: '0x45804880DE22913DAFE09F4980848ECE6ECBAF78',
|
|
484
|
+
provider: Providers.FIREBLOCKS,
|
|
460
485
|
hasWithdrawMemo: false
|
|
461
486
|
}]: []),
|
|
462
487
|
...(IS_TESTNET ? [{
|
|
@@ -466,6 +491,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
466
491
|
network: Networks.Ropsten,
|
|
467
492
|
precision: 18,
|
|
468
493
|
contract: '0x45804880DE22913DAFE09F4980848ECE6ECBAF78',
|
|
494
|
+
provider: Providers.FIREBLOCKS,
|
|
469
495
|
hasWithdrawMemo: false
|
|
470
496
|
}]: [])
|
|
471
497
|
],
|
|
@@ -532,6 +558,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
532
558
|
network: Networks.ERC20,
|
|
533
559
|
precision: 18,
|
|
534
560
|
contract: '0x1F9840A85D5AF5BF1D1762F925BDADDC4201F984',
|
|
561
|
+
provider: Providers.FIREBLOCKS,
|
|
535
562
|
hasWithdrawMemo: false
|
|
536
563
|
}]: []),
|
|
537
564
|
...(IS_TESTNET ? [{
|
|
@@ -541,6 +568,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
541
568
|
network: Networks.Ropsten,
|
|
542
569
|
precision: 18,
|
|
543
570
|
contract: '0x1F9840A85D5AF5BF1D1762F925BDADDC4201F984',
|
|
571
|
+
provider: Providers.FIREBLOCKS,
|
|
544
572
|
hasWithdrawMemo: false
|
|
545
573
|
}]: [])
|
|
546
574
|
],
|
|
@@ -565,6 +593,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
565
593
|
network: Networks.ERC20,
|
|
566
594
|
precision: 18,
|
|
567
595
|
contract: '0x111111111117DC0AA78B770FA6A738034120C302',
|
|
596
|
+
provider: Providers.FIREBLOCKS,
|
|
568
597
|
hasWithdrawMemo: false
|
|
569
598
|
}]: [])
|
|
570
599
|
],
|
|
@@ -589,6 +618,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
589
618
|
network: Networks.ERC20,
|
|
590
619
|
precision: 18,
|
|
591
620
|
contract: '0x514910771AF9CA656AF840DFF83E8264ECF986CA',
|
|
621
|
+
provider: Providers.FIREBLOCKS,
|
|
592
622
|
hasWithdrawMemo: false
|
|
593
623
|
}]: [])
|
|
594
624
|
],
|
|
@@ -613,6 +643,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
613
643
|
network: Networks.Mainnet,
|
|
614
644
|
precision: 8,
|
|
615
645
|
contract: undefined,
|
|
646
|
+
provider: Providers.FIREBLOCKS,
|
|
616
647
|
hasWithdrawMemo: false
|
|
617
648
|
}]: []),
|
|
618
649
|
...(IS_TESTNET ? [{
|
|
@@ -622,6 +653,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
622
653
|
network: Networks.Testnet,
|
|
623
654
|
precision: 8,
|
|
624
655
|
contract: undefined,
|
|
656
|
+
provider: Providers.FIREBLOCKS,
|
|
625
657
|
hasWithdrawMemo: false
|
|
626
658
|
}]: [])
|
|
627
659
|
],
|
|
@@ -646,6 +678,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
646
678
|
network: Networks.Mainnet,
|
|
647
679
|
precision: 8,
|
|
648
680
|
contract: undefined,
|
|
681
|
+
provider: Providers.FIREBLOCKS,
|
|
649
682
|
hasWithdrawMemo: false
|
|
650
683
|
}]: []),
|
|
651
684
|
...(IS_TESTNET ? [{
|
|
@@ -655,6 +688,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
655
688
|
network: Networks.Testnet,
|
|
656
689
|
precision: 8,
|
|
657
690
|
contract: undefined,
|
|
691
|
+
provider: Providers.FIREBLOCKS,
|
|
658
692
|
hasWithdrawMemo: false
|
|
659
693
|
}]: [])
|
|
660
694
|
],
|
|
@@ -679,6 +713,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
679
713
|
network: Networks.Mainnet,
|
|
680
714
|
precision: 7,
|
|
681
715
|
contract: undefined,
|
|
716
|
+
provider: Providers.FIREBLOCKS,
|
|
682
717
|
hasWithdrawMemo: true
|
|
683
718
|
}]: []),
|
|
684
719
|
...(IS_TESTNET ? [{
|
|
@@ -688,6 +723,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
688
723
|
network: Networks.Testnet,
|
|
689
724
|
precision: 7,
|
|
690
725
|
contract: undefined,
|
|
726
|
+
provider: Providers.FIREBLOCKS,
|
|
691
727
|
hasWithdrawMemo: true
|
|
692
728
|
}]: [])
|
|
693
729
|
],
|
|
@@ -726,6 +762,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
726
762
|
network: Networks.Mainnet,
|
|
727
763
|
precision: 10,
|
|
728
764
|
contract: undefined,
|
|
765
|
+
provider: Providers.FIREBLOCKS,
|
|
729
766
|
hasWithdrawMemo: false
|
|
730
767
|
}]: [])
|
|
731
768
|
],
|
|
@@ -750,6 +787,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
750
787
|
network: Networks.BEP20,
|
|
751
788
|
precision: 18,
|
|
752
789
|
contract: undefined,
|
|
790
|
+
provider: Providers.FIREBLOCKS,
|
|
753
791
|
hasWithdrawMemo: false
|
|
754
792
|
}]: [])
|
|
755
793
|
],
|
|
@@ -774,6 +812,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
774
812
|
network: Networks.BEP20,
|
|
775
813
|
precision: 18,
|
|
776
814
|
contract: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
|
|
815
|
+
provider: Providers.FIREBLOCKS,
|
|
777
816
|
hasWithdrawMemo: false
|
|
778
817
|
}]: [])
|
|
779
818
|
],
|
|
@@ -798,6 +837,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
798
837
|
network: Networks.Mainnet,
|
|
799
838
|
precision: 4,
|
|
800
839
|
contract: undefined,
|
|
840
|
+
provider: Providers.FIREBLOCKS,
|
|
801
841
|
hasWithdrawMemo: true
|
|
802
842
|
}]: []),
|
|
803
843
|
...(IS_TESTNET ? [{
|
|
@@ -807,6 +847,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
807
847
|
network: Networks.Testnet,
|
|
808
848
|
precision: 4,
|
|
809
849
|
contract: undefined,
|
|
850
|
+
provider: Providers.FIREBLOCKS,
|
|
810
851
|
hasWithdrawMemo: true
|
|
811
852
|
}]: [])
|
|
812
853
|
],
|
|
@@ -831,6 +872,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
831
872
|
network: Networks.Mainnet,
|
|
832
873
|
precision: 8,
|
|
833
874
|
contract: undefined,
|
|
875
|
+
provider: Providers.FIREBLOCKS,
|
|
834
876
|
hasWithdrawMemo: false
|
|
835
877
|
}]: []),
|
|
836
878
|
],
|
|
@@ -855,6 +897,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
855
897
|
network: Networks.Mainnet,
|
|
856
898
|
precision: 6,
|
|
857
899
|
contract: undefined,
|
|
900
|
+
provider: Providers.FIREBLOCKS,
|
|
858
901
|
hasWithdrawMemo: false
|
|
859
902
|
}]: [])
|
|
860
903
|
],
|
|
@@ -881,6 +924,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
881
924
|
network: Networks.Mainnet,
|
|
882
925
|
precision: 6,
|
|
883
926
|
contract: undefined,
|
|
927
|
+
provider: Providers.FIREBLOCKS,
|
|
884
928
|
hasWithdrawMemo: true
|
|
885
929
|
}]: [])
|
|
886
930
|
],
|
|
@@ -905,6 +949,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
905
949
|
network: Networks.Mainnet,
|
|
906
950
|
precision: 6,
|
|
907
951
|
contract: undefined,
|
|
952
|
+
provider: Providers.FIREBLOCKS,
|
|
908
953
|
hasWithdrawMemo: true
|
|
909
954
|
}]: [])
|
|
910
955
|
],
|
|
@@ -929,6 +974,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
929
974
|
network: Networks.Mainnet,
|
|
930
975
|
precision: 9,
|
|
931
976
|
contract: undefined,
|
|
977
|
+
provider: Providers.FIREBLOCKS,
|
|
932
978
|
hasWithdrawMemo: false
|
|
933
979
|
}]: [])
|
|
934
980
|
],
|
|
@@ -953,6 +999,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
953
999
|
network: Networks.Mainnet,
|
|
954
1000
|
precision: 6,
|
|
955
1001
|
contract: undefined,
|
|
1002
|
+
provider: Providers.FIREBLOCKS,
|
|
956
1003
|
hasWithdrawMemo: true
|
|
957
1004
|
}]: [])
|
|
958
1005
|
],
|
|
@@ -980,6 +1027,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
980
1027
|
network: Networks.Mainnet,
|
|
981
1028
|
precision: 9,
|
|
982
1029
|
contract: undefined,
|
|
1030
|
+
provider: Providers.FIREBLOCKS,
|
|
983
1031
|
hasWithdrawMemo: false
|
|
984
1032
|
}
|
|
985
1033
|
]: [])
|
|
@@ -1005,6 +1053,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
1005
1053
|
network: Networks.Mainnet,
|
|
1006
1054
|
precision: 18,
|
|
1007
1055
|
contract: '0x0000000000000000000000000000000000000000',
|
|
1056
|
+
provider: Providers.FIREBLOCKS,
|
|
1008
1057
|
hasWithdrawMemo: false
|
|
1009
1058
|
}]: [])
|
|
1010
1059
|
],
|
|
@@ -1029,6 +1078,7 @@ export const initializeCoins = (protonChain: string): {
|
|
|
1029
1078
|
network: Networks.Testnet,
|
|
1030
1079
|
precision: 8,
|
|
1031
1080
|
contract: undefined,
|
|
1081
|
+
provider: Providers.FIREBLOCKS,
|
|
1032
1082
|
hasWithdrawMemo: true
|
|
1033
1083
|
}]: [])
|
|
1034
1084
|
],
|
package/src/math.ts
CHANGED
|
@@ -12,12 +12,12 @@ import { FEE_FACTOR } from './constants'
|
|
|
12
12
|
*/
|
|
13
13
|
export const compute_transfer = (pool1: BN.Instance, pool2: BN.Instance, swap: BN.Instance, exchange_fee: number, precision: number): BN => {
|
|
14
14
|
const term1 = pool2
|
|
15
|
-
const term2over = pool1.
|
|
15
|
+
const term2over = pool1.times(pool2)
|
|
16
16
|
const term2under = pool1.plus(swap)
|
|
17
|
-
const term2 = term2over.
|
|
17
|
+
const term2 = term2over.div(term2under).integerValue(BN.ROUND_DOWN)
|
|
18
18
|
const term = term1.minus(term2)
|
|
19
|
-
const fee = new BN(exchange_fee).
|
|
20
|
-
const result = term.minus(term.
|
|
19
|
+
const fee = new BN(exchange_fee).div(FEE_FACTOR)
|
|
20
|
+
const result = term.minus(term.times(fee))
|
|
21
21
|
|
|
22
22
|
return result.integerValue(BN.ROUND_DOWN).shiftedBy(-precision)
|
|
23
23
|
}
|
|
@@ -59,7 +59,7 @@ export const compute_transfer_curve = (
|
|
|
59
59
|
i = MAX_ITERATIONS;
|
|
60
60
|
while ( x != x_prev && i--) {
|
|
61
61
|
x_prev = F(x);
|
|
62
|
-
x = +new BN(x * x + c).
|
|
62
|
+
x = +new BN(x * x + c).div(2 * x + b).toFixed(0, BN.ROUND_DOWN)
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (reserve_out <= x) {
|
|
@@ -71,7 +71,7 @@ export const compute_transfer_curve = (
|
|
|
71
71
|
|
|
72
72
|
// Fee + 1
|
|
73
73
|
// +1 covers small precision issues
|
|
74
|
-
const fee = amount_out_with_fee.
|
|
74
|
+
const fee = amount_out_with_fee.times(exchange_fee).div(FEE_FACTOR).plus(1).toFixed(0, BN.ROUND_DOWN);
|
|
75
75
|
|
|
76
76
|
// Amount out
|
|
77
77
|
const amount_out = amount_out_with_fee.minus(fee)
|
|
@@ -80,9 +80,9 @@ export const compute_transfer_curve = (
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export const compute_liquidity = (amount_lt: BN.Instance, pool: BN.Instance, lt_supply: BN.Instance, precision: number): number => {
|
|
83
|
-
const over = amount_lt.
|
|
83
|
+
const over = amount_lt.times(pool)
|
|
84
84
|
const under = lt_supply
|
|
85
|
-
const result = over.
|
|
85
|
+
const result = over.div(under).integerValue(BN.ROUND_DOWN)
|
|
86
86
|
|
|
87
87
|
return +(result.shiftedBy(-precision).toFixed(precision, BN.ROUND_DOWN))
|
|
88
88
|
}
|
package/src/parsers/dex.ts
CHANGED
|
@@ -44,6 +44,7 @@ export type OrderHistory = z.infer<typeof orderHistoryParser>
|
|
|
44
44
|
|
|
45
45
|
export const getOrderHistoryParser = z.object({
|
|
46
46
|
account: z.string(),
|
|
47
|
+
marketId: z.number().or(numTransform).optional(),
|
|
47
48
|
offset: z.number().or(numTransform).default(0),
|
|
48
49
|
limit: z.number().or(numTransform).default(100).refine(n => n <= 250, 'Max limit is 250'),
|
|
49
50
|
})
|
|
@@ -64,6 +65,15 @@ export const getDepthParser = z.object({
|
|
|
64
65
|
})
|
|
65
66
|
export type GetDepth = z.infer<typeof getDepthParser>
|
|
66
67
|
|
|
68
|
+
export const dailyParser = z.object({
|
|
69
|
+
market_id: z.number(),
|
|
70
|
+
first: z.number(),
|
|
71
|
+
last: z.number(),
|
|
72
|
+
bid: z.number(),
|
|
73
|
+
ask: z.number(),
|
|
74
|
+
})
|
|
75
|
+
export type Daily = z.infer<typeof dailyParser>
|
|
76
|
+
|
|
67
77
|
export const tradeParser = z.object({
|
|
68
78
|
block_num: z.number(),
|
|
69
79
|
block_time: z.string(),
|