Skip to content

Commit c436e09

Browse files
authored
Merge pull request #81 from solendprotocol/eclipse-updates
eclipse changes
2 parents 5c46e88 + 276c6c5 commit c436e09

12 files changed

+298
-51
lines changed

solend-sdk/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
scripts.ts
12
__tests__/scripts.test.ts
23
dist/
34
node_modules/

solend-sdk/__tests__/oracle.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { PythSolanaReceiver, pythSolanaReceiverIdl } from "@pythnetwork/pyth-solana-receiver";
1313
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
1414
import { AnchorProvider, Program } from "@coral-xyz/anchor-30";
15-
import { CrossbarClient, loadLookupTables, PullFeed, SB_ON_DEMAND_PID } from "@switchboard-xyz/on-demand";
15+
import { CrossbarClient, loadLookupTables, PullFeed, ON_DEMAND_MAINNET_PID } from "@switchboard-xyz/on-demand";
1616
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
1717

1818
jest.setTimeout(50_000);
@@ -29,7 +29,7 @@ import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
2929
const provider = new AnchorProvider(connection, new NodeWallet(Keypair.fromSecretKey(new Uint8Array(
3030
testKey
3131
))), {});
32-
const idl = (await Program.fetchIdl(SB_ON_DEMAND_PID, provider))!;
32+
const idl = (await Program.fetchIdl(ON_DEMAND_MAINNET_PID, provider))!;
3333
const sbod = new Program(idl, provider);
3434

3535
const sbPulledOracles = [

solend-sdk/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solendprotocol/solend-sdk",
3-
"version": "0.13.11",
3+
"version": "0.13.23",
44
"private": true,
55
"main": "src/index.ts",
66
"module": "src/index.ts",
@@ -23,7 +23,7 @@
2323
"@project-serum/anchor": "^0.24.2",
2424
"@pythnetwork/client": "^2.12.0",
2525
"@pythnetwork/price-service-client": "^1.9.0",
26-
"@pythnetwork/pyth-solana-receiver": "^0.8.0",
26+
"@pythnetwork/pyth-solana-receiver": "^0.8.2",
2727
"@solana/buffer-layout": "=4.0.1",
2828
"@solana/spl-token": "^0.3.7",
2929
"@solana/web3.js": "=1.92.3",

solend-sdk/src/core/actions.ts

+40-27
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import {
6565
createWithdrawAndBurnWrapperTokensInstruction,
6666
} from "@solendprotocol/token2022-wrapper-sdk";
6767
import { ReserveType } from "./utils";
68-
import { getSizeOfTransaction } from "../transaction";
6968

7069
const SOL_PADDING_FOR_INTEREST = "1000000";
7170

@@ -80,6 +79,8 @@ type ActionConfigType = {
8079
token2022Mint?: string;
8180
repayToken2022Mint?: string;
8281
debug?: boolean;
82+
computeUnitPriceMicroLamports?: number;
83+
computeUnitLimit?: number;
8384
};
8485

8586
type SupportType =
@@ -219,6 +220,10 @@ export class SolendActionCore {
219220

220221
environment: EnvironmentType;
221222

223+
computeUnitPriceMicroLamports?: number;
224+
225+
computeUnitLimit?: number;
226+
222227
private constructor(
223228
programId: PublicKey,
224229
connection: Connection,
@@ -250,6 +255,8 @@ export class SolendActionCore {
250255
token2022Mint?: PublicKey;
251256
wrappedAta?: PublicKey;
252257
debug?: boolean;
258+
computeUnitPriceMicroLamports?: number;
259+
computeUnitLimit?: number;
253260
}
254261
) {
255262
this.programId = programId;
@@ -282,6 +289,8 @@ export class SolendActionCore {
282289
// temporarily default to true
283290
this.debug = config?.debug ?? true;
284291
this.environment = config?.environment ?? "production";
292+
this.computeUnitPriceMicroLamports = config?.computeUnitPriceMicroLamports;
293+
this.computeUnitLimit = config?.computeUnitLimit;
285294
}
286295

287296
static async initialize(
@@ -391,7 +400,6 @@ export class SolendActionCore {
391400
amount,
392401
depositReserves,
393402
borrowReserves,
394-
395403
{
396404
environment: config.environment,
397405
hostAta: config.hostAta,
@@ -428,6 +436,9 @@ export class SolendActionCore {
428436
TOKEN_2022_PROGRAM_ID
429437
)
430438
: undefined,
439+
debug: config.debug,
440+
computeUnitPriceMicroLamports: config.computeUnitPriceMicroLamports,
441+
computeUnitLimit: config.computeUnitLimit,
431442
}
432443
);
433444
}
@@ -675,7 +686,7 @@ export class SolendActionCore {
675686
return new VersionedTransaction(
676687
new TransactionMessage({
677688
payerKey: this.publicKey,
678-
recentBlockhash: (await this.connection.getRecentBlockhash()).blockhash,
689+
recentBlockhash: (await this.connection.getLatestBlockhash()).blockhash,
679690
instructions: [
680691
...this.preTxnIxs,
681692
...this.setupIxs,
@@ -702,17 +713,17 @@ export class SolendActionCore {
702713
if (this.preTxnIxs.length) {
703714
txns.preLendingTxn = new Transaction({
704715
feePayer: this.publicKey,
705-
recentBlockhash: (await this.connection.getRecentBlockhash()).blockhash,
716+
recentBlockhash: (await this.connection.getLatestBlockhash()).blockhash,
706717
}).add(...this.preTxnIxs);
707718
}
708719
txns.lendingTxn = new Transaction({
709720
feePayer: this.publicKey,
710-
recentBlockhash: (await this.connection.getRecentBlockhash()).blockhash,
721+
recentBlockhash: (await this.connection.getLatestBlockhash()).blockhash,
711722
}).add(...this.setupIxs, ...this.lendingIxs, ...this.cleanupIxs);
712723
if (this.postTxnIxs.length) {
713724
txns.postLendingTxn = new Transaction({
714725
feePayer: this.publicKey,
715-
recentBlockhash: (await this.connection.getRecentBlockhash()).blockhash,
726+
recentBlockhash: (await this.connection.getLatestBlockhash()).blockhash,
716727
}).add(...this.postTxnIxs);
717728
}
718729
return txns;
@@ -754,6 +765,14 @@ export class SolendActionCore {
754765
pullPriceTxns: null,
755766
};
756767

768+
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
769+
microLamports: this.computeUnitPriceMicroLamports ?? 500_000,
770+
});
771+
772+
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
773+
units: this.computeUnitLimit ?? 1_000_000,
774+
});
775+
757776
if (this.pullPriceTxns.length) {
758777
txns.pullPriceTxns = this.pullPriceTxns;
759778
}
@@ -763,7 +782,7 @@ export class SolendActionCore {
763782
new TransactionMessage({
764783
payerKey: this.publicKey,
765784
recentBlockhash: blockhash.blockhash,
766-
instructions: this.preTxnIxs,
785+
instructions: [priorityFeeIx, modifyComputeUnits, ...this.preTxnIxs],
767786
}).compileToV0Message()
768787
);
769788
}
@@ -780,13 +799,6 @@ export class SolendActionCore {
780799
instructions.push(tip);
781800
}
782801

783-
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
784-
microLamports: 1_000_000,
785-
});
786-
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
787-
units: 1_000_000,
788-
});
789-
790802
txns.lendingTxn = new VersionedTransaction(
791803
new TransactionMessage({
792804
payerKey: this.publicKey,
@@ -802,7 +814,7 @@ export class SolendActionCore {
802814
new TransactionMessage({
803815
payerKey: this.publicKey,
804816
recentBlockhash: blockhash.blockhash,
805-
instructions: this.postTxnIxs,
817+
instructions: [priorityFeeIx, modifyComputeUnits, ...this.postTxnIxs],
806818
}).compileToV0Message()
807819
);
808820
}
@@ -1167,6 +1179,13 @@ export class SolendActionCore {
11671179
}
11681180

11691181
private async buildPullPriceTxns(oracleKeys: Array<string>) {
1182+
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
1183+
microLamports: this.computeUnitPriceMicroLamports ?? 1_000_000,
1184+
});
1185+
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit({
1186+
units: 1_000_000,
1187+
});
1188+
11701189
const oracleAccounts = await this.connection.getMultipleAccountsInfo(
11711190
oracleKeys.map((o) => new PublicKey(o)),
11721191
"processed"
@@ -1230,15 +1249,6 @@ export class SolendActionCore {
12301249
accountLookups
12311250
);
12321251

1233-
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({
1234-
microLamports: 1_000_000,
1235-
});
1236-
const modifyComputeUnits = ComputeBudgetProgram.setComputeUnitLimit(
1237-
{
1238-
units: 1_000_000,
1239-
}
1240-
);
1241-
12421252
const instructions = [priorityFeeIx, modifyComputeUnits, ix];
12431253

12441254
if (this.debug)
@@ -1326,9 +1336,13 @@ export class SolendActionCore {
13261336
0 // shardId of 0
13271337
);
13281338

1339+
transactionBuilder.addInstructions([
1340+
{ instruction: priorityFeeIx, signers: [] },
1341+
{ instruction: modifyComputeUnits, signers: [] },
1342+
]);
1343+
13291344
const transactionsWithSigners =
13301345
await transactionBuilder.buildVersionedTransactions({
1331-
tightComputeBudget: true,
13321346
jitoTipLamports: this.pullPriceTxns.length
13331347
? undefined
13341348
: this.jitoTipAmount,
@@ -1337,6 +1351,7 @@ export class SolendActionCore {
13371351
for (const transaction of transactionsWithSigners) {
13381352
const signers = transaction.signers;
13391353
const tx = transaction.tx;
1354+
13401355
if (signers) {
13411356
tx.sign(signers);
13421357
}
@@ -1363,8 +1378,6 @@ export class SolendActionCore {
13631378
])
13641379
);
13651380

1366-
console.log(allReserveAddresses);
1367-
13681381
await this.buildPullPriceTxns([
13691382
...allReserveAddresses.map((address) => reserveMap[address].pythOracle),
13701383
...allReserveAddresses.map(

solend-sdk/src/core/constants.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { Cluster, PublicKey } from "@solana/web3.js";
1+
import { PublicKey } from "@solana/web3.js";
22
import BigNumber from "bignumber.js";
33
import { EnvironmentType } from "./types";
44
export const WAD = "1".concat(Array(18 + 1).join("0"));
55
export const POSITION_LIMIT = 6;
66
export const SOL_PADDING_FOR_INTEREST = "1000000";
77
export const SLOTS_PER_YEAR = 63072000;
8-
export const WRAPPER_PROGRAM_ID = new PublicKey(
9-
"3JmCcXAjmBpFzHHuUpgJFfTQEQnAR7K1erNLtWV1g7d9"
10-
);
8+
export const WRAPPER_PROGRAM_ID =
9+
process.env.NEXT_PUBLIC_BRANCH === "eclipse"
10+
? new PublicKey("55ttmJsE9v5PtScfnA2q6S9VXgSPopV6WziiwH94SYws")
11+
: new PublicKey("3JmCcXAjmBpFzHHuUpgJFfTQEQnAR7K1erNLtWV1g7d9");
1112
export const SOLEND_ADDRESSES = [
1213
"5pHk2TmnqQzRF9L6egy5FfiyBgS7G9cMZ5RFaJAvghzw",
1314
"yaDPAockQPna7Srx5LB2TugJSKHUduHghyZdQcn7zYz",

0 commit comments

Comments
 (0)