@drift-labs/sdk-browser 2.155.0-beta.2 → 2.155.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/browser/accounts/grpcAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/grpcMultiAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/grpcProgramAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/laserProgramAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/webSocketAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/webSocketDriftClientAccountSubscriber.d.ts +0 -1
- package/lib/browser/accounts/webSocketProgramAccountSubscriber.d.ts +0 -1
- package/lib/browser/driftClient.d.ts +1 -2
- package/lib/browser/driftClient.js +5 -6
- package/lib/browser/oracles/pythPullClient.d.ts +2 -2
- package/lib/browser/oracles/pythPullClient.js +5 -2
- package/lib/browser/pyth/constants.d.ts +3 -0
- package/lib/browser/pyth/constants.js +6 -0
- package/lib/browser/pyth/index.d.ts +3 -0
- package/lib/browser/pyth/index.js +10 -0
- package/lib/browser/pyth/types.d.ts +2226 -0
- package/lib/browser/pyth/types.js +2224 -0
- package/lib/browser/pyth/utils.d.ts +2 -0
- package/lib/browser/pyth/utils.js +10 -0
- package/lib/node/accounts/grpcAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/grpcAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/grpcMultiAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/grpcProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/laserProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/webSocketDriftClientAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts +0 -1
- package/lib/node/accounts/webSocketProgramAccountSubscriber.d.ts.map +1 -1
- package/lib/node/driftClient.d.ts +1 -2
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +5 -6
- package/lib/node/oracles/pythPullClient.d.ts +2 -2
- package/lib/node/oracles/pythPullClient.d.ts.map +1 -1
- package/lib/node/oracles/pythPullClient.js +5 -2
- package/lib/node/pyth/constants.d.ts +4 -0
- package/lib/node/pyth/constants.d.ts.map +1 -0
- package/lib/node/pyth/constants.js +6 -0
- package/lib/node/pyth/index.d.ts +4 -0
- package/lib/node/pyth/index.d.ts.map +1 -0
- package/lib/node/pyth/index.js +10 -0
- package/lib/node/pyth/types.d.ts +2227 -0
- package/lib/node/pyth/types.d.ts.map +1 -0
- package/lib/node/pyth/types.js +2224 -0
- package/lib/node/pyth/utils.d.ts +3 -0
- package/lib/node/pyth/utils.d.ts.map +1 -0
- package/lib/node/pyth/utils.js +10 -0
- package/package.json +3 -4
- package/src/driftClient.ts +9 -11
- package/src/oracles/pythPullClient.ts +4 -5
- package/src/pyth/constants.ts +9 -0
- package/src/pyth/index.ts +11 -0
- package/src/pyth/types.ts +4453 -0
- package/src/pyth/utils.ts +13 -0
- package/tests/decode/test.ts +2 -1
- package/tests/dlob/helpers.ts +0 -1
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.155.0-beta.
|
|
1
|
+
2.155.0-beta.3
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { DataAndSlot, BufferAndSlot, AccountSubscriber, ResubOpts } from './types';
|
|
4
3
|
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { AccountInfo, Commitment, Context, PublicKey } from '@solana/web3.js';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
3
|
import { AccountSubscriber, DataAndSlot, DelistedMarketSetting, DriftClientAccountEvents, DriftClientAccountSubscriber, ResubOpts } from './types';
|
|
5
4
|
import { PerpMarketAccount, SpotMarketAccount, StateAccount } from '../types';
|
|
6
5
|
import { Program } from '@coral-xyz/anchor';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { BufferAndSlot, ProgramAccountSubscriber, ResubOpts } from './types';
|
|
4
3
|
import { Program } from '@coral-xyz/anchor';
|
|
5
4
|
import { Commitment, Context, KeyedAccountInfo, MemcmpFilter, PublicKey } from '@solana/web3.js';
|
|
@@ -22,14 +22,13 @@ import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
|
22
22
|
import { SwapMode, UnifiedQuoteResponse } from './swap/UnifiedSwapClient';
|
|
23
23
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
24
24
|
import { TxHandler } from './tx/txHandler';
|
|
25
|
-
import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana';
|
|
26
|
-
import { PythSolanaReceiver } from '@pythnetwork/pyth-solana-receiver/lib/idl/pyth_solana_receiver';
|
|
27
25
|
import { Slothash } from './slot/SlothashSubscriber';
|
|
28
26
|
import { SignedMsgOrderParams } from './types';
|
|
29
27
|
import { ConstituentMap } from './constituentMap/constituentMap';
|
|
30
28
|
import { RevenueShareEscrowMap } from './userMap/revenueShareEscrowMap';
|
|
31
29
|
import { TitanClient } from './titan/titanClient';
|
|
32
30
|
import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
|
|
31
|
+
import { WormholeCoreBridgeSolana, PythSolanaReceiver } from './pyth';
|
|
33
32
|
/**
|
|
34
33
|
* Union type for swap clients (Titan and Jupiter) - Legacy type
|
|
35
34
|
* @deprecated Use UnifiedSwapClient class instead
|
|
@@ -60,9 +60,7 @@ const utils_1 = require("./math/utils");
|
|
|
60
60
|
const txParamProcessor_1 = require("./tx/txParamProcessor");
|
|
61
61
|
const oracles_1 = require("./math/oracles");
|
|
62
62
|
const txHandler_1 = require("./tx/txHandler");
|
|
63
|
-
const pyth_solana_receiver_1 = require("@pythnetwork/pyth-solana-receiver");
|
|
64
63
|
const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
|
|
65
|
-
const address_1 = require("@pythnetwork/pyth-solana-receiver/lib/address");
|
|
66
64
|
const pythOracleUtils_1 = require("./util/pythOracleUtils");
|
|
67
65
|
const ed25519Utils_1 = require("./util/ed25519Utils");
|
|
68
66
|
const utils_2 = require("./tx/utils");
|
|
@@ -77,6 +75,7 @@ const orders_1 = require("./math/orders");
|
|
|
77
75
|
const builder_1 = require("./math/builder");
|
|
78
76
|
const titanClient_1 = require("./titan/titanClient");
|
|
79
77
|
const UnifiedSwapClient_1 = require("./swap/UnifiedSwapClient");
|
|
78
|
+
const pyth_1 = require("./pyth");
|
|
80
79
|
/**
|
|
81
80
|
* # DriftClient
|
|
82
81
|
* This class is the main way to interact with Drift Protocol. It allows you to subscribe to the various accounts where the Market's state is stored, as well as: opening positions, liquidating, settling funding, depositing & withdrawing, and more.
|
|
@@ -5666,7 +5665,7 @@ class DriftClient {
|
|
|
5666
5665
|
}
|
|
5667
5666
|
getReceiverProgram() {
|
|
5668
5667
|
if (this.receiverProgram === undefined) {
|
|
5669
|
-
this.receiverProgram = new anchor_1.Program(pyth_solana_receiver_json_1.default,
|
|
5668
|
+
this.receiverProgram = new anchor_1.Program(pyth_solana_receiver_json_1.default, pyth_1.DEFAULT_RECEIVER_PROGRAM_ID, this.provider);
|
|
5670
5669
|
}
|
|
5671
5670
|
return this.receiverProgram;
|
|
5672
5671
|
}
|
|
@@ -5691,7 +5690,7 @@ class DriftClient {
|
|
|
5691
5690
|
async getPostPythPullOracleUpdateAtomicIxs(vaaString, feedIds, numSignatures = 2) {
|
|
5692
5691
|
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(vaaString, 'base64'));
|
|
5693
5692
|
const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
|
|
5694
|
-
const guardianSet = (0,
|
|
5693
|
+
const guardianSet = (0, pyth_1.getGuardianSetPda)(guardianSetIndex, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID);
|
|
5695
5694
|
const trimmedVaa = (0, oracles_1.trimVaaSignatures)(accumulatorUpdateData.vaa, numSignatures);
|
|
5696
5695
|
const postIxs = [];
|
|
5697
5696
|
if (accumulatorUpdateData.updates.length > 1) {
|
|
@@ -5746,7 +5745,7 @@ class DriftClient {
|
|
|
5746
5745
|
feedId = (0, pythOracleUtils_1.trimFeedId)(feedId);
|
|
5747
5746
|
const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(vaaString, 'base64'));
|
|
5748
5747
|
const guardianSetIndex = accumulatorUpdateData.vaa.readUInt32BE(1);
|
|
5749
|
-
const guardianSet = (0,
|
|
5748
|
+
const guardianSet = (0, pyth_1.getGuardianSetPda)(guardianSetIndex, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID);
|
|
5750
5749
|
const [postIxs, encodedVaaAddress] = await this.getBuildEncodedVaaIxs(accumulatorUpdateData.vaa, guardianSet);
|
|
5751
5750
|
for (const update of accumulatorUpdateData.updates) {
|
|
5752
5751
|
postIxs.push(await this.getUpdatePythPullOracleIxs({
|
|
@@ -5857,7 +5856,7 @@ class DriftClient {
|
|
|
5857
5856
|
async getBuildEncodedVaaIxs(vaa, guardianSet) {
|
|
5858
5857
|
const postIxs = [];
|
|
5859
5858
|
if (this.wormholeProgram === undefined) {
|
|
5860
|
-
this.wormholeProgram = new anchor_1.Program(
|
|
5859
|
+
this.wormholeProgram = new anchor_1.Program(pyth_1.WORMHOLE_CORE_BRIDGE_SOLANA_IDL, pyth_1.DEFAULT_WORMHOLE_PROGRAM_ID, this.provider);
|
|
5861
5860
|
}
|
|
5862
5861
|
const encodedVaaKeypair = new web3_js_1.Keypair();
|
|
5863
5862
|
postIxs.push(await this.wormholeProgram.account.encodedVaa.createInstruction(encodedVaaKeypair, vaa.length + 46));
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
5
5
|
import { OracleClient, OraclePriceData } from './types';
|
|
6
6
|
import { BN, Program } from '@coral-xyz/anchor';
|
|
7
|
-
import { PythSolanaReceiverProgram } from '
|
|
8
|
-
import { PriceUpdateAccount } from '
|
|
7
|
+
import { PythSolanaReceiver as PythSolanaReceiverProgram } from '../pyth';
|
|
8
|
+
import { PriceUpdateAccount } from '../pyth';
|
|
9
9
|
export declare class PythPullClient implements OracleClient {
|
|
10
10
|
private connection;
|
|
11
11
|
private multiple;
|
|
@@ -1,10 +1,13 @@
|
|
|
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.convertPythPrice = exports.PythPullClient = void 0;
|
|
4
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
8
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
6
9
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
7
|
-
const
|
|
10
|
+
const pyth_solana_receiver_json_1 = __importDefault(require("../idl/pyth_solana_receiver.json"));
|
|
8
11
|
const config_1 = require("../config");
|
|
9
12
|
const wallet_1 = require("../wallet");
|
|
10
13
|
class PythPullClient {
|
|
@@ -17,7 +20,7 @@ class PythPullClient {
|
|
|
17
20
|
new wallet_1.Wallet(new web3_js_1.Keypair()), {
|
|
18
21
|
commitment: connection.commitment,
|
|
19
22
|
});
|
|
20
|
-
this.receiver = new anchor_1.Program(
|
|
23
|
+
this.receiver = new anchor_1.Program(pyth_solana_receiver_json_1.default, config_1.DRIFT_ORACLE_RECEIVER_ID, provider);
|
|
21
24
|
this.decodeFunc =
|
|
22
25
|
this.receiver.account.priceUpdateV2.coder.accounts.decodeUnchecked.bind(this.receiver.account.priceUpdateV2.coder.accounts);
|
|
23
26
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_RECEIVER_PROGRAM_ID = exports.DEFAULT_WORMHOLE_PROGRAM_ID = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
exports.DEFAULT_WORMHOLE_PROGRAM_ID = new web3_js_1.PublicKey('HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ');
|
|
6
|
+
exports.DEFAULT_RECEIVER_PROGRAM_ID = new web3_js_1.PublicKey('rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ');
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGuardianSetPda = exports.DEFAULT_RECEIVER_PROGRAM_ID = exports.DEFAULT_WORMHOLE_PROGRAM_ID = exports.WORMHOLE_CORE_BRIDGE_SOLANA_IDL = void 0;
|
|
4
|
+
var types_1 = require("./types");
|
|
5
|
+
Object.defineProperty(exports, "WORMHOLE_CORE_BRIDGE_SOLANA_IDL", { enumerable: true, get: function () { return types_1.WORMHOLE_CORE_BRIDGE_SOLANA_IDL; } });
|
|
6
|
+
var constants_1 = require("./constants");
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_WORMHOLE_PROGRAM_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_WORMHOLE_PROGRAM_ID; } });
|
|
8
|
+
Object.defineProperty(exports, "DEFAULT_RECEIVER_PROGRAM_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_RECEIVER_PROGRAM_ID; } });
|
|
9
|
+
var utils_1 = require("./utils");
|
|
10
|
+
Object.defineProperty(exports, "getGuardianSetPda", { enumerable: true, get: function () { return utils_1.getGuardianSetPda; } });
|