@everlend/general-pool
Advanced tools
Comparing version 0.0.16 to 0.0.17
@@ -29,3 +29,8 @@ /// <reference types="node" /> | ||
}): Promise<Pool[]>; | ||
static calcETokenRate(amounts: { | ||
poolMintSupply: number; | ||
totalAmountBorrowed: number; | ||
tokenAccountAmount: number; | ||
}): number; | ||
} | ||
export {}; |
@@ -75,4 +75,8 @@ "use strict"; | ||
} | ||
static calcETokenRate(amounts) { | ||
const { poolMintSupply, totalAmountBorrowed, tokenAccountAmount } = amounts; | ||
return poolMintSupply / (totalAmountBorrowed + tokenAccountAmount); | ||
} | ||
} | ||
exports.Pool = Pool; | ||
//# sourceMappingURL=pool.js.map |
{ | ||
"name": "@everlend/general-pool", | ||
"version": "0.0.16", | ||
"version": "0.0.17", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -58,3 +58,15 @@ import { AccountInfo, Connection, PublicKey } from '@solana/web3.js' | ||
static async findMany(connection: Connection, filters: { poolMarket?: PublicKey } = {}) { | ||
/** | ||
* Finds general pools. Also, can filter them. | ||
* | ||
* @param connection the JSON RPC connection instance. | ||
* @param filters the filter config object. | ||
*/ | ||
static async findMany( | ||
connection: Connection, | ||
filters: { | ||
/** the public key which represents the main manager root account which is used for generating PDAs. */ | ||
poolMarket?: PublicKey | ||
} = {}, | ||
) { | ||
return ( | ||
@@ -87,2 +99,20 @@ await GeneralPoolsProgram.getProgramAccounts(connection, { | ||
} | ||
/** | ||
* Calculates e-token rate. | ||
* | ||
* @param amounts the amount values needed for the calculation. | ||
*/ | ||
static calcETokenRate(amounts: { | ||
/** the total supply of a pool collateral token mint. */ | ||
poolMintSupply: number | ||
/** the amount of tokens borrowed from a pool. */ | ||
totalAmountBorrowed: number | ||
/** the amount of tokens left in a pool. */ | ||
tokenAccountAmount: number | ||
}) { | ||
const { poolMintSupply, totalAmountBorrowed, tokenAccountAmount } = amounts | ||
return poolMintSupply / (totalAmountBorrowed + tokenAccountAmount) | ||
} | ||
} |
@@ -69,5 +69,16 @@ import { AccountType, GeneralPoolsProgram } from '../program' | ||
/** | ||
* Finds user's unfinished withdrawal requests. Also, can filter them. | ||
* | ||
* @param connection the JSON RPC connection instance. | ||
* @param filters the filter config object. | ||
*/ | ||
static async findMany( | ||
connection: Connection, | ||
filters: { pool?: PublicKey; from?: PublicKey } = {}, | ||
filters: { | ||
/** the public key which represents a general pool address. */ | ||
pool?: PublicKey | ||
/** the public key which initialized withdrawal requests, usually user's SOL account (owner address). */ | ||
from?: PublicKey | ||
} = {}, | ||
) { | ||
@@ -74,0 +85,0 @@ return ( |
@@ -36,9 +36,15 @@ import { AccountLayout, MintLayout, TOKEN_PROGRAM_ID, NATIVE_MINT, Token } from '@solana/spl-token' | ||
/** The type is returned by actions, e.g. [[prepareDepositTx]] or [[prepareWithdrawalRequestTx]]. */ | ||
export type ActionResult = { | ||
/** the prepared transaction, ready for signing and sending. */ | ||
tx: Transaction | ||
/** the additional key pairs which may be needed for signing and sending transactions. */ | ||
keypairs?: Record<string, Keypair> | ||
} | ||
/** The type is used for actions params, e.g. [[prepareDepositTx]] or [[prepareWithdrawalRequestTx]]. */ | ||
export type ActionOptions = { | ||
/** the JSON RPC connection instance. */ | ||
connection: Connection | ||
/** the fee payer public key, can be user's SOL address (owner address). */ | ||
payerPublicKey: PublicKey | ||
@@ -127,2 +133,18 @@ } | ||
/** | ||
* Creates a transaction object for depositing to a general pool. | ||
* Also adds an extra instruction for creating a collateral token ATA (pool mint ATA) if a destination account doesn't exist. | ||
* If depositing SOL, the wrapping process takes place. | ||
* | ||
* @param actionOptions | ||
* @param pool the general pool public key for a specific token, e.g. there can be a general pool for USDT or USDC etc. | ||
* @param registry the public key of the registry (the program that stores a registry config). | ||
* @param amount the amount of tokens in lamports to deposit. | ||
* @param source the public key which represents user's token ATA (token mint ATA) from which the token amount will be taken. | ||
* When depositing native SOL it will be replaced by a newly generated ATA for wrapped SOL, created by `payerPublicKey` from [[ActionOptions]]. | ||
* @param destination the public key which represents user's collateral token ATA (pool mint ATA) where collateral tokens | ||
* will be sent after a deposit. | ||
* | ||
* @returns the object with a prepared deposit transaction and generated keypair if depositing SOL. | ||
*/ | ||
export const prepareDepositTx = async ( | ||
@@ -216,2 +238,22 @@ { connection, payerPublicKey }: ActionOptions, | ||
/** | ||
* Creates a transaction object for a withdrawal request from a general pool. | ||
* Also adds an extra instruction for creating a token ATA (token mint ATA) if a destination account doesn't exist. | ||
* | ||
* **NB! Everlend has a 2-step withdrawal process. The first one is creating a withdrawal request, the second one is an | ||
* actual token transfer from a general pool to user's account.** | ||
* | ||
* This function generates a transaction for the first step. | ||
* | ||
* @param actionOptions | ||
* @param pool the general pool public key for a specific token, e.g. there can be a general pool for USDT or USDC etc. | ||
* @param registry the public key of the registry (the program that stores a registry config). | ||
* @param collateralAmount the amount of collateral tokens in lamports which will be taken from a user. | ||
* @param source the public key which represents user's collateral token ATA (pool mint ATA) from which the collateral tokens will be taken. | ||
* @param destination the public key which represents user's token ATA (token mint ATA) to which the withdrawn from | ||
* a general pool tokens will be sent. The param isn't used when withdrawing SOL. There is wrapped SOL unwrapping logic | ||
* during the process, thus SOL is sent directly to user's native SOL address (owner address). | ||
* | ||
* @returns the object with a prepared withdrawal request transaction. | ||
*/ | ||
export const prepareWithdrawalRequestTx = async ( | ||
@@ -277,2 +319,18 @@ { connection, payerPublicKey }: ActionOptions, | ||
/** | ||
* Creates a transaction object for a withdrawal from a general pool. | ||
* Also adds an extra instruction for creating a token ATA (token mint ATA) if a destination account doesn't exist. | ||
* | ||
* **NB! Everlend has a 2-step withdrawal process. The first one is creating a withdrawal request, the second one is an | ||
* actual token transfer from a general pool to user's account.** | ||
* | ||
* This function generates a transaction for the second step. Generally the second step is automatic but there can be a case when | ||
* a user deletes their token ATA right after creating a withdrawal request. In such a case the second step cannot be | ||
* finished automatically. This function allows re-opening the token ATA and finish the withdrawal process. | ||
* | ||
* @param actionOptions | ||
* @param withdrawalRequest the withdrawal request public key. | ||
* | ||
* @returns the object with a prepared withdrawal transaction. | ||
*/ | ||
export const prepareWithdrawalTx = async ( | ||
@@ -345,2 +403,5 @@ { connection, payerPublicKey }: ActionOptions, | ||
/** | ||
* Creates a transaction object for borrowing from a general pool. | ||
*/ | ||
export const prepareBorrowTx = async ( | ||
@@ -347,0 +408,0 @@ { connection, payerPublicKey }: ActionOptions, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
149211
89
3069
1
89
0