@lavarage/sdk 6.8.9 → 6.8.92
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/dist/index.js +16 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -12
- package/dist/index.mjs.map +1 -1
- package/lending.ts +17 -8
- package/package.json +1 -1
package/lending.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
} from "@solana/web3.js";
|
|
13
13
|
import {
|
|
14
14
|
TOKEN_PROGRAM_ID,
|
|
15
|
+
createAssociatedTokenAccountIdempotentInstruction,
|
|
15
16
|
createTransferCheckedInstruction,
|
|
16
17
|
getAssociatedTokenAddressSync,
|
|
17
18
|
getMint,
|
|
@@ -116,7 +117,7 @@ export async function depositFunds(
|
|
|
116
117
|
const { blockhash } =
|
|
117
118
|
await lavarageProgram.provider.connection.getLatestBlockhash("finalized");
|
|
118
119
|
|
|
119
|
-
let instruction;
|
|
120
|
+
let instruction, createTokenAccountIx;
|
|
120
121
|
if (params.mint === undefined) {
|
|
121
122
|
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
122
123
|
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
@@ -143,6 +144,19 @@ export async function depositFunds(
|
|
|
143
144
|
const computeFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
|
|
144
145
|
microLamports: params.computeBudgetMicroLamports ?? 150000,
|
|
145
146
|
});
|
|
147
|
+
const destinationTokenAccount = getAssociatedTokenAddressSync(
|
|
148
|
+
mintPubkey,
|
|
149
|
+
new PublicKey(params.nodeWallet),
|
|
150
|
+
true,
|
|
151
|
+
mintOwner?.owner
|
|
152
|
+
)
|
|
153
|
+
createTokenAccountIx = createAssociatedTokenAccountIdempotentInstruction(
|
|
154
|
+
lavarageProgram.provider.publicKey!,
|
|
155
|
+
destinationTokenAccount,
|
|
156
|
+
params.nodeWallet,
|
|
157
|
+
new PublicKey(params.mint),
|
|
158
|
+
mintOwner?.owner
|
|
159
|
+
);
|
|
146
160
|
instruction = createTransferCheckedInstruction(
|
|
147
161
|
getAssociatedTokenAddressSync(
|
|
148
162
|
mintPubkey,
|
|
@@ -151,12 +165,7 @@ export async function depositFunds(
|
|
|
151
165
|
mintOwner?.owner
|
|
152
166
|
),
|
|
153
167
|
new PublicKey(params.mint),
|
|
154
|
-
|
|
155
|
-
mintPubkey,
|
|
156
|
-
new PublicKey(params.nodeWallet),
|
|
157
|
-
true,
|
|
158
|
-
mintOwner?.owner
|
|
159
|
-
),
|
|
168
|
+
destinationTokenAccount,
|
|
160
169
|
lavarageProgram.provider.publicKey!,
|
|
161
170
|
params.amount,
|
|
162
171
|
mintAccount.decimals,
|
|
@@ -172,7 +181,7 @@ export async function depositFunds(
|
|
|
172
181
|
const messageV0 = new TransactionMessage({
|
|
173
182
|
payerKey: lavarageProgram.provider.publicKey!,
|
|
174
183
|
recentBlockhash: blockhash,
|
|
175
|
-
instructions: [instruction, computeFeeIx],
|
|
184
|
+
instructions: [createTokenAccountIx, instruction, computeFeeIx].filter(Boolean) as TransactionInstruction[],
|
|
176
185
|
}).compileToV0Message();
|
|
177
186
|
|
|
178
187
|
return new VersionedTransaction(messageV0);
|