From 34f8f0e20f93dacda4b256af309a8b18b1a5a891 Mon Sep 17 00:00:00 2001 From: hippocampus-web3 Date: Sun, 24 Sep 2023 10:23:10 +0200 Subject: [PATCH] Update examples --- examples/check-tx/check-tx.ts | 6 ++++-- examples/check-tx/package.json | 1 + examples/do-swap/doSend.ts | 6 ++++-- examples/do-swap/doStreamingSwap.ts | 13 ++++--------- examples/do-swap/doSwap.ts | 13 ++++--------- examples/do-swap/package.json | 1 + examples/estimate-swap/estimateSwap.ts | 5 +++-- examples/estimate-swap/listPools.ts | 2 +- examples/estimate-swap/package.json | 1 + examples/liquidity/add-liquidity.ts | 5 +++-- examples/liquidity/add-savers.ts | 6 ++++-- examples/liquidity/check-liquidity.ts | 6 ++++-- examples/liquidity/check-saver-position.ts | 13 ++++--------- examples/liquidity/estimate-add-liquidity.ts | 5 +++-- examples/liquidity/estimate-add-saver.ts | 5 +++-- examples/liquidity/estimate-remove-liquidity.ts | 5 +++-- examples/liquidity/estimate-withdraw-saver.ts | 6 +++--- examples/liquidity/package.json | 1 + examples/liquidity/withdraw-liquidity.ts | 12 ++++-------- examples/liquidity/withdrawSavers.ts | 6 ++++-- examples/loans/loanQuoteClosed.ts | 5 +++-- examples/loans/loanQuoteOpen.ts | 5 +++-- examples/loans/package.json | 1 + 23 files changed, 66 insertions(+), 63 deletions(-) diff --git a/examples/check-tx/check-tx.ts b/examples/check-tx/check-tx.ts index 15416ef7f..6bc66c65e 100644 --- a/examples/check-tx/check-tx.ts +++ b/examples/check-tx/check-tx.ts @@ -1,10 +1,12 @@ import { Network } from '@xchainjs/xchain-client' -import { Midgard, ThorchainCache, Thornode, TransactionStage } from '@xchainjs/xchain-thorchain-query' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' +import { ThorchainCache, Thornode, TransactionStage } from '@xchainjs/xchain-thorchain-query' //function printTx(inboundTxHash: string, source: string) {} export const checkTx = async (network: Network, inboundHash: string) => { - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const transactionStage = new TransactionStage(thorchainCache) const checkTransaction = await transactionStage.checkTxProgress(inboundHash) console.log(`\ Checking on ${network} :)\n`) diff --git a/examples/check-tx/package.json b/examples/check-tx/package.json index 749995aa1..af4580c84 100644 --- a/examples/check-tx/package.json +++ b/examples/check-tx/package.json @@ -10,6 +10,7 @@ "license": "MIT", "dependencies": { "@xchainjs/xchain-thorchain-query": "file:../../packages/xchain-thorchain-query", + "@xchainjs/xchain-midgard-query": "file:../../packages/xchain-midgard-query", "@xchainjs/xchain-client": "file:../../packages/xchain-client", "@xchainjs/xchain-midgard": "file:../../packages/xchain-midgard", "@xchainjs/xchain-thornode": "file:../../packages/xchain-thornode", diff --git a/examples/do-swap/doSend.ts b/examples/do-swap/doSend.ts index 74b4c3293..1d2c335ae 100644 --- a/examples/do-swap/doSend.ts +++ b/examples/do-swap/doSend.ts @@ -1,7 +1,8 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { THORChain } from '@xchainjs/xchain-thorchain' import { Wallet } from '@xchainjs/xchain-thorchain-amm' -import { Midgard, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' +import { ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' import { assetAmount, assetFromString, assetToBase } from '@xchainjs/xchain-util' /** @@ -28,7 +29,8 @@ const doSend = async (wallet: Wallet) => { const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const wallet = new Wallet(seed, thorchainQuery) console.log(`\ Send on ${network} :)\n`) diff --git a/examples/do-swap/doStreamingSwap.ts b/examples/do-swap/doStreamingSwap.ts index 46ff4fe23..90222be97 100644 --- a/examples/do-swap/doStreamingSwap.ts +++ b/examples/do-swap/doStreamingSwap.ts @@ -1,14 +1,8 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { THORChain } from '@xchainjs/xchain-thorchain' import { AmmEstimateSwapParams, ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' -import { - CryptoAmount, - Midgard, - ThorchainCache, - ThorchainQuery, - Thornode, - TxDetails, -} from '@xchainjs/xchain-thorchain-query' +import { CryptoAmount, ThorchainCache, ThorchainQuery, Thornode, TxDetails } from '@xchainjs/xchain-thorchain-query' import { assetAmount, assetFromString, assetToBase, assetToString, delay } from '@xchainjs/xchain-util' import { checkTx } from '../check-tx/check-tx' @@ -112,7 +106,8 @@ const doStreamingSwap = async (tcAmm: ThorchainAMM, wallet: Wallet, network: Net const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/do-swap/doSwap.ts b/examples/do-swap/doSwap.ts index b29746d76..fcc1a7be3 100644 --- a/examples/do-swap/doSwap.ts +++ b/examples/do-swap/doSwap.ts @@ -1,14 +1,8 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { THORChain } from '@xchainjs/xchain-thorchain' import { AmmEstimateSwapParams, ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' -import { - CryptoAmount, - Midgard, - ThorchainCache, - ThorchainQuery, - Thornode, - TxDetails, -} from '@xchainjs/xchain-thorchain-query' +import { CryptoAmount, ThorchainCache, ThorchainQuery, Thornode, TxDetails } from '@xchainjs/xchain-thorchain-query' import { assetAmount, assetFromString, assetToBase, assetToString, delay } from '@xchainjs/xchain-util' import { checkTx } from '../check-tx/check-tx' @@ -111,7 +105,8 @@ const doSingleSwap = async (tcAmm: ThorchainAMM, wallet: Wallet, network: Networ const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/do-swap/package.json b/examples/do-swap/package.json index 44dbc7633..e68c356d3 100644 --- a/examples/do-swap/package.json +++ b/examples/do-swap/package.json @@ -31,6 +31,7 @@ "@xchainjs/xchain-util": "file:../../packages/xchain-util", "@xchainjs/xchain-avax": "file:../../packages/xchain-avax", "@xchainjs/xchain-thorchain-query": "file:../../packages/xchain-thorchain-query", + "@xchainjs/xchain-midgard-query": "file:../../packages/xchain-midgard-query", "axios-retry": "^3.3.1", "bchaddrjs": "^0.5.2", "bech32-buffer": "^0.2.0", diff --git a/examples/estimate-swap/estimateSwap.ts b/examples/estimate-swap/estimateSwap.ts index 0b75dc75e..9ca29d92c 100644 --- a/examples/estimate-swap/estimateSwap.ts +++ b/examples/estimate-swap/estimateSwap.ts @@ -1,7 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { CryptoAmount, - Midgard, QuoteSwapParams, SwapEstimate, ThorchainCache, @@ -53,7 +53,8 @@ const estimateSwap = async () => { const toAsset = assetFromString(`${process.argv[6]}`) const toDestinationAddress = `${process.argv[7]}` const fromAddress = `${process.argv[8]}` - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) let swapParams: QuoteSwapParams diff --git a/examples/estimate-swap/listPools.ts b/examples/estimate-swap/listPools.ts index 482c7dac0..717f72e1e 100644 --- a/examples/estimate-swap/listPools.ts +++ b/examples/estimate-swap/listPools.ts @@ -1,5 +1,5 @@ import { Network } from '@xchainjs/xchain-client' -import { Midgard } from '@xchainjs/xchain-thorchain-query' +import { Midgard } from '@xchainjs/xchain-midgard-query' const main = async () => { const network = process.argv[2] as Network diff --git a/examples/estimate-swap/package.json b/examples/estimate-swap/package.json index 62fcb20d7..8df9e91e5 100644 --- a/examples/estimate-swap/package.json +++ b/examples/estimate-swap/package.json @@ -12,6 +12,7 @@ "license": "MIT", "dependencies": { "@xchainjs/xchain-thorchain-query": "file:../../packages/xchain-thorchain-query", + "@xchainjs/xchain-midgard-query": "file:../../packages/xchain-midgard-query", "@xchainjs/xchain-client": "file:../../packages/xchain-client", "@xchainjs/xchain-midgard": "file:../../packages/xchain-midgard", "@xchainjs/xchain-thornode": "file:../../packages/xchain-thornode", diff --git a/examples/liquidity/add-liquidity.ts b/examples/liquidity/add-liquidity.ts index d190bc32a..8cebb640b 100644 --- a/examples/liquidity/add-liquidity.ts +++ b/examples/liquidity/add-liquidity.ts @@ -1,10 +1,10 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { isAssetRuneNative } from '@xchainjs/xchain-thorchain' import { ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' import { AddliquidityPosition, CryptoAmount, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -41,7 +41,8 @@ const addLp = async (tcAmm: ThorchainAMM, wallet: Wallet) => { const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/liquidity/add-savers.ts b/examples/liquidity/add-savers.ts index 9b90a790b..1660c9919 100644 --- a/examples/liquidity/add-savers.ts +++ b/examples/liquidity/add-savers.ts @@ -1,6 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' -import { CryptoAmount, Midgard, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' +import { CryptoAmount, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' import { assetAmount, assetFromStringEx, assetToBase } from '@xchainjs/xchain-util' /** @@ -24,7 +25,8 @@ const addSavers = async (tcAmm: ThorchainAMM, wallet: Wallet) => { const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/liquidity/check-liquidity.ts b/examples/liquidity/check-liquidity.ts index bb06954d9..bc6600148 100644 --- a/examples/liquidity/check-liquidity.ts +++ b/examples/liquidity/check-liquidity.ts @@ -1,5 +1,6 @@ import { Network } from '@xchainjs/xchain-client' -import { LiquidityPosition, Midgard, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' +import { LiquidityPosition, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' import { assetFromString } from '@xchainjs/xchain-util' function print(estimate: LiquidityPosition, address: string) { @@ -24,7 +25,8 @@ function print(estimate: LiquidityPosition, address: string) { const checkLiquidityPosition = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) const asset = assetFromString(process.argv[3]) diff --git a/examples/liquidity/check-saver-position.ts b/examples/liquidity/check-saver-position.ts index 7bd5ae405..3e3c67a7b 100644 --- a/examples/liquidity/check-saver-position.ts +++ b/examples/liquidity/check-saver-position.ts @@ -1,12 +1,6 @@ import { Network } from '@xchainjs/xchain-client' -import { - Midgard, - SaversPosition, - ThorchainCache, - ThorchainQuery, - Thornode, - getSaver, -} from '@xchainjs/xchain-thorchain-query' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' +import { SaversPosition, ThorchainCache, ThorchainQuery, Thornode, getSaver } from '@xchainjs/xchain-thorchain-query' import { assetFromString } from '@xchainjs/xchain-util' function printSaversPosition(saver: SaversPosition) { @@ -26,7 +20,8 @@ function printSaversPosition(saver: SaversPosition) { const getSaverPosition = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) const getSaver: getSaver = { asset: assetFromString(process.argv[4]), diff --git a/examples/liquidity/estimate-add-liquidity.ts b/examples/liquidity/estimate-add-liquidity.ts index 874ed316b..02489fbe0 100644 --- a/examples/liquidity/estimate-add-liquidity.ts +++ b/examples/liquidity/estimate-add-liquidity.ts @@ -1,10 +1,10 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { isAssetRuneNative } from '@xchainjs/xchain-thorchain' import { AddliquidityPosition, CryptoAmount, EstimateAddLP, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -36,7 +36,8 @@ function print(estimate: EstimateAddLP, rune: CryptoAmount, asset: CryptoAmount) const estimateAddLp = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) // TODO check if synth? diff --git a/examples/liquidity/estimate-add-saver.ts b/examples/liquidity/estimate-add-saver.ts index 9eb3a26bc..527a9f71b 100644 --- a/examples/liquidity/estimate-add-saver.ts +++ b/examples/liquidity/estimate-add-saver.ts @@ -1,8 +1,8 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { CryptoAmount, EstimateAddSaver, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -37,7 +37,8 @@ function printSaver(saver: EstimateAddSaver) { const estimateAddSaver = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) const asset = new CryptoAmount( diff --git a/examples/liquidity/estimate-remove-liquidity.ts b/examples/liquidity/estimate-remove-liquidity.ts index 27144ea51..d9ee7d27c 100644 --- a/examples/liquidity/estimate-remove-liquidity.ts +++ b/examples/liquidity/estimate-remove-liquidity.ts @@ -1,7 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { EstimateWithdrawLP, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -35,7 +35,8 @@ function print(estimate: EstimateWithdrawLP, withdrawLpParams: WithdrawLiquidity const estimateWithdrawLp = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) const asset = assetFromString(process.argv[3]) diff --git a/examples/liquidity/estimate-withdraw-saver.ts b/examples/liquidity/estimate-withdraw-saver.ts index 84c137cd6..d83c94de1 100644 --- a/examples/liquidity/estimate-withdraw-saver.ts +++ b/examples/liquidity/estimate-withdraw-saver.ts @@ -1,7 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { EstimateWithdrawSaver, - Midgard, SaversWithdraw, ThorchainCache, ThorchainQuery, @@ -20,7 +20,6 @@ function printWithdrawSaver(saver: EstimateWithdrawSaver) { expiry: saver.expiry, toAddress: saver.toAddress, memo: saver.memo, - estimateWaitTime: saver.estimatedWaitTime, slipBasisPoints: saver.slipBasisPoints, } console.log(expanded) @@ -33,7 +32,8 @@ function printWithdrawSaver(saver: EstimateWithdrawSaver) { const estimateWithdrawSaver = async () => { try { const network = process.argv[2] as Network - const thorchainCacheMainnet = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet) const asset = assetFromStringEx(process.argv[4]) const withdrawPos: SaversWithdraw = { diff --git a/examples/liquidity/package.json b/examples/liquidity/package.json index 1c530ef93..889608be9 100644 --- a/examples/liquidity/package.json +++ b/examples/liquidity/package.json @@ -20,6 +20,7 @@ "dependencies": { "@xchainjs/xchain-thorchain-amm": "file:../../packages/xchain-thorchain-amm", "@xchainjs/xchain-thorchain-query": "file:../../packages/xchain-thorchain-query", + "@xchainjs/xchain-midgard-query": "file:../../packages/xchain-midgard-query", "@xchainjs/xchain-client": "file:../../packages/xchain-client", "@xchainjs/xchain-midgard": "file:../../packages/xchain-midgard", "@xchainjs/xchain-thornode": "file:../../packages/xchain-thornode", diff --git a/examples/liquidity/withdraw-liquidity.ts b/examples/liquidity/withdraw-liquidity.ts index e41457a1f..3d9c23ee6 100644 --- a/examples/liquidity/withdraw-liquidity.ts +++ b/examples/liquidity/withdraw-liquidity.ts @@ -1,12 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' -import { - Midgard, - ThorchainCache, - ThorchainQuery, - Thornode, - WithdrawLiquidityPosition, -} from '@xchainjs/xchain-thorchain-query' +import { ThorchainCache, ThorchainQuery, Thornode, WithdrawLiquidityPosition } from '@xchainjs/xchain-thorchain-query' import { assetFromString } from '@xchainjs/xchain-util' /** @@ -37,7 +32,8 @@ const withdrawLp = async (tcAmm: ThorchainAMM, wallet: Wallet) => { const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/liquidity/withdrawSavers.ts b/examples/liquidity/withdrawSavers.ts index f2cf0de5a..740f02ebd 100644 --- a/examples/liquidity/withdrawSavers.ts +++ b/examples/liquidity/withdrawSavers.ts @@ -1,6 +1,7 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { ThorchainAMM, Wallet } from '@xchainjs/xchain-thorchain-amm' -import { Midgard, SaversWithdraw, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' +import { SaversWithdraw, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query' import { assetFromString } from '@xchainjs/xchain-util' /** @@ -29,7 +30,8 @@ const withdrawSavers = async (tcAmm: ThorchainAMM, wallet: Wallet) => { const main = async () => { const seed = process.argv[2] const network = process.argv[3] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) const wallet = new Wallet(seed, thorchainQuery) diff --git a/examples/loans/loanQuoteClosed.ts b/examples/loans/loanQuoteClosed.ts index 6c8844c87..3ac81815f 100644 --- a/examples/loans/loanQuoteClosed.ts +++ b/examples/loans/loanQuoteClosed.ts @@ -1,9 +1,9 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm' import { CryptoAmount, LoanCloseParams, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -37,7 +37,8 @@ const getLoanQuoteClosed = async (tcAmm: ThorchainAMM) => { // Call the function from main() const main = async () => { const network = process.argv[2] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) await getLoanQuoteClosed(thorchainAmm) diff --git a/examples/loans/loanQuoteOpen.ts b/examples/loans/loanQuoteOpen.ts index e9fb42b3c..bbe87efab 100644 --- a/examples/loans/loanQuoteOpen.ts +++ b/examples/loans/loanQuoteOpen.ts @@ -1,9 +1,9 @@ import { Network } from '@xchainjs/xchain-client' +import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query' import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm' import { CryptoAmount, LoanOpenParams, - Midgard, ThorchainCache, ThorchainQuery, Thornode, @@ -37,7 +37,8 @@ const getLoanQuoteOpen = async (tcAmm: ThorchainAMM) => { // Call the function from main() const main = async () => { const network = process.argv[2] as Network - const thorchainCache = new ThorchainCache(new Midgard(network), new Thornode(network)) + const midgardCache = new MidgardCache(new Midgard(network)) + const thorchainCache = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache)) const thorchainQuery = new ThorchainQuery(thorchainCache) const thorchainAmm = new ThorchainAMM(thorchainQuery) await getLoanQuoteOpen(thorchainAmm) diff --git a/examples/loans/package.json b/examples/loans/package.json index e7df90d73..55b242cc4 100644 --- a/examples/loans/package.json +++ b/examples/loans/package.json @@ -12,6 +12,7 @@ "dependencies": { "@xchainjs/xchain-thorchain-amm": "file:../../packages/xchain-thorchain-amm", "@xchainjs/xchain-thorchain-query": "file:../../packages/xchain-thorchain-query", + "@xchainjs/xchain-midgard-query": "file:../../packages/xchain-midgard-query", "@xchainjs/xchain-client": "file:../../packages/xchain-client", "@xchainjs/xchain-midgard": "file:../../packages/xchain-midgard", "@xchainjs/xchain-thornode": "file:../../packages/xchain-thornode",