@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 +2 -0
- package/long/builders.ts +20 -2
- package/package.json +1 -1
- package/short/builders.ts +1 -0
package/index.ts
CHANGED
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
|
|
92
|
-
|
|
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
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;
|