Last active
September 11, 2023 22:00
-
-
Save chuckbergeron/494d3ecef4cf20ffdc79c3b07c19faa4 to your computer and use it in GitHub Desktop.
Revisions
-
chuckbergeron renamed this gist
Sep 11, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chuckbergeron revised this gist
Sep 11, 2023 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,7 +20,9 @@ const calculateAmountOut = async ( // of token in depending on the state of the gradual auction) for (let i = 1; i <= 100; i++) { const amountToSendPercent = i; const wantedAmountOut = amountOut .mul(ethers.BigNumber.from(amountToSendPercent)) .div(100); wantedAmountsOut.push(wantedAmountOut); } -
chuckbergeron revised this gist
Sep 11, 2023 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,10 +3,8 @@ const { originalMaxAmountOut, wantedAmountsOut } = await calculateAmountOut( context, ); // Calculates necessary input parameters for the swap call based on current state // of the contracts const calculateAmountOut = async ( liquidationPair: Contract, context: ArbLiquidatorContext, @@ -17,8 +15,9 @@ const calculateAmountOut = async ( const wantedAmountsOut = []; const amountOut = await liquidationPair.callStatic.maxAmountOut(); // Get multiple data points across the auction function to determine // the most amount of profitability (most amount out for least amount // of token in depending on the state of the gradual auction) for (let i = 1; i <= 100; i++) { const amountToSendPercent = i; const wantedAmountOut = amountOut.mul(ethers.BigNumber.from(amountToSendPercent)).div(100); -
chuckbergeron revised this gist
Sep 11, 2023 . 1 changed file with 32 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,33 @@ const { originalMaxAmountOut, wantedAmountsOut } = await calculateAmountOut( liquidationPairContract, context, ); /** * Calculates necessary input parameters for the swap call based on current state of the contracts * @returns {Promise} Promise object with the input parameters exactAmountIn and amountOutMin */ const calculateAmountOut = async ( liquidationPair: Contract, context: ArbLiquidatorContext, ): Promise<{ originalMaxAmountOut: BigNumber; wantedAmountsOut: BigNumber[]; }> => { const wantedAmountsOut = []; const amountOut = await liquidationPair.callStatic.maxAmountOut(); // Get multiple data points across the auction function to determine the most amount of profitability // (most amount out for least amount of token in, depends on the state of the gradual auction) for (let i = 1; i <= 100; i++) { const amountToSendPercent = i; const wantedAmountOut = amountOut.mul(ethers.BigNumber.from(amountToSendPercent)).div(100); wantedAmountsOut.push(wantedAmountOut); } return { originalMaxAmountOut: amountOut, wantedAmountsOut, }; }; -
chuckbergeron renamed this gist
Sep 11, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chuckbergeron renamed this gist
Sep 11, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
chuckbergeron created this gist
Sep 11, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ const { originalMaxAmountOut, wantedAmountsOut } = await calculateAmountOut( liquidationPairContract, context, ); if (originalMaxAmountOut.eq(0)) { stats.push({ pair, estimatedProfitUsd: 0, error: `amountOut is 0`, }); logNextPair(liquidationPair, liquidationPairContracts); continue; }