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 5fd37ac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 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: 11 additions & 3 deletions packages/liquidation-sdk-viem/src/LiquidationEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,20 +462,26 @@ 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 ||
"0xfed6096f550864f8e1175f1e9dfa105ac911e5b4";

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 +518,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 +535,8 @@ export class LiquidationEncoder<
src: secondToken!,
dst: marketParams.loanToken,
amount: halfAmount,
from: this.address,
from,
origin,
slippage,
includeTokensInfo: false,
includeProtocols: false,
Expand Down
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 5fd37ac

Please sign in to comment.