diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/.prettierrc @@ -0,0 +1 @@ +{} diff --git a/src/constants.ts b/src/constants.ts index 05c4d034..c69e51f5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -71,12 +71,12 @@ export const QUARRY_CODERS = buildCoderMap<{ * Recipient of protocol fees. */ export const QUARRY_FEE_TO = new PublicKey( - "4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ" + "4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ", ); /** * Sets the protocol fees. */ export const QUARRY_FEE_SETTER = new PublicKey( - "4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ" + "4MMZH3ih1aSty2nx4MC3kSR94Zb55XsXnqb5jfEcyHWQ", ); diff --git a/src/sdk.ts b/src/sdk.ts index c158da77..503472ff 100644 --- a/src/sdk.ts +++ b/src/sdk.ts @@ -31,7 +31,7 @@ import { RedeemerWrapper } from "./wrappers/redeemer"; export class QuarrySDK { constructor( readonly provider: AugmentedProvider, - readonly programs: Programs + readonly programs: Programs, ) {} /** @@ -71,7 +71,7 @@ export class QuarrySDK { */ newTx( instructions: TransactionInstruction[], - signers?: Signer[] + signers?: Signer[], ): TransactionEnvelope { return this.provider.newTX(instructions, signers); } @@ -93,7 +93,7 @@ export class QuarrySDK { const programs = newProgramMap( provider, QUARRY_IDLS, - allAddresses + allAddresses, ); return new QuarrySDK(new SolanaAugmentedProvider(provider), programs); } diff --git a/src/wrappers/mergeMine/mergeMiner.ts b/src/wrappers/mergeMine/mergeMiner.ts index 9e08ee16..b381684e 100644 --- a/src/wrappers/mergeMine/mergeMiner.ts +++ b/src/wrappers/mergeMine/mergeMiner.ts @@ -31,7 +31,7 @@ export class MergeMiner { readonly mm: { key: PublicKey; data: MergeMinerData; - } + }, ) {} get provider(): Provider { @@ -83,7 +83,7 @@ export class MergeMiner { mmPrimaryTokenAccount, owner, [], - amount.toU64() + amount.toU64(), ), ]).combine(await this.stakePrimaryMiner(rewarder)); } @@ -160,7 +160,7 @@ export class MergeMiner { systemProgram: SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, }, - }) + }), ); if (minerReplicaMintTokenAccount.instruction) { txEnv.instructions.unshift(minerReplicaMintTokenAccount.instruction); @@ -186,11 +186,11 @@ export class MergeMiner { }): Promise { const withdrawPrimary = await this.unstakePrimaryMiner(rewarder, amount); const withdrawPrimaryFromMM = await this.withdrawTokens( - amount.token.mintAccount + amount.token.mintAccount, ); return TransactionEnvelope.combineAll( withdrawPrimary, - withdrawPrimaryFromMM + withdrawPrimaryFromMM, ); } @@ -224,7 +224,7 @@ export class MergeMiner { */ async unstakePrimaryMiner( rewarder: PublicKey, - amount: TokenAmount + amount: TokenAmount, ): Promise { const stake = await this.getPrimaryStakeAccounts(rewarder); const mmPrimaryTokenAccount = await getATAAddress({ @@ -312,7 +312,7 @@ export class MergeMiner { async claimPrimaryRewards(rewarder: PublicKey): Promise { return await this.claimRewardsCommon( this.primaryMint, - await this.getPrimaryStakeAccounts(rewarder) + await this.getPrimaryStakeAccounts(rewarder), ); } @@ -323,7 +323,7 @@ export class MergeMiner { async claimReplicaRewards(rewarder: PublicKey): Promise { return await this.claimRewardsCommon( this.replicaMint, - await this.getReplicaStakeAccounts(rewarder) + await this.getReplicaStakeAccounts(rewarder), ); } @@ -335,17 +335,17 @@ export class MergeMiner { async claimRewardsCommon( quarryMint: PublicKey, stake: QuarryStakeAccounts, - mmOwner: PublicKey = this.provider.wallet.publicKey + mmOwner: PublicKey = this.provider.wallet.publicKey, ): Promise { const rewarderKey = stake.rewarder; const rewarder = await this.mergeMine.sdk.programs.Mine.account.rewarder.fetch( - rewarderKey + rewarderKey, ); const [minter] = await findMinterAddress( rewarder.mintWrapper, rewarderKey, - this.mergeMine.sdk.programs.MintWrapper.programId + this.mergeMine.sdk.programs.MintWrapper.programId, ); const mm = this.mm.key; @@ -392,7 +392,7 @@ export class MergeMiner { } async getReplicaStakeAccounts( - rewarder: PublicKey + rewarder: PublicKey, ): Promise { const [quarry] = await findQuarryAddress(rewarder, this.replicaMint); const [miner] = await findMinerAddress(quarry, this.mm.key); @@ -410,7 +410,7 @@ export class MergeMiner { } async getPrimaryStakeAccounts( - rewarder: PublicKey + rewarder: PublicKey, ): Promise { const [quarry] = await findQuarryAddress(rewarder, this.primaryMint); const [miner] = await findMinerAddress(quarry, this.mm.key); diff --git a/src/wrappers/mergeMine/mergePool.ts b/src/wrappers/mergeMine/mergePool.ts index 4e48bd32..a1c40827 100644 --- a/src/wrappers/mergeMine/mergePool.ts +++ b/src/wrappers/mergeMine/mergePool.ts @@ -25,7 +25,10 @@ import type { MergeMine } from "./quarryMergeMine"; export class MergePool { private _data: MergePoolData | null = null; - constructor(readonly mergeMine: MergeMine, readonly key: PublicKey) {} + constructor( + readonly mergeMine: MergeMine, + readonly key: PublicKey, + ) {} async reloadData(): Promise { this._data = await this.mergeMine.program.account.mergePool.fetch(this.key); @@ -95,7 +98,7 @@ export class MergePool { payer: this.provider.wallet.publicKey, systemProgram: SystemProgram.programId, }, - }) + }), ); if (mmATAIx) { allInstructions.push(mmATAIx); @@ -117,12 +120,12 @@ export class MergePool { mmPrimaryTokenAccount, mmOwner, [], - amount.toU64() - ) + amount.toU64(), + ), ); return new TransactionEnvelope(this.provider, allInstructions).combine( - await this.stakePrimaryMiner(rewarder, mmKey) + await this.stakePrimaryMiner(rewarder, mmKey), ); } @@ -133,7 +136,7 @@ export class MergePool { */ async stakePrimaryMiner( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const { provider } = this.mergeMine; const data = await this.data(); @@ -160,7 +163,7 @@ export class MergePool { */ async stakeReplicaMiner( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); @@ -209,7 +212,7 @@ export class MergePool { systemProgram: SystemProgram.programId, tokenProgram: TOKEN_PROGRAM_ID, }, - }) + }), ); if (minerReplicaMintTokenAccount.instruction) { txEnv.instructions.unshift(minerReplicaMintTokenAccount.instruction); @@ -238,15 +241,15 @@ export class MergePool { const withdrawPrimary = await this.unstakePrimaryMiner( rewarder, mergeMiner, - amount + amount, ); const withdrawPrimaryFromMM = await this.withdrawTokens( amount.token.mintAccount, - mergeMiner + mergeMiner, ); return TransactionEnvelope.combineAll( withdrawPrimary, - withdrawPrimaryFromMM + withdrawPrimaryFromMM, ); } @@ -257,7 +260,7 @@ export class MergePool { */ async unstakeAllReplica( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); @@ -286,7 +289,7 @@ export class MergePool { async unstakePrimaryMiner( rewarder: PublicKey, mergeMiner: PublicKey, - amount: TokenAmount + amount: TokenAmount, ): Promise { const poolData = await this.data(); @@ -313,7 +316,7 @@ export class MergePool { */ async withdrawTokens( withdrawMint: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const owner = this.provider.wallet.publicKey; const mmPrimaryAccount = await getATAAddress({ @@ -345,12 +348,12 @@ export class MergePool { */ async claimPrimaryRewards( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); return await this.claimRewardsCommon( poolData.primaryMint, - await this.getPrimaryStakeAccounts(rewarder, mergeMiner) + await this.getPrimaryStakeAccounts(rewarder, mergeMiner), ); } @@ -360,13 +363,13 @@ export class MergePool { */ async claimReplicaRewards( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); return await this.claimRewardsCommon( poolData.replicaMint, - await this.getReplicaStakeAccounts(rewarder, mergeMiner) + await this.getReplicaStakeAccounts(rewarder, mergeMiner), ); } @@ -378,16 +381,16 @@ export class MergePool { async claimRewardsCommon( quarryMint: PublicKey, stake: QuarryStakeAccounts, - mmOwner: PublicKey = this.provider.wallet.publicKey + mmOwner: PublicKey = this.provider.wallet.publicKey, ): Promise { const rewarder = await this.mergeMine.sdk.programs.Mine.account.rewarder.fetch( - stake.rewarder + stake.rewarder, ); const [minter] = await findMinterAddress( rewarder.mintWrapper, stake.rewarder, - this.mergeMine.sdk.programs.MintWrapper.programId + this.mergeMine.sdk.programs.MintWrapper.programId, ); const withdrawMint = rewarder.rewardsTokenMint; @@ -434,7 +437,7 @@ export class MergePool { async getReplicaStakeAccounts( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); @@ -456,7 +459,7 @@ export class MergePool { async getPrimaryStakeAccounts( rewarder: PublicKey, - mergeMiner: PublicKey + mergeMiner: PublicKey, ): Promise { const poolData = await this.data(); diff --git a/src/wrappers/mergeMine/pda.ts b/src/wrappers/mergeMine/pda.ts index 45ee9012..52b4cc36 100644 --- a/src/wrappers/mergeMine/pda.ts +++ b/src/wrappers/mergeMine/pda.ts @@ -16,7 +16,7 @@ export const findPoolAddress = async ({ }): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [utils.bytes.utf8.encode("MergePool"), primaryMint.toBuffer()], - programId + programId, ); }; @@ -34,7 +34,7 @@ export const findReplicaMintAddress = async ({ const [pool] = await findPoolAddress({ programId, primaryMint }); return await PublicKey.findProgramAddress( [utils.bytes.utf8.encode("ReplicaMint"), pool.toBuffer()], - programId + programId, ); }; @@ -53,6 +53,6 @@ export const findMergeMinerAddress = async ({ }): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [utils.bytes.utf8.encode("MergeMiner"), pool.toBuffer(), owner.toBuffer()], - programId + programId, ); }; diff --git a/src/wrappers/mergeMine/quarryMergeMine.ts b/src/wrappers/mergeMine/quarryMergeMine.ts index 045f3e5d..b120c81e 100644 --- a/src/wrappers/mergeMine/quarryMergeMine.ts +++ b/src/wrappers/mergeMine/quarryMergeMine.ts @@ -100,7 +100,7 @@ export class MergeMine { } async fetchMergePoolData( - key: PublicKey + key: PublicKey, ): Promise<{ key: PublicKey; data: MergePoolData }> { return { key, @@ -109,7 +109,7 @@ export class MergeMine { } async fetchMergeMinerData( - key: PublicKey + key: PublicKey, ): Promise<{ key: PublicKey; data: MergeMinerData }> { return { key, @@ -203,7 +203,7 @@ export class MergeMine { payer, systemProgram: SystemProgram.programId, }, - }) + }), ); } @@ -244,9 +244,8 @@ export class MergeMine { const [minerKey] = await findMinerAddress(quarryKey, mm); const ixs: TransactionInstruction[] = []; - const minerAccountInfo = await this.sdk.provider.connection.getAccountInfo( - minerKey - ); + const minerAccountInfo = + await this.sdk.provider.connection.getAccountInfo(minerKey); if (minerAccountInfo) { return { miner: minerKey, ixs }; } @@ -274,7 +273,7 @@ export class MergeMine { tokenMint: mint, minerVault: minerATA.address, }, - }) + }), ); return { diff --git a/src/wrappers/mine/mine.ts b/src/wrappers/mine/mine.ts index 57fe0b61..e1e0b8f7 100644 --- a/src/wrappers/mine/mine.ts +++ b/src/wrappers/mine/mine.ts @@ -47,18 +47,18 @@ export class MineWrapper { }> { const [rewarderKey, bump] = await findRewarderAddress( baseKP.publicKey, - this.program.programId + this.program.programId, ); const mintWrapperDataRaw = await this.provider.getAccountInfo(mintWrapper); if (!mintWrapperDataRaw) { throw new Error( - `mint wrapper does not exist at ${mintWrapper.toString()}` + `mint wrapper does not exist at ${mintWrapper.toString()}`, ); } const mintWrapperData = QUARRY_CODERS.MintWrapper.accounts.mintWrapper.parse( - mintWrapperDataRaw.accountInfo.data + mintWrapperDataRaw.accountInfo.data, ); const { address: claimFeeTokenAccount, instruction: createATAInstruction } = @@ -87,7 +87,7 @@ export class MineWrapper { }, }), ], - [baseKP] + [baseKP], ), }; } @@ -111,19 +111,19 @@ export class MineWrapper { }> { const [rewarderKey] = await findRewarderAddress( baseKP.publicKey, - this.program.programId + this.program.programId, ); const mintWrapperDataRaw = await this.provider.getAccountInfo(mintWrapper); if (!mintWrapperDataRaw) { throw new Error( - `mint wrapper does not exist at ${mintWrapper.toString()}` + `mint wrapper does not exist at ${mintWrapper.toString()}`, ); } const mintWrapperData = QUARRY_CODERS.MintWrapper.accounts.mintWrapper.parse( - mintWrapperDataRaw.accountInfo.data + mintWrapperDataRaw.accountInfo.data, ); const { address: claimFeeTokenAccount, instruction: createATAInstruction } = @@ -151,7 +151,7 @@ export class MineWrapper { }, }), ], - [baseKP] + [baseKP], ), }; } @@ -201,7 +201,7 @@ export class MineWrapper { destinationTokenAccount, tokenProgram: TOKEN_PROGRAM_ID, }, - }) + }), ); return this.sdk.newTx(instructions); diff --git a/src/wrappers/mine/miner.ts b/src/wrappers/mine/miner.ts index 24ce6e62..dfb18402 100644 --- a/src/wrappers/mine/miner.ts +++ b/src/wrappers/mine/miner.ts @@ -33,7 +33,7 @@ export class MinerWrapper { readonly authority: PublicKey, readonly minerKey: PublicKey, readonly tokenVaultKey: PublicKey, - readonly stakedTokenATA: PublicKey + readonly stakedTokenATA: PublicKey, ) {} /** @@ -116,7 +116,7 @@ export class MinerWrapper { private _performStakeAction( amount: TokenAmount, - action: "stakeTokens" | "withdrawTokens" + action: "stakeTokens" | "withdrawTokens", ): TransactionEnvelope { const instruction = this.program.instruction[action](amount.toU64(), { accounts: this.userStakeAccounts, @@ -189,7 +189,7 @@ export class MinerWrapper { const [minter] = await findMinterAddress( this.quarry.rewarderData.mintWrapper, this.quarry.quarryData.rewarder, - this.sdk.mintWrapper.program.programId + this.sdk.mintWrapper.program.programId, ); const ix = this.quarry.program.instruction.claimRewards({ @@ -227,7 +227,7 @@ export class MinerWrapper { const [minter] = await findMinterAddress( this.quarry.rewarderData.mintWrapper, this.quarry.quarryData.rewarder, - this.sdk.mintWrapper.program.programId + this.sdk.mintWrapper.program.programId, ); const ix = this.quarry.program.instruction.claimRewardsV2({ diff --git a/src/wrappers/mine/payroll.ts b/src/wrappers/mine/payroll.ts index 3124190d..97e3ce83 100644 --- a/src/wrappers/mine/payroll.ts +++ b/src/wrappers/mine/payroll.ts @@ -14,7 +14,7 @@ export class Payroll { readonly lastCheckpointTs: BN, readonly annualRewardsRate: BN, readonly rewardsPerTokenStored: BN, - readonly totalTokensDeposited: BN + readonly totalTokensDeposited: BN, ) {} /** @@ -30,7 +30,7 @@ export class Payroll { const lastTimeRewardsApplicable = BN.min(currentTs, this.famineTs); const timeWorked = BN.max( ZERO, - lastTimeRewardsApplicable.sub(this.lastCheckpointTs) + lastTimeRewardsApplicable.sub(this.lastCheckpointTs), ); const reward = timeWorked .mul(MAX_U64_BN) @@ -52,7 +52,7 @@ export class Payroll { currentTs: BN, tokensDeposited: BN, rewardsPerTokenPaid: BN, - rewardsEarned: BN + rewardsEarned: BN, ): BN { const netNewRewards = this.calculateRewardPerToken(currentTs).sub(rewardsPerTokenPaid); diff --git a/src/wrappers/mine/pda.ts b/src/wrappers/mine/pda.ts index 33b65fa2..1285433f 100644 --- a/src/wrappers/mine/pda.ts +++ b/src/wrappers/mine/pda.ts @@ -5,18 +5,18 @@ import { QUARRY_ADDRESSES } from "../../constants"; export const findRewarderAddress = async ( base: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.Mine + programID: PublicKey = QUARRY_ADDRESSES.Mine, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [Buffer.from(utils.bytes.utf8.encode("Rewarder")), base.toBytes()], - programID + programID, ); }; export const findQuarryAddress = async ( rewarder: PublicKey, tokenMint: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.Mine + programID: PublicKey = QUARRY_ADDRESSES.Mine, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [ @@ -24,14 +24,14 @@ export const findQuarryAddress = async ( rewarder.toBytes(), tokenMint.toBytes(), ], - programID + programID, ); }; export const findMinerAddress = async ( quarry: PublicKey, authority: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.Mine + programID: PublicKey = QUARRY_ADDRESSES.Mine, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [ @@ -39,6 +39,6 @@ export const findMinerAddress = async ( quarry.toBytes(), authority.toBytes(), ], - programID + programID, ); }; diff --git a/src/wrappers/mine/quarry.ts b/src/wrappers/mine/quarry.ts index 29425c31..6627f2ce 100644 --- a/src/wrappers/mine/quarry.ts +++ b/src/wrappers/mine/quarry.ts @@ -39,23 +39,23 @@ export class QuarryWrapper { /** * The key of the quarry. */ - readonly key: PublicKey + readonly key: PublicKey, ) {} static fromData( provider: Provider, rewarder: ProgramAccount, - quarry: ProgramAccount + quarry: ProgramAccount, ): QuarryWrapper { return new QuarryWrapper( QuarrySDK.load({ provider }), Token.fromMint( quarry.account.tokenMintKey, - quarry.account.tokenMintDecimals + quarry.account.tokenMintDecimals, ), rewarder.account, quarry.account, - quarry.publicKey + quarry.publicKey, ); } @@ -95,7 +95,7 @@ export class QuarryWrapper { const program = sdk.programs.Mine; const quarryData = await program.account.quarry.fetch(key); const rewarderData = await program.account.rewarder.fetch( - quarryData.rewarder + quarryData.rewarder, ); return new QuarryWrapper(sdk, token, rewarderData, quarryData, key); } @@ -115,7 +115,7 @@ export class QuarryWrapper { return new u64(0); } const numerator = rewarder.annualRewardsRate.mul( - this.quarryData.rewardsShare + this.quarryData.rewardsShare, ); return numerator.div(totalRewardsShares); } @@ -129,7 +129,7 @@ export class QuarryWrapper { const [key] = await findMinerAddress( this.key, authority, - this.program.programId + this.program.programId, ); return key; } @@ -142,7 +142,7 @@ export class QuarryWrapper { async getMiner(authority: PublicKey): Promise { try { return await this.program.account.miner.fetch( - await this.getMinerAddress(authority) + await this.getMinerAddress(authority), ); } catch (e) { return null; @@ -155,7 +155,7 @@ export class QuarryWrapper { * @returns */ async getMinerActions( - authority: PublicKey = this.provider.wallet.publicKey + authority: PublicKey = this.provider.wallet.publicKey, ): Promise { const miner = await this.getMinerAddress(authority); const stakedTokenATA = await getATAAddress({ @@ -170,7 +170,7 @@ export class QuarryWrapper { authority, miner, tokenVaultKey, - stakedTokenATA + stakedTokenATA, ); } @@ -186,14 +186,14 @@ export class QuarryWrapper { authority: PublicKey, minerKey: PublicKey, tokenVaultKey: PublicKey, - stakedTokenATA: PublicKey + stakedTokenATA: PublicKey, ): MinerWrapper { return new MinerWrapper( this, authority, minerKey, tokenVaultKey, - stakedTokenATA + stakedTokenATA, ); } @@ -242,7 +242,7 @@ export class QuarryWrapper { const [miner] = await findMinerAddress( this.key, authority, - this.program.programId + this.program.programId, ); const { address: minerVault, instruction: createATATX } = await getOrCreateATA({ @@ -258,7 +258,7 @@ export class QuarryWrapper { authority, miner, minerVault, - stakedTokenATA + stakedTokenATA, ); const result = wrapper.initialize(); if (createATATX) { @@ -277,7 +277,7 @@ export class QuarryWrapper { data.lastUpdateTs, data.annualRewardsRate, data.rewardsPerTokenStored, - data.totalTokensDeposited + data.totalTokensDeposited, ); } } diff --git a/src/wrappers/mine/rewarder.ts b/src/wrappers/mine/rewarder.ts index d7bd450b..f6985af1 100644 --- a/src/wrappers/mine/rewarder.ts +++ b/src/wrappers/mine/rewarder.ts @@ -18,7 +18,7 @@ export class RewarderWrapper { constructor( readonly mineWrapper: MineWrapper, readonly rewarderKey: PublicKey, - readonly rewarderData: RewarderData + readonly rewarderData: RewarderData, ) { this.sdk = mineWrapper.sdk; this.program = mineWrapper.program; @@ -30,12 +30,12 @@ export class RewarderWrapper { static fromData( provider: Provider, - rewarder: ProgramAccount + rewarder: ProgramAccount, ): RewarderWrapper { return new RewarderWrapper( QuarrySDK.load({ provider }).mine, rewarder.publicKey, - rewarder.account + rewarder.account, ); } @@ -71,7 +71,7 @@ export class RewarderWrapper { const [quarryKey] = await findQuarryAddress( this.rewarderKey, mint, - this.program.programId + this.program.programId, ); return quarryKey; } @@ -92,7 +92,7 @@ export class RewarderWrapper { const [quarryKey, bump] = await findQuarryAddress( this.rewarderKey, token.mintAccount, - this.program.programId + this.program.programId, ); const ix = this.program.instruction.createQuarry(bump, { accounts: { @@ -130,7 +130,7 @@ export class RewarderWrapper { const [quarryKey] = await findQuarryAddress( this.rewarderKey, token.mintAccount, - this.program.programId + this.program.programId, ); const ix = this.program.instruction.createQuarryV2({ accounts: { @@ -182,7 +182,7 @@ export class RewarderWrapper { */ async setAndSyncAnnualRewards( newAnnualRate: u64, - mints: PublicKey[] + mints: PublicKey[], ): Promise { const tx = await this.syncQuarryRewards(mints); return this.setAnnualRewards({ newAnnualRate }).combine(tx); @@ -204,9 +204,9 @@ export class RewarderWrapper { rewarder: this.rewarderKey, quarry, }, - }) + }), ); - }) + }), ); return this.sdk.newTx(instructions); } @@ -261,7 +261,7 @@ export class RewarderWrapper { * Pause the rewarder */ pause( - authority: PublicKey = this.sdk.provider.wallet.publicKey + authority: PublicKey = this.sdk.provider.wallet.publicKey, ): TransactionEnvelope { return new TransactionEnvelope(this.sdk.provider, [ this.program.instruction.pause({ @@ -274,7 +274,7 @@ export class RewarderWrapper { * Unpause the rewarder */ unpause( - authority: PublicKey = this.sdk.provider.wallet.publicKey + authority: PublicKey = this.sdk.provider.wallet.publicKey, ): TransactionEnvelope { return new TransactionEnvelope(this.sdk.provider, [ this.program.instruction.unpause({ diff --git a/src/wrappers/mintWrapper/mintWrapper.ts b/src/wrappers/mintWrapper/mintWrapper.ts index 43493ea9..1c58c7d4 100644 --- a/src/wrappers/mintWrapper/mintWrapper.ts +++ b/src/wrappers/mintWrapper/mintWrapper.ts @@ -82,7 +82,7 @@ export class MintWrapper { }): Promise { const [mintWrapper, bump] = await findMintWrapperAddress( baseKP.publicKey, - this.program.programId + this.program.programId, ); return { mintWrapper, @@ -100,7 +100,7 @@ export class MintWrapper { }, }), ], - [baseKP] + [baseKP], ), }; } @@ -122,7 +122,7 @@ export class MintWrapper { }): Promise { const [mintWrapper] = await findMintWrapperAddress( baseKP.publicKey, - this.program.programId + this.program.programId, ); return { mintWrapper, @@ -140,7 +140,7 @@ export class MintWrapper { }, }), ], - [baseKP] + [baseKP], ), }; } @@ -190,7 +190,7 @@ export class MintWrapper { } return this.program.coder.accounts.decode( "MintWrapper", - accountInfo.data + accountInfo.data, ); } @@ -201,33 +201,32 @@ export class MintWrapper { */ async fetchMinter( wrapper: PublicKey, - authority: PublicKey + authority: PublicKey, ): Promise { const [minterAddress] = await findMinterAddress( wrapper, authority, - this.program.programId - ); - const accountInfo = await this.provider.connection.getAccountInfo( - minterAddress + this.program.programId, ); + const accountInfo = + await this.provider.connection.getAccountInfo(minterAddress); if (!accountInfo) { return null; } return this.program.coder.accounts.decode( "Minter", - accountInfo.data + accountInfo.data, ); } async newMinterV1( wrapper: PublicKey, - authority: PublicKey + authority: PublicKey, ): Promise { const [minter, bump] = await findMinterAddress( wrapper, authority, - this.program.programId + this.program.programId, ); return this.provider.newTX([ this.program.instruction.newMinter(bump, { @@ -247,12 +246,12 @@ export class MintWrapper { async newMinter( wrapper: PublicKey, - authority: PublicKey + authority: PublicKey, ): Promise { const [minter] = await findMinterAddress( wrapper, authority, - this.program.programId + this.program.programId, ); return this.provider.newTX([ this.program.instruction.newMinterV2({ @@ -279,12 +278,12 @@ export class MintWrapper { async minterUpdate( wrapper: PublicKey, authority: PublicKey, - allowance: u64 + allowance: u64, ): Promise { const [minter] = await findMinterAddress( wrapper, authority, - this.program.programId + this.program.programId, ); return this.provider.newTX([ this.program.instruction.minterUpdate(allowance, { @@ -309,13 +308,13 @@ export class MintWrapper { async newMinterWithAllowance( wrapper: PublicKey, authority: PublicKey, - allowance: u64 + allowance: u64, ): Promise { const newMinter = await this.newMinter(wrapper, authority); const updateAllowance = await this.minterUpdate( wrapper, authority, - allowance + allowance, ); return newMinter.combine(updateAllowance); } diff --git a/src/wrappers/mintWrapper/pda.ts b/src/wrappers/mintWrapper/pda.ts index 5da72763..3013f7b1 100644 --- a/src/wrappers/mintWrapper/pda.ts +++ b/src/wrappers/mintWrapper/pda.ts @@ -5,18 +5,18 @@ import { QUARRY_ADDRESSES } from "../../constants"; export const findMintWrapperAddress = async ( base: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.MintWrapper + programID: PublicKey = QUARRY_ADDRESSES.MintWrapper, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [Buffer.from(utils.bytes.utf8.encode("MintWrapper")), base.toBytes()], - programID + programID, ); }; export const findMinterAddress = async ( wrapper: PublicKey, authority: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.MintWrapper + programID: PublicKey = QUARRY_ADDRESSES.MintWrapper, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [ @@ -24,6 +24,6 @@ export const findMinterAddress = async ( wrapper.toBytes(), authority.toBytes(), ], - programID + programID, ); }; diff --git a/src/wrappers/operator/index.ts b/src/wrappers/operator/index.ts index c44729e2..c0749375 100644 --- a/src/wrappers/operator/index.ts +++ b/src/wrappers/operator/index.ts @@ -14,7 +14,7 @@ export class Operator { constructor( readonly sdk: QuarrySDK, readonly key: PublicKey, - readonly data: OperatorData + readonly data: OperatorData, ) {} get program(): QuarryOperatorProgram { @@ -39,7 +39,7 @@ export class Operator { }): Promise { const program = sdk.programs.Operator; const data = (await program.account.operator.fetchNullable( - key + key, )) as OperatorData; if (!data) { return null; @@ -65,7 +65,7 @@ export class Operator { }> { const [operatorKey] = await findOperatorAddress( baseKP.publicKey, - sdk.programs.Operator.programId + sdk.programs.Operator.programId, ); return { key: operatorKey, @@ -85,7 +85,7 @@ export class Operator { }, }), ], - [baseKP] + [baseKP], ), }; } @@ -183,7 +183,7 @@ export class Operator { const [quarry] = await findQuarryAddress( this.data.rewarder, tokenMint, - this.sdk.programs.Mine.programId + this.sdk.programs.Mine.programId, ); return { quarry, diff --git a/src/wrappers/operator/pda.ts b/src/wrappers/operator/pda.ts index 50e13879..7309e7ae 100644 --- a/src/wrappers/operator/pda.ts +++ b/src/wrappers/operator/pda.ts @@ -5,10 +5,10 @@ import { QUARRY_ADDRESSES } from "../../constants"; export const findOperatorAddress = async ( base: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.Operator + programID: PublicKey = QUARRY_ADDRESSES.Operator, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [utils.bytes.utf8.encode("Operator"), base.toBytes()], - programID + programID, ); }; diff --git a/src/wrappers/redeemer/index.ts b/src/wrappers/redeemer/index.ts index 0f4fa3a3..f1a75f13 100644 --- a/src/wrappers/redeemer/index.ts +++ b/src/wrappers/redeemer/index.ts @@ -24,7 +24,7 @@ export class RedeemerWrapper { readonly iouMint: PublicKey, readonly redemptionMint: PublicKey, readonly key: PublicKey, - readonly data: RedeemerData + readonly data: RedeemerData, ) {} get program(): RedeemerProgram { @@ -103,7 +103,7 @@ export class RedeemerWrapper { } async getRedeemTokenAccounts( - args: Omit + args: Omit, ): Promise<{ redeemer: PublicKey; iouMint: PublicKey; diff --git a/src/wrappers/redeemer/pda.ts b/src/wrappers/redeemer/pda.ts index b279c366..437890f8 100644 --- a/src/wrappers/redeemer/pda.ts +++ b/src/wrappers/redeemer/pda.ts @@ -16,6 +16,6 @@ export const findRedeemerKey = async ({ iouMint.toBytes(), redemptionMint.toBytes(), ], - QUARRY_ADDRESSES.Redeemer + QUARRY_ADDRESSES.Redeemer, ); }; diff --git a/src/wrappers/registry/pda.ts b/src/wrappers/registry/pda.ts index 42476ec3..018e2d39 100644 --- a/src/wrappers/registry/pda.ts +++ b/src/wrappers/registry/pda.ts @@ -5,10 +5,10 @@ import { QUARRY_ADDRESSES } from "../../constants"; export const findRegistryAddress = async ( rewarderKey: PublicKey, - programID: PublicKey = QUARRY_ADDRESSES.Registry + programID: PublicKey = QUARRY_ADDRESSES.Registry, ): Promise<[PublicKey, number]> => { return await PublicKey.findProgramAddress( [utils.bytes.utf8.encode("QuarryRegistry"), rewarderKey.toBytes()], - programID + programID, ); }; diff --git a/src/wrappers/registry/registry.ts b/src/wrappers/registry/registry.ts index b24430dd..18296c29 100644 --- a/src/wrappers/registry/registry.ts +++ b/src/wrappers/registry/registry.ts @@ -33,7 +33,7 @@ export class QuarryRegistry { }): Promise<{ tx: TransactionEnvelope; registry: PublicKey }> { const [registry, bump] = await findRegistryAddress( rewarderKey, - this.program.programId + this.program.programId, ); const createRegistryTX = new TransactionEnvelope(this.provider, [ this.program.instruction.newRegistry(numQuarries, bump, { @@ -60,12 +60,12 @@ export class QuarryRegistry { }): Promise { const [registry] = await findRegistryAddress( rewarderKey, - this.program.programId + this.program.programId, ); const [quarry] = await findQuarryAddress( rewarderKey, tokenMint, - this.sdk.programs.Mine.programId + this.sdk.programs.Mine.programId, ); return new TransactionEnvelope(this.provider, [ this.program.instruction.syncQuarry({ diff --git a/tests/famine.spec.ts b/tests/famine.spec.ts index b01879e4..38b95e28 100644 --- a/tests/famine.spec.ts +++ b/tests/famine.spec.ts @@ -59,7 +59,7 @@ describe("Famine", () => { stakeTokenMint = await createMint( provider, stakedMintAuthority.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); }); @@ -82,7 +82,7 @@ describe("Famine", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -106,7 +106,7 @@ describe("Famine", () => { rewarderWrapper.setAnnualRewards({ newAnnualRate: annualRewardsRate, }), - "Set annual rewards rate" + "Set annual rewards rate", ).to.be.fulfilled; // whitelist rewarder @@ -114,9 +114,9 @@ describe("Famine", () => { mintWrapper.newMinterWithAllowance( mintWrapperKey, rewarder, - new u64(100_000_000_000000) + new u64(100_000_000_000000), ), - "Minter add" + "Minter add", ).to.be.fulfilled; }); @@ -139,12 +139,12 @@ describe("Famine", () => { quarryWrapper, stakeToken, stakedMintAuthority, - stakeAmount + stakeAmount, ); await expectTX( quarryWrapper.setRewardsShare(new u64(100)), - "Set rewards share" + "Set rewards share", ).to.be.fulfilled; const { tx: tx2 } = await quarryWrapper.createMiner(); @@ -157,11 +157,11 @@ describe("Famine", () => { .fulfilled; const minerActions = await quarryWrapper.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); await expectTX( minerActions.stake(new TokenAmount(stakeToken, stakeAmount)), - "Stake into the quarry" + "Stake into the quarry", ).to.be.fulfilled; // Sleep for 5 seconds @@ -176,14 +176,14 @@ describe("Famine", () => { }); const rewardsTokenAccountInfo = await getTokenAccount( provider, - rewardsTokenAccount + rewardsTokenAccount, ); expect(rewardsTokenAccountInfo.amount.toString()).to.equal(ZERO.toString()); }); it("Stake before famine and claim after famine", async () => { const minerActions = await quarryWrapper.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); const rewardsDuration = 5; // 5 seconds @@ -192,7 +192,7 @@ describe("Famine", () => { minerActions .stake(new TokenAmount(stakeToken, stakeAmount)) .combine(quarryWrapper.setFamine(famine)), - "Set famine then stake tokens" + "Set famine then stake tokens", ).to.be.fulfilled; // Sleep for 8 seconds @@ -205,11 +205,11 @@ describe("Famine", () => { receipt.printLogs(); const claimEvent = QUARRY_CODERS.Mine.parseProgramLogEvents( - receipt.response.meta?.logMessages ?? [] + receipt.response.meta?.logMessages ?? [], ).find((ev) => ev.name === "ClaimEvent"); invariant( claimEvent && claimEvent.name === "ClaimEvent", - "claim event not found" + "claim event not found", ); const expectedRewards = dailyRewardsRate @@ -232,7 +232,7 @@ describe("Famine", () => { claim2Receipt.printLogs(); const claim2Event = QUARRY_CODERS.Mine.parseProgramLogEvents( - claim2Receipt.response.meta?.logMessages ?? [] + claim2Receipt.response.meta?.logMessages ?? [], )[0]; expect(claim2Event).to.be.undefined; // No claim event }); diff --git a/tests/mine.spec.ts b/tests/mine.spec.ts index 9b4448cb..1a36f676 100644 --- a/tests/mine.spec.ts +++ b/tests/mine.spec.ts @@ -72,7 +72,7 @@ describe("Mine", () => { stakeTokenMint = await createMint( provider, stakedMintAuthority.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); }); @@ -103,7 +103,7 @@ describe("Mine", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -145,7 +145,7 @@ describe("Mine", () => { feeToTokenAccount: ata.address, tokenProgram: TOKEN_PROGRAM_ID, }, - }) + }), ).to.be.fulfilled; }); @@ -209,7 +209,7 @@ describe("Mine", () => { expect(rewarder.annualRewardsRate.toString()).to.eql(ZERO.toString()); expect(rewarder.numQuarries).to.eq(ZERO.toNumber()); expect(rewarder.totalRewardsShares.toString()).to.bignumber.eq( - ZERO.toString() + ZERO.toString(), ); }); @@ -265,7 +265,7 @@ describe("Mine", () => { authority: newAuthority.publicKey, rewarder: rewarderKey, }, - }) + }), ); instructions.push( mine.program.instruction.acceptAuthority({ @@ -273,7 +273,7 @@ describe("Mine", () => { authority: provider.wallet.publicKey, rewarder: rewarderKey, }, - }) + }), ); tx = sdk.newTx(instructions, [newAuthority]); @@ -321,7 +321,7 @@ describe("Mine", () => { feeToTokenAccount: ata.address, tokenProgram: TOKEN_PROGRAM_ID, }, - }) + }), ).to.be.fulfilled; }); @@ -385,7 +385,7 @@ describe("Mine", () => { expect(rewarder.annualRewardsRate.toString()).to.eql(ZERO.toString()); expect(rewarder.numQuarries).to.eq(ZERO.toNumber()); expect(rewarder.totalRewardsShares.toString()).to.bignumber.eq( - ZERO.toString() + ZERO.toString(), ); }); @@ -441,7 +441,7 @@ describe("Mine", () => { authority: newAuthority.publicKey, rewarder: rewarderKey, }, - }) + }), ); instructions.push( mine.program.instruction.acceptAuthority({ @@ -449,7 +449,7 @@ describe("Mine", () => { authority: provider.wallet.publicKey, rewarder: rewarderKey, }, - }) + }), ); tx = sdk.newTx(instructions, [newAuthority]); @@ -479,7 +479,7 @@ describe("Mine", () => { rewarder = await mine.loadRewarderWrapper(rewarderKey); await expectTX( await rewarder.setAndSyncAnnualRewards(ANNUAL_REWARDS_RATE, []), - "set annual rewards" + "set annual rewards", ); }); @@ -490,31 +490,29 @@ describe("Mine", () => { }); await expectTX(tx, "Create new quarry").to.be.fulfilled; - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); assert.strictEqual(rewarderData.numQuarries, 1); - const quarryAccountInfo = await provider.connection.getAccountInfo( - quarry - ); + const quarryAccountInfo = + await provider.connection.getAccountInfo(quarry); expect(quarryAccountInfo?.owner).to.eqAddress(mine.program.programId); assert.ok(quarryAccountInfo); quarryData = mine.program.coder.accounts.decode( "Quarry", - quarryAccountInfo.data + quarryAccountInfo.data, ); assert.strictEqual( quarryData.famineTs.toString(), - "9223372036854775807" + "9223372036854775807", ); assert.strictEqual( quarryData.tokenMintKey.toBase58(), - stakeTokenMint.toBase58() + stakeTokenMint.toBase58(), ); assert.strictEqual( quarryData.annualRewardsRate.toString(), - ZERO.toString() + ZERO.toString(), ); assert.strictEqual(quarryData.rewardsShare.toString(), ZERO.toString()); @@ -534,26 +532,25 @@ describe("Mine", () => { }); }); - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.totalRewardsShares.toString()).to.equal( - quarryRewardsShare.toString() + quarryRewardsShare.toString(), ); let quarry = await rewarder.getQuarry(stakeToken); expect(quarry.key).to.eqAddress(quarryKey); expect(quarry.quarryData.lastUpdateTs.toString()).to.equal( - quarryData.lastUpdateTs.toString() + quarryData.lastUpdateTs.toString(), ); expect(quarry.quarryData.annualRewardsRate.toString()).to.equal( - quarryData.annualRewardsRate.toString() + quarryData.annualRewardsRate.toString(), ); expect(quarry.quarryData.rewardsShare.toString()).to.eq( - quarryRewardsShare.toString() + quarryRewardsShare.toString(), ); expect(quarry.quarryData.annualRewardsRate.toString()).to.not.equal( - quarry.computeAnnualRewardsRate().toString() + quarry.computeAnnualRewardsRate().toString(), ); const currentTime = Math.floor(new Date().getTime() / 1000); @@ -566,11 +563,11 @@ describe("Mine", () => { quarry.quarryData.lastUpdateTs .sub(new BN(currentTime)) .abs() - .lte(new BN(1)) + .lte(new BN(1)), ).to.be.true; const expectedRewardsRate = quarry.computeAnnualRewardsRate(); expect(quarry.quarryData.annualRewardsRate.toString()).to.equal( - expectedRewardsRate.toString() + expectedRewardsRate.toString(), ); }); @@ -587,13 +584,12 @@ describe("Mine", () => { }, }); }); - const quarryAccountInfo = await provider.connection.getAccountInfo( - quarryKey - ); + const quarryAccountInfo = + await provider.connection.getAccountInfo(quarryKey); assert.ok(quarryAccountInfo); const quarryData = mine.program.coder.accounts.decode( "Quarry", - quarryAccountInfo?.data + quarryAccountInfo?.data, ); assert.strictEqual(quarryData.famineTs.toString(), now.toString()); @@ -615,11 +611,11 @@ describe("Mine", () => { const nextMint = await createMint( provider, provider.wallet.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const [quarryKey, bump] = await findQuarryAddress( rewarderKey, - nextMint + nextMint, ); await assert.rejects( async () => { @@ -642,7 +638,7 @@ describe("Mine", () => { console.error(err); expect(err.message).to.include("Error Code: Unauthorized"); // mut constraint return true; - } + }, ); }); @@ -651,7 +647,7 @@ describe("Mine", () => { const nextMint = await createMint( provider, provider.wallet.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const [quarryKey] = await findQuarryAddress(rewarderKey, nextMint); await assert.rejects( @@ -674,7 +670,7 @@ describe("Mine", () => { console.error(err); expect(err.message).to.include("Error Code: Unauthorized"); return true; - } + }, ); }); @@ -682,7 +678,7 @@ describe("Mine", () => { await assert.rejects(async () => { const [quarryKey, bump] = await findQuarryAddress( rewarderKey, - Keypair.generate().publicKey + Keypair.generate().publicKey, ); await mine.program.rpc.createQuarry(bump, { accounts: { @@ -704,7 +700,7 @@ describe("Mine", () => { await assert.rejects(async () => { const [quarryKey] = await findQuarryAddress( rewarderKey, - Keypair.generate().publicKey + Keypair.generate().publicKey, ); await mine.program.rpc.createQuarryV2({ accounts: { @@ -746,12 +742,11 @@ describe("Mine", () => { totalRewardsShare = totalRewardsShare.add(rewardsShare); } - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.numQuarries).to.eq(numQuarries); expect(rewarderData.totalRewardsShares).to.bignumber.eq( - totalRewardsShare + totalRewardsShare, ); const mints = tokens.map((tok) => tok.mintAccount); @@ -761,20 +756,19 @@ describe("Mine", () => { it("Set annual rewards and make sure quarries update", async () => { const multiplier = new BN(10); - let rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + let rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); const nextAnnualRewardsRate = ANNUAL_REWARDS_RATE.mul(multiplier); const prevRates = await Promise.all( tokens.map(async (t) => { const quarry = await rewarder.getQuarry(t); return { token: t, rate: quarry.quarryData.annualRewardsRate }; - }) + }), ); const tx = await rewarder.setAndSyncAnnualRewards( nextAnnualRewardsRate, - tokens.map((t) => t.mintAccount) + tokens.map((t) => t.mintAccount), ); console.log(await tx.simulate()); await expectTX(tx, "set annual rewards and update quarry rewards").to.be @@ -782,7 +776,7 @@ describe("Mine", () => { rewarderData = await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.annualRewardsRate).to.bignumber.eq( - nextAnnualRewardsRate + nextAnnualRewardsRate, ); let sumRewardsPerAnnum = new BN(0); @@ -793,7 +787,7 @@ describe("Mine", () => { const prevRate = prevRates.find((r) => r.token.equals(token))?.rate; invariant( prevRate, - `prev rate not found for token ${token.toString()}` + `prev rate not found for token ${token.toString()}`, ); // Epsilon is 10 @@ -801,22 +795,22 @@ describe("Mine", () => { const expectedRate = prevRate.mul(multiplier); expect( nextRate, - `mul rate: ${multiplier.toString()}; expected: ${expectedRate.toString()}; got: ${nextRate.toString()}` + `mul rate: ${multiplier.toString()}; expected: ${expectedRate.toString()}; got: ${nextRate.toString()}`, ).to.bignumber.closeTo(expectedRate, "10"); } // Check on day multiple expect( sumRewardsPerAnnum, - "rewards rate within one day multiple" + "rewards rate within one day multiple", ).bignumber.closeTo( nextAnnualRewardsRate, - new BN(2) // precision lost + new BN(2), // precision lost ); // Restore daily rewards rate const txRestore = await rewarder.setAndSyncAnnualRewards( ANNUAL_REWARDS_RATE, - tokens.map((t) => t.mintAccount) + tokens.map((t) => t.mintAccount), ); await expectTX(txRestore, "revert daily rewards to previous amount").to .be.fulfilled; @@ -828,10 +822,10 @@ describe("Mine", () => { const prevRate = prevRates.find((r) => r.token.equals(token))?.rate; invariant( prevRate, - `prev rate not found for token ${token.toString()}` + `prev rate not found for token ${token.toString()}`, ); expect(lastRate, `revert rate ${token.toString()}`).bignumber.to.eq( - prevRate + prevRate, ); } }); @@ -855,7 +849,7 @@ describe("Mine", () => { rewarder = await mine.loadRewarderWrapper(rewarderKey); await expectTX( await rewarder.setAndSyncAnnualRewards(ANNUAL_REWARDS_RATE, []), - "set annual rewards" + "set annual rewards", ); }); @@ -866,31 +860,29 @@ describe("Mine", () => { }); await expectTX(tx, "Create new quarry").to.be.fulfilled; - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); assert.strictEqual(rewarderData.numQuarries, 1); - const quarryAccountInfo = await provider.connection.getAccountInfo( - quarry - ); + const quarryAccountInfo = + await provider.connection.getAccountInfo(quarry); expect(quarryAccountInfo?.owner).to.eqAddress(mine.program.programId); assert.ok(quarryAccountInfo); quarryData = mine.program.coder.accounts.decode( "Quarry", - quarryAccountInfo.data + quarryAccountInfo.data, ); assert.strictEqual( quarryData.famineTs.toString(), - "9223372036854775807" + "9223372036854775807", ); assert.strictEqual( quarryData.tokenMintKey.toBase58(), - stakeTokenMint.toBase58() + stakeTokenMint.toBase58(), ); assert.strictEqual( quarryData.annualRewardsRate.toString(), - ZERO.toString() + ZERO.toString(), ); assert.strictEqual(quarryData.rewardsShare.toString(), ZERO.toString()); @@ -910,26 +902,25 @@ describe("Mine", () => { }); }); - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.totalRewardsShares.toString()).to.equal( - quarryRewardsShare.toString() + quarryRewardsShare.toString(), ); let quarry = await rewarder.getQuarry(stakeToken); expect(quarry.key).to.eqAddress(quarryKey); expect(quarry.quarryData.lastUpdateTs.toString()).to.equal( - quarryData.lastUpdateTs.toString() + quarryData.lastUpdateTs.toString(), ); expect(quarry.quarryData.annualRewardsRate.toString()).to.equal( - quarryData.annualRewardsRate.toString() + quarryData.annualRewardsRate.toString(), ); expect(quarry.quarryData.rewardsShare.toString()).to.eq( - quarryRewardsShare.toString() + quarryRewardsShare.toString(), ); expect(quarry.quarryData.annualRewardsRate.toString()).to.not.equal( - quarry.computeAnnualRewardsRate().toString() + quarry.computeAnnualRewardsRate().toString(), ); const currentTime = Math.floor(new Date().getTime() / 1000); @@ -942,11 +933,11 @@ describe("Mine", () => { quarry.quarryData.lastUpdateTs .sub(new BN(currentTime)) .abs() - .lte(new BN(1)) + .lte(new BN(1)), ).to.be.true; const expectedRewardsRate = quarry.computeAnnualRewardsRate(); expect(quarry.quarryData.annualRewardsRate.toString()).to.equal( - expectedRewardsRate.toString() + expectedRewardsRate.toString(), ); }); @@ -963,13 +954,12 @@ describe("Mine", () => { }, }); }); - const quarryAccountInfo = await provider.connection.getAccountInfo( - quarryKey - ); + const quarryAccountInfo = + await provider.connection.getAccountInfo(quarryKey); assert.ok(quarryAccountInfo); const quarryData = mine.program.coder.accounts.decode( "Quarry", - quarryAccountInfo?.data + quarryAccountInfo?.data, ); assert.strictEqual(quarryData.famineTs.toString(), now.toString()); @@ -991,11 +981,11 @@ describe("Mine", () => { const nextMint = await createMint( provider, provider.wallet.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const [quarryKey, bump] = await findQuarryAddress( rewarderKey, - nextMint + nextMint, ); await assert.rejects( async () => { @@ -1018,7 +1008,7 @@ describe("Mine", () => { console.error(err); expect(err.message).to.include("Error Code: Unauthorized"); // mut constraint return true; - } + }, ); }); @@ -1027,7 +1017,7 @@ describe("Mine", () => { const nextMint = await createMint( provider, provider.wallet.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const [quarryKey] = await findQuarryAddress(rewarderKey, nextMint); await assert.rejects( @@ -1050,7 +1040,7 @@ describe("Mine", () => { console.error(err); expect(err.message).to.include("Error Code: Unauthorized"); return true; - } + }, ); }); @@ -1058,7 +1048,7 @@ describe("Mine", () => { await assert.rejects(async () => { const [quarryKey, bump] = await findQuarryAddress( rewarderKey, - Keypair.generate().publicKey + Keypair.generate().publicKey, ); await mine.program.rpc.createQuarry(bump, { accounts: { @@ -1080,7 +1070,7 @@ describe("Mine", () => { await assert.rejects(async () => { const [quarryKey] = await findQuarryAddress( rewarderKey, - Keypair.generate().publicKey + Keypair.generate().publicKey, ); await mine.program.rpc.createQuarryV2({ accounts: { @@ -1122,12 +1112,11 @@ describe("Mine", () => { totalRewardsShare = totalRewardsShare.add(rewardsShare); } - const rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + const rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.numQuarries).to.eq(numQuarries); expect(rewarderData.totalRewardsShares).to.bignumber.eq( - totalRewardsShare + totalRewardsShare, ); const mints = tokens.map((tok) => tok.mintAccount); @@ -1137,20 +1126,19 @@ describe("Mine", () => { it("Set annual rewards and make sure quarries update", async () => { const multiplier = new BN(10); - let rewarderData = await mine.program.account.rewarder.fetch( - rewarderKey - ); + let rewarderData = + await mine.program.account.rewarder.fetch(rewarderKey); const nextAnnualRewardsRate = ANNUAL_REWARDS_RATE.mul(multiplier); const prevRates = await Promise.all( tokens.map(async (t) => { const quarry = await rewarder.getQuarry(t); return { token: t, rate: quarry.quarryData.annualRewardsRate }; - }) + }), ); const tx = await rewarder.setAndSyncAnnualRewards( nextAnnualRewardsRate, - tokens.map((t) => t.mintAccount) + tokens.map((t) => t.mintAccount), ); console.log(await tx.simulate()); await expectTX(tx, "set annual rewards and update quarry rewards").to.be @@ -1158,7 +1146,7 @@ describe("Mine", () => { rewarderData = await mine.program.account.rewarder.fetch(rewarderKey); expect(rewarderData.annualRewardsRate).to.bignumber.eq( - nextAnnualRewardsRate + nextAnnualRewardsRate, ); let sumRewardsPerAnnum = new BN(0); @@ -1169,7 +1157,7 @@ describe("Mine", () => { const prevRate = prevRates.find((r) => r.token.equals(token))?.rate; invariant( prevRate, - `prev rate not found for token ${token.toString()}` + `prev rate not found for token ${token.toString()}`, ); // Epsilon is 10 @@ -1177,22 +1165,22 @@ describe("Mine", () => { const expectedRate = prevRate.mul(multiplier); expect( nextRate, - `mul rate: ${multiplier.toString()}; expected: ${expectedRate.toString()}; got: ${nextRate.toString()}` + `mul rate: ${multiplier.toString()}; expected: ${expectedRate.toString()}; got: ${nextRate.toString()}`, ).to.bignumber.closeTo(expectedRate, "10"); } // Check on day multiple expect( sumRewardsPerAnnum, - "rewards rate within one day multiple" + "rewards rate within one day multiple", ).bignumber.closeTo( nextAnnualRewardsRate, - new BN(2) // precision lost + new BN(2), // precision lost ); // Restore daily rewards rate const txRestore = await rewarder.setAndSyncAnnualRewards( ANNUAL_REWARDS_RATE, - tokens.map((t) => t.mintAccount) + tokens.map((t) => t.mintAccount), ); await expectTX(txRestore, "revert daily rewards to previous amount").to .be.fulfilled; @@ -1204,10 +1192,10 @@ describe("Mine", () => { const prevRate = prevRates.find((r) => r.token.equals(token))?.rate; invariant( prevRate, - `prev rate not found for token ${token.toString()}` + `prev rate not found for token ${token.toString()}`, ); expect(lastRate, `revert rate ${token.toString()}`).bignumber.to.eq( - prevRate + prevRate, ); } }); @@ -1228,7 +1216,7 @@ describe("Mine", () => { rewarderKey = theRewarderKey; rewarder = await mine.loadRewarderWrapper(rewarderKey); await expectTX( - await rewarder.setAndSyncAnnualRewards(ANNUAL_REWARDS_RATE, []) + await rewarder.setAndSyncAnnualRewards(ANNUAL_REWARDS_RATE, []), ).to.be.fulfilled; const { tx: quarryTx } = await rewarder.createQuarry({ @@ -1253,14 +1241,14 @@ describe("Mine", () => { assert.ok(minerAccountInfo?.data); const minerData = mine.program.coder.accounts.decode( "Miner", - minerAccountInfo.data + minerAccountInfo.data, ); expect(minerData.authority).to.eqAddress(provider.wallet.publicKey); assert.strictEqual(minerData.quarry.toBase58(), quarry.key.toBase58()); const minerBalance = await getTokenAccount( provider, - minerData.tokenVaultKey + minerData.tokenVaultKey, ); expect(minerBalance.amount).to.bignumber.eq(ZERO); }); @@ -1273,16 +1261,16 @@ describe("Mine", () => { quarry, stakeToken, stakedMintAuthority, - amount + amount, ); // stake into the quarry const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); await expectTX( minerActions.stake(new TokenAmount(stakeToken, amount)), - "Stake into the quarry" + "Stake into the quarry", ).to.be.fulfilled; let miner = await quarry.getMiner(provider.wallet.publicKey); @@ -1295,21 +1283,21 @@ describe("Mine", () => { expect(minerVaultInfo.amount).to.bignumber.eq(new BN(amount)); let userStakeTokenAccountInfo = await getTokenAccount( provider, - userStakeTokenAccount + userStakeTokenAccount, ); expect(userStakeTokenAccountInfo.amount).to.bignumber.eq(ZERO); // withdraw from the quarry await expectTX( minerActions.withdraw(new TokenAmount(stakeToken, amount)), - "Withdraw from the quarry" + "Withdraw from the quarry", ).to.be.fulfilled; miner = await quarry.getMiner(provider.wallet.publicKey); invariant(miner, "miner must exist"); const endMinerBalance = await getTokenAccount( provider, - miner.tokenVaultKey + miner.tokenVaultKey, ); expect(endMinerBalance.amount).to.bignumber.eq(ZERO); @@ -1317,7 +1305,7 @@ describe("Mine", () => { expect(minerVaultInfo.amount.toNumber()).to.eq(ZERO.toNumber()); userStakeTokenAccountInfo = await getTokenAccount( provider, - userStakeTokenAccount + userStakeTokenAccount, ); expect(userStakeTokenAccountInfo.amount.toNumber()).to.eq(amount); }); @@ -1331,7 +1319,7 @@ describe("Mine", () => { user = Keypair.generate(); await provider.connection.requestAirdrop( user.publicKey, - LAMPORTS_PER_SOL + LAMPORTS_PER_SOL, ); rescueMint = await createMint(provider); }); @@ -1362,8 +1350,8 @@ describe("Mine", () => { minerATA, provider.wallet.publicKey, [], - EXPECTED_RESCUE_AMOUNT - ) + EXPECTED_RESCUE_AMOUNT, + ), ); await expectTXTable(tx, "create miner with ATA").to.be.fulfilled; @@ -1376,13 +1364,13 @@ describe("Mine", () => { quarry, stakeToken, stakedMintAuthority, - stakeAmount.toNumber() + stakeAmount.toNumber(), ); const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); const stakeTx = minerActions.stake( - new TokenAmount(stakeToken, stakeAmount) + new TokenAmount(stakeToken, stakeAmount), ); await expectTX(stakeTx, "deposit staked tokens").to.be.fulfilled; @@ -1396,7 +1384,7 @@ describe("Mine", () => { }); await expectTX( rescueTX, - "rescue staked tokens for user" + "rescue staked tokens for user", ).to.be.rejectedWith("0x454"); }); @@ -1434,7 +1422,7 @@ describe("Mine", () => { owner: user.publicKey, }); await expectTX(tx, "rescue tokens for user").to.be.rejectedWith( - "Signature verification failed" + "Signature verification failed", ); }); }); diff --git a/tests/mineRewards.spec.ts b/tests/mineRewards.spec.ts index 292df416..32fb1359 100644 --- a/tests/mineRewards.spec.ts +++ b/tests/mineRewards.spec.ts @@ -83,7 +83,7 @@ describe("Mine Rewards", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -95,7 +95,7 @@ describe("Mine Rewards", () => { stakeTokenMint = await createMint( provider, stakedMintAuthority.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); stakeToken = Token.fromMint(stakeTokenMint, DEFAULT_DECIMALS, { name: "stake token", @@ -111,7 +111,7 @@ describe("Mine Rewards", () => { const setAnnualRewardsTX = await rewarderWrapper.setAndSyncAnnualRewards( annualRewardsRate, - [] + [], ); await expectTX(setAnnualRewardsTX).eventually.to.be.fulfilled; @@ -122,15 +122,13 @@ describe("Mine Rewards", () => { .fulfilled; const quarryWrapper = await rewarderWrapper.getQuarry(stakeToken); await expectTX( - ( - await quarryWrapper.createMiner() - ).tx, - "create miner for user" + (await quarryWrapper.createMiner()).tx, + "create miner for user", ).to.be.fulfilled; await expectTX( quarryWrapper.setRewardsShare(rewardsShare), - "set rewards share" + "set rewards share", ).to.be.fulfilled; // mint test tokens @@ -139,7 +137,7 @@ describe("Mine Rewards", () => { await rewarderWrapper.getQuarry(stakeToken), stakeToken, stakedMintAuthority, - stakeAmount + stakeAmount, ); }); @@ -147,7 +145,7 @@ describe("Mine Rewards", () => { let quarry = await rewarderWrapper.getQuarry(stakeToken); expect(quarry).to.exist; const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); // stake into the quarry const tx = minerActions.stake(new TokenAmount(stakeToken, stakeAmount)); @@ -155,7 +153,7 @@ describe("Mine Rewards", () => { const parser = new anchor.EventParser( sdk.programs.Mine.programId, - sdk.programs.Mine.coder + sdk.programs.Mine.coder, ); const theParser = (logs: string[]) => { const events: StakeEvent[] = []; @@ -171,14 +169,14 @@ describe("Mine Rewards", () => { const payroll = quarry.payroll; assert.ok(event); const expectedRewardsPerTokenStored = payroll.calculateRewardPerToken( - event.data.timestamp + event.data.timestamp, ); expect(quarry.quarryData.rewardsPerTokenStored.toString()).to.equal( - expectedRewardsPerTokenStored.toString() + expectedRewardsPerTokenStored.toString(), ); const expectedRewardsRate = quarry.computeAnnualRewardsRate(); expect(quarry.quarryData.annualRewardsRate.toString()).to.equal( - expectedRewardsRate.toString() + expectedRewardsRate.toString(), ); }); @@ -189,11 +187,11 @@ describe("Mine Rewards", () => { invariant(miner, "miner does not exist"); const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); const stakeTx = minerActions.stake( - new TokenAmount(stakeToken, stakeAmount) + new TokenAmount(stakeToken, stakeAmount), ); await expectTX(stakeTx, "Stake").to.be.fulfilled; @@ -204,9 +202,9 @@ describe("Mine Rewards", () => { mintWrapper.newMinterWithAllowance( mintWrapperKey, rewarder, - new u64(100_000_000_000000) + new u64(100_000_000_000000), ), - "Minter add" + "Minter add", ).to.be.fulfilled; // wait some time so we can earn some tokens @@ -219,7 +217,7 @@ describe("Mine Rewards", () => { receipt.printLogs(); const claimEvent = QUARRY_CODERS.Mine.parseProgramLogEvents( - receipt.response.meta?.logMessages ?? [] + receipt.response.meta?.logMessages ?? [], )[0]; invariant(claimEvent?.name === "ClaimEvent", "claim event not found"); assert.ok(claimEvent, "claim event not found"); @@ -234,7 +232,7 @@ describe("Mine Rewards", () => { claimEvent.data.timestamp, new BN(stakeAmount), wagesPerTokenPaid, - ZERO + ZERO, ); const fees = expectedWagesEarned.mul(new BN(1)).div(new BN(10_000)); @@ -250,10 +248,10 @@ describe("Mine Rewards", () => { }); const rewardsTokenAccountInfo = await getTokenAccount( provider, - rewardsTokenAccount + rewardsTokenAccount, ); expect(rewardsTokenAccountInfo.amount.toString()).to.equal( - claimEvent.data.amount.toString() + claimEvent.data.amount.toString(), ); }); @@ -264,11 +262,11 @@ describe("Mine Rewards", () => { invariant(miner, "miner does not exist"); const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); const stakeTx = minerActions.stake( - new TokenAmount(stakeToken, stakeAmount) + new TokenAmount(stakeToken, stakeAmount), ); await expectTX(stakeTx, "Stake").to.be.fulfilled; @@ -279,9 +277,9 @@ describe("Mine Rewards", () => { mintWrapper.newMinterWithAllowance( mintWrapperKey, rewarder, - new u64(100_000_000_000000) + new u64(100_000_000_000000), ), - "Minter add" + "Minter add", ).to.be.fulfilled; // wait some time so we can earn some tokens @@ -289,9 +287,8 @@ describe("Mine Rewards", () => { const initRewardsPerTokenPaid = miner.rewardsPerTokenPaid; - const mintWrapperBefore = await mintWrapper.fetchMintWrapper( - mintWrapperKey - ); + const mintWrapperBefore = + await mintWrapper.fetchMintWrapper(mintWrapperKey); invariant(mintWrapperBefore); const tx = await minerActions.claimV1(); @@ -310,17 +307,17 @@ describe("Mine Rewards", () => { // check that rewards have changed const rewardsPerTokenPaidDiff = nextRewardsPerTokenPaid.sub( - initRewardsPerTokenPaid + initRewardsPerTokenPaid, ); expect(rewardsPerTokenPaidDiff).to.not.bignumber.zero; const numMinted = mintWrapperAfter.totalMinted.sub( - mintWrapperBefore.totalMinted + mintWrapperBefore.totalMinted, ); expect(numMinted).to.not.bignumber.zero; const claimEvent = QUARRY_CODERS.Mine.parseProgramLogEvents( - receipt.response.meta?.logMessages ?? [] + receipt.response.meta?.logMessages ?? [], )[0]; invariant(claimEvent?.name === "ClaimEvent", "claim event not found"); assert.ok(claimEvent, "claim event not found"); @@ -335,7 +332,7 @@ describe("Mine Rewards", () => { claimEvent.data.timestamp, new BN(stakeAmount), wagesPerTokenPaid, - ZERO + ZERO, ); const fees = expectedWagesEarned.mul(new BN(1)).div(new BN(10_000)); @@ -353,10 +350,10 @@ describe("Mine Rewards", () => { }); const rewardsTokenAccountInfo = await getTokenAccount( provider, - rewardsTokenAccount + rewardsTokenAccount, ); expect(rewardsTokenAccountInfo.amount.toString()).to.equal( - claimEvent.data.amount.toString() + claimEvent.data.amount.toString(), ); }); @@ -367,11 +364,11 @@ describe("Mine Rewards", () => { invariant(miner, "miner does not exist"); const minerActions = await quarry.getMinerActions( - provider.wallet.publicKey + provider.wallet.publicKey, ); const stakeTx = minerActions.stake( - new TokenAmount(stakeToken, stakeAmount) + new TokenAmount(stakeToken, stakeAmount), ); await expectTX(stakeTx, "Stake").to.be.fulfilled; @@ -380,9 +377,9 @@ describe("Mine Rewards", () => { mintWrapper.newMinterWithAllowance( mintWrapperKey, rewarder, - new u64(100_000_000_000000) + new u64(100_000_000_000000), ), - "Minter add" + "Minter add", ).to.be.fulfilled; const rewardsTokenAccount = await getATAAddress({ @@ -396,12 +393,12 @@ describe("Mine Rewards", () => { await expectTX( quarry.setRewardsShare(new BN(42)).combine(await minerActions.claim()), - "set rewards share and claim" + "set rewards share and claim", ).to.be.fulfilled; const rewardsTokenAccountInfo = await getTokenAccount( provider, - rewardsTokenAccount + rewardsTokenAccount, ); expect(rewardsTokenAccountInfo.amount.isZero()).to.be.false; }); diff --git a/tests/mintWrapper.spec.ts b/tests/mintWrapper.spec.ts index 13108f9c..fe71ba5d 100644 --- a/tests/mintWrapper.spec.ts +++ b/tests/mintWrapper.spec.ts @@ -56,7 +56,7 @@ describe("MintWrapper", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -99,7 +99,7 @@ describe("MintWrapper", () => { await mintWrapper.program.account.mintWrapper.fetch(mintWrapperKey); expect(mintWrapperState.admin).to.eqAddress(provider.wallet.publicKey); expect(mintWrapperState.pendingAdmin).to.eqAddress( - newAuthority.publicKey + newAuthority.publicKey, ); const ix = mintWrapper.program.instruction.acceptAdmin({ @@ -110,12 +110,11 @@ describe("MintWrapper", () => { }); let tx = sdk.newTx([ix], [newAuthority]); await expectTX(tx, "transfer authority").to.be.fulfilled; - mintWrapperState = await mintWrapper.program.account.mintWrapper.fetch( - mintWrapperKey - ); + mintWrapperState = + await mintWrapper.program.account.mintWrapper.fetch(mintWrapperKey); expect(mintWrapperState.admin).to.eqAddress(newAuthority.publicKey); expect(mintWrapperState.pendingAdmin).to.eqAddress( - web3.PublicKey.default.toString() + web3.PublicKey.default.toString(), ); // Transfer back @@ -127,7 +126,7 @@ describe("MintWrapper", () => { admin: newAuthority.publicKey, nextAdmin: provider.wallet.publicKey, }, - }) + }), ); instructions.push( mintWrapper.program.instruction.acceptAdmin({ @@ -135,19 +134,18 @@ describe("MintWrapper", () => { mintWrapper: mintWrapperKey, pendingAdmin: provider.wallet.publicKey, }, - }) + }), ); tx = sdk.newTx(instructions, [newAuthority]); await expectTX(tx, "transfer authority back to original authority").to.be .fulfilled; - mintWrapperState = await mintWrapper.program.account.mintWrapper.fetch( - mintWrapperKey - ); + mintWrapperState = + await mintWrapper.program.account.mintWrapper.fetch(mintWrapperKey); expect(mintWrapperState.admin).to.eqAddress(provider.wallet.publicKey); expect(mintWrapperState.pendingAdmin).to.eqAddress( - web3.PublicKey.default + web3.PublicKey.default, ); }); @@ -155,7 +153,7 @@ describe("MintWrapper", () => { const id = Keypair.generate().publicKey; await expectTX( mintWrapper.newMinterV1(mintWrapperKey, id), - "new minter v1" + "new minter v1", ).to.be.fulfilled; }); @@ -164,21 +162,21 @@ describe("MintWrapper", () => { const id = Keypair.generate().publicKey; expect( (await mintWrapper.fetchMintWrapper(mintWrapperKey))?.numMinters, - "initial num minters" + "initial num minters", ).to.bignumber.eq(new BN(0)); await expectTX( mintWrapper.newMinterWithAllowance(mintWrapperKey, id, allowance), - "add minter" + "add minter", ).to.be.fulfilled; expect( (await mintWrapper.fetchMinter(mintWrapperKey, id))?.allowance, - "allowance" + "allowance", ).to.bignumber.eq(allowance); expect( (await mintWrapper.fetchMintWrapper(mintWrapperKey))?.numMinters, - "final num minters" + "final num minters", ).to.bignumber.eq(new BN(1)); }); @@ -187,21 +185,21 @@ describe("MintWrapper", () => { const id = Keypair.generate().publicKey; await expectTX( mintWrapper.newMinterWithAllowance(mintWrapperKey, id, allowance), - "add minter" + "add minter", ).to.be.fulfilled; expect( (await mintWrapper.fetchMinter(mintWrapperKey, id))?.allowance, - "allowance" + "allowance", ).to.bignumber.eq(allowance); await expectTX( mintWrapper.minterUpdate(mintWrapperKey, id, new u64(0)), - "remove minter" + "remove minter", ).to.be.fulfilled; expect( (await mintWrapper.fetchMinter(mintWrapperKey, id))?.allowance, - "no more allowance" + "no more allowance", ).to.bignumber.zero; }); @@ -215,20 +213,20 @@ describe("MintWrapper", () => { provider.connection, await provider.connection.requestAirdrop( kp.publicKey, - LAMPORTS_PER_SOL - ) - ) + LAMPORTS_PER_SOL, + ), + ), ).to.be.fulfilled; const id = kp.publicKey; await expectTX( mintWrapper.newMinterWithAllowance(mintWrapperKey, id, allowance), - "add minter" + "add minter", ).to.be.fulfilled; expect( (await mintWrapper.fetchMinter(mintWrapperKey, id))?.allowance, - "allowance" + "allowance", ).to.bignumber.eq(allowance); const amount = new TokenAmount(token, new u64(1_000)); @@ -236,7 +234,7 @@ describe("MintWrapper", () => { const [minterAddress] = await findMinterAddress(mintWrapperKey, id); const minterData = await minterSDK.programs.MintWrapper.account.minter.fetch( - minterAddress + minterAddress, ); const minterRaw = await provider.connection.getAccountInfo(minterAddress); assert.ok(minterRaw); @@ -252,24 +250,24 @@ describe("MintWrapper", () => { }, }, }), - "mint" + "mint", ).to.be.fulfilled; const minterData2 = await mintWrapper.fetchMinter(mintWrapperKey, id); const mwData2 = await mintWrapper.fetchMintWrapper(mintWrapperKey); assert.ok(minterData2 && mwData2); expect(minterData2.allowance, "allowance").to.bignumber.eq( - new BN(999_000) + new BN(999_000), ); expect(minterData2.totalMinted, "minter total minted").to.bignumber.eq( - new BN(1_000) + new BN(1_000), ); expect(mwData2.totalAllowance, "total allowance").to.bignumber.eq( - new BN(999_000) + new BN(999_000), ); expect(mwData2.totalMinted, "total minted").to.bignumber.eq( - new BN(1_000) + new BN(1_000), ); await expectTX( @@ -283,7 +281,7 @@ describe("MintWrapper", () => { }, }, }), - "mint" + "mint", ).to.be.rejected; }); }); diff --git a/tests/operator.spec.ts b/tests/operator.spec.ts index 96205a91..d14b903f 100644 --- a/tests/operator.spec.ts +++ b/tests/operator.spec.ts @@ -67,7 +67,7 @@ describe("Operator", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -87,7 +87,7 @@ describe("Operator", () => { rewarder = await mine.loadRewarderWrapper(rewarderKey); await expectTX( await rewarder.setAndSyncAnnualRewards(ANNUAL_REWARDS_RATE, []), - "set annual rewards" + "set annual rewards", ); }); @@ -188,8 +188,8 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( randomKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); const stakeMint = await createMint(sdk.provider); @@ -197,7 +197,7 @@ describe("Operator", () => { tokenMint: stakeMint, }); await expectTX(tx).to.be.rejected.and.to.match( - new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`) + new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`), ); // unauthorized }); @@ -215,8 +215,8 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( quarryCreatorKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); const stakeMint = await createMint(sdk.provider); @@ -264,17 +264,17 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( randomKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); await expectTX( randomOperator.delegateSetRewardsShare({ quarry: quarryKey, share: 1, - }) + }), ).to.be.rejected.and.to.match( - new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`) + new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`), ); // unauthorized }); @@ -292,8 +292,8 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( shareAllocatorKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); const tx = shareAllocatorOperator.delegateSetRewardsShare({ @@ -317,13 +317,13 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( shareAllocatorKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); const tx = shareAllocatorOperator.delegateSetFamine( new u64("9000000000000000000"), - quarryKey + quarryKey, ); await expectTX(tx).to.be.fulfilled; }); @@ -358,14 +358,14 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( randomKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); await expectTX( - randomOperator.delegateSetAnnualRewards(new u64(1_000000)) + randomOperator.delegateSetAnnualRewards(new u64(1_000000)), ).to.be.rejected.and.to.match( - new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`) + new RegExp(`0x${QuarryOperatorErrors.Unauthorized.code.toString(16)}`), ); }); @@ -383,8 +383,8 @@ describe("Operator", () => { sdk.provider.connection, await sdk.provider.connection.requestAirdrop( rateSetterKP.publicKey, - LAMPORTS_PER_SOL - ) + LAMPORTS_PER_SOL, + ), ).wait(); const tx = rateSetterOperator.delegateSetAnnualRewards(new u64(1_000000)); diff --git a/tests/quarryMergeMine.spec.ts b/tests/quarryMergeMine.spec.ts index bced6c88..921bf2f5 100644 --- a/tests/quarryMergeMine.spec.ts +++ b/tests/quarryMergeMine.spec.ts @@ -47,16 +47,16 @@ describe("Quarry Merge Mine", () => { const { connection } = provider; await connection.confirmTransaction( - await connection.requestAirdrop(adminKP.publicKey, 10 * LAMPORTS_PER_SOL) + await connection.requestAirdrop(adminKP.publicKey, 10 * LAMPORTS_PER_SOL), ); await connection.confirmTransaction( - await connection.requestAirdrop(ownerKP.publicKey, 10 * LAMPORTS_PER_SOL) + await connection.requestAirdrop(ownerKP.publicKey, 10 * LAMPORTS_PER_SOL), ); const stakedTokenMint = await createMint( provider, minterKP.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); stakedToken = Token.fromMint(stakedTokenMint, DEFAULT_DECIMALS); @@ -99,9 +99,8 @@ describe("Quarry Merge Mine", () => { }); // init merge miner - const poolData = await ownerSDK.mergeMine.program.account.mergePool.fetch( - poolKey - ); + const poolData = + await ownerSDK.mergeMine.program.account.mergePool.fetch(poolKey); const { tx: initMMTX, key: mmKey } = await ownerSDK.mergeMine.newMM({ pool: { key: poolKey, @@ -135,19 +134,19 @@ describe("Quarry Merge Mine", () => { ownerAccounts.staked, minterKP.publicKey, [], - 1_000_000_000_000 + 1_000_000_000_000, ), ], - [minterKP] + [minterKP], ), - "Mint staked token to owner" + "Mint staked token to owner", ).to.be.fulfilled; const ownerInitialBalance = ( await getTokenAccount(provider, ownerAccounts.staked) ).amount; expect(ownerInitialBalance).to.bignumber.eq( - TokenAmount.parse(stakedToken, "1000000").toU64() + TokenAmount.parse(stakedToken, "1000000").toU64(), ); const stakedAmount = TokenAmount.parse(stakedToken, "100"); @@ -186,26 +185,26 @@ describe("Quarry Merge Mine", () => { replicaBBalance: BN; walletBalance: BN; }, - msg?: string + msg?: string, ) => { const state = await fetchState(); const msgFmt = (prop: string) => (msg ? `${prop} (${msg})` : undefined); expect(state.primaryBalance, msgFmt("primaryBalance")).to.bignumber.eq( - args.primaryBalance + args.primaryBalance, ); expect(state.replicaBalance, msgFmt("replicaBalance")).to.bignumber.eq( - args.replicaBalance + args.replicaBalance, ); expect( state.replicaABalance, - msgFmt("replicaABalance") + msgFmt("replicaABalance"), ).to.bignumber.eq(args.replicaABalance); expect( state.replicaBBalance, - msgFmt("replicaBBalance") + msgFmt("replicaBBalance"), ).to.bignumber.eq(args.replicaBBalance); expect(state.walletBalance, msgFmt("walletBalance")).to.bignumber.eq( - args.walletBalance + args.walletBalance, ); }; @@ -218,7 +217,7 @@ describe("Quarry Merge Mine", () => { replicaBBalance: new BN(0), walletBalance: ownerInitialBalance, }, - "initial" + "initial", ); // deposit into pool @@ -243,20 +242,20 @@ describe("Quarry Merge Mine", () => { replicaBBalance: new BN(0), walletBalance: ownerInitialBalance.sub(stakedAmount.toU64()), }, - "after deposit" + "after deposit", ); // sleep so we earn some tokens await sleep(2_000); expect( - (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount + (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount, ).to.bignumber.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount, ).to.bignumber.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount, ).to.bignumber.eq("0"); // claim primary rewards @@ -276,14 +275,14 @@ describe("Quarry Merge Mine", () => { await expectTX(claimReplicaATX, "Claim replica A").to.be.fulfilled; expect( - (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount + (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount, ).to.bignumber.not.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount, ).to.bignumber.not.eq("0"); expect( (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount, - "not claimed" + "not claimed", ).to.bignumber.eq("0"); // withdraw from merge miner @@ -307,7 +306,7 @@ describe("Quarry Merge Mine", () => { replicaBBalance: new BN(0), walletBalance: ownerInitialBalance, }, - "after withdraw" + "after withdraw", ); }); @@ -317,7 +316,7 @@ describe("Quarry Merge Mine", () => { const stakedTokenMint = await createMint( provider, minterKP.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const stakedToken = Token.fromMint(stakedTokenMint, DEFAULT_DECIMALS); @@ -349,9 +348,8 @@ describe("Quarry Merge Mine", () => { }); // init merge miner - const poolData = await ownerSDK.mergeMine.program.account.mergePool.fetch( - poolKey - ); + const poolData = + await ownerSDK.mergeMine.program.account.mergePool.fetch(poolKey); const { tx: initMMTX, key: mmKey } = await ownerSDK.mergeMine.newMM({ pool: { key: poolKey, @@ -384,12 +382,12 @@ describe("Quarry Merge Mine", () => { ownerAccounts.staked, minterKP.publicKey, [], - 1_000_000_000000 + 1_000_000_000000, ), ], - [minterKP] + [minterKP], ), - "Mint staked token to owner" + "Mint staked token to owner", ).to.be.fulfilled; const stakedAmount = TokenAmount.parse(stakedToken, "100"); @@ -417,8 +415,8 @@ describe("Quarry Merge Mine", () => { const err = e as Error; expect(err.message).to.include( `0x${QuarryMergeMineErrors.OutstandingReplicaTokens.code.toString( - 16 - )}` + 16, + )}`, ); } }); @@ -485,7 +483,7 @@ describe("Quarry Merge Mine", () => { minerATAKey, provider.wallet.publicKey, [], - EXPECTED_RESCUE_AMOUNT + EXPECTED_RESCUE_AMOUNT, ), ]); await expectTX(mintToTX, "Mint rescue tokens to miner").to.be.fulfilled; @@ -519,7 +517,7 @@ describe("Quarry Merge Mine", () => { await expectTXTable( tx, - "rescue tokens from mergeMiner" + "rescue tokens from mergeMiner", ).to.be.rejectedWith("0x454"); }); @@ -555,7 +553,7 @@ describe("Quarry Merge Mine", () => { const tx = createMinerTokenAccountTx.combine(rescueTX); await expectTXTable( tx, - "rescue tokens from mergeMiner" + "rescue tokens from mergeMiner", ).to.be.rejectedWith("0x454"); }); @@ -592,7 +590,7 @@ describe("Quarry Merge Mine", () => { await expectTXTable( tx, - "rescue tokens from mergeMiner" + "rescue tokens from mergeMiner", ).to.be.rejectedWith("0x454"); }); @@ -623,7 +621,7 @@ describe("Quarry Merge Mine", () => { const tokenAccount = await getTokenAccount( provider, - destinationTokenAccount + destinationTokenAccount, ); expect(tokenAccount.amount).to.bignumber.eq(EXPECTED_RESCUE_AMOUNT); }); @@ -637,7 +635,7 @@ describe("Quarry Merge Mine", () => { const stakedTokenMint = await createMint( provider, minterKP.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const stakedToken = Token.fromMint(stakedTokenMint, DEFAULT_DECIMALS); @@ -697,19 +695,19 @@ describe("Quarry Merge Mine", () => { ownerAccounts.staked, minterKP.publicKey, [], - 1_000_000_000000 + 1_000_000_000000, ), ], - [minterKP] + [minterKP], ), - "Mint staked token to owner" + "Mint staked token to owner", ).to.be.fulfilled; const ownerInitialBalance = ( await getTokenAccount(provider, ownerAccounts.staked) ).amount; expect(ownerInitialBalance).to.bignumber.eq( - TokenAmount.parse(stakedToken, "1000000").toU64() + TokenAmount.parse(stakedToken, "1000000").toU64(), ); const stakedAmount = TokenAmount.parse(stakedToken, "100"); @@ -752,26 +750,26 @@ describe("Quarry Merge Mine", () => { replicaBBalance: BN; walletBalance: BN; }, - msg?: string + msg?: string, ) => { const state = await fetchState(); const msgFmt = (prop: string) => (msg ? `${prop} (${msg})` : undefined); expect(state.primaryBalance, msgFmt("primaryBalance")).to.bignumber.eq( - args.primaryBalance + args.primaryBalance, ); expect(state.replicaBalance, msgFmt("replicaBalance")).to.bignumber.eq( - args.replicaBalance + args.replicaBalance, ); expect( state.replicaABalance, - msgFmt("replicaABalance") + msgFmt("replicaABalance"), ).to.bignumber.eq(args.replicaABalance); expect( state.replicaBBalance, - msgFmt("replicaBBalance") + msgFmt("replicaBBalance"), ).to.bignumber.eq(args.replicaBBalance); expect(state.walletBalance, msgFmt("walletBalance")).to.bignumber.eq( - args.walletBalance + args.walletBalance, ); }; @@ -787,7 +785,7 @@ describe("Quarry Merge Mine", () => { const replicaAStakeTX = await mp.stakeReplicaMiner( replicaA.rewarder, - mmKey + mmKey, ); await expectTXTable(replicaAStakeTX, "Stake into replica A").to.be .fulfilled; @@ -801,63 +799,63 @@ describe("Quarry Merge Mine", () => { replicaBBalance: new BN(0), walletBalance: ownerInitialBalance.sub(stakedAmount.toU64()), }, - "after deposit" + "after deposit", ); // sleep so we earn some tokens await sleep(2_000); expect( - (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount + (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount, ).to.bignumber.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount, ).to.bignumber.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount, ).to.bignumber.eq("0"); // claim primary rewards const claimPrimary = await mp.claimPrimaryRewards( primary.rewarder, - mmKey + mmKey, ); const { ataIXs: claimPrimaryATATx, tx: claimPrimaryTx } = claimPrimary.splitATAIXs(); await expectTXTable( claimPrimaryATATx, - "Create ATA accounts for primary claim" + "Create ATA accounts for primary claim", ).to.be.fulfilled; await expectTXTable(claimPrimaryTx, "Claim primary").to.be.fulfilled; // claim replica A rewards const claimReplicaA = await mp.claimReplicaRewards( replicaA.rewarder, - mmKey + mmKey, ); const { ataIXs: claimReplicaATATx, tx: claimReplicaATX } = claimReplicaA.splitATAIXs(); await expectTXTable( claimReplicaATATx, - "Create ATA accounts for replica claim" + "Create ATA accounts for replica claim", ).to.be.fulfilled; await expectTXTable(claimReplicaATX, "Claim replica A").to.be.fulfilled; expect( - (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount + (await getTokenAccount(provider, ownerAccounts.primaryRewards)).amount, ).to.bignumber.not.eq("0"); expect( - (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount + (await getTokenAccount(provider, ownerAccounts.replicaARewards)).amount, ).to.bignumber.not.eq("0"); expect( (await getTokenAccount(provider, ownerAccounts.replicaBRewards)).amount, - "not claimed" + "not claimed", ).to.bignumber.eq("0"); // withdraw from merge miner const unstakeReplicaATX = await mp.unstakeAllReplica( replicaA.rewarder, - mmKey + mmKey, ); await expectTX(unstakeReplicaATX, "Unstake Replica A").to.be.fulfilled; const withdrawTX = await mp.withdraw({ @@ -879,7 +877,7 @@ describe("Quarry Merge Mine", () => { replicaBBalance: new BN(0), walletBalance: ownerInitialBalance, }, - "after withdraw" + "after withdraw", ); }); @@ -889,7 +887,7 @@ describe("Quarry Merge Mine", () => { const stakedTokenMint = await createMint( provider, minterKP.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); const stakedToken = Token.fromMint(stakedTokenMint, DEFAULT_DECIMALS); @@ -942,12 +940,12 @@ describe("Quarry Merge Mine", () => { ownerAccounts.staked, minterKP.publicKey, [], - 1_000_000_000000 + 1_000_000_000000, ), ], - [minterKP] + [minterKP], ), - "Mint staked token to owner" + "Mint staked token to owner", ).to.be.fulfilled; const stakedAmount = TokenAmount.parse(stakedToken, "100"); @@ -967,7 +965,7 @@ describe("Quarry Merge Mine", () => { }); const replicaAStakeTX = await mp.stakeReplicaMiner( replicaA.rewarder, - mmKey + mmKey, ); await expectTX(replicaAStakeTX, "Stake into replica A").to.be.fulfilled; @@ -983,8 +981,8 @@ describe("Quarry Merge Mine", () => { const err = e as Error; expect(err.message).to.include( `0x${QuarryMergeMineErrors.OutstandingReplicaTokens.code.toString( - 16 - )}` + 16, + )}`, ); } }); diff --git a/tests/quarryRedeemer.spec.ts b/tests/quarryRedeemer.spec.ts index 77106172..d6197f41 100644 --- a/tests/quarryRedeemer.spec.ts +++ b/tests/quarryRedeemer.spec.ts @@ -41,14 +41,14 @@ describe("Redeemer", () => { redemptionMintAuthority = Keypair.generate(); redemptionMint = await createMint( sdk.provider, - redemptionMintAuthority.publicKey + redemptionMintAuthority.publicKey, ); userAuthority = Keypair.generate(); // Airdrop to user await sdk.provider.connection.requestAirdrop( userAuthority.publicKey, - 10 * LAMPORTS_PER_SOL + 10 * LAMPORTS_PER_SOL, ); const { bump, tx, vaultTokenAccount } = await sdk.createRedeemer({ @@ -67,15 +67,15 @@ describe("Redeemer", () => { invariant( createAccountInstructions.iouMint, - "create user ATA account for iouMint" + "create user ATA account for iouMint", ); invariant( createAccountInstructions.redemptionMint, - "create user ATA account for redemptionMint" + "create user ATA account for redemptionMint", ); tx.instructions.push( createAccountInstructions.iouMint, - createAccountInstructions.redemptionMint + createAccountInstructions.redemptionMint, ); tx.instructions.push( ...createMintToInstruction({ @@ -91,7 +91,7 @@ describe("Redeemer", () => { mintAuthorityKP: iouMintAuthority, to: accounts.iouMint, amount: new u64(1_000 * DEFAULT_DECIMALS), - }).instructions + }).instructions, ); tx.addSigners(iouMintAuthority, redemptionMintAuthority); await expectTX(tx, "create redeemer").to.be.fulfilled; @@ -133,10 +133,10 @@ describe("Redeemer", () => { expect(iouSourceAccount.amount.toString()).to.equal(ZERO.toString()); const redemptionDestinationAccount = await getTokenAccount( provider, - redemptionDestination + redemptionDestination, ); expect(redemptionDestinationAccount.amount.toString()).to.equal( - expectedAmount.toString() + expectedAmount.toString(), ); }); }); diff --git a/tests/quarryUtils.ts b/tests/quarryUtils.ts index 251463fb..b8ca0b29 100644 --- a/tests/quarryUtils.ts +++ b/tests/quarryUtils.ts @@ -45,7 +45,7 @@ export const createRewarderAndQuarry = async ({ { connection, adminKP, - } + }, ); const { tx: createQuarryTX, quarry: quarryKey } = @@ -93,7 +93,7 @@ export const createRewarder = async ({ rewarderW: RewarderWrapper; }> => { await connection.confirmTransaction( - await connection.requestAirdrop(adminKP.publicKey, 10 * LAMPORTS_PER_SOL) + await connection.requestAirdrop(adminKP.publicKey, 10 * LAMPORTS_PER_SOL), ); const primaryQuarrySDK = QuarrySDK.load({ @@ -120,13 +120,13 @@ export const createRewarder = async ({ const minterAddTX = await primaryQuarrySDK.mintWrapper.newMinterWithAllowance( primaryMintWrapper.mintWrapper, primaryRewarder.key, - new u64(1_000_000000) + new u64(1_000_000000), ); await expectTX(minterAddTX, "Minter add").to.be.fulfilled; // create quarry const rewarderW = await primaryQuarrySDK.mine.loadRewarderWrapper( - primaryRewarder.key + primaryRewarder.key, ); return { diff --git a/tests/registry.spec.ts b/tests/registry.spec.ts index 1d73a59f..c3a71fe6 100644 --- a/tests/registry.spec.ts +++ b/tests/registry.spec.ts @@ -65,7 +65,7 @@ describe("Registry", () => { decimals: DEFAULT_DECIMALS, mintAuthority: wrapperKey, freezeAuthority: wrapperKey, - }) + }), ).to.be.fulfilled; mintWrapperKey = wrapperKey; @@ -77,7 +77,7 @@ describe("Registry", () => { stakeTokenMint = await createMint( provider, stakedMintAuthority.publicKey, - DEFAULT_DECIMALS + DEFAULT_DECIMALS, ); stakeToken = Token.fromMint(stakeTokenMint, DEFAULT_DECIMALS, { name: "stake token", @@ -93,7 +93,7 @@ describe("Registry", () => { const setAnnualRewardsTX = await rewarderWrapper.setAndSyncAnnualRewards( annualRewardsRate, - [] + [], ); await expectTX(setAnnualRewardsTX).eventually.to.be.fulfilled; @@ -120,8 +120,8 @@ describe("Registry", () => { console.log( (await sdk.registry.program.account.registry.fetch(registry)).tokens.map( - (tok) => tok.toString() - ) + (tok) => tok.toString(), + ), ); }); }); diff --git a/tests/utils.ts b/tests/utils.ts index f4a673e4..a62af99f 100644 --- a/tests/utils.ts +++ b/tests/utils.ts @@ -19,10 +19,10 @@ export const newUserStakeTokenAccount = async ( quarry: QuarryWrapper, stakeToken: Token, stakedMintAuthority: Signer, - amount: number + amount: number, ): Promise => { const minerActions = await quarry.getMinerActions( - sdk.provider.wallet.publicKey + sdk.provider.wallet.publicKey, ); const createATA = await minerActions.createATAIfNotExists(); if (createATA) { @@ -39,12 +39,12 @@ export const newUserStakeTokenAccount = async ( userStakeTokenAccount, stakedMintAuthority.publicKey, [], - amount + amount, ), ], - [stakedMintAuthority] + [stakedMintAuthority], ), - "mint initial" + "mint initial", ).to.be.fulfilled; return userStakeTokenAccount; @@ -53,13 +53,13 @@ export const newUserStakeTokenAccount = async ( export const initATA = async ( token: Token, owner: Signer, - mint?: { minter: Signer; mintAmount: number } + mint?: { minter: Signer; mintAmount: number }, ): Promise => { const account = await SPLToken.getAssociatedTokenAddress( ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, token.mintAccount, - owner.publicKey + owner.publicKey, ); const tx = new Transaction().add( @@ -69,8 +69,8 @@ export const initATA = async ( token.mintAccount, account, owner.publicKey, - AnchorProvider.env().wallet.publicKey - ) + AnchorProvider.env().wallet.publicKey, + ), ); if (mint) { @@ -81,8 +81,8 @@ export const initATA = async ( account, mint.minter.publicKey, [], - mint.mintAmount - ) + mint.mintAmount, + ), ); } // mint tokens @@ -91,7 +91,7 @@ export const initATA = async ( mint ? [mint.minter] : undefined, { commitment: "confirmed", - } + }, ); return account; };