Skip to content

Commit e8902bc

Browse files
committed
Format
1 parent 51bc3a0 commit e8902bc

File tree

6 files changed

+65
-75
lines changed

6 files changed

+65
-75
lines changed

ts-sdk/whirlpool/src/createPool.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@ import {
1111
import type {
1212
Address,
1313
GetAccountInfoApi,
14-
GetMinimumBalanceForRentExemptionApi,
1514
GetMultipleAccountsApi,
1615
IInstruction,
1716
Lamports,
1817
Rpc,
1918
TransactionSigner,
2019
} from "@solana/web3.js";
2120
import { generateKeyPairSigner, lamports } from "@solana/web3.js";
22-
import { fetchSysvarRent } from "@solana/sysvars"
2321
import {
2422
DEFAULT_ADDRESS,
2523
FUNDER,
@@ -252,10 +250,12 @@ export async function createConcentratedLiquidityPoolInstructions(
252250
stateSpaces.map(async (space) => {
253251
const rentExemption = await calculateMinimumBalance(rpc, space);
254252
return rentExemption;
255-
})
253+
}),
254+
);
255+
256+
const nonRefundableRent = lamports(
257+
nonRefundableRents.reduce((a, b) => a + b, 0n),
256258
);
257-
258-
const nonRefundableRent = lamports(nonRefundableRents.reduce((a, b) => a + b, 0n));
259259

260260
return {
261261
instructions,

ts-sdk/whirlpool/src/sysvar.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { fetchSysvarRent } from "@solana/sysvars"
2-
import { GetAccountInfoApi, lamports, Rpc } from "@solana/web3.js";
3-
import type { Lamports } from "@solana/web3.js";
1+
import { fetchSysvarRent } from "@solana/sysvars";
2+
import { lamports } from "@solana/web3.js";
3+
import type { Lamports, GetAccountInfoApi, Rpc } from "@solana/web3.js";
44

55
/**
66
* The overhead storage size for accounts.
@@ -14,11 +14,15 @@ const ACCOUNT_STORAGE_OVERHEAD = 128;
1414
* @param {number} dataSize - The size of the account data in bytes.
1515
* @returns {Promise<BigInt>} The minimum balance required for rent exemption in lamports.
1616
*/
17-
export async function calculateMinimumBalance(rpc: Rpc<GetAccountInfoApi>, dataSize: number): Promise<Lamports> {
17+
export async function calculateMinimumBalance(
18+
rpc: Rpc<GetAccountInfoApi>,
19+
dataSize: number,
20+
): Promise<Lamports> {
1821
const rent = await fetchSysvarRent(rpc);
1922
const actualDataLen = BigInt(dataSize + ACCOUNT_STORAGE_OVERHEAD);
2023
const rentLamportsPerYear = rent.lamportsPerByteYear * actualDataLen;
21-
const minimumBalance = rentLamportsPerYear * BigInt(Math.floor(rent.exemptionThreshold));
22-
23-
return lamports(minimumBalance)
24-
}
24+
const minimumBalance =
25+
rentLamportsPerYear * BigInt(Math.floor(rent.exemptionThreshold));
26+
27+
return lamports(minimumBalance);
28+
}

ts-sdk/whirlpool/src/token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {
3333
getTransferSolInstruction,
3434
} from "@solana-program/system";
3535
import { getTokenSize } from "@solana-program/token";
36-
import { TOKEN_2022_PROGRAM_ADDRESS, getTokenSize as getToken22Size } from "@solana-program/token-2022"
36+
import { getTokenSize as getToken22Size } from "@solana-program/token-2022";
3737
import type { ExtensionArgs, Mint } from "@solana-program/token-2022";
3838
import type { TransferFee } from "@orca-so/whirlpools-core";
3939
import assert from "assert";

ts-sdk/whirlpool/tests/createPool.test.ts

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,14 @@ import {
99
SPLASH_POOL_TICK_SPACING,
1010
} from "../src/config";
1111
import { setupMint } from "./utils/token";
12-
import { setupMintTE, setupMintTEFee } from "./utils/tokenExtensions";
12+
import { setupMintTEFee } from "./utils/tokenExtensions";
1313
import { orderMints } from "../src/token";
1414
import { rpc, sendTransaction, signer } from "./utils/mockRpc";
15-
import {
16-
fetchMaybeWhirlpool,
17-
} from "@orca-so/whirlpools-client";
15+
import { fetchMaybeWhirlpool } from "@orca-so/whirlpools-client";
1816
import assert from "assert";
1917
import type { Address } from "@solana/web3.js";
2018
import { assertAccountExists, lamports } from "@solana/web3.js";
21-
import {
22-
_TICK_ARRAY_SIZE,
23-
priceToSqrtPrice,
24-
} from "@orca-so/whirlpools-core";
19+
import { _TICK_ARRAY_SIZE, priceToSqrtPrice } from "@orca-so/whirlpools-core";
2520

2621
describe("Create Pool", () => {
2722
let mintA: Address;
@@ -54,15 +49,11 @@ describe("Create Pool", () => {
5449
let signerAccount = await rpc.getAccountInfo(signer.address).send();
5550
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
5651

57-
const { instructions, poolAddress, estInitializationCost } = await createSplashPoolInstructions(
58-
rpc,
59-
mintA,
60-
mintB,
61-
price,
62-
);
52+
const { instructions, poolAddress, estInitializationCost } =
53+
await createSplashPoolInstructions(rpc, mintA, mintB, price);
6354

6455
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
65-
assert.strictEqual(maybePool.exists, false)
56+
assert.strictEqual(maybePool.exists, false);
6657

6758
await sendTransaction(instructions);
6859

@@ -92,15 +83,11 @@ describe("Create Pool", () => {
9283
let signerAccount = await rpc.getAccountInfo(signer.address).send();
9384
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
9485

95-
const { instructions, poolAddress, estInitializationCost } = await createSplashPoolInstructions(
96-
rpc,
97-
mintC,
98-
mintD,
99-
price,
100-
);
86+
const { instructions, poolAddress, estInitializationCost } =
87+
await createSplashPoolInstructions(rpc, mintC, mintD, price);
10188

10289
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
103-
assert.strictEqual(maybePool.exists, false)
90+
assert.strictEqual(maybePool.exists, false);
10491

10592
await sendTransaction(instructions);
10693

@@ -130,15 +117,11 @@ describe("Create Pool", () => {
130117
let signerAccount = await rpc.getAccountInfo(signer.address).send();
131118
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
132119

133-
const { instructions, poolAddress, estInitializationCost } = await createSplashPoolInstructions(
134-
rpc,
135-
mintC,
136-
mintD,
137-
price,
138-
);
120+
const { instructions, poolAddress, estInitializationCost } =
121+
await createSplashPoolInstructions(rpc, mintC, mintD, price);
139122

140123
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
141-
assert.strictEqual(maybePool.exists, false)
124+
assert.strictEqual(maybePool.exists, false);
142125

143126
await sendTransaction(instructions);
144127

@@ -159,23 +142,24 @@ describe("Create Pool", () => {
159142
});
160143

161144
it("Should create concentrated liquidity pool", async () => {
162-
const tickSpacing = 64
145+
const tickSpacing = 64;
163146
const price = 10;
164147
const sqrtPrice = priceToSqrtPrice(price, 6, 6);
165148

166149
let signerAccount = await rpc.getAccountInfo(signer.address).send();
167150
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
168151

169-
const { instructions, poolAddress, estInitializationCost } = await createConcentratedLiquidityPoolInstructions(
170-
rpc,
171-
mintA,
172-
mintB,
173-
tickSpacing,
174-
price,
175-
);
152+
const { instructions, poolAddress, estInitializationCost } =
153+
await createConcentratedLiquidityPoolInstructions(
154+
rpc,
155+
mintA,
156+
mintB,
157+
tickSpacing,
158+
price,
159+
);
176160

177161
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
178-
assert.strictEqual(maybePool.exists, false)
162+
assert.strictEqual(maybePool.exists, false);
179163

180164
await sendTransaction(instructions);
181165

@@ -206,16 +190,17 @@ describe("Create Pool", () => {
206190
let signerAccount = await rpc.getAccountInfo(signer.address).send();
207191
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
208192

209-
const { instructions, poolAddress, estInitializationCost } = await createConcentratedLiquidityPoolInstructions(
210-
rpc,
211-
mintC,
212-
mintD,
213-
tickSpacing,
214-
price,
215-
);
193+
const { instructions, poolAddress, estInitializationCost } =
194+
await createConcentratedLiquidityPoolInstructions(
195+
rpc,
196+
mintC,
197+
mintD,
198+
tickSpacing,
199+
price,
200+
);
216201

217202
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
218-
assert.strictEqual(maybePool.exists, false)
203+
assert.strictEqual(maybePool.exists, false);
219204

220205
await sendTransaction(instructions);
221206

@@ -246,16 +231,17 @@ describe("Create Pool", () => {
246231
let signerAccount = await rpc.getAccountInfo(signer.address).send();
247232
const balanceBefore = signerAccount.value?.lamports ?? lamports(0n);
248233

249-
const { instructions, poolAddress, estInitializationCost } = await createConcentratedLiquidityPoolInstructions(
250-
rpc,
251-
mintC,
252-
mintD,
253-
tickSpacing,
254-
price,
255-
);
234+
const { instructions, poolAddress, estInitializationCost } =
235+
await createConcentratedLiquidityPoolInstructions(
236+
rpc,
237+
mintC,
238+
mintD,
239+
tickSpacing,
240+
price,
241+
);
256242

257243
const maybePool = await fetchMaybeWhirlpool(rpc, poolAddress);
258-
assert.strictEqual(maybePool.exists, false)
244+
assert.strictEqual(maybePool.exists, false);
259245

260246
await sendTransaction(instructions);
261247

ts-sdk/whirlpool/tests/token.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,21 +479,21 @@ describe("Token Account Creation", () => {
479479
});
480480

481481
it("Should get the correct token size for TOKEN_PROGRAM mint", async () => {
482-
const mintAccount = await fetchMint(rpc, mintA)
483-
const tokenSize = getTokenSizeForMint(mintAccount)
482+
const mintAccount = await fetchMint(rpc, mintA);
483+
const tokenSize = getTokenSizeForMint(mintAccount);
484484
assert.strictEqual(tokenSize, 165);
485485
});
486486

487487
it("Should get the correct token size for TOKEN_2022_PROGRAM mint", async () => {
488488
const mint = await setupMintTE();
489-
const mintAccount = await fetchMint(rpc, mint)
490-
const tokenSize = getTokenSizeForMint(mintAccount)
489+
const mintAccount = await fetchMint(rpc, mint);
490+
const tokenSize = getTokenSizeForMint(mintAccount);
491491
assert.strictEqual(tokenSize, 165);
492492
});
493493

494494
it("Should get the correct token size for TOKEN_2022_PROGRAM mint with", async () => {
495-
const mintAccount = await fetchMint(rpc, mintTE)
496-
const tokenSize = getTokenSizeForMint(mintAccount)
495+
const mintAccount = await fetchMint(rpc, mintTE);
496+
const tokenSize = getTokenSizeForMint(mintAccount);
497497
assert.strictEqual(tokenSize, 178);
498498
});
499499
});

ts-sdk/whirlpool/tests/utils/mockRpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ async function mockTransport<T>(
236236
slotsInEpoch: 32n,
237237
transactionCount: 0n,
238238
});
239-
}
239+
}
240240
return Promise.reject(
241241
`Method ${config.payload.method} not supported in mock transport`,
242242
);

0 commit comments

Comments
 (0)