@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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +45 -40
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/__tests__/memo.test.ts +1 -1
- package/src/helpers/memo.ts +1 -1
- package/src/modules/assetValue.ts +14 -3
|
@@ -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 [
|
|
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}.${
|
|
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] =
|
|
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
|
|