add idle asset lending with lulo

This commit is contained in:
Arihant Bansal
2024-11-26 16:24:38 +05:30
parent e3d1ff1d41
commit c26f6093ec
26 changed files with 340 additions and 2096 deletions

View File

@@ -7,7 +7,7 @@ import { Connection, ComputeBudgetProgram } from "@solana/web3.js";
* @param connection - Solana RPC connection
* @returns Priority fees statistics and instructions for different fee levels
*/
async function getPriorityFees(connection: Connection) {
export async function getPriorityFees(connection: Connection) {
try {
// Get recent prioritization fees
const priorityFees = await connection.getRecentPrioritizationFees();
@@ -32,7 +32,7 @@ async function getPriorityFees(connection: Connection) {
const median =
sortedFees.length % 2 === 0
? ((sortedFees[mid - 1] ?? 0) + (sortedFees[mid] ?? 0)) / 2
: sortedFees[mid] ?? 0;
: (sortedFees[mid] ?? 0);
// Helper to create priority fee IX based on chosen strategy
const createPriorityFeeIx = (fee: number) => {
@@ -67,7 +67,7 @@ async function getPriorityFees(connection: Connection) {
export async function sendTx(
agent: SolanaAgentKit,
tx: Transaction,
otherKeypairs?: Keypair[]
otherKeypairs?: Keypair[],
) {
tx.recentBlockhash = (await agent.connection.getLatestBlockhash()).blockhash;
tx.feePayer = agent.wallet_address;
@@ -81,9 +81,8 @@ export async function sendTx(
await agent.connection.confirmTransaction({
signature: txid,
blockhash: (await agent.connection.getLatestBlockhash()).blockhash,
lastValidBlockHeight: (
await agent.connection.getLatestBlockhash()
).lastValidBlockHeight,
lastValidBlockHeight: (await agent.connection.getLatestBlockhash())
.lastValidBlockHeight,
});
return txid;
}