@epicentral/sos-sdk 0.9.0-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.
Files changed (113) hide show
  1. package/.env.example +1 -0
  2. package/AGENTS.md +7 -0
  3. package/LICENSE +21 -0
  4. package/README.md +568 -0
  5. package/accounts/fetchers.ts +196 -0
  6. package/accounts/list.ts +184 -0
  7. package/accounts/pdas.ts +325 -0
  8. package/accounts/resolve-option.ts +104 -0
  9. package/client/lookup-table.ts +114 -0
  10. package/client/program.ts +13 -0
  11. package/client/types.ts +9 -0
  12. package/generated/accounts/collateralPool.ts +217 -0
  13. package/generated/accounts/config.ts +156 -0
  14. package/generated/accounts/escrowState.ts +183 -0
  15. package/generated/accounts/index.ts +20 -0
  16. package/generated/accounts/lenderPosition.ts +211 -0
  17. package/generated/accounts/makerCollateralShare.ts +229 -0
  18. package/generated/accounts/marketDataAccount.ts +176 -0
  19. package/generated/accounts/optionAccount.ts +247 -0
  20. package/generated/accounts/optionPool.ts +285 -0
  21. package/generated/accounts/poolLoan.ts +232 -0
  22. package/generated/accounts/positionAccount.ts +201 -0
  23. package/generated/accounts/vault.ts +366 -0
  24. package/generated/accounts/writerPosition.ts +327 -0
  25. package/generated/errors/index.ts +9 -0
  26. package/generated/errors/optionProgram.ts +476 -0
  27. package/generated/index.ts +13 -0
  28. package/generated/instructions/acceptAdmin.ts +230 -0
  29. package/generated/instructions/autoExerciseAllExpired.ts +685 -0
  30. package/generated/instructions/autoExerciseExpired.ts +754 -0
  31. package/generated/instructions/borrowFromPool.ts +619 -0
  32. package/generated/instructions/buyFromPool.ts +761 -0
  33. package/generated/instructions/closeLongToPool.ts +762 -0
  34. package/generated/instructions/closeOption.ts +235 -0
  35. package/generated/instructions/createEscrowV2.ts +518 -0
  36. package/generated/instructions/depositCollateral.ts +624 -0
  37. package/generated/instructions/depositToPosition.ts +429 -0
  38. package/generated/instructions/index.ts +47 -0
  39. package/generated/instructions/initCollateralPool.ts +513 -0
  40. package/generated/instructions/initConfig.ts +279 -0
  41. package/generated/instructions/initOptionPool.ts +587 -0
  42. package/generated/instructions/initializeMarketData.ts +359 -0
  43. package/generated/instructions/liquidateWriterPosition.ts +750 -0
  44. package/generated/instructions/liquidateWriterPositionRescue.ts +623 -0
  45. package/generated/instructions/omlpCreateVault.ts +553 -0
  46. package/generated/instructions/omlpUpdateFeeWallet.ts +473 -0
  47. package/generated/instructions/omlpUpdateInterestModel.ts +322 -0
  48. package/generated/instructions/omlpUpdateLiquidationThreshold.ts +304 -0
  49. package/generated/instructions/omlpUpdateMaintenanceBuffer.ts +304 -0
  50. package/generated/instructions/omlpUpdateMaxBorrowCap.ts +304 -0
  51. package/generated/instructions/omlpUpdateMaxLeverage.ts +304 -0
  52. package/generated/instructions/omlpUpdateProtocolFee.ts +304 -0
  53. package/generated/instructions/omlpUpdateSupplyLimit.ts +304 -0
  54. package/generated/instructions/optionExercise.ts +617 -0
  55. package/generated/instructions/optionMint.ts +1373 -0
  56. package/generated/instructions/optionValidate.ts +302 -0
  57. package/generated/instructions/repayPoolLoan.ts +558 -0
  58. package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
  59. package/generated/instructions/repayPoolLoanFromWallet.ts +542 -0
  60. package/generated/instructions/settleMakerCollateral.ts +509 -0
  61. package/generated/instructions/syncWriterPosition.ts +206 -0
  62. package/generated/instructions/transferAdmin.ts +245 -0
  63. package/generated/instructions/unwindWriterUnsold.ts +764 -0
  64. package/generated/instructions/updateImpliedVolatility.ts +226 -0
  65. package/generated/instructions/updateMarketData.ts +315 -0
  66. package/generated/instructions/withdrawFromPosition.ts +405 -0
  67. package/generated/instructions/writeToPool.ts +619 -0
  68. package/generated/programs/index.ts +9 -0
  69. package/generated/programs/optionProgram.ts +1144 -0
  70. package/generated/shared/index.ts +164 -0
  71. package/generated/types/impliedVolatilityUpdated.ts +73 -0
  72. package/generated/types/index.ts +28 -0
  73. package/generated/types/liquidationExecuted.ts +73 -0
  74. package/generated/types/liquidationRescueEvent.ts +82 -0
  75. package/generated/types/marketDataInitialized.ts +61 -0
  76. package/generated/types/marketDataUpdated.ts +69 -0
  77. package/generated/types/optionClosed.ts +56 -0
  78. package/generated/types/optionExercised.ts +62 -0
  79. package/generated/types/optionExpired.ts +49 -0
  80. package/generated/types/optionMinted.ts +78 -0
  81. package/generated/types/optionType.ts +38 -0
  82. package/generated/types/optionValidated.ts +82 -0
  83. package/generated/types/poolLoanCreated.ts +74 -0
  84. package/generated/types/poolLoanRepaid.ts +74 -0
  85. package/generated/types/positionDeposited.ts +73 -0
  86. package/generated/types/positionWithdrawn.ts +81 -0
  87. package/generated/types/protocolFeeUpdated.ts +69 -0
  88. package/generated/types/vaultCreated.ts +60 -0
  89. package/generated/types/vaultFeeWalletUpdated.ts +67 -0
  90. package/generated/types/vaultInterestModelUpdated.ts +77 -0
  91. package/generated/types/vaultLiquidationThresholdUpdated.ts +69 -0
  92. package/index.ts +68 -0
  93. package/long/builders.ts +690 -0
  94. package/long/exercise.ts +123 -0
  95. package/long/preflight.ts +214 -0
  96. package/long/quotes.ts +48 -0
  97. package/long/remaining-accounts.ts +111 -0
  98. package/omlp/builders.ts +94 -0
  99. package/omlp/service.ts +136 -0
  100. package/oracle/switchboard.ts +315 -0
  101. package/package.json +34 -0
  102. package/shared/amounts.ts +53 -0
  103. package/shared/balances.ts +57 -0
  104. package/shared/errors.ts +12 -0
  105. package/shared/remaining-accounts.ts +41 -0
  106. package/shared/trade-config.ts +27 -0
  107. package/shared/transactions.ts +121 -0
  108. package/short/builders.ts +874 -0
  109. package/short/close-option.ts +34 -0
  110. package/short/pool.ts +189 -0
  111. package/short/preflight.ts +619 -0
  112. package/tsconfig.json +13 -0
  113. package/wsol/instructions.ts +247 -0
@@ -0,0 +1,232 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ assertAccountExists,
11
+ assertAccountsExist,
12
+ combineCodec,
13
+ decodeAccount,
14
+ fetchEncodedAccount,
15
+ fetchEncodedAccounts,
16
+ fixDecoderSize,
17
+ fixEncoderSize,
18
+ getAddressDecoder,
19
+ getAddressEncoder,
20
+ getBytesDecoder,
21
+ getBytesEncoder,
22
+ getStructDecoder,
23
+ getStructEncoder,
24
+ getU16Decoder,
25
+ getU16Encoder,
26
+ getU64Decoder,
27
+ getU64Encoder,
28
+ getU8Decoder,
29
+ getU8Encoder,
30
+ transformEncoder,
31
+ type Account,
32
+ type Address,
33
+ type EncodedAccount,
34
+ type FetchAccountConfig,
35
+ type FetchAccountsConfig,
36
+ type FixedSizeCodec,
37
+ type FixedSizeDecoder,
38
+ type FixedSizeEncoder,
39
+ type MaybeAccount,
40
+ type MaybeEncodedAccount,
41
+ type ReadonlyUint8Array,
42
+ } from "@solana/kit";
43
+
44
+ export const POOL_LOAN_DISCRIMINATOR = new Uint8Array([
45
+ 31, 179, 93, 157, 68, 113, 2, 128,
46
+ ]);
47
+
48
+ export function getPoolLoanDiscriminatorBytes() {
49
+ return fixEncoderSize(getBytesEncoder(), 8).encode(POOL_LOAN_DISCRIMINATOR);
50
+ }
51
+
52
+ export type PoolLoan = {
53
+ discriminator: ReadonlyUint8Array;
54
+ /** Maker (borrower) who took this loan */
55
+ maker: Address;
56
+ /** Vault this loan is from */
57
+ vault: Address;
58
+ /**
59
+ * Escrow state PDA that validates maker/mint binding
60
+ * The actual token account is derived from escrow_authority_v2
61
+ */
62
+ escrowState: Address;
63
+ /**
64
+ * Writer position PDA for this option pool + maker (`["writer_position", option_pool, maker]`).
65
+ * Canonical link for aggregating/repaying debt per position.
66
+ */
67
+ writerPosition: Address;
68
+ /** Principal borrowed */
69
+ principal: bigint;
70
+ /** Interest rate at time of borrow (from vault's dynamic rate) */
71
+ rateBps: number;
72
+ /** Accrued interest (computed from slots) */
73
+ accruedInterest: bigint;
74
+ /** Protocol fees accrued */
75
+ accruedProtocolFees: bigint;
76
+ /** Collateral amount provided */
77
+ collateral: bigint;
78
+ /** Slot when loan started */
79
+ startSlot: bigint;
80
+ /** Last slot when interest was updated */
81
+ lastUpdateSlot: bigint;
82
+ /** Loan status: 1=Active, 2=Repaid, 3=Liquidated */
83
+ status: number;
84
+ /** Loan nonce for uniqueness */
85
+ nonce: bigint;
86
+ /** PDA bump */
87
+ bump: number;
88
+ };
89
+
90
+ export type PoolLoanArgs = {
91
+ /** Maker (borrower) who took this loan */
92
+ maker: Address;
93
+ /** Vault this loan is from */
94
+ vault: Address;
95
+ /**
96
+ * Escrow state PDA that validates maker/mint binding
97
+ * The actual token account is derived from escrow_authority_v2
98
+ */
99
+ escrowState: Address;
100
+ /**
101
+ * Writer position PDA for this option pool + maker (`["writer_position", option_pool, maker]`).
102
+ * Canonical link for aggregating/repaying debt per position.
103
+ */
104
+ writerPosition: Address;
105
+ /** Principal borrowed */
106
+ principal: number | bigint;
107
+ /** Interest rate at time of borrow (from vault's dynamic rate) */
108
+ rateBps: number;
109
+ /** Accrued interest (computed from slots) */
110
+ accruedInterest: number | bigint;
111
+ /** Protocol fees accrued */
112
+ accruedProtocolFees: number | bigint;
113
+ /** Collateral amount provided */
114
+ collateral: number | bigint;
115
+ /** Slot when loan started */
116
+ startSlot: number | bigint;
117
+ /** Last slot when interest was updated */
118
+ lastUpdateSlot: number | bigint;
119
+ /** Loan status: 1=Active, 2=Repaid, 3=Liquidated */
120
+ status: number;
121
+ /** Loan nonce for uniqueness */
122
+ nonce: number | bigint;
123
+ /** PDA bump */
124
+ bump: number;
125
+ };
126
+
127
+ /** Gets the encoder for {@link PoolLoanArgs} account data. */
128
+ export function getPoolLoanEncoder(): FixedSizeEncoder<PoolLoanArgs> {
129
+ return transformEncoder(
130
+ getStructEncoder([
131
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
132
+ ["maker", getAddressEncoder()],
133
+ ["vault", getAddressEncoder()],
134
+ ["escrowState", getAddressEncoder()],
135
+ ["writerPosition", getAddressEncoder()],
136
+ ["principal", getU64Encoder()],
137
+ ["rateBps", getU16Encoder()],
138
+ ["accruedInterest", getU64Encoder()],
139
+ ["accruedProtocolFees", getU64Encoder()],
140
+ ["collateral", getU64Encoder()],
141
+ ["startSlot", getU64Encoder()],
142
+ ["lastUpdateSlot", getU64Encoder()],
143
+ ["status", getU8Encoder()],
144
+ ["nonce", getU64Encoder()],
145
+ ["bump", getU8Encoder()],
146
+ ]),
147
+ (value) => ({ ...value, discriminator: POOL_LOAN_DISCRIMINATOR }),
148
+ );
149
+ }
150
+
151
+ /** Gets the decoder for {@link PoolLoan} account data. */
152
+ export function getPoolLoanDecoder(): FixedSizeDecoder<PoolLoan> {
153
+ return getStructDecoder([
154
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
155
+ ["maker", getAddressDecoder()],
156
+ ["vault", getAddressDecoder()],
157
+ ["escrowState", getAddressDecoder()],
158
+ ["writerPosition", getAddressDecoder()],
159
+ ["principal", getU64Decoder()],
160
+ ["rateBps", getU16Decoder()],
161
+ ["accruedInterest", getU64Decoder()],
162
+ ["accruedProtocolFees", getU64Decoder()],
163
+ ["collateral", getU64Decoder()],
164
+ ["startSlot", getU64Decoder()],
165
+ ["lastUpdateSlot", getU64Decoder()],
166
+ ["status", getU8Decoder()],
167
+ ["nonce", getU64Decoder()],
168
+ ["bump", getU8Decoder()],
169
+ ]);
170
+ }
171
+
172
+ /** Gets the codec for {@link PoolLoan} account data. */
173
+ export function getPoolLoanCodec(): FixedSizeCodec<PoolLoanArgs, PoolLoan> {
174
+ return combineCodec(getPoolLoanEncoder(), getPoolLoanDecoder());
175
+ }
176
+
177
+ export function decodePoolLoan<TAddress extends string = string>(
178
+ encodedAccount: EncodedAccount<TAddress>,
179
+ ): Account<PoolLoan, TAddress>;
180
+ export function decodePoolLoan<TAddress extends string = string>(
181
+ encodedAccount: MaybeEncodedAccount<TAddress>,
182
+ ): MaybeAccount<PoolLoan, TAddress>;
183
+ export function decodePoolLoan<TAddress extends string = string>(
184
+ encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
185
+ ): Account<PoolLoan, TAddress> | MaybeAccount<PoolLoan, TAddress> {
186
+ return decodeAccount(
187
+ encodedAccount as MaybeEncodedAccount<TAddress>,
188
+ getPoolLoanDecoder(),
189
+ );
190
+ }
191
+
192
+ export async function fetchPoolLoan<TAddress extends string = string>(
193
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
194
+ address: Address<TAddress>,
195
+ config?: FetchAccountConfig,
196
+ ): Promise<Account<PoolLoan, TAddress>> {
197
+ const maybeAccount = await fetchMaybePoolLoan(rpc, address, config);
198
+ assertAccountExists(maybeAccount);
199
+ return maybeAccount;
200
+ }
201
+
202
+ export async function fetchMaybePoolLoan<TAddress extends string = string>(
203
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
204
+ address: Address<TAddress>,
205
+ config?: FetchAccountConfig,
206
+ ): Promise<MaybeAccount<PoolLoan, TAddress>> {
207
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
208
+ return decodePoolLoan(maybeAccount);
209
+ }
210
+
211
+ export async function fetchAllPoolLoan(
212
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
213
+ addresses: Array<Address>,
214
+ config?: FetchAccountsConfig,
215
+ ): Promise<Account<PoolLoan>[]> {
216
+ const maybeAccounts = await fetchAllMaybePoolLoan(rpc, addresses, config);
217
+ assertAccountsExist(maybeAccounts);
218
+ return maybeAccounts;
219
+ }
220
+
221
+ export async function fetchAllMaybePoolLoan(
222
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
223
+ addresses: Array<Address>,
224
+ config?: FetchAccountsConfig,
225
+ ): Promise<MaybeAccount<PoolLoan>[]> {
226
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
227
+ return maybeAccounts.map((maybeAccount) => decodePoolLoan(maybeAccount));
228
+ }
229
+
230
+ export function getPoolLoanSize(): number {
231
+ return 196;
232
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ assertAccountExists,
11
+ assertAccountsExist,
12
+ combineCodec,
13
+ decodeAccount,
14
+ fetchEncodedAccount,
15
+ fetchEncodedAccounts,
16
+ fixDecoderSize,
17
+ fixEncoderSize,
18
+ getAddressDecoder,
19
+ getAddressEncoder,
20
+ getBooleanDecoder,
21
+ getBooleanEncoder,
22
+ getBytesDecoder,
23
+ getBytesEncoder,
24
+ getI64Decoder,
25
+ getI64Encoder,
26
+ getStructDecoder,
27
+ getStructEncoder,
28
+ getU64Decoder,
29
+ getU64Encoder,
30
+ transformEncoder,
31
+ type Account,
32
+ type Address,
33
+ type EncodedAccount,
34
+ type FetchAccountConfig,
35
+ type FetchAccountsConfig,
36
+ type FixedSizeCodec,
37
+ type FixedSizeDecoder,
38
+ type FixedSizeEncoder,
39
+ type MaybeAccount,
40
+ type MaybeEncodedAccount,
41
+ type ReadonlyUint8Array,
42
+ } from "@solana/kit";
43
+
44
+ export const POSITION_ACCOUNT_DISCRIMINATOR = new Uint8Array([
45
+ 60, 125, 250, 193, 181, 109, 238, 86,
46
+ ]);
47
+
48
+ export function getPositionAccountDiscriminatorBytes() {
49
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
50
+ POSITION_ACCOUNT_DISCRIMINATOR,
51
+ );
52
+ }
53
+
54
+ export type PositionAccount = {
55
+ discriminator: ReadonlyUint8Array;
56
+ buyer: Address;
57
+ optionAccount: Address;
58
+ quantity: bigint;
59
+ premiumPaid: bigint;
60
+ openedAt: bigint;
61
+ closedAt: bigint;
62
+ isClosed: boolean;
63
+ isExercised: boolean;
64
+ pnl: bigint;
65
+ /**
66
+ * Collateral mint used for settlement (e.g., USDC, BTC, SOL)
67
+ * Tracks which currency the buyer will receive at exercise/close
68
+ * Matches the WriterPosition.collateral_mint of the writer(s) who filled this position
69
+ */
70
+ collateralMint: Address;
71
+ };
72
+
73
+ export type PositionAccountArgs = {
74
+ buyer: Address;
75
+ optionAccount: Address;
76
+ quantity: number | bigint;
77
+ premiumPaid: number | bigint;
78
+ openedAt: number | bigint;
79
+ closedAt: number | bigint;
80
+ isClosed: boolean;
81
+ isExercised: boolean;
82
+ pnl: number | bigint;
83
+ /**
84
+ * Collateral mint used for settlement (e.g., USDC, BTC, SOL)
85
+ * Tracks which currency the buyer will receive at exercise/close
86
+ * Matches the WriterPosition.collateral_mint of the writer(s) who filled this position
87
+ */
88
+ collateralMint: Address;
89
+ };
90
+
91
+ /** Gets the encoder for {@link PositionAccountArgs} account data. */
92
+ export function getPositionAccountEncoder(): FixedSizeEncoder<PositionAccountArgs> {
93
+ return transformEncoder(
94
+ getStructEncoder([
95
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
96
+ ["buyer", getAddressEncoder()],
97
+ ["optionAccount", getAddressEncoder()],
98
+ ["quantity", getU64Encoder()],
99
+ ["premiumPaid", getU64Encoder()],
100
+ ["openedAt", getI64Encoder()],
101
+ ["closedAt", getI64Encoder()],
102
+ ["isClosed", getBooleanEncoder()],
103
+ ["isExercised", getBooleanEncoder()],
104
+ ["pnl", getI64Encoder()],
105
+ ["collateralMint", getAddressEncoder()],
106
+ ]),
107
+ (value) => ({ ...value, discriminator: POSITION_ACCOUNT_DISCRIMINATOR }),
108
+ );
109
+ }
110
+
111
+ /** Gets the decoder for {@link PositionAccount} account data. */
112
+ export function getPositionAccountDecoder(): FixedSizeDecoder<PositionAccount> {
113
+ return getStructDecoder([
114
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
115
+ ["buyer", getAddressDecoder()],
116
+ ["optionAccount", getAddressDecoder()],
117
+ ["quantity", getU64Decoder()],
118
+ ["premiumPaid", getU64Decoder()],
119
+ ["openedAt", getI64Decoder()],
120
+ ["closedAt", getI64Decoder()],
121
+ ["isClosed", getBooleanDecoder()],
122
+ ["isExercised", getBooleanDecoder()],
123
+ ["pnl", getI64Decoder()],
124
+ ["collateralMint", getAddressDecoder()],
125
+ ]);
126
+ }
127
+
128
+ /** Gets the codec for {@link PositionAccount} account data. */
129
+ export function getPositionAccountCodec(): FixedSizeCodec<
130
+ PositionAccountArgs,
131
+ PositionAccount
132
+ > {
133
+ return combineCodec(getPositionAccountEncoder(), getPositionAccountDecoder());
134
+ }
135
+
136
+ export function decodePositionAccount<TAddress extends string = string>(
137
+ encodedAccount: EncodedAccount<TAddress>,
138
+ ): Account<PositionAccount, TAddress>;
139
+ export function decodePositionAccount<TAddress extends string = string>(
140
+ encodedAccount: MaybeEncodedAccount<TAddress>,
141
+ ): MaybeAccount<PositionAccount, TAddress>;
142
+ export function decodePositionAccount<TAddress extends string = string>(
143
+ encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
144
+ ):
145
+ | Account<PositionAccount, TAddress>
146
+ | MaybeAccount<PositionAccount, TAddress> {
147
+ return decodeAccount(
148
+ encodedAccount as MaybeEncodedAccount<TAddress>,
149
+ getPositionAccountDecoder(),
150
+ );
151
+ }
152
+
153
+ export async function fetchPositionAccount<TAddress extends string = string>(
154
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
155
+ address: Address<TAddress>,
156
+ config?: FetchAccountConfig,
157
+ ): Promise<Account<PositionAccount, TAddress>> {
158
+ const maybeAccount = await fetchMaybePositionAccount(rpc, address, config);
159
+ assertAccountExists(maybeAccount);
160
+ return maybeAccount;
161
+ }
162
+
163
+ export async function fetchMaybePositionAccount<
164
+ TAddress extends string = string,
165
+ >(
166
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
167
+ address: Address<TAddress>,
168
+ config?: FetchAccountConfig,
169
+ ): Promise<MaybeAccount<PositionAccount, TAddress>> {
170
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
171
+ return decodePositionAccount(maybeAccount);
172
+ }
173
+
174
+ export async function fetchAllPositionAccount(
175
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
176
+ addresses: Array<Address>,
177
+ config?: FetchAccountsConfig,
178
+ ): Promise<Account<PositionAccount>[]> {
179
+ const maybeAccounts = await fetchAllMaybePositionAccount(
180
+ rpc,
181
+ addresses,
182
+ config,
183
+ );
184
+ assertAccountsExist(maybeAccounts);
185
+ return maybeAccounts;
186
+ }
187
+
188
+ export async function fetchAllMaybePositionAccount(
189
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
190
+ addresses: Array<Address>,
191
+ config?: FetchAccountsConfig,
192
+ ): Promise<MaybeAccount<PositionAccount>[]> {
193
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
194
+ return maybeAccounts.map((maybeAccount) =>
195
+ decodePositionAccount(maybeAccount),
196
+ );
197
+ }
198
+
199
+ export function getPositionAccountSize(): number {
200
+ return 146;
201
+ }