@swapkit/helpers 1.0.0-rc.56 → 1.0.0-rc.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -204,12 +204,17 @@ async function createAssetValue(identifier: string, value: NumberPrimitives = 0)
204
204
  }
205
205
 
206
206
  function createSyntheticAssetValue(identifier: string, value: NumberPrimitives = 0) {
207
- const [symbol, ticker] = identifier.split('/');
207
+ const [synthChain, symbol] =
208
+ identifier.split('.')[0].toUpperCase() === Chain.THORChain
209
+ ? identifier.split('.').slice(1)!.join().split('/')
210
+ : identifier.split('/');
211
+
212
+ if (!synthChain || !symbol) throw new Error('Invalid asset identifier');
208
213
 
209
214
  return new AssetValue({
210
215
  decimal: 8,
211
216
  value: safeValue(value, 8),
212
- identifier: `${Chain.THORChain}.${symbol}/${ticker}`,
217
+ identifier: `${Chain.THORChain}.${synthChain}/${symbol}`,
213
218
  });
214
219
  }
215
220
 
@@ -221,7 +226,13 @@ function safeValue(value: NumberPrimitives, decimal: number) {
221
226
 
222
227
  function getAssetInfo(identifier: string) {
223
228
  const isSynthetic = identifier.slice(0, 14).includes('/');
224
- const [synthChain, synthSymbol] = identifier.split('.').pop()!.split('/');
229
+ const [synthChain, synthSymbol] =
230
+ identifier.split('.')[0].toUpperCase() === Chain.THORChain
231
+ ? identifier.split('.').slice(1)!.join().split('/')
232
+ : identifier.split('/');
233
+
234
+ if (isSynthetic && (!synthChain || !synthSymbol)) throw new Error('Invalid asset identifier');
235
+
225
236
  const adjustedIdentifier =
226
237
  identifier.includes('.') && !isSynthetic ? identifier : `${Chain.THORChain}.${synthSymbol}`;
227
238