Skip to content

Commit

Permalink
Merge pull request #285 from EpicsDAO/feature
Browse files Browse the repository at this point in the history
feature
  • Loading branch information
POPPIN-FUMI authored Sep 17, 2024
2 parents 0467f56 + 3e98980 commit 09100eb
Show file tree
Hide file tree
Showing 22 changed files with 524 additions and 854 deletions.
8 changes: 8 additions & 0 deletions .changeset/serious-dryers-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@epics-dao/solv': patch
---

Update - rm priority fee

- small bug fix
- added new option to `solv swap` command
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@
"@changesets/cli": "2.27.1",
"@skeet-framework/utils": "1.2.4",
"@swc/core": "1.7.12",
"@types/node": "20.11.16",
"@types/node-fetch": "2.6.11",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@types/node": "22.5.4",
"@types/node-fetch": "3.0.2",
"@typescript-eslint/eslint-plugin": "8.5.0",
"@typescript-eslint/parser": "8.5.0",
"babel-loader": "9.1.3",
"bigint-buffer": "1.1.5",
"copyfiles": "2.4.1",
"esbuild": "0.20.0",
"eslint": "8.56.0",
"eslint": "9.10.0",
"eslint-config-prettier": "9.1.0",
"husky": "9.1.4",
"nodemon": "3.0.3",
"prettier": "3.2.5",
"tsup": "8.2.4",
"tsx": "4.8.1",
"turbo": "2.1.1",
"turbo": "2.1.2",
"typescript": "5.3.3"
},
"packageManager": "pnpm@9.3.0",
"dependencies": {
"discord.js": "^14.16.1"
"discord.js": "14.16.1",
"dotenv": "16.4.5"
}
}
14 changes: 7 additions & 7 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"react-internal.js"
],
"devDependencies": {
"@vercel/style-guide": "^5.2.0",
"eslint-config-turbo": "^1.12.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"typescript": "^5.3.3"
"@vercel/style-guide": "6.0.0",
"eslint-config-turbo": "2.1.2",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-only-warn": "1.1.0",
"@typescript-eslint/parser": "8.5.0",
"@typescript-eslint/eslint-plugin": "8.5.0",
"typescript": "5.3.3"
}
}
2 changes: 1 addition & 1 deletion packages/solv/src/cli/harvest/collectSOL.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getAllKeyPaths } from '@/config/config'
import { execSync, spawnSync } from 'child_process'
import { execSync, spawnSync } from 'node:child_process'
import { getHarvestBalance } from './getHarvestBalance'
import getBalance, { KeyType } from '@/lib/solana/getBalance'
import chalk from 'chalk'
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/harvest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import chalk from 'chalk'
import { transferSPLToken } from '@/lib/solana/transferSPLToken'
import { sendDiscord } from '@/lib/sendDiscord'
import mevOn from './mevOn'
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'
import { getEpochInfo } from '@/lib/getEpochInfo'
import { getSolanaAddress } from '@/lib/getSolanaAddress'
import { DefaultConfigType } from '@/config/types'
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/stake/createStakeAccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'

export const createStakeAccount = (
stakeKeypair: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/stake/deactivateStake.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Network } from '@/config/enums'
import readConfig from '@/config/readConfig'
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'

export const deactivateStake = async (stakeAccountPubkey: string) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/stake/delegateStake.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Network, NodeType } from '@/config/enums'
import readConfig from '@/config/readConfig'
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'

export const delegateStake = async (
stakeAccountPubkey: string,
Expand Down
4 changes: 0 additions & 4 deletions packages/solv/src/cli/stake/depositLST.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Connection, Keypair, PublicKey } from '@solana/web3.js'
import { askAmount } from '.'
import { PriorityLevel } from '@/lib/solana/priorityFee'
import { SOLV_POOL_MANAGER_ADDRESS } from '@/config/config'
import { getOrCreateDestinationAddress } from '@/lib/solana/getOrCreateDestinationAddress'
import { Spinner } from 'cli-spinner'
Expand All @@ -26,7 +25,6 @@ export const depositeLST = async (
spinner.setSpinnerTitle(
chalk.green(`✔︎ Checking Stake Pool ${poolAddress}...`),
)
const priorityFee = PriorityLevel.MEDIUM
const stakePoolAddress = new PublicKey(poolAddress)
const stakePool = await getStakePoolInfo(rpcUrl, poolAddress)
if (!stakePool) {
Expand Down Expand Up @@ -59,7 +57,6 @@ export const depositeLST = async (
connection,
fromWalletKey,
amount,
priorityFee,
stakePoolAddress,
new PublicKey(destinationTokenAccount),
new PublicKey(solvAssociatedTokenAccount),
Expand All @@ -80,7 +77,6 @@ export const depositeLST = async (
connection,
fromWalletKey,
amount,
priorityFee,
stakePoolAddress,
new PublicKey(destinationTokenAccount),
new PublicKey(solvAssociatedTokenAccount),
Expand Down
4 changes: 0 additions & 4 deletions packages/solv/src/cli/stake/elSOLdeposit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Connection, Keypair, PublicKey } from '@solana/web3.js'
import { askAmount } from '.'
import { PriorityLevel } from '@/lib/solana/priorityFee'
import { ELSOL_MINT_ADDRESS, SOLV_ELSOL_ACCOUNT_ADDRESS } from '@/config/config'
import { getOrCreateDestinationAddress } from '@/lib/solana/getOrCreateDestinationAddress'
import { Spinner } from 'cli-spinner'
Expand All @@ -25,7 +24,6 @@ export const elSOLdeposit = async (
spinner.setSpinnerTitle(
chalk.green(`✔︎ Checking Stake Pool ${poolAddress}...`),
)
const priorityFee = PriorityLevel.MEDIUM
const stakePoolAddress = new PublicKey(poolAddress)
const depositAuthority = Keypair.fromSecretKey(new Uint8Array(fromWalletKey))
const mintAddress = ELSOL_MINT_ADDRESS
Expand All @@ -45,7 +43,6 @@ export const elSOLdeposit = async (
connection,
fromWalletKey,
amount,
priorityFee,
stakePoolAddress,
new PublicKey(destinationTokenAccount),
new PublicKey(SOLV_ELSOL_ACCOUNT_ADDRESS),
Expand All @@ -67,7 +64,6 @@ export const elSOLdeposit = async (
connection,
fromWalletKey,
amount,
priorityFee,
stakePoolAddress,
new PublicKey(destinationTokenAccount),
new PublicKey(SOLV_ELSOL_ACCOUNT_ADDRESS),
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/stake/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import inquirer from 'inquirer'
import { existsAsync } from '@skeet-framework/utils'
import { elSOLdeposit } from './elSOLdeposit'
import { depositeLST } from './depositLST'
import { execSync } from 'child_process'
import { execSync } from 'node:child_process'
import { homedir } from 'os'
import { DefaultConfigType } from '@/config/types'
import { Network } from '@/config/enums'
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/cli/stake/withdrawStake.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawnSync } from 'child_process'
import { spawnSync } from 'node:child_process'

export const withdrawStake = async (
stakeAccountPubkey: string,
Expand Down
3 changes: 3 additions & 0 deletions packages/solv/src/cli/swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export const swapCommand = async (
.option('-o, --output <output>', 'Output token mint', '')
.option('-a, --amount <amount>', 'Input amount in lamports', '0')
.option('-s, --skip-confirm', 'Skip confirmation', false)
.option('-c, --init-config', 'Initialize config', false)
.action(
async (options: {
input: string
output: string
amount: number
skipConfirm: boolean
initConfig: boolean
}) => {
try {
await swapCmd(
Expand All @@ -44,6 +46,7 @@ export const swapCommand = async (
options.output,
Number(options.amount),
!options.skipConfirm,
options.initConfig,
)
} catch (error: any) {
if (error.message.includes('User force closed the prompt')) {
Expand Down
2 changes: 1 addition & 1 deletion packages/solv/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export enum MAINNET_TYPES {

// ⚠️ Please DO NOT forget to turn this to false if restart is not needed
export const NODE_RESTART_REQUIRED_MAINNET = false
export const NODE_RESTART_REQUIRED_TESTNET = true
export const NODE_RESTART_REQUIRED_TESTNET = false

export type CONFIG_TYPE = {
ID: string
Expand Down
3 changes: 0 additions & 3 deletions packages/solv/src/lib/solana/confirmTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import {
TransactionMessage,
VersionedTransaction,
} from '@solana/web3.js'
import { PriorityLevel } from './priorityFee'
import { getTestVersionedTxResult } from './getTestVersionedTxResult'

export const confirmTransaction = async (
connection: Connection,
fromWalletKeyString: string,
instructions: TransactionInstruction[],
priorityFee: PriorityLevel = PriorityLevel.LOW,
) => {
try {
const fromWalletKey = fromWalletKeyString.split(',').map(Number)
Expand All @@ -23,7 +21,6 @@ export const confirmTransaction = async (
connection,
fromWalletKeyString,
instructions,
priorityFee,
)
const versionedTx = new VersionedTransaction(
new TransactionMessage({
Expand Down
10 changes: 1 addition & 9 deletions packages/solv/src/lib/solana/depositSOL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ComputeBudgetProgram,
LAMPORTS_PER_SOL,
} from '@solana/web3.js'
import { PriorityLevel, getPriorityFeeEstimate } from './priorityFee'
import { SOLV_STAKE_POOL_ADDRESS } from '@/config/config'
import * as solanaStakePool from '@solana/spl-stake-pool'

Expand All @@ -20,7 +19,6 @@ export const depositSol = async (
connection: Connection,
fromWalletKey: number[],
SOL: number,
priorityFee: PriorityLevel = PriorityLevel.LOW,
stakePoolAddress: PublicKey = new PublicKey(SOLV_STAKE_POOL_ADDRESS),
destinationTokenAccount?: PublicKey,
referrerTokenAccount?: PublicKey,
Expand Down Expand Up @@ -49,15 +47,9 @@ export const depositSol = async (
txForEstimate.recentBlockhash = latestBlockhashAndContext.value.blockhash
txForEstimate.sign(...signers, fromWallet)

const estimatedFee = await getPriorityFeeEstimate(
connection.rpcEndpoint,
txForEstimate,
priorityFee,
)

const tx = new Transaction().add(...instructions).add(
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: Math.ceil(estimatedFee.priorityFeeEstimate),
microLamports: 1000,
}),
)

Expand Down
9 changes: 1 addition & 8 deletions packages/solv/src/lib/solana/getTestVersionedTxResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import {
TransactionMessage,
VersionedTransaction,
} from '@solana/web3.js'
import { PriorityLevel, getPriorityFeeEstimate } from './priorityFee'

export const getTestVersionedTxResult = async (
connection: Connection,
fromWalletKeyString: string,
instructions: TransactionInstruction[],
priorityFee: PriorityLevel = PriorityLevel.LOW,
) => {
const fromWalletKey = fromWalletKeyString.split(',').map(Number)
const fromWallet = Keypair.fromSecretKey(
Expand Down Expand Up @@ -46,15 +44,10 @@ export const getTestVersionedTxResult = async (
},
)
testVersionedTx.sign([fromWallet])
const estimatedFee = await getPriorityFeeEstimate(
connection.rpcEndpoint,
testVersionedTx,
priorityFee,
)

const result = {
testVersionedTx,
estimatedFee: estimatedFee.priorityFeeEstimate,
estimatedFee: 1000,
simulationResult,
latestBlockhashAndContext,
}
Expand Down
67 changes: 0 additions & 67 deletions packages/solv/src/lib/solana/priorityFee.ts

This file was deleted.

9 changes: 1 addition & 8 deletions packages/solv/src/lib/solana/solanaTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
VersionedTransaction,
TransactionMessage,
} from '@solana/web3.js'
import { PriorityLevel, getPriorityFeeEstimate } from './priorityFee'
import sleep from '../sleep'
import { MAX_RETRIES } from '@/config/constants'

Expand Down Expand Up @@ -67,12 +66,6 @@ export const solanaTransfer = async (

testVersionedTx.sign([fromWallet])

const estimatedFee = await getPriorityFeeEstimate(
connection.rpcEndpoint,
testVersionedTx,
PriorityLevel.MEDIUM,
)

const instructions = [
SystemProgram.transfer({
fromPubkey: fromWallet.publicKey,
Expand All @@ -85,7 +78,7 @@ export const solanaTransfer = async (
: 200_000,
}),
ComputeBudgetProgram.setComputeUnitPrice({
microLamports: Math.ceil(estimatedFee.priorityFeeEstimate),
microLamports: 1000,
}),
]

Expand Down
Loading

0 comments on commit 09100eb

Please sign in to comment.