-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for createPool.ts (#501)
* Base createPool test * Process feedback. Improve createPool.ts tests. Attempt modify sysvarFees. * Fix calculation of initizialization costs. Add createPool tests. * Clean up * Clean up * Clean up * Resolve minor comments * Restructure tests. Add getTokenSizeByProgram function, including tests. * Resolve comments. Fix minor bug tih token size calculation based on extensions array. * Format * Update doc on core-sdks (unrelated) * Update doc on core-sdks (unrelated) * Format * Resolve comments * Revert changes * Revert changes * Revert changes * Resolve comments * Resolve comments * Fromat --------- Co-authored-by: calintje <csimon@orca.so>
- Loading branch information
Showing
16 changed files
with
492 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { SysvarRent } from "@solana/sysvars"; | ||
|
||
/** | ||
* The overhead storage size for accounts. | ||
*/ | ||
const ACCOUNT_STORAGE_OVERHEAD = 128; | ||
|
||
/** | ||
* Calculates the minimum balance required for rent exemption for a given account size. | ||
* | ||
* @param {Rpc} rpc - The Solana RPC client to fetch sysvar rent data. | ||
* @param {number} dataSize - The size of the account data in bytes. | ||
* @returns {bigint} The minimum balance required for rent exemption in lamports. | ||
*/ | ||
export function calculateMinimumBalanceForRentExemption( | ||
rent: SysvarRent, | ||
dataSize: number, | ||
): bigint { | ||
const dataSizeForRent = BigInt(dataSize + ACCOUNT_STORAGE_OVERHEAD); | ||
const rentLamportsPerYear = rent.lamportsPerByteYear * dataSizeForRent; | ||
const minimumBalance = rentLamportsPerYear * BigInt(rent.exemptionThreshold); | ||
|
||
return minimumBalance; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.