@swapkit/helpers 1.0.0-rc.83 → 1.0.0-rc.85

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.
@@ -16,3 +16,11 @@ export function validateIdentifier(identifier = "") {
16
16
  `Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,
17
17
  );
18
18
  }
19
+
20
+ export function validateTNS(name: string) {
21
+ if (name.length > 30) return false;
22
+
23
+ const regex = /^[a-zA-Z0-9+_-]+$/g;
24
+
25
+ return !!name.match(regex);
26
+ }
@@ -1,5 +1,5 @@
1
+ import { describe, expect, test } from "bun:test";
1
2
  import { BaseDecimal, Chain } from "@swapkit/types";
2
- import { describe, expect, test } from "vitest";
3
3
 
4
4
  import { AssetValue, getMinAmountByChain } from "../assetValue.ts";
5
5
 
@@ -110,7 +110,7 @@ describe("AssetValue", () => {
110
110
  });
111
111
 
112
112
  describe("from bigint", () => {
113
- test.todo("returns asset value with correct decimal", async () => {
113
+ test("returns asset value with correct decimal", async () => {
114
114
  const avaxUSDCAsset = await AssetValue.fromIdentifier(
115
115
  `${Chain.Avalanche}.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e`,
116
116
  1234567800n,
@@ -138,7 +138,7 @@ describe("AssetValue", () => {
138
138
  });
139
139
 
140
140
  describe("fromIdentifier", () => {
141
- test.skip("creates AssetValue from string", async () => {
141
+ test("creates AssetValue from string", async () => {
142
142
  const avaxUSDCAsset = await AssetValue.fromIdentifier(
143
143
  "AVAX.USDC-0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
144
144
  );
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from "vitest";
1
+ import { describe, expect, test } from "bun:test";
2
2
 
3
3
  import { formatBigIntToSafeValue } from "../bigIntArithmetics.ts";
4
4
 
@@ -1,4 +1,4 @@
1
- import { describe, expect, test } from "vitest";
1
+ import { describe, expect, test } from "bun:test";
2
2
 
3
3
  import { SwapKitNumber } from "../swapKitNumber.ts";
4
4
 
@@ -180,7 +180,7 @@ export class AssetValue extends BigIntArithmetics {
180
180
  }
181
181
 
182
182
  static loadStaticAssets() {
183
- return new Promise<{ ok: true } | { ok: false; message: string; error: any }>(
183
+ return new Promise<{ ok: true } | { ok: false; message: string; error: Todo }>(
184
184
  (resolve, reject) => {
185
185
  try {
186
186
  import("@swapkit/tokens").then((tokenPackages) => {
@@ -251,7 +251,7 @@ async function createAssetValue(identifier: string, value: NumberPrimitives = 0)
251
251
 
252
252
  function createSyntheticAssetValue(identifier: string, value: NumberPrimitives = 0) {
253
253
  const [synthChain, symbol] =
254
- identifier.split(".")[0].toUpperCase() === Chain.THORChain
254
+ identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain
255
255
  ? identifier.split(".").slice(1).join().split("/")
256
256
  : identifier.split("/");
257
257
 
@@ -274,8 +274,8 @@ function safeValue(value: NumberPrimitives, decimal: number) {
274
274
  function getAssetInfo(identifier: string) {
275
275
  const isSynthetic = identifier.slice(0, 14).includes("/");
276
276
 
277
- const [synthChain, synthSymbol] =
278
- identifier.split(".")[0].toUpperCase() === Chain.THORChain
277
+ const [synthChain, synthSymbol = ""] =
278
+ identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain
279
279
  ? identifier.split(".").slice(1).join().split("/")
280
280
  : identifier.split("/");
281
281
 
@@ -41,10 +41,10 @@ export function formatBigIntToSafeValue({
41
41
  let decimalString = valueString.slice(-decimal);
42
42
 
43
43
  // Check if we need to round up
44
- if (Number.parseInt(decimalString[bigIntDecimal]) >= 5) {
44
+ if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
45
45
  // Increment the last decimal place and slice off the rest
46
46
  decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(
47
- Number.parseInt(decimalString[bigIntDecimal - 1]) + 1
47
+ Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1
48
48
  ).toString()}`;
49
49
  } else {
50
50
  // Just slice off the extra digits
@@ -244,7 +244,7 @@ export class BigIntArithmetics {
244
244
  } = {},
245
245
  ) {
246
246
  const value = this.getValue("number");
247
- const [int, dec = ""] = value.toFixed(6).split(".");
247
+ const [int = "", dec = ""] = value.toFixed(6).split(".");
248
248
  const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
249
249
 
250
250
  const parsedValue =
@@ -276,10 +276,10 @@ export class BigIntArithmetics {
276
276
  let decimalString = parsedValueString.slice(-decimalToUseForConversion);
277
277
 
278
278
  // Check if we need to round up
279
- if (Number.parseInt(decimalString[bigIntDecimal]) >= 5) {
279
+ if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
280
280
  // Increment the last decimal place and slice off the rest
281
281
  decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(
282
- Number.parseInt(decimalString[bigIntDecimal - 1]) + 1
282
+ Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1
283
283
  ).toString()}`;
284
284
  } else {
285
285
  // Just slice off the extra digits
@@ -345,7 +345,7 @@ export class BigIntArithmetics {
345
345
 
346
346
  #comparison(method: "gt" | "gte" | "lt" | "lte" | "eqValue", ...args: InitialisationValueType[]) {
347
347
  const decimal = this.#retrievePrecisionDecimal(this, ...args);
348
- const value = this.getBigIntValue(args[0], decimal);
348
+ const value = this.getBigIntValue(args[0] || "0", decimal);
349
349
  const compareToValue = this.getBigIntValue(this, decimal);
350
350
 
351
351
  switch (method) {
@@ -403,7 +403,7 @@ function toSafeValue(value: InitialisationValueType) {
403
403
 
404
404
  return splitValue.length > 1
405
405
  ? `${splitValue.slice(0, -1).join("")}.${splitValue.at(-1)}`
406
- : splitValue[0];
406
+ : splitValue[0] || "0";
407
407
  }
408
408
 
409
409
  function getFloatDecimals(value: string) {
@@ -79,7 +79,7 @@ const errorMessages = {
79
79
  export type ErrorKeys = keyof typeof errorMessages;
80
80
 
81
81
  export class SwapKitError extends Error {
82
- constructor(errorKey: ErrorKeys, sourceError?: any) {
82
+ constructor(errorKey: ErrorKeys, sourceError?: NotWorth) {
83
83
  if (sourceError) {
84
84
  console.error(sourceError, {
85
85
  stack: sourceError?.stack,
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright THORSwap
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
package/dist/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- "use strict";var ue=Object.create;var j=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty;var _e=(n,e,t)=>e in n?j(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var fe=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of he(e))!ge.call(n,r)&&r!==t&&j(n,r,{get:()=>e[r],enumerable:!(i=de(e,r))||i.enumerable});return n};var Y=(n,e,t)=>(t=n!=null?ue(me(n)):{},fe(e||!n||!n.__esModule?j(t,"default",{value:n,enumerable:!0}):t,n));var g=(n,e,t)=>(_e(n,typeof e!="symbol"?e+"":e,t),t),pe=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var $=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)};var h=(n,e,t)=>(pe(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("@swapkit/api"),a=require("@swapkit/types"),Ce="0x313ce567",Q=async({chain:n,to:e})=>{try{const{result:t}=await k.RequestClient.post(a.ChainToRPC[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:e.toLowerCase(),data:Ce},"latest"]})});return Number.parseInt(BigInt(t).toString())}catch(t){return console.error(t),a.BaseDecimal[n]}},Ae=n=>{if(n===a.Chain.Ethereum)return a.BaseDecimal.ETH;const[,e]=n.split("-");return e!=null&&e.startsWith("0x")?Q({chain:a.Chain.Ethereum,to:e}):a.BaseDecimal.ETH},$e=n=>{const[,e]=n.split("-");return e!=null&&e.startsWith("0x")?Q({chain:a.Chain.Avalanche,to:e.toLowerCase()}):a.BaseDecimal.AVAX},be=n=>(n===a.Chain.BinanceSmartChain,a.BaseDecimal.BSC),X=({chain:n,symbol:e})=>{switch(n){case a.Chain.Ethereum:return Ae(e);case a.Chain.Avalanche:return $e(e);case a.Chain.BinanceSmartChain:return be(e);default:return a.BaseDecimal[n]}},we={[a.FeeOption.Average]:1.2,[a.FeeOption.Fast]:1.5,[a.FeeOption.Fastest]:2},U=({chain:n,symbol:e})=>{switch(n){case a.Chain.Arbitrum:case a.Chain.Optimism:return e==="ETH";case a.Chain.Maya:return e==="CACAO";case a.Chain.Kujira:return e==="KUJI";case a.Chain.Cosmos:return e==="ATOM";case a.Chain.Polygon:return e==="MATIC";case a.Chain.BinanceSmartChain:return e==="BNB";case a.Chain.THORChain:return e==="RUNE";default:return e===n}},Z=n=>{switch(n){case`${a.Chain.Ethereum}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${a.Chain.Ethereum}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case a.Chain.Cosmos:return{identifier:"GAIA.ATOM",decimal:a.BaseDecimal[n]};case a.Chain.THORChain:return{identifier:"THOR.RUNE",decimal:a.BaseDecimal[n]};case a.Chain.BinanceSmartChain:return{identifier:"BSC.BNB",decimal:a.BaseDecimal[n]};case a.Chain.Maya:return{identifier:"MAYA.CACAO",decimal:a.BaseDecimal.MAYA};case`${a.Chain.Maya}.MAYA`:return{identifier:"MAYA.MAYA",decimal:4};case`${a.Chain.Kujira}.USK`:return{identifier:`${a.Chain.Kujira}.USK`,decimal:6};default:return{identifier:`${n}.${n}`,decimal:a.BaseDecimal[n]}}},ee=({chain:n,symbol:e})=>{if(e.includes("/"))return"Synth";switch(n){case a.Chain.Cosmos:return e==="ATOM"?"Native":a.Chain.Cosmos;case a.Chain.Kujira:return e===a.Chain.Kujira?"Native":a.Chain.Kujira;case a.Chain.Binance:return e===a.Chain.Binance?"Native":"BEP2";case a.Chain.BinanceSmartChain:return e===a.Chain.Binance?"Native":"BEP20";case a.Chain.Ethereum:return e===a.Chain.Ethereum?"Native":"ERC20";case a.Chain.Avalanche:return e===a.Chain.Avalanche?"Native":a.Chain.Avalanche;case a.Chain.Polygon:return e===a.Chain.Polygon?"Native":"POLYGON";case a.Chain.Arbitrum:return[a.Chain.Ethereum,a.Chain.Arbitrum].includes(e)?"Native":"ARBITRUM";case a.Chain.Optimism:return[a.Chain.Ethereum,a.Chain.Optimism].includes(e)?"Native":"OPTIMISM";default:return"Native"}},ve=n=>{var l;const[e,...t]=n.split("."),i=n.includes("/"),r=t.join("."),s=(l=r==null?void 0:r.split("-"))==null?void 0:l[0];return{chain:e,symbol:r,ticker:s,synth:i}},ye=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Be=n=>{const[e,t]=n.split(".");if(!a.EVMChains.includes(e))return!0;const[,i]=t.split("-");return U({chain:e,symbol:t})||!!i},Se=n=>n.filter(({chain:e,value:t,symbol:i})=>{const r=`${e}.${i}`;return!ye.test(r)&&Be(r)&&t!=="0"});async function Ie(n){const e=await import("@swapkit/tokens");for(const t of Object.values(e))for(const{identifier:i,chain:r,...s}of t.tokens)if("identifier"in n&&i===n.identifier||"address"in s&&"chain"in n&&r===n.chain&&s.address.toLowerCase()===n.contract.toLowerCase())return i}function te({liquidityUnits:n,poolUnits:e,runeDepth:t}){const i=m(n),r=m(e),s=m(t),l=i.mul(s),o=r.mul(r).mul(2),c=r.mul(i).mul(2),u=i.mul(i),d=r.mul(r).mul(r);return l.mul(o.sub(c).add(u)).div(d)}function ne({liquidityUnits:n,poolUnits:e,assetDepth:t}){const i=m(n),r=m(e),s=m(t),l=i.mul(s),o=r.mul(r).mul(2),c=r.mul(i).mul(2),u=i.mul(i),d=l.mul(o.sub(c).add(u)),B=r.mul(r).mul(r);return d.div(B)}function Me({percent:n,runeDepth:e,liquidityUnits:t,poolUnits:i}){return te({runeDepth:e,liquidityUnits:t,poolUnits:i}).mul(n)}function Te({percent:n,assetDepth:e,liquidityUnits:t,poolUnits:i}){return ne({assetDepth:e,liquidityUnits:t,poolUnits:i}).mul(n)}function m(n){return _.fromBigInt(BigInt(n),a.BaseDecimal.THOR)}function ie({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:i}){return{assetAmount:m(i).mul(n).div(e),runeAmount:m(t).mul(n).div(e)}}function Oe({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:i,percent:r}){return Object.fromEntries(Object.entries(ie({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:i})).map(([s,l])=>[s,l.mul(r)]))}function Ne({runeDepth:n,poolUnits:e,assetDepth:t,liquidityUnits:i,runeAmount:r,assetAmount:s}){const l=new _({value:n,decimal:8}),o=new _({value:t,decimal:8}),c=new _({value:e,decimal:8}),u=new _({value:r,decimal:8}),d=new _({value:s,decimal:8}),B=u.mul(o),G=d.mul(l),ae=u.mul(d),se=l.mul(o),ce=c.mul(B.add(G.add(ae.mul(2)))),oe=B.add(G.add(se.mul(2))),K=ce.div(oe),H=m(i).add(K);if(K.getBaseValue("number")===0)return H.div(c).getBaseValue("number");const le=c.add(H);return H.div(le).getBaseValue("number")}function Ve({runeAmount:n,assetAmount:e,runeDepth:t,assetDepth:i}){if(n==="0"||e==="0"||t==="0"||i==="0")return 0;const r=m(t),s=m(i),l=m(e),o=m(n),c=l.mul(r).sub(s.mul(o)),u=s.mul(o).add(r.mul(s));return Math.abs(c.div(u).getBaseValue("number"))}const Ee=(n,e)=>{switch(n){case a.MemoType.LEAVE:case a.MemoType.BOND:{const{address:t}=e;return`${n}:${t}`}case a.MemoType.UNBOND:{const{address:t,unbondAmount:i}=e;return`${n}:${t}:${i}`}case a.MemoType.THORNAME_REGISTER:{const{name:t,chain:i,address:r,owner:s}=e;return`${n}:${t}:${i}:${r}${s?`:${s}`:""}`}case a.MemoType.DEPOSIT:{const{chain:t,symbol:i,address:r,singleSide:s}=e;return s?`${n}:${t}/${i}`:`${n}:${((o,c)=>{switch(o){case a.Chain.Litecoin:return"l";case a.Chain.Dogecoin:return"d";case a.Chain.BitcoinCash:return"c";default:return`${o}.${c}`}})(t,i)}:${r||""}`}case a.MemoType.WITHDRAW:{const{chain:t,ticker:i,symbol:r,basisPoints:s,targetAssetString:l,singleSide:o}=e,c=t==="ETH"&&i!=="ETH"?`${i}-${r.slice(-3)}`:r,u=!o&&l?`:${l}`:"";return`${n}:${t}${o?"/":"."}${c}:${s}${u}`}case a.MemoType.OPEN_LOAN:case a.MemoType.CLOSE_LOAN:{const{asset:t,address:i}=e;return`${n}:${t}:${i}`}default:return""}};function Re(n){if(n<0)throw new Error("Invalid number of year");return 10+n}function De(n){if(n<0)throw new Error("Invalid number of year");return Math.round((10+n*1.0512)*1e10)/1e10}function He(n){if(n.length>30)return!1;const e=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(e)}function je(n){if(n.length>30)return!1;const e=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(e)}function xe([n,e,t,i,r]){return`${n}'/${e}'/${t}'/${i}${typeof r!="number"?"":`/${r}`}`}const z=[...Object.values(a.Chain),"TERRA"];function Pe(n=""){const e=n.toUpperCase(),[t]=e.split(".");if(z.includes(t))return!0;const[i]=e.split("/");if(z.includes(i))return!0;throw new Error(`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`)}const T=8,C=n=>10n**BigInt(n),S=n=>Math.log10(Number.parseFloat(n.toString()));function O({value:n,bigIntDecimal:e=T,decimal:t=T}){if(t===0)return n.toString();const i=n<0n;let r=n.toString().substring(i?1:0);const s=t-(r.length-1);s>0&&(r="0".repeat(s)+r);const l=r.length-t;let o=r.slice(-t);return Number.parseInt(o[e])>=5?o=`${o.substring(0,e-1)}${(Number.parseInt(o[e-1])+1).toString()}`:o=o.substring(0,e),`${i?"-":""}${r.slice(0,l)}.${o}`.replace(/\.?0*$/,"")}var A,I,p,b,R,re,N,F,V,L;const D=class D{constructor(e){$(this,A);$(this,p);$(this,R);$(this,N);$(this,V);g(this,"decimalMultiplier",10n**8n);g(this,"bigIntValue",0n);g(this,"decimal");const t=q(e),i=typeof e=="object";this.decimal=i?e.decimal:void 0,this.decimalMultiplier=i&&"decimalMultiplier"in e?e.decimalMultiplier:C(Math.max(J(E(t)),this.decimal||0)),h(this,R,re).call(this,t)}static fromBigInt(e,t){return new D({decimal:t,value:O({value:e,bigIntDecimal:t,decimal:t})})}static shiftDecimals({value:e,from:t,to:i}){return D.fromBigInt(e.getBaseValue("bigint")*C(i)/C(t),i)}set(e){return new this.constructor({decimal:this.decimal,value:e,identifier:this.toString()})}add(...e){return h(this,A,I).call(this,"add",...e)}sub(...e){return h(this,A,I).call(this,"sub",...e)}mul(...e){return h(this,A,I).call(this,"mul",...e)}div(...e){return h(this,A,I).call(this,"div",...e)}gt(e){return h(this,p,b).call(this,"gt",e)}gte(e){return h(this,p,b).call(this,"gte",e)}lt(e){return h(this,p,b).call(this,"lt",e)}lte(e){return h(this,p,b).call(this,"lte",e)}eqValue(e){return h(this,p,b).call(this,"eqValue",e)}getValue(e){const t=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||S(this.decimalMultiplier));switch(e){case"number":return Number(t);case"string":return t;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(e){const t=this.decimalMultiplier/C(this.decimal||a.BaseDecimal.THOR),i=this.bigIntValue/t;switch(e){case"number":return Number(i);case"string":return i.toString();case"bigint":return i}}getBigIntValue(e,t){if(!t&&typeof e=="object")return e.bigIntValue;const i=q(e),r=E(i);return r==="0"||r==="undefined"?0n:h(this,V,L).call(this,r,t)}toSignificant(e=6){const[t,i]=this.getValue("string").split("."),r=t||"",s=i||"";if((Number.parseInt(r)?r.length+s.length:s.length)<=e)return this.getValue("string");if(r.length>=e)return r.slice(0,e).padEnd(r.length,"0");if(Number.parseInt(r))return`${r}.${s.slice(0,e-r.length)}`.padEnd(e-r.length,"0");const o=Number.parseInt(s),c=`${o}`.slice(0,e);return`0.${c.padStart(s.length-`${o}`.length+c.length,"0")}`}toFixed(e=6){const[t,i]=this.getValue("string").split("."),r=t||"",s=i||"";if(Number.parseInt(r))return`${r}.${s.slice(0,e)}`.padEnd(e,"0");const l=Number.parseInt(s),o=`${l}`.slice(0,e);return`0.${o.padStart(s.length-`${l}`.length+o.length,"0")}`}toAbbreviation(e=2){const t=this.getValue("number"),i=["","K","M","B","T","Q","Qi","S"],r=Math.floor(Math.log10(Math.abs(t))/3),s=i[r];if(!s)return this.getValue("string");const l=10**(r*3);return`${(t/l).toFixed(e)}${s}`}toCurrency(e="$",{currencyPosition:t="start",decimal:i=2,decimalSeparator:r=".",thousandSeparator:s=","}={}){const l=this.getValue("number"),[o,c=""]=l.toFixed(6).split("."),u=o.replace(/\B(?=(\d{3})+(?!\d))/g,s),d=o||c?o==="0"?`${Number.parseFloat(`0.${c}`)}`.replace(".",r):`${u}${Number.parseInt(c)?`${r}${c.slice(0,i)}`:""}`:"0.00";return`${t==="start"?e:""}${d}${t==="end"?e:""}`}formatBigIntToSafeValue(e,t){const i=t||this.decimal||T,r=Math.max(i,S(this.decimalMultiplier)),s=e<0n,l=e.toString().substring(s?1:0),o=r-(l.length-1),c=o>0?"0".repeat(o)+l:l,u=c.length-r;let d=c.slice(-r);return Number.parseInt(d[i])>=5?d=`${d.substring(0,i-1)}${(Number.parseInt(d[i-1])+1).toString()}`:d=d.substring(0,i),`${s?"-":""}${c.slice(0,u)}.${d}`.replace(/\.?0*$/,"")}};A=new WeakSet,I=function(e,...t){const i=h(this,N,F).call(this,this,...t),r=Math.max(i,S(this.decimalMultiplier)),s=C(r),l=t.reduce((c,u)=>{const d=this.getBigIntValue(u,r);switch(e){case"add":return c+d;case"sub":return c-d;case"mul":return c*d/s;case"div":{if(d===0n)throw new RangeError("Division by zero");return c*s/d}default:return c}},this.bigIntValue*s/this.decimalMultiplier),o=O({bigIntDecimal:r,decimal:r,value:l});return new this.constructor({decimalMultiplier:C(r),decimal:this.decimal,value:o,identifier:this.toString()})},p=new WeakSet,b=function(e,...t){const i=h(this,N,F).call(this,this,...t),r=this.getBigIntValue(t[0],i),s=this.getBigIntValue(this,i);switch(e){case"gt":return s>r;case"gte":return s>=r;case"lt":return s<r;case"lte":return s<=r;case"eqValue":return s===r}},R=new WeakSet,re=function(e){const t=E(e)||"0";this.bigIntValue=h(this,V,L).call(this,t)},N=new WeakSet,F=function(...e){const t=e.map(i=>typeof i=="object"?i.decimal||S(i.decimalMultiplier):J(E(i))).filter(Boolean);return Math.max(...t,T)},V=new WeakSet,L=function(e,t){const i=t?C(t):this.decimalMultiplier,r=S(i),[s="",l=""]=e.split(".");return BigInt(`${s}${l.padEnd(r,"0")}`)};let y=D;const ke=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function E(n){const t=`${typeof n=="number"?ke.format(n):q(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]}function J(n){var t;const e=((t=n.split(".")[1])==null?void 0:t.length)||0;return Math.max(e,T)}function q(n){return typeof n=="object"?"getValue"in n?n.getValue("string"):n.value:n}class _ extends y{eq(e){return this.eqValue(e)}static fromBigInt(e,t){return new _({decimal:t,value:O({value:e,bigIntDecimal:t,decimal:t})})}}const w=new Map;class f extends y{constructor({value:t,decimal:i,tax:r,chain:s,symbol:l,identifier:o}){super(typeof t=="object"?t:{decimal:i,value:t});g(this,"address");g(this,"chain");g(this,"isGasAsset",!1);g(this,"isSynthetic",!1);g(this,"symbol");g(this,"tax");g(this,"ticker");g(this,"type");const c=M(o||`${s}.${l}`);this.type=ee(c),this.tax=r,this.chain=c.chain,this.ticker=c.ticker,this.symbol=c.symbol,this.address=c.address,this.isSynthetic=c.isSynthetic,this.isGasAsset=c.isGasAsset}toString(){return this.isSynthetic?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eq({chain:t,symbol:i}){return this.chain===t&&this.symbol===i}chainId(){return a.ChainToChainId[this.chain]}static fromUrl(t,i=0){const[r,s,l]=t.split(".");if(!(r&&s))throw new Error("Invalid asset url");const o=r===a.Chain.THORChain&&l?`${r}.${s}/${l}`:t;return x(o,i)}static fromString(t,i=0){return x(t,i)}static fromIdentifier(t,i=0){return x(t,i)}static fromStringSync(t,i=0){const{chain:r,isSynthetic:s}=M(t),l=w.get(t.toUpperCase());if(s)return P(t,i);const{tax:o,decimal:c,identifier:u}=l||{decimal:a.BaseDecimal[r],identifier:t};return new f({tax:o,value:v(i,c),identifier:s?t:u,decimal:s?8:c})}static async fromStringWithBase(t,i=0,r=a.BaseDecimal.THOR){const s=y.shiftDecimals({value:_.fromBigInt(BigInt(i)),from:0,to:r}).getBaseValue("string");return(await f.fromString(t,i)).set(s)}static fromStringWithBaseSync(t,i=0,r=a.BaseDecimal.THOR){const{chain:s,isSynthetic:l}=M(t),o=w.get(t.toUpperCase());if(l)return P(t,i);const{tax:c,decimal:u,identifier:d}=o||{decimal:a.BaseDecimal[s],identifier:t};return new f({tax:c,value:v(BigInt(i),r),identifier:d,decimal:u})}static fromIdentifierSync(t,i=0){const{chain:r,isSynthetic:s}=M(t),l=w.get(t);if(s)return P(t,i);const{tax:o,decimal:c,identifier:u}=l||{decimal:a.BaseDecimal[r],identifier:t};return new f({tax:o,decimal:c,identifier:u,value:v(i,c)})}static fromChainOrSignature(t,i=0){const{decimal:r,identifier:s}=Z(t);return new f({value:v(i,r),decimal:r,identifier:s})}static loadStaticAssets(){return new Promise((t,i)=>{try{import("@swapkit/tokens").then(r=>{for(const s of Object.values(r))for(const{identifier:l,chain:o,...c}of s.tokens)w.set(l.toUpperCase(),{identifier:l,decimal:"decimals"in c?c.decimals:a.BaseDecimal[o]});t({ok:!0})})}catch(r){console.error(r),i({ok:!1,error:r,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}}function Fe(n){const e=f.fromChainOrSignature(n);switch(n){case a.Chain.Bitcoin:case a.Chain.Litecoin:case a.Chain.BitcoinCash:return e.set(10001e-8);case a.Chain.Dogecoin:return e.set(1.00000001);case a.Chain.Avalanche:case a.Chain.Ethereum:return e.set(1e-8);case a.Chain.THORChain:case a.Chain.Maya:return e.set(0);case a.Chain.Cosmos:return e.set(1e-6);default:return e.set(1e-8)}}async function x(n,e=0){Pe(n);const t=w.get(n.toUpperCase()),i=(t==null?void 0:t.decimal)||await X(M(n));return t||w.set(n.toUpperCase(),{identifier:n,decimal:i}),new f({decimal:i,value:v(e,i),identifier:n})}function P(n,e=0){const[t,i]=n.split(".")[0].toUpperCase()===a.Chain.THORChain?n.split(".").slice(1).join().split("/"):n.split("/");if(!(t&&i))throw new Error("Invalid asset identifier");return new f({decimal:8,value:v(e,8),identifier:`${a.Chain.THORChain}.${t}/${i}`})}function v(n,e){return typeof n=="bigint"?O({value:n,bigIntDecimal:e,decimal:e}):n}function M(n){const e=n.slice(0,14).includes("/"),[t,i]=n.split(".")[0].toUpperCase()===a.Chain.THORChain?n.split(".").slice(1).join().split("/"):n.split("/");if(e&&!(t&&i))throw new Error("Invalid asset identifier");const r=n.includes(".")&&!e?n:`${a.Chain.THORChain}.${i}`,[s,...l]=r.split("."),[o,c]=(e?i:l.join(".")).split("-"),u=e?i:l.join(".");return{address:c==null?void 0:c.toLowerCase(),chain:s,isGasAsset:U({chain:s,symbol:u}),isSynthetic:e,symbol:(e?`${t}/`:"")+(c?`${o}-${(c==null?void 0:c.toLowerCase())??""}`:u),ticker:o}}const Le={core_wallet_connection_not_found:10001,core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_chain_halted:10099,core_wallet_xdefi_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,core_transaction_deposit_error:10301,core_transaction_create_liquidity_rune_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_no_rune_address:10306,core_transaction_add_liquidity_rune_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,wallet_ledger_connection_error:20001,wallet_ledger_connection_claimed:20002,wallet_ledger_get_address_error:20003,wallet_ledger_device_not_found:20004,wallet_ledger_device_locked:20005,chainflip_channel_error:30001,chainflip_broker_recipient_error:30002,helpers_number_different_decimals:99101};class W extends Error{constructor(e,t){t&&console.error(t,{stack:t==null?void 0:t.stack,message:t==null?void 0:t.message}),super(e,{cause:{code:Le[e],message:e}}),Object.setPrototypeOf(this,W.prototype)}}exports.AssetValue=f;exports.BigIntArithmetics=y;exports.SwapKitError=W;exports.SwapKitNumber=_;exports.assetFromString=ve;exports.derivationPathToString=xe;exports.filterAssets=Se;exports.findAssetBy=Ie;exports.formatBigIntToSafeValue=O;exports.gasFeeMultiplier=we;exports.getAssetType=ee;exports.getAsymmetricAssetShare=ne;exports.getAsymmetricAssetWithdrawAmount=Te;exports.getAsymmetricRuneShare=te;exports.getAsymmetricRuneWithdrawAmount=Me;exports.getCommonAssetInfo=Z;exports.getDecimal=X;exports.getEstimatedPoolShare=Ne;exports.getLiquiditySlippage=Ve;exports.getMAYANameCost=De;exports.getMemoFor=Ee;exports.getMinAmountByChain=Fe;exports.getSymmetricPoolShare=ie;exports.getSymmetricWithdraw=Oe;exports.getTHORNameCost=Re;exports.isGasAsset=U;exports.validateMAYAName=je;exports.validateTHORName=He;Object.keys(k).forEach(n=>{n!=="default"&&!Object.prototype.hasOwnProperty.call(exports,n)&&Object.defineProperty(exports,n,{enumerable:!0,get:()=>k[n]})});
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/helpers/asset.ts","../src/helpers/liquidity.ts","../src/helpers/memo.ts","../src/helpers/others.ts","../src/helpers/validators.ts","../src/modules/bigIntArithmetics.ts","../src/modules/swapKitNumber.ts","../src/modules/assetValue.ts","../src/modules/swapKitError.ts"],"sourcesContent":["import { RequestClient } from \"@swapkit/api\";\nimport type { EVMChain } from \"@swapkit/types\";\nimport { BaseDecimal, Chain, ChainToRPC, EVMChains, FeeOption } from \"@swapkit/types\";\nimport type { TokenNames } from \"../types.ts\";\n\nconst getDecimalMethodHex = \"0x313ce567\";\n\nexport type CommonAssetString =\n | `${Chain.Maya}.MAYA`\n | `${Chain.Ethereum}.THOR`\n | `${Chain.Ethereum}.vTHOR`\n | `${Chain.Kujira}.USK`\n | Chain;\n\nconst getContractDecimals = async ({ chain, to }: { chain: EVMChain; to: string }) => {\n try {\n const { result } = await RequestClient.post<{ result: string }>(ChainToRPC[chain], {\n headers: {\n accept: \"*/*\",\n \"content-type\": \"application/json\",\n \"cache-control\": \"no-cache\",\n },\n body: JSON.stringify({\n id: 44,\n jsonrpc: \"2.0\",\n method: \"eth_call\",\n params: [{ to: to.toLowerCase(), data: getDecimalMethodHex }, \"latest\"],\n }),\n });\n\n return Number.parseInt(BigInt(result).toString());\n } catch (error) {\n console.error(error);\n return BaseDecimal[chain];\n }\n};\n\nconst getETHAssetDecimal = (symbol: string) => {\n if (symbol === Chain.Ethereum) return BaseDecimal.ETH;\n const [, address] = symbol.split(\"-\");\n\n return address?.startsWith(\"0x\")\n ? getContractDecimals({ chain: Chain.Ethereum, to: address })\n : BaseDecimal.ETH;\n};\n\nconst getAVAXAssetDecimal = (symbol: string) => {\n const [, address] = symbol.split(\"-\");\n\n return address?.startsWith(\"0x\")\n ? getContractDecimals({ chain: Chain.Avalanche, to: address.toLowerCase() })\n : BaseDecimal.AVAX;\n};\n\nconst getBSCAssetDecimal = (symbol: string) => {\n if (symbol === Chain.BinanceSmartChain) return BaseDecimal.BSC;\n\n return BaseDecimal.BSC;\n};\n\nexport const getDecimal = ({ chain, symbol }: { chain: Chain; symbol: string }) => {\n switch (chain) {\n case Chain.Ethereum:\n return getETHAssetDecimal(symbol);\n case Chain.Avalanche:\n return getAVAXAssetDecimal(symbol);\n case Chain.BinanceSmartChain:\n return getBSCAssetDecimal(symbol);\n default:\n return BaseDecimal[chain];\n }\n};\n\nexport const gasFeeMultiplier: Record<FeeOption, number> = {\n [FeeOption.Average]: 1.2,\n [FeeOption.Fast]: 1.5,\n [FeeOption.Fastest]: 2,\n};\n\nexport const isGasAsset = ({ chain, symbol }: { chain: Chain; symbol: string }) => {\n switch (chain) {\n case Chain.Arbitrum:\n case Chain.Optimism:\n return symbol === \"ETH\";\n case Chain.Maya:\n return symbol === \"CACAO\";\n case Chain.Kujira:\n return symbol === \"KUJI\";\n case Chain.Cosmos:\n return symbol === \"ATOM\";\n case Chain.Polygon:\n return symbol === \"MATIC\";\n case Chain.BinanceSmartChain:\n return symbol === \"BNB\";\n case Chain.THORChain:\n return symbol === \"RUNE\";\n\n default:\n return symbol === chain;\n }\n};\n\nexport const getCommonAssetInfo = (\n assetString: CommonAssetString,\n): { identifier: string; decimal: number } => {\n switch (assetString) {\n case `${Chain.Ethereum}.THOR`:\n return { identifier: \"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044\", decimal: 18 };\n case `${Chain.Ethereum}.vTHOR`:\n return { identifier: \"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d\", decimal: 18 };\n\n case Chain.Cosmos:\n return { identifier: \"GAIA.ATOM\", decimal: BaseDecimal[assetString] };\n case Chain.THORChain:\n return { identifier: \"THOR.RUNE\", decimal: BaseDecimal[assetString] };\n case Chain.BinanceSmartChain:\n return { identifier: \"BSC.BNB\", decimal: BaseDecimal[assetString] };\n case Chain.Maya:\n return { identifier: \"MAYA.CACAO\", decimal: BaseDecimal.MAYA };\n case `${Chain.Maya}.MAYA`:\n return { identifier: \"MAYA.MAYA\", decimal: 4 };\n\n case `${Chain.Kujira}.USK`:\n return { identifier: `${Chain.Kujira}.USK`, decimal: 6 };\n\n default:\n return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };\n }\n};\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO: Refactor\nexport const getAssetType = ({ chain, symbol }: { chain: Chain; symbol: string }) => {\n if (symbol.includes(\"/\")) return \"Synth\";\n\n switch (chain) {\n case Chain.Cosmos:\n return symbol === \"ATOM\" ? \"Native\" : Chain.Cosmos;\n case Chain.Kujira:\n return symbol === Chain.Kujira ? \"Native\" : Chain.Kujira;\n case Chain.Binance:\n return symbol === Chain.Binance ? \"Native\" : \"BEP2\";\n case Chain.BinanceSmartChain:\n return symbol === Chain.Binance ? \"Native\" : \"BEP20\";\n case Chain.Ethereum:\n return symbol === Chain.Ethereum ? \"Native\" : \"ERC20\";\n case Chain.Avalanche:\n return symbol === Chain.Avalanche ? \"Native\" : Chain.Avalanche;\n case Chain.Polygon:\n return symbol === Chain.Polygon ? \"Native\" : \"POLYGON\";\n\n case Chain.Arbitrum:\n return [Chain.Ethereum, Chain.Arbitrum].includes(symbol as Chain) ? \"Native\" : \"ARBITRUM\";\n case Chain.Optimism:\n return [Chain.Ethereum, Chain.Optimism].includes(symbol as Chain) ? \"Native\" : \"OPTIMISM\";\n\n default:\n return \"Native\";\n }\n};\n\nexport const assetFromString = (assetString: string) => {\n const [chain, ...symbolArray] = assetString.split(\".\") as [Chain, ...(string | undefined)[]];\n const synth = assetString.includes(\"/\");\n const symbol = symbolArray.join(\".\");\n const ticker = symbol?.split(\"-\")?.[0];\n\n return { chain, symbol, ticker, synth };\n};\n\nconst potentialScamRegex = new RegExp(\n /(.)\\1{6}|\\.ORG|\\.NET|\\.FINANCE|\\.COM|WWW|HTTP|\\\\\\\\|\\/\\/|[\\s$%:[\\]]/,\n \"gmi\",\n);\n\nconst evmAssetHasAddress = (assetString: string) => {\n const [chain, symbol] = assetString.split(\".\") as [EVMChain, string];\n if (!EVMChains.includes(chain as EVMChain)) return true;\n const [, address] = symbol.split(\"-\") as [string, string?];\n\n return isGasAsset({ chain: chain as Chain, symbol }) || !!address;\n};\n\nexport const filterAssets = (\n tokens: {\n value: string;\n decimal: number;\n chain: Chain;\n symbol: string;\n }[],\n) =>\n tokens.filter(({ chain, value, symbol }) => {\n const assetString = `${chain}.${symbol}`;\n\n return (\n !potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== \"0\"\n );\n });\n\nexport async function findAssetBy(\n params: { chain: EVMChain; contract: string } | { identifier: `${Chain}.${string}` },\n) {\n const tokenPackages = await import(\"@swapkit/tokens\");\n\n for (const tokenList of Object.values(tokenPackages)) {\n for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) {\n if (\"identifier\" in params && identifier === params.identifier) {\n return identifier as TokenNames;\n }\n\n if (\n \"address\" in rest &&\n \"chain\" in params &&\n tokenChain === params.chain &&\n rest.address.toLowerCase() === params.contract.toLowerCase()\n )\n return identifier as TokenNames;\n }\n }\n\n return;\n}\n","import { BaseDecimal } from \"@swapkit/types\";\n\nimport { SwapKitNumber } from \"../index.ts\";\n\ntype ShareParams<T extends {}> = T & {\n liquidityUnits: string;\n poolUnits: string;\n};\n\ntype PoolParams = {\n runeAmount: string;\n assetAmount: string;\n runeDepth: string;\n assetDepth: string;\n};\n\n/**\n * Ref: https://gitlab.com/thorchain/thornode/-/issues/657\n * share = (s * A * (2 * T^2 - 2 * T * s + s^2))/T^3\n * s = stakeUnits for member (after factoring in withdrawBasisPoints)\n * T = totalPoolUnits for pool\n * A = assetDepth to be withdrawn\n *\n * Formula:\n * share = (s * A * (2 * T^2 - 2 * T * s + s^2))/T^3\n * (part1 * (part2 - part3 + part4)) / part5\n */\nexport function getAsymmetricRuneShare({\n liquidityUnits,\n poolUnits,\n runeDepth,\n}: ShareParams<{ runeDepth: string }>) {\n const s = toTCSwapKitNumber(liquidityUnits);\n const T = toTCSwapKitNumber(poolUnits);\n const A = toTCSwapKitNumber(runeDepth);\n\n const part1 = s.mul(A);\n const part2 = T.mul(T).mul(2);\n const part3 = T.mul(s).mul(2);\n const part4 = s.mul(s);\n const part5 = T.mul(T).mul(T);\n\n const numerator = part1.mul(part2.sub(part3).add(part4));\n\n return numerator.div(part5);\n}\n\nexport function getAsymmetricAssetShare({\n liquidityUnits,\n poolUnits,\n assetDepth,\n}: ShareParams<{ assetDepth: string }>) {\n const s = toTCSwapKitNumber(liquidityUnits);\n const T = toTCSwapKitNumber(poolUnits);\n const A = toTCSwapKitNumber(assetDepth);\n\n const part1 = s.mul(A);\n const part2 = T.mul(T).mul(2);\n const part3 = T.mul(s).mul(2);\n const part4 = s.mul(s);\n const numerator = part1.mul(part2.sub(part3).add(part4));\n const part5 = T.mul(T).mul(T);\n\n return numerator.div(part5);\n}\n\nexport function getAsymmetricRuneWithdrawAmount({\n percent,\n runeDepth,\n liquidityUnits,\n poolUnits,\n}: ShareParams<{ percent: number; runeDepth: string }>) {\n return getAsymmetricRuneShare({ runeDepth, liquidityUnits, poolUnits }).mul(percent);\n}\n\nexport function getAsymmetricAssetWithdrawAmount({\n percent,\n assetDepth,\n liquidityUnits,\n poolUnits,\n}: ShareParams<{ percent: number; assetDepth: string }>) {\n return getAsymmetricAssetShare({ assetDepth, liquidityUnits, poolUnits }).mul(percent);\n}\n\nfunction toTCSwapKitNumber(value: string) {\n return SwapKitNumber.fromBigInt(BigInt(value), BaseDecimal.THOR);\n}\n\nexport function getSymmetricPoolShare({\n liquidityUnits,\n poolUnits,\n runeDepth,\n assetDepth,\n}: ShareParams<{\n runeDepth: string;\n assetDepth: string;\n}>) {\n return {\n assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),\n runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits),\n };\n}\n\nexport function getSymmetricWithdraw({\n liquidityUnits,\n poolUnits,\n runeDepth,\n assetDepth,\n percent,\n}: ShareParams<{\n runeDepth: string;\n assetDepth: string;\n percent: number;\n}>) {\n return Object.fromEntries(\n Object.entries(getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth })).map(\n ([name, value]) => [name, value.mul(percent)],\n ),\n );\n}\n\nexport function getEstimatedPoolShare({\n runeDepth,\n poolUnits,\n assetDepth,\n liquidityUnits,\n runeAmount,\n assetAmount,\n}: ShareParams<{\n runeAmount: string;\n assetAmount: string;\n runeDepth: string;\n assetDepth: string;\n}>) {\n const R = new SwapKitNumber({ value: runeDepth, decimal: 8 });\n const A = new SwapKitNumber({ value: assetDepth, decimal: 8 });\n const P = new SwapKitNumber({ value: poolUnits, decimal: 8 });\n const runeAddAmount = new SwapKitNumber({ value: runeAmount, decimal: 8 });\n const assetAddAmount = new SwapKitNumber({ value: assetAmount, decimal: 8 });\n\n // liquidityUnits = P * (r*A + a*R + 2*r*a) / (r*A + a*R + 2*R*A)\n const rA = runeAddAmount.mul(A);\n const aR = assetAddAmount.mul(R);\n const ra = runeAddAmount.mul(assetAddAmount);\n const RA = R.mul(A);\n const numerator = P.mul(rA.add(aR.add(ra.mul(2))));\n const denominator = rA.add(aR.add(RA.mul(2)));\n const liquidityUnitsAfterAdd = numerator.div(denominator);\n const estimatedLiquidityUnits = toTCSwapKitNumber(liquidityUnits).add(liquidityUnitsAfterAdd);\n\n if (liquidityUnitsAfterAdd.getBaseValue(\"number\") === 0) {\n return estimatedLiquidityUnits.div(P).getBaseValue(\"number\");\n }\n\n // get pool units after add\n const newPoolUnits = P.add(estimatedLiquidityUnits);\n\n return estimatedLiquidityUnits.div(newPoolUnits).getBaseValue(\"number\");\n}\n\nexport function getLiquiditySlippage({\n runeAmount,\n assetAmount,\n runeDepth,\n assetDepth,\n}: PoolParams) {\n if (runeAmount === \"0\" || assetAmount === \"0\" || runeDepth === \"0\" || assetDepth === \"0\")\n return 0;\n // formula: (t * R - T * r)/ (T*r + R*T)\n const R = toTCSwapKitNumber(runeDepth);\n const T = toTCSwapKitNumber(assetDepth);\n const assetAddAmount = toTCSwapKitNumber(assetAmount);\n const runeAddAmount = toTCSwapKitNumber(runeAmount);\n\n const numerator = assetAddAmount.mul(R).sub(T.mul(runeAddAmount));\n const denominator = T.mul(runeAddAmount).add(R.mul(T));\n\n // set absolute value of percent, no negative allowed\n return Math.abs(numerator.div(denominator).getBaseValue(\"number\"));\n}\n","import { Chain, MemoType } from \"@swapkit/types\";\n\nexport type ThornameRegisterParam = {\n name: string;\n chain: string;\n address: string;\n owner?: string;\n preferredAsset?: string;\n expiryBlock?: string;\n};\n\ntype WithChain<T extends {}> = T & { chain: Chain };\n\nexport type MemoOptions<T extends MemoType> = {\n [MemoType.BOND]: { address: string };\n [MemoType.LEAVE]: { address: string };\n [MemoType.CLOSE_LOAN]: { address: string; asset: string; minAmount?: string };\n [MemoType.OPEN_LOAN]: { address: string; asset: string; minAmount?: string };\n [MemoType.UNBOND]: { address: string; unbondAmount: number };\n [MemoType.DEPOSIT]: WithChain<{ symbol: string; address?: string; singleSide?: boolean }>;\n [MemoType.WITHDRAW]: WithChain<{\n ticker: string;\n symbol: string;\n basisPoints: number;\n targetAssetString?: string;\n singleSide?: boolean;\n }>;\n [MemoType.THORNAME_REGISTER]: Omit<ThornameRegisterParam, \"preferredAsset\" | \"expiryBlock\">;\n}[T];\n\nexport const getMemoFor = <T extends MemoType>(memoType: T, options: MemoOptions<T>) => {\n switch (memoType) {\n case MemoType.LEAVE:\n case MemoType.BOND: {\n const { address } = options as MemoOptions<MemoType.BOND>;\n return `${memoType}:${address}`;\n }\n\n case MemoType.UNBOND: {\n const { address, unbondAmount } = options as MemoOptions<MemoType.UNBOND>;\n return `${memoType}:${address}:${unbondAmount}`;\n }\n\n case MemoType.THORNAME_REGISTER: {\n const { name, chain, address, owner } = options as MemoOptions<MemoType.THORNAME_REGISTER>;\n return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : \"\"}`;\n }\n\n case MemoType.DEPOSIT: {\n const { chain, symbol, address, singleSide } = options as MemoOptions<MemoType.DEPOSIT>;\n\n const getPoolIdentifier = (chain: Chain, symbol: string): string => {\n switch (chain) {\n case Chain.Litecoin:\n return \"l\";\n case Chain.Dogecoin:\n return \"d\";\n case Chain.BitcoinCash:\n return \"c\";\n default:\n return `${chain}.${symbol}`;\n }\n };\n\n return singleSide\n ? `${memoType}:${chain}/${symbol}`\n : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || \"\"}`;\n }\n\n case MemoType.WITHDRAW: {\n const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } =\n options as MemoOptions<MemoType.WITHDRAW>;\n\n const shortenedSymbol =\n chain === \"ETH\" && ticker !== \"ETH\" ? `${ticker}-${symbol.slice(-3)}` : symbol;\n const target = !singleSide && targetAssetString ? `:${targetAssetString}` : \"\";\n const assetDivider = singleSide ? \"/\" : \".\";\n\n return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;\n }\n\n case MemoType.OPEN_LOAN:\n case MemoType.CLOSE_LOAN: {\n const { asset, address } = options as MemoOptions<MemoType.OPEN_LOAN>;\n\n return `${memoType}:${asset}:${address}`; //:${minAmount ? `${minAmount}` : ''}:t:0`;\n }\n\n default:\n return \"\";\n }\n};\n","// 10 rune for register, 1 rune per year\n// MINIMUM_REGISTRATION_FEE = 11\nexport function getTHORNameCost(year: number) {\n if (year < 0) throw new Error(\"Invalid number of year\");\n return 10 + year;\n}\n\n// 10 CACAO for register\n// 1.0512 CACAO per year\nexport function getMAYANameCost(year: number) {\n if (year < 0) throw new Error(\"Invalid number of year\");\n // round to max 10 decimals\n return Math.round((10 + year * 1.0512) * 1e10) / 1e10;\n}\n\nexport function validateTHORName(name: string) {\n if (name.length > 30) return false;\n\n const regex = /^[a-zA-Z0-9+_-]+$/g;\n\n return !!name.match(regex);\n}\n\nexport function validateMAYAName(name: string) {\n if (name.length > 30) return false;\n\n const regex = /^[a-zA-Z0-9+_-]+$/g;\n\n return !!name.match(regex);\n}\n\nexport function derivationPathToString([network, chainId, account, change, index]: [\n number,\n number,\n number,\n number,\n number | undefined,\n]) {\n const shortPath = typeof index !== \"number\";\n\n return `${network}'/${chainId}'/${account}'/${change}${shortPath ? \"\" : `/${index}`}`;\n}\n","import { Chain } from \"@swapkit/types\";\n\n// Backward compatibility\nconst supportedChains = [...Object.values(Chain), \"TERRA\"];\n\nexport function validateIdentifier(identifier = \"\") {\n const uppercasedIdentifier = identifier.toUpperCase();\n\n const [chain] = uppercasedIdentifier.split(\".\") as [Chain, string];\n if (supportedChains.includes(chain)) return true;\n\n const [synthChain] = uppercasedIdentifier.split(\"/\") as [Chain, string];\n if (supportedChains.includes(synthChain)) return true;\n\n throw new Error(\n `Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,\n );\n}\n","import { BaseDecimal } from \"@swapkit/types\";\n\nimport type { SwapKitNumber } from \"./swapKitNumber.ts\";\n\ntype NumberPrimitivesType = {\n bigint: bigint;\n number: number;\n string: string;\n};\nexport type NumberPrimitives = bigint | number | string;\ntype InitialisationValueType = NumberPrimitives | BigIntArithmetics | SwapKitNumber;\n\ntype SKBigIntParams = InitialisationValueType | { decimal?: number; value: number | string };\ntype AllowedNumberTypes = \"bigint\" | \"number\" | \"string\";\n\nconst DEFAULT_DECIMAL = 8;\nconst toMultiplier = (decimal: number) => 10n ** BigInt(decimal);\nconst decimalFromMultiplier = (multiplier: bigint) =>\n Math.log10(Number.parseFloat(multiplier.toString()));\n\nexport function formatBigIntToSafeValue({\n value,\n bigIntDecimal = DEFAULT_DECIMAL,\n decimal = DEFAULT_DECIMAL,\n}: {\n value: bigint;\n bigIntDecimal?: number;\n decimal?: number;\n}) {\n if (decimal === 0) return value.toString();\n const isNegative = value < 0n;\n let valueString = value.toString().substring(isNegative ? 1 : 0);\n\n const padLength = decimal - (valueString.length - 1);\n\n if (padLength > 0) {\n valueString = \"0\".repeat(padLength) + valueString;\n }\n\n const decimalIndex = valueString.length - decimal;\n let decimalString = valueString.slice(-decimal);\n\n // Check if we need to round up\n if (Number.parseInt(decimalString[bigIntDecimal]) >= 5) {\n // Increment the last decimal place and slice off the rest\n decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(\n Number.parseInt(decimalString[bigIntDecimal - 1]) + 1\n ).toString()}`;\n } else {\n // Just slice off the extra digits\n decimalString = decimalString.substring(0, bigIntDecimal);\n }\n\n return `${isNegative ? \"-\" : \"\"}${valueString.slice(0, decimalIndex)}.${decimalString}`.replace(\n /\\.?0*$/,\n \"\",\n );\n}\n\nexport class BigIntArithmetics {\n decimalMultiplier: bigint = 10n ** 8n;\n bigIntValue = 0n;\n decimal?: number;\n\n static fromBigInt(value: bigint, decimal?: number) {\n return new BigIntArithmetics({\n decimal,\n value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }),\n });\n }\n\n static shiftDecimals({\n value,\n from,\n to,\n }: {\n value: InstanceType<typeof SwapKitNumber>;\n from: number;\n to: number;\n }) {\n return BigIntArithmetics.fromBigInt(\n (value.getBaseValue(\"bigint\") * toMultiplier(to)) / toMultiplier(from),\n to,\n );\n }\n\n constructor(params: SKBigIntParams) {\n const value = getStringValue(params);\n const isComplex = typeof params === \"object\";\n this.decimal = isComplex ? params.decimal : undefined;\n\n // use the multiplier to keep track of decimal point - defaults to 8 if lower than 8\n this.decimalMultiplier =\n isComplex && \"decimalMultiplier\" in params\n ? params.decimalMultiplier\n : toMultiplier(Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0));\n this.#setValue(value);\n }\n\n set(value: SKBigIntParams): this {\n // @ts-expect-error False positive\n return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });\n }\n add(...args: InitialisationValueType[]) {\n return this.#arithmetics(\"add\", ...args);\n }\n sub(...args: InitialisationValueType[]) {\n return this.#arithmetics(\"sub\", ...args);\n }\n mul(...args: InitialisationValueType[]) {\n return this.#arithmetics(\"mul\", ...args);\n }\n div(...args: InitialisationValueType[]) {\n return this.#arithmetics(\"div\", ...args);\n }\n gt(value: InitialisationValueType) {\n return this.#comparison(\"gt\", value);\n }\n gte(value: InitialisationValueType) {\n return this.#comparison(\"gte\", value);\n }\n lt(value: InitialisationValueType) {\n return this.#comparison(\"lt\", value);\n }\n lte(value: InitialisationValueType) {\n return this.#comparison(\"lte\", value);\n }\n eqValue(value: InitialisationValueType) {\n return this.#comparison(\"eqValue\", value);\n }\n\n // @ts-expect-error False positive\n getValue<T extends AllowedNumberTypes>(type: T): NumberPrimitivesType[T] {\n const value = this.formatBigIntToSafeValue(\n this.bigIntValue,\n this.decimal || decimalFromMultiplier(this.decimalMultiplier),\n );\n\n switch (type) {\n case \"number\":\n return Number(value) as NumberPrimitivesType[T];\n case \"string\":\n return value as NumberPrimitivesType[T];\n case \"bigint\":\n return ((this.bigIntValue * 10n ** BigInt(this.decimal || 8n)) /\n this.decimalMultiplier) as NumberPrimitivesType[T];\n }\n }\n\n // @ts-expect-error\n getBaseValue<T extends AllowedNumberTypes>(type: T): NumberPrimitivesType[T] {\n const divisor = this.decimalMultiplier / toMultiplier(this.decimal || BaseDecimal.THOR);\n const baseValue = this.bigIntValue / divisor;\n\n switch (type) {\n case \"number\":\n return Number(baseValue) as NumberPrimitivesType[T];\n case \"string\":\n return baseValue.toString() as NumberPrimitivesType[T];\n case \"bigint\":\n return baseValue as NumberPrimitivesType[T];\n }\n }\n\n getBigIntValue(value: InitialisationValueType, decimal?: number) {\n if (!decimal && typeof value === \"object\") return value.bigIntValue;\n\n const stringValue = getStringValue(value);\n const safeValue = toSafeValue(stringValue);\n\n if (safeValue === \"0\" || safeValue === \"undefined\") return 0n;\n return this.#toBigInt(safeValue, decimal);\n }\n\n toSignificant(significantDigits = 6) {\n const [int, dec] = this.getValue(\"string\").split(\".\");\n const integer = int || \"\";\n const decimal = dec || \"\";\n const valueLength = Number.parseInt(integer) ? integer.length + decimal.length : decimal.length;\n\n if (valueLength <= significantDigits) {\n return this.getValue(\"string\");\n }\n\n if (integer.length >= significantDigits) {\n return integer.slice(0, significantDigits).padEnd(integer.length, \"0\");\n }\n\n if (Number.parseInt(integer)) {\n return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(\n significantDigits - integer.length,\n \"0\",\n );\n }\n\n const trimmedDecimal = Number.parseInt(decimal);\n const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);\n\n return `0.${slicedDecimal.padStart(\n decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length,\n \"0\",\n )}`;\n }\n\n toFixed(fixedDigits = 6) {\n const [int, dec] = this.getValue(\"string\").split(\".\");\n const integer = int || \"\";\n const decimal = dec || \"\";\n\n if (Number.parseInt(integer)) {\n return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, \"0\");\n }\n\n const trimmedDecimal = Number.parseInt(decimal);\n const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);\n\n return `0.${slicedDecimal.padStart(\n decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length,\n \"0\",\n )}`;\n }\n\n toAbbreviation(digits = 2) {\n const value = this.getValue(\"number\");\n const abbreviations = [\"\", \"K\", \"M\", \"B\", \"T\", \"Q\", \"Qi\", \"S\"];\n const tier = Math.floor(Math.log10(Math.abs(value)) / 3);\n const suffix = abbreviations[tier];\n\n if (!suffix) return this.getValue(\"string\");\n\n const scale = 10 ** (tier * 3);\n const scaled = value / scale;\n\n return `${scaled.toFixed(digits)}${suffix}`;\n }\n\n toCurrency(\n currency = \"$\",\n {\n currencyPosition = \"start\",\n decimal = 2,\n decimalSeparator = \".\",\n thousandSeparator = \",\",\n } = {},\n ) {\n const value = this.getValue(\"number\");\n const [int, dec = \"\"] = value.toFixed(6).split(\".\");\n const integer = int.replace(/\\B(?=(\\d{3})+(?!\\d))/g, thousandSeparator);\n\n const parsedValue =\n int || dec\n ? int === \"0\"\n ? `${Number.parseFloat(`0.${dec}`)}`.replace(\".\", decimalSeparator)\n : `${integer}${Number.parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : \"\"}`\n : \"0.00\";\n\n return `${currencyPosition === \"start\" ? currency : \"\"}${parsedValue}${\n currencyPosition === \"end\" ? currency : \"\"\n }`;\n }\n\n formatBigIntToSafeValue(value: bigint, decimal?: number) {\n const bigIntDecimal = decimal || this.decimal || DEFAULT_DECIMAL;\n const decimalToUseForConversion = Math.max(\n bigIntDecimal,\n decimalFromMultiplier(this.decimalMultiplier),\n );\n const isNegative = value < 0n;\n\n const valueString = value.toString().substring(isNegative ? 1 : 0);\n const padLength = decimalToUseForConversion - (valueString.length - 1);\n\n const parsedValueString = padLength > 0 ? \"0\".repeat(padLength) + valueString : valueString;\n\n const decimalIndex = parsedValueString.length - decimalToUseForConversion;\n let decimalString = parsedValueString.slice(-decimalToUseForConversion);\n\n // Check if we need to round up\n if (Number.parseInt(decimalString[bigIntDecimal]) >= 5) {\n // Increment the last decimal place and slice off the rest\n decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(\n Number.parseInt(decimalString[bigIntDecimal - 1]) + 1\n ).toString()}`;\n } else {\n // Just slice off the extra digits\n decimalString = decimalString.substring(0, bigIntDecimal);\n }\n\n return `${isNegative ? \"-\" : \"\"}${parsedValueString.slice(\n 0,\n decimalIndex,\n )}.${decimalString}`.replace(/\\.?0*$/, \"\");\n }\n\n #arithmetics(method: \"add\" | \"sub\" | \"mul\" | \"div\", ...args: InitialisationValueType[]): this {\n const precisionDecimal = this.#retrievePrecisionDecimal(this, ...args);\n const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));\n const precisionDecimalMultiplier = toMultiplier(decimal);\n\n const result = args.reduce(\n (acc: bigint, arg) => {\n const value = this.getBigIntValue(arg, decimal);\n\n switch (method) {\n case \"add\":\n return acc + value;\n case \"sub\":\n return acc - value;\n /**\n * Multiplication & division would end up with wrong result if we don't adjust the value\n * 200000000n * 200000000n => 40000000000000000n\n * 200000000n / 200000000n => 1n\n * So we do the following:\n * 200000000n * 200000000n = 40000000000000000n / 100000000n (decimals) => 400000000n\n * (200000000n * 100000000n (decimals)) / 200000000n => 100000000n\n */\n case \"mul\":\n return (acc * value) / precisionDecimalMultiplier;\n case \"div\": {\n if (value === 0n) throw new RangeError(\"Division by zero\");\n return (acc * precisionDecimalMultiplier) / value;\n }\n default:\n return acc;\n }\n },\n //normalize is to precision multiplier base\n (this.bigIntValue * precisionDecimalMultiplier) / this.decimalMultiplier,\n );\n\n const value = formatBigIntToSafeValue({\n bigIntDecimal: decimal,\n decimal,\n value: result,\n });\n\n // @ts-expect-error False positive\n return new this.constructor({\n decimalMultiplier: toMultiplier(decimal),\n decimal: this.decimal,\n value,\n identifier: this.toString(),\n });\n }\n\n #comparison(method: \"gt\" | \"gte\" | \"lt\" | \"lte\" | \"eqValue\", ...args: InitialisationValueType[]) {\n const decimal = this.#retrievePrecisionDecimal(this, ...args);\n const value = this.getBigIntValue(args[0], decimal);\n const compareToValue = this.getBigIntValue(this, decimal);\n\n switch (method) {\n case \"gt\":\n return compareToValue > value;\n case \"gte\":\n return compareToValue >= value;\n case \"lt\":\n return compareToValue < value;\n case \"lte\":\n return compareToValue <= value;\n case \"eqValue\":\n return compareToValue === value;\n }\n }\n\n #setValue(value: InitialisationValueType) {\n const safeValue = toSafeValue(value) || \"0\";\n this.bigIntValue = this.#toBigInt(safeValue);\n }\n\n #retrievePrecisionDecimal(...args: InitialisationValueType[]) {\n const decimals = args\n .map((arg) => {\n const isObject = typeof arg === \"object\";\n const value = isObject\n ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier)\n : getFloatDecimals(toSafeValue(arg));\n\n return value;\n })\n .filter(Boolean) as number[];\n\n return Math.max(...decimals, DEFAULT_DECIMAL);\n }\n\n #toBigInt(value: string, decimal?: number) {\n const multiplier = decimal ? toMultiplier(decimal) : this.decimalMultiplier;\n const padDecimal = decimalFromMultiplier(multiplier);\n const [integerPart = \"\", decimalPart = \"\"] = value.split(\".\");\n\n return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, \"0\")}`);\n }\n}\n\nconst numberFormatter = Intl.NumberFormat(\"fullwide\", {\n useGrouping: false,\n maximumFractionDigits: 20,\n});\n\nfunction toSafeValue(value: InitialisationValueType) {\n const parsedValue =\n typeof value === \"number\" ? numberFormatter.format(value) : getStringValue(value);\n const splitValue = `${parsedValue}`.replaceAll(\",\", \".\").split(\".\");\n\n return splitValue.length > 1\n ? `${splitValue.slice(0, -1).join(\"\")}.${splitValue.at(-1)}`\n : splitValue[0];\n}\n\nfunction getFloatDecimals(value: string) {\n const decimals = value.split(\".\")[1]?.length || 0;\n return Math.max(decimals, DEFAULT_DECIMAL);\n}\n\nfunction getStringValue(param: SKBigIntParams) {\n return typeof param === \"object\"\n ? \"getValue\" in param\n ? param.getValue(\"string\")\n : param.value\n : param;\n}\n","import { BigIntArithmetics, formatBigIntToSafeValue } from \"./bigIntArithmetics.ts\";\n\nexport type SwapKitValueType = BigIntArithmetics | string | number;\n\nexport class SwapKitNumber extends BigIntArithmetics {\n eq(value: SwapKitValueType) {\n return this.eqValue(value);\n }\n\n static fromBigInt(value: bigint, decimal?: number) {\n return new SwapKitNumber({\n decimal,\n value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }),\n });\n }\n}\n","import { BaseDecimal, Chain, ChainToChainId } from \"@swapkit/types\";\n\nimport type { CommonAssetString } from \"../helpers/asset.ts\";\nimport { getAssetType, getCommonAssetInfo, getDecimal, isGasAsset } from \"../helpers/asset.ts\";\nimport { validateIdentifier } from \"../helpers/validators.ts\";\nimport type { TokenNames, TokenTax } from \"../types.ts\";\n\nimport type { NumberPrimitives } from \"./bigIntArithmetics.ts\";\nimport { BigIntArithmetics, formatBigIntToSafeValue } from \"./bigIntArithmetics.ts\";\nimport { SwapKitNumber, type SwapKitValueType } from \"./swapKitNumber.ts\";\n\nconst staticTokensMap = new Map<\n TokenNames,\n { tax?: TokenTax; decimal: number; identifier: string }\n>();\n\nexport class AssetValue extends BigIntArithmetics {\n address?: string;\n chain: Chain;\n isGasAsset = false;\n isSynthetic = false;\n symbol: string;\n tax?: TokenTax;\n ticker: string;\n type: ReturnType<typeof getAssetType>;\n\n constructor({\n value,\n decimal,\n tax,\n chain,\n symbol,\n identifier,\n }: { decimal: number; value: SwapKitValueType; tax?: TokenTax } & (\n | { chain: Chain; symbol: string; identifier?: never }\n | { identifier: string; chain?: never; symbol?: never }\n )) {\n super(typeof value === \"object\" ? value : { decimal, value });\n\n const assetInfo = getAssetInfo(identifier || `${chain}.${symbol}`);\n\n this.type = getAssetType(assetInfo);\n this.tax = tax;\n this.chain = assetInfo.chain;\n this.ticker = assetInfo.ticker;\n this.symbol = assetInfo.symbol;\n this.address = assetInfo.address;\n this.isSynthetic = assetInfo.isSynthetic;\n this.isGasAsset = assetInfo.isGasAsset;\n }\n\n toString() {\n return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;\n }\n\n toUrl() {\n return this.isSynthetic ? `${this.chain}.${this.symbol.replace(\"/\", \".\")}` : this.toString();\n }\n\n eq({ chain, symbol }: { chain: Chain; symbol: string }) {\n return this.chain === chain && this.symbol === symbol;\n }\n\n chainId() {\n return ChainToChainId[this.chain];\n }\n\n // THOR.RUNE\n // THOR.ETH.ETH\n // ETH.THOR-0x1234567890\n static fromUrl(urlAsset: string, value: NumberPrimitives = 0) {\n const [chain, ticker, symbol] = urlAsset.split(\".\");\n if (!(chain && ticker)) throw new Error(\"Invalid asset url\");\n\n const assetString =\n chain === Chain.THORChain && symbol ? `${chain}.${ticker}/${symbol}` : urlAsset;\n\n return createAssetValue(assetString, value);\n }\n\n static fromString(assetString: string, value: NumberPrimitives = 0) {\n return createAssetValue(assetString, value);\n }\n static fromIdentifier(\n assetString:\n | `${Chain}.${string}`\n | `${Chain}/${string}`\n | `${Chain}.${string}-${string}`\n | TokenNames,\n value: NumberPrimitives = 0,\n ) {\n return createAssetValue(assetString, value);\n }\n\n static fromStringSync(assetString: string, value: NumberPrimitives = 0) {\n const { chain, isSynthetic } = getAssetInfo(assetString);\n const tokenInfo = staticTokensMap.get(assetString.toUpperCase() as TokenNames);\n\n if (isSynthetic) return createSyntheticAssetValue(assetString, value);\n // TODO: write logger that will only run in dev mode with some flag\n // if (!tokenInfo) {\n // console.error(\n // `Asset ${assetString} is not loaded. Use AssetValue.loadStaticAssets() to load it`,\n // );\n // }\n\n const { tax, decimal, identifier } = tokenInfo || {\n decimal: BaseDecimal[chain],\n identifier: assetString,\n };\n\n return new AssetValue({\n tax,\n value: safeValue(value, decimal),\n identifier: isSynthetic ? assetString : identifier,\n decimal: isSynthetic ? 8 : decimal,\n });\n }\n\n static async fromStringWithBase(\n assetString: string,\n value: NumberPrimitives = 0,\n baseDecimal: number = BaseDecimal.THOR,\n ) {\n const shiftedAmount = BigIntArithmetics.shiftDecimals({\n value: SwapKitNumber.fromBigInt(BigInt(value)),\n from: 0,\n to: baseDecimal,\n }).getBaseValue(\"string\");\n const assetValue = await AssetValue.fromString(assetString, value);\n\n return assetValue.set(shiftedAmount);\n }\n\n static fromStringWithBaseSync(\n assetString: string,\n value: NumberPrimitives = 0,\n baseDecimal: number = BaseDecimal.THOR,\n ) {\n const { chain, isSynthetic } = getAssetInfo(assetString);\n const tokenInfo = staticTokensMap.get(assetString.toUpperCase() as TokenNames);\n\n if (isSynthetic) return createSyntheticAssetValue(assetString, value);\n\n const { tax, decimal, identifier } = tokenInfo || {\n decimal: BaseDecimal[chain],\n identifier: assetString,\n };\n\n return new AssetValue({\n tax,\n value: safeValue(BigInt(value), baseDecimal),\n identifier,\n decimal,\n });\n }\n\n static fromIdentifierSync(assetString: TokenNames, value: NumberPrimitives = 0) {\n const { chain, isSynthetic } = getAssetInfo(assetString);\n const tokenInfo = staticTokensMap.get(assetString);\n\n if (isSynthetic) return createSyntheticAssetValue(assetString, value);\n // TODO: write logger that will only run in dev mode with some flag\n // if (!tokenInfo) {\n // console.error(\n // `Asset ${assetString} is not loaded. - Loading with base Chain. Use AssetValue.loadStaticAssets() to load it`,\n // );\n // }\n\n const { tax, decimal, identifier } = tokenInfo || {\n decimal: BaseDecimal[chain],\n identifier: assetString,\n };\n return new AssetValue({ tax, decimal, identifier, value: safeValue(value, decimal) });\n }\n\n static fromChainOrSignature(assetString: CommonAssetString, value: NumberPrimitives = 0) {\n const { decimal, identifier } = getCommonAssetInfo(assetString);\n return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });\n }\n\n static loadStaticAssets() {\n return new Promise<{ ok: true } | { ok: false; message: string; error: any }>(\n (resolve, reject) => {\n try {\n import(\"@swapkit/tokens\").then((tokenPackages) => {\n for (const tokenList of Object.values(tokenPackages)) {\n for (const { identifier, chain, ...rest } of tokenList.tokens) {\n staticTokensMap.set(identifier.toUpperCase() as TokenNames, {\n identifier,\n decimal: \"decimals\" in rest ? rest.decimals : BaseDecimal[chain as Chain],\n });\n }\n }\n\n resolve({ ok: true });\n });\n } catch (error) {\n console.error(error);\n reject({\n ok: false,\n error,\n message:\n \"Couldn't load static assets. Ensure you have installed @swapkit/tokens package\",\n });\n }\n },\n );\n }\n}\n\nexport function getMinAmountByChain(chain: Chain) {\n const asset = AssetValue.fromChainOrSignature(chain);\n\n switch (chain) {\n case Chain.Bitcoin:\n case Chain.Litecoin:\n case Chain.BitcoinCash:\n return asset.set(0.00010001);\n\n case Chain.Dogecoin:\n return asset.set(1.00000001);\n\n case Chain.Avalanche:\n case Chain.Ethereum:\n return asset.set(0.00000001);\n\n case Chain.THORChain:\n case Chain.Maya:\n return asset.set(0);\n\n case Chain.Cosmos:\n return asset.set(0.000001);\n\n default:\n return asset.set(0.00000001);\n }\n}\n\nasync function createAssetValue(identifier: string, value: NumberPrimitives = 0) {\n validateIdentifier(identifier);\n\n const staticToken = staticTokensMap.get(identifier.toUpperCase() as TokenNames);\n const decimal = staticToken?.decimal || (await getDecimal(getAssetInfo(identifier)));\n if (!staticToken) {\n staticTokensMap.set(identifier.toUpperCase() as TokenNames, { identifier, decimal });\n }\n\n return new AssetValue({ decimal, value: safeValue(value, decimal), identifier });\n}\n\nfunction createSyntheticAssetValue(identifier: string, value: NumberPrimitives = 0) {\n const [synthChain, symbol] =\n identifier.split(\".\")[0].toUpperCase() === Chain.THORChain\n ? identifier.split(\".\").slice(1).join().split(\"/\")\n : identifier.split(\"/\");\n\n if (!(synthChain && symbol)) throw new Error(\"Invalid asset identifier\");\n\n return new AssetValue({\n decimal: 8,\n value: safeValue(value, 8),\n identifier: `${Chain.THORChain}.${synthChain}/${symbol}`,\n });\n}\n\nfunction safeValue(value: NumberPrimitives, decimal: number) {\n return typeof value === \"bigint\"\n ? formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })\n : value;\n}\n\n// TODO refactor & split into smaller functions\nfunction getAssetInfo(identifier: string) {\n const isSynthetic = identifier.slice(0, 14).includes(\"/\");\n\n const [synthChain, synthSymbol] =\n identifier.split(\".\")[0].toUpperCase() === Chain.THORChain\n ? identifier.split(\".\").slice(1).join().split(\"/\")\n : identifier.split(\"/\");\n\n if (isSynthetic && !(synthChain && synthSymbol)) throw new Error(\"Invalid asset identifier\");\n\n const adjustedIdentifier =\n identifier.includes(\".\") && !isSynthetic ? identifier : `${Chain.THORChain}.${synthSymbol}`;\n\n const [chain, ...rest] = adjustedIdentifier.split(\".\") as [Chain, string];\n const [ticker, address] = (isSynthetic ? synthSymbol : rest.join(\".\")).split(\"-\") as [\n string,\n string?,\n ];\n const symbol = isSynthetic ? synthSymbol : rest.join(\".\");\n\n return {\n address: address?.toLowerCase(),\n chain,\n isGasAsset: isGasAsset({ chain, symbol }),\n isSynthetic,\n symbol:\n (isSynthetic ? `${synthChain}/` : \"\") +\n (address ? `${ticker}-${address?.toLowerCase() ?? \"\"}` : symbol),\n ticker,\n };\n}\n","const errorMessages = {\n /**\n * Core\n */\n core_wallet_connection_not_found: 10001,\n core_estimated_max_spendable_chain_not_supported: 10002,\n core_extend_error: 10003,\n core_inbound_data_not_found: 10004,\n core_approve_asset_address_or_from_not_found: 10005,\n core_plugin_not_found: 10006,\n core_chain_halted: 10099,\n /**\n * Core - Wallet Connection\n */\n core_wallet_xdefi_not_installed: 10101,\n core_wallet_evmwallet_not_installed: 10102,\n core_wallet_walletconnect_not_installed: 10103,\n core_wallet_keystore_not_installed: 10104,\n core_wallet_ledger_not_installed: 10105,\n core_wallet_trezor_not_installed: 10106,\n core_wallet_keplr_not_installed: 10107,\n core_wallet_okx_not_installed: 10108,\n core_wallet_keepkey_not_installed: 10109,\n /**\n * Core - Swap\n */\n core_swap_invalid_params: 10200,\n core_swap_route_not_complete: 10201,\n core_swap_asset_not_recognized: 10202,\n core_swap_contract_not_found: 10203,\n core_swap_route_transaction_not_found: 10204,\n core_swap_contract_not_supported: 10205,\n core_swap_transaction_error: 10206,\n core_swap_quote_mode_not_supported: 10207,\n /**\n * Core - Transaction\n */\n core_transaction_deposit_error: 10301,\n core_transaction_create_liquidity_rune_error: 10302,\n core_transaction_create_liquidity_asset_error: 10303,\n core_transaction_create_liquidity_invalid_params: 10304,\n core_transaction_add_liquidity_invalid_params: 10305,\n core_transaction_add_liquidity_no_rune_address: 10306,\n core_transaction_add_liquidity_rune_error: 10307,\n core_transaction_add_liquidity_asset_error: 10308,\n core_transaction_withdraw_error: 10309,\n core_transaction_deposit_to_pool_error: 10310,\n core_transaction_deposit_insufficient_funds_error: 10311,\n core_transaction_deposit_gas_error: 10312,\n core_transaction_invalid_sender_address: 10313,\n core_transaction_deposit_server_error: 10314,\n core_transaction_user_rejected: 10315,\n\n /**\n * Wallets\n */\n wallet_ledger_connection_error: 20001,\n wallet_ledger_connection_claimed: 20002,\n wallet_ledger_get_address_error: 20003,\n wallet_ledger_device_not_found: 20004,\n wallet_ledger_device_locked: 20005,\n\n /**\n * Chainflip\n */\n chainflip_channel_error: 30001,\n chainflip_broker_recipient_error: 30002,\n\n /**\n * THORChain\n */\n\n /**\n * Helpers\n */\n helpers_number_different_decimals: 99101,\n} as const;\n\nexport type ErrorKeys = keyof typeof errorMessages;\n\nexport class SwapKitError extends Error {\n constructor(errorKey: ErrorKeys, sourceError?: any) {\n if (sourceError) {\n console.error(sourceError, {\n stack: sourceError?.stack,\n message: sourceError?.message,\n });\n }\n\n super(errorKey, {\n cause: { code: errorMessages[errorKey], message: errorKey },\n });\n Object.setPrototypeOf(this, SwapKitError.prototype);\n }\n}\n"],"names":["getDecimalMethodHex","getContractDecimals","chain","to","result","RequestClient","ChainToRPC","error","BaseDecimal","getETHAssetDecimal","symbol","Chain","address","getAVAXAssetDecimal","getBSCAssetDecimal","getDecimal","gasFeeMultiplier","FeeOption","isGasAsset","getCommonAssetInfo","assetString","getAssetType","assetFromString","symbolArray","synth","ticker","_a","potentialScamRegex","evmAssetHasAddress","EVMChains","filterAssets","tokens","value","findAssetBy","params","tokenPackages","tokenList","identifier","tokenChain","rest","getAsymmetricRuneShare","liquidityUnits","poolUnits","runeDepth","s","toTCSwapKitNumber","T","A","part1","part2","part3","part4","part5","getAsymmetricAssetShare","assetDepth","numerator","getAsymmetricRuneWithdrawAmount","percent","getAsymmetricAssetWithdrawAmount","SwapKitNumber","getSymmetricPoolShare","getSymmetricWithdraw","name","getEstimatedPoolShare","runeAmount","assetAmount","R","P","runeAddAmount","assetAddAmount","rA","aR","ra","RA","denominator","liquidityUnitsAfterAdd","estimatedLiquidityUnits","newPoolUnits","getLiquiditySlippage","getMemoFor","memoType","options","MemoType","unbondAmount","owner","singleSide","basisPoints","targetAssetString","shortenedSymbol","target","asset","getTHORNameCost","year","getMAYANameCost","validateTHORName","regex","validateMAYAName","derivationPathToString","network","chainId","account","change","index","supportedChains","validateIdentifier","uppercasedIdentifier","synthChain","DEFAULT_DECIMAL","toMultiplier","decimal","decimalFromMultiplier","multiplier","formatBigIntToSafeValue","bigIntDecimal","isNegative","valueString","padLength","decimalIndex","decimalString","_BigIntArithmetics","__privateAdd","_arithmetics","_comparison","_setValue","_retrievePrecisionDecimal","_toBigInt","__publicField","getStringValue","isComplex","getFloatDecimals","toSafeValue","__privateMethod","setValue_fn","from","args","arithmetics_fn","comparison_fn","type","divisor","baseValue","stringValue","safeValue","toBigInt_fn","significantDigits","int","dec","integer","trimmedDecimal","slicedDecimal","fixedDigits","digits","abbreviations","tier","suffix","scale","currency","currencyPosition","decimalSeparator","thousandSeparator","parsedValue","decimalToUseForConversion","parsedValueString","method","precisionDecimal","retrievePrecisionDecimal_fn","precisionDecimalMultiplier","acc","arg","compareToValue","decimals","padDecimal","integerPart","decimalPart","BigIntArithmetics","numberFormatter","splitValue","param","staticTokensMap","AssetValue","tax","assetInfo","getAssetInfo","ChainToChainId","urlAsset","createAssetValue","isSynthetic","tokenInfo","createSyntheticAssetValue","baseDecimal","shiftedAmount","resolve","reject","getMinAmountByChain","staticToken","synthSymbol","adjustedIdentifier","errorMessages","SwapKitError","errorKey","sourceError"],"mappings":"u+BAKMA,GAAsB,aAStBC,EAAsB,MAAO,CAAE,MAAAC,EAAO,GAAAC,KAA0C,CAChF,GAAA,CACI,KAAA,CAAE,OAAAC,GAAW,MAAMC,EAAAA,cAAc,KAAyBC,EAAAA,WAAWJ,CAAK,EAAG,CACjF,QAAS,CACP,OAAQ,MACR,eAAgB,mBAChB,gBAAiB,UACnB,EACA,KAAM,KAAK,UAAU,CACnB,GAAI,GACJ,QAAS,MACT,OAAQ,WACR,OAAQ,CAAC,CAAE,GAAIC,EAAG,cAAe,KAAMH,EAAoB,EAAG,QAAQ,CAAA,CACvE,CAAA,CACF,EAED,OAAO,OAAO,SAAS,OAAOI,CAAM,EAAE,UAAU,QACzCG,EAAO,CACd,eAAQ,MAAMA,CAAK,EACZC,EAAAA,YAAYN,CAAK,CAC1B,CACF,EAEMO,GAAsBC,GAAmB,CAC7C,GAAIA,IAAWC,EAAAA,MAAM,SAAU,OAAOH,EAAAA,YAA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