Skip to content

Commit 0b6f12a

Browse files
authored
added solana params to Query and tc-amm (#1478)
* added solana params to Query and tc-amm * added solana params to Query and tc-amm
1 parent 3996e98 commit 0b6f12a

File tree

8 files changed

+32
-1
lines changed

8 files changed

+32
-1
lines changed

.changeset/loose-files-fall.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@xchainjs/xchain-thorchain-query': patch
3+
'@xchainjs/xchain-thorchain-amm': patch
4+
---
5+
6+
Update to support solana for quoting and tc-amm

packages/xchain-thorchain-amm/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@xchainjs/xchain-evm": "workspace:*",
4949
"@xchainjs/xchain-litecoin": "workspace:*",
5050
"@xchainjs/xchain-ripple": "workspace:*",
51+
"@xchainjs/xchain-solana": "workspace:*",
5152
"@xchainjs/xchain-thorchain": "workspace:*",
5253
"@xchainjs/xchain-thorchain-query": "workspace:*",
5354
"@xchainjs/xchain-util": "workspace:*",

packages/xchain-thorchain-amm/src/thorchain-amm.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Client as XRPClient, defaultXRPParams } from '@xchainjs/xchain-ripple'
44
import { Client as BtcClient, defaultBTCParams as defaultBtcParams } from '@xchainjs/xchain-bitcoin'
55
import { Client as BchClient, defaultBchParams } from '@xchainjs/xchain-bitcoincash'
66
import { Client as BscClient, defaultBscParams } from '@xchainjs/xchain-bsc'
7+
import { Client as SOLClient, defaultSolanaParams } from '@xchainjs/xchain-solana'
78
import { Network } from '@xchainjs/xchain-client'
89
import { Client as GaiaClient } from '@xchainjs/xchain-cosmos'
910
import { Client as DogeClient, defaultDogeParams } from '@xchainjs/xchain-doge'
@@ -100,6 +101,7 @@ export class ThorchainAMM {
100101
THOR: new ThorClient({ ...defaultThorParams, network: Network.Mainnet }),
101102
BASE: new BaseClient({ ...defaultBaseParams, network: Network.Mainnet }),
102103
XRP: new XRPClient({ ...defaultXRPParams, network: Network.Mainnet }),
104+
SOL: new SOLClient({ ...defaultSolanaParams, network: Network.Mainnet }),
103105
}),
104106
) {
105107
this.thorchainQuery = thorchainQuery

packages/xchain-thorchain-amm/src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Network } from '@xchainjs/xchain-client'
77
import { AssetATOM, Client as GaiaClient, GAIAChain } from '@xchainjs/xchain-cosmos'
88
import { Client as DogeClient, DOGEChain, defaultDogeParams } from '@xchainjs/xchain-doge'
99
import { Client as XRPClient, XRPChain, defaultXRPParams } from '@xchainjs/xchain-ripple'
10+
import { Client as SOLClient, SOLChain, defaultSolanaParams } from '@xchainjs/xchain-solana'
1011
import { AssetETH, Client as EthClient, ETHChain, defaultEthParams } from '@xchainjs/xchain-ethereum'
1112
import { Client as LtcClient, LTCChain, defaultLtcParams } from '@xchainjs/xchain-litecoin'
1213
import { Client as ThorClient, THORChain, defaultClientConfig as defaultThorParams } from '@xchainjs/xchain-thorchain'
@@ -88,6 +89,8 @@ export const validateAddress = (network: Network, chain: Chain, address: Address
8889
return new ThorClient({ ...defaultThorParams, network }).validateAddress(address)
8990
case XRPChain:
9091
return new XRPClient({ ...defaultXRPParams, network }).validateAddress(address)
92+
case SOLChain:
93+
return new SOLClient({ ...defaultSolanaParams, network }).validateAddress(address)
9194
default:
9295
throw Error('Unsupported chain')
9396
}

packages/xchain-thorchain-query/src/chain-defaults.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ const DefaultChainAttributes: Record<Chain, ChainAttributes> = {
5454
blockReward: 0, // No block reward for xrp
5555
avgBlockTimeInSecs: 4, // Average block time for xrp in seconds
5656
},
57+
SOL: {
58+
blockReward: 0, // No block reward for sol
59+
avgBlockTimeInSecs: 0.4, // Average block time for sol in seconds
60+
},
5761
}
5862

5963
// Export the DefaultChainAttributes object

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const assetUSDC = assetFromStringEx('ETH.USDC-0XA0B86991C6218B36C1D19D4A2
1414
export const AssetBNB = assetFromStringEx('BSC.BNB') as Asset
1515
export const AssetBASE = assetFromStringEx('BASE.ETH') as Asset
1616
export const AssetXRP = assetFromStringEx('XRP.XRP') as Asset
17+
export const AssetSOL = assetFromStringEx('SOL.SOL') as Asset
1718

1819
export const BNBChain = 'BNB'
1920
export const BTCChain = 'BTC'
@@ -28,6 +29,7 @@ export const BSCChain = 'BSC'
2829
export const THORChain = 'THOR'
2930
export const BASEChain = 'BASE'
3031
export const XRPChain = 'XRP'
32+
export const SOLChain = 'SOL'
3133

3234
export const THORCHAIN_DECIMAL = 8
3335

packages/xchain-thorchain-query/src/utils/utils.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
AssetLTC,
2525
AssetMAYA,
2626
AssetXRP,
27+
AssetSOL,
2728
AssetRuneNative,
2829
BASEChain,
2930
BCHChain,
@@ -37,6 +38,7 @@ import {
3738
MAYAChain,
3839
THORChain,
3940
XRPChain,
41+
SOLChain,
4042
} from './const'
4143

4244
export const getBaseAmountWithDiffDecimals = (inputAmount: CryptoAmount, outDecimals: number): BigNumber => {
@@ -87,6 +89,8 @@ export const getChainAsset = (chain: Chain): Asset => {
8789
return AssetBASE
8890
case XRPChain:
8991
return AssetXRP
92+
case SOLChain:
93+
return AssetSOL
9094
default:
9195
throw Error('Unknown chain')
9296
}
@@ -154,6 +158,8 @@ export const calcNetworkFee = (asset: CompatibleAsset, inbound: InboundDetail):
154158
return new AssetCryptoAmount(baseAmount(inbound.gasRate), AssetBASE)
155159
case XRPChain:
156160
return new AssetCryptoAmount(baseAmount(inbound.gasRate), AssetXRP)
161+
case SOLChain:
162+
return new AssetCryptoAmount(baseAmount(inbound.gasRate), AssetSOL)
157163
}
158164
throw new Error(`could not calculate inbound fee for ${asset.chain}`)
159165
}
@@ -192,7 +198,11 @@ export const calcOutboundFee = (asset: CompatibleAsset, inbound: InboundDetail):
192198
case MAYAChain:
193199
return new AssetCryptoAmount(baseAmount(2000000), AssetMAYA)
194200
case BASEChain:
195-
return new AssetCryptoAmount(baseAmount(2000000), AssetBASE)
201+
return new AssetCryptoAmount(baseAmount(inbound.outboundFee), AssetBASE)
202+
case XRPChain:
203+
return new AssetCryptoAmount(baseAmount(inbound.outboundFee), AssetXRP)
204+
case SOLChain:
205+
return new AssetCryptoAmount(baseAmount(inbound.outboundFee), AssetSOL)
196206
}
197207
throw new Error(`could not calculate outbound fee for ${asset.chain}`)
198208
}
@@ -230,6 +240,8 @@ export const getChain = (chain: string): Chain => {
230240
return BASEChain
231241
case 'XRP':
232242
return XRPChain
243+
case 'SOL':
244+
return SOLChain
233245
default:
234246
throw Error('Unknown chain')
235247
}

yarn.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4381,6 +4381,7 @@ __metadata:
43814381
"@xchainjs/xchain-evm": "workspace:*"
43824382
"@xchainjs/xchain-litecoin": "workspace:*"
43834383
"@xchainjs/xchain-ripple": "workspace:*"
4384+
"@xchainjs/xchain-solana": "workspace:*"
43844385
"@xchainjs/xchain-thorchain": "workspace:*"
43854386
"@xchainjs/xchain-thorchain-query": "workspace:*"
43864387
"@xchainjs/xchain-util": "workspace:*"

0 commit comments

Comments
 (0)