@acta-markets/ts-sdk 0.0.1-beta
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/README.md +308 -0
- package/dist/actaClient.d.ts +46 -0
- package/dist/actaClient.js +99 -0
- package/dist/chain/client.d.ts +65 -0
- package/dist/chain/client.js +82 -0
- package/dist/chain/fetch.d.ts +204 -0
- package/dist/chain/fetch.js +392 -0
- package/dist/chain/fetch.test.d.ts +1 -0
- package/dist/chain/fetch.test.js +158 -0
- package/dist/chain/flows/index.d.ts +1 -0
- package/dist/chain/flows/index.js +1 -0
- package/dist/chain/flows/openPosition.d.ts +48 -0
- package/dist/chain/flows/openPosition.js +78 -0
- package/dist/chain/flows/openPosition.test.d.ts +1 -0
- package/dist/chain/flows/openPosition.test.js +43 -0
- package/dist/chain/helpers.d.ts +16 -0
- package/dist/chain/helpers.js +60 -0
- package/dist/chain/index.d.ts +9 -0
- package/dist/chain/index.js +9 -0
- package/dist/chain/instructions.admin.d.ts +44 -0
- package/dist/chain/instructions.admin.js +113 -0
- package/dist/chain/instructions.d.ts +5 -0
- package/dist/chain/instructions.js +5 -0
- package/dist/chain/instructions.maker.d.ts +34 -0
- package/dist/chain/instructions.maker.js +86 -0
- package/dist/chain/instructions.market.d.ts +39 -0
- package/dist/chain/instructions.market.js +107 -0
- package/dist/chain/instructions.oracle.d.ts +38 -0
- package/dist/chain/instructions.oracle.js +63 -0
- package/dist/chain/instructions.position.d.ts +82 -0
- package/dist/chain/instructions.position.js +240 -0
- package/dist/chain/instructions.resolve.test.d.ts +1 -0
- package/dist/chain/instructions.resolve.test.js +32 -0
- package/dist/chain/instructions.shared.d.ts +23 -0
- package/dist/chain/instructions.shared.js +55 -0
- package/dist/chain/orders.d.ts +40 -0
- package/dist/chain/orders.js +117 -0
- package/dist/chain/orders.test.d.ts +1 -0
- package/dist/chain/orders.test.js +67 -0
- package/dist/chain/signers.d.ts +9 -0
- package/dist/chain/signers.js +19 -0
- package/dist/chain/signers.test.d.ts +1 -0
- package/dist/chain/signers.test.js +13 -0
- package/dist/chain/token.d.ts +59 -0
- package/dist/chain/token.js +136 -0
- package/dist/chain/token.test.d.ts +1 -0
- package/dist/chain/token.test.js +69 -0
- package/dist/chain/tx.d.ts +72 -0
- package/dist/chain/tx.js +97 -0
- package/dist/cjs/actaClient.js +103 -0
- package/dist/cjs/chain/client.js +119 -0
- package/dist/cjs/chain/fetch.js +431 -0
- package/dist/cjs/chain/fetch.test.js +160 -0
- package/dist/cjs/chain/flows/index.js +17 -0
- package/dist/cjs/chain/flows/openPosition.js +81 -0
- package/dist/cjs/chain/flows/openPosition.test.js +45 -0
- package/dist/cjs/chain/helpers.js +67 -0
- package/dist/cjs/chain/index.js +48 -0
- package/dist/cjs/chain/instructions.admin.js +119 -0
- package/dist/cjs/chain/instructions.js +21 -0
- package/dist/cjs/chain/instructions.maker.js +92 -0
- package/dist/cjs/chain/instructions.market.js +112 -0
- package/dist/cjs/chain/instructions.oracle.js +70 -0
- package/dist/cjs/chain/instructions.position.js +247 -0
- package/dist/cjs/chain/instructions.resolve.test.js +34 -0
- package/dist/cjs/chain/instructions.shared.js +64 -0
- package/dist/cjs/chain/orders.js +126 -0
- package/dist/cjs/chain/orders.test.js +69 -0
- package/dist/cjs/chain/signers.js +22 -0
- package/dist/cjs/chain/signers.test.js +15 -0
- package/dist/cjs/chain/token.js +147 -0
- package/dist/cjs/chain/token.test.js +71 -0
- package/dist/cjs/chain/tx.js +103 -0
- package/dist/cjs/constants.js +6 -0
- package/dist/cjs/constants.test.js +31 -0
- package/dist/cjs/events.js +75 -0
- package/dist/cjs/events.test.js +384 -0
- package/dist/cjs/generated/accounts/config.js +79 -0
- package/dist/cjs/generated/accounts/index.js +28 -0
- package/dist/cjs/generated/accounts/maker.js +71 -0
- package/dist/cjs/generated/accounts/market.js +93 -0
- package/dist/cjs/generated/accounts/oracle.js +85 -0
- package/dist/cjs/generated/accounts/position.js +89 -0
- package/dist/cjs/generated/errors/actaContract.js +154 -0
- package/dist/cjs/generated/errors/index.js +24 -0
- package/dist/cjs/generated/index.js +28 -0
- package/dist/cjs/generated/instructions/changeOracleSource.js +81 -0
- package/dist/cjs/generated/instructions/closeMarket.js +83 -0
- package/dist/cjs/generated/instructions/closeOracle.js +79 -0
- package/dist/cjs/generated/instructions/createMarket.js +116 -0
- package/dist/cjs/generated/instructions/createOracle.js +99 -0
- package/dist/cjs/generated/instructions/depositFundsToPosition.js +101 -0
- package/dist/cjs/generated/instructions/depositPremium.js +96 -0
- package/dist/cjs/generated/instructions/finalizeMarket.js +91 -0
- package/dist/cjs/generated/instructions/index.js +43 -0
- package/dist/cjs/generated/instructions/initializeConfig.js +108 -0
- package/dist/cjs/generated/instructions/liquidatePosition.js +107 -0
- package/dist/cjs/generated/instructions/openPosition.js +154 -0
- package/dist/cjs/generated/instructions/registerMaker.js +90 -0
- package/dist/cjs/generated/instructions/setOracleConfig.js +80 -0
- package/dist/cjs/generated/instructions/settlePosition.js +104 -0
- package/dist/cjs/generated/instructions/topupFeeFund.js +96 -0
- package/dist/cjs/generated/instructions/updateConfig.js +86 -0
- package/dist/cjs/generated/instructions/updateMakerQuoteSigning.js +79 -0
- package/dist/cjs/generated/instructions/updateMarketOracles.js +96 -0
- package/dist/cjs/generated/instructions/updateOraclePrice.js +89 -0
- package/dist/cjs/generated/instructions/withdrawFromFeeFund.js +96 -0
- package/dist/cjs/generated/instructions/withdrawPremium.js +96 -0
- package/dist/cjs/generated/programs/actaContract.js +108 -0
- package/dist/cjs/generated/programs/index.js +24 -0
- package/dist/cjs/generated/shared/index.js +94 -0
- package/dist/cjs/generated/types/actaEvent.js +342 -0
- package/dist/cjs/generated/types/eventKind.js +45 -0
- package/dist/cjs/generated/types/index.js +27 -0
- package/dist/cjs/generated/types/positionStatus.js +31 -0
- package/dist/cjs/generated/types/positionType.js +28 -0
- package/dist/cjs/idl/acta_contract.json +2329 -0
- package/dist/cjs/idl/hash.js +4 -0
- package/dist/cjs/index.js +84 -0
- package/dist/cjs/nonce.js +93 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/cjs/types/orderId.js +40 -0
- package/dist/cjs/types/orders.js +10 -0
- package/dist/cjs/ws/apy.js +106 -0
- package/dist/cjs/ws/apy.test.js +29 -0
- package/dist/cjs/ws/auth.js +104 -0
- package/dist/cjs/ws/client.handshake.integration.test.js +69 -0
- package/dist/cjs/ws/client.js +861 -0
- package/dist/cjs/ws/client.test.js +230 -0
- package/dist/cjs/ws/discovery.js +48 -0
- package/dist/cjs/ws/flows.js +101 -0
- package/dist/cjs/ws/flows.test.js +85 -0
- package/dist/cjs/ws/index.js +23 -0
- package/dist/cjs/ws/sponsoredTx.js +95 -0
- package/dist/cjs/ws/types.js +14 -0
- package/dist/cjs/ws/wirePolicy.js +34 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/constants.test.d.ts +1 -0
- package/dist/constants.test.js +29 -0
- package/dist/events.d.ts +15 -0
- package/dist/events.js +64 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +382 -0
- package/dist/generated/accounts/config.d.ts +47 -0
- package/dist/generated/accounts/config.js +68 -0
- package/dist/generated/accounts/index.d.ts +12 -0
- package/dist/generated/accounts/index.js +12 -0
- package/dist/generated/accounts/maker.d.ts +39 -0
- package/dist/generated/accounts/maker.js +60 -0
- package/dist/generated/accounts/market.d.ts +61 -0
- package/dist/generated/accounts/market.js +82 -0
- package/dist/generated/accounts/oracle.d.ts +53 -0
- package/dist/generated/accounts/oracle.js +74 -0
- package/dist/generated/accounts/position.d.ts +57 -0
- package/dist/generated/accounts/position.js +78 -0
- package/dist/generated/errors/actaContract.d.ts +103 -0
- package/dist/generated/errors/actaContract.js +149 -0
- package/dist/generated/errors/index.d.ts +8 -0
- package/dist/generated/errors/index.js +8 -0
- package/dist/generated/index.d.ts +12 -0
- package/dist/generated/index.js +12 -0
- package/dist/generated/instructions/changeOracleSource.d.ts +50 -0
- package/dist/generated/instructions/changeOracleSource.js +72 -0
- package/dist/generated/instructions/closeMarket.d.ts +58 -0
- package/dist/generated/instructions/closeMarket.js +74 -0
- package/dist/generated/instructions/closeOracle.d.ts +48 -0
- package/dist/generated/instructions/closeOracle.js +70 -0
- package/dist/generated/instructions/createMarket.d.ts +90 -0
- package/dist/generated/instructions/createMarket.js +107 -0
- package/dist/generated/instructions/createOracle.d.ts +71 -0
- package/dist/generated/instructions/createOracle.js +90 -0
- package/dist/generated/instructions/depositFundsToPosition.d.ts +73 -0
- package/dist/generated/instructions/depositFundsToPosition.js +92 -0
- package/dist/generated/instructions/depositPremium.d.ts +62 -0
- package/dist/generated/instructions/depositPremium.js +87 -0
- package/dist/generated/instructions/finalizeMarket.d.ts +63 -0
- package/dist/generated/instructions/finalizeMarket.js +82 -0
- package/dist/generated/instructions/index.d.ts +27 -0
- package/dist/generated/instructions/index.js +27 -0
- package/dist/generated/instructions/initializeConfig.d.ts +75 -0
- package/dist/generated/instructions/initializeConfig.js +99 -0
- package/dist/generated/instructions/liquidatePosition.d.ts +78 -0
- package/dist/generated/instructions/liquidatePosition.js +98 -0
- package/dist/generated/instructions/openPosition.d.ts +130 -0
- package/dist/generated/instructions/openPosition.js +145 -0
- package/dist/generated/instructions/registerMaker.d.ts +57 -0
- package/dist/generated/instructions/registerMaker.js +81 -0
- package/dist/generated/instructions/setOracleConfig.d.ts +53 -0
- package/dist/generated/instructions/setOracleConfig.js +71 -0
- package/dist/generated/instructions/settlePosition.d.ts +78 -0
- package/dist/generated/instructions/settlePosition.js +95 -0
- package/dist/generated/instructions/topupFeeFund.d.ts +67 -0
- package/dist/generated/instructions/topupFeeFund.js +87 -0
- package/dist/generated/instructions/updateConfig.d.ts +58 -0
- package/dist/generated/instructions/updateConfig.js +77 -0
- package/dist/generated/instructions/updateMakerQuoteSigning.d.ts +47 -0
- package/dist/generated/instructions/updateMakerQuoteSigning.js +70 -0
- package/dist/generated/instructions/updateMarketOracles.d.ts +65 -0
- package/dist/generated/instructions/updateMarketOracles.js +87 -0
- package/dist/generated/instructions/updateOraclePrice.d.ts +55 -0
- package/dist/generated/instructions/updateOraclePrice.js +80 -0
- package/dist/generated/instructions/withdrawFromFeeFund.d.ts +62 -0
- package/dist/generated/instructions/withdrawFromFeeFund.js +87 -0
- package/dist/generated/instructions/withdrawPremium.d.ts +62 -0
- package/dist/generated/instructions/withdrawPremium.js +87 -0
- package/dist/generated/programs/actaContract.d.ts +83 -0
- package/dist/generated/programs/actaContract.js +104 -0
- package/dist/generated/programs/index.d.ts +8 -0
- package/dist/generated/programs/index.js +8 -0
- package/dist/generated/shared/index.d.ts +49 -0
- package/dist/generated/shared/index.js +86 -0
- package/dist/generated/types/actaEvent.d.ts +249 -0
- package/dist/generated/types/actaEvent.js +335 -0
- package/dist/generated/types/eventKind.d.ts +33 -0
- package/dist/generated/types/eventKind.js +39 -0
- package/dist/generated/types/index.d.ts +11 -0
- package/dist/generated/types/index.js +11 -0
- package/dist/generated/types/positionStatus.d.ts +19 -0
- package/dist/generated/types/positionStatus.js +25 -0
- package/dist/generated/types/positionType.d.ts +16 -0
- package/dist/generated/types/positionType.js +22 -0
- package/dist/idl/acta_contract.json +2329 -0
- package/dist/idl/hash.d.ts +1 -0
- package/dist/idl/hash.js +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +34 -0
- package/dist/nonce.d.ts +29 -0
- package/dist/nonce.js +89 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/orderId.d.ts +13 -0
- package/dist/types/orderId.js +35 -0
- package/dist/types/orders.d.ts +9 -0
- package/dist/types/orders.js +9 -0
- package/dist/ws/apy.d.ts +79 -0
- package/dist/ws/apy.js +98 -0
- package/dist/ws/apy.test.d.ts +1 -0
- package/dist/ws/apy.test.js +27 -0
- package/dist/ws/auth.d.ts +67 -0
- package/dist/ws/auth.js +98 -0
- package/dist/ws/client.d.ts +263 -0
- package/dist/ws/client.handshake.integration.test.d.ts +1 -0
- package/dist/ws/client.handshake.integration.test.js +64 -0
- package/dist/ws/client.js +857 -0
- package/dist/ws/client.test.d.ts +1 -0
- package/dist/ws/client.test.js +228 -0
- package/dist/ws/discovery.d.ts +13 -0
- package/dist/ws/discovery.js +44 -0
- package/dist/ws/flows.d.ts +44 -0
- package/dist/ws/flows.js +96 -0
- package/dist/ws/flows.test.d.ts +1 -0
- package/dist/ws/flows.test.js +83 -0
- package/dist/ws/index.d.ts +7 -0
- package/dist/ws/index.js +7 -0
- package/dist/ws/sponsoredTx.d.ts +39 -0
- package/dist/ws/sponsoredTx.js +92 -0
- package/dist/ws/types.d.ts +900 -0
- package/dist/ws/types.js +13 -0
- package/dist/ws/wirePolicy.d.ts +12 -0
- package/dist/ws/wirePolicy.js +30 -0
- package/package.json +87 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { Address } from "@solana/addresses";
|
|
2
|
+
import { createSolanaRpc } from "@solana/rpc";
|
|
3
|
+
import type { Base58EncodedBytes, Commitment } from "@solana/rpc-types";
|
|
4
|
+
import { type Config } from "../generated/accounts/config";
|
|
5
|
+
import { type Market } from "../generated/accounts/market";
|
|
6
|
+
import { type Oracle } from "../generated/accounts/oracle";
|
|
7
|
+
import { type Position } from "../generated/accounts/position";
|
|
8
|
+
import { type Maker } from "../generated/accounts/maker";
|
|
9
|
+
import { Buffer } from "buffer";
|
|
10
|
+
export declare const POSITION_OFFSET_STATUS = 4;
|
|
11
|
+
export declare const POSITION_OFFSET_TAKER_OWNER = 8;
|
|
12
|
+
export declare const POSITION_OFFSET_MAKER_OWNER = 40;
|
|
13
|
+
export declare const POSITION_OFFSET_MARKET = 72;
|
|
14
|
+
export declare const MARKET_OFFSET_UNDERLYING_DECIMALS = 3;
|
|
15
|
+
export declare const MARKET_OFFSET_QUOTE_DECIMALS = 4;
|
|
16
|
+
export declare const MARKET_OFFSET_FLAGS = 5;
|
|
17
|
+
export declare const MARKET_OFFSET_EXPIRY_TS = 8;
|
|
18
|
+
export declare const MARKET_OFFSET_SETTLEMENT_PRICE = 16;
|
|
19
|
+
export declare const MARKET_OFFSET_UNDERLYING_MINT = 32;
|
|
20
|
+
export declare const MARKET_OFFSET_QUOTE_MINT = 64;
|
|
21
|
+
export declare const MARKET_OFFSET_UNDERLYING_ORACLE_ADDRESS = 160;
|
|
22
|
+
export declare const MARKET_OFFSET_QUOTE_ORACLE_ADDRESS = 192;
|
|
23
|
+
export declare const ORACLE_OFFSET_ORACLE_TYPE = 3;
|
|
24
|
+
export declare const ORACLE_OFFSET_FLAGS = 4;
|
|
25
|
+
export declare const ORACLE_OFFSET_DECIMALS = 5;
|
|
26
|
+
export declare const ORACLE_OFFSET_ACTIVE_MARKETS_COUNT = 6;
|
|
27
|
+
export declare const ORACLE_OFFSET_PRICE = 8;
|
|
28
|
+
export declare const ORACLE_OFFSET_UPDATED_AT = 16;
|
|
29
|
+
export declare const ORACLE_OFFSET_EXPIRY_TS = 24;
|
|
30
|
+
export declare const ORACLE_OFFSET_MINT = 32;
|
|
31
|
+
export declare const ORACLE_OFFSET_AUTHORITY = 64;
|
|
32
|
+
export declare const ORACLE_OFFSET_FEED_ID = 96;
|
|
33
|
+
export declare const MAKER_OFFSET_MAKER_OWNER = 4;
|
|
34
|
+
export declare const MAKER_OFFSET_QUOTE_SIGNING = 36;
|
|
35
|
+
export declare const POSITION_ACCOUNT_DISCRIMINATOR = 1;
|
|
36
|
+
export declare const MAKER_ACCOUNT_DISCRIMINATOR = 2;
|
|
37
|
+
export declare const CONFIG_ACCOUNT_DISCRIMINATOR = 3;
|
|
38
|
+
export declare const MARKET_ACCOUNT_DISCRIMINATOR = 4;
|
|
39
|
+
export declare const ORACLE_ACCOUNT_DISCRIMINATOR = 5;
|
|
40
|
+
export declare const POSITION_ACCOUNT_SIZE_BYTES = 416;
|
|
41
|
+
export declare const MAKER_ACCOUNT_SIZE_BYTES = 328;
|
|
42
|
+
export declare const CONFIG_ACCOUNT_SIZE_BYTES = 392;
|
|
43
|
+
export declare const MARKET_ACCOUNT_SIZE_BYTES = 416;
|
|
44
|
+
export declare const ORACLE_ACCOUNT_SIZE_BYTES = 384;
|
|
45
|
+
type FetchOptions = {
|
|
46
|
+
commitment?: Commitment;
|
|
47
|
+
dataSlice?: {
|
|
48
|
+
offset: number;
|
|
49
|
+
length: number;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type Rpc = ReturnType<typeof createSolanaRpc>;
|
|
53
|
+
export type DecodedPositionAccount = ReturnType<typeof decodePositionAccount>;
|
|
54
|
+
export type DecodedMarketAccount = ReturnType<typeof decodeMarketAccount>;
|
|
55
|
+
export type DecodedConfigAccount = ReturnType<typeof decodeConfigAccount>;
|
|
56
|
+
export type DecodedOracleAccount = ReturnType<typeof decodeOracleAccount>;
|
|
57
|
+
type DecodedAccount<T> = {
|
|
58
|
+
pubkey: Address<string>;
|
|
59
|
+
account: T;
|
|
60
|
+
};
|
|
61
|
+
export declare function fetchPositionsByMaker(rpc: Rpc, makerOwner: Address<string>, options?: FetchOptions): Promise<Readonly<{
|
|
62
|
+
account: Readonly<{
|
|
63
|
+
executable: boolean;
|
|
64
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
65
|
+
owner: Address;
|
|
66
|
+
space: bigint;
|
|
67
|
+
}> & Readonly<{
|
|
68
|
+
data: Base58EncodedBytes;
|
|
69
|
+
}>;
|
|
70
|
+
pubkey: Address;
|
|
71
|
+
}>[]>;
|
|
72
|
+
export declare function fetchPositionsByMakerDecoded(rpc: Rpc, makerOwner: Address<string>, options?: FetchOptions): Promise<DecodedAccount<DecodedPositionAccount>[]>;
|
|
73
|
+
export declare function fetchPositionsByTaker(rpc: Rpc, takerOwner: Address<string>, options?: FetchOptions): Promise<Readonly<{
|
|
74
|
+
account: Readonly<{
|
|
75
|
+
executable: boolean;
|
|
76
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
77
|
+
owner: Address;
|
|
78
|
+
space: bigint;
|
|
79
|
+
}> & Readonly<{
|
|
80
|
+
data: Base58EncodedBytes;
|
|
81
|
+
}>;
|
|
82
|
+
pubkey: Address;
|
|
83
|
+
}>[]>;
|
|
84
|
+
export declare function fetchPositionsByTakerDecoded(rpc: Rpc, takerOwner: Address<string>, options?: FetchOptions): Promise<DecodedAccount<DecodedPositionAccount>[]>;
|
|
85
|
+
export declare function fetchPositionsByMarket(rpc: Rpc, market: Address<string>, options?: FetchOptions): Promise<Readonly<{
|
|
86
|
+
account: Readonly<{
|
|
87
|
+
executable: boolean;
|
|
88
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
89
|
+
owner: Address;
|
|
90
|
+
space: bigint;
|
|
91
|
+
}> & Readonly<{
|
|
92
|
+
data: Base58EncodedBytes;
|
|
93
|
+
}>;
|
|
94
|
+
pubkey: Address;
|
|
95
|
+
}>[]>;
|
|
96
|
+
export declare function fetchPositionsByMarketDecoded(rpc: Rpc, market: Address<string>, options?: FetchOptions): Promise<DecodedAccount<DecodedPositionAccount>[]>;
|
|
97
|
+
export declare function fetchPositionsByStatus(rpc: Rpc, status: number, options?: FetchOptions): Promise<Readonly<{
|
|
98
|
+
account: Readonly<{
|
|
99
|
+
executable: boolean;
|
|
100
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
101
|
+
owner: Address;
|
|
102
|
+
space: bigint;
|
|
103
|
+
}> & Readonly<{
|
|
104
|
+
data: Base58EncodedBytes;
|
|
105
|
+
}>;
|
|
106
|
+
pubkey: Address;
|
|
107
|
+
}>[]>;
|
|
108
|
+
export declare function fetchPositionsByMakerAndStatus(rpc: Rpc, makerOwner: Address<string>, status: number, options?: FetchOptions): Promise<Readonly<{
|
|
109
|
+
account: Readonly<{
|
|
110
|
+
executable: boolean;
|
|
111
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
112
|
+
owner: Address;
|
|
113
|
+
space: bigint;
|
|
114
|
+
}> & Readonly<{
|
|
115
|
+
data: Base58EncodedBytes;
|
|
116
|
+
}>;
|
|
117
|
+
pubkey: Address;
|
|
118
|
+
}>[]>;
|
|
119
|
+
export declare function fetchPositionsByMarketAndStatus(rpc: Rpc, market: Address<string>, status: number, options?: FetchOptions): Promise<Readonly<{
|
|
120
|
+
account: Readonly<{
|
|
121
|
+
executable: boolean;
|
|
122
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
123
|
+
owner: Address;
|
|
124
|
+
space: bigint;
|
|
125
|
+
}> & Readonly<{
|
|
126
|
+
data: Base58EncodedBytes;
|
|
127
|
+
}>;
|
|
128
|
+
pubkey: Address;
|
|
129
|
+
}>[]>;
|
|
130
|
+
export declare function fetchPositionsByStatusDecoded(rpc: Rpc, status: number, options?: FetchOptions): Promise<DecodedAccount<DecodedPositionAccount>[]>;
|
|
131
|
+
export declare function fetchAllConfigsDecoded(rpc: Rpc, options?: FetchOptions): Promise<DecodedAccount<DecodedConfigAccount>[]>;
|
|
132
|
+
export declare function fetchAllMakersDecoded(rpc: Rpc, options?: FetchOptions): Promise<DecodedAccount<ReturnType<typeof decodeMakerAccount>>[]>;
|
|
133
|
+
export declare function fetchAllMarketsDecoded(rpc: Rpc, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
134
|
+
export declare function fetchAllOraclesDecoded(rpc: Rpc, options?: FetchOptions): Promise<DecodedAccount<DecodedOracleAccount>[]>;
|
|
135
|
+
export declare function fetchAllPositionsDecoded(rpc: Rpc, options?: FetchOptions): Promise<DecodedAccount<DecodedPositionAccount>[]>;
|
|
136
|
+
export declare function fetchMarketsByUnderlying(rpc: Rpc, underlying: Address<string>, options?: FetchOptions): Promise<Readonly<{
|
|
137
|
+
account: Readonly<{
|
|
138
|
+
executable: boolean;
|
|
139
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
140
|
+
owner: Address;
|
|
141
|
+
space: bigint;
|
|
142
|
+
}> & Readonly<{
|
|
143
|
+
data: Base58EncodedBytes;
|
|
144
|
+
}>;
|
|
145
|
+
pubkey: Address;
|
|
146
|
+
}>[]>;
|
|
147
|
+
export declare function fetchMarketsByUnderlyingDecoded(rpc: Rpc, underlying: Address<string>, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
148
|
+
export declare function fetchMarketsByQuote(rpc: Rpc, quote: Address<string>, options?: FetchOptions): Promise<Readonly<{
|
|
149
|
+
account: Readonly<{
|
|
150
|
+
executable: boolean;
|
|
151
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
152
|
+
owner: Address;
|
|
153
|
+
space: bigint;
|
|
154
|
+
}> & Readonly<{
|
|
155
|
+
data: Base58EncodedBytes;
|
|
156
|
+
}>;
|
|
157
|
+
pubkey: Address;
|
|
158
|
+
}>[]>;
|
|
159
|
+
export declare function fetchMarketsByQuoteDecoded(rpc: Rpc, quote: Address<string>, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
160
|
+
export declare function fetchMarketsByExpiry(rpc: Rpc, expiryTs: bigint | number, options?: FetchOptions): Promise<Readonly<{
|
|
161
|
+
account: Readonly<{
|
|
162
|
+
executable: boolean;
|
|
163
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
164
|
+
owner: Address;
|
|
165
|
+
space: bigint;
|
|
166
|
+
}> & Readonly<{
|
|
167
|
+
data: Base58EncodedBytes;
|
|
168
|
+
}>;
|
|
169
|
+
pubkey: Address;
|
|
170
|
+
}>[]>;
|
|
171
|
+
export declare function fetchMarketsByExpiryDecoded(rpc: Rpc, expiryTs: bigint | number, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
172
|
+
export declare function fetchMarketsByQuoteAndExpiry(rpc: Rpc, quote: Address<string>, expiryTs: bigint | number, options?: FetchOptions): Promise<Readonly<{
|
|
173
|
+
account: Readonly<{
|
|
174
|
+
executable: boolean;
|
|
175
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
176
|
+
owner: Address;
|
|
177
|
+
space: bigint;
|
|
178
|
+
}> & Readonly<{
|
|
179
|
+
data: Base58EncodedBytes;
|
|
180
|
+
}>;
|
|
181
|
+
pubkey: Address;
|
|
182
|
+
}>[]>;
|
|
183
|
+
export declare function fetchMarketsByQuoteAndExpiryDecoded(rpc: Rpc, quote: Address<string>, expiryTs: bigint | number, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
184
|
+
export declare function fetchMarketsByUnderlyingAndExpiry(rpc: Rpc, underlying: Address<string>, expiryTs: bigint | number, options?: FetchOptions): Promise<Readonly<{
|
|
185
|
+
account: Readonly<{
|
|
186
|
+
executable: boolean;
|
|
187
|
+
lamports: import("@solana/rpc-types").Lamports;
|
|
188
|
+
owner: Address;
|
|
189
|
+
space: bigint;
|
|
190
|
+
}> & Readonly<{
|
|
191
|
+
data: Base58EncodedBytes;
|
|
192
|
+
}>;
|
|
193
|
+
pubkey: Address;
|
|
194
|
+
}>[]>;
|
|
195
|
+
export declare function fetchConfigAccountByAddress(rpc: Rpc, address: Address<string>, commitment?: Commitment): Promise<DecodedAccount<DecodedConfigAccount>>;
|
|
196
|
+
export declare function fetchMarketAccountByAddress(rpc: Rpc, address: Address<string>, commitment?: Commitment): Promise<DecodedAccount<DecodedMarketAccount>>;
|
|
197
|
+
export declare function fetchOracleAccountByAddress(rpc: Rpc, address: Address<string>, commitment?: Commitment): Promise<DecodedAccount<DecodedOracleAccount>>;
|
|
198
|
+
export declare function fetchMarketsByUnderlyingAndExpiryDecoded(rpc: Rpc, underlying: Address<string>, expiryTs: bigint | number, options?: FetchOptions): Promise<DecodedAccount<DecodedMarketAccount>[]>;
|
|
199
|
+
export declare function decodePositionAccount(data: Buffer): Position;
|
|
200
|
+
export declare function decodeMarketAccount(data: Buffer): Market;
|
|
201
|
+
export declare function decodeConfigAccount(data: Buffer): Config;
|
|
202
|
+
export declare function decodeMakerAccount(data: Buffer): Maker;
|
|
203
|
+
export declare function decodeOracleAccount(data: Buffer): Oracle;
|
|
204
|
+
export {};
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { getAddressEncoder } from "@solana/addresses";
|
|
2
|
+
import { fetchConfig as fetchGeneratedConfig, getConfigDecoder, } from "../generated/accounts/config";
|
|
3
|
+
import { fetchMarket as fetchGeneratedMarket, getMarketDecoder, } from "../generated/accounts/market";
|
|
4
|
+
import { fetchOracle as fetchGeneratedOracle, getOracleDecoder, } from "../generated/accounts/oracle";
|
|
5
|
+
import { getPositionDecoder, } from "../generated/accounts/position";
|
|
6
|
+
import { getMakerDecoder } from "../generated/accounts/maker";
|
|
7
|
+
import { getActaProgramId } from "../index";
|
|
8
|
+
import { Buffer } from "buffer";
|
|
9
|
+
import bs58 from "bs58";
|
|
10
|
+
// Offsets match Rust account layouts (discriminator is the first field).
|
|
11
|
+
export const POSITION_OFFSET_STATUS = 4;
|
|
12
|
+
export const POSITION_OFFSET_TAKER_OWNER = 8;
|
|
13
|
+
export const POSITION_OFFSET_MAKER_OWNER = 40;
|
|
14
|
+
export const POSITION_OFFSET_MARKET = 72;
|
|
15
|
+
export const MARKET_OFFSET_UNDERLYING_DECIMALS = 3;
|
|
16
|
+
export const MARKET_OFFSET_QUOTE_DECIMALS = 4;
|
|
17
|
+
export const MARKET_OFFSET_FLAGS = 5;
|
|
18
|
+
export const MARKET_OFFSET_EXPIRY_TS = 8;
|
|
19
|
+
export const MARKET_OFFSET_SETTLEMENT_PRICE = 16;
|
|
20
|
+
export const MARKET_OFFSET_UNDERLYING_MINT = 32;
|
|
21
|
+
export const MARKET_OFFSET_QUOTE_MINT = 64;
|
|
22
|
+
export const MARKET_OFFSET_UNDERLYING_ORACLE_ADDRESS = 160;
|
|
23
|
+
export const MARKET_OFFSET_QUOTE_ORACLE_ADDRESS = 192;
|
|
24
|
+
export const ORACLE_OFFSET_ORACLE_TYPE = 3;
|
|
25
|
+
export const ORACLE_OFFSET_FLAGS = 4;
|
|
26
|
+
export const ORACLE_OFFSET_DECIMALS = 5;
|
|
27
|
+
export const ORACLE_OFFSET_ACTIVE_MARKETS_COUNT = 6;
|
|
28
|
+
export const ORACLE_OFFSET_PRICE = 8;
|
|
29
|
+
export const ORACLE_OFFSET_UPDATED_AT = 16;
|
|
30
|
+
export const ORACLE_OFFSET_EXPIRY_TS = 24;
|
|
31
|
+
export const ORACLE_OFFSET_MINT = 32;
|
|
32
|
+
export const ORACLE_OFFSET_AUTHORITY = 64;
|
|
33
|
+
export const ORACLE_OFFSET_FEED_ID = 96;
|
|
34
|
+
// Maker (account) offsets
|
|
35
|
+
export const MAKER_OFFSET_MAKER_OWNER = 4;
|
|
36
|
+
export const MAKER_OFFSET_QUOTE_SIGNING = 36;
|
|
37
|
+
// Account discriminators (first byte of account data).
|
|
38
|
+
export const POSITION_ACCOUNT_DISCRIMINATOR = 1;
|
|
39
|
+
export const MAKER_ACCOUNT_DISCRIMINATOR = 2;
|
|
40
|
+
export const CONFIG_ACCOUNT_DISCRIMINATOR = 3;
|
|
41
|
+
export const MARKET_ACCOUNT_DISCRIMINATOR = 4;
|
|
42
|
+
export const ORACLE_ACCOUNT_DISCRIMINATOR = 5;
|
|
43
|
+
// Account sizes (bytes). Note: Maker includes 4 bytes of padding on-chain.
|
|
44
|
+
export const POSITION_ACCOUNT_SIZE_BYTES = 416;
|
|
45
|
+
export const MAKER_ACCOUNT_SIZE_BYTES = 328;
|
|
46
|
+
export const CONFIG_ACCOUNT_SIZE_BYTES = 392;
|
|
47
|
+
export const MARKET_ACCOUNT_SIZE_BYTES = 416;
|
|
48
|
+
export const ORACLE_ACCOUNT_SIZE_BYTES = 384;
|
|
49
|
+
const addressEncoder = getAddressEncoder();
|
|
50
|
+
function memcmp(offset, addressOrBytes) {
|
|
51
|
+
const bytes = addressOrBytes instanceof Uint8Array
|
|
52
|
+
? bs58.encode(addressOrBytes)
|
|
53
|
+
: addressOrBytes;
|
|
54
|
+
return {
|
|
55
|
+
memcmp: {
|
|
56
|
+
offset: BigInt(offset),
|
|
57
|
+
bytes,
|
|
58
|
+
encoding: "base58",
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function u64Le(value) {
|
|
63
|
+
const buf = Buffer.alloc(8);
|
|
64
|
+
buf.writeBigUInt64LE(BigInt(value));
|
|
65
|
+
return buf;
|
|
66
|
+
}
|
|
67
|
+
function addrBytes(address) {
|
|
68
|
+
return Buffer.from(addressEncoder.encode(address));
|
|
69
|
+
}
|
|
70
|
+
async function fetchAndDecode(rpc, config, decode) {
|
|
71
|
+
// IMPORTANT: Solana JSON-RPC rejects base58 encoding for account data > 128 bytes.
|
|
72
|
+
// Always request base64 here, because we decode bytes locally.
|
|
73
|
+
const configWithEncoding = {
|
|
74
|
+
...config,
|
|
75
|
+
encoding: "base64",
|
|
76
|
+
};
|
|
77
|
+
const accounts = (await rpc
|
|
78
|
+
.getProgramAccounts(getActaProgramId(), configWithEncoding)
|
|
79
|
+
.send());
|
|
80
|
+
return accounts.map((acc) => {
|
|
81
|
+
const [b64] = acc.account.data;
|
|
82
|
+
const buf = Buffer.from(b64, "base64");
|
|
83
|
+
return { pubkey: acc.pubkey, account: decode(buf) };
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function dataSize(bytes) {
|
|
87
|
+
return { dataSize: BigInt(bytes) };
|
|
88
|
+
}
|
|
89
|
+
// --- Positions ---
|
|
90
|
+
export async function fetchPositionsByMaker(rpc, makerOwner, options) {
|
|
91
|
+
return rpc
|
|
92
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
93
|
+
commitment: options?.commitment,
|
|
94
|
+
dataSlice: options?.dataSlice,
|
|
95
|
+
filters: [
|
|
96
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
97
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
98
|
+
memcmp(POSITION_OFFSET_MAKER_OWNER, addrBytes(makerOwner)),
|
|
99
|
+
],
|
|
100
|
+
})
|
|
101
|
+
.send();
|
|
102
|
+
}
|
|
103
|
+
export async function fetchPositionsByMakerDecoded(rpc, makerOwner, options) {
|
|
104
|
+
return fetchAndDecode(rpc, {
|
|
105
|
+
commitment: options?.commitment,
|
|
106
|
+
dataSlice: options?.dataSlice,
|
|
107
|
+
filters: [
|
|
108
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
109
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
110
|
+
memcmp(POSITION_OFFSET_MAKER_OWNER, addrBytes(makerOwner)),
|
|
111
|
+
],
|
|
112
|
+
}, decodePositionAccount);
|
|
113
|
+
}
|
|
114
|
+
export async function fetchPositionsByTaker(rpc, takerOwner, options) {
|
|
115
|
+
return rpc
|
|
116
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
117
|
+
commitment: options?.commitment,
|
|
118
|
+
dataSlice: options?.dataSlice,
|
|
119
|
+
filters: [
|
|
120
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
121
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
122
|
+
memcmp(POSITION_OFFSET_TAKER_OWNER, addrBytes(takerOwner)),
|
|
123
|
+
],
|
|
124
|
+
})
|
|
125
|
+
.send();
|
|
126
|
+
}
|
|
127
|
+
export async function fetchPositionsByTakerDecoded(rpc, takerOwner, options) {
|
|
128
|
+
return fetchAndDecode(rpc, {
|
|
129
|
+
commitment: options?.commitment,
|
|
130
|
+
dataSlice: options?.dataSlice,
|
|
131
|
+
filters: [
|
|
132
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
133
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
134
|
+
memcmp(POSITION_OFFSET_TAKER_OWNER, addrBytes(takerOwner)),
|
|
135
|
+
],
|
|
136
|
+
}, decodePositionAccount);
|
|
137
|
+
}
|
|
138
|
+
export async function fetchPositionsByMarket(rpc, market, options) {
|
|
139
|
+
return rpc
|
|
140
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
141
|
+
commitment: options?.commitment,
|
|
142
|
+
dataSlice: options?.dataSlice,
|
|
143
|
+
filters: [
|
|
144
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
145
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
146
|
+
memcmp(POSITION_OFFSET_MARKET, addrBytes(market)),
|
|
147
|
+
],
|
|
148
|
+
})
|
|
149
|
+
.send();
|
|
150
|
+
}
|
|
151
|
+
export async function fetchPositionsByMarketDecoded(rpc, market, options) {
|
|
152
|
+
return fetchAndDecode(rpc, {
|
|
153
|
+
commitment: options?.commitment,
|
|
154
|
+
dataSlice: options?.dataSlice,
|
|
155
|
+
filters: [
|
|
156
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
157
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
158
|
+
memcmp(POSITION_OFFSET_MARKET, addrBytes(market)),
|
|
159
|
+
],
|
|
160
|
+
}, decodePositionAccount);
|
|
161
|
+
}
|
|
162
|
+
export async function fetchPositionsByStatus(rpc, status, options) {
|
|
163
|
+
return rpc
|
|
164
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
165
|
+
commitment: options?.commitment,
|
|
166
|
+
dataSlice: options?.dataSlice,
|
|
167
|
+
filters: [
|
|
168
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
169
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
170
|
+
memcmp(POSITION_OFFSET_STATUS, new Uint8Array([status])),
|
|
171
|
+
],
|
|
172
|
+
})
|
|
173
|
+
.send();
|
|
174
|
+
}
|
|
175
|
+
export async function fetchPositionsByMakerAndStatus(rpc, makerOwner, status, options) {
|
|
176
|
+
return rpc
|
|
177
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
178
|
+
commitment: options?.commitment,
|
|
179
|
+
dataSlice: options?.dataSlice,
|
|
180
|
+
filters: [
|
|
181
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
182
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
183
|
+
memcmp(POSITION_OFFSET_MAKER_OWNER, addrBytes(makerOwner)),
|
|
184
|
+
memcmp(POSITION_OFFSET_STATUS, new Uint8Array([status])),
|
|
185
|
+
],
|
|
186
|
+
})
|
|
187
|
+
.send();
|
|
188
|
+
}
|
|
189
|
+
export async function fetchPositionsByMarketAndStatus(rpc, market, status, options) {
|
|
190
|
+
return rpc
|
|
191
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
192
|
+
commitment: options?.commitment,
|
|
193
|
+
dataSlice: options?.dataSlice,
|
|
194
|
+
filters: [
|
|
195
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
196
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
197
|
+
memcmp(POSITION_OFFSET_MARKET, addrBytes(market)),
|
|
198
|
+
memcmp(POSITION_OFFSET_STATUS, new Uint8Array([status])),
|
|
199
|
+
],
|
|
200
|
+
})
|
|
201
|
+
.send();
|
|
202
|
+
}
|
|
203
|
+
export async function fetchPositionsByStatusDecoded(rpc, status, options) {
|
|
204
|
+
return fetchAndDecode(rpc, {
|
|
205
|
+
commitment: options?.commitment,
|
|
206
|
+
dataSlice: options?.dataSlice,
|
|
207
|
+
filters: [
|
|
208
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
209
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
210
|
+
memcmp(POSITION_OFFSET_STATUS, new Uint8Array([status])),
|
|
211
|
+
],
|
|
212
|
+
}, decodePositionAccount);
|
|
213
|
+
}
|
|
214
|
+
// --- Fetch-all (GPA) helpers ---
|
|
215
|
+
export async function fetchAllConfigsDecoded(rpc, options) {
|
|
216
|
+
return fetchAndDecode(rpc, {
|
|
217
|
+
commitment: options?.commitment,
|
|
218
|
+
dataSlice: options?.dataSlice,
|
|
219
|
+
filters: [
|
|
220
|
+
dataSize(CONFIG_ACCOUNT_SIZE_BYTES),
|
|
221
|
+
memcmp(0, new Uint8Array([CONFIG_ACCOUNT_DISCRIMINATOR])),
|
|
222
|
+
],
|
|
223
|
+
}, decodeConfigAccount);
|
|
224
|
+
}
|
|
225
|
+
export async function fetchAllMakersDecoded(rpc, options) {
|
|
226
|
+
return fetchAndDecode(rpc, {
|
|
227
|
+
commitment: options?.commitment,
|
|
228
|
+
dataSlice: options?.dataSlice,
|
|
229
|
+
filters: [
|
|
230
|
+
dataSize(MAKER_ACCOUNT_SIZE_BYTES),
|
|
231
|
+
memcmp(0, new Uint8Array([MAKER_ACCOUNT_DISCRIMINATOR])),
|
|
232
|
+
],
|
|
233
|
+
}, decodeMakerAccount);
|
|
234
|
+
}
|
|
235
|
+
export async function fetchAllMarketsDecoded(rpc, options) {
|
|
236
|
+
return fetchAndDecode(rpc, {
|
|
237
|
+
commitment: options?.commitment,
|
|
238
|
+
dataSlice: options?.dataSlice,
|
|
239
|
+
filters: [
|
|
240
|
+
dataSize(MARKET_ACCOUNT_SIZE_BYTES),
|
|
241
|
+
memcmp(0, new Uint8Array([MARKET_ACCOUNT_DISCRIMINATOR])),
|
|
242
|
+
],
|
|
243
|
+
}, decodeMarketAccount);
|
|
244
|
+
}
|
|
245
|
+
export async function fetchAllOraclesDecoded(rpc, options) {
|
|
246
|
+
return fetchAndDecode(rpc, {
|
|
247
|
+
commitment: options?.commitment,
|
|
248
|
+
dataSlice: options?.dataSlice,
|
|
249
|
+
filters: [
|
|
250
|
+
dataSize(ORACLE_ACCOUNT_SIZE_BYTES),
|
|
251
|
+
memcmp(0, new Uint8Array([ORACLE_ACCOUNT_DISCRIMINATOR])),
|
|
252
|
+
],
|
|
253
|
+
}, decodeOracleAccount);
|
|
254
|
+
}
|
|
255
|
+
export async function fetchAllPositionsDecoded(rpc, options) {
|
|
256
|
+
return fetchAndDecode(rpc, {
|
|
257
|
+
commitment: options?.commitment,
|
|
258
|
+
dataSlice: options?.dataSlice,
|
|
259
|
+
filters: [
|
|
260
|
+
dataSize(POSITION_ACCOUNT_SIZE_BYTES),
|
|
261
|
+
memcmp(0, new Uint8Array([POSITION_ACCOUNT_DISCRIMINATOR])),
|
|
262
|
+
],
|
|
263
|
+
}, decodePositionAccount);
|
|
264
|
+
}
|
|
265
|
+
// --- Markets ---
|
|
266
|
+
export async function fetchMarketsByUnderlying(rpc, underlying, options) {
|
|
267
|
+
return rpc
|
|
268
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
269
|
+
commitment: options?.commitment,
|
|
270
|
+
dataSlice: options?.dataSlice,
|
|
271
|
+
filters: [memcmp(MARKET_OFFSET_UNDERLYING_MINT, addrBytes(underlying))],
|
|
272
|
+
})
|
|
273
|
+
.send();
|
|
274
|
+
}
|
|
275
|
+
export async function fetchMarketsByUnderlyingDecoded(rpc, underlying, options) {
|
|
276
|
+
return fetchAndDecode(rpc, {
|
|
277
|
+
commitment: options?.commitment,
|
|
278
|
+
dataSlice: options?.dataSlice,
|
|
279
|
+
filters: [memcmp(MARKET_OFFSET_UNDERLYING_MINT, addrBytes(underlying))],
|
|
280
|
+
}, decodeMarketAccount);
|
|
281
|
+
}
|
|
282
|
+
export async function fetchMarketsByQuote(rpc, quote, options) {
|
|
283
|
+
return rpc
|
|
284
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
285
|
+
commitment: options?.commitment,
|
|
286
|
+
dataSlice: options?.dataSlice,
|
|
287
|
+
filters: [memcmp(MARKET_OFFSET_QUOTE_MINT, addrBytes(quote))],
|
|
288
|
+
})
|
|
289
|
+
.send();
|
|
290
|
+
}
|
|
291
|
+
export async function fetchMarketsByQuoteDecoded(rpc, quote, options) {
|
|
292
|
+
return fetchAndDecode(rpc, {
|
|
293
|
+
commitment: options?.commitment,
|
|
294
|
+
dataSlice: options?.dataSlice,
|
|
295
|
+
filters: [memcmp(MARKET_OFFSET_QUOTE_MINT, addrBytes(quote))],
|
|
296
|
+
}, decodeMarketAccount);
|
|
297
|
+
}
|
|
298
|
+
export async function fetchMarketsByExpiry(rpc, expiryTs, options) {
|
|
299
|
+
return rpc
|
|
300
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
301
|
+
commitment: options?.commitment,
|
|
302
|
+
dataSlice: options?.dataSlice,
|
|
303
|
+
filters: [memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs))],
|
|
304
|
+
})
|
|
305
|
+
.send();
|
|
306
|
+
}
|
|
307
|
+
export async function fetchMarketsByExpiryDecoded(rpc, expiryTs, options) {
|
|
308
|
+
return fetchAndDecode(rpc, {
|
|
309
|
+
commitment: options?.commitment,
|
|
310
|
+
dataSlice: options?.dataSlice,
|
|
311
|
+
filters: [memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs))],
|
|
312
|
+
}, decodeMarketAccount);
|
|
313
|
+
}
|
|
314
|
+
export async function fetchMarketsByQuoteAndExpiry(rpc, quote, expiryTs, options) {
|
|
315
|
+
return rpc
|
|
316
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
317
|
+
commitment: options?.commitment,
|
|
318
|
+
dataSlice: options?.dataSlice,
|
|
319
|
+
filters: [
|
|
320
|
+
memcmp(MARKET_OFFSET_QUOTE_MINT, addrBytes(quote)),
|
|
321
|
+
memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs)),
|
|
322
|
+
],
|
|
323
|
+
})
|
|
324
|
+
.send();
|
|
325
|
+
}
|
|
326
|
+
export async function fetchMarketsByQuoteAndExpiryDecoded(rpc, quote, expiryTs, options) {
|
|
327
|
+
return fetchAndDecode(rpc, {
|
|
328
|
+
commitment: options?.commitment,
|
|
329
|
+
dataSlice: options?.dataSlice,
|
|
330
|
+
filters: [
|
|
331
|
+
memcmp(MARKET_OFFSET_QUOTE_MINT, addrBytes(quote)),
|
|
332
|
+
memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs)),
|
|
333
|
+
],
|
|
334
|
+
}, decodeMarketAccount);
|
|
335
|
+
}
|
|
336
|
+
export async function fetchMarketsByUnderlyingAndExpiry(rpc, underlying, expiryTs, options) {
|
|
337
|
+
return rpc
|
|
338
|
+
.getProgramAccounts(getActaProgramId(), {
|
|
339
|
+
commitment: options?.commitment,
|
|
340
|
+
dataSlice: options?.dataSlice,
|
|
341
|
+
filters: [
|
|
342
|
+
memcmp(MARKET_OFFSET_UNDERLYING_MINT, addrBytes(underlying)),
|
|
343
|
+
memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs)),
|
|
344
|
+
],
|
|
345
|
+
})
|
|
346
|
+
.send();
|
|
347
|
+
}
|
|
348
|
+
// --- Single account fetch helpers ---
|
|
349
|
+
export async function fetchConfigAccountByAddress(rpc, address, commitment) {
|
|
350
|
+
const resp = await fetchGeneratedConfig(rpc, address, {
|
|
351
|
+
commitment,
|
|
352
|
+
});
|
|
353
|
+
return { pubkey: resp.address, account: resp.data };
|
|
354
|
+
}
|
|
355
|
+
export async function fetchMarketAccountByAddress(rpc, address, commitment) {
|
|
356
|
+
const resp = await fetchGeneratedMarket(rpc, address, {
|
|
357
|
+
commitment,
|
|
358
|
+
});
|
|
359
|
+
return { pubkey: resp.address, account: resp.data };
|
|
360
|
+
}
|
|
361
|
+
export async function fetchOracleAccountByAddress(rpc, address, commitment) {
|
|
362
|
+
const resp = await fetchGeneratedOracle(rpc, address, {
|
|
363
|
+
commitment,
|
|
364
|
+
});
|
|
365
|
+
return { pubkey: resp.address, account: resp.data };
|
|
366
|
+
}
|
|
367
|
+
export async function fetchMarketsByUnderlyingAndExpiryDecoded(rpc, underlying, expiryTs, options) {
|
|
368
|
+
return fetchAndDecode(rpc, {
|
|
369
|
+
commitment: options?.commitment,
|
|
370
|
+
dataSlice: options?.dataSlice,
|
|
371
|
+
filters: [
|
|
372
|
+
memcmp(MARKET_OFFSET_UNDERLYING_MINT, addrBytes(underlying)),
|
|
373
|
+
memcmp(MARKET_OFFSET_EXPIRY_TS, u64Le(expiryTs)),
|
|
374
|
+
],
|
|
375
|
+
}, decodeMarketAccount);
|
|
376
|
+
}
|
|
377
|
+
// --- Decode helpers ---
|
|
378
|
+
export function decodePositionAccount(data) {
|
|
379
|
+
return getPositionDecoder().decode(data);
|
|
380
|
+
}
|
|
381
|
+
export function decodeMarketAccount(data) {
|
|
382
|
+
return getMarketDecoder().decode(data);
|
|
383
|
+
}
|
|
384
|
+
export function decodeConfigAccount(data) {
|
|
385
|
+
return getConfigDecoder().decode(data);
|
|
386
|
+
}
|
|
387
|
+
export function decodeMakerAccount(data) {
|
|
388
|
+
return getMakerDecoder().decode(data);
|
|
389
|
+
}
|
|
390
|
+
export function decodeOracleAccount(data) {
|
|
391
|
+
return getOracleDecoder().decode(data);
|
|
392
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|