-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add HighValueLoss emitter event (#86)
* feat: add HighValueLoss emitter event * fix: export HighValueLossUpdate props * refactor: rename to RouteHighValueLoss * feat: only trigger emit on continue * refactor: remove unused emit + extract calc func * refactor: adjust emit message * refactor: move func to utils * refactor: optimize token value loss threshold calculation * refactor: optimize token value loss threshold calculation --------- Co-authored-by: Eugene Chybisov <18644653+chybisov@users.noreply.github.com> Co-authored-by: Eugene Chybisov <imchybisov@gmail.com>
- Loading branch information
1 parent
81c0773
commit 69d3918
Showing
6 changed files
with
67 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Route } from '@lifi/sdk'; | ||
|
||
export const calcValueLoss = (route: Route) => { | ||
return `${( | ||
(Number(route.toAmountUSD || 0) / | ||
(Number(route.fromAmountUSD || 0) + Number(route.gasCostUSD || 0)) - | ||
1) * | ||
100 | ||
).toFixed(2)}%`; | ||
}; |
This file contains 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 characters