@epicentral/sos-sdk 0.10.4-beta → 0.11.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.
package/README.md CHANGED
@@ -63,8 +63,12 @@ Additional modules:
63
63
  | `buildUnwindWriterUnsoldTransactionWithDerivation` | Builds unwind unsold transaction. |
64
64
  | `buildUnwindWriterUnsoldWithLoanRepayment` | **Unwind + repay pool loans in one tx.** Use when closing unsold shorts that borrowed from OMLP. |
65
65
  | `buildSyncWriterPositionTransaction` | Syncs writer position with pool accumulators. |
66
- | `buildSettleMakerCollateralTransaction` | Expiry Phase A: keeper-signed lender repayment and maker-share snapshot. Repays one active loan's principal + accrued interest to OMLP from collateral vault, and initializes the maker settlement share from `WriterPosition` when older mints do not yet have one. Writers with multiple loans for the expired option call it once per loan; maker residual is claimed separately. |
67
- | `getClaimMakerRemainingInstructionAsync` | Expiry Phase C generated instruction: returns remaining maker collateral after Phase B buyer payouts complete. |
66
+ | `buildSettleMakerCollateralTransaction` | Expiry Phase A: keeper-signed lender repayment and maker-share snapshot. Repays one active loan's principal + accrued interest to OMLP from collateral vault, and initializes the maker settlement share from `WriterPosition` when older mints do not yet have one. Writers with multiple loans for the expired option call it once per loan; maker residual is prepared/claimed separately. |
67
+ | `buildPrepareBuyerSettlementInstruction` | Expiry Phase B (prepare): keeper snapshots a buyer’s capped expiry claim into `BuyerSettlementClaim` PDAs; **does not** transfer to the buyer’s wallet (non-custodial OPX path). |
68
+ | `buildClaimBuyerSettlementInstruction` | Expiry Phase B (claim): **buyer-signed** instruction that transfers the prepared payout from the collateral vault to the buyer’s ATA and closes the position. |
69
+ | `buildPrepareMakerSettlementInstruction` | Expiry Phase C (prepare): keeper snapshots maker residual into `MakerSettlementClaim` after Phase B completes. |
70
+ | `buildClaimMakerSettlementInstruction` | Expiry Phase C (claim): **maker-signed** instruction that transfers prepared residual collateral to the maker. |
71
+ | `getClaimMakerRemainingInstructionAsync` | **Legacy** Phase C: direct vault → maker transfer in one keeper call (still on-chain). Prefer prepare/claim for user-controlled settlement. |
68
72
  | `buildCloseOptionTransaction` | Closes option token account. |
69
73
  | `buildClaimThetaTransaction` | Claims theta (time-decay share) for writer. |
70
74
  | `buildRepayPoolLoanFromCollateralInstruction` | Repays pool loan from collateral (short/pool). |
@@ -81,17 +85,17 @@ Additional modules:
81
85
  - No maker transaction signer is required by this instruction format.
82
86
  - On-chain repayment (`collateral_vault` -> `omlp_vault`) is signed by the `collateral_pool` PDA.
83
87
  - Lender repayment is sourced from collateral vault funds, not maker wallet funds.
84
- - Expiry residual maker collateral is returned later by `claim_maker_remaining` after buyer payout Phase B.
88
+ - After Phase B, maker residual is returned via **prepare/claim** (`prepare_maker_settlement` `claim_maker_settlement`) or the legacy **`claim_maker_remaining`** instruction.
85
89
 
86
90
  ### Expiry Settlement
87
91
 
88
- Expiry settlement is lender-first and split across three instructions:
92
+ Expiry settlement is **lender-first**, then buyer phase, then maker phase. **OPX uses a non-custodial prepare/claim path:** keepers only **prepare** snapshots and phase progress; **users sign** claim transactions to receive tokens.
89
93
 
90
- 1. `settle_maker_collateral` (Phase A) for every non-liquidated maker. Lender repayment is paid to the loan vault's ATA for the pool collateral mint, so devnet fake SOL/USDC pools and mainnet WSOL pools use the same mint-safe path. The keeper pays rent to create the maker settlement share if the writer was opened through `option_mint` before that share existed. If a writer has multiple active `PoolLoan` accounts for that expired option, keepers submit one Phase A transaction per loan; the maker share is not marked Phase A settled until all are repaid.
91
- 2. `auto_exercise_expired` / `auto_exercise_all_expired` (Phase B) for buyers, capped by `eligible_maker_pot`; options with zero buyer positions are considered buyer-settled so maker claims do not stall. The single and batch paths take the collateral/settlement mint so cash-settled payouts use the correct token decimals; batch remaining accounts must pair each position with that buyer's token account for the same mint.
92
- 3. `claim_maker_remaining` (Phase C) for makers after `phase_b_complete`, returning residual collateral in the pool collateral mint.
94
+ 1. **`settle_maker_collateral` (Phase A)** For every non-liquidated maker: repay OMLP principal + interest from the collateral vault; snapshot `eligible_maker_pot` / `post_debt_collateral`. One transaction per active `PoolLoan` when a writer has multiple loans.
95
+ 2. **Phase B (buyers)** — **Recommended:** `prepare_buyer_settlement` (keeper, per position) records capped payouts on `BuyerSettlementClaim` and advances `phase_b_complete` when all buyer rows are processed; then **`claim_buyer_settlement` (buyer signer)** performs the vault buyer ATA transfer. Payouts are capped by `eligible_maker_pot` with the same pro-rata scaling as before. **Legacy:** `auto_exercise_expired` / `auto_exercise_all_expired` still exist and can transfer directly from the vault to buyer ATAs in the same instruction when invoked (custodial keeper pattern).
96
+ 3. **Phase C (makers)** — **Recommended:** `prepare_maker_settlement` (keeper) then **`claim_maker_settlement` (maker signer)**. **Legacy:** `claim_maker_remaining` still performs a direct residual transfer when called.
93
97
 
94
- New program errors exposed in the IDL: `LenderRepaymentNotComplete`, `BuyerPayoutNotComplete`, and `MakerLiquidated`.
98
+ New / related program errors include `LenderRepaymentNotComplete`, `BuyerPayoutNotComplete`, `MakerLiquidated`, and claim-state errors such as `SettlementClaimNotPrepared` / `SettlementClaimAlreadyClaimed` (see IDL).
95
99
 
96
100
  ### OMLP (Lending)
97
101
 
@@ -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
+ }