Skip to content

Commit

Permalink
Enforce min slippage of 0.1% on bLUSD lp withdrawal to reduce transac…
Browse files Browse the repository at this point in the history
…tion failure
  • Loading branch information
edmulraney committed Mar 14, 2023
1 parent 1ec07b8 commit 5b3229e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1557,6 +1557,9 @@ yarn start-demo:dev-frontend

This spawns a modified version of dev-frontend that automatically signs transactions so you don't need to interact with a browser wallet. It directly uses the local forked RPC node.

You may need to wait a minute or so for your fork mainnet provider to load and cache all the blockchain state at your chosen block number. Refresh the page after 5 minutes.


#### Build dev-frontend for production

In a freshly cloned & installed monorepo, or if you have only modified code inside the dev-frontend package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ export const WithdrawPane: React.FC = () => {
setOutput(checkOutput(e.target.value));

const handleConfirmPressed = () => {
const curveSlippage = 0.001; // Allow mininum of %0.1% slippage due to Curve rounding issues
if (output === "both") {
const minBLusdAmount = withdrawal.get(BLusdAmmTokenIndex.BLUSD);
const minLusdAmount = withdrawal.get(BLusdAmmTokenIndex.LUSD);
const minBLusdAmount = withdrawal.get(BLusdAmmTokenIndex.BLUSD)?.mul(1 - curveSlippage);
const minLusdAmount = withdrawal.get(BLusdAmmTokenIndex.LUSD)?.mul(1 - curveSlippage);

if (minBLusdAmount === undefined || minBLusdAmount === Decimal.ZERO) return;
if (minLusdAmount === undefined || minLusdAmount === Decimal.ZERO) return;
Expand All @@ -89,7 +90,7 @@ export const WithdrawPane: React.FC = () => {
minLusdAmount
});
} else {
const minAmount = withdrawal.get(output);
const minAmount = withdrawal.get(output)?.mul(1 - curveSlippage);

if (minAmount === undefined || minAmount === Decimal.ZERO) return;

Expand All @@ -100,7 +101,7 @@ export const WithdrawPane: React.FC = () => {
minAmount
});
}
};
}

const handleBackPressed = () => {
dispatchEvent("BACK_PRESSED");
Expand Down Expand Up @@ -235,4 +236,4 @@ export const WithdrawPane: React.FC = () => {
</Flex>
</>
);
};
};;

0 comments on commit 5b3229e

Please sign in to comment.