Skip to content

Commit

Permalink
Add Maya Protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
peachbits committed Sep 18, 2024
1 parent 279461a commit e6e40e5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- added: Add Maya Protocol
- changed: Separate thorchain and thorchainda initOptions and exchangeInfo cleaner

## 2.8.0 (2024-09-12)
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -34,6 +35,7 @@ const plugins = {
sideshift: makeSideshiftPlugin,
spookySwap: makeSpookySwapPlugin,
swapuz: makeSwapuzPlugin,
mayaprotocol: makeMayaProtocolPlugin,
thorchain: makeThorchainPlugin,
thorchainda: makeThorchainDaPlugin,
tombSwap: makeTombSwapPlugin,
Expand Down
15 changes: 13 additions & 2 deletions src/swap/defi/thorchain/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -272,7 +283,7 @@ interface ThorchainOpts {
THORNODE_SERVERS_DEFAULT: string[]
orderUri: string
swapInfo: EdgeSwapInfo
thornodesFetchOptions: Record<string, string>
thornodesFetchOptions?: Record<string, string>
}

export function makeThorchainBasedPlugin(
Expand All @@ -291,7 +302,7 @@ export function makeThorchainBasedPlugin(
THORNODE_SERVERS_DEFAULT,
orderUri,
swapInfo,
thornodesFetchOptions
thornodesFetchOptions = {}
} = thorchainOpts

const fetchSwapQuoteInner = async (
Expand Down
40 changes: 40 additions & 0 deletions src/swap/defi/thorchain/mayaprotocol.ts
Original file line number Diff line number Diff line change
@@ -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
})
}

0 comments on commit e6e40e5

Please sign in to comment.