@drift-labs/sdk 2.64.0-beta.1 → 2.64.0-beta.3
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/constants/perpMarkets.js +10 -0
- package/lib/math/market.js +1 -1
- package/lib/tx/baseTxSender.js +3 -1
- package/package.json +1 -1
- package/src/constants/perpMarkets.ts +10 -0
- package/src/math/market.ts +1 -1
- package/src/tx/baseTxSender.ts +5 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.64.0-beta.
|
|
1
|
+
2.64.0-beta.3
|
|
@@ -496,6 +496,16 @@ exports.MainnetPerpMarkets = [
|
|
|
496
496
|
launchTs: 1706713201000,
|
|
497
497
|
oracleSource: __1.OracleSource.PYTH,
|
|
498
498
|
},
|
|
499
|
+
{
|
|
500
|
+
fullName: 'Dymension',
|
|
501
|
+
category: ['Rollup', 'Infra'],
|
|
502
|
+
symbol: 'DYM-PERP',
|
|
503
|
+
baseAssetSymbol: 'DYM',
|
|
504
|
+
marketIndex: 25,
|
|
505
|
+
oracle: new web3_js_1.PublicKey('CSRRrhXa6DYu1W5jf89A7unCATdug2Z33tYyV2NXZZxa'),
|
|
506
|
+
launchTs: 1708448765000,
|
|
507
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
508
|
+
},
|
|
499
509
|
];
|
|
500
510
|
exports.PerpMarkets = {
|
|
501
511
|
devnet: exports.DevnetPerpMarkets,
|
package/lib/math/market.js
CHANGED
|
@@ -123,7 +123,7 @@ exports.calculateNetUserPnl = calculateNetUserPnl;
|
|
|
123
123
|
function calculateNetUserPnlImbalance(perpMarket, spotMarket, oraclePriceData) {
|
|
124
124
|
const netUserPnl = calculateNetUserPnl(perpMarket, oraclePriceData);
|
|
125
125
|
const pnlPool = (0, spotBalance_1.getTokenAmount)(perpMarket.pnlPool.scaledBalance, spotMarket, types_1.SpotBalanceType.DEPOSIT);
|
|
126
|
-
const feePool = (0, spotBalance_1.getTokenAmount)(perpMarket.amm.feePool.scaledBalance, spotMarket, types_1.SpotBalanceType.DEPOSIT);
|
|
126
|
+
const feePool = (0, spotBalance_1.getTokenAmount)(perpMarket.amm.feePool.scaledBalance, spotMarket, types_1.SpotBalanceType.DEPOSIT).div(new anchor_1.BN(5));
|
|
127
127
|
const imbalance = netUserPnl.sub(pnlPool.add(feePool));
|
|
128
128
|
return imbalance;
|
|
129
129
|
}
|
package/lib/tx/baseTxSender.js
CHANGED
|
@@ -166,6 +166,7 @@ class BaseTxSender {
|
|
|
166
166
|
var _a;
|
|
167
167
|
let totalTime = 0;
|
|
168
168
|
let backoffTime = 400; // approx block time
|
|
169
|
+
const start = Date.now();
|
|
169
170
|
while (totalTime < this.timeout) {
|
|
170
171
|
await new Promise((resolve) => setTimeout(resolve, backoffTime));
|
|
171
172
|
const response = await this.connection.getSignatureStatus(signature);
|
|
@@ -178,7 +179,8 @@ class BaseTxSender {
|
|
|
178
179
|
}
|
|
179
180
|
// Transaction not confirmed within 30 seconds
|
|
180
181
|
this.timeoutCount += 1;
|
|
181
|
-
|
|
182
|
+
const duration = (Date.now() - start) / 1000;
|
|
183
|
+
throw new Error(`Transaction was not confirmed in ${duration.toFixed(2)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`);
|
|
182
184
|
}
|
|
183
185
|
async confirmTransaction(signature, commitment) {
|
|
184
186
|
if (this.confirmationStrategy === types_1.ConfirmationStrategy.WebSocket ||
|
package/package.json
CHANGED
|
@@ -507,6 +507,16 @@ export const MainnetPerpMarkets: PerpMarketConfig[] = [
|
|
|
507
507
|
launchTs: 1706713201000,
|
|
508
508
|
oracleSource: OracleSource.PYTH,
|
|
509
509
|
},
|
|
510
|
+
{
|
|
511
|
+
fullName: 'Dymension',
|
|
512
|
+
category: ['Rollup', 'Infra'],
|
|
513
|
+
symbol: 'DYM-PERP',
|
|
514
|
+
baseAssetSymbol: 'DYM',
|
|
515
|
+
marketIndex: 25,
|
|
516
|
+
oracle: new PublicKey('CSRRrhXa6DYu1W5jf89A7unCATdug2Z33tYyV2NXZZxa'),
|
|
517
|
+
launchTs: 1708448765000,
|
|
518
|
+
oracleSource: OracleSource.PYTH,
|
|
519
|
+
},
|
|
510
520
|
];
|
|
511
521
|
|
|
512
522
|
export const PerpMarkets: { [key in DriftEnv]: PerpMarketConfig[] } = {
|
package/src/math/market.ts
CHANGED
package/src/tx/baseTxSender.ts
CHANGED
|
@@ -267,6 +267,7 @@ export abstract class BaseTxSender implements TxSender {
|
|
|
267
267
|
): Promise<RpcResponseAndContext<SignatureResult> | undefined> {
|
|
268
268
|
let totalTime = 0;
|
|
269
269
|
let backoffTime = 400; // approx block time
|
|
270
|
+
const start = Date.now();
|
|
270
271
|
|
|
271
272
|
while (totalTime < this.timeout) {
|
|
272
273
|
await new Promise((resolve) => setTimeout(resolve, backoffTime));
|
|
@@ -284,8 +285,11 @@ export abstract class BaseTxSender implements TxSender {
|
|
|
284
285
|
|
|
285
286
|
// Transaction not confirmed within 30 seconds
|
|
286
287
|
this.timeoutCount += 1;
|
|
288
|
+
const duration = (Date.now() - start) / 1000;
|
|
287
289
|
throw new Error(
|
|
288
|
-
`Transaction was not confirmed in
|
|
290
|
+
`Transaction was not confirmed in ${duration.toFixed(
|
|
291
|
+
2
|
|
292
|
+
)} seconds. It is unknown if it succeeded or failed. Check signature ${signature} using the Solana Explorer or CLI tools.`
|
|
289
293
|
);
|
|
290
294
|
}
|
|
291
295
|
|