@epicentral/sos-sdk 0.6.1-alpha → 0.6.2-alpha
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 +16 -0
- package/client/lookup-table.ts +3 -1
- package/package.json +1 -1
- package/shared/transactions.ts +26 -5
package/README.md
CHANGED
|
@@ -89,6 +89,22 @@ Additional modules:
|
|
|
89
89
|
|
|
90
90
|
Borrow/repay for writers: use `buildOptionMintTransactionWithDerivation` (with vault/poolLoan) and `buildRepayPoolLoanFromCollateralInstruction` or `buildUnwindWriterUnsoldWithLoanRepayment`.
|
|
91
91
|
|
|
92
|
+
### Transaction size and Address Lookup Tables
|
|
93
|
+
|
|
94
|
+
Option mint (and buy/close) transactions exceed Solana's 1232-byte limit without compression. If you see **"encoding overruns Uint8Array"** when minting, pass `network` to `sendBuiltTransaction`:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await sendBuiltTransaction({
|
|
98
|
+
instructions: tx.instructions,
|
|
99
|
+
rpc,
|
|
100
|
+
rpcSubscriptions,
|
|
101
|
+
feePayer: walletSigner,
|
|
102
|
+
network: "devnet", // or "mainnet" — auto-includes lookup table when configured
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Or pass `addressLookupTableAddresses: [getLookupTableAddressForNetwork("devnet")]` when non-null. Mainnet lookup table is `null` by default; create one via `yarn update:lookuptable` for mainnet.
|
|
107
|
+
|
|
92
108
|
### Token account closing (option mint and close long)
|
|
93
109
|
|
|
94
110
|
- **Option mint (seller/writer):** After `option_mint`, all LONG tokens go to the pool escrow; the maker's LONG ATA is left with zero balance. The SDK **automatically appends an SPL CloseAccount instruction** (when `closeMakerLongAccount` is not set to `false`) so the maker reclaims rent. Use `buildOptionMintTransaction` or `buildOptionMintTransactionWithDerivation`; pass `closeMakerLongAccount: false` to skip closing the LONG ATA.
|
package/client/lookup-table.ts
CHANGED
|
@@ -10,7 +10,9 @@ export const LOOKUP_TABLE_ADDRESSES: Record<"devnet" | "mainnet", Address | null
|
|
|
10
10
|
|
|
11
11
|
export const LOOKUP_TABLE_ADDRESS: Address | null = LOOKUP_TABLE_ADDRESSES.devnet;
|
|
12
12
|
|
|
13
|
-
export
|
|
13
|
+
export type LookupTableNetwork = "devnet" | "mainnet";
|
|
14
|
+
|
|
15
|
+
export function detectNetwork(rpcUrl: string): LookupTableNetwork {
|
|
14
16
|
const lower = rpcUrl.toLowerCase();
|
|
15
17
|
return lower.includes("mainnet") ? "mainnet" : "devnet";
|
|
16
18
|
}
|
package/package.json
CHANGED
package/shared/transactions.ts
CHANGED
|
@@ -21,6 +21,10 @@ import {
|
|
|
21
21
|
import type { Instruction } from "@solana/kit";
|
|
22
22
|
import { toAddress } from "../client/program";
|
|
23
23
|
import type { AddressLike, BuiltTransaction, KitRpc } from "../client/types";
|
|
24
|
+
import {
|
|
25
|
+
getLookupTableAddressForNetwork,
|
|
26
|
+
type LookupTableNetwork,
|
|
27
|
+
} from "../client/lookup-table";
|
|
24
28
|
|
|
25
29
|
export interface SendBuiltTransactionParams extends BuiltTransaction {
|
|
26
30
|
rpc: KitRpc;
|
|
@@ -29,7 +33,18 @@ export interface SendBuiltTransactionParams extends BuiltTransaction {
|
|
|
29
33
|
commitment?: "processed" | "confirmed" | "finalized";
|
|
30
34
|
computeUnitLimit?: number;
|
|
31
35
|
computeUnitPriceMicroLamports?: number;
|
|
36
|
+
/**
|
|
37
|
+
* Address Lookup Table addresses to compress the transaction.
|
|
38
|
+
* REQUIRED for option_mint and other large transactions to avoid
|
|
39
|
+
* "encoding overruns Uint8Array" (Solana's 1232-byte tx limit).
|
|
40
|
+
* Use getLookupTableAddressForNetwork(network) or pass network to auto-include.
|
|
41
|
+
*/
|
|
32
42
|
addressLookupTableAddresses?: AddressLike[];
|
|
43
|
+
/**
|
|
44
|
+
* When set, automatically includes the option program's lookup table for this network.
|
|
45
|
+
* Use this when sending option_mint, buy_from_pool, or other large transactions.
|
|
46
|
+
*/
|
|
47
|
+
network?: LookupTableNetwork;
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
/**
|
|
@@ -58,6 +73,15 @@ export async function sendBuiltTransaction(
|
|
|
58
73
|
}
|
|
59
74
|
const allInstructions = [...computeBudgetInstructions, ...params.instructions];
|
|
60
75
|
|
|
76
|
+
// Resolve address lookup tables: explicit list, or from network for option program
|
|
77
|
+
let addressLookupTableAddresses = params.addressLookupTableAddresses ?? [];
|
|
78
|
+
if (params.network) {
|
|
79
|
+
const programAlt = getLookupTableAddressForNetwork(params.network);
|
|
80
|
+
if (programAlt && !addressLookupTableAddresses.some((a) => String(a) === String(programAlt))) {
|
|
81
|
+
addressLookupTableAddresses = [programAlt, ...addressLookupTableAddresses];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
let txMessage = pipe(
|
|
62
86
|
createTransactionMessage({ version: 0 }),
|
|
63
87
|
(tx) => setTransactionMessageFeePayerSigner(params.feePayer, tx),
|
|
@@ -65,12 +89,9 @@ export async function sendBuiltTransaction(
|
|
|
65
89
|
(tx) => appendTransactionMessageInstructions(allInstructions, tx)
|
|
66
90
|
);
|
|
67
91
|
|
|
68
|
-
if (
|
|
69
|
-
params.addressLookupTableAddresses &&
|
|
70
|
-
params.addressLookupTableAddresses.length > 0
|
|
71
|
-
) {
|
|
92
|
+
if (addressLookupTableAddresses.length > 0) {
|
|
72
93
|
const addressesByAddressLookupTable: AddressesByLookupTableAddress = {};
|
|
73
|
-
for (const altAddress of
|
|
94
|
+
for (const altAddress of addressLookupTableAddresses) {
|
|
74
95
|
const resolvedAddress = toAddress(altAddress);
|
|
75
96
|
const { data } = await fetchAddressLookupTable(params.rpc, resolvedAddress);
|
|
76
97
|
addressesByAddressLookupTable[resolvedAddress] = data.addresses;
|