@drift-labs/sdk 0.1.18-orders.1 → 0.1.18-orders.2
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/README.md +2 -1
- package/lib/accounts/bulkAccountLoader.d.ts +32 -0
- package/lib/accounts/bulkAccountLoader.js +156 -0
- package/lib/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserSubscription.js +28 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +49 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +228 -0
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +25 -0
- package/lib/accounts/pollingTokenAccountSubscriber.js +79 -0
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/accounts/pollingUserAccountSubscriber.js +133 -0
- package/lib/accounts/types.d.ts +30 -25
- package/lib/accounts/utils.d.ts +1 -0
- package/lib/accounts/utils.js +7 -0
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.d.ts → webSocketClearingHouseAccountSubscriber.d.ts} +6 -4
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.js → webSocketClearingHouseAccountSubscriber.js} +5 -4
- package/lib/accounts/{defaultUserAccountSubscriber.d.ts → webSocketUserAccountSubscriber.d.ts} +3 -1
- package/lib/accounts/{defaultUserAccountSubscriber.js → webSocketUserAccountSubscriber.js} +10 -7
- package/lib/addresses.d.ts +2 -2
- package/lib/addresses.js +4 -4
- package/lib/admin.d.ts +3 -0
- package/lib/admin.js +61 -13
- package/lib/clearingHouse.d.ts +16 -4
- package/lib/clearingHouse.js +50 -10
- package/lib/clearingHouseUser.d.ts +9 -1
- package/lib/clearingHouseUser.js +19 -5
- package/lib/config.js +1 -1
- package/lib/constants/markets.js +16 -0
- package/lib/factory/clearingHouse.d.ts +25 -0
- package/lib/factory/clearingHouse.js +64 -0
- package/lib/factory/clearingHouseUser.d.ts +19 -0
- package/lib/factory/clearingHouseUser.js +34 -0
- package/lib/idl/clearing_house.json +360 -15
- package/lib/index.d.ts +9 -4
- package/lib/index.js +14 -5
- package/lib/math/funding.js +4 -1
- package/lib/math/utils.d.ts +2 -2
- package/lib/math/utils.js +6 -3
- package/lib/orderParams.d.ts +3 -3
- package/lib/orderParams.js +23 -3
- package/lib/token/index.d.ts +3 -0
- package/lib/token/index.js +38 -0
- package/lib/types.d.ts +13 -3
- package/package.json +3 -3
- package/src/accounts/bulkAccountLoader.ts +195 -0
- package/src/accounts/bulkUserSubscription.ts +28 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +326 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +99 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +186 -0
- package/src/accounts/types.ts +35 -30
- package/src/accounts/utils.ts +3 -0
- package/src/accounts/{defaultClearingHouseAccountSubscriber.ts → webSocketClearingHouseAccountSubscriber.ts} +9 -6
- package/src/accounts/{defaultUserAccountSubscriber.ts → webSocketUserAccountSubscriber.ts} +10 -5
- package/src/addresses.ts +6 -4
- package/src/admin.ts +73 -20
- package/src/clearingHouse.ts +69 -25
- package/src/clearingHouseUser.ts +26 -6
- package/src/config.ts +1 -1
- package/src/constants/markets.ts +16 -0
- package/src/factory/clearingHouse.ts +125 -0
- package/src/factory/clearingHouseUser.ts +73 -0
- package/src/idl/clearing_house.json +360 -15
- package/src/index.ts +9 -4
- package/src/math/funding.ts +5 -1
- package/src/math/utils.ts +1 -1
- package/src/orderParams.ts +26 -3
- package/src/token/index.ts +37 -0
- package/src/types.ts +13 -3
- package/lib/accounts/defaultHistoryAccountSubscriber.d.ts +0 -28
- package/lib/accounts/defaultHistoryAccountSubscriber.js +0 -110
- package/src/accounts/defaultHistoryAccountSubscriber.ts +0 -176
|
@@ -604,13 +604,69 @@
|
|
|
604
604
|
]
|
|
605
605
|
},
|
|
606
606
|
{
|
|
607
|
-
"name": "
|
|
607
|
+
"name": "cancelOrderByUserId",
|
|
608
608
|
"accounts": [
|
|
609
609
|
{
|
|
610
610
|
"name": "state",
|
|
611
|
+
"isMut": false,
|
|
612
|
+
"isSigner": false
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"name": "orderState",
|
|
616
|
+
"isMut": false,
|
|
617
|
+
"isSigner": false
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
"name": "user",
|
|
621
|
+
"isMut": false,
|
|
622
|
+
"isSigner": false
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
"name": "authority",
|
|
626
|
+
"isMut": false,
|
|
627
|
+
"isSigner": true
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
"name": "markets",
|
|
611
631
|
"isMut": true,
|
|
612
632
|
"isSigner": false
|
|
613
633
|
},
|
|
634
|
+
{
|
|
635
|
+
"name": "userPositions",
|
|
636
|
+
"isMut": true,
|
|
637
|
+
"isSigner": false
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
"name": "userOrders",
|
|
641
|
+
"isMut": true,
|
|
642
|
+
"isSigner": false
|
|
643
|
+
},
|
|
644
|
+
{
|
|
645
|
+
"name": "fundingPaymentHistory",
|
|
646
|
+
"isMut": true,
|
|
647
|
+
"isSigner": false
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
"name": "orderHistory",
|
|
651
|
+
"isMut": true,
|
|
652
|
+
"isSigner": false
|
|
653
|
+
}
|
|
654
|
+
],
|
|
655
|
+
"args": [
|
|
656
|
+
{
|
|
657
|
+
"name": "userOrderId",
|
|
658
|
+
"type": "u8"
|
|
659
|
+
}
|
|
660
|
+
]
|
|
661
|
+
},
|
|
662
|
+
{
|
|
663
|
+
"name": "fillOrder",
|
|
664
|
+
"accounts": [
|
|
665
|
+
{
|
|
666
|
+
"name": "state",
|
|
667
|
+
"isMut": false,
|
|
668
|
+
"isSigner": false
|
|
669
|
+
},
|
|
614
670
|
{
|
|
615
671
|
"name": "orderState",
|
|
616
672
|
"isMut": false,
|
|
@@ -666,6 +722,11 @@
|
|
|
666
722
|
"isMut": true,
|
|
667
723
|
"isSigner": false
|
|
668
724
|
},
|
|
725
|
+
{
|
|
726
|
+
"name": "extendedCurveHistory",
|
|
727
|
+
"isMut": true,
|
|
728
|
+
"isSigner": false
|
|
729
|
+
},
|
|
669
730
|
{
|
|
670
731
|
"name": "oracle",
|
|
671
732
|
"isMut": false,
|
|
@@ -737,6 +798,11 @@
|
|
|
737
798
|
"isMut": true,
|
|
738
799
|
"isSigner": false
|
|
739
800
|
},
|
|
801
|
+
{
|
|
802
|
+
"name": "extendedCurveHistory",
|
|
803
|
+
"isMut": true,
|
|
804
|
+
"isSigner": false
|
|
805
|
+
},
|
|
740
806
|
{
|
|
741
807
|
"name": "oracle",
|
|
742
808
|
"isMut": false,
|
|
@@ -1043,6 +1109,78 @@
|
|
|
1043
1109
|
}
|
|
1044
1110
|
]
|
|
1045
1111
|
},
|
|
1112
|
+
{
|
|
1113
|
+
"name": "updateAmmOracleTwap",
|
|
1114
|
+
"accounts": [
|
|
1115
|
+
{
|
|
1116
|
+
"name": "state",
|
|
1117
|
+
"isMut": false,
|
|
1118
|
+
"isSigner": false
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
"name": "markets",
|
|
1122
|
+
"isMut": true,
|
|
1123
|
+
"isSigner": false
|
|
1124
|
+
},
|
|
1125
|
+
{
|
|
1126
|
+
"name": "oracle",
|
|
1127
|
+
"isMut": false,
|
|
1128
|
+
"isSigner": false
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
"name": "admin",
|
|
1132
|
+
"isMut": false,
|
|
1133
|
+
"isSigner": true
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
"name": "curveHistory",
|
|
1137
|
+
"isMut": true,
|
|
1138
|
+
"isSigner": false
|
|
1139
|
+
}
|
|
1140
|
+
],
|
|
1141
|
+
"args": [
|
|
1142
|
+
{
|
|
1143
|
+
"name": "marketIndex",
|
|
1144
|
+
"type": "u64"
|
|
1145
|
+
}
|
|
1146
|
+
]
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
"name": "resetAmmOracleTwap",
|
|
1150
|
+
"accounts": [
|
|
1151
|
+
{
|
|
1152
|
+
"name": "state",
|
|
1153
|
+
"isMut": false,
|
|
1154
|
+
"isSigner": false
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"name": "markets",
|
|
1158
|
+
"isMut": true,
|
|
1159
|
+
"isSigner": false
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
"name": "oracle",
|
|
1163
|
+
"isMut": false,
|
|
1164
|
+
"isSigner": false
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
"name": "admin",
|
|
1168
|
+
"isMut": false,
|
|
1169
|
+
"isSigner": true
|
|
1170
|
+
},
|
|
1171
|
+
{
|
|
1172
|
+
"name": "curveHistory",
|
|
1173
|
+
"isMut": true,
|
|
1174
|
+
"isSigner": false
|
|
1175
|
+
}
|
|
1176
|
+
],
|
|
1177
|
+
"args": [
|
|
1178
|
+
{
|
|
1179
|
+
"name": "marketIndex",
|
|
1180
|
+
"type": "u64"
|
|
1181
|
+
}
|
|
1182
|
+
]
|
|
1183
|
+
},
|
|
1046
1184
|
{
|
|
1047
1185
|
"name": "initializeUser",
|
|
1048
1186
|
"accounts": [
|
|
@@ -1284,6 +1422,11 @@
|
|
|
1284
1422
|
"isMut": true,
|
|
1285
1423
|
"isSigner": false
|
|
1286
1424
|
},
|
|
1425
|
+
{
|
|
1426
|
+
"name": "oracle",
|
|
1427
|
+
"isMut": false,
|
|
1428
|
+
"isSigner": false
|
|
1429
|
+
},
|
|
1287
1430
|
{
|
|
1288
1431
|
"name": "curveHistory",
|
|
1289
1432
|
"isMut": true,
|
|
@@ -1301,6 +1444,32 @@
|
|
|
1301
1444
|
}
|
|
1302
1445
|
]
|
|
1303
1446
|
},
|
|
1447
|
+
{
|
|
1448
|
+
"name": "updateCurveHistory",
|
|
1449
|
+
"accounts": [
|
|
1450
|
+
{
|
|
1451
|
+
"name": "admin",
|
|
1452
|
+
"isMut": false,
|
|
1453
|
+
"isSigner": true
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
"name": "state",
|
|
1457
|
+
"isMut": true,
|
|
1458
|
+
"isSigner": false
|
|
1459
|
+
},
|
|
1460
|
+
{
|
|
1461
|
+
"name": "extendedCurveHistory",
|
|
1462
|
+
"isMut": true,
|
|
1463
|
+
"isSigner": false
|
|
1464
|
+
},
|
|
1465
|
+
{
|
|
1466
|
+
"name": "curveHistory",
|
|
1467
|
+
"isMut": false,
|
|
1468
|
+
"isSigner": false
|
|
1469
|
+
}
|
|
1470
|
+
],
|
|
1471
|
+
"args": []
|
|
1472
|
+
},
|
|
1304
1473
|
{
|
|
1305
1474
|
"name": "updateMarginRatio",
|
|
1306
1475
|
"accounts": [
|
|
@@ -1771,7 +1940,7 @@
|
|
|
1771
1940
|
"type": "u64"
|
|
1772
1941
|
},
|
|
1773
1942
|
{
|
|
1774
|
-
"name": "
|
|
1943
|
+
"name": "curveRecords",
|
|
1775
1944
|
"type": {
|
|
1776
1945
|
"array": [
|
|
1777
1946
|
{
|
|
@@ -1784,6 +1953,29 @@
|
|
|
1784
1953
|
]
|
|
1785
1954
|
}
|
|
1786
1955
|
},
|
|
1956
|
+
{
|
|
1957
|
+
"name": "ExtendedCurveHistory",
|
|
1958
|
+
"type": {
|
|
1959
|
+
"kind": "struct",
|
|
1960
|
+
"fields": [
|
|
1961
|
+
{
|
|
1962
|
+
"name": "head",
|
|
1963
|
+
"type": "u64"
|
|
1964
|
+
},
|
|
1965
|
+
{
|
|
1966
|
+
"name": "curveRecords",
|
|
1967
|
+
"type": {
|
|
1968
|
+
"array": [
|
|
1969
|
+
{
|
|
1970
|
+
"defined": "ExtendedCurveRecord"
|
|
1971
|
+
},
|
|
1972
|
+
1024
|
|
1973
|
+
]
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
]
|
|
1977
|
+
}
|
|
1978
|
+
},
|
|
1787
1979
|
{
|
|
1788
1980
|
"name": "DepositHistory",
|
|
1789
1981
|
"type": {
|
|
@@ -1940,6 +2132,15 @@
|
|
|
1940
2132
|
{
|
|
1941
2133
|
"name": "minOrderQuoteAssetAmount",
|
|
1942
2134
|
"type": "u128"
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
"name": "padding",
|
|
2138
|
+
"type": {
|
|
2139
|
+
"array": [
|
|
2140
|
+
"u128",
|
|
2141
|
+
10
|
|
2142
|
+
]
|
|
2143
|
+
}
|
|
1943
2144
|
}
|
|
1944
2145
|
]
|
|
1945
2146
|
}
|
|
@@ -2093,6 +2294,10 @@
|
|
|
2093
2294
|
"name": "orderState",
|
|
2094
2295
|
"type": "publicKey"
|
|
2095
2296
|
},
|
|
2297
|
+
{
|
|
2298
|
+
"name": "extendedCurveHistory",
|
|
2299
|
+
"type": "publicKey"
|
|
2300
|
+
},
|
|
2096
2301
|
{
|
|
2097
2302
|
"name": "padding0",
|
|
2098
2303
|
"type": "u128"
|
|
@@ -2108,14 +2313,6 @@
|
|
|
2108
2313
|
{
|
|
2109
2314
|
"name": "padding3",
|
|
2110
2315
|
"type": "u128"
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
"name": "padding4",
|
|
2114
|
-
"type": "u128"
|
|
2115
|
-
},
|
|
2116
|
-
{
|
|
2117
|
-
"name": "padding5",
|
|
2118
|
-
"type": "u128"
|
|
2119
2316
|
}
|
|
2120
2317
|
]
|
|
2121
2318
|
}
|
|
@@ -2292,6 +2489,10 @@
|
|
|
2292
2489
|
"defined": "PositionDirection"
|
|
2293
2490
|
}
|
|
2294
2491
|
},
|
|
2492
|
+
{
|
|
2493
|
+
"name": "userOrderId",
|
|
2494
|
+
"type": "u8"
|
|
2495
|
+
},
|
|
2295
2496
|
{
|
|
2296
2497
|
"name": "quoteAssetAmount",
|
|
2297
2498
|
"type": "u128"
|
|
@@ -2335,6 +2536,22 @@
|
|
|
2335
2536
|
"type": {
|
|
2336
2537
|
"defined": "OrderParamsOptionalAccounts"
|
|
2337
2538
|
}
|
|
2539
|
+
},
|
|
2540
|
+
{
|
|
2541
|
+
"name": "positionLimit",
|
|
2542
|
+
"type": "u128"
|
|
2543
|
+
},
|
|
2544
|
+
{
|
|
2545
|
+
"name": "oraclePriceOffset",
|
|
2546
|
+
"type": "u128"
|
|
2547
|
+
},
|
|
2548
|
+
{
|
|
2549
|
+
"name": "padding0",
|
|
2550
|
+
"type": "bool"
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
"name": "padding1",
|
|
2554
|
+
"type": "bool"
|
|
2338
2555
|
}
|
|
2339
2556
|
]
|
|
2340
2557
|
}
|
|
@@ -2435,6 +2652,103 @@
|
|
|
2435
2652
|
]
|
|
2436
2653
|
}
|
|
2437
2654
|
},
|
|
2655
|
+
{
|
|
2656
|
+
"name": "ExtendedCurveRecord",
|
|
2657
|
+
"type": {
|
|
2658
|
+
"kind": "struct",
|
|
2659
|
+
"fields": [
|
|
2660
|
+
{
|
|
2661
|
+
"name": "ts",
|
|
2662
|
+
"type": "i64"
|
|
2663
|
+
},
|
|
2664
|
+
{
|
|
2665
|
+
"name": "recordId",
|
|
2666
|
+
"type": "u128"
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
"name": "marketIndex",
|
|
2670
|
+
"type": "u64"
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
"name": "pegMultiplierBefore",
|
|
2674
|
+
"type": "u128"
|
|
2675
|
+
},
|
|
2676
|
+
{
|
|
2677
|
+
"name": "baseAssetReserveBefore",
|
|
2678
|
+
"type": "u128"
|
|
2679
|
+
},
|
|
2680
|
+
{
|
|
2681
|
+
"name": "quoteAssetReserveBefore",
|
|
2682
|
+
"type": "u128"
|
|
2683
|
+
},
|
|
2684
|
+
{
|
|
2685
|
+
"name": "sqrtKBefore",
|
|
2686
|
+
"type": "u128"
|
|
2687
|
+
},
|
|
2688
|
+
{
|
|
2689
|
+
"name": "pegMultiplierAfter",
|
|
2690
|
+
"type": "u128"
|
|
2691
|
+
},
|
|
2692
|
+
{
|
|
2693
|
+
"name": "baseAssetReserveAfter",
|
|
2694
|
+
"type": "u128"
|
|
2695
|
+
},
|
|
2696
|
+
{
|
|
2697
|
+
"name": "quoteAssetReserveAfter",
|
|
2698
|
+
"type": "u128"
|
|
2699
|
+
},
|
|
2700
|
+
{
|
|
2701
|
+
"name": "sqrtKAfter",
|
|
2702
|
+
"type": "u128"
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
"name": "baseAssetAmountLong",
|
|
2706
|
+
"type": "u128"
|
|
2707
|
+
},
|
|
2708
|
+
{
|
|
2709
|
+
"name": "baseAssetAmountShort",
|
|
2710
|
+
"type": "u128"
|
|
2711
|
+
},
|
|
2712
|
+
{
|
|
2713
|
+
"name": "baseAssetAmount",
|
|
2714
|
+
"type": "i128"
|
|
2715
|
+
},
|
|
2716
|
+
{
|
|
2717
|
+
"name": "openInterest",
|
|
2718
|
+
"type": "u128"
|
|
2719
|
+
},
|
|
2720
|
+
{
|
|
2721
|
+
"name": "totalFee",
|
|
2722
|
+
"type": "u128"
|
|
2723
|
+
},
|
|
2724
|
+
{
|
|
2725
|
+
"name": "totalFeeMinusDistributions",
|
|
2726
|
+
"type": "u128"
|
|
2727
|
+
},
|
|
2728
|
+
{
|
|
2729
|
+
"name": "adjustmentCost",
|
|
2730
|
+
"type": "i128"
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
"name": "oraclePrice",
|
|
2734
|
+
"type": "i128"
|
|
2735
|
+
},
|
|
2736
|
+
{
|
|
2737
|
+
"name": "tradeRecord",
|
|
2738
|
+
"type": "u128"
|
|
2739
|
+
},
|
|
2740
|
+
{
|
|
2741
|
+
"name": "padding",
|
|
2742
|
+
"type": {
|
|
2743
|
+
"array": [
|
|
2744
|
+
"u128",
|
|
2745
|
+
5
|
|
2746
|
+
]
|
|
2747
|
+
}
|
|
2748
|
+
}
|
|
2749
|
+
]
|
|
2750
|
+
}
|
|
2751
|
+
},
|
|
2438
2752
|
{
|
|
2439
2753
|
"name": "DepositRecord",
|
|
2440
2754
|
"type": {
|
|
@@ -2783,16 +3097,16 @@
|
|
|
2783
3097
|
"type": "i64"
|
|
2784
3098
|
},
|
|
2785
3099
|
{
|
|
2786
|
-
"name": "
|
|
2787
|
-
"type": "
|
|
3100
|
+
"name": "lastOraclePrice",
|
|
3101
|
+
"type": "i128"
|
|
2788
3102
|
},
|
|
2789
3103
|
{
|
|
2790
|
-
"name": "
|
|
2791
|
-
"type": "
|
|
3104
|
+
"name": "minimumBaseAssetTradeSize",
|
|
3105
|
+
"type": "u128"
|
|
2792
3106
|
},
|
|
2793
3107
|
{
|
|
2794
3108
|
"name": "padding1",
|
|
2795
|
-
"type": "
|
|
3109
|
+
"type": "u64"
|
|
2796
3110
|
},
|
|
2797
3111
|
{
|
|
2798
3112
|
"name": "padding2",
|
|
@@ -2861,6 +3175,15 @@
|
|
|
2861
3175
|
{
|
|
2862
3176
|
"name": "fillerReward",
|
|
2863
3177
|
"type": "u128"
|
|
3178
|
+
},
|
|
3179
|
+
{
|
|
3180
|
+
"name": "padding",
|
|
3181
|
+
"type": {
|
|
3182
|
+
"array": [
|
|
3183
|
+
"u64",
|
|
3184
|
+
10
|
|
3185
|
+
]
|
|
3186
|
+
}
|
|
2864
3187
|
}
|
|
2865
3188
|
]
|
|
2866
3189
|
}
|
|
@@ -3212,6 +3535,10 @@
|
|
|
3212
3535
|
"name": "orderId",
|
|
3213
3536
|
"type": "u128"
|
|
3214
3537
|
},
|
|
3538
|
+
{
|
|
3539
|
+
"name": "userOrderId",
|
|
3540
|
+
"type": "u8"
|
|
3541
|
+
},
|
|
3215
3542
|
{
|
|
3216
3543
|
"name": "marketIndex",
|
|
3217
3544
|
"type": "u64"
|
|
@@ -3277,6 +3604,19 @@
|
|
|
3277
3604
|
{
|
|
3278
3605
|
"name": "referrer",
|
|
3279
3606
|
"type": "publicKey"
|
|
3607
|
+
},
|
|
3608
|
+
{
|
|
3609
|
+
"name": "oraclePriceOffset",
|
|
3610
|
+
"type": "i128"
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
"name": "padding",
|
|
3614
|
+
"type": {
|
|
3615
|
+
"array": [
|
|
3616
|
+
"u16",
|
|
3617
|
+
3
|
|
3618
|
+
]
|
|
3619
|
+
}
|
|
3280
3620
|
}
|
|
3281
3621
|
]
|
|
3282
3622
|
}
|
|
@@ -3715,6 +4055,11 @@
|
|
|
3715
4055
|
"code": 6054,
|
|
3716
4056
|
"name": "MarketOrderMustBeInPlaceAndFill",
|
|
3717
4057
|
"msg": "Market order must be in place and fill"
|
|
4058
|
+
},
|
|
4059
|
+
{
|
|
4060
|
+
"code": 6055,
|
|
4061
|
+
"name": "UserOrderIdAlreadyInUse",
|
|
4062
|
+
"msg": "User Order Id Already In Use"
|
|
3718
4063
|
}
|
|
3719
4064
|
]
|
|
3720
4065
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
3
|
export * from './mockUSDCFaucet';
|
|
3
4
|
export * from './pythClient';
|
|
4
5
|
export * from './types';
|
|
5
6
|
export * from './constants/markets';
|
|
6
|
-
export * from './accounts/
|
|
7
|
-
export * from './accounts/
|
|
7
|
+
export * from './accounts/webSocketClearingHouseAccountSubscriber';
|
|
8
|
+
export * from './accounts/bulkAccountLoader';
|
|
9
|
+
export * from './accounts/pollingClearingHouseAccountSubscriber';
|
|
10
|
+
export * from './accounts/pollingTokenAccountSubscriber';
|
|
8
11
|
export * from './accounts/types';
|
|
9
12
|
export * from './addresses';
|
|
10
13
|
export * from './admin';
|
|
11
14
|
export * from './clearingHouseUser';
|
|
12
15
|
export * from './clearingHouse';
|
|
16
|
+
export * from './factory/clearingHouse';
|
|
17
|
+
export * from './factory/clearingHouseUser';
|
|
13
18
|
export * from './math/conversion';
|
|
14
19
|
export * from './math/funding';
|
|
15
20
|
export * from './math/insuranceFund';
|
|
@@ -27,4 +32,4 @@ export * from './config';
|
|
|
27
32
|
export * from './constants/numericConstants';
|
|
28
33
|
export * from './util/computeUnits';
|
|
29
34
|
export * from './util/tps';
|
|
30
|
-
export { BN };
|
|
35
|
+
export { BN, PublicKey };
|
package/lib/index.js
CHANGED
|
@@ -9,21 +9,30 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.BN = void 0;
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
+
exports.PublicKey = exports.BN = void 0;
|
|
17
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
18
|
+
exports.BN = bn_js_1.default;
|
|
19
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
20
|
+
Object.defineProperty(exports, "PublicKey", { enumerable: true, get: function () { return web3_js_1.PublicKey; } });
|
|
16
21
|
__exportStar(require("./mockUSDCFaucet"), exports);
|
|
17
22
|
__exportStar(require("./pythClient"), exports);
|
|
18
23
|
__exportStar(require("./types"), exports);
|
|
19
24
|
__exportStar(require("./constants/markets"), exports);
|
|
20
|
-
__exportStar(require("./accounts/
|
|
21
|
-
__exportStar(require("./accounts/
|
|
25
|
+
__exportStar(require("./accounts/webSocketClearingHouseAccountSubscriber"), exports);
|
|
26
|
+
__exportStar(require("./accounts/bulkAccountLoader"), exports);
|
|
27
|
+
__exportStar(require("./accounts/pollingClearingHouseAccountSubscriber"), exports);
|
|
28
|
+
__exportStar(require("./accounts/pollingTokenAccountSubscriber"), exports);
|
|
22
29
|
__exportStar(require("./accounts/types"), exports);
|
|
23
30
|
__exportStar(require("./addresses"), exports);
|
|
24
31
|
__exportStar(require("./admin"), exports);
|
|
25
32
|
__exportStar(require("./clearingHouseUser"), exports);
|
|
26
33
|
__exportStar(require("./clearingHouse"), exports);
|
|
34
|
+
__exportStar(require("./factory/clearingHouse"), exports);
|
|
35
|
+
__exportStar(require("./factory/clearingHouseUser"), exports);
|
|
27
36
|
__exportStar(require("./math/conversion"), exports);
|
|
28
37
|
__exportStar(require("./math/funding"), exports);
|
|
29
38
|
__exportStar(require("./math/insuranceFund"), exports);
|
package/lib/math/funding.js
CHANGED
|
@@ -242,7 +242,10 @@ exports.calculateLongShortFundingRateAndLiveTwaps = calculateLongShortFundingRat
|
|
|
242
242
|
function calculateFundingPool(market) {
|
|
243
243
|
// todo
|
|
244
244
|
const totalFeeLB = market.amm.totalFee.div(new anchor_1.BN(2));
|
|
245
|
-
const feePool = anchor_1.BN.max(numericConstants_1.ZERO, market.amm.totalFeeMinusDistributions
|
|
245
|
+
const feePool = anchor_1.BN.max(numericConstants_1.ZERO, market.amm.totalFeeMinusDistributions
|
|
246
|
+
.sub(totalFeeLB)
|
|
247
|
+
.mul(new anchor_1.BN(2))
|
|
248
|
+
.div(new anchor_1.BN(3)));
|
|
246
249
|
return feePool;
|
|
247
250
|
}
|
|
248
251
|
exports.calculateFundingPool = calculateFundingPool;
|
package/lib/math/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const squareRootBN: (n: any, closeness?:
|
|
1
|
+
import BN from 'bn.js';
|
|
2
|
+
export declare const squareRootBN: (n: any, closeness?: BN) => any;
|
package/lib/math/utils.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.squareRootBN = void 0;
|
|
4
|
-
const bn_js_1 = require("bn.js");
|
|
5
|
-
const squareRootBN = (n, closeness = new bn_js_1.
|
|
7
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
8
|
+
const squareRootBN = (n, closeness = new bn_js_1.default(1)) => {
|
|
6
9
|
// Assuming the sqrt of n as n only
|
|
7
10
|
let x = n;
|
|
8
11
|
// The closed guess will be stored in the root
|
|
9
12
|
let root;
|
|
10
13
|
// To count the number of iterations
|
|
11
14
|
let count = 0;
|
|
12
|
-
const TWO = new bn_js_1.
|
|
15
|
+
const TWO = new bn_js_1.default(2);
|
|
13
16
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
17
|
while (count < Number.MAX_SAFE_INTEGER) {
|
|
15
18
|
count++;
|
package/lib/orderParams.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { OrderParams, OrderTriggerCondition, PositionDirection } from './types';
|
|
3
3
|
import { BN } from '@project-serum/anchor';
|
|
4
|
-
export declare function getLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean): OrderParams;
|
|
5
|
-
export declare function getStopOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean): OrderParams;
|
|
6
|
-
export declare function getStopLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean): OrderParams;
|
|
4
|
+
export declare function getLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number): OrderParams;
|
|
5
|
+
export declare function getStopOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number): OrderParams;
|
|
6
|
+
export declare function getStopLimitOrderParams(marketIndex: BN, direction: PositionDirection, baseAssetAmount: BN, price: BN, triggerPrice: BN, triggerCondition: OrderTriggerCondition, reduceOnly: boolean, discountToken?: boolean, referrer?: boolean, userOrderId?: number): OrderParams;
|
|
7
7
|
export declare function getMarketOrderParams(marketIndex: BN, direction: PositionDirection, quoteAssetAmount: BN, baseAssetAmount: BN, reduceOnly: boolean, price?: BN, discountToken?: boolean, referrer?: boolean): OrderParams;
|