@pioneer-platform/helpers 4.8.0 → 4.8.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @pioneer-platform/helpers
2
2
 
3
+ ## 4.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - clean packages
8
+ - Updated dependencies
9
+ - @pioneer-platform/tokens@0.8.1
10
+
3
11
  ## 4.8.0
4
12
 
5
13
  ### Minor Changes
@@ -1,9 +1,10 @@
1
- import { Chain, FeeOption } from '@coinmasters/types';
1
+ import { Chain } from '@pioneer-platform/pioneer-caip';
2
+ import { FeeOption } from '@pioneer-platform/pioneer-types';
2
3
  export type CommonAssetString = 'MAYA.MAYA' | 'ETH.THOR' | 'ETH.vTHOR' | Chain;
3
4
  export declare const getDecimal: ({ chain, symbol }: {
4
5
  chain: Chain;
5
6
  symbol: string;
6
- }) => Promise<number>;
7
+ }) => Promise<any>;
7
8
  export declare const gasFeeMultiplier: Record<FeeOption, number>;
8
9
  export declare const isGasAsset: ({ chain, symbol }: {
9
10
  chain: Chain;
@@ -10,12 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.filterAssets = exports.assetFromString = exports.getAssetType = exports.getCommonAssetInfo = exports.isGasAsset = exports.gasFeeMultiplier = exports.getDecimal = void 0;
13
- const types_1 = require("@coinmasters/types");
13
+ const pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
14
+ const pioneer_types_1 = require("@pioneer-platform/pioneer-types");
14
15
  const index_1 = require("../index");
15
16
  const getDecimalMethodHex = '0x313ce567';
16
17
  const getContractDecimals = (_a) => __awaiter(void 0, [_a], void 0, function* ({ chain, to }) {
17
18
  try {
18
- const { result } = yield index_1.RequestClient.post(types_1.ChainToRPC[chain], {
19
+ const { result } = yield index_1.RequestClient.post(pioneer_caip_1.ChainToRPC[chain], {
19
20
  headers: {
20
21
  accept: '*/*',
21
22
  'content-type': 'application/json',
@@ -33,76 +34,76 @@ const getContractDecimals = (_a) => __awaiter(void 0, [_a], void 0, function* ({
33
34
  catch (error) {
34
35
  console.error(error);
35
36
  // @ts-ignore
36
- return types_1.BaseDecimal[chain];
37
+ return pioneer_caip_1.BaseDecimal[chain];
37
38
  }
38
39
  });
39
40
  const getETHAssetDecimal = (symbol) => __awaiter(void 0, void 0, void 0, function* () {
40
- if (symbol === types_1.Chain.Ethereum)
41
- return types_1.BaseDecimal.ETH;
41
+ if (symbol === pioneer_caip_1.Chain.Ethereum)
42
+ return pioneer_caip_1.BaseDecimal.ETH;
42
43
  const [, address] = symbol.split('-');
43
44
  return (address === null || address === void 0 ? void 0 : address.startsWith('0x'))
44
- ? getContractDecimals({ chain: types_1.Chain.Ethereum, to: address })
45
- : types_1.BaseDecimal.ETH;
45
+ ? getContractDecimals({ chain: pioneer_caip_1.Chain.Ethereum, to: address })
46
+ : pioneer_caip_1.BaseDecimal.ETH;
46
47
  });
47
48
  const getAVAXAssetDecimal = (symbol) => __awaiter(void 0, void 0, void 0, function* () {
48
49
  const [, address] = symbol.split('-');
49
50
  return (address === null || address === void 0 ? void 0 : address.startsWith('0x'))
50
- ? getContractDecimals({ chain: types_1.Chain.Avalanche, to: address.toLowerCase() })
51
- : types_1.BaseDecimal.AVAX;
51
+ ? getContractDecimals({ chain: pioneer_caip_1.Chain.Avalanche, to: address.toLowerCase() })
52
+ : pioneer_caip_1.BaseDecimal.AVAX;
52
53
  });
53
54
  const getBSCAssetDecimal = (symbol) => __awaiter(void 0, void 0, void 0, function* () {
54
- if (symbol === types_1.Chain.BinanceSmartChain)
55
- return types_1.BaseDecimal.BSC;
56
- return types_1.BaseDecimal.BSC;
55
+ if (symbol === pioneer_caip_1.Chain.BinanceSmartChain)
56
+ return pioneer_caip_1.BaseDecimal.BSC;
57
+ return pioneer_caip_1.BaseDecimal.BSC;
57
58
  });
58
59
  const getDecimal = (_a) => __awaiter(void 0, [_a], void 0, function* ({ chain, symbol }) {
59
60
  switch (chain) {
60
- case types_1.Chain.Ethereum:
61
+ case pioneer_caip_1.Chain.Ethereum:
61
62
  return getETHAssetDecimal(symbol);
62
- case types_1.Chain.Avalanche:
63
+ case pioneer_caip_1.Chain.Avalanche:
63
64
  return getAVAXAssetDecimal(symbol);
64
- case types_1.Chain.BinanceSmartChain:
65
+ case pioneer_caip_1.Chain.BinanceSmartChain:
65
66
  return getBSCAssetDecimal(symbol);
66
67
  default:
67
68
  // @ts-ignore
68
- return types_1.BaseDecimal[chain];
69
+ return pioneer_caip_1.BaseDecimal[chain];
69
70
  }
70
71
  });
71
72
  exports.getDecimal = getDecimal;
72
73
  exports.gasFeeMultiplier = {
73
- [types_1.FeeOption.Average]: 1.2,
74
- [types_1.FeeOption.Fast]: 1.5,
75
- [types_1.FeeOption.Fastest]: 2,
74
+ [pioneer_types_1.FeeOption.Average]: 1.2,
75
+ [pioneer_types_1.FeeOption.Fast]: 1.5,
76
+ [pioneer_types_1.FeeOption.Fastest]: 2,
76
77
  };
77
78
  const isGasAsset = ({ chain, symbol }) => {
78
79
  switch (chain) {
79
- case types_1.Chain.Bitcoin:
80
- case types_1.Chain.BitcoinCash:
81
- case types_1.Chain.Dash:
82
- case types_1.Chain.Digibyte:
83
- case types_1.Chain.Zcash:
84
- case types_1.Chain.Ripple:
85
- case types_1.Chain.Litecoin:
86
- case types_1.Chain.Dogecoin:
87
- case types_1.Chain.Ethereum:
88
- case types_1.Chain.Avalanche:
80
+ case pioneer_caip_1.Chain.Bitcoin:
81
+ case pioneer_caip_1.Chain.BitcoinCash:
82
+ case pioneer_caip_1.Chain.Dash:
83
+ case pioneer_caip_1.Chain.Digibyte:
84
+ case pioneer_caip_1.Chain.Zcash:
85
+ case pioneer_caip_1.Chain.Ripple:
86
+ case pioneer_caip_1.Chain.Litecoin:
87
+ case pioneer_caip_1.Chain.Dogecoin:
88
+ case pioneer_caip_1.Chain.Ethereum:
89
+ case pioneer_caip_1.Chain.Avalanche:
89
90
  return symbol === chain;
90
- case types_1.Chain.Arbitrum:
91
- case types_1.Chain.Optimism:
92
- case types_1.Chain.Base:
91
+ case pioneer_caip_1.Chain.Arbitrum:
92
+ case pioneer_caip_1.Chain.Optimism:
93
+ case pioneer_caip_1.Chain.Base:
93
94
  return 'ETH' === symbol;
94
95
  // @ts-ignore
95
- case types_1.Chain.Mayachain:
96
+ case pioneer_caip_1.Chain.Mayachain:
96
97
  return symbol === 'CACAO';
97
- case types_1.Chain.Kujira:
98
+ case pioneer_caip_1.Chain.Kujira:
98
99
  return symbol === 'KUJI';
99
- case types_1.Chain.Cosmos:
100
+ case pioneer_caip_1.Chain.Cosmos:
100
101
  return symbol === 'ATOM';
101
- case types_1.Chain.Polygon:
102
+ case pioneer_caip_1.Chain.Polygon:
102
103
  return symbol === 'MATIC';
103
- case types_1.Chain.BinanceSmartChain:
104
+ case pioneer_caip_1.Chain.BinanceSmartChain:
104
105
  return symbol === 'BNB';
105
- case types_1.Chain.THORChain:
106
+ case pioneer_caip_1.Chain.THORChain:
106
107
  return symbol === 'RUNE';
107
108
  }
108
109
  };
@@ -113,36 +114,36 @@ const getCommonAssetInfo = (assetString) => {
113
114
  return { identifier: 'ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044', decimal: 18 };
114
115
  case 'ETH.vTHOR':
115
116
  return { identifier: 'ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d', decimal: 18 };
116
- case types_1.Chain.Cosmos:
117
- return { identifier: 'GAIA.ATOM', decimal: types_1.BaseDecimal[assetString] };
118
- case types_1.Chain.THORChain:
119
- return { identifier: 'THOR.RUNE', decimal: types_1.BaseDecimal[assetString] };
120
- case types_1.Chain.BinanceSmartChain:
121
- return { identifier: 'BSC.BNB', decimal: types_1.BaseDecimal[assetString] };
117
+ case pioneer_caip_1.Chain.Cosmos:
118
+ return { identifier: 'GAIA.ATOM', decimal: pioneer_caip_1.BaseDecimal[assetString] };
119
+ case pioneer_caip_1.Chain.THORChain:
120
+ return { identifier: 'THOR.RUNE', decimal: pioneer_caip_1.BaseDecimal[assetString] };
121
+ case pioneer_caip_1.Chain.BinanceSmartChain:
122
+ return { identifier: 'BSC.BNB', decimal: pioneer_caip_1.BaseDecimal[assetString] };
122
123
  // @ts-ignore
123
- case types_1.Chain.Mayachain:
124
- return { identifier: 'MAYA.CACAO', decimal: types_1.BaseDecimal.MAYA };
124
+ case pioneer_caip_1.Chain.Mayachain:
125
+ return { identifier: 'MAYA.CACAO', decimal: pioneer_caip_1.BaseDecimal.MAYA };
125
126
  case 'MAYA.MAYA':
126
127
  return { identifier: 'MAYA.MAYA', decimal: 4 };
127
- case types_1.Chain.Arbitrum:
128
+ case pioneer_caip_1.Chain.Arbitrum:
128
129
  return { identifier: 'ARB.ETH', decimal: 18 };
129
- case types_1.Chain.Base:
130
+ case pioneer_caip_1.Chain.Base:
130
131
  return { identifier: 'BASE.ETH', decimal: 18 };
131
- case types_1.Chain.Optimism:
132
+ case pioneer_caip_1.Chain.Optimism:
132
133
  return { identifier: 'OP.ETH', decimal: 18 };
133
- case types_1.Chain.Avalanche:
134
+ case pioneer_caip_1.Chain.Avalanche:
134
135
  return { identifier: 'AVAX.ETH', decimal: 18 };
135
- case types_1.Chain.Ripple:
136
- case types_1.Chain.Kujira:
137
- case types_1.Chain.BitcoinCash:
138
- case types_1.Chain.Zcash:
139
- case types_1.Chain.Dash:
140
- case types_1.Chain.Litecoin:
141
- case types_1.Chain.Dogecoin:
142
- case types_1.Chain.Polygon:
143
- case types_1.Chain.Bitcoin:
144
- case types_1.Chain.Ethereum:
145
- return { identifier: `${assetString}.${assetString}`, decimal: types_1.BaseDecimal[assetString] };
136
+ case pioneer_caip_1.Chain.Ripple:
137
+ case pioneer_caip_1.Chain.Kujira:
138
+ case pioneer_caip_1.Chain.BitcoinCash:
139
+ case pioneer_caip_1.Chain.Zcash:
140
+ case pioneer_caip_1.Chain.Dash:
141
+ case pioneer_caip_1.Chain.Litecoin:
142
+ case pioneer_caip_1.Chain.Dogecoin:
143
+ case pioneer_caip_1.Chain.Polygon:
144
+ case pioneer_caip_1.Chain.Bitcoin:
145
+ case pioneer_caip_1.Chain.Ethereum:
146
+ return { identifier: `${assetString}.${assetString}`, decimal: pioneer_caip_1.BaseDecimal[assetString] };
146
147
  }
147
148
  };
148
149
  exports.getCommonAssetInfo = getCommonAssetInfo;
@@ -150,35 +151,35 @@ const getAssetType = ({ chain, symbol }) => {
150
151
  if (symbol.includes('/'))
151
152
  return 'Synth';
152
153
  switch (chain) {
153
- case types_1.Chain.Bitcoin:
154
- case types_1.Chain.BitcoinCash:
155
- case types_1.Chain.Dogecoin:
156
- case types_1.Chain.Dash:
157
- case types_1.Chain.Zcash:
158
- case types_1.Chain.Litecoin:
154
+ case pioneer_caip_1.Chain.Bitcoin:
155
+ case pioneer_caip_1.Chain.BitcoinCash:
156
+ case pioneer_caip_1.Chain.Dogecoin:
157
+ case pioneer_caip_1.Chain.Dash:
158
+ case pioneer_caip_1.Chain.Zcash:
159
+ case pioneer_caip_1.Chain.Litecoin:
159
160
  // @ts-ignore
160
- case types_1.Chain.Mayachain:
161
- case types_1.Chain.THORChain:
161
+ case pioneer_caip_1.Chain.Mayachain:
162
+ case pioneer_caip_1.Chain.THORChain:
162
163
  return 'Native';
163
- case types_1.Chain.Osmosis:
164
+ case pioneer_caip_1.Chain.Osmosis:
164
165
  return 'Native';
165
- case types_1.Chain.Cosmos:
166
- return symbol === 'ATOM' ? 'Native' : types_1.Chain.Cosmos;
167
- case types_1.Chain.Kujira:
168
- return symbol === types_1.Chain.Kujira ? 'Native' : types_1.Chain.Kujira;
169
- case types_1.Chain.BinanceSmartChain:
170
- case types_1.Chain.Ethereum:
171
- return symbol === types_1.Chain.Ethereum ? 'Native' : 'ERC20';
172
- case types_1.Chain.Avalanche:
173
- return symbol === types_1.Chain.Avalanche ? 'Native' : types_1.Chain.Avalanche;
174
- case types_1.Chain.Polygon:
175
- return symbol === types_1.Chain.Polygon ? 'Native' : 'POLYGON';
176
- case types_1.Chain.Base:
177
- return symbol === types_1.Chain.Ethereum ? 'Native' : 'ERC20';
178
- case types_1.Chain.Arbitrum:
179
- return [types_1.Chain.Ethereum, types_1.Chain.Arbitrum].includes(symbol) ? 'Native' : 'ARBITRUM';
180
- case types_1.Chain.Optimism:
181
- return [types_1.Chain.Ethereum, types_1.Chain.Optimism].includes(symbol) ? 'Native' : 'OPTIMISM';
166
+ case pioneer_caip_1.Chain.Cosmos:
167
+ return symbol === 'ATOM' ? 'Native' : pioneer_caip_1.Chain.Cosmos;
168
+ case pioneer_caip_1.Chain.Kujira:
169
+ return symbol === pioneer_caip_1.Chain.Kujira ? 'Native' : pioneer_caip_1.Chain.Kujira;
170
+ case pioneer_caip_1.Chain.BinanceSmartChain:
171
+ case pioneer_caip_1.Chain.Ethereum:
172
+ return symbol === pioneer_caip_1.Chain.Ethereum ? 'Native' : 'ERC20';
173
+ case pioneer_caip_1.Chain.Avalanche:
174
+ return symbol === pioneer_caip_1.Chain.Avalanche ? 'Native' : pioneer_caip_1.Chain.Avalanche;
175
+ case pioneer_caip_1.Chain.Polygon:
176
+ return symbol === pioneer_caip_1.Chain.Polygon ? 'Native' : 'POLYGON';
177
+ case pioneer_caip_1.Chain.Base:
178
+ return symbol === pioneer_caip_1.Chain.Ethereum ? 'Native' : 'ERC20';
179
+ case pioneer_caip_1.Chain.Arbitrum:
180
+ return [pioneer_caip_1.Chain.Ethereum, pioneer_caip_1.Chain.Arbitrum].includes(symbol) ? 'Native' : 'ARBITRUM';
181
+ case pioneer_caip_1.Chain.Optimism:
182
+ return [pioneer_caip_1.Chain.Ethereum, pioneer_caip_1.Chain.Optimism].includes(symbol) ? 'Native' : 'OPTIMISM';
182
183
  }
183
184
  };
184
185
  exports.getAssetType = getAssetType;
@@ -194,7 +195,7 @@ exports.assetFromString = assetFromString;
194
195
  const potentialScamRegex = new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, 'gmi');
195
196
  const evmAssetHasAddress = (assetString) => {
196
197
  const [chain, symbol] = assetString.split('.');
197
- if (!types_1.EVMChainList.includes(chain))
198
+ if (!pioneer_caip_1.EVMChainList.includes(chain))
198
199
  return true;
199
200
  const [, address] = symbol.split('-');
200
201
  return (0, exports.isGasAsset)({ chain: chain, symbol }) || !!address;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLiquiditySlippage = exports.getEstimatedPoolShare = exports.getSymmetricWithdraw = exports.getSymmetricPoolShare = exports.getAsymmetricAssetWithdrawAmount = exports.getAsymmetricRuneWithdrawAmount = exports.getAsymmetricAssetShare = exports.getAsymmetricRuneShare = void 0;
4
- const types_1 = require("@coinmasters/types");
4
+ const pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
5
5
  const index_1 = require("../index");
6
6
  /**
7
7
  * Ref: https://gitlab.com/thorchain/thornode/-/issues/657
@@ -44,7 +44,7 @@ const getAsymmetricRuneWithdrawAmount = ({ percent, runeDepth, liquidityUnits, p
44
44
  exports.getAsymmetricRuneWithdrawAmount = getAsymmetricRuneWithdrawAmount;
45
45
  const getAsymmetricAssetWithdrawAmount = ({ percent, assetDepth, liquidityUnits, poolUnits, }) => (0, exports.getAsymmetricAssetShare)({ assetDepth, liquidityUnits, poolUnits }).mul(percent);
46
46
  exports.getAsymmetricAssetWithdrawAmount = getAsymmetricAssetWithdrawAmount;
47
- const toTCSwapKitNumber = (value) => index_1.SwapKitNumber.fromBigInt(BigInt(value), types_1.BaseDecimal.THOR);
47
+ const toTCSwapKitNumber = (value) => index_1.SwapKitNumber.fromBigInt(BigInt(value), pioneer_caip_1.BaseDecimal.THOR);
48
48
  const getSymmetricPoolShare = ({ liquidityUnits, poolUnits, runeDepth, assetDepth, }) => ({
49
49
  assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),
50
50
  runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits),
@@ -1,5 +1,5 @@
1
- import type { Chain } from '@coinmasters/types';
2
- import { MemoType } from '@coinmasters/types';
1
+ import type { Chain } from '@pioneer-platform/pioneer-caip';
2
+ import { MemoType } from '@pioneer-platform/pioneer-types';
3
3
  export type ThornameRegisterParam = {
4
4
  name: string;
5
5
  chain: string;
@@ -1,38 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMemoFor = void 0;
4
- const types_1 = require("@coinmasters/types");
4
+ const pioneer_types_1 = require("@pioneer-platform/pioneer-types");
5
5
  const getShortenedSymbol = ({ symbol, ticker, chain, }) => (chain === 'ETH' && ticker !== 'ETH' ? `${ticker}-${symbol.slice(-3)}` : symbol);
6
6
  const getMemoFor = (memoType, options) => {
7
7
  switch (memoType) {
8
- case types_1.MemoType.LEAVE:
9
- case types_1.MemoType.BOND: {
8
+ case pioneer_types_1.MemoType.LEAVE:
9
+ case pioneer_types_1.MemoType.BOND: {
10
10
  const { address } = options;
11
11
  return `${memoType}:${address}`;
12
12
  }
13
- case types_1.MemoType.UNBOND: {
13
+ case pioneer_types_1.MemoType.UNBOND: {
14
14
  const { address, unbondAmount } = options;
15
15
  return `${memoType}:${address}:${unbondAmount * Math.pow(10, 8)}`;
16
16
  }
17
- case types_1.MemoType.THORNAME_REGISTER: {
17
+ case pioneer_types_1.MemoType.THORNAME_REGISTER: {
18
18
  const { name, chain, address, owner } = options;
19
19
  return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ''}`;
20
20
  }
21
- case types_1.MemoType.DEPOSIT: {
21
+ case pioneer_types_1.MemoType.DEPOSIT: {
22
22
  const { chain, symbol, address, singleSide } = options;
23
23
  return singleSide
24
24
  ? `${memoType}:${chain}/${symbol}::t:0`
25
25
  : `${memoType}:${chain}.${symbol}:${address || ''}:t:0`;
26
26
  }
27
- case types_1.MemoType.WITHDRAW: {
27
+ case pioneer_types_1.MemoType.WITHDRAW: {
28
28
  const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } = options;
29
29
  const target = !singleSide && targetAssetString ? `:${targetAssetString}` : '';
30
30
  const shortenedSymbol = getShortenedSymbol({ chain, symbol, ticker });
31
31
  const assetDivider = singleSide ? '/' : '.';
32
32
  return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
33
33
  }
34
- case types_1.MemoType.OPEN_LOAN:
35
- case types_1.MemoType.CLOSE_LOAN: {
34
+ case pioneer_types_1.MemoType.OPEN_LOAN:
35
+ case pioneer_types_1.MemoType.CLOSE_LOAN: {
36
36
  const { asset, address } = options;
37
37
  return `${memoType}:${asset}:${address}`; //:${minAmount ? `${minAmount}` : ''}:t:0`;
38
38
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateIdentifier = void 0;
4
- const types_1 = require("@coinmasters/types");
5
- const supportedChains = Object.values(types_1.Chain);
4
+ const pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
5
+ const supportedChains = Object.values(pioneer_caip_1.Chain);
6
6
  const validateIdentifier = (identifier = '') => {
7
7
  const uppercasedIdentifier = identifier.toUpperCase();
8
8
  const [chain] = uppercasedIdentifier.split('.');
@@ -1,5 +1,5 @@
1
- import type { CoinGeckoList, MayaList, PancakeswapETHList, PancakeswapList, PangolinList, PioneerList, StargateARBList, SushiswapList, ThorchainList, TraderjoeList, UniswapList, WoofiList } from '@coinmasters/tokens';
2
- import { Chain } from '@coinmasters/types';
1
+ import type { CoinGeckoList, MayaList, PancakeswapETHList, PancakeswapList, PangolinList, PioneerList, StargateARBList, SushiswapList, ThorchainList, TraderjoeList, UniswapList, WoofiList } from '@pioneer-platform/tokens';
2
+ import { Chain } from '@pioneer-platform/pioneer-caip';
3
3
  import type { CommonAssetString } from '../helpers/asset';
4
4
  import { getAssetType } from '../helpers/asset';
5
5
  import type { NumberPrimitives } from './bigIntArithmetics';
@@ -55,7 +55,7 @@ var __rest = (this && this.__rest) || function (s, e) {
55
55
  Object.defineProperty(exports, "__esModule", { value: true });
56
56
  exports.getMinAmountByChain = exports.AssetValue = void 0;
57
57
  exports.safeValue = safeValue;
58
- const types_1 = require("@coinmasters/types");
58
+ const pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
59
59
  const asset_1 = require("../helpers/asset");
60
60
  const validators_1 = require("../helpers/validators");
61
61
  const bigIntArithmetics_1 = require("./bigIntArithmetics");
@@ -87,7 +87,7 @@ const getStaticToken = (identifier) => {
87
87
  throw new Error('Static assets not loaded, call await AssetValue.loadStaticAssets() first');
88
88
  }
89
89
  const tokenInfo = staticTokensMap.get(identifier.toUpperCase());
90
- return tokenInfo || { decimal: types_1.BaseDecimal.THOR, identifier: '' };
90
+ return tokenInfo || { decimal: pioneer_caip_1.BaseDecimal.THOR, identifier: '' };
91
91
  }
92
92
  catch (error) {
93
93
  console.error(tag + 'Error in getStaticToken:', error);
@@ -266,7 +266,7 @@ class AssetValue extends bigIntArithmetics_1.BigIntArithmetics {
266
266
  try {
267
267
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
268
268
  try {
269
- const _a = yield Promise.resolve().then(() => __importStar(require('@coinmasters/tokens'))), { ThorchainList: _ThorchainList, NativeList } = _a, tokensPackage = __rest(_a, ["ThorchainList", "NativeList"]);
269
+ const _a = yield Promise.resolve().then(() => __importStar(require('@pioneer-platform/tokens'))), { ThorchainList: _ThorchainList, NativeList } = _a, tokensPackage = __rest(_a, ["ThorchainList", "NativeList"]);
270
270
  const tokensMap = [NativeList, ...Object.values(tokensPackage)].reduce((acc, { tokens }) => {
271
271
  if (!tokens) {
272
272
  console.warn(tag + "No tokens found in the current package, skipping.");
@@ -275,7 +275,8 @@ class AssetValue extends bigIntArithmetics_1.BigIntArithmetics {
275
275
  // @ts-ignore
276
276
  tokens.forEach((_a) => {
277
277
  var { identifier, chain } = _a, rest = __rest(_a, ["identifier", "chain"]);
278
- const decimal = 'decimals' in rest ? rest.decimals : types_1.BaseDecimal[chain];
278
+ // @ts-ignore - BaseDecimal uses string keys but is typed as enum
279
+ const decimal = 'decimals' in rest ? rest.decimals : pioneer_caip_1.BaseDecimal[chain];
279
280
  acc.set(identifier, { identifier, decimal });
280
281
  });
281
282
  return acc;
@@ -288,7 +289,7 @@ class AssetValue extends bigIntArithmetics_1.BigIntArithmetics {
288
289
  reject({
289
290
  ok: false,
290
291
  error,
291
- message: "Couldn't load static assets. Ensure you have installed @coinmasters/tokens package",
292
+ message: "Couldn't load static assets. Ensure you have installed @pioneer-platform/tokens package",
292
293
  });
293
294
  }
294
295
  }));
@@ -305,21 +306,21 @@ const getMinAmountByChain = (chain) => {
305
306
  try {
306
307
  const asset = AssetValue.fromChainOrSignature(chain);
307
308
  switch (chain) {
308
- case types_1.Chain.Bitcoin:
309
- case types_1.Chain.Litecoin:
310
- case types_1.Chain.Dash:
311
- case types_1.Chain.Zcash:
312
- case types_1.Chain.BitcoinCash:
309
+ case pioneer_caip_1.Chain.Bitcoin:
310
+ case pioneer_caip_1.Chain.Litecoin:
311
+ case pioneer_caip_1.Chain.Dash:
312
+ case pioneer_caip_1.Chain.Zcash:
313
+ case pioneer_caip_1.Chain.BitcoinCash:
313
314
  return asset.set(0.00010001);
314
- case types_1.Chain.Dogecoin:
315
+ case pioneer_caip_1.Chain.Dogecoin:
315
316
  return asset.set(1.00000001);
316
- case types_1.Chain.Base:
317
- case types_1.Chain.Arbitrum:
318
- case types_1.Chain.Avalanche:
319
- case types_1.Chain.Ethereum:
317
+ case pioneer_caip_1.Chain.Base:
318
+ case pioneer_caip_1.Chain.Arbitrum:
319
+ case pioneer_caip_1.Chain.Avalanche:
320
+ case pioneer_caip_1.Chain.Ethereum:
320
321
  return asset.set(0.00000001);
321
- case types_1.Chain.THORChain:
322
- case types_1.Chain.Mayachain:
322
+ case pioneer_caip_1.Chain.THORChain:
323
+ case pioneer_caip_1.Chain.Mayachain:
323
324
  return asset.set(0.0000000001);
324
325
  default:
325
326
  return asset.set(0.00000001);
@@ -336,7 +337,7 @@ const getAssetInfo = (identifier) => {
336
337
  try {
337
338
  const isSynthetic = identifier.slice(0, 14).includes('/');
338
339
  const [synthChain, synthSymbol] = identifier.split('.').pop().split('/');
339
- const adjustedIdentifier = identifier.includes('.') && !isSynthetic ? identifier : `${types_1.Chain.THORChain}.${synthSymbol}`;
340
+ const adjustedIdentifier = identifier.includes('.') && !isSynthetic ? identifier : `${pioneer_caip_1.Chain.THORChain}.${synthSymbol}`;
340
341
  const [chain, symbol] = adjustedIdentifier.split('.');
341
342
  const [ticker, address] = (isSynthetic ? synthSymbol : symbol).split('-');
342
343
  return {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BigIntArithmetics = exports.toMultiplier = void 0;
4
4
  exports.formatBigIntToSafeValue = formatBigIntToSafeValue;
5
- const types_1 = require("@coinmasters/types");
5
+ const pioneer_caip_1 = require("@pioneer-platform/pioneer-caip");
6
6
  const TAG = " | BigIntArithmetics | ";
7
7
  const DEFAULT_DECIMAL = 8;
8
8
  const bigintPow = (base, exponent) => {
@@ -326,7 +326,7 @@ class BigIntArithmetics {
326
326
  getBaseValue(type) {
327
327
  let tag = TAG + " | getBaseValue | ";
328
328
  try {
329
- const divisor = this.decimalMultiplier / (0, exports.toMultiplier)(this.decimal || types_1.BaseDecimal.THOR);
329
+ const divisor = this.decimalMultiplier / (0, exports.toMultiplier)(this.decimal || pioneer_caip_1.BaseDecimal.THOR);
330
330
  const baseValue = this.bigIntValue / divisor;
331
331
  switch (type) {
332
332
  case 'number':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pioneer-platform/helpers",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
4
4
  "main": "./lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "scripts": {
@@ -13,9 +13,9 @@
13
13
  "refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
14
14
  },
15
15
  "dependencies": {
16
- "@coinmasters/core": "^12.0.8",
17
- "@coinmasters/tokens": "^3.7.28",
18
- "@coinmasters/types": "^4.10.1",
16
+ "@pioneer-platform/pioneer-caip": "workspace:*",
17
+ "@pioneer-platform/pioneer-types": "workspace:*",
18
+ "@pioneer-platform/tokens": "workspace:*",
19
19
  "@noble/hashes": "^1.4.0",
20
20
  "@pioneer-platform/loggerdog": "^8.11.0",
21
21
  "@types/node": "^18.15.11",
@@ -1,5 +1,6 @@
1
- import type { EVMChain } from '@coinmasters/types';
2
- import { BaseDecimal, Chain, ChainToRPC, EVMChainList, FeeOption } from '@coinmasters/types';
1
+ import type { EVMChain } from '@pioneer-platform/pioneer-caip';
2
+ import { BaseDecimal, Chain, ChainToRPC, EVMChainList } from '@pioneer-platform/pioneer-caip';
3
+ import { FeeOption } from '@pioneer-platform/pioneer-types';
3
4
 
4
5
  import { RequestClient } from '../index';
5
6
 
@@ -1,4 +1,4 @@
1
- import { BaseDecimal } from '@coinmasters/types';
1
+ import { BaseDecimal } from '@pioneer-platform/pioneer-caip';
2
2
 
3
3
  import { SwapKitNumber } from '../index';
4
4
 
@@ -1,5 +1,5 @@
1
- import type { Chain } from '@coinmasters/types';
2
- import { MemoType } from '@coinmasters/types';
1
+ import type { Chain } from '@pioneer-platform/pioneer-caip';
2
+ import { MemoType } from '@pioneer-platform/pioneer-types';
3
3
 
4
4
  export type ThornameRegisterParam = {
5
5
  name: string;
@@ -1,4 +1,4 @@
1
- import { Chain } from '@coinmasters/types';
1
+ import { Chain } from '@pioneer-platform/pioneer-caip';
2
2
 
3
3
  const supportedChains = Object.values(Chain);
4
4
 
@@ -11,8 +11,8 @@ import type {
11
11
  TraderjoeList,
12
12
  UniswapList,
13
13
  WoofiList,
14
- } from '@coinmasters/tokens';
15
- import { BaseDecimal, Chain } from '@coinmasters/types';
14
+ } from '@pioneer-platform/tokens';
15
+ import { BaseDecimal, Chain } from '@pioneer-platform/pioneer-caip';
16
16
 
17
17
  import type { CommonAssetString } from '../helpers/asset';
18
18
  import { getAssetType, getCommonAssetInfo, getDecimal, isGasAsset } from '../helpers/asset';
@@ -282,7 +282,7 @@ export class AssetValue extends BigIntArithmetics {
282
282
  ThorchainList: _ThorchainList,
283
283
  NativeList,
284
284
  ...tokensPackage
285
- } = await import('@coinmasters/tokens');
285
+ } = await import('@pioneer-platform/tokens');
286
286
 
287
287
  const tokensMap = [NativeList, ...Object.values(tokensPackage)].reduce(
288
288
  (acc, { tokens }: any) => {
@@ -293,6 +293,7 @@ export class AssetValue extends BigIntArithmetics {
293
293
 
294
294
  // @ts-ignore
295
295
  tokens.forEach(({ identifier, chain, ...rest }) => {
296
+ // @ts-ignore - BaseDecimal uses string keys but is typed as enum
296
297
  const decimal = 'decimals' in rest ? rest.decimals : BaseDecimal[chain as Chain];
297
298
 
298
299
  acc.set(identifier as TokenNames, { identifier, decimal });
@@ -311,7 +312,7 @@ export class AssetValue extends BigIntArithmetics {
311
312
  reject({
312
313
  ok: false,
313
314
  error,
314
- message: "Couldn't load static assets. Ensure you have installed @coinmasters/tokens package",
315
+ message: "Couldn't load static assets. Ensure you have installed @pioneer-platform/tokens package",
315
316
  });
316
317
  }
317
318
  },
@@ -1,4 +1,4 @@
1
- import { BaseDecimal } from '@coinmasters/types';
1
+ import { BaseDecimal } from '@pioneer-platform/pioneer-caip';
2
2
  import type { SwapKitNumber } from './swapKitNumber';
3
3
 
4
4
  const TAG = " | BigIntArithmetics | ";