From 913f936dab51f9dda202f3bf333ca724b3b4b7fb Mon Sep 17 00:00:00 2001 From: Jon Tzeng Date: Fri, 20 Sep 2024 14:27:21 -0700 Subject: [PATCH 1/2] Rename thorchainDa.ts -> swapKit.ts --- src/index.ts | 2 +- src/swap/defi/{thorchainDa.ts => swapKit.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/swap/defi/{thorchainDa.ts => swapKit.ts} (100%) diff --git a/src/index.ts b/src/index.ts index e9f97930..02b650e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,8 +13,8 @@ import { make0xGaslessPlugin } from './swap/defi/0x/0xGasless' import { makeCosmosIbcPlugin } from './swap/defi/cosmosIbc' import { makeLifiPlugin } from './swap/defi/lifi' import { makeRangoPlugin } from './swap/defi/rango' +import { makeThorchainDaPlugin } from './swap/defi/swapKit' import { makeThorchainPlugin } from './swap/defi/thorchain' -import { makeThorchainDaPlugin } from './swap/defi/thorchainDa' import { makeSpookySwapPlugin } from './swap/defi/uni-v2-based/plugins/spookySwap' import { makeTombSwapPlugin } from './swap/defi/uni-v2-based/plugins/tombSwap' import { makeVelodromePlugin } from './swap/defi/uni-v2-based/plugins/velodrome' diff --git a/src/swap/defi/thorchainDa.ts b/src/swap/defi/swapKit.ts similarity index 100% rename from src/swap/defi/thorchainDa.ts rename to src/swap/defi/swapKit.ts From ec3ed7d4b9ff5cb2b0b7fb8a8c6d3775984f2c7b Mon Sep 17 00:00:00 2001 From: Jon Tzeng Date: Fri, 20 Sep 2024 14:30:38 -0700 Subject: [PATCH 2/2] Rename pluginId thorchainda->swapkit Retain original thorchainda export for backwards compatibility --- CHANGELOG.md | 2 ++ src/index.ts | 6 ++++-- src/swap/defi/swapKit.ts | 28 +++++++++++----------------- test/createUserDump.ts | 1 + test/testpartner.ts | 1 + 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01fd6e05..3f9a504d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- changed: Changed 'thorchainda' pluginId to 'swapkit.' 'thorchainda' still exists for backwards compatibility + ## 2.8.0 (2024-09-12) - added: `minReceiveAmount` passed in `EdgeSwapQuotes` for lifi and rango diff --git a/src/index.ts b/src/index.ts index 02b650e6..bbc57a31 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,7 @@ import { make0xGaslessPlugin } from './swap/defi/0x/0xGasless' import { makeCosmosIbcPlugin } from './swap/defi/cosmosIbc' import { makeLifiPlugin } from './swap/defi/lifi' import { makeRangoPlugin } from './swap/defi/rango' -import { makeThorchainDaPlugin } from './swap/defi/swapKit' +import { makeSwapKitPlugin } from './swap/defi/swapKit' import { makeThorchainPlugin } from './swap/defi/thorchain' import { makeSpookySwapPlugin } from './swap/defi/uni-v2-based/plugins/spookySwap' import { makeTombSwapPlugin } from './swap/defi/uni-v2-based/plugins/tombSwap' @@ -33,9 +33,11 @@ const plugins = { rango: makeRangoPlugin, sideshift: makeSideshiftPlugin, spookySwap: makeSpookySwapPlugin, + swapkit: makeSwapKitPlugin, swapuz: makeSwapuzPlugin, thorchain: makeThorchainPlugin, - thorchainda: makeThorchainDaPlugin, + /** @deprecated - For backwards compatibility with swapkit */ + thorchainda: makeSwapKitPlugin, tombSwap: makeTombSwapPlugin, transfer: makeTransferPlugin, velodrome: makeVelodromePlugin, diff --git a/src/swap/defi/swapKit.ts b/src/swap/defi/swapKit.ts index b909456e..72183ea6 100644 --- a/src/swap/defi/swapKit.ts +++ b/src/swap/defi/swapKit.ts @@ -53,16 +53,16 @@ import { THORNODE_SERVERS_DEFAULT } from './thorchain' -const pluginId = 'thorchainda' +const pluginId = 'swapkit' const swapInfo: EdgeSwapInfo = { pluginId, isDex: true, - displayName: 'Thorchain DEX Aggregator', + displayName: 'Swap Kit', supportEmail: 'support@edge.app' } // This needs to be a type so adding the '& {}' prevents auto correction to an interface -type ThorSwapQuoteParams = { +type SwapKitSwapQuoteParams = { sellAsset: string buyAsset: string sellAmount: string @@ -78,7 +78,7 @@ const asCalldata = asObject({ memo: asOptional(asString) }) -const asThorSwapRoute = asObject({ +const asSwapKitSwapRoute = asObject({ contract: asEither(asString, asNull), contractMethod: asEither(asString, asNull), contractInfo: asOptional(asString), @@ -93,8 +93,8 @@ const asThorSwapRoute = asObject({ deadline: asOptional(asString) }) -const asThorSwapQuoteResponse = asObject({ - routes: asArray(asThorSwapRoute) +const asSwapKitSwapQuoteResponse = asObject({ + routes: asArray(asSwapKitSwapRoute) }) /** Max slippage for 5% for estimated quotes */ @@ -111,9 +111,7 @@ const tokenProxyMap: { [currencyPluginId: string]: string } = { avalanche: '0x69ba883af416ff5501d54d5e27a1f497fbd97156' } -export function makeThorchainDaPlugin( - opts: EdgeCorePluginOptions -): EdgeSwapPlugin { +export function makeSwapKitPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin { const { io, log } = opts const { fetchCors = io.fetch } = io const { @@ -225,7 +223,7 @@ export function makeThorchainDaPlugin( fromCurrencyCode ) - const quoteParams: ThorSwapQuoteParams = { + const quoteParams: SwapKitSwapQuoteParams = { sellAsset: `${fromMainnetCode}.${fromCurrencyCode}` + (fromTokenId != null ? `-0x${fromTokenId}` : ''), @@ -263,7 +261,7 @@ export function makeThorchainDaPlugin( if (!iaResponse.ok) { const responseText = await iaResponse.text() throw new Error( - `Thorchain could not fetch inbound_addresses: ${JSON.stringify( + `Swap Kit could not fetch inbound_addresses: ${JSON.stringify( responseText, null, 2 @@ -273,11 +271,7 @@ export function makeThorchainDaPlugin( if (!thorSwapResponse.ok) { const responseText = await thorSwapResponse.text() throw new Error( - `Thorchain could not get thorswap quote: ${JSON.stringify( - responseText, - null, - 2 - )}` + `Swap Kit could not get quote: ${JSON.stringify(responseText, null, 2)}` ) } @@ -285,7 +279,7 @@ export function makeThorchainDaPlugin( const inboundAddresses = asInboundAddresses(iaJson) const thorSwapJson = await thorSwapResponse.json() - const thorSwapQuote = asThorSwapQuoteResponse(thorSwapJson) + const thorSwapQuote = asSwapKitSwapQuoteResponse(thorSwapJson) // Check for supported chain and asset const inAddressObject = inboundAddresses.find( diff --git a/test/createUserDump.ts b/test/createUserDump.ts index 3a8f6fd1..68c4002c 100644 --- a/test/createUserDump.ts +++ b/test/createUserDump.ts @@ -42,6 +42,7 @@ async function main(): Promise { avalanche: true, piratechain: true, polygon: true, + swapkit: true, thorchainda: true } }) diff --git a/test/testpartner.ts b/test/testpartner.ts index dc8c66e4..f6bbc391 100644 --- a/test/testpartner.ts +++ b/test/testpartner.ts @@ -97,6 +97,7 @@ async function main(): Promise { polygon: config.POLYGON_INIT, piratechain: true, rango: config.RANGO_INIT, + swapkit: config.THORCHAIN_INIT, thorchain: config.THORCHAIN_INIT, thorchainda: config.THORCHAIN_INIT }