@epicentral/sos-sdk 0.10.4-beta → 0.10.5-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.
@@ -1,8 +1,10 @@
1
1
  import {
2
+ getBuyerSettlementClaimDecoder,
2
3
  COLLATERAL_POOL_DISCRIMINATOR,
3
4
  OPTION_POOL_DISCRIMINATOR,
4
5
  getCollateralPoolDecoder,
5
6
  getLenderPositionDecoder,
7
+ getMakerSettlementClaimDecoder,
6
8
  getMarketDataAccountDecoder,
7
9
  getOptionAccountDecoder,
8
10
  getOptionPoolDecoder,
@@ -10,8 +12,10 @@ import {
10
12
  getPositionAccountDecoder,
11
13
  getVaultDecoder,
12
14
  getWriterPositionDecoder,
15
+ type BuyerSettlementClaim,
13
16
  type CollateralPool,
14
17
  type LenderPosition,
18
+ type MakerSettlementClaim,
15
19
  type MarketDataAccount,
16
20
  type OptionAccount,
17
21
  type OptionPool,
@@ -158,6 +162,20 @@ export async function fetchBuyerPosition(
158
162
  return decodeAccount(rpc, buyerPosition, getPositionAccountDecoder());
159
163
  }
160
164
 
165
+ export async function fetchBuyerSettlementClaim(
166
+ rpc: KitRpc,
167
+ buyerSettlementClaim: AddressLike
168
+ ): Promise<BuyerSettlementClaim | null> {
169
+ return decodeAccount(rpc, buyerSettlementClaim, getBuyerSettlementClaimDecoder());
170
+ }
171
+
172
+ export async function fetchMakerSettlementClaim(
173
+ rpc: KitRpc,
174
+ makerSettlementClaim: AddressLike
175
+ ): Promise<MakerSettlementClaim | null> {
176
+ return decodeAccount(rpc, makerSettlementClaim, getMakerSettlementClaimDecoder());
177
+ }
178
+
161
179
  export async function fetchVault(
162
180
  rpc: KitRpc,
163
181
  vault: AddressLike
package/accounts/pdas.ts CHANGED
@@ -159,6 +159,34 @@ export async function deriveMakerCollateralSharePda(
159
159
  });
160
160
  }
161
161
 
162
+ export async function deriveBuyerSettlementClaimPda(
163
+ positionAccount: AddressLike,
164
+ programId: AddressLike = PROGRAM_ID
165
+ ): Promise<readonly [Address, number]> {
166
+ const addressEncoder = getAddressEncoder();
167
+ return getProgramDerivedAddress({
168
+ programAddress: toAddress(programId),
169
+ seeds: [
170
+ new TextEncoder().encode("buyer_settlement_claim"),
171
+ addressEncoder.encode(toAddress(positionAccount)),
172
+ ],
173
+ });
174
+ }
175
+
176
+ export async function deriveMakerSettlementClaimPda(
177
+ makerCollateralShare: AddressLike,
178
+ programId: AddressLike = PROGRAM_ID
179
+ ): Promise<readonly [Address, number]> {
180
+ const addressEncoder = getAddressEncoder();
181
+ return getProgramDerivedAddress({
182
+ programAddress: toAddress(programId),
183
+ seeds: [
184
+ new TextEncoder().encode("maker_settlement_claim"),
185
+ addressEncoder.encode(toAddress(makerCollateralShare)),
186
+ ],
187
+ });
188
+ }
189
+
162
190
  export async function deriveBuyerPositionPda(
163
191
  buyer: AddressLike,
164
192
  optionAccount: AddressLike,
@@ -0,0 +1,227 @@
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
+ getF64Decoder,
25
+ getF64Encoder,
26
+ getI64Decoder,
27
+ getI64Encoder,
28
+ getStructDecoder,
29
+ getStructEncoder,
30
+ getU64Decoder,
31
+ getU64Encoder,
32
+ getU8Decoder,
33
+ getU8Encoder,
34
+ transformEncoder,
35
+ type Account,
36
+ type Address,
37
+ type EncodedAccount,
38
+ type FetchAccountConfig,
39
+ type FetchAccountsConfig,
40
+ type FixedSizeCodec,
41
+ type FixedSizeDecoder,
42
+ type FixedSizeEncoder,
43
+ type MaybeAccount,
44
+ type MaybeEncodedAccount,
45
+ type ReadonlyUint8Array,
46
+ } from "@solana/kit";
47
+
48
+ export const BUYER_SETTLEMENT_CLAIM_DISCRIMINATOR = new Uint8Array([
49
+ 225, 103, 137, 75, 32, 42, 45, 106,
50
+ ]);
51
+
52
+ export function getBuyerSettlementClaimDiscriminatorBytes() {
53
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
54
+ BUYER_SETTLEMENT_CLAIM_DISCRIMINATOR,
55
+ );
56
+ }
57
+
58
+ export type BuyerSettlementClaim = {
59
+ discriminator: ReadonlyUint8Array;
60
+ buyer: Address;
61
+ optionAccount: Address;
62
+ positionAccount: Address;
63
+ collateralPool: Address;
64
+ settlementMint: Address;
65
+ quantity: bigint;
66
+ premiumPaid: bigint;
67
+ intrinsicOwed: bigint;
68
+ claimAmount: bigint;
69
+ claimablePnl: bigint;
70
+ oraclePriceAtExpiry: number;
71
+ snapshotAt: bigint;
72
+ claimedAt: bigint;
73
+ isClaimed: boolean;
74
+ bump: number;
75
+ };
76
+
77
+ export type BuyerSettlementClaimArgs = {
78
+ buyer: Address;
79
+ optionAccount: Address;
80
+ positionAccount: Address;
81
+ collateralPool: Address;
82
+ settlementMint: Address;
83
+ quantity: number | bigint;
84
+ premiumPaid: number | bigint;
85
+ intrinsicOwed: number | bigint;
86
+ claimAmount: number | bigint;
87
+ claimablePnl: number | bigint;
88
+ oraclePriceAtExpiry: number;
89
+ snapshotAt: number | bigint;
90
+ claimedAt: number | bigint;
91
+ isClaimed: boolean;
92
+ bump: number;
93
+ };
94
+
95
+ /** Gets the encoder for {@link BuyerSettlementClaimArgs} account data. */
96
+ export function getBuyerSettlementClaimEncoder(): FixedSizeEncoder<BuyerSettlementClaimArgs> {
97
+ return transformEncoder(
98
+ getStructEncoder([
99
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
100
+ ["buyer", getAddressEncoder()],
101
+ ["optionAccount", getAddressEncoder()],
102
+ ["positionAccount", getAddressEncoder()],
103
+ ["collateralPool", getAddressEncoder()],
104
+ ["settlementMint", getAddressEncoder()],
105
+ ["quantity", getU64Encoder()],
106
+ ["premiumPaid", getU64Encoder()],
107
+ ["intrinsicOwed", getU64Encoder()],
108
+ ["claimAmount", getU64Encoder()],
109
+ ["claimablePnl", getI64Encoder()],
110
+ ["oraclePriceAtExpiry", getF64Encoder()],
111
+ ["snapshotAt", getI64Encoder()],
112
+ ["claimedAt", getI64Encoder()],
113
+ ["isClaimed", getBooleanEncoder()],
114
+ ["bump", getU8Encoder()],
115
+ ]),
116
+ (value) => ({
117
+ ...value,
118
+ discriminator: BUYER_SETTLEMENT_CLAIM_DISCRIMINATOR,
119
+ }),
120
+ );
121
+ }
122
+
123
+ /** Gets the decoder for {@link BuyerSettlementClaim} account data. */
124
+ export function getBuyerSettlementClaimDecoder(): FixedSizeDecoder<BuyerSettlementClaim> {
125
+ return getStructDecoder([
126
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
127
+ ["buyer", getAddressDecoder()],
128
+ ["optionAccount", getAddressDecoder()],
129
+ ["positionAccount", getAddressDecoder()],
130
+ ["collateralPool", getAddressDecoder()],
131
+ ["settlementMint", getAddressDecoder()],
132
+ ["quantity", getU64Decoder()],
133
+ ["premiumPaid", getU64Decoder()],
134
+ ["intrinsicOwed", getU64Decoder()],
135
+ ["claimAmount", getU64Decoder()],
136
+ ["claimablePnl", getI64Decoder()],
137
+ ["oraclePriceAtExpiry", getF64Decoder()],
138
+ ["snapshotAt", getI64Decoder()],
139
+ ["claimedAt", getI64Decoder()],
140
+ ["isClaimed", getBooleanDecoder()],
141
+ ["bump", getU8Decoder()],
142
+ ]);
143
+ }
144
+
145
+ /** Gets the codec for {@link BuyerSettlementClaim} account data. */
146
+ export function getBuyerSettlementClaimCodec(): FixedSizeCodec<
147
+ BuyerSettlementClaimArgs,
148
+ BuyerSettlementClaim
149
+ > {
150
+ return combineCodec(
151
+ getBuyerSettlementClaimEncoder(),
152
+ getBuyerSettlementClaimDecoder(),
153
+ );
154
+ }
155
+
156
+ export function decodeBuyerSettlementClaim<TAddress extends string = string>(
157
+ encodedAccount: EncodedAccount<TAddress>,
158
+ ): Account<BuyerSettlementClaim, TAddress>;
159
+ export function decodeBuyerSettlementClaim<TAddress extends string = string>(
160
+ encodedAccount: MaybeEncodedAccount<TAddress>,
161
+ ): MaybeAccount<BuyerSettlementClaim, TAddress>;
162
+ export function decodeBuyerSettlementClaim<TAddress extends string = string>(
163
+ encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
164
+ ):
165
+ | Account<BuyerSettlementClaim, TAddress>
166
+ | MaybeAccount<BuyerSettlementClaim, TAddress> {
167
+ return decodeAccount(
168
+ encodedAccount as MaybeEncodedAccount<TAddress>,
169
+ getBuyerSettlementClaimDecoder(),
170
+ );
171
+ }
172
+
173
+ export async function fetchBuyerSettlementClaim<
174
+ TAddress extends string = string,
175
+ >(
176
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
177
+ address: Address<TAddress>,
178
+ config?: FetchAccountConfig,
179
+ ): Promise<Account<BuyerSettlementClaim, TAddress>> {
180
+ const maybeAccount = await fetchMaybeBuyerSettlementClaim(
181
+ rpc,
182
+ address,
183
+ config,
184
+ );
185
+ assertAccountExists(maybeAccount);
186
+ return maybeAccount;
187
+ }
188
+
189
+ export async function fetchMaybeBuyerSettlementClaim<
190
+ TAddress extends string = string,
191
+ >(
192
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
193
+ address: Address<TAddress>,
194
+ config?: FetchAccountConfig,
195
+ ): Promise<MaybeAccount<BuyerSettlementClaim, TAddress>> {
196
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
197
+ return decodeBuyerSettlementClaim(maybeAccount);
198
+ }
199
+
200
+ export async function fetchAllBuyerSettlementClaim(
201
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
202
+ addresses: Array<Address>,
203
+ config?: FetchAccountsConfig,
204
+ ): Promise<Account<BuyerSettlementClaim>[]> {
205
+ const maybeAccounts = await fetchAllMaybeBuyerSettlementClaim(
206
+ rpc,
207
+ addresses,
208
+ config,
209
+ );
210
+ assertAccountsExist(maybeAccounts);
211
+ return maybeAccounts;
212
+ }
213
+
214
+ export async function fetchAllMaybeBuyerSettlementClaim(
215
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
216
+ addresses: Array<Address>,
217
+ config?: FetchAccountsConfig,
218
+ ): Promise<MaybeAccount<BuyerSettlementClaim>[]> {
219
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
220
+ return maybeAccounts.map((maybeAccount) =>
221
+ decodeBuyerSettlementClaim(maybeAccount),
222
+ );
223
+ }
224
+
225
+ export function getBuyerSettlementClaimSize(): number {
226
+ return 234;
227
+ }
@@ -6,11 +6,13 @@
6
6
  * @see https://github.com/codama-idl/codama
7
7
  */
8
8
 
9
+ export * from "./buyerSettlementClaim";
9
10
  export * from "./collateralPool";
10
11
  export * from "./config";
11
12
  export * from "./escrowState";
12
13
  export * from "./lenderPosition";
13
14
  export * from "./makerCollateralShare";
15
+ export * from "./makerSettlementClaim";
14
16
  export * from "./marketDataAccount";
15
17
  export * from "./optionAccount";
16
18
  export * from "./optionPool";
@@ -0,0 +1,233 @@
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
+ getU8Decoder,
31
+ getU8Encoder,
32
+ transformEncoder,
33
+ type Account,
34
+ type Address,
35
+ type EncodedAccount,
36
+ type FetchAccountConfig,
37
+ type FetchAccountsConfig,
38
+ type FixedSizeCodec,
39
+ type FixedSizeDecoder,
40
+ type FixedSizeEncoder,
41
+ type MaybeAccount,
42
+ type MaybeEncodedAccount,
43
+ type ReadonlyUint8Array,
44
+ } from "@solana/kit";
45
+
46
+ export const MAKER_SETTLEMENT_CLAIM_DISCRIMINATOR = new Uint8Array([
47
+ 195, 112, 137, 189, 12, 182, 197, 194,
48
+ ]);
49
+
50
+ export function getMakerSettlementClaimDiscriminatorBytes() {
51
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
52
+ MAKER_SETTLEMENT_CLAIM_DISCRIMINATOR,
53
+ );
54
+ }
55
+
56
+ export type MakerSettlementClaim = {
57
+ discriminator: ReadonlyUint8Array;
58
+ maker: Address;
59
+ optionAccount: Address;
60
+ makerCollateralShare: Address;
61
+ writerPosition: Address;
62
+ collateralPool: Address;
63
+ settlementMint: Address;
64
+ quantityBacked: bigint;
65
+ ownMakerBasis: bigint;
66
+ makerReturn: bigint;
67
+ exercisePayout: bigint;
68
+ premiumCollected: bigint;
69
+ lenderRepayment: bigint;
70
+ claimablePnl: bigint;
71
+ snapshotAt: bigint;
72
+ claimedAt: bigint;
73
+ isClaimed: boolean;
74
+ bump: number;
75
+ };
76
+
77
+ export type MakerSettlementClaimArgs = {
78
+ maker: Address;
79
+ optionAccount: Address;
80
+ makerCollateralShare: Address;
81
+ writerPosition: Address;
82
+ collateralPool: Address;
83
+ settlementMint: Address;
84
+ quantityBacked: number | bigint;
85
+ ownMakerBasis: number | bigint;
86
+ makerReturn: number | bigint;
87
+ exercisePayout: number | bigint;
88
+ premiumCollected: number | bigint;
89
+ lenderRepayment: number | bigint;
90
+ claimablePnl: number | bigint;
91
+ snapshotAt: number | bigint;
92
+ claimedAt: number | bigint;
93
+ isClaimed: boolean;
94
+ bump: number;
95
+ };
96
+
97
+ /** Gets the encoder for {@link MakerSettlementClaimArgs} account data. */
98
+ export function getMakerSettlementClaimEncoder(): FixedSizeEncoder<MakerSettlementClaimArgs> {
99
+ return transformEncoder(
100
+ getStructEncoder([
101
+ ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
102
+ ["maker", getAddressEncoder()],
103
+ ["optionAccount", getAddressEncoder()],
104
+ ["makerCollateralShare", getAddressEncoder()],
105
+ ["writerPosition", getAddressEncoder()],
106
+ ["collateralPool", getAddressEncoder()],
107
+ ["settlementMint", getAddressEncoder()],
108
+ ["quantityBacked", getU64Encoder()],
109
+ ["ownMakerBasis", getU64Encoder()],
110
+ ["makerReturn", getU64Encoder()],
111
+ ["exercisePayout", getU64Encoder()],
112
+ ["premiumCollected", getU64Encoder()],
113
+ ["lenderRepayment", getU64Encoder()],
114
+ ["claimablePnl", getI64Encoder()],
115
+ ["snapshotAt", getI64Encoder()],
116
+ ["claimedAt", getI64Encoder()],
117
+ ["isClaimed", getBooleanEncoder()],
118
+ ["bump", getU8Encoder()],
119
+ ]),
120
+ (value) => ({
121
+ ...value,
122
+ discriminator: MAKER_SETTLEMENT_CLAIM_DISCRIMINATOR,
123
+ }),
124
+ );
125
+ }
126
+
127
+ /** Gets the decoder for {@link MakerSettlementClaim} account data. */
128
+ export function getMakerSettlementClaimDecoder(): FixedSizeDecoder<MakerSettlementClaim> {
129
+ return getStructDecoder([
130
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
131
+ ["maker", getAddressDecoder()],
132
+ ["optionAccount", getAddressDecoder()],
133
+ ["makerCollateralShare", getAddressDecoder()],
134
+ ["writerPosition", getAddressDecoder()],
135
+ ["collateralPool", getAddressDecoder()],
136
+ ["settlementMint", getAddressDecoder()],
137
+ ["quantityBacked", getU64Decoder()],
138
+ ["ownMakerBasis", getU64Decoder()],
139
+ ["makerReturn", getU64Decoder()],
140
+ ["exercisePayout", getU64Decoder()],
141
+ ["premiumCollected", getU64Decoder()],
142
+ ["lenderRepayment", getU64Decoder()],
143
+ ["claimablePnl", getI64Decoder()],
144
+ ["snapshotAt", getI64Decoder()],
145
+ ["claimedAt", getI64Decoder()],
146
+ ["isClaimed", getBooleanDecoder()],
147
+ ["bump", getU8Decoder()],
148
+ ]);
149
+ }
150
+
151
+ /** Gets the codec for {@link MakerSettlementClaim} account data. */
152
+ export function getMakerSettlementClaimCodec(): FixedSizeCodec<
153
+ MakerSettlementClaimArgs,
154
+ MakerSettlementClaim
155
+ > {
156
+ return combineCodec(
157
+ getMakerSettlementClaimEncoder(),
158
+ getMakerSettlementClaimDecoder(),
159
+ );
160
+ }
161
+
162
+ export function decodeMakerSettlementClaim<TAddress extends string = string>(
163
+ encodedAccount: EncodedAccount<TAddress>,
164
+ ): Account<MakerSettlementClaim, TAddress>;
165
+ export function decodeMakerSettlementClaim<TAddress extends string = string>(
166
+ encodedAccount: MaybeEncodedAccount<TAddress>,
167
+ ): MaybeAccount<MakerSettlementClaim, TAddress>;
168
+ export function decodeMakerSettlementClaim<TAddress extends string = string>(
169
+ encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
170
+ ):
171
+ | Account<MakerSettlementClaim, TAddress>
172
+ | MaybeAccount<MakerSettlementClaim, TAddress> {
173
+ return decodeAccount(
174
+ encodedAccount as MaybeEncodedAccount<TAddress>,
175
+ getMakerSettlementClaimDecoder(),
176
+ );
177
+ }
178
+
179
+ export async function fetchMakerSettlementClaim<
180
+ TAddress extends string = string,
181
+ >(
182
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
183
+ address: Address<TAddress>,
184
+ config?: FetchAccountConfig,
185
+ ): Promise<Account<MakerSettlementClaim, TAddress>> {
186
+ const maybeAccount = await fetchMaybeMakerSettlementClaim(
187
+ rpc,
188
+ address,
189
+ config,
190
+ );
191
+ assertAccountExists(maybeAccount);
192
+ return maybeAccount;
193
+ }
194
+
195
+ export async function fetchMaybeMakerSettlementClaim<
196
+ TAddress extends string = string,
197
+ >(
198
+ rpc: Parameters<typeof fetchEncodedAccount>[0],
199
+ address: Address<TAddress>,
200
+ config?: FetchAccountConfig,
201
+ ): Promise<MaybeAccount<MakerSettlementClaim, TAddress>> {
202
+ const maybeAccount = await fetchEncodedAccount(rpc, address, config);
203
+ return decodeMakerSettlementClaim(maybeAccount);
204
+ }
205
+
206
+ export async function fetchAllMakerSettlementClaim(
207
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
208
+ addresses: Array<Address>,
209
+ config?: FetchAccountsConfig,
210
+ ): Promise<Account<MakerSettlementClaim>[]> {
211
+ const maybeAccounts = await fetchAllMaybeMakerSettlementClaim(
212
+ rpc,
213
+ addresses,
214
+ config,
215
+ );
216
+ assertAccountsExist(maybeAccounts);
217
+ return maybeAccounts;
218
+ }
219
+
220
+ export async function fetchAllMaybeMakerSettlementClaim(
221
+ rpc: Parameters<typeof fetchEncodedAccounts>[0],
222
+ addresses: Array<Address>,
223
+ config?: FetchAccountsConfig,
224
+ ): Promise<MaybeAccount<MakerSettlementClaim>[]> {
225
+ const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
226
+ return maybeAccounts.map((maybeAccount) =>
227
+ decodeMakerSettlementClaim(maybeAccount),
228
+ );
229
+ }
230
+
231
+ export function getMakerSettlementClaimSize(): number {
232
+ return 274;
233
+ }