@send-fun/sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/index.cjs +12808 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4406 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4405 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12749 -0
- package/dist/index.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +72 -0
- package/src/constants.ts +38 -0
- package/src/dex/generated/accounts/globalConfig.ts +189 -0
- package/src/dex/generated/accounts/index.ts +12 -0
- package/src/dex/generated/accounts/pool.ts +244 -0
- package/src/dex/generated/accounts/rewardAccrual.ts +191 -0
- package/src/dex/generated/accounts/sendDex.accounts.ts +47 -0
- package/src/dex/generated/errors/index.ts +9 -0
- package/src/dex/generated/errors/sendDex.ts +161 -0
- package/src/dex/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/dex/generated/events/creatorClaimEvent.ts +119 -0
- package/src/dex/generated/events/depositQuoteEvent.ts +115 -0
- package/src/dex/generated/events/index.ts +16 -0
- package/src/dex/generated/events/poolCreateEvent.ts +128 -0
- package/src/dex/generated/events/protocolClaimEvent.ts +111 -0
- package/src/dex/generated/events/sendDex.events.ts +184 -0
- package/src/dex/generated/events/tokenCreateEvent.ts +143 -0
- package/src/dex/generated/events/tradeEvent.ts +143 -0
- package/src/dex/generated/index.ts +16 -0
- package/src/dex/generated/instructions/buyExactIn.ts +815 -0
- package/src/dex/generated/instructions/buyExactOut.ts +815 -0
- package/src/dex/generated/instructions/claimCreatorFees.ts +648 -0
- package/src/dex/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/dex/generated/instructions/index.ts +15 -0
- package/src/dex/generated/instructions/sellExactIn.ts +815 -0
- package/src/dex/generated/instructions/sellExactOut.ts +815 -0
- package/src/dex/generated/instructions/sendDex.instructions.ts +173 -0
- package/src/dex/generated/pdas/eventAuthority.ts +20 -0
- package/src/dex/generated/pdas/globalConfig.ts +20 -0
- package/src/dex/generated/pdas/index.ts +14 -0
- package/src/dex/generated/pdas/lpMint.ts +36 -0
- package/src/dex/generated/pdas/pool.ts +34 -0
- package/src/dex/generated/pdas/rewardAccrual.ts +37 -0
- package/src/dex/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/dex/generated/plugins/index.ts +9 -0
- package/src/dex/generated/plugins/sendDex.ts +282 -0
- package/src/dex/generated/programs/index.ts +9 -0
- package/src/dex/generated/programs/sendDex.ts +12 -0
- package/src/dex/generated/types/index.ts +10 -0
- package/src/dex/generated/types/poolStatus.ts +38 -0
- package/src/dex/generated/types/tradeDirection.ts +38 -0
- package/src/dex/index.ts +8 -0
- package/src/dex/trade.ts +215 -0
- package/src/index.ts +8 -0
- package/src/launchpad/create.ts +116 -0
- package/src/launchpad/generated/accounts/bondingCurve.ts +273 -0
- package/src/launchpad/generated/accounts/globalConfig.ts +211 -0
- package/src/launchpad/generated/accounts/index.ts +12 -0
- package/src/launchpad/generated/accounts/rewardAccrual.ts +191 -0
- package/src/launchpad/generated/accounts/sendLaunchpad.accounts.ts +50 -0
- package/src/launchpad/generated/errors/index.ts +9 -0
- package/src/launchpad/generated/errors/sendLaunchpad.ts +175 -0
- package/src/launchpad/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/launchpad/generated/events/completeEvent.ts +120 -0
- package/src/launchpad/generated/events/creatorClaimEvent.ts +122 -0
- package/src/launchpad/generated/events/index.ts +17 -0
- package/src/launchpad/generated/events/migrateEvent.ts +121 -0
- package/src/launchpad/generated/events/protocolClaimEvent.ts +114 -0
- package/src/launchpad/generated/events/recycleEvent.ts +113 -0
- package/src/launchpad/generated/events/sendLaunchpad.events.ts +207 -0
- package/src/launchpad/generated/events/tokenCreateEvent.ts +156 -0
- package/src/launchpad/generated/events/tradeEvent.ts +148 -0
- package/src/launchpad/generated/index.ts +16 -0
- package/src/launchpad/generated/instructions/buyExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/buyExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/claimCreatorFees.ts +651 -0
- package/src/launchpad/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/launchpad/generated/instructions/createToken.ts +1150 -0
- package/src/launchpad/generated/instructions/index.ts +17 -0
- package/src/launchpad/generated/instructions/migrate.ts +840 -0
- package/src/launchpad/generated/instructions/sellExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/sellExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/sendLaunchpad.instructions.ts +210 -0
- package/src/launchpad/generated/pdas/bondingCurve.ts +39 -0
- package/src/launchpad/generated/pdas/eventAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/globalConfig.ts +20 -0
- package/src/launchpad/generated/pdas/index.ts +14 -0
- package/src/launchpad/generated/pdas/migrationAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/rewardAccrual.ts +37 -0
- package/src/launchpad/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/launchpad/generated/plugins/index.ts +9 -0
- package/src/launchpad/generated/plugins/sendLaunchpad.ts +315 -0
- package/src/launchpad/generated/programs/index.ts +9 -0
- package/src/launchpad/generated/programs/sendLaunchpad.ts +12 -0
- package/src/launchpad/generated/types/bondingCurveStatus.ts +43 -0
- package/src/launchpad/generated/types/index.ts +10 -0
- package/src/launchpad/generated/types/tradeDirection.ts +38 -0
- package/src/launchpad/index.ts +10 -0
- package/src/launchpad/migrate.ts +54 -0
- package/src/launchpad/trade.ts +247 -0
- package/src/math/amm.ts +511 -0
- package/src/math/fee-decay.ts +49 -0
- package/src/math/fees.ts +75 -0
- package/src/math/index.ts +3 -0
- package/src/math/internal.ts +16 -0
- package/src/nexus/fee-helpers.ts +49 -0
- package/src/nexus/generated/accounts/altRegistry.ts +177 -0
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +200 -0
- package/src/nexus/generated/accounts/feePreset.ts +196 -0
- package/src/nexus/generated/accounts/globalConfig.ts +188 -0
- package/src/nexus/generated/accounts/index.ts +19 -0
- package/src/nexus/generated/accounts/partnerConfig.ts +209 -0
- package/src/nexus/generated/accounts/partnerMetadata.ts +216 -0
- package/src/nexus/generated/accounts/rewardState.ts +209 -0
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +85 -0
- package/src/nexus/generated/accounts/stakingConfig.ts +197 -0
- package/src/nexus/generated/accounts/userRewardDebt.ts +221 -0
- package/src/nexus/generated/accounts/userStakePosition.ts +218 -0
- package/src/nexus/generated/constants/index.ts +9 -0
- package/src/nexus/generated/constants/sendNexus.ts +13 -0
- package/src/nexus/generated/errors/index.ts +9 -0
- package/src/nexus/generated/errors/sendNexus.ts +229 -0
- package/src/nexus/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/nexus/generated/events/claimEvent.ts +106 -0
- package/src/nexus/generated/events/index.ts +13 -0
- package/src/nexus/generated/events/sendNexus.events.ts +121 -0
- package/src/nexus/generated/events/stakeEvent.ts +106 -0
- package/src/nexus/generated/events/unstakeEvent.ts +106 -0
- package/src/nexus/generated/index.ts +17 -0
- package/src/nexus/generated/instructions/claim.ts +740 -0
- package/src/nexus/generated/instructions/createUserRewardDebt.ts +498 -0
- package/src/nexus/generated/instructions/index.ts +14 -0
- package/src/nexus/generated/instructions/sendNexus.instructions.ts +146 -0
- package/src/nexus/generated/instructions/settle.ts +517 -0
- package/src/nexus/generated/instructions/stake.ts +615 -0
- package/src/nexus/generated/instructions/unstake.ts +593 -0
- package/src/nexus/generated/pdas/altRegistry.ts +20 -0
- package/src/nexus/generated/pdas/creatorFeeConfig.ts +39 -0
- package/src/nexus/generated/pdas/defaultFeePreset.ts +37 -0
- package/src/nexus/generated/pdas/defaultPartner.ts +40 -0
- package/src/nexus/generated/pdas/defaultPartnerMetadata.ts +42 -0
- package/src/nexus/generated/pdas/eventAuthority.ts +20 -0
- package/src/nexus/generated/pdas/feePreset.ts +39 -0
- package/src/nexus/generated/pdas/globalConfig.ts +20 -0
- package/src/nexus/generated/pdas/index.ts +22 -0
- package/src/nexus/generated/pdas/partnerConfig.ts +36 -0
- package/src/nexus/generated/pdas/partnerMetadata.ts +38 -0
- package/src/nexus/generated/pdas/rewardState.ts +36 -0
- package/src/nexus/generated/pdas/stakingConfig.ts +20 -0
- package/src/nexus/generated/pdas/userRewardDebt.ts +41 -0
- package/src/nexus/generated/pdas/userStakePosition.ts +39 -0
- package/src/nexus/generated/plugins/index.ts +9 -0
- package/src/nexus/generated/plugins/sendNexus.ts +494 -0
- package/src/nexus/generated/programs/index.ts +9 -0
- package/src/nexus/generated/programs/sendNexus.ts +12 -0
- package/src/nexus/generated/types/authPlatformEntry.ts +52 -0
- package/src/nexus/generated/types/callerType.ts +38 -0
- package/src/nexus/generated/types/dexFees.ts +64 -0
- package/src/nexus/generated/types/feeConfig.ts +73 -0
- package/src/nexus/generated/types/index.ts +13 -0
- package/src/nexus/generated/types/launchpadFees.ts +63 -0
- package/src/nexus/index.ts +9 -0
- package/src/nexus/staking.ts +581 -0
- package/src/platform.ts +19 -0
- package/src/transfer-fee.ts +216 -0
- package/src/utils/chunk.ts +21 -0
- package/src/utils/creator-hash.ts +57 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/mint-info.ts +102 -0
- package/src/utils/partner.ts +5 -0
- package/src/utils/pda.ts +24 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import type { Address, Instruction, TransactionSigner } from '@solana/kit';
|
|
2
|
+
import type { BuyQuote, MintFee, SellQuote } from '../math/amm.js';
|
|
3
|
+
import * as amm from '../math/amm.js';
|
|
4
|
+
import type { PartnerInput } from '../utils/partner.js';
|
|
5
|
+
import { getBuyExactInInstructionAsync } from './generated/instructions/buyExactIn.js';
|
|
6
|
+
import { getBuyExactOutInstructionAsync } from './generated/instructions/buyExactOut.js';
|
|
7
|
+
import { getSellExactInInstructionAsync } from './generated/instructions/sellExactIn.js';
|
|
8
|
+
import { getSellExactOutInstructionAsync } from './generated/instructions/sellExactOut.js';
|
|
9
|
+
|
|
10
|
+
export interface LaunchpadTradeParams {
|
|
11
|
+
user: TransactionSigner;
|
|
12
|
+
payer?: TransactionSigner;
|
|
13
|
+
baseMint: Address;
|
|
14
|
+
quoteMint: Address;
|
|
15
|
+
virtualBaseReserves: bigint;
|
|
16
|
+
virtualQuoteReserves: bigint;
|
|
17
|
+
feeBps: number;
|
|
18
|
+
slippageBps: number;
|
|
19
|
+
partner: PartnerInput;
|
|
20
|
+
platformConfig: Address;
|
|
21
|
+
quoteTokenProgram: Address;
|
|
22
|
+
/** Token-2022 schedule for the epoch the trade lands in; stale or missing skews the slippage bounds. */
|
|
23
|
+
quoteFee?: MintFee;
|
|
24
|
+
baseFee?: MintFee;
|
|
25
|
+
/** {@inheritDoc LaunchpadInstructionParams.userQuoteAccount} */
|
|
26
|
+
userQuoteAccount?: Address;
|
|
27
|
+
/** {@inheritDoc LaunchpadInstructionParams.userBaseAccount} */
|
|
28
|
+
userBaseAccount?: Address;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LaunchpadBuyParams extends LaunchpadTradeParams {
|
|
32
|
+
realBaseReserves: bigint;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LaunchpadInstructionParams {
|
|
36
|
+
user: TransactionSigner;
|
|
37
|
+
payer?: TransactionSigner;
|
|
38
|
+
baseMint: Address;
|
|
39
|
+
quoteMint: Address;
|
|
40
|
+
partner: PartnerInput;
|
|
41
|
+
platformConfig: Address;
|
|
42
|
+
quoteTokenProgram: Address;
|
|
43
|
+
/** Any user-owned quote-mint account. Defaults to the ATA, created mid-trade
|
|
44
|
+
* if missing (payer funds rent), which only rescues a sell. For WSOL,
|
|
45
|
+
* a throwaway `createAccountWithSeed` account is cheaper. */
|
|
46
|
+
userQuoteAccount?: Address;
|
|
47
|
+
/** Any user-owned base-mint account. Defaults to the ATA, created mid-trade
|
|
48
|
+
* if missing (payer funds rent), which only rescues a buy. */
|
|
49
|
+
userBaseAccount?: Address;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** `baseAmountOut` is net to the buyer: the program reads `amount` as `base_to_user`. */
|
|
53
|
+
export async function buyExactOut(
|
|
54
|
+
params: LaunchpadBuyParams & { baseAmountOut: bigint },
|
|
55
|
+
): Promise<{ instruction: Instruction; quote: BuyQuote }> {
|
|
56
|
+
const quote = amm.buyExactOut({
|
|
57
|
+
reserveQuote: params.virtualQuoteReserves,
|
|
58
|
+
reserveBase: params.virtualBaseReserves,
|
|
59
|
+
baseAmountOut: params.baseAmountOut,
|
|
60
|
+
feeBps: params.feeBps,
|
|
61
|
+
quoteFee: params.quoteFee,
|
|
62
|
+
baseFee: params.baseFee,
|
|
63
|
+
baseReserveCap: params.realBaseReserves,
|
|
64
|
+
});
|
|
65
|
+
// The cap is measured on the gross the buyer sends, quote transfer fee included.
|
|
66
|
+
const maxQuoteIn = amm.calculateSlippageUp(
|
|
67
|
+
quote.quoteFromUser,
|
|
68
|
+
params.slippageBps,
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
instruction: await buildBuyExactOutInstruction({
|
|
72
|
+
...params,
|
|
73
|
+
amountOut: params.baseAmountOut,
|
|
74
|
+
maxAmountIn: maxQuoteIn,
|
|
75
|
+
}),
|
|
76
|
+
quote,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function buyExactIn(
|
|
81
|
+
params: LaunchpadBuyParams & { quoteAmountIn: bigint },
|
|
82
|
+
): Promise<{ instruction: Instruction; quote: BuyQuote }> {
|
|
83
|
+
const quote = amm.buyExactIn({
|
|
84
|
+
reserveQuote: params.virtualQuoteReserves,
|
|
85
|
+
reserveBase: params.virtualBaseReserves,
|
|
86
|
+
quoteAmountIn: params.quoteAmountIn,
|
|
87
|
+
feeBps: params.feeBps,
|
|
88
|
+
quoteFee: params.quoteFee,
|
|
89
|
+
baseFee: params.baseFee,
|
|
90
|
+
baseReserveCap: params.realBaseReserves,
|
|
91
|
+
});
|
|
92
|
+
// The floor is measured on the buyer's credit, not the vault's debit.
|
|
93
|
+
const minBaseOut = amm.calculateSlippageDown(
|
|
94
|
+
quote.baseToUser,
|
|
95
|
+
params.slippageBps,
|
|
96
|
+
);
|
|
97
|
+
return {
|
|
98
|
+
instruction: await buildBuyExactInInstruction({
|
|
99
|
+
...params,
|
|
100
|
+
amountIn: params.quoteAmountIn,
|
|
101
|
+
minAmountOut: minBaseOut,
|
|
102
|
+
}),
|
|
103
|
+
quote,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function sellExactIn(
|
|
108
|
+
params: LaunchpadTradeParams & { baseAmountIn: bigint },
|
|
109
|
+
): Promise<{ instruction: Instruction; quote: SellQuote }> {
|
|
110
|
+
const quote = amm.sellExactIn({
|
|
111
|
+
reserveQuote: params.virtualQuoteReserves,
|
|
112
|
+
reserveBase: params.virtualBaseReserves,
|
|
113
|
+
baseAmountIn: params.baseAmountIn,
|
|
114
|
+
feeBps: params.feeBps,
|
|
115
|
+
quoteFee: params.quoteFee,
|
|
116
|
+
baseFee: params.baseFee,
|
|
117
|
+
});
|
|
118
|
+
// The floor is measured on the seller's credit, not what leaves the vault.
|
|
119
|
+
const minQuoteOut = amm.calculateSlippageDown(
|
|
120
|
+
quote.quoteToUser,
|
|
121
|
+
params.slippageBps,
|
|
122
|
+
);
|
|
123
|
+
return {
|
|
124
|
+
instruction: await buildSellExactInInstruction({
|
|
125
|
+
...params,
|
|
126
|
+
amountIn: params.baseAmountIn,
|
|
127
|
+
minAmountOut: minQuoteOut,
|
|
128
|
+
}),
|
|
129
|
+
quote,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** `quoteAmountOut` is net to the seller: the program reads `amount` as `quote_to_user`. */
|
|
134
|
+
export async function sellExactOut(
|
|
135
|
+
params: LaunchpadTradeParams & { quoteAmountOut: bigint },
|
|
136
|
+
): Promise<{ instruction: Instruction; quote: SellQuote }> {
|
|
137
|
+
const quote = amm.sellExactOut({
|
|
138
|
+
reserveQuote: params.virtualQuoteReserves,
|
|
139
|
+
reserveBase: params.virtualBaseReserves,
|
|
140
|
+
quoteAmountOut: params.quoteAmountOut,
|
|
141
|
+
feeBps: params.feeBps,
|
|
142
|
+
quoteFee: params.quoteFee,
|
|
143
|
+
baseFee: params.baseFee,
|
|
144
|
+
});
|
|
145
|
+
// The cap is measured on the gross the seller sends, base transfer fee included.
|
|
146
|
+
const maxBaseIn = amm.calculateSlippageUp(
|
|
147
|
+
quote.baseFromUser,
|
|
148
|
+
params.slippageBps,
|
|
149
|
+
);
|
|
150
|
+
return {
|
|
151
|
+
instruction: await buildSellExactOutInstruction({
|
|
152
|
+
...params,
|
|
153
|
+
amountOut: params.quoteAmountOut,
|
|
154
|
+
maxAmountIn: maxBaseIn,
|
|
155
|
+
}),
|
|
156
|
+
quote,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function buildBuyExactInInstruction(
|
|
161
|
+
params: LaunchpadInstructionParams & {
|
|
162
|
+
amountIn: bigint;
|
|
163
|
+
minAmountOut: bigint;
|
|
164
|
+
},
|
|
165
|
+
): Promise<Instruction> {
|
|
166
|
+
const shared = resolveSharedAccounts(params);
|
|
167
|
+
return getBuyExactInInstructionAsync({
|
|
168
|
+
...shared,
|
|
169
|
+
amountIn: params.amountIn,
|
|
170
|
+
minAmountOut: params.minAmountOut,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export async function buildBuyExactOutInstruction(
|
|
175
|
+
params: LaunchpadInstructionParams & {
|
|
176
|
+
amountOut: bigint;
|
|
177
|
+
maxAmountIn: bigint;
|
|
178
|
+
},
|
|
179
|
+
): Promise<Instruction> {
|
|
180
|
+
const shared = resolveSharedAccounts(params);
|
|
181
|
+
return getBuyExactOutInstructionAsync({
|
|
182
|
+
...shared,
|
|
183
|
+
amountOut: params.amountOut,
|
|
184
|
+
maxAmountIn: params.maxAmountIn,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export async function buildSellExactInInstruction(
|
|
189
|
+
params: LaunchpadInstructionParams & {
|
|
190
|
+
amountIn: bigint;
|
|
191
|
+
minAmountOut: bigint;
|
|
192
|
+
},
|
|
193
|
+
): Promise<Instruction> {
|
|
194
|
+
const shared = resolveSharedAccounts(params);
|
|
195
|
+
return getSellExactInInstructionAsync({
|
|
196
|
+
...shared,
|
|
197
|
+
amountIn: params.amountIn,
|
|
198
|
+
minAmountOut: params.minAmountOut,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export async function buildSellExactOutInstruction(
|
|
203
|
+
params: LaunchpadInstructionParams & {
|
|
204
|
+
amountOut: bigint;
|
|
205
|
+
maxAmountIn: bigint;
|
|
206
|
+
},
|
|
207
|
+
): Promise<Instruction> {
|
|
208
|
+
const shared = resolveSharedAccounts(params);
|
|
209
|
+
return getSellExactOutInstructionAsync({
|
|
210
|
+
...shared,
|
|
211
|
+
amountOut: params.amountOut,
|
|
212
|
+
maxAmountIn: params.maxAmountIn,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** Percent of the curve's real base sold (0-100); 100 is the migration threshold. */
|
|
217
|
+
export function calculateBondingCurveProgress(params: {
|
|
218
|
+
realBaseReserves: bigint;
|
|
219
|
+
initialRealBase: bigint;
|
|
220
|
+
}): number {
|
|
221
|
+
const { realBaseReserves, initialRealBase } = params;
|
|
222
|
+
if (initialRealBase === 0n) return 100;
|
|
223
|
+
const sold = initialRealBase - realBaseReserves;
|
|
224
|
+
return Math.max(
|
|
225
|
+
0,
|
|
226
|
+
Math.min(Number((sold * 1000n) / initialRealBase) / 10, 100),
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function resolveSharedAccounts(params: LaunchpadInstructionParams) {
|
|
231
|
+
return {
|
|
232
|
+
user: params.user,
|
|
233
|
+
payer: params.payer ?? params.user,
|
|
234
|
+
baseMint: params.baseMint,
|
|
235
|
+
quoteMint: params.quoteMint,
|
|
236
|
+
partner: params.partner,
|
|
237
|
+
platformConfig: params.platformConfig,
|
|
238
|
+
quoteTokenProgram: params.quoteTokenProgram,
|
|
239
|
+
// Left undefined so the generated client derives the ATA itself.
|
|
240
|
+
...(params.userQuoteAccount !== undefined && {
|
|
241
|
+
userQuoteAccount: params.userQuoteAccount,
|
|
242
|
+
}),
|
|
243
|
+
...(params.userBaseAccount !== undefined && {
|
|
244
|
+
userBaseAccount: params.userBaseAccount,
|
|
245
|
+
}),
|
|
246
|
+
};
|
|
247
|
+
}
|