Skip to content

Commit

Permalink
fixed getSaverEstimateErrors() in query (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorian1te authored Dec 2, 2023
1 parent 62b8e3e commit 0dcc178
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
6 changes: 6 additions & 0 deletions packages/xchain-thorchain-amm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.8.5 (2023-11-28)

## Update

- bump thorchain-query dep

# v0.8.4 (2023-11-21)

## Update
Expand Down
6 changes: 3 additions & 3 deletions packages/xchain-thorchain-amm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xchainjs/xchain-thorchain-amm",
"version": "0.8.4",
"version": "0.8.5",
"description": "module that exposes estimating & swappping cryptocurrency assets on thorchain",
"keywords": [
"THORChain",
Expand Down Expand Up @@ -50,7 +50,7 @@
"@xchainjs/xchain-doge": "^0.7.7",
"@xchainjs/xchain-ethereum": "^0.31.1",
"@xchainjs/xchain-thornode": "^0.3.8",
"@xchainjs/xchain-thorchain-query": "^0.6.12",
"@xchainjs/xchain-thorchain-query": "^0.6.13",
"@xchainjs/xchain-evm": "^0.4.1",
"@xchainjs/xchain-litecoin": "^0.13.6",
"@xchainjs/xchain-mayachain": "^0.2.10",
Expand Down Expand Up @@ -86,7 +86,7 @@
"@xchainjs/xchain-doge": "^0.7.7",
"@xchainjs/xchain-ethereum": "^0.31.1",
"@xchainjs/xchain-thornode": "^0.3.8",
"@xchainjs/xchain-thorchain-query": "^0.6.12",
"@xchainjs/xchain-thorchain-query": "^0.6.13",
"@xchainjs/xchain-evm": "^0.4.1",
"@xchainjs/xchain-litecoin": "^0.13.6",
"@xchainjs/xchain-mayachain": "^0.2.10",
Expand Down
6 changes: 6 additions & 0 deletions packages/xchain-thorchain-query/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v0.6.13 (2023-11-28)

## Update

- getSaverEstimateErrors() inboundFee error check

# v0.6.12 (2023-11-21)

## Update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
toleranceBps: 300,
affiliateAddress: affiliateAddress,
affiliateBps: 300, //optional
fromAddress: btcAddress,
}

const estimate = await thorchainQuery.quoteSwap(swapParams)
Expand All @@ -90,7 +89,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
// toleranceBps: 200,
destinationAsset: BUSD,
destinationAddress: bnbAddress,
fromAddress: btcAddress,
}

const estimate = await thorchainQuery.quoteSwap(swapParams)
Expand Down Expand Up @@ -142,7 +140,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
//affiliate: affiliateAddress, //
//affiliateBps: 30, //optional
toleranceBps: 300, //optional
fromAddress: btcAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -161,7 +158,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
affiliateAddress: affiliateAddress,
affiliateBps: 30, //optional
//toleranceBps: 20, //optional\
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -179,8 +175,7 @@ describe('Thorchain-query estimate Integration Tests', () => {
destinationAddress: 'xxx',
// affiliate: affiliateAddress,
// affiliateBps: 30, //optional
toleranceBps: 20, //optional
fromAddress: runeAddress,
toleranceBps: 20, //optional,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -199,7 +194,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
// affiliate: affiliateAddress,
// affiliateBps: 30, //optional
toleranceBps: 20, //optional
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -212,7 +206,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
destinationAsset: AssetBTC,
destinationAddress: btcAddress,
toleranceBps: 200, //optional
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -225,7 +218,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount(1000, 8)), BUSD),
destinationAsset: AssetBTC,
destinationAddress: btcAddress,
fromAddress: bnbAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -238,7 +230,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount(0.01)), AssetRuneNative),
destinationAsset: AssetBTC,
destinationAddress: btcAddress,
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -253,7 +244,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount(1)), AssetBTC),
destinationAsset: AssetBTC,
destinationAddress: btcAddress,
fromAddress: btcAddress,
}

const estimate = await thorchainQuery.quoteSwap(swapParams)
Expand All @@ -267,7 +257,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount(0)), AssetBTC),
destinationAsset: AssetETH,
destinationAddress: ethAddress,
fromAddress: btcAddress,
}

const estimate = await thorchainQuery.quoteSwap(swapParams)
Expand All @@ -282,7 +271,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount('1', 18)), AssetAVAX),
destinationAsset: AssetRuneNative,
destinationAddress: runeAddress,
fromAddress: avaxAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -294,7 +282,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount('1000')), AssetRuneNative),
destinationAsset: AssetAVAX,
destinationAddress: avaxAddress,
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -306,7 +293,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
amount: new CryptoAmount(assetToBase(assetAmount('20')), AssetRuneNative),
destinationAsset: AssetBTC,
destinationAddress: btcAddress,
fromAddress: runeAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
expect(estimate.txEstimate.canSwap).toBe(false)
Expand All @@ -321,7 +307,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
streamingInterval: 10, // time between swaps
streamingQuantity: 10, // how many swaps in this stream
toleranceBps: 10000,
fromAddress: btcAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand All @@ -336,7 +321,6 @@ describe('Thorchain-query estimate Integration Tests', () => {
streamingInterval: 10, // time between swaps
streamingQuantity: 10, // how many swaps in this stream
toleranceBps: 10000,
fromAddress: ethAddress,
}
const estimate = await thorchainQuery.quoteSwap(swapParams)
printTx(estimate, swapParams.amount)
Expand Down
4 changes: 2 additions & 2 deletions packages/xchain-thorchain-query/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xchainjs/xchain-thorchain-query",
"version": "0.6.12",
"version": "0.6.13",
"license": "MIT",
"description": "Thorchain query module that is resposible for estimating swap calculations and add/remove liquidity for thorchain ",
"keywords": [
Expand Down Expand Up @@ -53,4 +53,4 @@
"publishConfig": {
"access": "public"
}
}
}
2 changes: 1 addition & 1 deletion packages/xchain-thorchain-query/src/thorchain-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ export class ThorchainQuery {
const pool = (await this.thorchainCache.getPoolForAsset(addAmount.asset)).thornodeDetails
if (pool.status.toLowerCase() !== 'available')
errors.push(`Pool is not available for this asset ${assetToString(addAmount.asset)}`)
const inboundFee = calcNetworkFee(addAmount.asset, inboundDetails[addAmount.asset.chain])
const inboundFee = new CryptoAmount(baseAmount(inboundDetails[addAmount.asset.chain].gasRate), addAmount.asset) // only needs to check against inbound fee, not network fee.
const inboundFeeInAddAmountAsset = await this.convert(inboundFee, addAmount.asset) // to make sure maths is being done on same assets
if (addAmount.lte(inboundFeeInAddAmountAsset)) errors.push(`Add amount does not cover fees`)
return errors
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2522,6 +2522,11 @@
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"

"@xchainjs/xchain-client@^0.14.1":
version "0.14.2"
resolved "https://registry.yarnpkg.com/@xchainjs/xchain-client/-/xchain-client-0.14.2.tgz#9047bcb83a940fdceff52cd53baeb2fdc8362237"
integrity sha512-uYnKLU5qcDixNizIGtyt7K4FYHkWCEq2PNKSv/8mApjIVjsYvt2TnzFCazj0kK0tOxhlFZUzELCHbvQpF+ugDg==

"@yarnpkg/lockfile@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"
Expand Down

0 comments on commit 0dcc178

Please sign in to comment.