diff --git a/liquidator/.eslintrc.js b/liquidator/.eslintrc.js index 508f4991..f27de97d 100644 --- a/liquidator/.eslintrc.js +++ b/liquidator/.eslintrc.js @@ -1,7 +1,7 @@ module.exports = { root: true, parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], + plugins: ['@typescript-eslint', 'react', 'import'], extends: [ 'eslint:recommended', 'airbnb-typescript', diff --git a/liquidator/package.json b/liquidator/package.json index 5a0e1297..f8465b96 100644 --- a/liquidator/package.json +++ b/liquidator/package.json @@ -39,6 +39,7 @@ "bs58": "^4.0.1", "buffer-layout": "^1.2.1", "dotenv": "^10.0.0", + "eslint-config-airbnb": "^19.0.4", "ggoldca-sdk": "^0.0.17", "got": "^9.6.0", "hot-shots": "^8.5.0", @@ -53,12 +54,12 @@ "devDependencies": { "@types/jest": "^24.9.1", "@types/node": "^14.0.14", - "@typescript-eslint/eslint-plugin": "^3.10.1", - "@typescript-eslint/parser": "^3.10.1", - "eslint": "^5.16.0", + "@typescript-eslint/eslint-plugin": "^6.2.1", + "@typescript-eslint/parser": "^6.2.1", + "eslint": "^8.46.0", "eslint-config-airbnb-base": "^13.2.0", - "eslint-config-airbnb-typescript": "^8.0.2", - "eslint-plugin-import": "^2.18.2", + "eslint-config-airbnb-typescript": "^17.1.0", + "eslint-plugin-import": "^2.28.0", "eslint-plugin-jest": "^22.21.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-react": "^7.20.0", @@ -68,6 +69,6 @@ "nodemon": "^1.19.4", "supertest": "^4.0.2", "ts-jest": "^26.3.0", - "typescript": "^4.4.4" + "typescript": "^5.1.6" } } diff --git a/liquidator/src/libs/rebalanceWallet.ts b/liquidator/src/libs/rebalanceWallet.ts index d231ea0c..3dac6bbe 100644 --- a/liquidator/src/libs/rebalanceWallet.ts +++ b/liquidator/src/libs/rebalanceWallet.ts @@ -67,7 +67,7 @@ export async function rebalanceWallet(connection, payer, jupiter, tokensOracle, function aggregateInfo(tokensOracle, walletBalances, connection, wallet, target) { const info: any = []; target.forEach(async (tokenDistribution: TokenCount) => { - const { symbol, target } = tokenDistribution; + const { symbol, target: tokenTarget } = tokenDistribution; const tokenOracle = findWhere(tokensOracle, { symbol }); const walletBalance = findWhere(walletBalances, { symbol }); @@ -90,7 +90,7 @@ function aggregateInfo(tokensOracle, walletBalances, connection, wallet, target) const usdValue = new BigNumber(walletBalance.balance).multipliedBy(tokenOracle.price); info.push({ symbol, - target, + target: tokenTarget, mintAddress: tokenOracle.mintAddress, ata: walletBalance.ata?.toString(), balance: walletBalance.balance, diff --git a/liquidator/src/libs/refreshObligation.ts b/liquidator/src/libs/refreshObligation.ts index 5e78ab49..cb31837f 100644 --- a/liquidator/src/libs/refreshObligation.ts +++ b/liquidator/src/libs/refreshObligation.ts @@ -84,7 +84,7 @@ export function calculateRefreshedObligation( mintAddress, marketValue, symbol, - addedBorrowWeightBPS: reserve.config.addedBorrowWeightBPS + addedBorrowWeightBPS: reserve.config.addedBorrowWeightBPS, }); }); diff --git a/liquidator/src/libs/unwrap/nazare/ggoldca.ts b/liquidator/src/libs/unwrap/nazare/ggoldca.ts index 9137e18e..28b81a2c 100644 --- a/liquidator/src/libs/unwrap/nazare/ggoldca.ts +++ b/liquidator/src/libs/unwrap/nazare/ggoldca.ts @@ -64,7 +64,7 @@ export type Ggoldca = { 'name': 'rent', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -78,7 +78,7 @@ export type Ggoldca = { { 'name': 'minSlotsForReinvest', 'type': 'u64' - } + }, ] }, { @@ -93,13 +93,13 @@ export type Ggoldca = { 'name': 'vaultAccount', 'isMut': true, 'isSigner': false - } + }, ], 'args': [ { 'name': 'isPaused', 'type': 'bool' - } + }, ] }, { @@ -114,13 +114,13 @@ export type Ggoldca = { 'name': 'vaultAccount', 'isMut': true, 'isSigner': false - } + }, ], 'args': [ { 'name': 'isActive', 'type': 'bool' - } + }, ] }, { @@ -180,7 +180,7 @@ export type Ggoldca = { 'name': 'associatedTokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -194,7 +194,7 @@ export type Ggoldca = { { 'name': 'tickUpperIndex', 'type': 'i32' - } + }, ] }, { @@ -234,7 +234,7 @@ export type Ggoldca = { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -265,7 +265,7 @@ export type Ggoldca = { 'name': 'destinationTokenAccount', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -273,7 +273,7 @@ export type Ggoldca = { 'type': { 'defined': 'MarketRewardsInfoInput' } - } + }, ] }, { @@ -288,13 +288,13 @@ export type Ggoldca = { 'name': 'vaultAccount', 'isMut': true, 'isSigner': false - } + }, ], 'args': [ { 'name': 'fee', 'type': 'u64' - } + }, ] }, { @@ -309,13 +309,13 @@ export type Ggoldca = { 'name': 'vaultAccount', 'isMut': true, 'isSigner': false - } + }, ], 'args': [ { 'name': 'minSlots', 'type': 'u64' - } + }, ] }, { @@ -383,7 +383,7 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { @@ -413,14 +413,14 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -499,7 +499,7 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { @@ -516,7 +516,7 @@ export type Ggoldca = { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -530,7 +530,7 @@ export type Ggoldca = { { 'name': 'maxAmountB', 'type': 'u64' - } + }, ] }, { @@ -608,7 +608,7 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { @@ -625,7 +625,7 @@ export type Ggoldca = { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -639,7 +639,7 @@ export type Ggoldca = { { 'name': 'minAmountB', 'type': 'u64' - } + }, ] }, { @@ -712,14 +712,14 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -778,20 +778,20 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { 'name': 'rewardIndex', 'type': 'u8' - } + }, ] }, { @@ -821,7 +821,7 @@ export type Ggoldca = { 'name': 'swapProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -847,7 +847,7 @@ export type Ggoldca = { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -916,7 +916,7 @@ export type Ggoldca = { 'name': 'tickArrayUpper', 'isMut': true, 'isSigner': false - } + }, ] }, { @@ -943,7 +943,7 @@ export type Ggoldca = { 'name': 'tokenProgram', 'isMut': false, 'isSigner': false - } + }, ], 'args': [] }, @@ -994,7 +994,7 @@ export type Ggoldca = { 'name': 'rent', 'isMut': false, 'isSigner': false - } + }, ], 'args': [ { @@ -1012,15 +1012,15 @@ export type Ggoldca = { { 'name': 'firstTime', 'type': 'bool' - } + }, ] - } + }, ], 'accounts': [ { 'name': 'vaultAccount', 'docs': [ - 'Strategy vault account' + 'Strategy vault account', ], 'type': { 'kind': 'struct', @@ -1028,35 +1028,35 @@ export type Ggoldca = { { 'name': 'version', 'docs': [ - 'Vault version' + 'Vault version', ], 'type': 'u8' }, { 'name': 'isActiveFromUi', 'docs': [ - 'The vault is active from the UI' + 'The vault is active from the UI', ], 'type': 'bool' }, { 'name': 'isPaused', 'docs': [ - 'The smart contract is paused for this vault' + 'The smart contract is paused for this vault', ], 'type': 'bool' }, { 'name': 'id', 'docs': [ - 'Vault number for a given whirlpool' + 'Vault number for a given whirlpool', ], 'type': 'u8' }, { 'name': 'bumps', 'docs': [ - 'PDA bump seeds' + 'PDA bump seeds', ], 'type': { 'defined': 'Bumps' @@ -1065,56 +1065,56 @@ export type Ggoldca = { { 'name': 'whirlpoolId', 'docs': [ - 'Whirlpool pubkey' + 'Whirlpool pubkey', ], 'type': 'publicKey' }, { 'name': 'inputTokenAMintPubkey', 'docs': [ - 'Pool input token_a mint address' + 'Pool input token_a mint address', ], 'type': 'publicKey' }, { 'name': 'inputTokenBMintPubkey', 'docs': [ - 'Pool input token_b mint address' + 'Pool input token_b mint address', ], 'type': 'publicKey' }, { 'name': 'fee', 'docs': [ - 'Fee percentage using FEE_SCALE. Fee applied on earnings' + 'Fee percentage using FEE_SCALE. Fee applied on earnings', ], 'type': 'u64' }, { 'name': 'minSlotsForReinvest', 'docs': [ - 'Minimum number of elapsed slots required for reinvesting' + 'Minimum number of elapsed slots required for reinvesting', ], 'type': 'u64' }, { 'name': 'lastReinvestmentSlot', 'docs': [ - 'Last reinvestment slot' + 'Last reinvestment slot', ], 'type': 'u64' }, { 'name': 'lastLiquidityIncrease', 'docs': [ - 'Last reinvestment liquidity increase' + 'Last reinvestment liquidity increase', ], 'type': 'u128' }, { 'name': 'earnedRewardsTokenA', 'docs': [ - 'Total rewards earned by the vault' + 'Total rewards earned by the vault', ], 'type': 'u64' }, @@ -1125,21 +1125,21 @@ export type Ggoldca = { { 'name': 'marketRewards', 'docs': [ - 'The market where to sell the rewards' + 'The market where to sell the rewards', ], 'type': { 'array': [ { 'defined': 'MarketRewardsInfo' }, - 3 + 3, ] } }, { 'name': 'positions', 'docs': [ - 'Information about the opened positions (max = MAX_POSITIONS)' + 'Information about the opened positions (max = MAX_POSITIONS)', ], 'type': { 'vec': { @@ -1150,18 +1150,18 @@ export type Ggoldca = { { 'name': 'padding', 'docs': [ - 'Additional padding' + 'Additional padding', ], 'type': { 'array': [ 'u64', - 10 + 10, ] } - } + }, ] } - } + }, ], 'types': [ { @@ -1172,7 +1172,7 @@ export type Ggoldca = { { 'name': 'id', 'docs': [ - 'Id of market associated' + 'Id of market associated', ], 'type': { 'defined': 'MarketRewards' @@ -1181,17 +1181,17 @@ export type Ggoldca = { { 'name': 'minAmountOut', 'docs': [ - 'Minimum number of lamports to receive during swap' + 'Minimum number of lamports to receive during swap', ], 'type': 'u64' - } + }, ] } }, { 'name': 'Bumps', 'docs': [ - 'PDA bump seeds' + 'PDA bump seeds', ], 'type': { 'kind': 'struct', @@ -1203,14 +1203,14 @@ export type Ggoldca = { { 'name': 'lpTokenMint', 'type': 'u8' - } + }, ] } }, { 'name': 'PositionInfo', 'docs': [ - 'Position information' + 'Position information', ], 'type': { 'kind': 'struct', @@ -1218,24 +1218,24 @@ export type Ggoldca = { { 'name': 'pubkey', 'docs': [ - 'Position pubkey' + 'Position pubkey', ], 'type': 'publicKey' }, { 'name': 'lowerTick', 'docs': [ - 'Position lower tick' + 'Position lower tick', ], 'type': 'i32' }, { 'name': 'upperTick', 'docs': [ - 'Position upper tick' + 'Position upper tick', ], 'type': 'i32' - } + }, ] } }, @@ -1247,7 +1247,7 @@ export type Ggoldca = { { 'name': 'id', 'docs': [ - 'Id of market associated' + 'Id of market associated', ], 'type': { 'defined': 'MarketRewards' @@ -1256,24 +1256,24 @@ export type Ggoldca = { { 'name': 'rewardsMint', 'docs': [ - 'Pubkey of the rewards token mint' + 'Pubkey of the rewards token mint', ], 'type': 'publicKey' }, { 'name': 'destinationTokenAccount', 'docs': [ - 'Destination account' + 'Destination account', ], 'type': 'publicKey' }, { 'name': 'minAmountOut', 'docs': [ - 'Minimum number of lamports to receive during swap' + 'Minimum number of lamports to receive during swap', ], 'type': 'u64' - } + }, ] } }, @@ -1293,10 +1293,10 @@ export type Ggoldca = { }, { 'name': 'Whirlpool' - } + }, ] } - } + }, ], 'events': [ { @@ -1326,7 +1326,7 @@ export type Ggoldca = { 'name': 'treasuryFeeTokenB', 'type': 'u64', 'index': false - } + }, ] }, { @@ -1346,7 +1346,7 @@ export type Ggoldca = { 'name': 'treasuryFee', 'type': 'u64', 'index': false - } + }, ] }, { @@ -1371,7 +1371,7 @@ export type Ggoldca = { 'name': 'liquidity', 'type': 'u128', 'index': false - } + }, ] }, { @@ -1391,7 +1391,7 @@ export type Ggoldca = { 'name': 'newLiquidity', 'type': 'u128', 'index': false - } + }, ] }, { @@ -1421,7 +1421,7 @@ export type Ggoldca = { 'name': 'elapsedSlots', 'type': 'u64', 'index': false - } + }, ] }, { @@ -1451,9 +1451,9 @@ export type Ggoldca = { 'name': 'amountOut', 'type': 'u64', 'index': false - } + }, ] - } + }, ], 'errors': [ { @@ -1610,7 +1610,7 @@ export type Ggoldca = { 'code': 6030, 'name': 'WhirlpoolLiquidityToDeltasOverflow', 'msg': 'whirlpool_cpi: Overflow while computing liquidity to token deltas' - } + }, ] }; diff --git a/liquidator/src/liquidate.ts b/liquidator/src/liquidate.ts index 22b70197..41c6722d 100644 --- a/liquidator/src/liquidate.ts +++ b/liquidator/src/liquidate.ts @@ -75,7 +75,7 @@ async function runLiquidator() { } // select repay token that has the highest market value - let selectedBorrow: Borrow | undefined = sortBorrows(borrows)[0]; + const selectedBorrow: Borrow | undefined = sortBorrows(borrows)[0]; // select the withdrawal collateral token with the highest market value let selectedDeposit;