|
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' |
2 | 9 |
|
3 | 10 | import { MayachainQuery } from '../src/mayachain-query'
|
4 | 11 | import { QuoteSwap, QuoteSwapParams } from '../src/types'
|
5 |
| -import { EthAsset } from '../src/utils' |
| 12 | +import { CacaoAsset, EthAsset } from '../src/utils' |
6 | 13 |
|
7 | 14 | const mayachainQuery = new MayachainQuery()
|
8 | 15 |
|
9 | 16 | const AssetBTC = assetFromStringEx('BTC.BTC')
|
| 17 | +const AssetArb = assetFromStringEx('ARB.ETH') |
| 18 | + |
| 19 | +const ethAddress = '0xf155e9cdD77A5d77073aB43d17F661507C08E23d' |
| 20 | +const mayaAddress = 'maya1tqpyn3athvuj8dj7nu5fp0xm76ut86sjcg0dkv' |
10 | 21 |
|
11 | 22 | function printQuoteSwap(quoteSwap: QuoteSwap) {
|
12 | 23 | console.log({
|
@@ -59,4 +70,25 @@ describe('Estimate swap e2e tests', () => {
|
59 | 70 | const estimate = await mayachainQuery.quoteSwap(swapParams)
|
60 | 71 | printQuoteSwap(estimate)
|
61 | 72 | })
|
| 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 | + }) |
62 | 94 | })
|
0 commit comments