Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paul/dex slippage #326

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- changed: Standardize DEX quotes to 5% slippage and estimate quote

## 2.4.3 (2024-06-03)

- added: (Exolix) Add Piratechain
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/lifi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const asInitOptions = asObject({
integrator: asOptional(asString, 'edgeapp')
})

/** Allow up to 20% slippage even for variable rate quotes */
const MAX_SLIPPAGE = '0.2'
/** Allow up to 5% slippage even for variable rate quotes */
const MAX_SLIPPAGE = '0.05'
const LIFI_SERVERS_DEFAULT = ['https://li.quest']
const EXPIRATION_MS = 1000 * 60
const EXCHANGE_INFO_UPDATE_FREQ_MS = 60000
Expand Down
7 changes: 5 additions & 2 deletions src/swap/defi/thorchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ const calcSwapFrom = async ({
total_swap_seconds: maxFulfillmentSeconds
} = bestQuote

const canBePartial = streamingSwapBlocks > 1
const canBePartial = !isEstimate || streamingSwapBlocks > 1

let toThorAmountWithSpread: string
if (canBePartial) {
log(`volatilitySpreadStreamingFinal: ${volatilitySpreadStreamingFinal}`)
Expand Down Expand Up @@ -984,7 +985,9 @@ const calcSwapTo = async ({
total_swap_seconds: maxFulfillmentSeconds
} = bestQuote

const canBePartial = streamingSwapBlocks > 1
// If we get a streaming quote, this should be considered a fully executing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: Add additional context

// transaction since we don't put a slippage limit
const canBePartial = !isEstimate || streamingSwapBlocks > 1

// Get the percent drop from the 'to' amount the user wanted compared to the
// 'to' amount returned by the API. Add that percent to the 'from' amount to
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/thorchainDa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ const asThorSwapQuoteResponse = asObject({
routes: asArray(asThorSwapRoute)
})

/** Max slippage for 20% for estimated quotes */
const DA_VOLATILITY_SPREAD_DEFAULT = 0.2
/** Max slippage for 5% for estimated quotes */
const DA_VOLATILITY_SPREAD_DEFAULT = 0.05
const THORSWAP_DEFAULT_SERVERS = ['https://api.thorswap.net/aggregator']

type ExchangeInfo = ReturnType<typeof asExchangeInfo>
Expand Down
2 changes: 1 addition & 1 deletion src/swap/defi/uni-v2-based/plugins/spookySwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function makeSpookySwapPlugin(
savedAction: {
actionType: 'swap',
swapInfo,
isEstimate: false,
isEstimate: true,
toAsset: {
pluginId: request.toWallet.currencyInfo.pluginId,
tokenId: request.toTokenId,
Expand Down
2 changes: 1 addition & 1 deletion src/swap/defi/uni-v2-based/plugins/tombSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export function makeTombSwapPlugin(
savedAction: {
actionType: 'swap',
swapInfo,
isEstimate: false,
isEstimate: true,
toAsset: {
pluginId: request.toWallet.currencyInfo.pluginId,
tokenId: request.toTokenId,
Expand Down
4 changes: 2 additions & 2 deletions src/swap/defi/uni-v2-based/plugins/velodrome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export function makeVelodromePlugin(
savedAction: {
actionType: 'swap',
swapInfo,
isEstimate: false,
isEstimate: true,
toAsset: {
pluginId: request.toWallet.currencyInfo.pluginId,
tokenId: request.toTokenId,
Expand Down Expand Up @@ -267,7 +267,7 @@ export function makeVelodromePlugin(
savedAction: {
actionType: 'swap',
swapInfo,
isEstimate: false,
isEstimate: true,
toAsset: {
pluginId: request.toWallet.currencyInfo.pluginId,
tokenId: request.toTokenId,
Expand Down
Loading