@epicentral/sos-sdk 0.2.5 → 0.2.6

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/accounts/list.ts CHANGED
@@ -7,10 +7,15 @@ import {
7
7
  VAULT_DISCRIMINATOR,
8
8
  WRITER_POSITION_DISCRIMINATOR,
9
9
  getOptionPoolDecoder,
10
+ getOptionPoolSize,
10
11
  getPoolLoanDecoder,
12
+ getPoolLoanSize,
11
13
  getPositionAccountDecoder,
14
+ getPositionAccountSize,
12
15
  getVaultDecoder,
16
+ getVaultSize,
13
17
  getWriterPositionDecoder,
18
+ getWriterPositionSize,
14
19
  type OptionPool,
15
20
  type PoolLoan,
16
21
  type PositionAccount,
@@ -32,7 +37,7 @@ type ListedAccount<T> = {
32
37
  type ProgramAccountResponse = {
33
38
  pubkey: Address;
34
39
  account: {
35
- data: [string, string];
40
+ data: [string, string] | string;
36
41
  };
37
42
  };
38
43
 
@@ -80,7 +85,8 @@ async function fetchAndDecodeProgramAccounts<T>(
80
85
  : (response as { value: Array<ProgramAccountResponse> }).value;
81
86
 
82
87
  return rawAccounts.map(({ pubkey, account }) => {
83
- const [base64Data] = account.data;
88
+ const base64Data =
89
+ Array.isArray(account.data) ? account.data[0] : account.data;
84
90
  return {
85
91
  address: pubkey,
86
92
  data: decoder.decode(decodeBase64Data(base64Data)),
@@ -95,6 +101,7 @@ export async function fetchWriterPositionsByWriter(
95
101
  return fetchAndDecodeProgramAccounts(rpc, getWriterPositionDecoder(), [
96
102
  discriminatorFilter(WRITER_POSITION_DISCRIMINATOR),
97
103
  ownerFilter(writer),
104
+ { dataSize: BigInt(getWriterPositionSize()) },
98
105
  ]);
99
106
  }
100
107
 
@@ -105,6 +112,7 @@ export async function fetchPositionAccountsByBuyer(
105
112
  return fetchAndDecodeProgramAccounts(rpc, getPositionAccountDecoder(), [
106
113
  discriminatorFilter(POSITION_ACCOUNT_DISCRIMINATOR),
107
114
  ownerFilter(buyer),
115
+ { dataSize: BigInt(getPositionAccountSize()) },
108
116
  ]);
109
117
  }
110
118
 
@@ -115,6 +123,7 @@ export async function fetchPoolLoansByMaker(
115
123
  const decoded = await fetchAndDecodeProgramAccounts(rpc, getPoolLoanDecoder(), [
116
124
  discriminatorFilter(POOL_LOAN_DISCRIMINATOR),
117
125
  ownerFilter(maker),
126
+ { dataSize: BigInt(getPoolLoanSize()) },
118
127
  ]);
119
128
  return decoded.filter(
120
129
  (item: { address: Address; data: PoolLoan }) =>
@@ -127,6 +136,7 @@ export async function fetchAllOptionPools(
127
136
  ): Promise<Array<ListedAccount<OptionPool>>> {
128
137
  return fetchAndDecodeProgramAccounts(rpc, getOptionPoolDecoder(), [
129
138
  discriminatorFilter(OPTION_POOL_DISCRIMINATOR),
139
+ { dataSize: BigInt(getOptionPoolSize()) },
130
140
  ]);
131
141
  }
132
142
 
@@ -135,5 +145,6 @@ export async function fetchAllVaults(
135
145
  ): Promise<Array<ListedAccount<Vault>>> {
136
146
  return fetchAndDecodeProgramAccounts(rpc, getVaultDecoder(), [
137
147
  discriminatorFilter(VAULT_DISCRIMINATOR),
148
+ { dataSize: BigInt(getVaultSize()) },
138
149
  ]);
139
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "private": false,
5
5
  "description": "Solana Option Standard SDK. The frontend-first SDK for Native Options Trading on Solana. Created by Epicentral Labs.",
6
6
  "type": "module",
@@ -1,37 +0,0 @@
1
- import { getClaimPremiumInstructionAsync } from "../generated/instructions";
2
- import type { Instruction } from "@solana/kit";
3
- import { toAddress } from "../client/program";
4
- import type { AddressLike, BuiltTransaction } from "../client/types";
5
-
6
- export interface BuildClaimPremiumParams {
7
- optionPool: AddressLike;
8
- makerPaymentAccount: AddressLike;
9
- premiumVault: AddressLike;
10
- maker: AddressLike;
11
- makerPoolShare?: AddressLike;
12
- tokenProgram?: AddressLike;
13
- }
14
-
15
- export async function buildClaimPremiumInstruction(
16
- params: BuildClaimPremiumParams
17
- ): Promise<Instruction<string>> {
18
- return getClaimPremiumInstructionAsync({
19
- optionPool: toAddress(params.optionPool),
20
- makerPoolShare: params.makerPoolShare ? toAddress(params.makerPoolShare) : undefined,
21
- makerPaymentAccount: toAddress(params.makerPaymentAccount),
22
- premiumVault: toAddress(params.premiumVault),
23
- maker: toAddress(params.maker) as any,
24
- tokenProgram: params.tokenProgram ? toAddress(params.tokenProgram) : undefined,
25
- });
26
- }
27
-
28
- /**
29
- * Builds a premium claim transaction for a maker's pool share.
30
- * `makerPoolShare` is optional and can be derived by the generated instruction helper.
31
- */
32
- export async function buildClaimPremiumTransaction(
33
- params: BuildClaimPremiumParams
34
- ): Promise<BuiltTransaction> {
35
- const instruction = await buildClaimPremiumInstruction(params);
36
- return { instructions: [instruction] };
37
- }