@drift-labs/sdk 2.71.0-beta.0 → 2.71.0-beta.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/VERSION +1 -1
- package/lib/accounts/pollingDriftClientAccountSubscriber.js +2 -2
- package/lib/accounts/webSocketDriftClientAccountSubscriber.js +1 -1
- package/lib/addresses/pda.d.ts +1 -0
- package/lib/addresses/pda.js +8 -1
- package/lib/adminClient.d.ts +2 -0
- package/lib/adminClient.js +30 -0
- package/lib/constants/perpMarkets.js +10 -10
- package/lib/driftClient.d.ts +2 -0
- package/lib/driftClient.js +19 -1
- package/lib/factory/oracleClient.d.ts +2 -1
- package/lib/factory/oracleClient.js +5 -1
- package/lib/idl/drift.json +255 -35
- package/lib/oracles/oracleClientCache.d.ts +2 -1
- package/lib/oracles/oracleClientCache.js +2 -2
- package/lib/oracles/prelaunchOracleClient.d.ts +11 -0
- package/lib/oracles/prelaunchOracleClient.js +23 -0
- package/lib/types.d.ts +11 -0
- package/lib/types.js +1 -0
- package/package.json +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +4 -2
- package/src/accounts/webSocketDriftClientAccountSubscriber.ts +2 -1
- package/src/addresses/pda.ts +13 -0
- package/src/adminClient.ts +47 -0
- package/src/constants/perpMarkets.ts +10 -10
- package/src/driftClient.ts +36 -1
- package/src/factory/oracleClient.ts +8 -2
- package/src/idl/drift.json +255 -35
- package/src/oracles/oracleClientCache.ts +7 -2
- package/src/oracles/prelaunchOracleClient.ts +36 -0
- package/src/types.ts +10 -0
package/src/idl/drift.json
CHANGED
|
@@ -2039,6 +2039,27 @@
|
|
|
2039
2039
|
}
|
|
2040
2040
|
]
|
|
2041
2041
|
},
|
|
2042
|
+
{
|
|
2043
|
+
"name": "updatePrelaunchOracle",
|
|
2044
|
+
"accounts": [
|
|
2045
|
+
{
|
|
2046
|
+
"name": "state",
|
|
2047
|
+
"isMut": false,
|
|
2048
|
+
"isSigner": false
|
|
2049
|
+
},
|
|
2050
|
+
{
|
|
2051
|
+
"name": "perpMarket",
|
|
2052
|
+
"isMut": false,
|
|
2053
|
+
"isSigner": false
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
"name": "oracle",
|
|
2057
|
+
"isMut": true,
|
|
2058
|
+
"isSigner": false
|
|
2059
|
+
}
|
|
2060
|
+
],
|
|
2061
|
+
"args": []
|
|
2062
|
+
},
|
|
2042
2063
|
{
|
|
2043
2064
|
"name": "updatePerpBidAskTwap",
|
|
2044
2065
|
"accounts": [
|
|
@@ -4894,6 +4915,72 @@
|
|
|
4894
4915
|
}
|
|
4895
4916
|
}
|
|
4896
4917
|
]
|
|
4918
|
+
},
|
|
4919
|
+
{
|
|
4920
|
+
"name": "initializePrelaunchOracle",
|
|
4921
|
+
"accounts": [
|
|
4922
|
+
{
|
|
4923
|
+
"name": "admin",
|
|
4924
|
+
"isMut": true,
|
|
4925
|
+
"isSigner": true
|
|
4926
|
+
},
|
|
4927
|
+
{
|
|
4928
|
+
"name": "prelaunchOracle",
|
|
4929
|
+
"isMut": true,
|
|
4930
|
+
"isSigner": false
|
|
4931
|
+
},
|
|
4932
|
+
{
|
|
4933
|
+
"name": "state",
|
|
4934
|
+
"isMut": false,
|
|
4935
|
+
"isSigner": false
|
|
4936
|
+
},
|
|
4937
|
+
{
|
|
4938
|
+
"name": "rent",
|
|
4939
|
+
"isMut": false,
|
|
4940
|
+
"isSigner": false
|
|
4941
|
+
},
|
|
4942
|
+
{
|
|
4943
|
+
"name": "systemProgram",
|
|
4944
|
+
"isMut": false,
|
|
4945
|
+
"isSigner": false
|
|
4946
|
+
}
|
|
4947
|
+
],
|
|
4948
|
+
"args": [
|
|
4949
|
+
{
|
|
4950
|
+
"name": "params",
|
|
4951
|
+
"type": {
|
|
4952
|
+
"defined": "PrelaunchOracleParams"
|
|
4953
|
+
}
|
|
4954
|
+
}
|
|
4955
|
+
]
|
|
4956
|
+
},
|
|
4957
|
+
{
|
|
4958
|
+
"name": "updatePrelaunchOracleParams",
|
|
4959
|
+
"accounts": [
|
|
4960
|
+
{
|
|
4961
|
+
"name": "admin",
|
|
4962
|
+
"isMut": true,
|
|
4963
|
+
"isSigner": true
|
|
4964
|
+
},
|
|
4965
|
+
{
|
|
4966
|
+
"name": "prelaunchOracle",
|
|
4967
|
+
"isMut": true,
|
|
4968
|
+
"isSigner": false
|
|
4969
|
+
},
|
|
4970
|
+
{
|
|
4971
|
+
"name": "state",
|
|
4972
|
+
"isMut": false,
|
|
4973
|
+
"isSigner": false
|
|
4974
|
+
}
|
|
4975
|
+
],
|
|
4976
|
+
"args": [
|
|
4977
|
+
{
|
|
4978
|
+
"name": "params",
|
|
4979
|
+
"type": {
|
|
4980
|
+
"defined": "PrelaunchOracleParams"
|
|
4981
|
+
}
|
|
4982
|
+
}
|
|
4983
|
+
]
|
|
4897
4984
|
}
|
|
4898
4985
|
],
|
|
4899
4986
|
"accounts": [
|
|
@@ -5122,6 +5209,47 @@
|
|
|
5122
5209
|
]
|
|
5123
5210
|
}
|
|
5124
5211
|
},
|
|
5212
|
+
{
|
|
5213
|
+
"name": "PrelaunchOracle",
|
|
5214
|
+
"type": {
|
|
5215
|
+
"kind": "struct",
|
|
5216
|
+
"fields": [
|
|
5217
|
+
{
|
|
5218
|
+
"name": "price",
|
|
5219
|
+
"type": "i64"
|
|
5220
|
+
},
|
|
5221
|
+
{
|
|
5222
|
+
"name": "maxPrice",
|
|
5223
|
+
"type": "i64"
|
|
5224
|
+
},
|
|
5225
|
+
{
|
|
5226
|
+
"name": "confidence",
|
|
5227
|
+
"type": "u64"
|
|
5228
|
+
},
|
|
5229
|
+
{
|
|
5230
|
+
"name": "lastUpdateSlot",
|
|
5231
|
+
"type": "u64"
|
|
5232
|
+
},
|
|
5233
|
+
{
|
|
5234
|
+
"name": "ammLastUpdateSlot",
|
|
5235
|
+
"type": "u64"
|
|
5236
|
+
},
|
|
5237
|
+
{
|
|
5238
|
+
"name": "perpMarketIndex",
|
|
5239
|
+
"type": "u16"
|
|
5240
|
+
},
|
|
5241
|
+
{
|
|
5242
|
+
"name": "padding",
|
|
5243
|
+
"type": {
|
|
5244
|
+
"array": [
|
|
5245
|
+
"u8",
|
|
5246
|
+
70
|
|
5247
|
+
]
|
|
5248
|
+
}
|
|
5249
|
+
}
|
|
5250
|
+
]
|
|
5251
|
+
}
|
|
5252
|
+
},
|
|
5125
5253
|
{
|
|
5126
5254
|
"name": "PerpMarket",
|
|
5127
5255
|
"type": {
|
|
@@ -6340,6 +6468,9 @@
|
|
|
6340
6468
|
},
|
|
6341
6469
|
{
|
|
6342
6470
|
"name": "lpShares",
|
|
6471
|
+
"docs": [
|
|
6472
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6473
|
+
],
|
|
6343
6474
|
"type": "u64"
|
|
6344
6475
|
},
|
|
6345
6476
|
{
|
|
@@ -6356,10 +6487,16 @@
|
|
|
6356
6487
|
},
|
|
6357
6488
|
{
|
|
6358
6489
|
"name": "liquidatorFee",
|
|
6490
|
+
"docs": [
|
|
6491
|
+
"precision: QUOTE_PRECISION"
|
|
6492
|
+
],
|
|
6359
6493
|
"type": "u64"
|
|
6360
6494
|
},
|
|
6361
6495
|
{
|
|
6362
6496
|
"name": "ifFee",
|
|
6497
|
+
"docs": [
|
|
6498
|
+
"precision: QUOTE_PRECISION"
|
|
6499
|
+
],
|
|
6363
6500
|
"type": "u64"
|
|
6364
6501
|
}
|
|
6365
6502
|
]
|
|
@@ -6392,10 +6529,16 @@
|
|
|
6392
6529
|
},
|
|
6393
6530
|
{
|
|
6394
6531
|
"name": "liabilityTransfer",
|
|
6532
|
+
"docs": [
|
|
6533
|
+
"precision: token mint precision"
|
|
6534
|
+
],
|
|
6395
6535
|
"type": "u128"
|
|
6396
6536
|
},
|
|
6397
6537
|
{
|
|
6398
6538
|
"name": "ifFee",
|
|
6539
|
+
"docs": [
|
|
6540
|
+
"precision: token mint precision"
|
|
6541
|
+
],
|
|
6399
6542
|
"type": "u64"
|
|
6400
6543
|
}
|
|
6401
6544
|
]
|
|
@@ -6564,6 +6707,9 @@
|
|
|
6564
6707
|
},
|
|
6565
6708
|
{
|
|
6566
6709
|
"name": "lastOracleDelay",
|
|
6710
|
+
"docs": [
|
|
6711
|
+
"number of slots since last update"
|
|
6712
|
+
],
|
|
6567
6713
|
"type": "i64"
|
|
6568
6714
|
},
|
|
6569
6715
|
{
|
|
@@ -6582,6 +6728,9 @@
|
|
|
6582
6728
|
},
|
|
6583
6729
|
{
|
|
6584
6730
|
"name": "lastOraclePriceTwapTs",
|
|
6731
|
+
"docs": [
|
|
6732
|
+
"unix_timestamp of last snapshot"
|
|
6733
|
+
],
|
|
6585
6734
|
"type": "i64"
|
|
6586
6735
|
}
|
|
6587
6736
|
]
|
|
@@ -6622,11 +6771,38 @@
|
|
|
6622
6771
|
},
|
|
6623
6772
|
{
|
|
6624
6773
|
"name": "lastIndexPriceTwapTs",
|
|
6774
|
+
"docs": [
|
|
6775
|
+
"unix_timestamp of last snapshot"
|
|
6776
|
+
],
|
|
6625
6777
|
"type": "i64"
|
|
6626
6778
|
}
|
|
6627
6779
|
]
|
|
6628
6780
|
}
|
|
6629
6781
|
},
|
|
6782
|
+
{
|
|
6783
|
+
"name": "PrelaunchOracleParams",
|
|
6784
|
+
"type": {
|
|
6785
|
+
"kind": "struct",
|
|
6786
|
+
"fields": [
|
|
6787
|
+
{
|
|
6788
|
+
"name": "perpMarketIndex",
|
|
6789
|
+
"type": "u16"
|
|
6790
|
+
},
|
|
6791
|
+
{
|
|
6792
|
+
"name": "price",
|
|
6793
|
+
"type": {
|
|
6794
|
+
"option": "i64"
|
|
6795
|
+
}
|
|
6796
|
+
},
|
|
6797
|
+
{
|
|
6798
|
+
"name": "maxPrice",
|
|
6799
|
+
"type": {
|
|
6800
|
+
"option": "i64"
|
|
6801
|
+
}
|
|
6802
|
+
}
|
|
6803
|
+
]
|
|
6804
|
+
}
|
|
6805
|
+
},
|
|
6630
6806
|
{
|
|
6631
6807
|
"name": "OrderParams",
|
|
6632
6808
|
"type": {
|
|
@@ -6931,14 +7107,16 @@
|
|
|
6931
7107
|
{
|
|
6932
7108
|
"name": "baseAssetAmountPerLp",
|
|
6933
7109
|
"docs": [
|
|
6934
|
-
"accumulated base asset amount since inception per lp share"
|
|
7110
|
+
"accumulated base asset amount since inception per lp share",
|
|
7111
|
+
"precision: QUOTE_PRECISION"
|
|
6935
7112
|
],
|
|
6936
7113
|
"type": "i128"
|
|
6937
7114
|
},
|
|
6938
7115
|
{
|
|
6939
7116
|
"name": "quoteAssetAmountPerLp",
|
|
6940
7117
|
"docs": [
|
|
6941
|
-
"accumulated quote asset amount since inception per lp share"
|
|
7118
|
+
"accumulated quote asset amount since inception per lp share",
|
|
7119
|
+
"precision: QUOTE_PRECISION"
|
|
6942
7120
|
],
|
|
6943
7121
|
"type": "i128"
|
|
6944
7122
|
},
|
|
@@ -6954,14 +7132,16 @@
|
|
|
6954
7132
|
{
|
|
6955
7133
|
"name": "baseAssetReserve",
|
|
6956
7134
|
"docs": [
|
|
6957
|
-
"`x` reserves for constant product mm formula (x * y = k)"
|
|
7135
|
+
"`x` reserves for constant product mm formula (x * y = k)",
|
|
7136
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6958
7137
|
],
|
|
6959
7138
|
"type": "u128"
|
|
6960
7139
|
},
|
|
6961
7140
|
{
|
|
6962
7141
|
"name": "quoteAssetReserve",
|
|
6963
7142
|
"docs": [
|
|
6964
|
-
"`y` reserves for constant product mm formula (x * y = k)"
|
|
7143
|
+
"`y` reserves for constant product mm formula (x * y = k)",
|
|
7144
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6965
7145
|
],
|
|
6966
7146
|
"type": "u128"
|
|
6967
7147
|
},
|
|
@@ -6969,189 +7149,216 @@
|
|
|
6969
7149
|
"name": "concentrationCoef",
|
|
6970
7150
|
"docs": [
|
|
6971
7151
|
"determines how close the min/max base asset reserve sit vs base reserves",
|
|
6972
|
-
"allow for decreasing slippage without increasing liquidity and v.v."
|
|
7152
|
+
"allow for decreasing slippage without increasing liquidity and v.v.",
|
|
7153
|
+
"precision: PERCENTAGE_PRECISION"
|
|
6973
7154
|
],
|
|
6974
7155
|
"type": "u128"
|
|
6975
7156
|
},
|
|
6976
7157
|
{
|
|
6977
7158
|
"name": "minBaseAssetReserve",
|
|
6978
7159
|
"docs": [
|
|
6979
|
-
"minimum base_asset_reserve allowed before AMM is unavailable"
|
|
7160
|
+
"minimum base_asset_reserve allowed before AMM is unavailable",
|
|
7161
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6980
7162
|
],
|
|
6981
7163
|
"type": "u128"
|
|
6982
7164
|
},
|
|
6983
7165
|
{
|
|
6984
7166
|
"name": "maxBaseAssetReserve",
|
|
6985
7167
|
"docs": [
|
|
6986
|
-
"maximum base_asset_reserve allowed before AMM is unavailable"
|
|
7168
|
+
"maximum base_asset_reserve allowed before AMM is unavailable",
|
|
7169
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6987
7170
|
],
|
|
6988
7171
|
"type": "u128"
|
|
6989
7172
|
},
|
|
6990
7173
|
{
|
|
6991
7174
|
"name": "sqrtK",
|
|
6992
7175
|
"docs": [
|
|
6993
|
-
"`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues"
|
|
7176
|
+
"`sqrt(k)` in constant product mm formula (x * y = k). stored to avoid drift caused by integer math issues",
|
|
7177
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
6994
7178
|
],
|
|
6995
7179
|
"type": "u128"
|
|
6996
7180
|
},
|
|
6997
7181
|
{
|
|
6998
7182
|
"name": "pegMultiplier",
|
|
6999
7183
|
"docs": [
|
|
7000
|
-
"normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced"
|
|
7184
|
+
"normalizing numerical factor for y, its use offers lowest slippage in cp-curve when market is balanced",
|
|
7185
|
+
"precision: PEG_PRECISION"
|
|
7001
7186
|
],
|
|
7002
7187
|
"type": "u128"
|
|
7003
7188
|
},
|
|
7004
7189
|
{
|
|
7005
7190
|
"name": "terminalQuoteAssetReserve",
|
|
7006
7191
|
"docs": [
|
|
7007
|
-
"y when market is balanced. stored to save computation"
|
|
7192
|
+
"y when market is balanced. stored to save computation",
|
|
7193
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7008
7194
|
],
|
|
7009
7195
|
"type": "u128"
|
|
7010
7196
|
},
|
|
7011
7197
|
{
|
|
7012
7198
|
"name": "baseAssetAmountLong",
|
|
7013
7199
|
"docs": [
|
|
7014
|
-
"tracks number of total longs in market (regardless of counterparty)"
|
|
7200
|
+
"always non-negative. tracks number of total longs in market (regardless of counterparty)",
|
|
7201
|
+
"precision: BASE_PRECISION"
|
|
7015
7202
|
],
|
|
7016
7203
|
"type": "i128"
|
|
7017
7204
|
},
|
|
7018
7205
|
{
|
|
7019
7206
|
"name": "baseAssetAmountShort",
|
|
7020
7207
|
"docs": [
|
|
7021
|
-
"tracks number of total shorts in market (regardless of counterparty)"
|
|
7208
|
+
"always non-positive. tracks number of total shorts in market (regardless of counterparty)",
|
|
7209
|
+
"precision: BASE_PRECISION"
|
|
7022
7210
|
],
|
|
7023
7211
|
"type": "i128"
|
|
7024
7212
|
},
|
|
7025
7213
|
{
|
|
7026
7214
|
"name": "baseAssetAmountWithAmm",
|
|
7027
7215
|
"docs": [
|
|
7028
|
-
"tracks net position (longs-shorts) in market with AMM as counterparty"
|
|
7216
|
+
"tracks net position (longs-shorts) in market with AMM as counterparty",
|
|
7217
|
+
"precision: BASE_PRECISION"
|
|
7029
7218
|
],
|
|
7030
7219
|
"type": "i128"
|
|
7031
7220
|
},
|
|
7032
7221
|
{
|
|
7033
7222
|
"name": "baseAssetAmountWithUnsettledLp",
|
|
7034
7223
|
"docs": [
|
|
7035
|
-
"tracks net position (longs-shorts) in market with LPs as counterparty"
|
|
7224
|
+
"tracks net position (longs-shorts) in market with LPs as counterparty",
|
|
7225
|
+
"precision: BASE_PRECISION"
|
|
7036
7226
|
],
|
|
7037
7227
|
"type": "i128"
|
|
7038
7228
|
},
|
|
7039
7229
|
{
|
|
7040
7230
|
"name": "maxOpenInterest",
|
|
7041
7231
|
"docs": [
|
|
7042
|
-
"max allowed open interest, blocks trades that breach this value"
|
|
7232
|
+
"max allowed open interest, blocks trades that breach this value",
|
|
7233
|
+
"precision: BASE_PRECISION"
|
|
7043
7234
|
],
|
|
7044
7235
|
"type": "u128"
|
|
7045
7236
|
},
|
|
7046
7237
|
{
|
|
7047
7238
|
"name": "quoteAssetAmount",
|
|
7048
7239
|
"docs": [
|
|
7049
|
-
"sum of all user's perp quote_asset_amount in market"
|
|
7240
|
+
"sum of all user's perp quote_asset_amount in market",
|
|
7241
|
+
"precision: QUOTE_PRECISION"
|
|
7050
7242
|
],
|
|
7051
7243
|
"type": "i128"
|
|
7052
7244
|
},
|
|
7053
7245
|
{
|
|
7054
7246
|
"name": "quoteEntryAmountLong",
|
|
7055
7247
|
"docs": [
|
|
7056
|
-
"sum of all long user's quote_entry_amount in market"
|
|
7248
|
+
"sum of all long user's quote_entry_amount in market",
|
|
7249
|
+
"precision: QUOTE_PRECISION"
|
|
7057
7250
|
],
|
|
7058
7251
|
"type": "i128"
|
|
7059
7252
|
},
|
|
7060
7253
|
{
|
|
7061
7254
|
"name": "quoteEntryAmountShort",
|
|
7062
7255
|
"docs": [
|
|
7063
|
-
"sum of all short user's quote_entry_amount in market"
|
|
7256
|
+
"sum of all short user's quote_entry_amount in market",
|
|
7257
|
+
"precision: QUOTE_PRECISION"
|
|
7064
7258
|
],
|
|
7065
7259
|
"type": "i128"
|
|
7066
7260
|
},
|
|
7067
7261
|
{
|
|
7068
7262
|
"name": "quoteBreakEvenAmountLong",
|
|
7069
7263
|
"docs": [
|
|
7070
|
-
"sum of all long user's quote_break_even_amount in market"
|
|
7264
|
+
"sum of all long user's quote_break_even_amount in market",
|
|
7265
|
+
"precision: QUOTE_PRECISION"
|
|
7071
7266
|
],
|
|
7072
7267
|
"type": "i128"
|
|
7073
7268
|
},
|
|
7074
7269
|
{
|
|
7075
7270
|
"name": "quoteBreakEvenAmountShort",
|
|
7076
7271
|
"docs": [
|
|
7077
|
-
"sum of all short user's quote_break_even_amount in market"
|
|
7272
|
+
"sum of all short user's quote_break_even_amount in market",
|
|
7273
|
+
"precision: QUOTE_PRECISION"
|
|
7078
7274
|
],
|
|
7079
7275
|
"type": "i128"
|
|
7080
7276
|
},
|
|
7081
7277
|
{
|
|
7082
7278
|
"name": "userLpShares",
|
|
7083
7279
|
"docs": [
|
|
7084
|
-
"total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)"
|
|
7280
|
+
"total user lp shares of sqrt_k (protocol owned liquidity = sqrt_k - last_funding_rate)",
|
|
7281
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7085
7282
|
],
|
|
7086
7283
|
"type": "u128"
|
|
7087
7284
|
},
|
|
7088
7285
|
{
|
|
7089
7286
|
"name": "lastFundingRate",
|
|
7090
7287
|
"docs": [
|
|
7091
|
-
"last funding rate in this perp market (unit is quote per base)"
|
|
7288
|
+
"last funding rate in this perp market (unit is quote per base)",
|
|
7289
|
+
"precision: QUOTE_PRECISION"
|
|
7092
7290
|
],
|
|
7093
7291
|
"type": "i64"
|
|
7094
7292
|
},
|
|
7095
7293
|
{
|
|
7096
7294
|
"name": "lastFundingRateLong",
|
|
7097
7295
|
"docs": [
|
|
7098
|
-
"last funding rate for longs in this perp market (unit is quote per base)"
|
|
7296
|
+
"last funding rate for longs in this perp market (unit is quote per base)",
|
|
7297
|
+
"precision: QUOTE_PRECISION"
|
|
7099
7298
|
],
|
|
7100
7299
|
"type": "i64"
|
|
7101
7300
|
},
|
|
7102
7301
|
{
|
|
7103
7302
|
"name": "lastFundingRateShort",
|
|
7104
7303
|
"docs": [
|
|
7105
|
-
"last funding rate for shorts in this perp market (unit is quote per base)"
|
|
7304
|
+
"last funding rate for shorts in this perp market (unit is quote per base)",
|
|
7305
|
+
"precision: QUOTE_PRECISION"
|
|
7106
7306
|
],
|
|
7107
7307
|
"type": "i64"
|
|
7108
7308
|
},
|
|
7109
7309
|
{
|
|
7110
7310
|
"name": "last24hAvgFundingRate",
|
|
7111
7311
|
"docs": [
|
|
7112
|
-
"estimate of last 24h of funding rate perp market (unit is quote per base)"
|
|
7312
|
+
"estimate of last 24h of funding rate perp market (unit is quote per base)",
|
|
7313
|
+
"precision: QUOTE_PRECISION"
|
|
7113
7314
|
],
|
|
7114
7315
|
"type": "i64"
|
|
7115
7316
|
},
|
|
7116
7317
|
{
|
|
7117
7318
|
"name": "totalFee",
|
|
7118
7319
|
"docs": [
|
|
7119
|
-
"total fees collected by this perp market"
|
|
7320
|
+
"total fees collected by this perp market",
|
|
7321
|
+
"precision: QUOTE_PRECISION"
|
|
7120
7322
|
],
|
|
7121
7323
|
"type": "i128"
|
|
7122
7324
|
},
|
|
7123
7325
|
{
|
|
7124
7326
|
"name": "totalMmFee",
|
|
7125
7327
|
"docs": [
|
|
7126
|
-
"total fees collected by the vAMM's bid/ask spread"
|
|
7328
|
+
"total fees collected by the vAMM's bid/ask spread",
|
|
7329
|
+
"precision: QUOTE_PRECISION"
|
|
7127
7330
|
],
|
|
7128
7331
|
"type": "i128"
|
|
7129
7332
|
},
|
|
7130
7333
|
{
|
|
7131
7334
|
"name": "totalExchangeFee",
|
|
7132
7335
|
"docs": [
|
|
7133
|
-
"total fees collected by exchange fee schedule"
|
|
7336
|
+
"total fees collected by exchange fee schedule",
|
|
7337
|
+
"precision: QUOTE_PRECISION"
|
|
7134
7338
|
],
|
|
7135
7339
|
"type": "u128"
|
|
7136
7340
|
},
|
|
7137
7341
|
{
|
|
7138
7342
|
"name": "totalFeeMinusDistributions",
|
|
7139
7343
|
"docs": [
|
|
7140
|
-
"total fees minus any recognized upnl and pool withdraws"
|
|
7344
|
+
"total fees minus any recognized upnl and pool withdraws",
|
|
7345
|
+
"precision: QUOTE_PRECISION"
|
|
7141
7346
|
],
|
|
7142
7347
|
"type": "i128"
|
|
7143
7348
|
},
|
|
7144
7349
|
{
|
|
7145
7350
|
"name": "totalFeeWithdrawn",
|
|
7146
7351
|
"docs": [
|
|
7147
|
-
"sum of all fees from fee pool withdrawn to revenue pool"
|
|
7352
|
+
"sum of all fees from fee pool withdrawn to revenue pool",
|
|
7353
|
+
"precision: QUOTE_PRECISION"
|
|
7148
7354
|
],
|
|
7149
7355
|
"type": "u128"
|
|
7150
7356
|
},
|
|
7151
7357
|
{
|
|
7152
7358
|
"name": "totalLiquidationFee",
|
|
7153
7359
|
"docs": [
|
|
7154
|
-
"all fees collected by market for liquidations"
|
|
7360
|
+
"all fees collected by market for liquidations",
|
|
7361
|
+
"precision: QUOTE_PRECISION"
|
|
7155
7362
|
],
|
|
7156
7363
|
"type": "u128"
|
|
7157
7364
|
},
|
|
@@ -7179,28 +7386,32 @@
|
|
|
7179
7386
|
{
|
|
7180
7387
|
"name": "askBaseAssetReserve",
|
|
7181
7388
|
"docs": [
|
|
7182
|
-
"transformed base_asset_reserve for users going long"
|
|
7389
|
+
"transformed base_asset_reserve for users going long",
|
|
7390
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7183
7391
|
],
|
|
7184
7392
|
"type": "u128"
|
|
7185
7393
|
},
|
|
7186
7394
|
{
|
|
7187
7395
|
"name": "askQuoteAssetReserve",
|
|
7188
7396
|
"docs": [
|
|
7189
|
-
"transformed quote_asset_reserve for users going long"
|
|
7397
|
+
"transformed quote_asset_reserve for users going long",
|
|
7398
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7190
7399
|
],
|
|
7191
7400
|
"type": "u128"
|
|
7192
7401
|
},
|
|
7193
7402
|
{
|
|
7194
7403
|
"name": "bidBaseAssetReserve",
|
|
7195
7404
|
"docs": [
|
|
7196
|
-
"transformed base_asset_reserve for users going short"
|
|
7405
|
+
"transformed base_asset_reserve for users going short",
|
|
7406
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7197
7407
|
],
|
|
7198
7408
|
"type": "u128"
|
|
7199
7409
|
},
|
|
7200
7410
|
{
|
|
7201
7411
|
"name": "bidQuoteAssetReserve",
|
|
7202
7412
|
"docs": [
|
|
7203
|
-
"transformed quote_asset_reserve for users going short"
|
|
7413
|
+
"transformed quote_asset_reserve for users going short",
|
|
7414
|
+
"precision: AMM_RESERVE_PRECISION"
|
|
7204
7415
|
],
|
|
7205
7416
|
"type": "u128"
|
|
7206
7417
|
},
|
|
@@ -8690,6 +8901,9 @@
|
|
|
8690
8901
|
},
|
|
8691
8902
|
{
|
|
8692
8903
|
"name": "PythStableCoin"
|
|
8904
|
+
},
|
|
8905
|
+
{
|
|
8906
|
+
"name": "Prelaunch"
|
|
8693
8907
|
}
|
|
8694
8908
|
]
|
|
8695
8909
|
}
|
|
@@ -8747,6 +8961,9 @@
|
|
|
8747
8961
|
},
|
|
8748
8962
|
{
|
|
8749
8963
|
"name": "SettlePnlWithPosition"
|
|
8964
|
+
},
|
|
8965
|
+
{
|
|
8966
|
+
"name": "Liquidation"
|
|
8750
8967
|
}
|
|
8751
8968
|
]
|
|
8752
8969
|
}
|
|
@@ -8764,6 +8981,9 @@
|
|
|
8764
8981
|
},
|
|
8765
8982
|
{
|
|
8766
8983
|
"name": "Withdraw"
|
|
8984
|
+
},
|
|
8985
|
+
{
|
|
8986
|
+
"name": "Liquidation"
|
|
8767
8987
|
}
|
|
8768
8988
|
]
|
|
8769
8989
|
}
|
|
@@ -2,18 +2,23 @@ import { OracleClient } from './types';
|
|
|
2
2
|
import { OracleSource } from '../types';
|
|
3
3
|
import { getOracleClient } from '../factory/oracleClient';
|
|
4
4
|
import { Connection } from '@solana/web3.js';
|
|
5
|
+
import { Program } from '@coral-xyz/anchor';
|
|
5
6
|
|
|
6
7
|
export class OracleClientCache {
|
|
7
8
|
cache = new Map<string, OracleClient>();
|
|
8
9
|
public constructor() {}
|
|
9
10
|
|
|
10
|
-
public get(
|
|
11
|
+
public get(
|
|
12
|
+
oracleSource: OracleSource,
|
|
13
|
+
connection: Connection,
|
|
14
|
+
program: Program
|
|
15
|
+
) {
|
|
11
16
|
const key = Object.keys(oracleSource)[0];
|
|
12
17
|
if (this.cache.has(key)) {
|
|
13
18
|
return this.cache.get(key);
|
|
14
19
|
}
|
|
15
20
|
|
|
16
|
-
const client = getOracleClient(oracleSource, connection);
|
|
21
|
+
const client = getOracleClient(oracleSource, connection, program);
|
|
17
22
|
this.cache.set(key, client);
|
|
18
23
|
return client;
|
|
19
24
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { OracleClient, OraclePriceData } from './types';
|
|
3
|
+
import { Program } from '@coral-xyz/anchor';
|
|
4
|
+
import { PrelaunchOracle } from '../types';
|
|
5
|
+
|
|
6
|
+
export class PrelaunchOracleClient implements OracleClient {
|
|
7
|
+
private connection: Connection;
|
|
8
|
+
private program: Program;
|
|
9
|
+
|
|
10
|
+
public constructor(connection: Connection, program: Program) {
|
|
11
|
+
this.connection = connection;
|
|
12
|
+
this.program = program;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async getOraclePriceData(
|
|
16
|
+
pricePublicKey: PublicKey
|
|
17
|
+
): Promise<OraclePriceData> {
|
|
18
|
+
const accountInfo = await this.connection.getAccountInfo(pricePublicKey);
|
|
19
|
+
return this.getOraclePriceDataFromBuffer(accountInfo.data);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getOraclePriceDataFromBuffer(buffer: Buffer): OraclePriceData {
|
|
23
|
+
const prelaunchOracle =
|
|
24
|
+
this.program.account.prelaunchOracle.coder.accounts.decodeUnchecked(
|
|
25
|
+
'PrelaunchOracle',
|
|
26
|
+
buffer
|
|
27
|
+
) as PrelaunchOracle;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
price: prelaunchOracle.price,
|
|
31
|
+
slot: prelaunchOracle.ammLastUpdateSlot,
|
|
32
|
+
confidence: prelaunchOracle.confidence,
|
|
33
|
+
hasSufficientNumberOfDataPoints: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -96,6 +96,7 @@ export class OracleSource {
|
|
|
96
96
|
// static readonly SWITCHBOARD = { switchboard: {} };
|
|
97
97
|
static readonly QUOTE_ASSET = { quoteAsset: {} };
|
|
98
98
|
static readonly PYTH_STABLE_COIN = { pythStableCoin: {} };
|
|
99
|
+
static readonly Prelaunch = { prelaunch: {} };
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
export class OrderType {
|
|
@@ -1060,6 +1061,15 @@ export type OracleGuardRails = {
|
|
|
1060
1061
|
};
|
|
1061
1062
|
};
|
|
1062
1063
|
|
|
1064
|
+
export type PrelaunchOracle = {
|
|
1065
|
+
price: BN;
|
|
1066
|
+
maxPrice: BN;
|
|
1067
|
+
confidence: BN;
|
|
1068
|
+
ammLastUpdateSlot: BN;
|
|
1069
|
+
lastUpdateSlot: BN;
|
|
1070
|
+
perpMarketIndex: number;
|
|
1071
|
+
};
|
|
1072
|
+
|
|
1063
1073
|
export type MarginCategory = 'Initial' | 'Maintenance';
|
|
1064
1074
|
|
|
1065
1075
|
export type InsuranceFundStake = {
|