import { Connection, Account, PublicKey } from '@solana/web3.js';
import { createPool } from '@bonfida/bot';
import { signAndSendTransactionInstructions, Numberu64 } from '@bonfida/bot';
import { ENDPOINTS } from '@bonfida/bot';
const connection = new Connection(ENDPOINTS.mainnet);
const sourceOwnerAccount = new Account(['<MY PRIVATE KEY ARRAY>']);
const signalProviderAccount = new Account(['<MY PRIVATE KEY ARRAY AGAIN>']);
// The payer account will pay for the fees involved with the transaction.
// For the sake of simplicity, we choose the source owner.
const payerAccount = sourceOwnerAccount;
// Creating a pool means making the initial deposit.
// Any number of assets can be added. For each asset, the public key of the payer token account should be provided.
// The deposit amounts are also given, with the precision (mostly 6 decimals) of the respective token.
const sourceAssetKeys = [
new PublicKey('<First asset Key>'),
new PublicKey('<Second asset Key>'),
const deposit_amounts = [1000000, 1000000]; // This corresponds to 1 token of each with 6 decimals precisions
//Fetching the number of decimals using the mint of a token can be done with:
export const decimalsFromMint = async (
const result = await connection.getParsedAccountInfo(mint);
const decimals = result?.value?.data?.parsed?.info?.decimals;
throw new Error('Invalid mint');
// Maximum number of assets that can be held by the pool at any given time.
// A higher number means more flexibility but increases the initial pool account allocation fee.
const maxNumberOfAsset = 10;
// It is necessary for the purpose of security to hardcode all Serum markets that will be usable by the pool.
// It is advised to put here as many trusted markets with enough liquidity as required.
new PublicKey('E14BKBhDWD4EuTkWj1ooZezesGxMW8LPCps4W5PuzZJo'),
]; // FIDA/USDC market address, for example
// Market addresses can be fetched with:
}).lastIndexOf('<Market name, FIDA/USDC for instance>')
// Interval of time in seconds between two fee collections. This must be greater or equal to a week (604800 s).
const feeCollectionPeriod = new Numberu64(604800);
// Total percentage of the pool to be collected as fees (which are split up between teh signal provider and Bonfida) at an interval defined by feeCollectionPeriod
const feePercentage = 0.1;
const pool = async () => {
let [poolSeed, createInstructions] = await createPool(
sourceOwnerAccount.publicKey,
signalProviderAccount.publicKey,
await signAndSendTransactionInstructions(
[sourceOwnerAccount], // The owner of the source asset accounts must sign this transaction.
console.log('Created Pool');