@epicentral/sos-sdk 0.2.10 → 0.2.12

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/index.ts CHANGED
@@ -34,3 +34,5 @@ export {
34
34
  getCreateAssociatedTokenIdempotentInstructionWithAddress,
35
35
  NATIVE_MINT,
36
36
  } from "./wsol/instructions";
37
+
38
+ export { getCreateEscrowV2InstructionAsync } from "./generated/instructions/createEscrowV2";
package/long/builders.ts CHANGED
@@ -17,6 +17,7 @@ import {
17
17
  type RemainingAccountInput,
18
18
  } from "../shared/remaining-accounts";
19
19
  import type { OptionType } from "../generated/types";
20
+ import { getCreateAssociatedTokenIdempotentInstructionWithAddress } from "../wsol/instructions";
20
21
 
21
22
  export interface BuildBuyFromPoolParams {
22
23
  optionPool: AddressLike;
@@ -85,11 +86,28 @@ export async function buildBuyFromPoolInstruction(
85
86
  return appendRemainingAccounts(kitInstruction, params.remainingAccounts);
86
87
  }
87
88
 
89
+ /**
90
+ * Builds a buy-from-pool transaction. The returned transaction may include a
91
+ * leading create-ATA-idempotent instruction for the buyer's option account so
92
+ * first-time buyers succeed without a separate setup step.
93
+ */
88
94
  export async function buildBuyFromPoolTransaction(
89
95
  params: BuildBuyFromPoolParams
90
96
  ): Promise<BuiltTransaction> {
91
- const instruction = await buildBuyFromPoolInstruction(params);
92
- return { instructions: [instruction] };
97
+ const buyerOptionAccountAddress = params.buyerOptionAccount
98
+ ? toAddress(params.buyerOptionAccount)
99
+ : await deriveAssociatedTokenAddress(params.buyer, params.longMint);
100
+
101
+ const createAtaIx =
102
+ await getCreateAssociatedTokenIdempotentInstructionWithAddress(
103
+ params.buyer,
104
+ params.buyer,
105
+ params.longMint,
106
+ buyerOptionAccountAddress
107
+ );
108
+
109
+ const buyFromPoolIx = await buildBuyFromPoolInstruction(params);
110
+ return { instructions: [createAtaIx, buyFromPoolIx] };
93
111
  }
94
112
 
95
113
  export interface BuildBuyFromPoolTransactionWithDerivationParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
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",
package/short/builders.ts CHANGED
@@ -200,6 +200,7 @@ export interface BuildOptionMintTransactionWithDerivationParams {
200
200
  makerCollateralAmount: bigint | number;
201
201
  borrowedAmount: bigint | number;
202
202
  maker: AddressLike;
203
+ /** Optional. When omitted, the SDK derives the maker's collateral ATA for underlyingMint. */
203
204
  makerCollateralAccount?: AddressLike;
204
205
  rpc: KitRpc;
205
206
  programId?: AddressLike;