Skip to content

Commit 496c2a9

Browse files
committed
Rename pluginId thorchainda->swapkit
Retain original thorchainda export for backwards compatibility
1 parent 913f936 commit 496c2a9

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- changed: Changed 'thorchainda' pluginId to 'swapkit.' 'thorchainda' still exists for backwards compatibility
6+
57
## 2.8.0 (2024-09-12)
68

79
- added: `minReceiveAmount` passed in `EdgeSwapQuotes` for lifi and rango

src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { make0xGaslessPlugin } from './swap/defi/0x/0xGasless'
1313
import { makeCosmosIbcPlugin } from './swap/defi/cosmosIbc'
1414
import { makeLifiPlugin } from './swap/defi/lifi'
1515
import { makeRangoPlugin } from './swap/defi/rango'
16-
import { makeThorchainDaPlugin } from './swap/defi/swapKit'
16+
import { makeSwapKitPlugin } from './swap/defi/swapKit'
1717
import { makeThorchainPlugin } from './swap/defi/thorchain'
1818
import { makeSpookySwapPlugin } from './swap/defi/uni-v2-based/plugins/spookySwap'
1919
import { makeTombSwapPlugin } from './swap/defi/uni-v2-based/plugins/tombSwap'
@@ -33,9 +33,11 @@ const plugins = {
3333
rango: makeRangoPlugin,
3434
sideshift: makeSideshiftPlugin,
3535
spookySwap: makeSpookySwapPlugin,
36+
swapkit: makeSwapKitPlugin,
3637
swapuz: makeSwapuzPlugin,
3738
thorchain: makeThorchainPlugin,
38-
thorchainda: makeThorchainDaPlugin,
39+
/** @deprecated - For backwards compatibility with swapkit */
40+
thorchainda: makeSwapKitPlugin,
3941
tombSwap: makeTombSwapPlugin,
4042
transfer: makeTransferPlugin,
4143
velodrome: makeVelodromePlugin,

src/swap/defi/swapKit.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ import {
5353
THORNODE_SERVERS_DEFAULT
5454
} from './thorchain'
5555

56-
const pluginId = 'thorchainda'
56+
const pluginId = 'swapkit'
5757
const swapInfo: EdgeSwapInfo = {
5858
pluginId,
5959
isDex: true,
60-
displayName: 'Thorchain DEX Aggregator',
60+
displayName: 'Swap Kit',
6161
supportEmail: 'support@edge.app'
6262
}
6363

6464
// This needs to be a type so adding the '& {}' prevents auto correction to an interface
65-
type ThorSwapQuoteParams = {
65+
type SwapKitSwapQuoteParams = {
6666
sellAsset: string
6767
buyAsset: string
6868
sellAmount: string
@@ -78,7 +78,7 @@ const asCalldata = asObject({
7878
memo: asOptional(asString)
7979
})
8080

81-
const asThorSwapRoute = asObject({
81+
const asSwapKitSwapRoute = asObject({
8282
contract: asEither(asString, asNull),
8383
contractMethod: asEither(asString, asNull),
8484
contractInfo: asOptional(asString),
@@ -93,8 +93,8 @@ const asThorSwapRoute = asObject({
9393
deadline: asOptional(asString)
9494
})
9595

96-
const asThorSwapQuoteResponse = asObject({
97-
routes: asArray(asThorSwapRoute)
96+
const asSwapKitSwapQuoteResponse = asObject({
97+
routes: asArray(asSwapKitSwapRoute)
9898
})
9999

100100
/** Max slippage for 5% for estimated quotes */
@@ -111,9 +111,7 @@ const tokenProxyMap: { [currencyPluginId: string]: string } = {
111111
avalanche: '0x69ba883af416ff5501d54d5e27a1f497fbd97156'
112112
}
113113

114-
export function makeThorchainDaPlugin(
115-
opts: EdgeCorePluginOptions
116-
): EdgeSwapPlugin {
114+
export function makeSwapKitPlugin(opts: EdgeCorePluginOptions): EdgeSwapPlugin {
117115
const { io, log } = opts
118116
const { fetchCors = io.fetch } = io
119117
const {
@@ -225,7 +223,7 @@ export function makeThorchainDaPlugin(
225223
fromCurrencyCode
226224
)
227225

228-
const quoteParams: ThorSwapQuoteParams = {
226+
const quoteParams: SwapKitSwapQuoteParams = {
229227
sellAsset:
230228
`${fromMainnetCode}.${fromCurrencyCode}` +
231229
(fromTokenId != null ? `-0x${fromTokenId}` : ''),
@@ -263,7 +261,7 @@ export function makeThorchainDaPlugin(
263261
if (!iaResponse.ok) {
264262
const responseText = await iaResponse.text()
265263
throw new Error(
266-
`Thorchain could not fetch inbound_addresses: ${JSON.stringify(
264+
`SwapKitchain could not fetch inbound_addresses: ${JSON.stringify(
267265
responseText,
268266
null,
269267
2
@@ -273,7 +271,7 @@ export function makeThorchainDaPlugin(
273271
if (!thorSwapResponse.ok) {
274272
const responseText = await thorSwapResponse.text()
275273
throw new Error(
276-
`Thorchain could not get thorswap quote: ${JSON.stringify(
274+
`SwapKitchain could not get thorswap quote: ${JSON.stringify(
277275
responseText,
278276
null,
279277
2
@@ -285,7 +283,7 @@ export function makeThorchainDaPlugin(
285283
const inboundAddresses = asInboundAddresses(iaJson)
286284

287285
const thorSwapJson = await thorSwapResponse.json()
288-
const thorSwapQuote = asThorSwapQuoteResponse(thorSwapJson)
286+
const thorSwapQuote = asSwapKitSwapQuoteResponse(thorSwapJson)
289287

290288
// Check for supported chain and asset
291289
const inAddressObject = inboundAddresses.find(
@@ -360,7 +358,7 @@ export function makeThorchainDaPlugin(
360358
throw new Error(
361359
`Missing sourceTokenContractAddress for ${fromMainnetCode}`
362360
)
363-
// Need to use ethers.js to craft a proper tx that calls Thorchain contract, then extract the data payload
361+
// Need to use ethers.js to craft a proper tx that calls SwapKitchain contract, then extract the data payload
364362
// Token transactions send no ETH (or other EVM mainnet coin)
365363
if (tcDirect) {
366364
memo = await getEvmTokenData({

test/createUserDump.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ async function main(): Promise<void> {
4242
avalanche: true,
4343
piratechain: true,
4444
polygon: true,
45+
swapkit: true,
4546
thorchainda: true
4647
}
4748
})

test/testpartner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ async function main(): Promise<void> {
9797
polygon: config.POLYGON_INIT,
9898
piratechain: true,
9999
rango: config.RANGO_INIT,
100+
swapkit: config.THORCHAIN_INIT,
100101
thorchain: config.THORCHAIN_INIT,
101102
thorchainda: config.THORCHAIN_INIT
102103
}

0 commit comments

Comments
 (0)