diff --git a/CHANGELOG.md b/CHANGELOG.md index a96e373a..81282317 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unreleased +- added: Add Maya Protocol - changed: Separate thorchain and thorchainda initOptions and exchangeInfo cleaner ## 2.8.0 (2024-09-12) diff --git a/src/index.ts b/src/index.ts index 3c3e7057..25767289 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,6 +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 { makeMayaProtocolPlugin } from './swap/defi/thorchain/mayaprotocol' import { makeThorchainPlugin } from './swap/defi/thorchain/thorchain' import { makeThorchainDaPlugin } from './swap/defi/thorchain/thorchainDa' import { makeSpookySwapPlugin } from './swap/defi/uni-v2-based/plugins/spookySwap' @@ -34,6 +35,7 @@ const plugins = { sideshift: makeSideshiftPlugin, spookySwap: makeSpookySwapPlugin, swapuz: makeSwapuzPlugin, + mayaprotocol: makeMayaProtocolPlugin, thorchain: makeThorchainPlugin, thorchainda: makeThorchainDaPlugin, tombSwap: makeTombSwapPlugin, diff --git a/src/swap/defi/thorchain/common.ts b/src/swap/defi/thorchain/common.ts index ba956831..980c1f98 100644 --- a/src/swap/defi/thorchain/common.ts +++ b/src/swap/defi/thorchain/common.ts @@ -92,6 +92,15 @@ export const PER_ASSET_SPREAD_DEFAULT: AssetSpread[] = [ destTokenId: undefined, destCurrencyCode: undefined }, + { + sourcePluginId: 'dash', + volatilitySpread: 0.01, + sourceTokenId: undefined, + sourceCurrencyCode: undefined, + destPluginId: undefined, + destTokenId: undefined, + destCurrencyCode: undefined + }, { sourcePluginId: 'dogecoin', volatilitySpread: 0.01, @@ -122,11 +131,13 @@ export const INVALID_CURRENCY_CODES: InvalidCurrencyCodes = { } export const EVM_CURRENCY_CODES: { [cc: string]: boolean } = { + ARB: true, AVAX: true, BCH: false, BNB: false, BSC: true, BTC: false, + DASH: false, DOGE: false, ETC: true, ETH: true, @@ -272,7 +283,7 @@ interface ThorchainOpts { THORNODE_SERVERS_DEFAULT: string[] orderUri: string swapInfo: EdgeSwapInfo - thornodesFetchOptions: Record + thornodesFetchOptions?: Record } export function makeThorchainBasedPlugin( @@ -291,7 +302,7 @@ export function makeThorchainBasedPlugin( THORNODE_SERVERS_DEFAULT, orderUri, swapInfo, - thornodesFetchOptions + thornodesFetchOptions = {} } = thorchainOpts const fetchSwapQuoteInner = async ( diff --git a/src/swap/defi/thorchain/mayaprotocol.ts b/src/swap/defi/thorchain/mayaprotocol.ts new file mode 100644 index 00000000..3653355b --- /dev/null +++ b/src/swap/defi/thorchain/mayaprotocol.ts @@ -0,0 +1,40 @@ +import { + EdgeCorePluginOptions, + EdgeSwapInfo, + EdgeSwapPlugin +} from 'edge-core-js/types' + +import { makeThorchainBasedPlugin } from './common' + +const swapInfo: EdgeSwapInfo = { + pluginId: 'mayaprotocol', + isDex: true, + displayName: 'Maya Protocol', + supportEmail: 'support@edge.app' +} +const orderUri = 'https://www.mayascan.org/tx/' + +const MIDGARD_SERVERS_DEFAULT = ['https://midgard.mayachain.info'] +const THORNODE_SERVERS_DEFAULT = ['https://mayanode.mayachain.info/mayachain'] + +// Network names that don't match parent network currency code +export const MAINNET_CODE_TRANSCRIPTION: { [cc: string]: string } = { + arbitrum: 'ARB', + bitcoin: 'BTC', + dash: 'DASH', + ethereum: 'ETH', + litecoin: 'LTC', + thorchainrune: 'THOR' +} + +export const makeMayaProtocolPlugin = ( + opts: EdgeCorePluginOptions +): EdgeSwapPlugin => { + return makeThorchainBasedPlugin(opts, { + MAINNET_CODE_TRANSCRIPTION, + MIDGARD_SERVERS_DEFAULT, + THORNODE_SERVERS_DEFAULT, + orderUri, + swapInfo + }) +}