Skip to content

Commit

Permalink
fix: 1inch query
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Grimal committed Jan 9, 2025
1 parent 5d1e9db commit 2805028
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ export const check = async <
srcToken,
srcAmount,
market.params,
slippage,
slippage / 10n ** 16n,
repaidAssets,
client.account.address,
);

if (result) {
Expand Down
14 changes: 10 additions & 4 deletions packages/liquidation-sdk-viem/src/LiquidationEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -512,7 +516,8 @@ export class LiquidationEncoder<
src: firstToken!,
dst: marketParams.loanToken,
amount: halfAmount,
from: this.address,
from,
origin,
slippage,
includeTokensInfo: false,
includeProtocols: false,
Expand All @@ -528,7 +533,8 @@ export class LiquidationEncoder<
src: secondToken!,
dst: marketParams.loanToken,
amount: halfAmount,
from: this.address,
from,
origin,
slippage,
includeTokensInfo: false,
includeProtocols: false,
Expand Down
2 changes: 2 additions & 0 deletions packages/liquidation-sdk-viem/src/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ export const curvePools = {
"usd0usd0++": "0x1d08E7adC263CfC70b1BaBe6dC5Bb339c16Eec52",
usd0usdc: "0x14100f81e33C33Ecc7CDac70181Fb45B6E78569F",
} as const;

export const executorAddress = "0xfed6096f550864f8e1175f1e9dfa105ac911e5b4";
1 change: 1 addition & 0 deletions packages/liquidation-sdk-viem/src/swap/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface SwapParams {
dst: string;
amount: BigIntish;
from: string;
origin: string;
slippage: BigIntish;
protocols?: string;
fee?: BigIntish;
Expand Down

0 comments on commit 2805028

Please sign in to comment.