Skip to content

Commit

Permalink
1201 Asset type protocol refactor (#1203)
Browse files Browse the repository at this point in the history
* Wallet reafactored with new Asset type

* MAYA protocol with new Asset type and CryptoAmount class

* Thorchain protocol with new Asset type and CryptoAmount class

* Aggregator with new Asset type and CryptoAmount class

* Missing changes

* Clean Cryptoamount

* 1205 aggregator affiliates (#1206)

* Affiliate bug fix in doSwap

* Changeset version file

* Version Packages (#1210)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* 1207 Estimate MAYAName (#1211)

* getMAYANameDetails response standardise with Thorchain

* Estimate MAYAName

* Tests

* Changeset version file

* 1196 Mayachain AMM docs (#1197)

* Get MAYANames by address

* Changeset version file

* MAYAChainAMM docs

* Readme links

* Dependencies removed

* Changeset version files removed

* 1212 Register and Update Thorname and MAYAName (#1214)

* getMAYANameDetails response standardise with Thorchain

* Estimate MAYAName

* Tests

* Changeset version file

* MAYAName feature

* Tests

* Register and Update THORName

* Error bug fix

* Tests

* Changeset version files

* Version Packages (#1215)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* 1208 Update THORChain client apis (#1216)

* Thornode v1.133.0

* Midgard v2.32.2

* Changeset version files

* Action TxType parameter

* Tests

* Changeset version file

* 1208 Update MAYAChain client apis (#1217)

* MAYANode v1.110.0

* Streaming swap parameters for quote swap

* MAYAChainAMM tests

* Midgard v2.10.0

* Changeset version files

* Version Packages (#1220)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* 1223 MAYAChain streaming swaps (#1222)

* Streaming and missing parameters for QuoteSwap type

* Tests

* Changeset version files

* e2e tests

* Changeset version files

* 1201 Examples and tests with new Asset type and CryptoAmount refactor (#1204)

* Examples and tests with new Asset type and CryptoAmount refactor

* Example bug fix

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 30, 2024
1 parent eb229aa commit 602ebcb
Show file tree
Hide file tree
Showing 171 changed files with 5,863 additions and 1,486 deletions.
5 changes: 5 additions & 0 deletions .changeset/large-hounds-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xchainjs/xchain-wallet': major
---

New type `CosmosTxParams` for Cosmos transfers.
5 changes: 5 additions & 0 deletions .changeset/seven-ducks-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xchainjs/xchain-mayachain-amm': patch
---

Streaming swap parameters for `estimateSwap`, `validateSwap` and `doSwap` method.
5 changes: 5 additions & 0 deletions .changeset/shy-penguins-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xchainjs/xchain-mayachain-query': patch
---

`QuoteSwap` type updated. `Fees` type with `liquidityFee` and `totalFee` parameters.
10 changes: 10 additions & 0 deletions .changeset/stupid-teachers-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@xchainjs/xchain-mayachain-query': major
'@xchainjs/xchain-thorchain-query': major
'@xchainjs/xchain-mayachain-amm': major
'@xchainjs/xchain-midgard-query': major
'@xchainjs/xchain-thorchain-amm': major
'@xchainjs/xchain-aggregator': major
---

Methods and types updated with `Asset` type refactored.
5 changes: 5 additions & 0 deletions .changeset/tame-pumpkins-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@xchainjs/xchain-mayachain-query': patch
---

Streaming swap parameters for `quoteSwap` method.
19 changes: 19 additions & 0 deletions examples/check-tx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# xchainjs-check-tx

## 1.0.10

### Patch Changes

- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- @xchainjs/xchain-midgard@0.5.8
- @xchainjs/xchain-thornode@0.3.17
- @xchainjs/xchain-midgard-query@0.1.20
- @xchainjs/xchain-thorchain-query@0.7.17

## 1.0.9

### Patch Changes

- Updated dependencies [7df3870]
- @xchainjs/xchain-thorchain-query@0.7.16

## 1.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/check-tx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xchainjs-check-tx",
"private": true,
"version": "1.0.8",
"version": "1.0.10",
"scripts": {
"checktx": "npx ts-node check-tx.ts",
"build": "tsc --noEmit"
Expand Down
39 changes: 0 additions & 39 deletions examples/do-maya-swap/README.md

This file was deleted.

25 changes: 25 additions & 0 deletions examples/do-swap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# xchainjs-do-swap

## 1.0.19

### Patch Changes

- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- @xchainjs/xchain-midgard@0.5.8
- @xchainjs/xchain-thornode@0.3.17
- @xchainjs/xchain-midgard-query@0.1.20
- @xchainjs/xchain-thorchain-query@0.7.17
- @xchainjs/xchain-thorchain-amm@1.1.18

## 1.0.18

### Patch Changes

- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- @xchainjs/xchain-thorchain-amm@1.1.17
- @xchainjs/xchain-thorchain-query@0.7.16

## 1.0.17

### Patch Changes
Expand Down
3 changes: 2 additions & 1 deletion examples/do-swap/doStreamingSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
assetToBase,
assetToString,
delay,
isSynthAsset,
register9Rheader,
} from '@xchainjs/xchain-util'
import { Wallet } from '@xchainjs/xchain-wallet'
Expand Down Expand Up @@ -80,7 +81,7 @@ const doStreamingSwap = async (tcAmm: ThorchainAMM, wallet: Wallet) => {
const streamingInterval = Number(process.argv[8])
const streamingQuantity = Number(process.argv[9])

const toChain = toAsset.synth ? THORChain : toAsset.chain
const toChain = isSynthAsset(toAsset) ? THORChain : toAsset.chain

const swapParams: QuoteSwapParams = {
fromAddress: await wallet.getAddress(fromAsset.chain),
Expand Down
3 changes: 2 additions & 1 deletion examples/do-swap/doSwap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
assetToBase,
assetToString,
delay,
isSynthAsset,
register9Rheader,
} from '@xchainjs/xchain-util'
import { Wallet } from '@xchainjs/xchain-wallet'
Expand Down Expand Up @@ -81,7 +82,7 @@ const doSingleSwap = async (tcAmm: ThorchainAMM, wallet: Wallet) => {
const fromAsset = assetFromString(`${process.argv[6]}`)
const toAsset = assetFromString(`${process.argv[7]}`)

const toChain = toAsset.synth ? THORChain : toAsset.chain
const toChain = isSynthAsset(toAsset) ? THORChain : toAsset.chain

const swapParams: QuoteSwapParams = {
fromAsset,
Expand Down
2 changes: 1 addition & 1 deletion examples/do-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xchainjs-do-swap",
"private": true,
"version": "1.0.17",
"version": "1.0.19",
"scripts": {
"doSwap": "npx ts-node doSwap.ts",
"doStreamingSwap": "npx ts-node doStreamingSwap.ts",
Expand Down
19 changes: 19 additions & 0 deletions examples/estimate-swap/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# xchainjs-estimate-swap

## 1.0.10

### Patch Changes

- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- @xchainjs/xchain-midgard@0.5.8
- @xchainjs/xchain-thornode@0.3.17
- @xchainjs/xchain-midgard-query@0.1.20
- @xchainjs/xchain-thorchain-query@0.7.17

## 1.0.9

### Patch Changes

- Updated dependencies [7df3870]
- @xchainjs/xchain-thorchain-query@0.7.16

## 1.0.8

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/estimate-swap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xchainjs-estimate-swap",
"private": true,
"version": "1.0.8",
"version": "1.0.10",
"scripts": {
"listPools": "npx ts-node listPools.ts",
"estimateSwap": "npx ts-node estimateSwap.ts",
Expand Down
25 changes: 25 additions & 0 deletions examples/liquidity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# xchainjs-liquidity

## 1.0.19

### Patch Changes

- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- Updated dependencies [7d70a1c]
- @xchainjs/xchain-midgard@0.5.8
- @xchainjs/xchain-thornode@0.3.17
- @xchainjs/xchain-midgard-query@0.1.20
- @xchainjs/xchain-thorchain-query@0.7.17
- @xchainjs/xchain-thorchain-amm@1.1.18

## 1.0.18

### Patch Changes

- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- Updated dependencies [7df3870]
- @xchainjs/xchain-thorchain-amm@1.1.17
- @xchainjs/xchain-thorchain-query@0.7.16

## 1.0.17

### Patch Changes
Expand Down
18 changes: 15 additions & 3 deletions examples/liquidity/add-liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ import {
} from '@xchainjs/xchain-thorchain'
import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm'
import { AddliquidityPosition, ThorchainQuery } from '@xchainjs/xchain-thorchain-query'
import { CryptoAmount, assetAmount, assetFromStringEx, assetToBase, register9Rheader } from '@xchainjs/xchain-util'
import {
Asset,
AssetCryptoAmount,
CryptoAmount,
TokenAsset,
assetAmount,
assetFromStringEx,
assetToBase,
register9Rheader,
} from '@xchainjs/xchain-util'
import { Wallet } from '@xchainjs/xchain-wallet'
import axios from 'axios'

Expand All @@ -29,13 +38,16 @@ register9Rheader(axios)
*/
const addLp = async (tcAmm: ThorchainAMM) => {
try {
const rune = new CryptoAmount(assetToBase(assetAmount(process.argv[4])), assetFromStringEx(process.argv[5]))
const rune = new AssetCryptoAmount(
assetToBase(assetAmount(process.argv[4])),
assetFromStringEx(process.argv[5]) as Asset,
)
if (!isAssetRuneNative(rune.asset)) {
throw Error('THOR.RUNE must be the first argument')
}
const asset = new CryptoAmount(
assetToBase(assetAmount(process.argv[6], Number(process.argv[7]))),
assetFromStringEx(process.argv[8]),
assetFromStringEx(process.argv[8]) as Asset | TokenAsset,
)

const addLpParams: AddliquidityPosition = {
Expand Down
12 changes: 10 additions & 2 deletions examples/liquidity/add-savers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import { Client as LtcClient, defaultLtcParams } from '@xchainjs/xchain-litecoin
import { Client as ThorClient, defaultClientConfig as defaultThorParams } from '@xchainjs/xchain-thorchain'
import { ThorchainAMM } from '@xchainjs/xchain-thorchain-amm'
import { ThorchainQuery } from '@xchainjs/xchain-thorchain-query'
import { CryptoAmount, assetAmount, assetFromStringEx, assetToBase, register9Rheader } from '@xchainjs/xchain-util'
import {
Asset,
CryptoAmount,
TokenAsset,
assetAmount,
assetFromStringEx,
assetToBase,
register9Rheader,
} from '@xchainjs/xchain-util'
import { Wallet } from '@xchainjs/xchain-wallet'
import axios from 'axios'

Expand All @@ -25,7 +33,7 @@ const addSavers = async (tcAmm: ThorchainAMM) => {
try {
const asset = new CryptoAmount(
assetToBase(assetAmount(process.argv[4], Number(process.argv[5]))),
assetFromStringEx(process.argv[6]),
assetFromStringEx(process.argv[6]) as Asset | TokenAsset,
)
const addlptx = await tcAmm.addSaver(asset)
console.log(addlptx)
Expand Down
4 changes: 2 additions & 2 deletions examples/liquidity/check-liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cosmosclient from '@cosmos-client/core'
import { Network } from '@xchainjs/xchain-client'
import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query'
import { LiquidityPosition, ThorchainCache, ThorchainQuery, Thornode } from '@xchainjs/xchain-thorchain-query'
import { assetFromString, register9Rheader } from '@xchainjs/xchain-util'
import { Asset, TokenAsset, assetFromString, register9Rheader } from '@xchainjs/xchain-util'
import axios from 'axios'

register9Rheader(axios)
Expand Down Expand Up @@ -35,7 +35,7 @@ const checkLiquidityPosition = async () => {
const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache))
const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet)

const asset = assetFromString(process.argv[3])
const asset = assetFromString(process.argv[3]) as Asset | TokenAsset
const address = process.argv[4] || ''

const lp = await thorchainQueryMainnet.checkLiquidityPosition(asset, address)
Expand Down
4 changes: 2 additions & 2 deletions examples/liquidity/check-saver-position.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Network } from '@xchainjs/xchain-client'
import { Midgard, MidgardCache, MidgardQuery } from '@xchainjs/xchain-midgard-query'
import { SaversPosition, ThorchainCache, ThorchainQuery, Thornode, getSaver } from '@xchainjs/xchain-thorchain-query'
import { assetFromString, register9Rheader } from '@xchainjs/xchain-util'
import { Asset, TokenAsset, assetFromString, register9Rheader } from '@xchainjs/xchain-util'
import axios from 'axios'

register9Rheader(axios)
Expand All @@ -27,7 +27,7 @@ const getSaverPosition = async () => {
const thorchainCacheMainnet = new ThorchainCache(new Thornode(network), new MidgardQuery(midgardCache))
const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet)
const getSaver: getSaver = {
asset: assetFromString(process.argv[4]),
asset: assetFromString(process.argv[4]) as Asset | TokenAsset,
address: process.argv[3] || '',
}

Expand Down
20 changes: 16 additions & 4 deletions examples/liquidity/estimate-add-liquidity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ import {
ThorchainQuery,
Thornode,
} from '@xchainjs/xchain-thorchain-query'
import { CryptoAmount, assetAmount, assetFromStringEx, assetToBase, register9Rheader } from '@xchainjs/xchain-util'
import {
Asset,
AssetCryptoAmount,
CryptoAmount,
TokenAsset,
assetAmount,
assetFromStringEx,
assetToBase,
register9Rheader,
} from '@xchainjs/xchain-util'
import axios from 'axios'

register9Rheader(axios)

function print(estimate: EstimateAddLP, rune: CryptoAmount, asset: CryptoAmount) {
function print(estimate: EstimateAddLP, rune: AssetCryptoAmount, asset: CryptoAmount<Asset | TokenAsset>) {
const expanded = {
rune: rune.formatedAssetString(),
asset: asset.formatedAssetString(),
Expand Down Expand Up @@ -43,13 +52,16 @@ const estimateAddLp = async () => {
const thorchainQueryMainnet = new ThorchainQuery(thorchainCacheMainnet)

// TODO check if synth?
const rune = new CryptoAmount(assetToBase(assetAmount(process.argv[3])), assetFromStringEx(process.argv[4]))
const rune = new AssetCryptoAmount(
assetToBase(assetAmount(process.argv[3])),
assetFromStringEx(process.argv[4]) as Asset,
)
if (!isAssetRuneNative(rune.asset)) {
throw Error('THOR.RUNE must be the first argument')
}
const asset = new CryptoAmount(
assetToBase(assetAmount(process.argv[5], Number(process.argv[6]))),
assetFromStringEx(process.argv[7]),
assetFromStringEx(process.argv[7]) as Asset | TokenAsset,
)
// const rune =
const addLpParams: AddliquidityPosition = {
Expand Down
Loading

0 comments on commit 602ebcb

Please sign in to comment.