Skip to content

Commit

Permalink
fix: remove slippage from swap quote calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
robercano committed Apr 30, 2024
1 parent 8429737 commit 626a57b
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 9 deletions.
1 change: 0 additions & 1 deletion sdk/sdk-server/src/handlers/getSwapQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ export const getSwapQuoteExactInput = publicProcedure
chainInfo: opts.input.chainInfo,
fromAmount: opts.input.fromAmount,
toToken: opts.input.toToken,
slippage: opts.input.slippage,
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export async function getSwapStepData(params: {
chainInfo: params.chainInfo,
fromAmount: amountAfterSummerFee,
toToken: params.toToken,
slippage: params.slippage,
}),
params.swapManager.getSpotPrice({
chainInfo: params.chainInfo,
Expand Down
1 change: 0 additions & 1 deletion sdk/swap-common/src/interfaces/ISwapManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export interface ISwapManager {
chainInfo: ChainInfo
fromAmount: TokenAmount
toToken: Token
slippage: Percentage
}): Promise<QuoteData>

/**
Expand Down
1 change: 0 additions & 1 deletion sdk/swap-common/src/interfaces/ISwapProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export interface ISwapProvider {
chainInfo: ChainInfo
fromAmount: TokenAmount
toToken: Token
slippage: Percentage
}): Promise<QuoteData>

/**
Expand Down
1 change: 0 additions & 1 deletion sdk/swap-service/src/implementation/SwapManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export class SwapManager implements ISwapManager {
chainInfo: ChainInfo
fromAmount: TokenAmount
toToken: Token
slippage: Percentage
forceUseProvider?: SwapProviderType
}): Promise<QuoteData> {
const provider: Maybe<ISwapProvider> = this._getBestProvider(params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export class OneInchSwapProvider implements ISwapProvider {
chainInfo: ChainInfo
fromAmount: TokenAmount
toToken: Token
slippage: Percentage
}): Promise<QuoteData> {
const swapUrl = this._formatOneInchQuoteUrl({
chainInfo: params.chainInfo,
Expand All @@ -133,15 +132,13 @@ export class OneInchSwapProvider implements ISwapProvider {

const responseData = (await response.json()) as OneInchQuoteResponse

const One = Percentage.createFrom({ value: 100 })

return {
provider: SwapProviderType.OneInch,
fromTokenAmount: params.fromAmount,
toTokenAmount: TokenAmount.createFromBaseUnit({
token: params.toToken,
amount: responseData.toTokenAmount,
}).multiply(One.subtract(params.slippage)),
}),
routes: this._extractSwapRoutes(responseData.protocols),
estimatedGas: responseData.estimatedGas,
}
Expand Down

0 comments on commit 626a57b

Please sign in to comment.