Skip to content

Commit

Permalink
Rename pluginId thorchainda->swapkit
Browse files Browse the repository at this point in the history
Retain original thorchainda export for backwards compatibility
  • Loading branch information
Jon-edge committed Sep 20, 2024
1 parent 913f936 commit ec3ed7d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
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: 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
Expand Down
6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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,
Expand Down
28 changes: 11 additions & 17 deletions src/swap/defi/swapKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand All @@ -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 */
Expand All @@ -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 {
Expand Down Expand Up @@ -225,7 +223,7 @@ export function makeThorchainDaPlugin(
fromCurrencyCode
)

const quoteParams: ThorSwapQuoteParams = {
const quoteParams: SwapKitSwapQuoteParams = {
sellAsset:
`${fromMainnetCode}.${fromCurrencyCode}` +
(fromTokenId != null ? `-0x${fromTokenId}` : ''),
Expand Down Expand Up @@ -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
Expand All @@ -273,19 +271,15 @@ 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)}`
)
}

const iaJson = await iaResponse.json()
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(
Expand Down
1 change: 1 addition & 0 deletions test/createUserDump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ async function main(): Promise<void> {
avalanche: true,
piratechain: true,
polygon: true,
swapkit: true,
thorchainda: true
}
})
Expand Down
1 change: 1 addition & 0 deletions test/testpartner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ async function main(): Promise<void> {
polygon: config.POLYGON_INIT,
piratechain: true,
rango: config.RANGO_INIT,
swapkit: config.THORCHAIN_INIT,
thorchain: config.THORCHAIN_INIT,
thorchainda: config.THORCHAIN_INIT
}
Expand Down

0 comments on commit ec3ed7d

Please sign in to comment.