Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@everstake/eversol-ts-sdk

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@everstake/eversol-ts-sdk - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

41

eversol-ts-sdk/eSol.js

@@ -7,2 +7,3 @@ import { ESolConfig } from './config';

import { DAO_STATE_LAYOUT, COMMUNITY_TOKEN_LAYOUT, METRICS_DEPOSIT_REFERRER_LAYOUT, REFERRER_LIST_LAYOUT, } from './service/layouts';
import { TRANSACTION_FEE, RENT_EXEMPTION_FEE } from './service/constants';
import { ASSOCIATED_TOKEN_PROGRAM_ID, Token, TOKEN_PROGRAM_ID } from '@solana/spl-token';

@@ -16,3 +17,5 @@ export class ESol {

const userSolBalance = await CONNECTION.getBalance(userAddress, 'confirmed');
if (userSolBalance < lamports) {
const transactionFee = solToLamports(TRANSACTION_FEE);
const lamportsWithFee = lamports + transactionFee;
if (userSolBalance < lamportsWithFee) {
throw new Error(`Not enough SOL to deposit into pool. Maximum deposit amount is ${lamportsToSol(userSolBalance)} SOL.`);

@@ -173,3 +176,9 @@ }

const stakePool = await getStakePoolAccount(CONNECTION, stakePoolAddress);
const poolAmount = solToLamports(solAmount);
const lamportsToWithdraw = solToLamports(solAmount);
const userSolBalance = await CONNECTION.getBalance(userAddress, 'confirmed');
const transactionFee = solToLamports(TRANSACTION_FEE);
const rentExemptionFee = solToLamports(RENT_EXEMPTION_FEE);
if (userSolBalance < transactionFee + rentExemptionFee) {
throw Error("You don't have enough SOL to complete this transaction");
}
// dao part

@@ -191,3 +200,3 @@ const daoStateDtoInfo = await PublicKey.findProgramAddress([Buffer.from(this.config.seedPrefixDaoState), stakePoolAddress.toBuffer(), StakePoolProgram.programId.toBuffer()], StakePoolProgram.programId);

const rate = rateOfExchange ? rateOfExchange.numerator.toNumber() / rateOfExchange.denominator.toNumber() : 1;
const solToWithdraw = poolAmount * rate;
const solToWithdraw = lamportsToWithdraw * rate;
if ((reserveStake === null || reserveStake === void 0 ? void 0 : reserveStake.lamports) || (reserveStake === null || reserveStake === void 0 ? void 0 : reserveStake.lamports) === 0) {

@@ -206,4 +215,4 @@ const availableAmount = (reserveStake === null || reserveStake === void 0 ? void 0 : reserveStake.lamports) - stakeReceiverAccountBalance;

// Check withdrawFrom balance
if (tokenAccount.amount.toNumber() < poolAmount) {
throw new Error(`Not enough token balance to withdraw ${lamportsToSol(poolAmount)} pool tokens.
if (tokenAccount.amount.toNumber() < lamportsToWithdraw) {
throw new Error(`Not enough token balance to withdraw ${lamportsToSol(lamportsToWithdraw)} pool tokens.
Maximum withdraw amount is ${lamportsToSol(tokenAccount.amount.toNumber())} pool tokens.`);

@@ -261,3 +270,3 @@ }

}
instructions.push(Token.createApproveInstruction(TOKEN_PROGRAM_ID, poolTokenAccount, userTransferAuthority.publicKey, tokenOwner, [], poolAmount));
instructions.push(Token.createApproveInstruction(TOKEN_PROGRAM_ID, poolTokenAccount, userTransferAuthority.publicKey, tokenOwner, [], lamportsToWithdraw));
const poolWithdrawAuthority = await findWithdrawAuthorityProgramAddress(StakePoolProgram.programId, stakePoolAddress);

@@ -287,3 +296,3 @@ if (solWithdrawAuthority) {

lamportsTo: solReceiver,
poolTokens: poolAmount,
poolTokens: lamportsToWithdraw,
});

@@ -303,3 +312,9 @@ instructions.push(withdrawTransaction);

const stakePool = await getStakePoolAccount(CONNECTION, stakePoolAddress);
const poolAmount = solToLamports(solAmount);
const lamportsToWithdraw = solToLamports(solAmount);
const userSolBalance = await CONNECTION.getBalance(userAddress, 'confirmed');
const transactionFee = solToLamports(TRANSACTION_FEE);
const rentExemptionFee = solToLamports(RENT_EXEMPTION_FEE);
if (userSolBalance < transactionFee + rentExemptionFee) {
throw Error("You don't have enough SOL to complete this transaction");
}
// dao part

@@ -325,4 +340,4 @@ const daoStateDtoInfo = await PublicKey.findProgramAddress([Buffer.from(this.config.seedPrefixDaoState), stakePoolAddress.toBuffer(), StakePoolProgram.programId.toBuffer()], StakePoolProgram.programId);

// Check withdrawFrom balance
if (tokenAccount.amount.toNumber() < poolAmount) {
throw new Error(`Not enough token balance to withdraw ${lamportsToSol(poolAmount)} pool tokens.
if (tokenAccount.amount.toNumber() < lamportsToWithdraw) {
throw new Error(`Not enough token balance to withdraw ${lamportsToSol(lamportsToWithdraw)} pool tokens.
Maximum withdraw amount is ${lamportsToSol(tokenAccount.amount.toNumber())} pool tokens.`);

@@ -383,4 +398,4 @@ }

}
instructions.push(Token.createApproveInstruction(TOKEN_PROGRAM_ID, poolTokenAccount, userTransferAuthority.publicKey, userAddress, [], poolAmount));
const withdrawAccount = await prepareWithdrawAccounts(CONNECTION, stakePool.account.data, stakePoolAddress, poolAmount);
instructions.push(Token.createApproveInstruction(TOKEN_PROGRAM_ID, poolTokenAccount, userTransferAuthority.publicKey, userAddress, [], lamportsToWithdraw));
const withdrawAccount = await prepareWithdrawAccounts(CONNECTION, stakePool.account.data, stakePoolAddress, lamportsToWithdraw);
if (!withdrawAccount) {

@@ -390,3 +405,3 @@ throw Error(`Not available at the moment. Please try again later. Sorry for the inconvenience.`);

const availableSol = lamportsToSol(withdrawAccount.poolAmount);
if (withdrawAccount.poolAmount < poolAmount) {
if (withdrawAccount.poolAmount < lamportsToWithdraw) {
throw Error(`Currently, you can undelegate only ${availableSol} SOL within one transaction due to delayed unstake limitations. Please unstake the desired amount in few transactions. Note that you will be able to track your unstaked SOL in the “Wallet” tab as a summary of transactions!.`);

@@ -393,0 +408,0 @@ }

/// <reference types="node" />
export declare const TRANSIENT_STAKE_SEED_PREFIX: Buffer;
export declare const TRANSACTION_FEE = 0.000005;
export declare const RENT_EXEMPTION_FEE = 0.00203928;
export const TRANSIENT_STAKE_SEED_PREFIX = Buffer.from('transient');
export const TRANSACTION_FEE = 0.000005;
export const RENT_EXEMPTION_FEE = 0.00203928;

@@ -79,2 +79,3 @@ import { PublicKey } from '@solana/web3.js';

totalLamportsLiquidity: BN;
maxValidatorYieldPerEpochNumerator: BN;
}

@@ -81,0 +82,0 @@ export declare const DAO_STATE_LAYOUT: any;

@@ -67,2 +67,3 @@ import { publicKey, struct, u32, u64, u16, u8, option, vec, bool } from '@project-serum/borsh';

u64('totalLamportsLiquidity'),
u32("maxValidatorYieldPerEpochNumerator")
]);

@@ -69,0 +70,0 @@ export const VALIDATOR_STAKE_INFO_LAYOUT = struct([

{
"name": "@everstake/eversol-ts-sdk",
"version": "1.0.4",
"version": "1.0.5",
"description": "Eversol ts sdk",

@@ -5,0 +5,0 @@ "main": "eversol-ts-sdk/index.js",

@@ -40,3 +40,3 @@ <div align="center">

const depositSolTransaction = await eSol.depositSolTransaction(userAddress, amountLamports, referrerAccount)
// referrerAccount - should be exist in referrer list (contact our team to add your address)
// referrerAccount - should exist in referrer list (contact our team to add your address)
// than sign and send the `transaction`

@@ -69,1 +69,41 @@ ```

- [Eversol docs](https://docs.eversol.one/overview/welcome-to-eversol)
export const STAKE_POOL_LAYOUT = struct<StakePool>([
// rustEnum(AccountTypeKind, 'accountType'),
u8("accountType"),
publicKey("manager"),
publicKey("staker"),
publicKey("stakeDepositAuthority"),
u8("stakeWithdrawBumpSeed"),
publicKey("validatorList"),
publicKey("reserveStake"),
publicKey("poolMint"),
publicKey("managerFeeAccount"),
publicKey("tokenProgramId"),
u64("totalLamports"),
u64("poolTokenSupply"),
u64("lastUpdateEpoch"),
struct([u64("unixTimestamp"), u64("epoch"), publicKey("custodian")], "lockup"),
struct(feeFields, "epochFee"),
option(struct(feeFields), "nextEpochFee"),
option(publicKey(), "preferredDepositValidatorVoteAddress"),
option(publicKey(), "preferredWithdrawValidatorVoteAddress"),
struct(feeFields, "stakeDepositFee"),
struct(feeFields, "stakeWithdrawalFee"),
option(struct(feeFields), "nextWithdrawalFee"),
u8("stakeReferralFee"),
option(publicKey(), "solDepositAuthority"),
struct(feeFields, "solDepositFee"),
u8("solReferralFee"),
option(publicKey(), "solWithdrawAuthority"),
struct(feeFields, "solWithdrawalFee"),
option(struct(feeFields), "nextSolWithdrawalFee"),
u64("lastEpochPoolTokenSupply"),
u64("lastEpochTotalLamports"),
option(struct(rateOfExchangeFields), "rateOfExchange"),
publicKey("treasuryFeeAccount"),
struct(feeFields, "treasuryFee"),
u64("totalLamportsLiquidity"),
]);
maxValidatorYieldPerEpochNumerator: BN;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc