On-chain (programs/): - driftbear_custom_adaptor (1,058 lines, deployed devnet) - drift_vaults (15,243 lines) - raydium_clmm (20,909 lines) - drift_rs_sdk (55,940 lines) - ctoken_market_program + mock (673 lines) New TypeScript modules (ported from 19 plugins): - JIT maker (sniper+shotgun from jit-proxy) - Filler bot (DLOB fills from keeper-bots-v2) - FloatingMaker (slot-based from keeper-bots-v2) - Executor upgrades (tx simulation, Jito bundles, ALTs) - Event stream (WebSocket + Yellowstone gRPC) - DLOB orderbook + price impact + funding TWAP - Ranger Data API (funding arbs, liquidation signals) - Ranger SOR (full API: quotes, withdraw, deposit collateral) - Sanctum LST (swap, APY, best LST selection) - Lulo lending aggregator - Pyth oracle cross-validation - Helius DAS API + smart priority fees - Flash Trade, Orca, Meteora, deBridge venue clients - Voltr vault strategy client - Drift insurance fund staking - Adaptor CPI client for on-chain program - Raydium LP strategy All wired into strategy engine runCycle(): - 11 data sources called every cycle - 3 background execution modules (JIT, Filler, FloatingMaker) - Multi-venue funding rate comparison - Lending yield optimizer across protocols - LP yield scanning (Orca + Meteora) - Auto-deploy idle capital to best lending protocol - Pyth oracle cross-validation - Realistic backtest mode (0.30% round-trip costs) Tests: 20/20 suites, 181/181 pass Build: zero TypeScript errors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
// NOTE: ONLY ONE REQUEST WITHDRAWAL CAN BE MADE AT A TIME, WILL FAIL IF ANOTHER REQUEST WITHDRAWAL IS PENDING/NOT CLAIMED
|
|
import "dotenv/config";
|
|
import {
|
|
Connection,
|
|
Keypair,
|
|
PublicKey,
|
|
TransactionInstruction,
|
|
} from "@solana/web3.js";
|
|
import * as fs from "fs";
|
|
import { BN } from "@coral-xyz/anchor";
|
|
import { sendAndConfirmOptimisedTx, setupTokenAccount } from "../utils/helper";
|
|
import { RequestWithdrawVaultArgs, VoltrClient } from "@voltr/vault-sdk";
|
|
import {
|
|
vaultAddress,
|
|
withdrawAmountVault,
|
|
isWithdrawInLp,
|
|
isWithdrawAll,
|
|
} from "../../config/base";
|
|
|
|
const userKpFile = fs.readFileSync(process.env.USER_FILE_PATH!, "utf-8");
|
|
const userKpData = JSON.parse(userKpFile);
|
|
const userSecret = Uint8Array.from(userKpData);
|
|
const userKp = Keypair.fromSecretKey(userSecret);
|
|
const user = userKp.publicKey;
|
|
|
|
const vault = new PublicKey(vaultAddress);
|
|
|
|
const connection = new Connection(process.env.HELIUS_RPC_URL!);
|
|
const vc = new VoltrClient(connection);
|
|
const withdrawAmount = new BN(withdrawAmountVault);
|
|
|
|
const requestWithdrawVaultHandler = async (
|
|
withdrawAmount: BN,
|
|
isAmountInLp: boolean,
|
|
isWithdrawAll: boolean
|
|
) => {
|
|
const vaultLpMint = vc.findVaultLpMint(vault);
|
|
const requestWithdrawVaultReceipt = vc.findRequestWithdrawVaultReceipt(
|
|
vault,
|
|
user
|
|
);
|
|
let ixs: TransactionInstruction[] = [];
|
|
const _requestWithdrawLpAta = await setupTokenAccount(
|
|
connection,
|
|
user,
|
|
vaultLpMint,
|
|
requestWithdrawVaultReceipt,
|
|
ixs
|
|
);
|
|
|
|
const requestWithdrawVaultArgs: RequestWithdrawVaultArgs = {
|
|
amount: withdrawAmount,
|
|
isAmountInLp,
|
|
isWithdrawAll,
|
|
};
|
|
|
|
const requestWithdrawVaultIx = await vc.createRequestWithdrawVaultIx(
|
|
requestWithdrawVaultArgs,
|
|
{
|
|
payer: user,
|
|
userTransferAuthority: user,
|
|
vault,
|
|
}
|
|
);
|
|
ixs.push(requestWithdrawVaultIx);
|
|
|
|
const txSig = await sendAndConfirmOptimisedTx(
|
|
ixs,
|
|
process.env.HELIUS_RPC_URL!,
|
|
userKp
|
|
);
|
|
console.log("Request Withdraw Vault Tx Sig: ", txSig);
|
|
};
|
|
|
|
requestWithdrawVaultHandler(withdrawAmount, isWithdrawInLp, isWithdrawAll);
|