Merge pull request 'fix: sellAllKrk uses amountOutMinimum: 0n with no throw on 0 output (#450)' (#474) from fix/issue-450 into master
This commit is contained in:
commit
b711860152
1 changed files with 3 additions and 4 deletions
|
|
@ -297,7 +297,7 @@ export async function sellKrk(
|
|||
* This is the "sovereign exit" path — it bypasses the UI swap widget and
|
||||
* sends transactions directly so the test is not gated on the sell-side UI.
|
||||
*
|
||||
* Logs a warning if the WETH balance does not increase after the swap, which
|
||||
* Throws if the WETH balance does not increase after the swap, which
|
||||
* indicates the pool returned 0 output (possible with amountOutMinimum: 0n on
|
||||
* a partially-drained pool).
|
||||
*
|
||||
|
|
@ -360,9 +360,8 @@ export async function sellAllKrk(page: Page, config: SellConfig): Promise<bigint
|
|||
const wethAfter = await erc20BalanceOf(config.rpcUrl, WETH, config.accountAddress);
|
||||
const wethReceived = wethAfter - wethBefore;
|
||||
if (wethReceived <= 0n) {
|
||||
console.warn('[swap] WARNING: WETH balance did not increase after sell — pool may have returned 0 output');
|
||||
} else {
|
||||
console.log(`[swap] Received ${wethReceived} WETH`);
|
||||
throw new Error('sellAllKrk: swap returned 0 WETH — pool may be drained or price impact exceeded balance');
|
||||
}
|
||||
console.log(`[swap] Received ${wethReceived} WETH`);
|
||||
return wethReceived;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue