-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add any pair capability to refinance strategy (#153)
- Reintroduce the two swaps to refinance strategy - Simplify spotPrice method on SwapManager and SwapProviders. Gets one price only. Calculates a derived spot price when the quote token is a token and not a currency symbol. - Calculate the borrowAmount on the target protocol when a debtSwap is required. Accounts for slippage and summer fees when determining how much to borrow to repay flashloan - Account for summer fees when getting quotes on swap steps - Add getSummerFee method to SwapManager (currently resolves only to 20 basis pts - will update shortly) TODO: - Add config and implement getSummerFee appropriately.
- Loading branch information
Showing
42 changed files
with
753 additions
and
474 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,89 +0,0 @@ | ||
import { Address, ChainInfo, Percentage, Token, TokenAmount } from '@summerfi/sdk-common/common' | ||
import { ISwapManager } from '@summerfi/swap-common/interfaces' | ||
import { QuoteData, SwapData, SpotData } from '@summerfi/sdk-common/swap' | ||
|
||
export class SwapManagerMock implements ISwapManager { | ||
private _swapDataReturnValue: SwapData = {} as SwapData | ||
private _quoteDataReturnValue: QuoteData = {} as QuoteData | ||
private _spotDataReturnValue: SpotData = {} as SpotData | ||
|
||
private _lastGetSwapDataExactInputParams: | ||
| { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
recipient: Address | ||
slippage: Percentage | ||
} | ||
| undefined | ||
|
||
private _lastGetSwapQuoteExactInputParams: | ||
| { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
} | ||
| undefined | ||
|
||
setSwapData(swapData: SwapData): void { | ||
this._swapDataReturnValue = swapData | ||
} | ||
|
||
setQuoteData(quoteData: QuoteData): void { | ||
this._quoteDataReturnValue = quoteData | ||
} | ||
|
||
async getSwapDataExactInput(params: { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
recipient: Address | ||
slippage: Percentage | ||
}): Promise<SwapData> { | ||
this._lastGetSwapDataExactInputParams = params | ||
return this._swapDataReturnValue | ||
} | ||
|
||
async getSwapQuoteExactInput(params: { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
}): Promise<QuoteData> { | ||
this._lastGetSwapQuoteExactInputParams = params | ||
return this._quoteDataReturnValue | ||
} | ||
|
||
async getSpotPrices(params: { chainInfo: ChainInfo; tokens: Token[] }): Promise<SpotData> { | ||
return this._spotDataReturnValue | ||
} | ||
|
||
get swapDataReturnValue(): SwapData { | ||
return this._swapDataReturnValue | ||
} | ||
|
||
get quoteDataReturnValue(): QuoteData { | ||
return this._quoteDataReturnValue | ||
} | ||
|
||
get lastGetSwapDataExactInputParams(): | ||
| { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
recipient: Address | ||
slippage: Percentage | ||
} | ||
| undefined { | ||
return this._lastGetSwapDataExactInputParams | ||
} | ||
|
||
get lastGetSwapQuoteExactInputParams(): | ||
| { | ||
chainInfo: ChainInfo | ||
fromAmount: TokenAmount | ||
toToken: Token | ||
} | ||
| undefined { | ||
return this._lastGetSwapQuoteExactInputParams | ||
} | ||
} | ||
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.