@drift-labs/sdk 0.1.36-master.2 → 0.1.36-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/admin.js +1 -1
- package/lib/clearingHouse.d.ts +6 -4
- package/lib/clearingHouse.js +46 -8
- package/lib/examples/makeTradeExample.js +1 -1
- package/lib/factory/clearingHouse.js +4 -4
- package/lib/idl/clearing_house.json +377 -306
- package/lib/mockUSDCFaucet.d.ts +2 -2
- package/lib/mockUSDCFaucet.js +3 -3
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/tx/defaultTxSender.d.ts +3 -3
- package/lib/tx/defaultTxSender.js +1 -1
- package/lib/tx/retryTxSender.d.ts +3 -3
- package/package.json +2 -2
- package/src/accounts/webSocketAccountSubscriber.ts +3 -3
- package/src/admin.ts +2 -2
- package/src/clearingHouse.ts +81 -10
- package/src/examples/makeTradeExample.ts +6 -2
- package/src/factory/clearingHouse.ts +13 -5
- package/src/idl/clearing_house.json +377 -306
- package/src/mockUSDCFaucet.ts +5 -5
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/tx/defaultTxSender.ts +4 -4
- package/src/tx/retryTxSender.ts +3 -3
package/src/mockUSDCFaucet.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as anchor from '@project-serum/anchor';
|
|
2
|
-
import { Idl, Program
|
|
2
|
+
import { AnchorProvider, Idl, Program } from '@project-serum/anchor';
|
|
3
3
|
import {
|
|
4
4
|
AccountInfo,
|
|
5
5
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
@@ -25,7 +25,7 @@ export class MockUSDCFaucet {
|
|
|
25
25
|
connection: Connection;
|
|
26
26
|
wallet: IWallet;
|
|
27
27
|
public program: Program;
|
|
28
|
-
provider:
|
|
28
|
+
provider: AnchorProvider;
|
|
29
29
|
opts?: ConfirmOptions;
|
|
30
30
|
|
|
31
31
|
public constructor(
|
|
@@ -36,8 +36,8 @@ export class MockUSDCFaucet {
|
|
|
36
36
|
) {
|
|
37
37
|
this.connection = connection;
|
|
38
38
|
this.wallet = wallet;
|
|
39
|
-
this.opts = opts ||
|
|
40
|
-
const provider = new
|
|
39
|
+
this.opts = opts || AnchorProvider.defaultOptions();
|
|
40
|
+
const provider = new AnchorProvider(connection, wallet, this.opts);
|
|
41
41
|
this.provider = provider;
|
|
42
42
|
this.program = new Program(mockUSDCFaucetIDL as Idl, programId, provider);
|
|
43
43
|
}
|
|
@@ -140,7 +140,7 @@ export class MockUSDCFaucet {
|
|
|
140
140
|
amount
|
|
141
141
|
);
|
|
142
142
|
const tx = new Transaction().add(createAssociatedAccountIx).add(mintToTx);
|
|
143
|
-
const txSig = await this.program.provider.
|
|
143
|
+
const txSig = await this.program.provider.sendAndConfirm(tx, [], this.opts);
|
|
144
144
|
return [associatedTokenPublicKey, txSig];
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from '@switchboard-xyz/switchboard-v2';
|
|
5
5
|
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
6
6
|
import { DriftEnv } from '../config';
|
|
7
|
-
import { BN,
|
|
7
|
+
import { BN, Program, Idl, AnchorProvider } from '@project-serum/anchor';
|
|
8
8
|
import { MARK_PRICE_PRECISION, TEN } from '../constants/numericConstants';
|
|
9
9
|
import { OracleClient, OraclePriceData } from './types';
|
|
10
10
|
import { Wallet } from '../wallet';
|
|
@@ -74,7 +74,7 @@ async function getSwitchboardProgram(
|
|
|
74
74
|
const DEFAULT_KEYPAIR = Keypair.fromSeed(new Uint8Array(32).fill(1));
|
|
75
75
|
const programId = getSwitchboardPid(env);
|
|
76
76
|
const wallet = new Wallet(DEFAULT_KEYPAIR);
|
|
77
|
-
const provider = new
|
|
77
|
+
const provider = new AnchorProvider(connection, wallet, {});
|
|
78
78
|
|
|
79
79
|
return new Program(switchboardV2Idl as Idl, programId, provider);
|
|
80
80
|
}
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
Transaction,
|
|
6
6
|
TransactionSignature,
|
|
7
7
|
} from '@solana/web3.js';
|
|
8
|
-
import {
|
|
8
|
+
import { AnchorProvider } from '@project-serum/anchor';
|
|
9
9
|
|
|
10
10
|
export class DefaultTxSender implements TxSender {
|
|
11
|
-
provider:
|
|
11
|
+
provider: AnchorProvider;
|
|
12
12
|
|
|
13
|
-
public constructor(provider:
|
|
13
|
+
public constructor(provider: AnchorProvider) {
|
|
14
14
|
this.provider = provider;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -19,6 +19,6 @@ export class DefaultTxSender implements TxSender {
|
|
|
19
19
|
additionalSigners?: Array<Signer>,
|
|
20
20
|
opts?: ConfirmOptions
|
|
21
21
|
): Promise<TransactionSignature> {
|
|
22
|
-
return this.provider.
|
|
22
|
+
return this.provider.sendAndConfirm(tx, additionalSigners, opts);
|
|
23
23
|
}
|
|
24
24
|
}
|
package/src/tx/retryTxSender.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
TransactionSignature,
|
|
11
11
|
Connection,
|
|
12
12
|
} from '@solana/web3.js';
|
|
13
|
-
import {
|
|
13
|
+
import { AnchorProvider } from '@project-serum/anchor';
|
|
14
14
|
import assert from 'assert';
|
|
15
15
|
import bs58 from 'bs58';
|
|
16
16
|
|
|
@@ -22,13 +22,13 @@ type ResolveReference = {
|
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
export class RetryTxSender implements TxSender {
|
|
25
|
-
provider:
|
|
25
|
+
provider: AnchorProvider;
|
|
26
26
|
timeout: number;
|
|
27
27
|
retrySleep: number;
|
|
28
28
|
additionalConnections: Connection[];
|
|
29
29
|
|
|
30
30
|
public constructor(
|
|
31
|
-
provider:
|
|
31
|
+
provider: AnchorProvider,
|
|
32
32
|
timeout?: number,
|
|
33
33
|
retrySleep?: number,
|
|
34
34
|
additionalConnections = new Array<Connection>()
|