Skip to content

Commit

Permalink
fix: remove more sdk-gov parts
Browse files Browse the repository at this point in the history
  • Loading branch information
doomsower committed Oct 16, 2024
1 parent 93da24c commit 68b05ac
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"test": "vitest"
},
"dependencies": {
"@gearbox-protocol/sdk": "3.0.0-vfour.58",
"@gearbox-protocol/sdk": "3.0.0-vfour.61",
"node-pty": "^1.0.0",
"pino-pretty": "^11.2.2"
},
Expand Down
7 changes: 4 additions & 3 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MAX_INT } from "@gearbox-protocol/sdk-gov";
import { MAX_UINT16 } from "@gearbox-protocol/sdk";
import { Address } from "abitype/zod";
import { type Hex, isHex } from "viem";
import { z } from "zod";
Expand All @@ -15,7 +15,7 @@ const bigintLike = z.any().transform(v => BigInt(v));

export const ConfigSchema = z.object({
/**
* By default uses address provider from @gearbox-protocol/sdk-gov
* By default uses address provider from @gearbox-protocol/sdk
* Use this option to override address provider
*/
addressProviderOverride: Address.optional(),
Expand Down Expand Up @@ -64,8 +64,9 @@ export const ConfigSchema = z.object({
/**
* Filter out all accounts with HF >= threshold during scan stage
* 65535 is constant for zero-debt account (kind strang, because it's in the middle of the range of allowed values)
* TODO: this should be changed to uint256 in contracts
*/
hfThreshold: z.coerce.bigint().min(0n).max(MAX_INT).default(MAX_INT),
hfThreshold: z.coerce.bigint().min(0n).max(MAX_UINT16).default(MAX_UINT16),
/**
* Enable optimistic liquidations
*/
Expand Down
6 changes: 2 additions & 4 deletions src/services/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {
NetworkType,
} from "@gearbox-protocol/sdk";
import { PERCENTAGE_FACTOR } from "@gearbox-protocol/sdk";
import { tokenDataByNetwork } from "@gearbox-protocol/sdk-gov";
import { iCreditManagerV3Abi } from "@gearbox-protocol/types/abi";
import type { Address, Block } from "viem";
import { getContract } from "viem";
Expand Down Expand Up @@ -134,6 +133,7 @@ export class Scanner {

async #setupRestakingWorkaround(): Promise<void> {
this.#restakingCMAddr = RESTAKING_CMS[this.config.network];
const ezETH = this.caService.sdk.tokensMeta.mustFindBySymbol("ezETH");

if (this.#restakingCMAddr) {
const cm = getContract({
Expand All @@ -143,9 +143,7 @@ export class Scanner {
});
const [[, , liquidationDiscount], ezETHLT] = await Promise.all([
cm.read.fees(),
cm.read.liquidationThresholds([
tokenDataByNetwork[this.config.network].ezETH,
]),
cm.read.liquidationThresholds([ezETH.addr]),
]);

// For restaking accounts, say for simplicity account with only ezETH:
Expand Down
12 changes: 9 additions & 3 deletions src/services/liquidate/AAVELiquidatorContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ import {
AaveFLTaker_bytecode,
AaveLiquidator_bytecode,
} from "@gearbox-protocol/liquidator-v2-contracts/bytecode";
import { contractsByNetwork } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import type { Address } from "viem";

import type { ILogger } from "../../log/index.js";
import { Logger } from "../../log/index.js";
import PartialLiquidatorContract from "./PartialLiquidatorContract.js";

const AAVE_V3_LENDING_POOL: Record<NetworkType, Address> = {
Mainnet: "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
Arbitrum: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
Optimism: "0x794a61358D6845594F94dc1DB02A252b5b4814aD",
Base: "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5",
};

export default class AAVELiquidatorContract extends PartialLiquidatorContract {
@Logger("AAVEPartialLiquidator")
logger!: ILogger;
Expand All @@ -23,8 +30,7 @@ export default class AAVELiquidatorContract extends PartialLiquidatorContract {

public async deploy(): Promise<void> {
let address = this.config.aavePartialLiquidatorAddress;
const aavePool =
contractsByNetwork[this.config.network].AAVE_V3_LENDING_POOL;
const aavePool = AAVE_V3_LENDING_POOL[this.config.network];
if (!address) {
this.logger.debug(
{ aavePool, router: this.router, bot: this.bot },
Expand Down
5 changes: 2 additions & 3 deletions src/services/liquidate/GHOLiquidatorContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
GhoFMTaker_bytecode,
GhoLiquidator_bytecode,
} from "@gearbox-protocol/liquidator-v2-contracts/bytecode";
import { tokenDataByNetwork } from "@gearbox-protocol/sdk-gov";
import type { Address } from "viem";

import type { ILogger } from "../../log/index.js";
Expand Down Expand Up @@ -39,7 +38,7 @@ export default class GHOLiquidatorContract extends PartialLiquidatorContract {
// constructor(address _ghoFlashMinter, address _gho) {
args: [
this.ghoFlashMinter,
tokenDataByNetwork[this.config.network].GHO,
this.creditAccountService.sdk.tokensMeta.mustFindBySymbol("GHO").addr,
],
});
this.logger.debug(`waiting for GhoFMTaker to deploy, tx hash: ${hash}`);
Expand Down Expand Up @@ -69,7 +68,7 @@ export default class GHOLiquidatorContract extends PartialLiquidatorContract {
this.bot,
this.ghoFlashMinter,
ghoFMTakerAddr,
tokenDataByNetwork[this.config.network].GHO,
this.creditAccountService.sdk.tokensMeta.mustFindBySymbol("GHO").addr,
],
});
this.logger.debug(`waiting for liquidator to deploy, tx hash: ${hash}`);
Expand Down
4 changes: 2 additions & 2 deletions src/services/liquidate/SingularPartialLiquidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
createAnvilClient,
setLTs,
} from "@gearbox-protocol/sdk/dev";
import { tokenDataByNetwork } from "@gearbox-protocol/sdk-gov";
import type { Address, SimulateContractReturnType } from "viem";

import { exceptionsAbis } from "../../data/index.js";
Expand Down Expand Up @@ -42,7 +41,8 @@ export default class SingularPartialLiquidator extends SingularLiquidator<Partia

const aaveLiquidator = new AAVELiquidatorContract(router, bot);
const ghoLiquidator = new GHOLiquidatorContract(router, bot);
const GHO = tokenDataByNetwork[this.config.network].GHO.toLowerCase();
const GHO =
this.creditAccountService.sdk.tokensMeta.mustFindBySymbol("GHO").addr;

for (const cm of this.sdk.marketRegister.creditManagers) {
if (cm.underlying === GHO) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/swap/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NetworkType } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import { tokenDataByNetwork } from "@gearbox-protocol/sdk-gov";
import type { Address } from "viem";

Expand Down
2 changes: 1 addition & 1 deletion src/services/swap/noop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NetworkType } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import type { Address } from "viem";

import type { ISwapper } from "./types.js";
Expand Down
2 changes: 1 addition & 1 deletion src/services/swap/oneInch.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NetworkType } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import {
CHAINS,
formatBN,
Expand Down
2 changes: 1 addition & 1 deletion src/services/swap/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NetworkType } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import type { Address } from "viem";
/**
* Service that used to swap underlying back to ETH after liquidation
Expand Down
2 changes: 1 addition & 1 deletion src/services/swap/uniswap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NetworkType } from "@gearbox-protocol/sdk-gov";
import type { NetworkType } from "@gearbox-protocol/sdk";
import {
CHAINS,
decimals,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1602,10 +1602,10 @@
humanize-duration-ts "^2.1.1"
zod "^3.22.2"

"@gearbox-protocol/[email protected].58":
version "3.0.0-vfour.58"
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk/-/sdk-3.0.0-vfour.58.tgz#cddc31c0fca601ade1b182ec9b178e23f8c82644"
integrity sha512-eOIOE1zjtXpkPTWGd75C7DKotib05YSYgb9gYvXfEqkKHtVggp+JTQKuxrTOAyby0RYIr9PVhBKZT7KC5UKrtw==
"@gearbox-protocol/[email protected].61":
version "3.0.0-vfour.61"
resolved "https://registry.yarnpkg.com/@gearbox-protocol/sdk/-/sdk-3.0.0-vfour.61.tgz#95a9af6487cfa315ed2c5f82343075c33f290db4"
integrity sha512-tFdKbXG3IaInEJhMDHNB0UihyPEu/J2fPHLWAUt+hi/2j0RMpkO59a14R6xA9wpPpH3memr/3oaky8GelMjLkA==
dependencies:
"@gearbox-protocol/sdk-gov" "^2.22.0"
"@redstone-finance/evm-connector" "^0.6.2"
Expand Down

0 comments on commit 68b05ac

Please sign in to comment.