Skip to content

Commit

Permalink
test: add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Grimal committed Jan 3, 2025
1 parent 9e0b45f commit f4ca0e5
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/liquidation-sdk-viem/examples/whitelistedMarkets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ export const check = async <

const encoder = new LiquidationEncoder(executorAddress, client);

console.log("seizedAssets", seizedAssets);
if (seizableCollateral.preLiquidation)
console.log("seizedAssets", seizedAssets);

let dstAmount = 0n;
// Handle Pendle Tokens
Expand Down Expand Up @@ -253,12 +254,15 @@ export const check = async <
repaidAssets,
);

console.log("result", result);
if (seizableCollateral.preLiquidation)
console.log("result", result);

if (result) {
dstAmount = result.dstAmount;
if (seizableCollateral.preLiquidation)
dstAmount = result.dstAmount;

console.log("dstAmount", dstAmount);
if (seizableCollateral.preLiquidation)
console.log("dstAmount", dstAmount);
} else {
return;
}
Expand Down Expand Up @@ -300,7 +304,8 @@ export const check = async <
maxUint256,
);

console.log("pre liquidation encoding");
if (seizableCollateral.preLiquidation)
console.log("pre liquidation encoding");

seizableCollateral.preLiquidation
? encoder.preLiquidationPreLiquidate(
Expand All @@ -319,7 +324,8 @@ export const check = async <
encoder.flush(),
);

console.log("pre liquidation encoded");
if (seizableCollateral.preLiquidation)
console.log("pre liquidation encoded");

const populatedTx = await encoder.encodeExec();
const [gasLimit, blockNumber, txCount, { maxFeePerGas }] =
Expand Down Expand Up @@ -354,7 +360,8 @@ export const check = async <
maxFeePerGas,
};

console.log("transaction", transaction);
if (seizableCollateral.preLiquidation)
console.log("transaction", transaction);

if (chainId === ChainId.EthMainnet) {
const signedBundle = await Flashbots.signBundle([
Expand All @@ -373,7 +380,8 @@ export const check = async <

return await sendTransaction(client, transaction);
} catch (error) {
console.log("error", error);
if (seizableCollateral.preLiquidation)
console.log("error", error);
console.warn(
`Tried liquidating "${seizedAssets}" collateral ("${withdrawnAssets}" underlying) from "${user}" on market "${market.id}":\n`,
error instanceof Error ? error.stack : error,
Expand Down

0 comments on commit f4ca0e5

Please sign in to comment.