@drift-labs/sdk 0.1.18-orders.0 → 0.1.18-orders.4
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 +31 -0
- package/lib/accounts/bulkAccountLoader.js +175 -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 +34 -25
- package/lib/accounts/utils.d.ts +1 -0
- package/lib/accounts/utils.js +7 -0
- package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -2
- package/lib/accounts/webSocketAccountSubscriber.js +43 -12
- 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 +20 -4
- package/lib/clearingHouse.js +90 -10
- package/lib/clearingHouseUser.d.ts +12 -4
- package/lib/clearingHouseUser.js +35 -25
- package/lib/config.js +1 -1
- package/lib/constants/markets.d.ts +2 -1
- package/lib/constants/markets.js +35 -14
- package/lib/constants/numericConstants.d.ts +3 -1
- package/lib/constants/numericConstants.js +15 -17
- package/lib/examples/makeTradeExample.js +1 -1
- 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 +366 -17
- package/lib/index.d.ts +9 -3
- package/lib/index.js +10 -3
- package/lib/math/conversion.d.ts +1 -1
- package/lib/math/funding.js +4 -1
- package/lib/math/insuranceFund.d.ts +2 -1
- package/lib/math/insuranceFund.js +3 -6
- package/lib/math/position.d.ts +2 -1
- package/lib/math/position.js +2 -5
- package/lib/math/utils.d.ts +2 -1
- package/lib/math/utils.js +3 -3
- package/lib/mockUSDCFaucet.d.ts +2 -1
- package/lib/orderParams.d.ts +3 -3
- package/lib/orderParams.js +28 -8
- package/lib/orders.d.ts +2 -1
- package/lib/token/index.d.ts +3 -0
- package/lib/token/index.js +38 -0
- package/lib/types.d.ts +20 -8
- package/lib/types.js +2 -2
- package/package.json +11 -3
- package/src/accounts/bulkAccountLoader.ts +215 -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 +40 -30
- package/src/accounts/utils.ts +3 -0
- package/src/accounts/webSocketAccountSubscriber.ts +67 -17
- 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 +125 -25
- package/src/clearingHouseUser.ts +28 -8
- package/src/config.ts +1 -1
- package/src/constants/markets.ts +25 -1
- package/src/constants/numericConstants.ts +2 -1
- package/src/examples/makeTradeExample.ts +4 -1
- package/src/factory/clearingHouse.ts +125 -0
- package/src/factory/clearingHouseUser.ts +73 -0
- package/src/idl/clearing_house.json +366 -17
- package/src/index.ts +9 -3
- package/src/math/conversion.ts +1 -1
- package/src/math/funding.ts +5 -1
- package/src/math/insuranceFund.ts +1 -1
- package/src/math/position.ts +1 -1
- package/src/math/utils.ts +1 -1
- package/src/mockUSDCFaucet.ts +1 -1
- package/src/orderParams.ts +30 -7
- package/src/orders.ts +1 -1
- package/src/token/index.ts +37 -0
- package/src/types.ts +17 -6
- 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"
|
|
@@ -3220,6 +3547,10 @@
|
|
|
3220
3547
|
"name": "price",
|
|
3221
3548
|
"type": "u128"
|
|
3222
3549
|
},
|
|
3550
|
+
{
|
|
3551
|
+
"name": "userBaseAssetAmount",
|
|
3552
|
+
"type": "i128"
|
|
3553
|
+
},
|
|
3223
3554
|
{
|
|
3224
3555
|
"name": "quoteAssetAmount",
|
|
3225
3556
|
"type": "u128"
|
|
@@ -3277,6 +3608,19 @@
|
|
|
3277
3608
|
{
|
|
3278
3609
|
"name": "referrer",
|
|
3279
3610
|
"type": "publicKey"
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
"name": "oraclePriceOffset",
|
|
3614
|
+
"type": "i128"
|
|
3615
|
+
},
|
|
3616
|
+
{
|
|
3617
|
+
"name": "padding",
|
|
3618
|
+
"type": {
|
|
3619
|
+
"array": [
|
|
3620
|
+
"u16",
|
|
3621
|
+
3
|
|
3622
|
+
]
|
|
3623
|
+
}
|
|
3280
3624
|
}
|
|
3281
3625
|
]
|
|
3282
3626
|
}
|
|
@@ -3394,10 +3738,10 @@
|
|
|
3394
3738
|
"name": "Limit"
|
|
3395
3739
|
},
|
|
3396
3740
|
{
|
|
3397
|
-
"name": "
|
|
3741
|
+
"name": "TriggerMarket"
|
|
3398
3742
|
},
|
|
3399
3743
|
{
|
|
3400
|
-
"name": "
|
|
3744
|
+
"name": "TriggerLimit"
|
|
3401
3745
|
}
|
|
3402
3746
|
]
|
|
3403
3747
|
}
|
|
@@ -3715,6 +4059,11 @@
|
|
|
3715
4059
|
"code": 6054,
|
|
3716
4060
|
"name": "MarketOrderMustBeInPlaceAndFill",
|
|
3717
4061
|
"msg": "Market order must be in place and fill"
|
|
4062
|
+
},
|
|
4063
|
+
{
|
|
4064
|
+
"code": 6055,
|
|
4065
|
+
"name": "UserOrderIdAlreadyInUse",
|
|
4066
|
+
"msg": "User Order Id Already In Use"
|
|
3718
4067
|
}
|
|
3719
4068
|
]
|
|
3720
4069
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { BN } from '@project-serum/anchor';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
2
3
|
|
|
3
4
|
export * from './mockUSDCFaucet';
|
|
4
5
|
export * from './pythClient';
|
|
5
6
|
export * from './types';
|
|
6
7
|
export * from './constants/markets';
|
|
7
|
-
export * from './accounts/
|
|
8
|
-
export * from './accounts/
|
|
8
|
+
export * from './accounts/webSocketClearingHouseAccountSubscriber';
|
|
9
|
+
export * from './accounts/bulkAccountLoader';
|
|
10
|
+
export * from './accounts/pollingClearingHouseAccountSubscriber';
|
|
11
|
+
export * from './accounts/pollingTokenAccountSubscriber';
|
|
9
12
|
export * from './accounts/types';
|
|
10
13
|
export * from './addresses';
|
|
11
14
|
export * from './admin';
|
|
12
15
|
export * from './clearingHouseUser';
|
|
13
16
|
export * from './clearingHouse';
|
|
17
|
+
export * from './factory/clearingHouse';
|
|
18
|
+
export * from './factory/clearingHouseUser';
|
|
14
19
|
export * from './math/conversion';
|
|
15
20
|
export * from './math/funding';
|
|
16
21
|
export * from './math/insuranceFund';
|
|
@@ -18,6 +23,7 @@ export * from './math/market';
|
|
|
18
23
|
export * from './math/position';
|
|
19
24
|
export * from './math/amm';
|
|
20
25
|
export * from './math/trade';
|
|
26
|
+
export * from './math/orders';
|
|
21
27
|
export * from './orders';
|
|
22
28
|
export * from './orderParams';
|
|
23
29
|
export * from './wallet';
|
|
@@ -28,4 +34,4 @@ export * from './constants/numericConstants';
|
|
|
28
34
|
export * from './util/computeUnits';
|
|
29
35
|
export * from './util/tps';
|
|
30
36
|
|
|
31
|
-
export { BN };
|
|
37
|
+
export { BN, PublicKey };
|
package/src/math/conversion.ts
CHANGED
package/src/math/funding.ts
CHANGED
|
@@ -120,6 +120,7 @@ export async function calculateAllEstimatedFundingRate(
|
|
|
120
120
|
.mul(periodAdjustment)
|
|
121
121
|
.div(hoursInDay)
|
|
122
122
|
.div(MARK_PRICE_PRECISION.div(QUOTE_PRECISION));
|
|
123
|
+
|
|
123
124
|
let feePoolSize = calculateFundingPool(market);
|
|
124
125
|
if (interpRateQuote.lt(new BN(0))) {
|
|
125
126
|
feePoolSize = feePoolSize.mul(new BN(-1));
|
|
@@ -289,7 +290,10 @@ export function calculateFundingPool(market: Market): BN {
|
|
|
289
290
|
const totalFeeLB = market.amm.totalFee.div(new BN(2));
|
|
290
291
|
const feePool = BN.max(
|
|
291
292
|
ZERO,
|
|
292
|
-
market.amm.totalFeeMinusDistributions
|
|
293
|
+
market.amm.totalFeeMinusDistributions
|
|
294
|
+
.sub(totalFeeLB)
|
|
295
|
+
.mul(new BN(2))
|
|
296
|
+
.div(new BN(3))
|
|
293
297
|
);
|
|
294
298
|
return feePool;
|
|
295
299
|
}
|
package/src/math/position.ts
CHANGED
package/src/math/utils.ts
CHANGED
package/src/mockUSDCFaucet.ts
CHANGED