Skip to content

Commit ecacc18

Browse files
authored
1121 update mayachain query to support arbitrum swaps 1 (#1122)
* update maya-query to serve arbitrum chain
1 parent 4dde59d commit ecacc18

File tree

4 files changed

+44
-2
lines changed

4 files changed

+44
-2
lines changed

.changeset/heavy-tables-marry.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@xchainjs/xchain-mayachain-query': patch
3+
---
4+
5+
Add chain ARB to getDustValues

packages/xchain-mayachain-query/__e2e__/mayachain-estimateSwap.e2e.test.ts

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
import { CryptoAmount, assetFromStringEx, assetToString, baseAmount } from '@xchainjs/xchain-util'
1+
import {
2+
CryptoAmount,
3+
assetAmount,
4+
assetFromStringEx,
5+
assetToBase,
6+
assetToString,
7+
baseAmount,
8+
} from '@xchainjs/xchain-util'
29

310
import { MayachainQuery } from '../src/mayachain-query'
411
import { QuoteSwap, QuoteSwapParams } from '../src/types'
5-
import { EthAsset } from '../src/utils'
12+
import { CacaoAsset, EthAsset } from '../src/utils'
613

714
const mayachainQuery = new MayachainQuery()
815

916
const AssetBTC = assetFromStringEx('BTC.BTC')
17+
const AssetArb = assetFromStringEx('ARB.ETH')
18+
19+
const ethAddress = '0xf155e9cdD77A5d77073aB43d17F661507C08E23d'
20+
const mayaAddress = 'maya1tqpyn3athvuj8dj7nu5fp0xm76ut86sjcg0dkv'
1021

1122
function printQuoteSwap(quoteSwap: QuoteSwap) {
1223
console.log({
@@ -59,4 +70,25 @@ describe('Estimate swap e2e tests', () => {
5970
const estimate = await mayachainQuery.quoteSwap(swapParams)
6071
printQuoteSwap(estimate)
6172
})
73+
74+
it('should estimate a swap of 1 ARB.ETH to Cacao', async () => {
75+
const swapParams: QuoteSwapParams = {
76+
fromAsset: AssetArb,
77+
amount: new CryptoAmount(assetToBase(assetAmount(1, 18)), AssetArb),
78+
destinationAsset: CacaoAsset,
79+
destinationAddress: mayaAddress,
80+
}
81+
const estimate = await mayachainQuery.quoteSwap(swapParams)
82+
printQuoteSwap(estimate)
83+
})
84+
it('should estimate a swap of 10 Cacao to Arb.eth', async () => {
85+
const swapParams: QuoteSwapParams = {
86+
fromAsset: CacaoAsset,
87+
amount: new CryptoAmount(assetToBase(assetAmount(10, 10)), CacaoAsset),
88+
destinationAsset: AssetArb,
89+
destinationAddress: ethAddress,
90+
}
91+
const estimate = await mayachainQuery.quoteSwap(swapParams)
92+
printQuoteSwap(estimate)
93+
})
6294
})

packages/xchain-mayachain-query/src/mayachain-query.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import {
1515
import { MayachainCache } from './mayachain-cache'
1616
import { InboundDetail, QuoteSwap, QuoteSwapParams, SwapHistoryParams, SwapsHistory } from './types'
1717
import {
18+
ArbAsset,
19+
ArbChain,
1820
BtcAsset,
1921
BtcChain,
2022
CacaoAsset,
@@ -170,6 +172,7 @@ export class MayachainQuery {
170172
[KujiraChain]: new CryptoAmount(baseAmount(0, 6), KujiraAsset),
171173
[ThorChain]: new CryptoAmount(baseAmount(0, 8), RuneAsset),
172174
[MayaChain]: new CryptoAmount(baseAmount(0, 10), CacaoAsset),
175+
[ArbChain]: new CryptoAmount(baseAmount(0, 18), ArbAsset),
173176
}
174177
}
175178

packages/xchain-mayachain-query/src/utils/const.ts

+2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ export const CacaoAsset = assetFromStringEx('MAYA.CACAO')
66
export const RuneAsset = assetFromStringEx('THOR.RUNE')
77
export const DashAsset = assetFromStringEx('DASH.DASH')
88
export const KujiraAsset = assetFromStringEx('KUJI.KUJI')
9+
export const ArbAsset = assetFromStringEx('ARB.ETH')
910

1011
export const BtcChain = 'BTC'
1112
export const EthChain = 'ETH'
1213
export const MayaChain = 'MAYA'
1314
export const ThorChain = 'THOR'
1415
export const DashChain = 'DASH'
1516
export const KujiraChain = 'KUJI'
17+
export const ArbChain = 'ARB'
1618

1719
export const DEFAULT_MAYACHAIN_DECIMALS = 8

0 commit comments

Comments
 (0)