@drift-labs/sdk 0.2.0-master.2 → 0.2.0-master.5
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/lib/accounts/types.d.ts +0 -1
- package/lib/admin.d.ts +5 -3
- package/lib/admin.js +30 -7
- package/lib/clearingHouse.d.ts +8 -11
- package/lib/clearingHouse.js +49 -75
- package/lib/config.js +1 -1
- package/lib/idl/clearing_house.json +171 -36
- package/lib/index.d.ts +2 -1
- package/lib/index.js +6 -1
- package/lib/math/amm.js +7 -35
- package/lib/math/auction.js +4 -1
- package/lib/math/orders.d.ts +2 -2
- package/lib/math/orders.js +18 -11
- package/lib/math/position.js +3 -1
- package/lib/math/trade.d.ts +1 -1
- package/lib/math/trade.js +7 -10
- package/lib/orderParams.d.ts +14 -5
- package/lib/orderParams.js +8 -96
- package/lib/orders.js +1 -9
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +70 -1
- package/lib/types.js +41 -1
- package/package.json +3 -3
- package/src/admin.ts +47 -8
- package/src/clearingHouse.ts +79 -151
- package/src/config.ts +1 -1
- package/src/idl/clearing_house.json +171 -36
- package/src/index.ts +2 -1
- package/src/math/amm.ts +19 -49
- package/src/math/auction.ts +5 -1
- package/src/math/orders.ts +17 -13
- package/src/math/position.ts +5 -1
- package/src/math/trade.ts +23 -25
- package/src/orderParams.ts +20 -141
- package/src/orders.ts +1 -8
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +65 -2
package/src/clearingHouse.ts
CHANGED
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
BankAccount,
|
|
12
12
|
UserBankBalance,
|
|
13
13
|
MakerInfo,
|
|
14
|
+
TakerInfo,
|
|
15
|
+
OptionalOrderParams,
|
|
16
|
+
DefaultOrderParams,
|
|
17
|
+
OrderType,
|
|
14
18
|
} from './types';
|
|
15
19
|
import * as anchor from '@project-serum/anchor';
|
|
16
20
|
import clearingHouseIDL from './idl/clearing_house.json';
|
|
@@ -52,7 +56,6 @@ import { WebSocketClearingHouseAccountSubscriber } from './accounts/webSocketCle
|
|
|
52
56
|
import { RetryTxSender } from './tx/retryTxSender';
|
|
53
57
|
import { ClearingHouseUser } from './clearingHouseUser';
|
|
54
58
|
import { ClearingHouseUserAccountSubscriptionConfig } from './clearingHouseUserConfig';
|
|
55
|
-
import { getMarketOrderParams } from './orderParams';
|
|
56
59
|
import { getMarketsBanksAndOraclesForSubscription } from './config';
|
|
57
60
|
|
|
58
61
|
/**
|
|
@@ -798,20 +801,17 @@ export class ClearingHouse {
|
|
|
798
801
|
marketIndex: BN,
|
|
799
802
|
limitPrice?: BN
|
|
800
803
|
): Promise<TransactionSignature> {
|
|
801
|
-
return await this.placeAndTake(
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
limitPrice
|
|
809
|
-
)
|
|
810
|
-
);
|
|
804
|
+
return await this.placeAndTake({
|
|
805
|
+
orderType: OrderType.MARKET,
|
|
806
|
+
marketIndex,
|
|
807
|
+
direction,
|
|
808
|
+
baseAssetAmount: amount,
|
|
809
|
+
price: limitPrice,
|
|
810
|
+
});
|
|
811
811
|
}
|
|
812
812
|
|
|
813
813
|
public async placeOrder(
|
|
814
|
-
orderParams:
|
|
814
|
+
orderParams: OptionalOrderParams
|
|
815
815
|
): Promise<TransactionSignature> {
|
|
816
816
|
const { txSig, slot } = await this.txSender.send(
|
|
817
817
|
wrapInTx(await this.getPlaceOrderIx(orderParams)),
|
|
@@ -822,14 +822,16 @@ export class ClearingHouse {
|
|
|
822
822
|
return txSig;
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
+
getOrderParams(optionalOrderParams: OptionalOrderParams): OrderParams {
|
|
826
|
+
return Object.assign({}, DefaultOrderParams, optionalOrderParams);
|
|
827
|
+
}
|
|
828
|
+
|
|
825
829
|
public async getPlaceOrderIx(
|
|
826
|
-
orderParams:
|
|
830
|
+
orderParams: OptionalOrderParams
|
|
827
831
|
): Promise<TransactionInstruction> {
|
|
832
|
+
orderParams = this.getOrderParams(orderParams);
|
|
828
833
|
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
829
834
|
|
|
830
|
-
const priceOracle = this.getMarketAccount(orderParams.marketIndex).amm
|
|
831
|
-
.oracle;
|
|
832
|
-
|
|
833
835
|
const remainingAccounts = this.getRemainingAccounts({
|
|
834
836
|
writableMarketIndex: orderParams.marketIndex,
|
|
835
837
|
});
|
|
@@ -839,38 +841,11 @@ export class ClearingHouse {
|
|
|
839
841
|
state: await this.getStatePublicKey(),
|
|
840
842
|
user: userAccountPublicKey,
|
|
841
843
|
authority: this.wallet.publicKey,
|
|
842
|
-
oracle: priceOracle,
|
|
843
844
|
},
|
|
844
845
|
remainingAccounts,
|
|
845
846
|
});
|
|
846
847
|
}
|
|
847
848
|
|
|
848
|
-
public async expireOrders(
|
|
849
|
-
userAccountPublicKey: PublicKey
|
|
850
|
-
): Promise<TransactionSignature> {
|
|
851
|
-
const { txSig } = await this.txSender.send(
|
|
852
|
-
wrapInTx(await this.getExpireOrdersIx(userAccountPublicKey)),
|
|
853
|
-
[],
|
|
854
|
-
this.opts
|
|
855
|
-
);
|
|
856
|
-
return txSig;
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
public async getExpireOrdersIx(
|
|
860
|
-
userAccountPublicKey: PublicKey
|
|
861
|
-
): Promise<TransactionInstruction> {
|
|
862
|
-
const fillerPublicKey = await this.getUserAccountPublicKey();
|
|
863
|
-
|
|
864
|
-
return await this.program.instruction.expireOrders({
|
|
865
|
-
accounts: {
|
|
866
|
-
state: await this.getStatePublicKey(),
|
|
867
|
-
filler: fillerPublicKey,
|
|
868
|
-
user: userAccountPublicKey,
|
|
869
|
-
authority: this.wallet.publicKey,
|
|
870
|
-
},
|
|
871
|
-
});
|
|
872
|
-
}
|
|
873
|
-
|
|
874
849
|
public async updateAMMs(marketIndexes: BN[]): Promise<TransactionSignature> {
|
|
875
850
|
const { txSig } = await this.txSender.send(
|
|
876
851
|
wrapInTx(await this.getUpdateAMMsIx(marketIndexes)),
|
|
@@ -970,95 +945,6 @@ export class ClearingHouse {
|
|
|
970
945
|
});
|
|
971
946
|
}
|
|
972
947
|
|
|
973
|
-
public async cancelAllOrders(
|
|
974
|
-
bestEffort?: boolean
|
|
975
|
-
): Promise<TransactionSignature> {
|
|
976
|
-
const { txSig } = await this.txSender.send(
|
|
977
|
-
wrapInTx(await this.getCancelAllOrdersIx(bestEffort)),
|
|
978
|
-
[],
|
|
979
|
-
this.opts
|
|
980
|
-
);
|
|
981
|
-
return txSig;
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
public async getCancelAllOrdersIx(
|
|
985
|
-
bestEffort?: boolean
|
|
986
|
-
): Promise<TransactionInstruction> {
|
|
987
|
-
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
988
|
-
|
|
989
|
-
const remainingAccounts = this.getRemainingAccounts({});
|
|
990
|
-
|
|
991
|
-
for (const order of this.getUserAccount().orders) {
|
|
992
|
-
const oracle = this.getMarketAccount(order.marketIndex).amm.oracle;
|
|
993
|
-
remainingAccounts.push({
|
|
994
|
-
pubkey: oracle,
|
|
995
|
-
isWritable: false,
|
|
996
|
-
isSigner: false,
|
|
997
|
-
});
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
return await this.program.instruction.cancelAllOrders(bestEffort, {
|
|
1001
|
-
accounts: {
|
|
1002
|
-
state: await this.getStatePublicKey(),
|
|
1003
|
-
user: userAccountPublicKey,
|
|
1004
|
-
authority: this.wallet.publicKey,
|
|
1005
|
-
},
|
|
1006
|
-
remainingAccounts,
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
public async cancelOrdersByMarketAndSide(
|
|
1011
|
-
bestEffort?: boolean,
|
|
1012
|
-
marketIndexOnly?: BN,
|
|
1013
|
-
directionOnly?: PositionDirection
|
|
1014
|
-
): Promise<TransactionSignature> {
|
|
1015
|
-
const { txSig } = await this.txSender.send(
|
|
1016
|
-
wrapInTx(
|
|
1017
|
-
await this.getCancelOrdersByMarketAndSideIx(
|
|
1018
|
-
bestEffort,
|
|
1019
|
-
marketIndexOnly,
|
|
1020
|
-
directionOnly
|
|
1021
|
-
)
|
|
1022
|
-
),
|
|
1023
|
-
[],
|
|
1024
|
-
this.opts
|
|
1025
|
-
);
|
|
1026
|
-
return txSig;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
public async getCancelOrdersByMarketAndSideIx(
|
|
1030
|
-
bestEffort?: boolean,
|
|
1031
|
-
marketIndexOnly?: BN,
|
|
1032
|
-
directionOnly?: PositionDirection
|
|
1033
|
-
): Promise<TransactionInstruction> {
|
|
1034
|
-
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
1035
|
-
|
|
1036
|
-
const remainingAccounts = this.getRemainingAccounts({});
|
|
1037
|
-
|
|
1038
|
-
for (const order of this.getUserAccount().orders) {
|
|
1039
|
-
const oracle = this.getMarketAccount(order.marketIndex).amm.oracle;
|
|
1040
|
-
remainingAccounts.push({
|
|
1041
|
-
pubkey: oracle,
|
|
1042
|
-
isWritable: false,
|
|
1043
|
-
isSigner: false,
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
|
|
1047
|
-
return await this.program.instruction.cancelOrdersByMarketAndSide(
|
|
1048
|
-
bestEffort,
|
|
1049
|
-
marketIndexOnly,
|
|
1050
|
-
directionOnly,
|
|
1051
|
-
{
|
|
1052
|
-
accounts: {
|
|
1053
|
-
state: await this.getStatePublicKey(),
|
|
1054
|
-
user: userAccountPublicKey,
|
|
1055
|
-
authority: this.wallet.publicKey,
|
|
1056
|
-
},
|
|
1057
|
-
remainingAccounts,
|
|
1058
|
-
}
|
|
1059
|
-
);
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
948
|
public async fillOrder(
|
|
1063
949
|
userAccountPublicKey: PublicKey,
|
|
1064
950
|
user: UserAccount,
|
|
@@ -1085,7 +971,6 @@ export class ClearingHouse {
|
|
|
1085
971
|
|
|
1086
972
|
const marketIndex = order.marketIndex;
|
|
1087
973
|
const marketAccount = this.getMarketAccount(marketIndex);
|
|
1088
|
-
const oracle = marketAccount.amm.oracle;
|
|
1089
974
|
|
|
1090
975
|
const bankAccountInfos = [
|
|
1091
976
|
{
|
|
@@ -1116,7 +1001,7 @@ export class ClearingHouse {
|
|
|
1116
1001
|
const market = this.getMarketAccount(position.marketIndex);
|
|
1117
1002
|
marketAccountInfos.push({
|
|
1118
1003
|
pubkey: market.pubkey,
|
|
1119
|
-
isWritable:
|
|
1004
|
+
isWritable: true,
|
|
1120
1005
|
isSigner: false,
|
|
1121
1006
|
});
|
|
1122
1007
|
oracleAccountInfos.push({
|
|
@@ -1140,13 +1025,13 @@ export class ClearingHouse {
|
|
|
1140
1025
|
|
|
1141
1026
|
const orderId = order.orderId;
|
|
1142
1027
|
const makerOrderId = makerInfo ? makerInfo.order.orderId : null;
|
|
1028
|
+
|
|
1143
1029
|
return await this.program.instruction.fillOrder(orderId, makerOrderId, {
|
|
1144
1030
|
accounts: {
|
|
1145
1031
|
state: await this.getStatePublicKey(),
|
|
1146
1032
|
filler: fillerPublicKey,
|
|
1147
1033
|
user: userAccountPublicKey,
|
|
1148
1034
|
authority: this.wallet.publicKey,
|
|
1149
|
-
oracle: oracle,
|
|
1150
1035
|
},
|
|
1151
1036
|
remainingAccounts,
|
|
1152
1037
|
});
|
|
@@ -1231,7 +1116,7 @@ export class ClearingHouse {
|
|
|
1231
1116
|
}
|
|
1232
1117
|
|
|
1233
1118
|
public async placeAndTake(
|
|
1234
|
-
orderParams:
|
|
1119
|
+
orderParams: OptionalOrderParams,
|
|
1235
1120
|
makerInfo?: MakerInfo
|
|
1236
1121
|
): Promise<TransactionSignature> {
|
|
1237
1122
|
const { txSig, slot } = await this.txSender.send(
|
|
@@ -1244,14 +1129,12 @@ export class ClearingHouse {
|
|
|
1244
1129
|
}
|
|
1245
1130
|
|
|
1246
1131
|
public async getPlaceAndTakeIx(
|
|
1247
|
-
orderParams:
|
|
1132
|
+
orderParams: OptionalOrderParams,
|
|
1248
1133
|
makerInfo?: MakerInfo
|
|
1249
1134
|
): Promise<TransactionInstruction> {
|
|
1135
|
+
orderParams = this.getOrderParams(orderParams);
|
|
1250
1136
|
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
1251
1137
|
|
|
1252
|
-
const priceOracle = this.getMarketAccount(orderParams.marketIndex).amm
|
|
1253
|
-
.oracle;
|
|
1254
|
-
|
|
1255
1138
|
const remainingAccounts = this.getRemainingAccounts({
|
|
1256
1139
|
writableMarketIndex: orderParams.marketIndex,
|
|
1257
1140
|
writableBankIndex: QUOTE_ASSET_BANK_INDEX,
|
|
@@ -1275,7 +1158,55 @@ export class ClearingHouse {
|
|
|
1275
1158
|
state: await this.getStatePublicKey(),
|
|
1276
1159
|
user: userAccountPublicKey,
|
|
1277
1160
|
authority: this.wallet.publicKey,
|
|
1278
|
-
|
|
1161
|
+
},
|
|
1162
|
+
remainingAccounts,
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
public async placeAndMake(
|
|
1168
|
+
orderParams: OptionalOrderParams,
|
|
1169
|
+
takerInfo: TakerInfo,
|
|
1170
|
+
): Promise<TransactionSignature> {
|
|
1171
|
+
const { txSig, slot } = await this.txSender.send(
|
|
1172
|
+
wrapInTx(await this.getPlaceAndMakeIx(orderParams, takerInfo)),
|
|
1173
|
+
[],
|
|
1174
|
+
this.opts
|
|
1175
|
+
);
|
|
1176
|
+
|
|
1177
|
+
this.marketLastSlotCache.set(orderParams.marketIndex.toNumber(), slot);
|
|
1178
|
+
|
|
1179
|
+
return txSig;
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
public async getPlaceAndMakeIx(
|
|
1183
|
+
orderParams: OptionalOrderParams,
|
|
1184
|
+
takerInfo: TakerInfo,
|
|
1185
|
+
): Promise<TransactionInstruction> {
|
|
1186
|
+
orderParams = this.getOrderParams(orderParams);
|
|
1187
|
+
const userAccountPublicKey = await this.getUserAccountPublicKey();
|
|
1188
|
+
|
|
1189
|
+
const remainingAccounts = this.getRemainingAccounts({
|
|
1190
|
+
writableMarketIndex: orderParams.marketIndex,
|
|
1191
|
+
writableBankIndex: QUOTE_ASSET_BANK_INDEX,
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
const takerOrderId = takerInfo!.order!.orderId;
|
|
1195
|
+
remainingAccounts.push({
|
|
1196
|
+
pubkey: takerInfo.taker,
|
|
1197
|
+
isSigner: false,
|
|
1198
|
+
isWritable: true,
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
return await this.program.instruction.placeAndMake(
|
|
1202
|
+
orderParams,
|
|
1203
|
+
takerOrderId,
|
|
1204
|
+
{
|
|
1205
|
+
accounts: {
|
|
1206
|
+
state: await this.getStatePublicKey(),
|
|
1207
|
+
user: userAccountPublicKey,
|
|
1208
|
+
taker: takerInfo.taker,
|
|
1209
|
+
authority: this.wallet.publicKey,
|
|
1279
1210
|
},
|
|
1280
1211
|
remainingAccounts,
|
|
1281
1212
|
}
|
|
@@ -1293,16 +1224,13 @@ export class ClearingHouse {
|
|
|
1293
1224
|
throw Error(`No position in market ${marketIndex.toString()}`);
|
|
1294
1225
|
}
|
|
1295
1226
|
|
|
1296
|
-
return await this.placeAndTake(
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
undefined
|
|
1304
|
-
)
|
|
1305
|
-
);
|
|
1227
|
+
return await this.placeAndTake({
|
|
1228
|
+
orderType: OrderType.MARKET,
|
|
1229
|
+
marketIndex,
|
|
1230
|
+
direction: findDirectionToClose(userPosition),
|
|
1231
|
+
baseAssetAmount: userPosition.baseAssetAmount,
|
|
1232
|
+
reduceOnly: true,
|
|
1233
|
+
});
|
|
1306
1234
|
}
|
|
1307
1235
|
|
|
1308
1236
|
public async settlePNLs(
|
package/src/config.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const configs: { [key in DriftEnv]: DriftConfig } = {
|
|
|
28
28
|
devnet: {
|
|
29
29
|
ENV: 'devnet',
|
|
30
30
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
31
|
-
CLEARING_HOUSE_PROGRAM_ID: '
|
|
31
|
+
CLEARING_HOUSE_PROGRAM_ID: 'BMow898PH56jD8z4EaqxicoGXkR1HhN17qrER6Uc4AYq',
|
|
32
32
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
33
33
|
MARKETS: DevnetMarkets,
|
|
34
34
|
BANKS: DevnetBanks,
|
|
@@ -141,6 +141,10 @@
|
|
|
141
141
|
{
|
|
142
142
|
"name": "maintenanceLiabilityWeight",
|
|
143
143
|
"type": "u128"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"name": "imfFactor",
|
|
147
|
+
"type": "u128"
|
|
144
148
|
}
|
|
145
149
|
]
|
|
146
150
|
},
|
|
@@ -381,11 +385,6 @@
|
|
|
381
385
|
"name": "authority",
|
|
382
386
|
"isMut": false,
|
|
383
387
|
"isSigner": true
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
"name": "oracle",
|
|
387
|
-
"isMut": false,
|
|
388
|
-
"isSigner": false
|
|
389
388
|
}
|
|
390
389
|
],
|
|
391
390
|
"args": [
|
|
@@ -473,11 +472,6 @@
|
|
|
473
472
|
"name": "user",
|
|
474
473
|
"isMut": true,
|
|
475
474
|
"isSigner": false
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
"name": "oracle",
|
|
479
|
-
"isMut": false,
|
|
480
|
-
"isSigner": false
|
|
481
475
|
}
|
|
482
476
|
],
|
|
483
477
|
"args": [
|
|
@@ -512,11 +506,6 @@
|
|
|
512
506
|
"name": "authority",
|
|
513
507
|
"isMut": false,
|
|
514
508
|
"isSigner": true
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
"name": "oracle",
|
|
518
|
-
"isMut": false,
|
|
519
|
-
"isSigner": false
|
|
520
509
|
}
|
|
521
510
|
],
|
|
522
511
|
"args": [
|
|
@@ -549,18 +538,13 @@
|
|
|
549
538
|
},
|
|
550
539
|
{
|
|
551
540
|
"name": "taker",
|
|
552
|
-
"isMut":
|
|
541
|
+
"isMut": true,
|
|
553
542
|
"isSigner": false
|
|
554
543
|
},
|
|
555
544
|
{
|
|
556
545
|
"name": "authority",
|
|
557
546
|
"isMut": false,
|
|
558
547
|
"isSigner": true
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
"name": "oracle",
|
|
562
|
-
"isMut": false,
|
|
563
|
-
"isSigner": false
|
|
564
548
|
}
|
|
565
549
|
],
|
|
566
550
|
"args": [
|
|
@@ -736,7 +720,7 @@
|
|
|
736
720
|
]
|
|
737
721
|
},
|
|
738
722
|
{
|
|
739
|
-
"name": "
|
|
723
|
+
"name": "withdrawFromMarketToInsuranceVault",
|
|
740
724
|
"accounts": [
|
|
741
725
|
{
|
|
742
726
|
"name": "state",
|
|
@@ -750,7 +734,7 @@
|
|
|
750
734
|
},
|
|
751
735
|
{
|
|
752
736
|
"name": "bank",
|
|
753
|
-
"isMut":
|
|
737
|
+
"isMut": true,
|
|
754
738
|
"isSigner": false
|
|
755
739
|
},
|
|
756
740
|
{
|
|
@@ -855,6 +839,11 @@
|
|
|
855
839
|
"isMut": false,
|
|
856
840
|
"isSigner": false
|
|
857
841
|
},
|
|
842
|
+
{
|
|
843
|
+
"name": "bank",
|
|
844
|
+
"isMut": true,
|
|
845
|
+
"isSigner": false
|
|
846
|
+
},
|
|
858
847
|
{
|
|
859
848
|
"name": "bankVault",
|
|
860
849
|
"isMut": true,
|
|
@@ -1113,6 +1102,62 @@
|
|
|
1113
1102
|
}
|
|
1114
1103
|
]
|
|
1115
1104
|
},
|
|
1105
|
+
{
|
|
1106
|
+
"name": "updateMarketImfFactor",
|
|
1107
|
+
"accounts": [
|
|
1108
|
+
{
|
|
1109
|
+
"name": "admin",
|
|
1110
|
+
"isMut": false,
|
|
1111
|
+
"isSigner": true
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
"name": "state",
|
|
1115
|
+
"isMut": false,
|
|
1116
|
+
"isSigner": false
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
"name": "market",
|
|
1120
|
+
"isMut": true,
|
|
1121
|
+
"isSigner": false
|
|
1122
|
+
}
|
|
1123
|
+
],
|
|
1124
|
+
"args": [
|
|
1125
|
+
{
|
|
1126
|
+
"name": "imfFactor",
|
|
1127
|
+
"type": "u128"
|
|
1128
|
+
}
|
|
1129
|
+
]
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
"name": "updateMarketUnsettledAssetWeight",
|
|
1133
|
+
"accounts": [
|
|
1134
|
+
{
|
|
1135
|
+
"name": "admin",
|
|
1136
|
+
"isMut": false,
|
|
1137
|
+
"isSigner": true
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
"name": "state",
|
|
1141
|
+
"isMut": false,
|
|
1142
|
+
"isSigner": false
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
"name": "market",
|
|
1146
|
+
"isMut": true,
|
|
1147
|
+
"isSigner": false
|
|
1148
|
+
}
|
|
1149
|
+
],
|
|
1150
|
+
"args": [
|
|
1151
|
+
{
|
|
1152
|
+
"name": "unsettledInitialAssetWeight",
|
|
1153
|
+
"type": "u8"
|
|
1154
|
+
},
|
|
1155
|
+
{
|
|
1156
|
+
"name": "unsettledMaintenanceAssetWeight",
|
|
1157
|
+
"type": "u8"
|
|
1158
|
+
}
|
|
1159
|
+
]
|
|
1160
|
+
},
|
|
1116
1161
|
{
|
|
1117
1162
|
"name": "updateCurveUpdateIntensity",
|
|
1118
1163
|
"accounts": [
|
|
@@ -1461,6 +1506,58 @@
|
|
|
1461
1506
|
}
|
|
1462
1507
|
]
|
|
1463
1508
|
},
|
|
1509
|
+
{
|
|
1510
|
+
"name": "updateMarketMaxSlippageRatio",
|
|
1511
|
+
"accounts": [
|
|
1512
|
+
{
|
|
1513
|
+
"name": "admin",
|
|
1514
|
+
"isMut": false,
|
|
1515
|
+
"isSigner": true
|
|
1516
|
+
},
|
|
1517
|
+
{
|
|
1518
|
+
"name": "state",
|
|
1519
|
+
"isMut": false,
|
|
1520
|
+
"isSigner": false
|
|
1521
|
+
},
|
|
1522
|
+
{
|
|
1523
|
+
"name": "market",
|
|
1524
|
+
"isMut": true,
|
|
1525
|
+
"isSigner": false
|
|
1526
|
+
}
|
|
1527
|
+
],
|
|
1528
|
+
"args": [
|
|
1529
|
+
{
|
|
1530
|
+
"name": "maxSlippageRatio",
|
|
1531
|
+
"type": "u16"
|
|
1532
|
+
}
|
|
1533
|
+
]
|
|
1534
|
+
},
|
|
1535
|
+
{
|
|
1536
|
+
"name": "updateMaxBaseAssetAmountRatio",
|
|
1537
|
+
"accounts": [
|
|
1538
|
+
{
|
|
1539
|
+
"name": "admin",
|
|
1540
|
+
"isMut": false,
|
|
1541
|
+
"isSigner": true
|
|
1542
|
+
},
|
|
1543
|
+
{
|
|
1544
|
+
"name": "state",
|
|
1545
|
+
"isMut": false,
|
|
1546
|
+
"isSigner": false
|
|
1547
|
+
},
|
|
1548
|
+
{
|
|
1549
|
+
"name": "market",
|
|
1550
|
+
"isMut": true,
|
|
1551
|
+
"isSigner": false
|
|
1552
|
+
}
|
|
1553
|
+
],
|
|
1554
|
+
"args": [
|
|
1555
|
+
{
|
|
1556
|
+
"name": "maxBaseAssetAmountRatio",
|
|
1557
|
+
"type": "u16"
|
|
1558
|
+
}
|
|
1559
|
+
]
|
|
1560
|
+
},
|
|
1464
1561
|
{
|
|
1465
1562
|
"name": "updateAdmin",
|
|
1466
1563
|
"accounts": [
|
|
@@ -1583,7 +1680,7 @@
|
|
|
1583
1680
|
]
|
|
1584
1681
|
},
|
|
1585
1682
|
{
|
|
1586
|
-
"name": "
|
|
1683
|
+
"name": "updateAuctionDuration",
|
|
1587
1684
|
"accounts": [
|
|
1588
1685
|
{
|
|
1589
1686
|
"name": "admin",
|
|
@@ -1598,7 +1695,11 @@
|
|
|
1598
1695
|
],
|
|
1599
1696
|
"args": [
|
|
1600
1697
|
{
|
|
1601
|
-
"name": "
|
|
1698
|
+
"name": "minAuctionDuration",
|
|
1699
|
+
"type": "u8"
|
|
1700
|
+
},
|
|
1701
|
+
{
|
|
1702
|
+
"name": "maxAuctionDuration",
|
|
1602
1703
|
"type": "u8"
|
|
1603
1704
|
}
|
|
1604
1705
|
]
|
|
@@ -1695,6 +1796,10 @@
|
|
|
1695
1796
|
{
|
|
1696
1797
|
"name": "maintenanceLiabilityWeight",
|
|
1697
1798
|
"type": "u128"
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
"name": "imfFactor",
|
|
1802
|
+
"type": "u128"
|
|
1698
1803
|
}
|
|
1699
1804
|
]
|
|
1700
1805
|
}
|
|
@@ -1772,6 +1877,22 @@
|
|
|
1772
1877
|
"name": "unsettledLoss",
|
|
1773
1878
|
"type": "u128"
|
|
1774
1879
|
},
|
|
1880
|
+
{
|
|
1881
|
+
"name": "imfFactor",
|
|
1882
|
+
"type": "u128"
|
|
1883
|
+
},
|
|
1884
|
+
{
|
|
1885
|
+
"name": "unsettledInitialAssetWeight",
|
|
1886
|
+
"type": "u8"
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
"name": "unsettledMaintenanceAssetWeight",
|
|
1890
|
+
"type": "u8"
|
|
1891
|
+
},
|
|
1892
|
+
{
|
|
1893
|
+
"name": "unsettledImfFactor",
|
|
1894
|
+
"type": "u128"
|
|
1895
|
+
},
|
|
1775
1896
|
{
|
|
1776
1897
|
"name": "padding0",
|
|
1777
1898
|
"type": "u32"
|
|
@@ -1905,7 +2026,11 @@
|
|
|
1905
2026
|
"type": "u128"
|
|
1906
2027
|
},
|
|
1907
2028
|
{
|
|
1908
|
-
"name": "
|
|
2029
|
+
"name": "minAuctionDuration",
|
|
2030
|
+
"type": "u8"
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
"name": "maxAuctionDuration",
|
|
1909
2034
|
"type": "u8"
|
|
1910
2035
|
},
|
|
1911
2036
|
{
|
|
@@ -2010,10 +2135,6 @@
|
|
|
2010
2135
|
"name": "userOrderId",
|
|
2011
2136
|
"type": "u8"
|
|
2012
2137
|
},
|
|
2013
|
-
{
|
|
2014
|
-
"name": "quoteAssetAmount",
|
|
2015
|
-
"type": "u128"
|
|
2016
|
-
},
|
|
2017
2138
|
{
|
|
2018
2139
|
"name": "baseAssetAmount",
|
|
2019
2140
|
"type": "u128"
|
|
@@ -2062,6 +2183,10 @@
|
|
|
2062
2183
|
"name": "oraclePriceOffset",
|
|
2063
2184
|
"type": "i128"
|
|
2064
2185
|
},
|
|
2186
|
+
{
|
|
2187
|
+
"name": "auctionDuration",
|
|
2188
|
+
"type": "u8"
|
|
2189
|
+
},
|
|
2065
2190
|
{
|
|
2066
2191
|
"name": "padding0",
|
|
2067
2192
|
"type": "bool"
|
|
@@ -2224,6 +2349,14 @@
|
|
|
2224
2349
|
"name": "minimumQuoteAssetTradeSize",
|
|
2225
2350
|
"type": "u128"
|
|
2226
2351
|
},
|
|
2352
|
+
{
|
|
2353
|
+
"name": "maxBaseAssetAmountRatio",
|
|
2354
|
+
"type": "u16"
|
|
2355
|
+
},
|
|
2356
|
+
{
|
|
2357
|
+
"name": "maxSlippageRatio",
|
|
2358
|
+
"type": "u16"
|
|
2359
|
+
},
|
|
2227
2360
|
{
|
|
2228
2361
|
"name": "baseAssetAmountStepSize",
|
|
2229
2362
|
"type": "u128"
|
|
@@ -2708,10 +2841,6 @@
|
|
|
2708
2841
|
"defined": "PositionDirection"
|
|
2709
2842
|
}
|
|
2710
2843
|
},
|
|
2711
|
-
{
|
|
2712
|
-
"name": "quoteAssetAmount",
|
|
2713
|
-
"type": "u128"
|
|
2714
|
-
},
|
|
2715
2844
|
{
|
|
2716
2845
|
"name": "baseAssetAmount",
|
|
2717
2846
|
"type": "u128"
|
|
@@ -2924,6 +3053,12 @@
|
|
|
2924
3053
|
},
|
|
2925
3054
|
{
|
|
2926
3055
|
"name": "OraclePriceBreachedLimitPrice"
|
|
3056
|
+
},
|
|
3057
|
+
{
|
|
3058
|
+
"name": "MarketOrderFilledToLimitPrice"
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
"name": "MarketOrderAuctionExpired"
|
|
2927
3062
|
}
|
|
2928
3063
|
]
|
|
2929
3064
|
}
|
|
@@ -3711,8 +3846,8 @@
|
|
|
3711
3846
|
},
|
|
3712
3847
|
{
|
|
3713
3848
|
"code": 6044,
|
|
3714
|
-
"name": "
|
|
3715
|
-
"msg": "
|
|
3849
|
+
"name": "FillOrderDidNotUpdateState",
|
|
3850
|
+
"msg": "FillOrderDidNotUpdateState"
|
|
3716
3851
|
},
|
|
3717
3852
|
{
|
|
3718
3853
|
"code": 6045,
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BN } from '@project-serum/anchor';
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import pyth from '@pythnetwork/client';
|
|
3
4
|
|
|
4
5
|
export * from './mockUSDCFaucet';
|
|
5
6
|
export * from './oracles/types';
|
|
@@ -49,4 +50,4 @@ export * from './math/bankBalance';
|
|
|
49
50
|
export * from './constants/banks';
|
|
50
51
|
export * from './clearingHouseConfig';
|
|
51
52
|
|
|
52
|
-
export { BN, PublicKey };
|
|
53
|
+
export { BN, PublicKey, pyth };
|