diff --git a/packages/liquidation-sdk-viem/examples/whitelisted-erc4626-1inch.ts b/packages/liquidation-sdk-viem/examples/whitelisted-erc4626-1inch.ts index 0df7405f..63bbdb88 100644 --- a/packages/liquidation-sdk-viem/examples/whitelisted-erc4626-1inch.ts +++ b/packages/liquidation-sdk-viem/examples/whitelisted-erc4626-1inch.ts @@ -253,8 +253,9 @@ export const check = async < srcToken, srcAmount, market.params, - slippage, + slippage / 10n ** 16n, repaidAssets, + client.account.address, ); if (result) { diff --git a/packages/liquidation-sdk-viem/src/LiquidationEncoder.ts b/packages/liquidation-sdk-viem/src/LiquidationEncoder.ts index a2de5079..cddc2d1c 100644 --- a/packages/liquidation-sdk-viem/src/LiquidationEncoder.ts +++ b/packages/liquidation-sdk-viem/src/LiquidationEncoder.ts @@ -15,7 +15,7 @@ import { import { readContract } from "viem/actions"; import { daiUsdsConverterAbi, mkrSkyConverterAbi } from "./abis.js"; import { curveStableSwapNGAbi, sUsdsAbi } from "./abis.js"; -import { curvePools, mainnetAddresses } from "./addresses.js"; +import { curvePools, executorAddress, mainnetAddresses } from "./addresses.js"; import { fetchBestSwap } from "./swap/index.js"; import { Pendle, Sky, Usual } from "./tokens/index.js"; @@ -462,20 +462,24 @@ export class LiquidationEncoder< marketParams: MarketParams, slippage: bigint, repaidAssets: bigint, + origin: Address, ) { let srcToken = initialSrcToken; const srcAmount = initialSrcAmount; const tries: SwapAttempt[] = []; let dstAmount = 0n; + const from = process.env.EXECUTOR_ADDRESS || executorAddress; + while (true) { const bestSwap = await fetchBestSwap({ chainId, src: srcToken, dst: marketParams.loanToken, amount: srcAmount, - from: this.address, + from, slippage, + origin, includeTokensInfo: false, includeProtocols: false, includeGas: false, @@ -512,7 +516,8 @@ export class LiquidationEncoder< src: firstToken!, dst: marketParams.loanToken, amount: halfAmount, - from: this.address, + from, + origin, slippage, includeTokensInfo: false, includeProtocols: false, @@ -528,7 +533,8 @@ export class LiquidationEncoder< src: secondToken!, dst: marketParams.loanToken, amount: halfAmount, - from: this.address, + from, + origin, slippage, includeTokensInfo: false, includeProtocols: false, diff --git a/packages/liquidation-sdk-viem/src/addresses.ts b/packages/liquidation-sdk-viem/src/addresses.ts index 83972cd8..8b7936bd 100644 --- a/packages/liquidation-sdk-viem/src/addresses.ts +++ b/packages/liquidation-sdk-viem/src/addresses.ts @@ -52,3 +52,5 @@ export const curvePools = { "usd0usd0++": "0x1d08E7adC263CfC70b1BaBe6dC5Bb339c16Eec52", usd0usdc: "0x14100f81e33C33Ecc7CDac70181Fb45B6E78569F", } as const; + +export const executorAddress = "0xfed6096f550864f8e1175f1e9dfa105ac911e5b4"; diff --git a/packages/liquidation-sdk-viem/src/swap/types.ts b/packages/liquidation-sdk-viem/src/swap/types.ts index d60f9326..207c555f 100644 --- a/packages/liquidation-sdk-viem/src/swap/types.ts +++ b/packages/liquidation-sdk-viem/src/swap/types.ts @@ -7,6 +7,7 @@ export interface SwapParams { dst: string; amount: BigIntish; from: string; + origin: string; slippage: BigIntish; protocols?: string; fee?: BigIntish;