@talismn/balances 1.0.9 → 1.2.0

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.
Files changed (24) hide show
  1. package/dist/declarations/src/BalancesProvider.d.ts +1 -0
  2. package/dist/declarations/src/modules/index.d.ts +12 -1
  3. package/dist/declarations/src/modules/substrate-dtao/alphaPrice.d.ts +5 -0
  4. package/dist/declarations/src/modules/substrate-dtao/config.d.ts +5 -0
  5. package/dist/declarations/src/modules/substrate-dtao/fetchBalances.d.ts +3 -0
  6. package/dist/declarations/src/modules/substrate-dtao/fetchTokens.d.ts +3 -0
  7. package/dist/declarations/src/modules/substrate-dtao/getDtaoTokenRates.d.ts +11 -0
  8. package/dist/declarations/src/modules/substrate-dtao/getMiniMetadata.d.ts +3 -0
  9. package/dist/declarations/src/modules/substrate-dtao/getTransferCallData.d.ts +3 -0
  10. package/dist/declarations/src/modules/substrate-dtao/index.d.ts +4 -0
  11. package/dist/declarations/src/modules/substrate-dtao/module.d.ts +3 -0
  12. package/dist/declarations/src/modules/substrate-dtao/subscribeBalances.d.ts +3 -0
  13. package/dist/declarations/src/modules/substrate-dtao/types.d.ts +17 -0
  14. package/dist/declarations/src/modules/substrate-native/index.d.ts +0 -1
  15. package/dist/declarations/src/modules/substrate-native/types.d.ts +0 -1
  16. package/dist/declarations/src/types/IBalanceModule.d.ts +4 -0
  17. package/dist/declarations/src/types/balances.d.ts +27 -10
  18. package/dist/declarations/src/types/balancetypes.d.ts +1 -1
  19. package/dist/talismn-balances.cjs.dev.js +629 -365
  20. package/dist/talismn-balances.cjs.prod.js +629 -365
  21. package/dist/talismn-balances.esm.js +625 -362
  22. package/package.json +4 -4
  23. package/dist/declarations/src/modules/substrate-native/bittensor/getSubtensorStakingBalances.d.ts +0 -9
  24. package/dist/declarations/src/modules/substrate-native/bittensor/subtensor.d.ts +0 -20
@@ -33,8 +33,8 @@ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
33
33
  var upperFirst__default = /*#__PURE__*/_interopDefault(upperFirst);
34
34
  var PQueue__default = /*#__PURE__*/_interopDefault(PQueue);
35
35
 
36
- const MODULE_TYPE$a = chaindataProvider.EvmErc20TokenSchema.shape.type.value;
37
- const PLATFORM$a = chaindataProvider.EvmErc20TokenSchema.shape.platform.value;
36
+ const MODULE_TYPE$b = chaindataProvider.EvmErc20TokenSchema.shape.type.value;
37
+ const PLATFORM$b = chaindataProvider.EvmErc20TokenSchema.shape.platform.value;
38
38
 
39
39
  const abiMulticall = viem.parseAbi(["struct Call { address target; bytes callData; }", "struct Call3 { address target; bool allowFailure; bytes callData; }", "struct Call3Value { address target; bool allowFailure; uint256 value; bytes callData; }", "struct Result { bool success; bytes returnData; }", "function aggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes[] memory returnData)", "function aggregate3(Call3[] calldata calls) public payable returns (Result[] memory returnData)", "function aggregate3Value(Call3Value[] calldata calls) public payable returns (Result[] memory returnData)", "function blockAndAggregate(Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)", "function getBasefee() view returns (uint256 basefee)", "function getBlockHash(uint256 blockNumber) view returns (bytes32 blockHash)", "function getBlockNumber() view returns (uint256 blockNumber)", "function getChainId() view returns (uint256 chainid)", "function getCurrentBlockCoinbase() view returns (address coinbase)", "function getCurrentBlockDifficulty() view returns (uint256 difficulty)", "function getCurrentBlockGasLimit() view returns (uint256 gaslimit)", "function getCurrentBlockTimestamp() view returns (uint256 timestamp)", "function getEthBalance(address addr) view returns (uint256 balance)", "function getLastBlockHash() view returns (bytes32 blockHash)", "function tryAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (Result[] memory returnData)", "function tryBlockAndAggregate(bool requireSuccess, Call[] calldata calls) public payable returns (uint256 blockNumber, bytes32 blockHash, Result[] memory returnData)"]);
40
40
 
@@ -630,7 +630,7 @@ const getBalanceDefs = addressesByToken => {
630
630
  // if there is at least one storage entry, the results will be an array with a single object
631
631
  // if the storage has no entries in it (ex: Assets on ewx or moonbeam), the response will be an empty array
632
632
 
633
- const fetchBalances$a = async ({
633
+ const fetchBalances$b = async ({
634
634
  networkId,
635
635
  tokensWithAddresses,
636
636
  connector
@@ -642,7 +642,7 @@ const fetchBalances$a = async ({
642
642
  const client = await connector.getPublicClientForEvmNetwork(networkId);
643
643
  if (!client) throw new Error(`Could not get rpc provider for evm network ${networkId}`);
644
644
  for (const [token, addresses] of tokensWithAddresses) {
645
- if (token.type !== MODULE_TYPE$a || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
645
+ if (token.type !== MODULE_TYPE$b || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
646
646
  for (const address of addresses) if (!crypto.isEthereumAddress(address)) throw new Error(`Invalid ethereum address for EVM ERC20 balance module: ${address} for token ${token.id}`);
647
647
  }
648
648
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
@@ -672,7 +672,7 @@ const fetchWithoutAggregator = async (client, balanceDefs) => {
672
672
  address,
673
673
  tokenId: token.id,
674
674
  value: result.toString(),
675
- source: MODULE_TYPE$a,
675
+ source: MODULE_TYPE$b,
676
676
  networkId: chaindataProvider.parseEvmErc20TokenId(token.id).networkId,
677
677
  status: "live"
678
678
  };
@@ -715,7 +715,7 @@ const fetchWithAggregator = async (client, balanceDefs, erc20BalancesAggregatorA
715
715
  address: balanceDef.address,
716
716
  tokenId: balanceDef.token.id,
717
717
  value: erc20Balances[index].toString(),
718
- source: MODULE_TYPE$a,
718
+ source: MODULE_TYPE$b,
719
719
  networkId: chaindataProvider.parseTokenId(balanceDef.token.id).networkId,
720
720
  status: "live"
721
721
  }));
@@ -784,7 +784,7 @@ const TokenCacheSchema$2 = z__default.default.discriminatedUnion("isValid", [z__
784
784
  id: chaindataProvider.EvmErc20TokenSchema.shape.id,
785
785
  isValid: z__default.default.literal(false)
786
786
  })]);
787
- const fetchTokens$a = async ({
787
+ const fetchTokens$b = async ({
788
788
  networkId,
789
789
  tokens,
790
790
  connector,
@@ -824,8 +824,8 @@ const fetchTokens$a = async ({
824
824
  }
825
825
  const base = {
826
826
  id: tokenId,
827
- type: MODULE_TYPE$a,
828
- platform: PLATFORM$a,
827
+ type: MODULE_TYPE$b,
828
+ platform: PLATFORM$b,
829
829
  networkId
830
830
  };
831
831
  const cached2 = cache[tokenId] && TokenCacheSchema$2.safeParse(cache[tokenId]).data;
@@ -843,17 +843,17 @@ const fetchTokens$a = async ({
843
843
  return result;
844
844
  };
845
845
 
846
- const getMiniMetadata$a = () => {
846
+ const getMiniMetadata$b = () => {
847
847
  throw new Error("MiniMetadata is not supported for ethereum tokens");
848
848
  };
849
849
 
850
- const getTransferCallData$a = ({
850
+ const getTransferCallData$b = ({
851
851
  from,
852
852
  to,
853
853
  value,
854
854
  token
855
855
  }) => {
856
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$a)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$a}.`);
856
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$b)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$b}.`);
857
857
  if (!crypto.isEthereumAddress(from)) throw new Error("Invalid from address");
858
858
  if (!crypto.isEthereumAddress(to)) throw new Error("Invalid to address");
859
859
  const data = viem.encodeFunctionData({
@@ -868,8 +868,8 @@ const getTransferCallData$a = ({
868
868
  };
869
869
  };
870
870
 
871
- const SUBSCRIPTION_INTERVAL$6 = 6_000;
872
- const subscribeBalances$a = ({
871
+ const SUBSCRIPTION_INTERVAL$7 = 6_000;
872
+ const subscribeBalances$b = ({
873
873
  networkId,
874
874
  tokensWithAddresses,
875
875
  connector
@@ -883,17 +883,17 @@ const subscribeBalances$a = ({
883
883
  const poll = async () => {
884
884
  try {
885
885
  if (abortController.signal.aborted) return;
886
- const balances = await fetchBalances$a({
886
+ const balances = await fetchBalances$b({
887
887
  networkId,
888
888
  tokensWithAddresses: tokensWithAddresses,
889
889
  connector
890
890
  });
891
891
  if (abortController.signal.aborted) return;
892
892
  subscriber.next(balances);
893
- setTimeout(poll, SUBSCRIPTION_INTERVAL$6);
893
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$7);
894
894
  } catch (error) {
895
895
  log.error("Error", {
896
- module: MODULE_TYPE$a,
896
+ module: MODULE_TYPE$b,
897
897
  networkId,
898
898
  addressesByToken: tokensWithAddresses,
899
899
  error
@@ -909,13 +909,13 @@ const subscribeBalances$a = ({
909
909
  };
910
910
 
911
911
  const EvmErc20BalanceModule = {
912
- type: MODULE_TYPE$a,
913
- platform: PLATFORM$a,
914
- getMiniMetadata: getMiniMetadata$a,
915
- fetchTokens: fetchTokens$a,
916
- fetchBalances: fetchBalances$a,
917
- subscribeBalances: subscribeBalances$a,
918
- getTransferCallData: getTransferCallData$a
912
+ type: MODULE_TYPE$b,
913
+ platform: PLATFORM$b,
914
+ getMiniMetadata: getMiniMetadata$b,
915
+ fetchTokens: fetchTokens$b,
916
+ fetchBalances: fetchBalances$b,
917
+ subscribeBalances: subscribeBalances$b,
918
+ getTransferCallData: getTransferCallData$b
919
919
  };
920
920
 
921
921
  const TokenConfigBaseSchema = chaindataProvider.TokenBaseSchema.partial().omit({
@@ -928,10 +928,10 @@ const EvmErc20TokenConfigSchema = z__default.default.strictObject({
928
928
  ...TokenConfigBaseSchema.shape
929
929
  });
930
930
 
931
- const MODULE_TYPE$9 = chaindataProvider.EvmNativeTokenSchema.shape.type.value;
932
- const PLATFORM$9 = chaindataProvider.EvmNativeTokenSchema.shape.platform.value;
931
+ const MODULE_TYPE$a = chaindataProvider.EvmNativeTokenSchema.shape.type.value;
932
+ const PLATFORM$a = chaindataProvider.EvmNativeTokenSchema.shape.platform.value;
933
933
 
934
- const fetchBalances$9 = async ({
934
+ const fetchBalances$a = async ({
935
935
  networkId,
936
936
  tokensWithAddresses,
937
937
  connector
@@ -943,7 +943,7 @@ const fetchBalances$9 = async ({
943
943
  const client = await connector.getPublicClientForEvmNetwork(networkId);
944
944
  if (!client) throw new Error(`Could not get rpc provider for evm network ${networkId}`);
945
945
  for (const [token, addresses] of tokensWithAddresses) {
946
- if (token.type !== MODULE_TYPE$9 || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
946
+ if (token.type !== MODULE_TYPE$a || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
947
947
  for (const address of addresses) if (!crypto.isEthereumAddress(address)) throw new Error(`Invalid ethereum address for EVM ERC20 balance module: ${address} for token ${token.id}`);
948
948
  }
949
949
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
@@ -970,7 +970,7 @@ const fetchWithoutMulticall = async (client, balanceDefs) => {
970
970
  address,
971
971
  tokenId: token.id,
972
972
  value: result.toString(),
973
- source: MODULE_TYPE$9,
973
+ source: MODULE_TYPE$a,
974
974
  networkId: chaindataProvider.parseTokenId(token.id).networkId,
975
975
  status: "live"
976
976
  };
@@ -1016,7 +1016,7 @@ const fetchWithMulticall = async (client, balanceDefs, multicall3Address) => {
1016
1016
  address: balanceDefs[index].address,
1017
1017
  tokenId: balanceDefs[index].token.id,
1018
1018
  value: result.result.toString(),
1019
- source: MODULE_TYPE$9,
1019
+ source: MODULE_TYPE$a,
1020
1020
  networkId: chaindataProvider.parseTokenId(balanceDefs[index].token.id).networkId,
1021
1021
  status: "live"
1022
1022
  });
@@ -1046,7 +1046,7 @@ const fetchWithMulticall = async (client, balanceDefs, multicall3Address) => {
1046
1046
  }
1047
1047
  };
1048
1048
 
1049
- const fetchTokens$9 = async ({
1049
+ const fetchTokens$a = async ({
1050
1050
  networkId,
1051
1051
  tokens
1052
1052
  }) => {
@@ -1054,8 +1054,8 @@ const fetchTokens$9 = async ({
1054
1054
  if (tokens.length !== 1) throw new Error("EVM Native module expects the nativeCurrency to be passed as a single token in the array");
1055
1055
  const token = lodashEs.assign({
1056
1056
  id: chaindataProvider.evmNativeTokenId(networkId),
1057
- type: MODULE_TYPE$9,
1058
- platform: PLATFORM$9,
1057
+ type: MODULE_TYPE$a,
1058
+ platform: PLATFORM$a,
1059
1059
  networkId,
1060
1060
  isDefault: true
1061
1061
  }, tokens[0]);
@@ -1067,17 +1067,17 @@ const fetchTokens$9 = async ({
1067
1067
  return [parsed.data];
1068
1068
  };
1069
1069
 
1070
- const getMiniMetadata$9 = () => {
1070
+ const getMiniMetadata$a = () => {
1071
1071
  throw new Error("MiniMetadata is not supported for ethereum tokens");
1072
1072
  };
1073
1073
 
1074
- const getTransferCallData$9 = ({
1074
+ const getTransferCallData$a = ({
1075
1075
  from,
1076
1076
  to,
1077
1077
  value,
1078
1078
  token
1079
1079
  }) => {
1080
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$9)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$9}.`);
1080
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$a)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$a}.`);
1081
1081
  if (!crypto.isEthereumAddress(from)) throw new Error("Invalid from address");
1082
1082
  if (!crypto.isEthereumAddress(to)) throw new Error("Invalid to address");
1083
1083
  return {
@@ -1088,8 +1088,8 @@ const getTransferCallData$9 = ({
1088
1088
  };
1089
1089
  };
1090
1090
 
1091
- const SUBSCRIPTION_INTERVAL$5 = 6_000;
1092
- const subscribeBalances$9 = ({
1091
+ const SUBSCRIPTION_INTERVAL$6 = 6_000;
1092
+ const subscribeBalances$a = ({
1093
1093
  networkId,
1094
1094
  tokensWithAddresses,
1095
1095
  connector
@@ -1103,17 +1103,17 @@ const subscribeBalances$9 = ({
1103
1103
  const poll = async () => {
1104
1104
  try {
1105
1105
  if (abortController.signal.aborted) return;
1106
- const balances = await fetchBalances$9({
1106
+ const balances = await fetchBalances$a({
1107
1107
  networkId,
1108
1108
  tokensWithAddresses: tokensWithAddresses,
1109
1109
  connector
1110
1110
  });
1111
1111
  if (abortController.signal.aborted) return;
1112
1112
  subscriber.next(balances);
1113
- setTimeout(poll, SUBSCRIPTION_INTERVAL$5);
1113
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$6);
1114
1114
  } catch (error) {
1115
1115
  log.error("Error", {
1116
- module: MODULE_TYPE$9,
1116
+ module: MODULE_TYPE$a,
1117
1117
  networkId,
1118
1118
  addressesByToken: tokensWithAddresses,
1119
1119
  error
@@ -1129,13 +1129,13 @@ const subscribeBalances$9 = ({
1129
1129
  };
1130
1130
 
1131
1131
  const EvmNativeBalanceModule = {
1132
- type: MODULE_TYPE$9,
1133
- platform: PLATFORM$9,
1134
- getMiniMetadata: getMiniMetadata$9,
1135
- fetchTokens: fetchTokens$9,
1136
- fetchBalances: fetchBalances$9,
1137
- subscribeBalances: subscribeBalances$9,
1138
- getTransferCallData: getTransferCallData$9
1132
+ type: MODULE_TYPE$a,
1133
+ platform: PLATFORM$a,
1134
+ getMiniMetadata: getMiniMetadata$a,
1135
+ fetchTokens: fetchTokens$a,
1136
+ fetchBalances: fetchBalances$a,
1137
+ subscribeBalances: subscribeBalances$a,
1138
+ getTransferCallData: getTransferCallData$a
1139
1139
  };
1140
1140
 
1141
1141
  // to be used by chaindata too
@@ -1143,10 +1143,10 @@ const EvmNativeTokenConfigSchema = z__default.default.strictObject({
1143
1143
  ...TokenConfigBaseSchema.shape
1144
1144
  });
1145
1145
 
1146
- const MODULE_TYPE$8 = chaindataProvider.EvmUniswapV2TokenSchema.shape.type.value;
1147
- const PLATFORM$8 = chaindataProvider.EvmUniswapV2TokenSchema.shape.platform.value;
1146
+ const MODULE_TYPE$9 = chaindataProvider.EvmUniswapV2TokenSchema.shape.type.value;
1147
+ const PLATFORM$9 = chaindataProvider.EvmUniswapV2TokenSchema.shape.platform.value;
1148
1148
 
1149
- const fetchBalances$8 = async ({
1149
+ const fetchBalances$9 = async ({
1150
1150
  networkId,
1151
1151
  tokensWithAddresses,
1152
1152
  connector
@@ -1158,7 +1158,7 @@ const fetchBalances$8 = async ({
1158
1158
  const client = await connector.getPublicClientForEvmNetwork(networkId);
1159
1159
  if (!client) throw new Error(`Could not get rpc provider for evm network ${networkId}`);
1160
1160
  for (const [token, addresses] of tokensWithAddresses) {
1161
- if (token.type !== MODULE_TYPE$8 || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
1161
+ if (token.type !== MODULE_TYPE$9 || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for EVM ERC20 balance module: ${token.type} on ${token.networkId}`);
1162
1162
  for (const address of addresses) if (!crypto.isEthereumAddress(address)) throw new Error(`Invalid ethereum address for EVM ERC20 balance module: ${address} for token ${token.id}`);
1163
1163
  }
1164
1164
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
@@ -1245,7 +1245,7 @@ const fetchPoolBalances = async (client, balanceDefs) => {
1245
1245
  acc.success.push({
1246
1246
  address,
1247
1247
  tokenId: token.id,
1248
- source: MODULE_TYPE$8,
1248
+ source: MODULE_TYPE$9,
1249
1249
  networkId: chaindataProvider.parseTokenId(token.id).networkId,
1250
1250
  status: "live",
1251
1251
  values: [{
@@ -1323,7 +1323,7 @@ const TokenCacheSchema$1 = z__default.default.discriminatedUnion("isValid", [z__
1323
1323
  id: chaindataProvider.EvmUniswapV2TokenSchema.shape.id,
1324
1324
  isValid: z__default.default.literal(false)
1325
1325
  })]);
1326
- const fetchTokens$8 = async ({
1326
+ const fetchTokens$9 = async ({
1327
1327
  networkId,
1328
1328
  tokens,
1329
1329
  connector,
@@ -1382,8 +1382,8 @@ const fetchTokens$8 = async ({
1382
1382
  }
1383
1383
  const base = {
1384
1384
  id: tokenId,
1385
- type: MODULE_TYPE$8,
1386
- platform: PLATFORM$8,
1385
+ type: MODULE_TYPE$9,
1386
+ platform: PLATFORM$9,
1387
1387
  networkId
1388
1388
  };
1389
1389
  const cached2 = cache[tokenId] && TokenCacheSchema$1.safeParse(cache[tokenId]).data;
@@ -1399,17 +1399,17 @@ const fetchTokens$8 = async ({
1399
1399
  return result;
1400
1400
  };
1401
1401
 
1402
- const getMiniMetadata$8 = () => {
1402
+ const getMiniMetadata$9 = () => {
1403
1403
  throw new Error("MiniMetadata is not supported for ethereum tokens");
1404
1404
  };
1405
1405
 
1406
- const getTransferCallData$8 = ({
1406
+ const getTransferCallData$9 = ({
1407
1407
  from,
1408
1408
  to,
1409
1409
  value,
1410
1410
  token
1411
1411
  }) => {
1412
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$8)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$8}.`);
1412
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$9)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$9}.`);
1413
1413
  if (!crypto.isEthereumAddress(from)) throw new Error("Invalid from address");
1414
1414
  if (!crypto.isEthereumAddress(to)) throw new Error("Invalid to address");
1415
1415
  const data = viem.encodeFunctionData({
@@ -1424,8 +1424,8 @@ const getTransferCallData$8 = ({
1424
1424
  };
1425
1425
  };
1426
1426
 
1427
- const SUBSCRIPTION_INTERVAL$4 = 6_000;
1428
- const subscribeBalances$8 = ({
1427
+ const SUBSCRIPTION_INTERVAL$5 = 6_000;
1428
+ const subscribeBalances$9 = ({
1429
1429
  networkId,
1430
1430
  tokensWithAddresses,
1431
1431
  connector
@@ -1439,17 +1439,17 @@ const subscribeBalances$8 = ({
1439
1439
  const poll = async () => {
1440
1440
  try {
1441
1441
  if (abortController.signal.aborted) return;
1442
- const balances = await fetchBalances$8({
1442
+ const balances = await fetchBalances$9({
1443
1443
  networkId,
1444
1444
  tokensWithAddresses: tokensWithAddresses,
1445
1445
  connector
1446
1446
  });
1447
1447
  if (abortController.signal.aborted) return;
1448
1448
  subscriber.next(balances);
1449
- setTimeout(poll, SUBSCRIPTION_INTERVAL$4);
1449
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$5);
1450
1450
  } catch (error) {
1451
1451
  log.error("Error", {
1452
- module: MODULE_TYPE$8,
1452
+ module: MODULE_TYPE$9,
1453
1453
  networkId,
1454
1454
  addressesByToken: tokensWithAddresses,
1455
1455
  error
@@ -1465,13 +1465,13 @@ const subscribeBalances$8 = ({
1465
1465
  };
1466
1466
 
1467
1467
  const EvmUniswapV2BalanceModule = {
1468
- type: MODULE_TYPE$8,
1469
- platform: PLATFORM$8,
1470
- getMiniMetadata: getMiniMetadata$8,
1471
- fetchTokens: fetchTokens$8,
1472
- fetchBalances: fetchBalances$8,
1473
- subscribeBalances: subscribeBalances$8,
1474
- getTransferCallData: getTransferCallData$8
1468
+ type: MODULE_TYPE$9,
1469
+ platform: PLATFORM$9,
1470
+ getMiniMetadata: getMiniMetadata$9,
1471
+ fetchTokens: fetchTokens$9,
1472
+ fetchBalances: fetchBalances$9,
1473
+ subscribeBalances: subscribeBalances$9,
1474
+ getTransferCallData: getTransferCallData$9
1475
1475
  };
1476
1476
 
1477
1477
  // to be used by chaindata too
@@ -1480,10 +1480,10 @@ const EvmUniswapV2TokenConfigSchema = z__default.default.strictObject({
1480
1480
  ...TokenConfigBaseSchema.shape
1481
1481
  });
1482
1482
 
1483
- const MODULE_TYPE$7 = chaindataProvider.SolNativeTokenSchema.shape.type.value;
1484
- const PLATFORM$7 = chaindataProvider.SolNativeTokenSchema.shape.platform.value;
1483
+ const MODULE_TYPE$8 = chaindataProvider.SolNativeTokenSchema.shape.type.value;
1484
+ const PLATFORM$8 = chaindataProvider.SolNativeTokenSchema.shape.platform.value;
1485
1485
 
1486
- const fetchBalances$7 = async ({
1486
+ const fetchBalances$8 = async ({
1487
1487
  networkId,
1488
1488
  tokensWithAddresses,
1489
1489
  connector
@@ -1495,7 +1495,7 @@ const fetchBalances$7 = async ({
1495
1495
  const connection = await connector.getConnection(networkId);
1496
1496
  if (!connection) throw new Error(`Could not get rpc provider for sol network ${networkId}`);
1497
1497
  for (const [token, addresses] of tokensWithAddresses) {
1498
- if (token.type !== MODULE_TYPE$7 || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for balance module: ${token.type} on ${token.networkId}`);
1498
+ if (token.type !== MODULE_TYPE$8 || token.networkId !== networkId) throw new Error(`Invalid token type or networkId for balance module: ${token.type} on ${token.networkId}`);
1499
1499
  for (const address of addresses) if (!crypto.isSolanaAddress(address)) throw new Error(`Invalid solana address for balance module: ${address} for token ${token.id}`);
1500
1500
  }
1501
1501
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
@@ -1510,7 +1510,7 @@ const fetchBalances$7 = async ({
1510
1510
  address: address,
1511
1511
  tokenId: token.id,
1512
1512
  value: lamports.toString(),
1513
- source: MODULE_TYPE$7,
1513
+ source: MODULE_TYPE$8,
1514
1514
  networkId: token.networkId,
1515
1515
  status: "live"
1516
1516
  };
@@ -1534,7 +1534,7 @@ const fetchBalances$7 = async ({
1534
1534
  });
1535
1535
  };
1536
1536
 
1537
- const fetchTokens$7 = async ({
1537
+ const fetchTokens$8 = async ({
1538
1538
  networkId,
1539
1539
  tokens
1540
1540
  }) => {
@@ -1542,8 +1542,8 @@ const fetchTokens$7 = async ({
1542
1542
  if (tokens.length !== 1) throw new Error("EVM Native module expects the nativeCurrency to be passed as a single token in the array");
1543
1543
  const token = lodashEs.assign({
1544
1544
  id: chaindataProvider.solNativeTokenId(networkId),
1545
- type: MODULE_TYPE$7,
1546
- platform: PLATFORM$7,
1545
+ type: MODULE_TYPE$8,
1546
+ platform: PLATFORM$8,
1547
1547
  networkId,
1548
1548
  isDefault: true
1549
1549
  }, tokens[0]);
@@ -1555,17 +1555,17 @@ const fetchTokens$7 = async ({
1555
1555
  return [parsed.data];
1556
1556
  };
1557
1557
 
1558
- const getMiniMetadata$7 = () => {
1558
+ const getMiniMetadata$8 = () => {
1559
1559
  throw new Error("MiniMetadata is not supported for sol-native tokens");
1560
1560
  };
1561
1561
 
1562
- const getTransferCallData$7 = ({
1562
+ const getTransferCallData$8 = ({
1563
1563
  from,
1564
1564
  to,
1565
1565
  value,
1566
1566
  token
1567
1567
  }) => {
1568
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$7)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$7}.`);
1568
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$8)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$8}.`);
1569
1569
  const fromPubkey = new web3_js.PublicKey(from);
1570
1570
  const transferIx = web3_js.SystemProgram.transfer({
1571
1571
  fromPubkey,
@@ -1575,8 +1575,8 @@ const getTransferCallData$7 = ({
1575
1575
  return [transferIx];
1576
1576
  };
1577
1577
 
1578
- const SUBSCRIPTION_INTERVAL$3 = 6_000;
1579
- const subscribeBalances$7 = ({
1578
+ const SUBSCRIPTION_INTERVAL$4 = 6_000;
1579
+ const subscribeBalances$8 = ({
1580
1580
  networkId,
1581
1581
  tokensWithAddresses,
1582
1582
  connector
@@ -1590,17 +1590,17 @@ const subscribeBalances$7 = ({
1590
1590
  const poll = async () => {
1591
1591
  try {
1592
1592
  if (abortController.signal.aborted) return;
1593
- const balances = await fetchBalances$7({
1593
+ const balances = await fetchBalances$8({
1594
1594
  networkId,
1595
1595
  tokensWithAddresses,
1596
1596
  connector
1597
1597
  });
1598
1598
  if (abortController.signal.aborted) return;
1599
1599
  subscriber.next(balances);
1600
- setTimeout(poll, SUBSCRIPTION_INTERVAL$3);
1600
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$4);
1601
1601
  } catch (error) {
1602
1602
  log.error("Error", {
1603
- module: MODULE_TYPE$7,
1603
+ module: MODULE_TYPE$8,
1604
1604
  networkId,
1605
1605
  tokensWithAddresses,
1606
1606
  error
@@ -1616,13 +1616,13 @@ const subscribeBalances$7 = ({
1616
1616
  };
1617
1617
 
1618
1618
  const SolNativeBalanceModule = {
1619
- type: MODULE_TYPE$7,
1620
- platform: PLATFORM$7,
1621
- getMiniMetadata: getMiniMetadata$7,
1622
- fetchTokens: fetchTokens$7,
1623
- fetchBalances: fetchBalances$7,
1624
- subscribeBalances: subscribeBalances$7,
1625
- getTransferCallData: getTransferCallData$7
1619
+ type: MODULE_TYPE$8,
1620
+ platform: PLATFORM$8,
1621
+ getMiniMetadata: getMiniMetadata$8,
1622
+ fetchTokens: fetchTokens$8,
1623
+ fetchBalances: fetchBalances$8,
1624
+ subscribeBalances: subscribeBalances$8,
1625
+ getTransferCallData: getTransferCallData$8
1626
1626
  };
1627
1627
 
1628
1628
  // to be used by chaindata too
@@ -1630,16 +1630,22 @@ const SolNativeTokenConfigSchema = z__default.default.strictObject({
1630
1630
  ...TokenConfigBaseSchema.shape
1631
1631
  });
1632
1632
 
1633
- const MODULE_TYPE$6 = chaindataProvider.SolSplTokenSchema.shape.type.value;
1634
- const PLATFORM$6 = chaindataProvider.SolSplTokenSchema.shape.platform.value;
1633
+ const MODULE_TYPE$7 = chaindataProvider.SolSplTokenSchema.shape.type.value;
1634
+ const PLATFORM$7 = chaindataProvider.SolSplTokenSchema.shape.platform.value;
1635
1635
 
1636
1636
  const fetchRuntimeCallResult = async (connector, networkId, metadataRpc, apiName, method, args) => {
1637
- const {
1638
- builder
1639
- } = scale.parseMetadataRpc(metadataRpc);
1640
- const call = builder.buildRuntimeCall(apiName, method);
1641
- const hex = await connector.send(networkId, "state_call", [`${apiName}_${method}`, scale.toHex(call.args.enc(args))]);
1642
- return call.value.dec(hex);
1637
+ try {
1638
+ const {
1639
+ builder
1640
+ } = scale.parseMetadataRpc(metadataRpc);
1641
+ const call = builder.buildRuntimeCall(apiName, method);
1642
+ const hex = await connector.send(networkId, "state_call", [`${apiName}_${method}`, scale.toHex(call.args.enc(args))]);
1643
+ return call.value.dec(hex);
1644
+ } catch (cause) {
1645
+ throw new Error(`Error fetching runtime call on ${networkId} for ${apiName}.${method}`, {
1646
+ cause
1647
+ });
1648
+ }
1643
1649
  };
1644
1650
 
1645
1651
  const hasStorageItem = (metadata, palletName, itemName) => {
@@ -1784,7 +1790,7 @@ const setDetectedTokenIds = (address, type, tokenIds) => {
1784
1790
  const getDetectedTokensIds$ = address => tokenIdsByAddress.pipe(rxjs.map(ownedTokens => ownedTokens[address] ?? []), rxjs.distinctUntilChanged(lodashEs.isEqual));
1785
1791
 
1786
1792
  const SPL_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
1787
- const fetchBalances$6 = async ({
1793
+ const fetchBalances$7 = async ({
1788
1794
  networkId,
1789
1795
  tokensWithAddresses,
1790
1796
  connector
@@ -1808,7 +1814,7 @@ const fetchBalances$6 = async ({
1808
1814
  tokenId: chaindataProvider.solSplTokenId(networkId, mintAddress),
1809
1815
  networkId,
1810
1816
  address,
1811
- source: MODULE_TYPE$6,
1817
+ source: MODULE_TYPE$7,
1812
1818
  status: "live",
1813
1819
  value
1814
1820
  };
@@ -1822,7 +1828,7 @@ const fetchBalances$6 = async ({
1822
1828
  }).filter(util.isNotNil);
1823
1829
 
1824
1830
  // allows the wallet to detect new tokens, and enable them automatically
1825
- setDetectedTokenIds(address, MODULE_TYPE$6, balances.map(b => b.tokenId));
1831
+ setDetectedTokenIds(address, MODULE_TYPE$7, balances.map(b => b.tokenId));
1826
1832
  return [address, balances];
1827
1833
  }));
1828
1834
  const allBalancesByKey = lodashEs.keyBy(balancesPerAddress.flatMap(([, addressBalances]) => addressBalances), b => getBalanceKey(b.tokenId, b.address));
@@ -1835,7 +1841,7 @@ const fetchBalances$6 = async ({
1835
1841
  tokenId: bd.token.id,
1836
1842
  networkId: bd.token.networkId,
1837
1843
  address: bd.address,
1838
- source: MODULE_TYPE$6,
1844
+ source: MODULE_TYPE$7,
1839
1845
  status: "live",
1840
1846
  value: "0"
1841
1847
  };
@@ -1863,7 +1869,7 @@ const TokenCacheSchema = z__default.default.discriminatedUnion("isValid", [z__de
1863
1869
  isValid: z__default.default.literal(false)
1864
1870
  })]);
1865
1871
  const METAPLEX_PROGRAM_ID = new web3_js.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
1866
- const fetchTokens$6 = async ({
1872
+ const fetchTokens$7 = async ({
1867
1873
  networkId,
1868
1874
  tokens,
1869
1875
  connector,
@@ -1881,8 +1887,8 @@ const fetchTokens$6 = async ({
1881
1887
  if (cached?.isValid === false) continue;
1882
1888
  const base = {
1883
1889
  id: tokenId,
1884
- type: MODULE_TYPE$6,
1885
- platform: PLATFORM$6,
1890
+ type: MODULE_TYPE$7,
1891
+ platform: PLATFORM$7,
1886
1892
  networkId
1887
1893
  };
1888
1894
  const token = lodashEs.assign(base, cached?.isValid ? lodashEs.omit(cached, ["isValid"]) : {}, tokenConfig);
@@ -1949,18 +1955,18 @@ const fetchOnChainTokenData = async (connector, tokenId) => {
1949
1955
  return null;
1950
1956
  };
1951
1957
 
1952
- const getMiniMetadata$6 = () => {
1958
+ const getMiniMetadata$7 = () => {
1953
1959
  throw new Error("MiniMetadata is not supported for solana tokens");
1954
1960
  };
1955
1961
 
1956
- const getTransferCallData$6 = async ({
1962
+ const getTransferCallData$7 = async ({
1957
1963
  from,
1958
1964
  to,
1959
1965
  value,
1960
1966
  token,
1961
1967
  connector
1962
1968
  }) => {
1963
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$6)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$6}.`);
1969
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$7)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$7}.`);
1964
1970
  const connection = await connector.getConnection(token.networkId);
1965
1971
  const instructions = [];
1966
1972
  const mint = new web3_js.PublicKey(token.mintAddress);
@@ -1991,8 +1997,8 @@ const tokenAccountExists = async (connection, address) => {
1991
1997
  }
1992
1998
  };
1993
1999
 
1994
- const SUBSCRIPTION_INTERVAL$2 = 6_000;
1995
- const subscribeBalances$6 = ({
2000
+ const SUBSCRIPTION_INTERVAL$3 = 6_000;
2001
+ const subscribeBalances$7 = ({
1996
2002
  networkId,
1997
2003
  tokensWithAddresses,
1998
2004
  connector
@@ -2006,17 +2012,17 @@ const subscribeBalances$6 = ({
2006
2012
  const poll = async () => {
2007
2013
  try {
2008
2014
  if (abortController.signal.aborted) return;
2009
- const balances = await fetchBalances$6({
2015
+ const balances = await fetchBalances$7({
2010
2016
  networkId,
2011
2017
  tokensWithAddresses: tokensWithAddresses,
2012
2018
  connector
2013
2019
  });
2014
2020
  if (abortController.signal.aborted) return;
2015
2021
  subscriber.next(balances);
2016
- setTimeout(poll, SUBSCRIPTION_INTERVAL$2);
2022
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$3);
2017
2023
  } catch (error) {
2018
2024
  log.error("Error", {
2019
- module: MODULE_TYPE$6,
2025
+ module: MODULE_TYPE$7,
2020
2026
  networkId,
2021
2027
  addressesByToken: tokensWithAddresses,
2022
2028
  error
@@ -2032,13 +2038,13 @@ const subscribeBalances$6 = ({
2032
2038
  };
2033
2039
 
2034
2040
  const SolSplBalanceModule = {
2035
- type: MODULE_TYPE$6,
2036
- platform: PLATFORM$6,
2037
- getMiniMetadata: getMiniMetadata$6,
2038
- fetchTokens: fetchTokens$6,
2039
- fetchBalances: fetchBalances$6,
2040
- subscribeBalances: subscribeBalances$6,
2041
- getTransferCallData: getTransferCallData$6
2041
+ type: MODULE_TYPE$7,
2042
+ platform: PLATFORM$7,
2043
+ getMiniMetadata: getMiniMetadata$7,
2044
+ fetchTokens: fetchTokens$7,
2045
+ fetchBalances: fetchBalances$7,
2046
+ subscribeBalances: subscribeBalances$7,
2047
+ getTransferCallData: getTransferCallData$7
2042
2048
  };
2043
2049
 
2044
2050
  // to be used by chaindata too
@@ -2047,8 +2053,8 @@ const SolSplTokenConfigSchema = z__default.default.strictObject({
2047
2053
  ...TokenConfigBaseSchema.shape
2048
2054
  });
2049
2055
 
2050
- const MODULE_TYPE$5 = chaindataProvider.SubAssetsTokenSchema.shape.type.value;
2051
- const PLATFORM$5 = chaindataProvider.SubAssetsTokenSchema.shape.platform.value;
2056
+ const MODULE_TYPE$6 = chaindataProvider.SubAssetsTokenSchema.shape.type.value;
2057
+ const PLATFORM$6 = chaindataProvider.SubAssetsTokenSchema.shape.platform.value;
2052
2058
 
2053
2059
  const buildQueries$2 = (networkId, balanceDefs, miniMetadata) => {
2054
2060
  const networkStorageCoders = buildNetworkStorageCoders(networkId, miniMetadata, {
@@ -2124,7 +2130,7 @@ const tryEncode = (scaleCoder, ...args) => {
2124
2130
  }
2125
2131
  };
2126
2132
 
2127
- const fetchBalances$5 = async ({
2133
+ const fetchBalances$6 = async ({
2128
2134
  networkId,
2129
2135
  tokensWithAddresses,
2130
2136
  connector,
@@ -2136,7 +2142,7 @@ const fetchBalances$5 = async ({
2136
2142
  };
2137
2143
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
2138
2144
  if (!miniMetadata?.data) {
2139
- log.warn(`MiniMetadata is required for fetching ${MODULE_TYPE$5} balances on ${networkId}.`);
2145
+ log.warn(`MiniMetadata is required for fetching ${MODULE_TYPE$6} balances on ${networkId}.`);
2140
2146
  return {
2141
2147
  success: [],
2142
2148
  errors: balanceDefs.map(def => ({
@@ -2146,19 +2152,19 @@ const fetchBalances$5 = async ({
2146
2152
  }))
2147
2153
  };
2148
2154
  }
2149
- if (miniMetadata.source !== MODULE_TYPE$5) {
2150
- log.warn(`Ignoring miniMetadata with source ${miniMetadata.source} in ${MODULE_TYPE$5}.`);
2155
+ if (miniMetadata.source !== MODULE_TYPE$6) {
2156
+ log.warn(`Ignoring miniMetadata with source ${miniMetadata.source} in ${MODULE_TYPE$6}.`);
2151
2157
  return {
2152
2158
  success: [],
2153
2159
  errors: balanceDefs.map(def => ({
2154
2160
  tokenId: def.token.id,
2155
2161
  address: def.address,
2156
- error: new Error(`Invalid request: miniMetadata source is not ${MODULE_TYPE$5}`)
2162
+ error: new Error(`Invalid request: miniMetadata source is not ${MODULE_TYPE$6}`)
2157
2163
  }))
2158
2164
  };
2159
2165
  }
2160
2166
  if (miniMetadata.chainId !== networkId) {
2161
- log.warn(`Ignoring miniMetadata with chainId ${miniMetadata.chainId} in ${MODULE_TYPE$5}. Expected chainId is ${networkId}`);
2167
+ log.warn(`Ignoring miniMetadata with chainId ${miniMetadata.chainId} in ${MODULE_TYPE$6}. Expected chainId is ${networkId}`);
2162
2168
  return {
2163
2169
  success: [],
2164
2170
  errors: balanceDefs.map(def => ({
@@ -2178,7 +2184,7 @@ const fetchBalances$5 = async ({
2178
2184
  address: def.address,
2179
2185
  networkId,
2180
2186
  tokenId: def.token.id,
2181
- source: MODULE_TYPE$5,
2187
+ source: MODULE_TYPE$6,
2182
2188
  status: "live",
2183
2189
  values: [{
2184
2190
  type: "free",
@@ -2197,7 +2203,7 @@ const fetchBalances$5 = async ({
2197
2203
  });
2198
2204
  };
2199
2205
 
2200
- const fetchTokens$5 = async ({
2206
+ const fetchTokens$6 = async ({
2201
2207
  networkId,
2202
2208
  tokens,
2203
2209
  connector,
@@ -2238,7 +2244,7 @@ const fetchTokens$5 = async ({
2238
2244
  const configTokenByAssetId = lodashEs.keyBy(tokens, t => t.assetId);
2239
2245
  return allTokens.map(asset => ({
2240
2246
  id: chaindataProvider.subAssetTokenId(networkId, String(asset.assetId)),
2241
- type: MODULE_TYPE$5,
2247
+ type: MODULE_TYPE$6,
2242
2248
  platform: "polkadot",
2243
2249
  networkId,
2244
2250
  assetId: String(asset.assetId),
@@ -2269,6 +2275,394 @@ const fetchTokens$5 = async ({
2269
2275
  });
2270
2276
  };
2271
2277
 
2278
+ const MODULE_TYPE$5 = chaindataProvider.SubDTaoTokenSchema.shape.type.value;
2279
+ const PLATFORM$5 = chaindataProvider.SubDTaoTokenSchema.shape.platform.value;
2280
+
2281
+ const TAO_DECIMALS = 9n;
2282
+
2283
+ // manipulating price as bigint requires using at least as many decimals as TAO itself
2284
+ const ALPHA_PRICE_SCALE = 10n ** TAO_DECIMALS;
2285
+ const getScaledAlphaPrice = (alphaIn, taoIn) => {
2286
+ if (!alphaIn || !taoIn) return 0n;
2287
+ return taoIn * ALPHA_PRICE_SCALE / alphaIn;
2288
+ };
2289
+ const alphaToTao = (alpha, scaledAlphaPrice) => {
2290
+ if (!alpha || !scaledAlphaPrice) return 0n;
2291
+ return alpha * scaledAlphaPrice / ALPHA_PRICE_SCALE;
2292
+ };
2293
+ const taoToAlpha = (tao, scaledAlphaPrice) => {
2294
+ if (!tao || !scaledAlphaPrice) return 0n;
2295
+ return tao * ALPHA_PRICE_SCALE / scaledAlphaPrice;
2296
+ };
2297
+
2298
+ const fetchBalances$5 = async ({
2299
+ networkId,
2300
+ tokensWithAddresses,
2301
+ connector,
2302
+ miniMetadata
2303
+ }) => {
2304
+ if (!tokensWithAddresses.length) return {
2305
+ success: [],
2306
+ errors: []
2307
+ };
2308
+ const balanceDefs = getBalanceDefs(tokensWithAddresses);
2309
+ if (!miniMetadata?.data) {
2310
+ log.warn(`MiniMetadata is required for fetching ${MODULE_TYPE$5} balances on ${networkId}.`, {
2311
+ tokensWithAddresses
2312
+ });
2313
+ return {
2314
+ success: [],
2315
+ errors: balanceDefs.map(def => ({
2316
+ tokenId: def.token.id,
2317
+ address: def.address,
2318
+ error: new Error("Minimetadata is required for fetching balances")
2319
+ }))
2320
+ };
2321
+ }
2322
+ if (miniMetadata.source !== MODULE_TYPE$5) {
2323
+ log.warn(`Ignoring miniMetadata with source ${miniMetadata.source} in ${MODULE_TYPE$5}.`);
2324
+ return {
2325
+ success: [],
2326
+ errors: balanceDefs.map(def => ({
2327
+ tokenId: def.token.id,
2328
+ address: def.address,
2329
+ error: new Error(`Invalid request: miniMetadata source is not ${MODULE_TYPE$5}`)
2330
+ }))
2331
+ };
2332
+ }
2333
+ if (miniMetadata.chainId !== networkId) {
2334
+ log.warn(`Ignoring miniMetadata with chainId ${miniMetadata.chainId} in ${MODULE_TYPE$5}. Expected chainId is ${networkId}`);
2335
+ return {
2336
+ success: [],
2337
+ errors: balanceDefs.map(def => ({
2338
+ tokenId: def.token.id,
2339
+ address: def.address,
2340
+ error: new Error(`Invalid request: Expected chainId is ${networkId}`)
2341
+ }))
2342
+ };
2343
+ }
2344
+ const addresses = lodashEs.uniq(balanceDefs.map(def => def.address));
2345
+ try {
2346
+ const [stakeInfos, dynamicInfos] = await Promise.all([fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "StakeInfoRuntimeApi", "get_stake_info_for_coldkeys", [addresses]), fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "SubnetInfoRuntimeApi", "get_all_dynamic_info", [])]);
2347
+ const dynamicInfoByNetuid = lodashEs.keyBy(dynamicInfos.filter(util.isNotNil), info => info.netuid);
2348
+ const balances = stakeInfos.flatMap(([address, stakes]) => stakes.map(stake => {
2349
+ const dynamicInfo = dynamicInfoByNetuid[stake.netuid];
2350
+ const scaledAlphaPrice = dynamicInfo ? getScaledAlphaPrice(dynamicInfo.alpha_in, dynamicInfo.tao_in) : 0n;
2351
+ return {
2352
+ address,
2353
+ tokenId: chaindataProvider.subDTaoTokenId(networkId, stake.netuid, stake.hotkey),
2354
+ baseTokenId: chaindataProvider.subDTaoTokenId(networkId, stake.netuid),
2355
+ stake: stake.stake,
2356
+ hotkey: stake.hotkey,
2357
+ netuid: stake.netuid,
2358
+ scaledAlphaPrice
2359
+ };
2360
+ }));
2361
+ const tokensById = lodashEs.keyBy(tokensWithAddresses.map(([token]) => token), t => t.id);
2362
+ const dynamicTokens = [];
2363
+
2364
+ // identify tokens that were not requested but have balances
2365
+ // BalanceProvider will be register them in ChaindataProvider at runtime, so they will be requested on next call
2366
+ for (const bal of balances) {
2367
+ if (!balanceDefs.some(def => def.token.id === bal.tokenId)) {
2368
+ const baseToken = tokensById[bal.baseTokenId];
2369
+ // define a token specific to this staking hotkey
2370
+ if (baseToken) {
2371
+ const cleanToken = chaindataProvider.getCleanToken(baseToken);
2372
+ const newToken = chaindataProvider.TokenSchema.parse({
2373
+ ...cleanToken,
2374
+ id: bal.tokenId,
2375
+ hotkey: bal.hotkey
2376
+ });
2377
+ dynamicTokens.push(newToken);
2378
+ }
2379
+ }
2380
+ }
2381
+ const success = balanceDefs.map(def => {
2382
+ const stake = balances.find(b => b.address === def.address && b.tokenId === def.token.id);
2383
+ const meta = {
2384
+ scaledAlphaPrice: stake?.scaledAlphaPrice.toString() ?? "0"
2385
+ };
2386
+ const balanceValue = {
2387
+ type: "free",
2388
+ label: stake?.netuid === 0 ? "Root Staking" : `Subnet Staking`,
2389
+ amount: stake?.stake.toString() ?? "0",
2390
+ meta
2391
+ };
2392
+ return {
2393
+ address: def.address,
2394
+ networkId,
2395
+ tokenId: def.token.id,
2396
+ source: MODULE_TYPE$5,
2397
+ status: "live",
2398
+ values: [balanceValue]
2399
+ };
2400
+ });
2401
+ return {
2402
+ success,
2403
+ errors: [],
2404
+ dynamicTokens
2405
+ };
2406
+ } catch (err) {
2407
+ log.warn("Failed to fetch balances for substrate-dtao", {
2408
+ err
2409
+ });
2410
+ const errors = balanceDefs.map(def => ({
2411
+ tokenId: def.token.id,
2412
+ address: def.address,
2413
+ error: new Error(`Failed to fetch balance for ${def.address} on ${networkId}`)
2414
+ }));
2415
+ return {
2416
+ success: [],
2417
+ errors
2418
+ };
2419
+ }
2420
+ };
2421
+
2422
+ // hardcoded because we dont have access to native tokens from the balance module
2423
+ const NATIVE_TOKEN_SYMBOLS = {
2424
+ "bittensor": "TAO",
2425
+ "bittensor-testnet": "testTAO"
2426
+ };
2427
+ const fetchTokens$5 = async ({
2428
+ networkId,
2429
+ connector,
2430
+ tokens,
2431
+ miniMetadata
2432
+ }) => {
2433
+ const anyMiniMetadata = miniMetadata;
2434
+ if (!anyMiniMetadata?.data) return [];
2435
+ const [transferableTokensMap, dynamicInfos] = await Promise.all([fetchTransferableTokensMap(connector, anyMiniMetadata.data, networkId), fetchRuntimeCallResult(connector, networkId, anyMiniMetadata.data, "SubnetInfoRuntimeApi", "get_all_dynamic_info", [])]);
2436
+ return dynamicInfos.filter(util.isNotNil).map(info => {
2437
+ const config = tokens.find(t => t.netuid === info.netuid);
2438
+ let symbol = new TextDecoder().decode(Uint8Array.from(info.token_symbol));
2439
+ const subnetName = info.subnet_identity?.subnet_name?.asText() ?? (info.netuid === 0 ? "Root" : `Subnet ${info.netuid}`);
2440
+ const name = `SN${info.netuid} | ${subnetName} ${symbol}`;
2441
+
2442
+ // for root we want same symbol as native so they can be grouped together in portfolio
2443
+ if (info.netuid === 0 && NATIVE_TOKEN_SYMBOLS[networkId]) symbol = NATIVE_TOKEN_SYMBOLS[networkId];
2444
+
2445
+ // if not stage in storage, consider transferable
2446
+ const isTransferable = transferableTokensMap[info.netuid] ?? true;
2447
+ const token = {
2448
+ id: chaindataProvider.subDTaoTokenId(networkId, info.netuid),
2449
+ type: MODULE_TYPE$5,
2450
+ platform: PLATFORM$5,
2451
+ networkId,
2452
+ netuid: info.netuid,
2453
+ isDefault: true,
2454
+ symbol,
2455
+ decimals: 9,
2456
+ name,
2457
+ subnetName,
2458
+ isTransferable
2459
+ };
2460
+ return Object.assign({}, token, config);
2461
+ }).filter(t => {
2462
+ const parsed = chaindataProvider.SubDTaoTokenSchema.safeParse(t);
2463
+ return parsed.success;
2464
+ });
2465
+ };
2466
+ const fetchTransferableTokensMap = async (connector, metadata, networkId) => {
2467
+ const {
2468
+ builder
2469
+ } = scale.parseMetadataRpc(metadata);
2470
+ const transferToggleCodec = builder.buildStorage("SubtensorModule", "TransferToggle");
2471
+ const transferToggleKeys = await connector.send(networkId, "state_getKeys", [scale.getStorageKeyPrefix("SubtensorModule", "TransferToggle")]);
2472
+ const transferToggleResults = await connector.send(networkId, "state_queryStorageAt", [transferToggleKeys]);
2473
+ const transferToggleEntries = transferToggleResults.length ? transferToggleResults[0].changes : [];
2474
+ return lodashEs.fromPairs(transferToggleEntries.map(([key, value]) => {
2475
+ const [netuid] = transferToggleCodec.keys.dec(key);
2476
+ const isTransferable = transferToggleCodec.value.dec(value);
2477
+ return [netuid, isTransferable];
2478
+ }));
2479
+ };
2480
+
2481
+ const getMiniMetadata$6 = ({
2482
+ networkId,
2483
+ specVersion,
2484
+ metadataRpc
2485
+ }) => {
2486
+ const source = MODULE_TYPE$5;
2487
+ const chainId = networkId;
2488
+ const systemVersion = getConstantValue(metadataRpc, "System", "Version");
2489
+ if (specVersion !== systemVersion.spec_version) throw new Error(`specVersion mismatch: expected ${specVersion}, metadata got ${systemVersion.spec_version}`);
2490
+ const id = deriveMiniMetadataId({
2491
+ source,
2492
+ chainId,
2493
+ specVersion
2494
+ });
2495
+ const {
2496
+ unifiedMetadata
2497
+ } = scale.parseMetadataRpc(metadataRpc);
2498
+ if (unifiedMetadata.version < 14) throw new Error(`Unsupported metadata version: ${unifiedMetadata.version}. Minimum required is 14.`);
2499
+ return {
2500
+ id,
2501
+ source,
2502
+ chainId,
2503
+ specVersion,
2504
+ version: chaindataProvider.MINIMETADATA_VERSION,
2505
+ data: getData$4(metadataRpc),
2506
+ extra: null
2507
+ };
2508
+ };
2509
+ const getData$4 = metadataRpc => {
2510
+ const {
2511
+ metadata,
2512
+ unifiedMetadata
2513
+ } = scale.parseMetadataRpc(metadataRpc);
2514
+ const isBittensor = unifiedMetadata.pallets.some(({
2515
+ name
2516
+ }) => name === "SubtensorModule");
2517
+ if (!isBittensor) return null;
2518
+ scale.compactMetadata(metadata, [{
2519
+ pallet: "SubtensorModule",
2520
+ items: ["TransferToggle"]
2521
+ }], [{
2522
+ runtimeApi: "StakeInfoRuntimeApi",
2523
+ methods: ["get_stake_info_for_coldkeys"]
2524
+ }, {
2525
+ runtimeApi: "SubnetInfoRuntimeApi",
2526
+ methods: ["get_all_dynamic_info"]
2527
+ }]);
2528
+ return scale.encodeMetadata(metadata);
2529
+ };
2530
+
2531
+ const getTransferCallData$6 = ({
2532
+ from,
2533
+ to,
2534
+ value,
2535
+ token,
2536
+ metadataRpc
2537
+ }) => {
2538
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$5)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$5}.`);
2539
+ const {
2540
+ netuid: subnetId,
2541
+ hotkey
2542
+ } = chaindataProvider.parseSubDTaoTokenId(token.id);
2543
+ if (!hotkey) throw new Error(`Missing hotkey`);
2544
+ const {
2545
+ builder
2546
+ } = scale.parseMetadataRpc(metadataRpc);
2547
+ const {
2548
+ codec,
2549
+ location
2550
+ } = builder.buildCall("SubtensorModule", "transfer_stake");
2551
+ const args = codec.enc({
2552
+ origin_netuid: subnetId,
2553
+ hotkey,
2554
+ destination_coldkey: to,
2555
+ destination_netuid: subnetId,
2556
+ alpha_amount: value
2557
+ });
2558
+ const callData = polkadotApi.Binary.fromBytes(utils.mergeUint8([new Uint8Array(location), args]));
2559
+ return {
2560
+ address: from,
2561
+ method: callData.asHex()
2562
+ };
2563
+ };
2564
+
2565
+ const SUBSCRIPTION_INTERVAL$2 = 6_000;
2566
+ const subscribeBalances$6 = ({
2567
+ networkId,
2568
+ tokensWithAddresses,
2569
+ connector,
2570
+ miniMetadata
2571
+ }) => {
2572
+ if (!tokensWithAddresses.length) return rxjs.of({
2573
+ success: [],
2574
+ errors: []
2575
+ });
2576
+ return new rxjs.Observable(subscriber => {
2577
+ const abortController = new AbortController();
2578
+
2579
+ // on hydration balances are fetched using a runtimeApi, which can't be subscribed to.
2580
+ // => poll values for each block
2581
+ const poll = async () => {
2582
+ try {
2583
+ if (abortController.signal.aborted) return;
2584
+ const balances = await fetchBalances$5({
2585
+ networkId,
2586
+ tokensWithAddresses: tokensWithAddresses,
2587
+ connector,
2588
+ miniMetadata
2589
+ });
2590
+ if (abortController.signal.aborted) return;
2591
+ subscriber.next(balances);
2592
+ setTimeout(poll, SUBSCRIPTION_INTERVAL$2);
2593
+ } catch (error) {
2594
+ log.error("Error", {
2595
+ module: MODULE_TYPE$5,
2596
+ networkId,
2597
+ miniMetadata,
2598
+ addressesByToken: tokensWithAddresses,
2599
+ error
2600
+ });
2601
+ subscriber.error(error);
2602
+ }
2603
+ };
2604
+ poll();
2605
+ return () => {
2606
+ abortController.abort();
2607
+ };
2608
+ }).pipe(rxjs.distinctUntilChanged(lodashEs.isEqual));
2609
+ };
2610
+
2611
+ const SubDTaoBalanceModule = {
2612
+ type: MODULE_TYPE$5,
2613
+ platform: PLATFORM$5,
2614
+ getMiniMetadata: getMiniMetadata$6,
2615
+ fetchTokens: fetchTokens$5,
2616
+ fetchBalances: fetchBalances$5,
2617
+ subscribeBalances: subscribeBalances$6,
2618
+ getTransferCallData: getTransferCallData$6
2619
+ };
2620
+
2621
+ // to be used by chaindata too
2622
+ const SubDTaoTokenConfigSchema = z__default.default.strictObject({
2623
+ netuid: chaindataProvider.SubDTaoTokenSchema.shape.netuid,
2624
+ ...TokenConfigBaseSchema.shape
2625
+ });
2626
+
2627
+ const ONE_ALPHA = 10n ** TAO_DECIMALS;
2628
+
2629
+ /**
2630
+ * To be used for tokens that don't have a coingecko id
2631
+ *
2632
+ * @param token
2633
+ * @param tokenRates
2634
+ * @param scaledAlphaPrice
2635
+ * @returns
2636
+ */
2637
+ const getDTaoTokenRates = (token, tokenRates$1, scaledAlphaPrice) => {
2638
+ try {
2639
+ const taoTokenId = chaindataProvider.subNativeTokenId(token.networkId);
2640
+ const taoTokenRates = tokenRates$1[taoTokenId];
2641
+ if (!taoTokenRates) return null;
2642
+
2643
+ // for root subnet, same rates as TAO
2644
+ if (token.netuid === 0) return structuredClone(taoTokenRates);
2645
+ const alphaRates = tokenRates.newTokenRates();
2646
+ for (const [currency, taoRate] of Object.entries(taoTokenRates)) {
2647
+ if (!taoRate) {
2648
+ alphaRates[currency] = null;
2649
+ } else {
2650
+ const taoPrice = alphaToTao(ONE_ALPHA, BigInt(scaledAlphaPrice));
2651
+ const priceRatio = Number(taoPrice) / Number(ALPHA_PRICE_SCALE);
2652
+ alphaRates[currency] = {
2653
+ price: taoRate.price * priceRatio,
2654
+ marketCap: taoRate.marketCap ? taoRate.marketCap * priceRatio : undefined,
2655
+ change24h: undefined // cannot be determined from TAO rates alone
2656
+ };
2657
+ }
2658
+ }
2659
+ return alphaRates;
2660
+ } catch (err) {
2661
+ log.error(err);
2662
+ return null;
2663
+ }
2664
+ };
2665
+
2272
2666
  function excludeFromTransferableAmount(locks) {
2273
2667
  if (typeof locks === "string") return BigInt(locks);
2274
2668
  if (!Array.isArray(locks)) locks = [locks];
@@ -2597,6 +2991,16 @@ class Balance {
2597
2991
  return lpTokenRates;
2598
2992
  }
2599
2993
 
2994
+ // dTAO balances need to be converted to the native token to compute their rate, unless we have a coingeckoId
2995
+ if (this.token?.type === "substrate-dtao" && !this.token.coingeckoId) {
2996
+ if (!this.#db?.tokenRates) return null;
2997
+ const balances = this.#valueGetter.get("free");
2998
+ if (!balances.length) return null;
2999
+ const balanceMeta = balances[0].meta;
3000
+ if (!balanceMeta?.scaledAlphaPrice) return null;
3001
+ return getDTaoTokenRates(this.token, this.#db.tokenRates, balanceMeta.scaledAlphaPrice);
3002
+ }
3003
+
2600
3004
  // other tokens can just pick from the tokenRates db using the tokenId
2601
3005
  return this.#db?.tokenRates && this.#db.tokenRates[this.tokenId] || null;
2602
3006
  }
@@ -2643,9 +3047,7 @@ class Balance {
2643
3047
  const nomPoolStakedPlancks = this.locks.some(lock => lock.source === "substrate-native-holds" && lock.label === "DelegatedStaking") ? 0n : this.nompools.map(({
2644
3048
  amount
2645
3049
  }) => amount.planck).reduce((a, b) => a + b, 0n);
2646
- return this.#format(this.free.planck + this.reserved.planck + nomPoolStakedPlancks + this.subtensor.map(({
2647
- amount
2648
- }) => amount.planck).reduce((a, b) => a + b, 0n) + includeInTotalExtraAmount(extra));
3050
+ return this.#format(this.free.planck + this.reserved.planck + nomPoolStakedPlancks + includeInTotalExtraAmount(extra));
2649
3051
  }
2650
3052
  /** The non-reserved balance of this token. Includes the frozen amount. Is included in the total. */
2651
3053
  get free() {
@@ -2682,9 +3084,6 @@ class Balance {
2682
3084
  get nompools() {
2683
3085
  return this.getValue("nompool");
2684
3086
  }
2685
- get subtensor() {
2686
- return this.getValue("subtensor");
2687
- }
2688
3087
 
2689
3088
  /** The extra balance of this token */
2690
3089
  get extra() {
@@ -2757,8 +3156,7 @@ class Balance {
2757
3156
  const nomPoolStakedPlancks = this.locks.some(lock => lock.source === "substrate-native-holds" && lock.label === "DelegatedStaking") ? 0n : this.nompools.map(({
2758
3157
  amount
2759
3158
  }) => amount.planck).reduce((a, b) => a + b, 0n);
2760
- const otherUnavailable = nomPoolStakedPlancks + this.subtensor.reduce((total, each) => total + each.amount.planck, 0n);
2761
- return this.#format(baseUnavailable + otherUnavailable);
3159
+ return this.#format(baseUnavailable + nomPoolStakedPlancks);
2762
3160
  }
2763
3161
 
2764
3162
  /** The feePayable balance of this token. Is generally the free amount - the feeFrozen amount. */
@@ -3005,13 +3403,6 @@ const getValueId = amount => {
3005
3403
  const meta = amount.meta;
3006
3404
  if (!meta) return "";
3007
3405
  if (amount.type === "nompool") return meta.poolId?.toString() ?? "";
3008
- if (amount.type === "subtensor") {
3009
- const {
3010
- hotkey,
3011
- netuid
3012
- } = meta;
3013
- if (hotkey && netuid !== undefined) return `${hotkey.toString()}${netuid.toString()}`;
3014
- }
3015
3406
  return "";
3016
3407
  };
3017
3408
  return [amount.label, amount.type, amount.source, getMetaId()].join("::");
@@ -3033,7 +3424,7 @@ const getMiniMetadata$5 = ({
3033
3424
  specVersion,
3034
3425
  metadataRpc
3035
3426
  }) => {
3036
- const source = MODULE_TYPE$5;
3427
+ const source = MODULE_TYPE$6;
3037
3428
  const chainId = networkId;
3038
3429
  const systemVersion = getConstantValue(metadataRpc, "System", "Version");
3039
3430
  if (specVersion !== systemVersion.spec_version) throw new Error(`specVersion mismatch: expected ${specVersion}, metadata got ${systemVersion.spec_version}`);
@@ -3079,7 +3470,7 @@ const getTransferCallData$5 = ({
3079
3470
  type,
3080
3471
  metadataRpc
3081
3472
  }) => {
3082
- if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$5)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$5}.`);
3473
+ if (!chaindataProvider.isTokenOfType(token, MODULE_TYPE$6)) throw new Error(`Token type ${token.type} is not ${MODULE_TYPE$6}.`);
3083
3474
  const {
3084
3475
  builder
3085
3476
  } = scale.parseMetadataRpc(metadataRpc);
@@ -3187,11 +3578,11 @@ const subscribeBalances$5 = ({
3187
3578
  };
3188
3579
 
3189
3580
  const SubAssetsBalanceModule = {
3190
- type: MODULE_TYPE$5,
3191
- platform: PLATFORM$5,
3581
+ type: MODULE_TYPE$6,
3582
+ platform: PLATFORM$6,
3192
3583
  getMiniMetadata: getMiniMetadata$5,
3193
- fetchTokens: fetchTokens$5,
3194
- fetchBalances: fetchBalances$5,
3584
+ fetchTokens: fetchTokens$6,
3585
+ fetchBalances: fetchBalances$6,
3195
3586
  subscribeBalances: subscribeBalances$5,
3196
3587
  getTransferCallData: getTransferCallData$5
3197
3588
  };
@@ -3912,154 +4303,6 @@ const SubHydrationBalanceModule = {
3912
4303
  const MODULE_TYPE$2 = chaindataProvider.SubNativeTokenSchema.shape.type.value;
3913
4304
  const PLATFORM$2 = chaindataProvider.SubNativeTokenSchema.shape.platform.value;
3914
4305
 
3915
- const SUBTENSOR_ROOT_NETUID = 0;
3916
- const SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = 1000000n;
3917
- const TAO_DECIMALS = 9n;
3918
- const SCALE_FACTOR = 10n ** TAO_DECIMALS; // Equivalent to 10e9 for precision
3919
- const ONE_ALPHA_TOKEN = SCALE_FACTOR;
3920
- const calculateAlphaPrice = ({
3921
- dynamicInfo
3922
- }) => {
3923
- if (!dynamicInfo) return 0n;
3924
- const {
3925
- alpha_in,
3926
- tao_in
3927
- } = dynamicInfo;
3928
-
3929
- // Scale taoIn before division to preserve precision
3930
- const result = tao_in * SCALE_FACTOR / alpha_in;
3931
- return result; // Scaled price as bigint
3932
- };
3933
- const calculateTaoAmountFromAlpha = ({
3934
- alphaPrice,
3935
- alphaStaked
3936
- }) => {
3937
- if (!alphaStaked || !alphaPrice) return 0n;
3938
- const expectedAlpha = alphaStaked * alphaPrice;
3939
- return expectedAlpha / SCALE_FACTOR;
3940
- };
3941
- const calculateTaoFromDynamicInfo = ({
3942
- dynamicInfo,
3943
- alphaStaked
3944
- }) => {
3945
- const alphaPrice = calculateAlphaPrice({
3946
- dynamicInfo
3947
- });
3948
- return calculateTaoAmountFromAlpha({
3949
- alphaPrice,
3950
- alphaStaked
3951
- });
3952
- };
3953
-
3954
- // per address, lists of values to add to the native balance
3955
-
3956
- const getSubtensorStakingBalances$ = (connector, networkId, balanceDefs, miniMetadata) => {
3957
- const addresses = balanceDefs.map(def => def.address);
3958
- const token = balanceDefs[0].token;
3959
- if (!addresses.length || !token || !miniMetadata.extra.hasSubtensorPallet || !miniMetadata.data) return rxjs.of({});
3960
-
3961
- // we are only doing runtime calls, there is no way to subscribe to changes, except polling
3962
- // => start immediately, then repeat every 30 seconds
3963
- return rxjs.timer(0, 30000).pipe(rxjs.switchMap(() => rxjs.from(fetchStakeInfoByAddress(connector, networkId, miniMetadata, addresses)).pipe(rxjs.switchMap(stakeInfoByAddress => fetchStakingBalanceValuesByAddress(connector, networkId, miniMetadata, stakeInfoByAddress)))));
3964
- };
3965
- const fetchStakingBalanceValuesByAddress = async (connector, networkId, miniMetadata, stakeInfoByAddress) => {
3966
- const uniqueNetuids = lodashEs.uniq(lodashEs.values(stakeInfoByAddress).flatMap(infos => infos.map(info => info.netuid))).filter(netuid => netuid !== SUBTENSOR_ROOT_NETUID);
3967
- const dynamicInfoByNetuid = await fetchDynamicInfoByNetuid(connector, networkId, miniMetadata, uniqueNetuids);
3968
- return lodashEs.fromPairs(lodashEs.toPairs(stakeInfoByAddress).map(([address, stakeInfos]) => {
3969
- const stakesBalances = stakeInfos.filter(({
3970
- stake
3971
- }) => stake >= SUBTENSOR_MIN_STAKE_AMOUNT_PLANK).map(({
3972
- hotkey,
3973
- netuid,
3974
- stake
3975
- }) => ({
3976
- hotkey,
3977
- netuid: Number(netuid),
3978
- stake: BigInt(stake),
3979
- dynamicInfo: dynamicInfoByNetuid[Number(netuid)]
3980
- })).map(({
3981
- hotkey,
3982
- stake,
3983
- netuid,
3984
- dynamicInfo
3985
- }) => {
3986
- const {
3987
- token_symbol,
3988
- subnet_name,
3989
- subnet_identity
3990
- } = dynamicInfo ?? {};
3991
- const tokenSymbol = new TextDecoder().decode(Uint8Array.from(token_symbol ?? []));
3992
- const subnetName = new TextDecoder().decode(Uint8Array.from(subnet_name ?? []));
3993
- const subnetIdentity = subnet_identity ? lodashEs.fromPairs(lodashEs.toPairs(subnet_identity).map(([key, binary]) => [key, binary.asText()])) : undefined;
3994
-
3995
- // Add 1n balance if failed to fetch dynamic info, so the position is not ignored by Balance lib and is displayed in the UI.
3996
- const alphaStakedInTao = dynamicInfo ? calculateTaoFromDynamicInfo({
3997
- dynamicInfo,
3998
- alphaStaked: stake
3999
- }) : 1n;
4000
- const alphaToTaoRate = calculateTaoFromDynamicInfo({
4001
- dynamicInfo: dynamicInfo ?? null,
4002
- alphaStaked: ONE_ALPHA_TOKEN
4003
- }).toString();
4004
- const stakeByNetuid = Number(netuid) === SUBTENSOR_ROOT_NETUID ? stake : alphaStakedInTao;
4005
- const balanceValue = {
4006
- source: "subtensor-staking",
4007
- type: "subtensor",
4008
- label: "subtensor-staking",
4009
- amount: stakeByNetuid.toString(),
4010
- meta: {
4011
- type: "subtensor-staking",
4012
- hotkey,
4013
- netuid,
4014
- amountStaked: stake.toString(),
4015
- alphaToTaoRate,
4016
- dynamicInfo: {
4017
- tokenSymbol,
4018
- subnetName,
4019
- subnetIdentity: {
4020
- ...subnetIdentity,
4021
- subnetName: subnetIdentity?.subnet_name || subnetName
4022
- }
4023
- }
4024
- }
4025
- };
4026
- return balanceValue;
4027
- });
4028
- return [address, stakesBalances];
4029
- }));
4030
- };
4031
- const fetchStakeInfoByAddress = async (connector, networkId, miniMetadata, addresses) => {
4032
- const pairs = await Promise.all(addresses.map(async address => [address, await viem.withRetry(() => fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "StakeInfoRuntimeApi", "get_stake_info_for_coldkey", [address]), {
4033
- delay: 500,
4034
- retryCount: 3
4035
- })]));
4036
- return lodashEs.fromPairs(pairs);
4037
- };
4038
-
4039
- // assume dynamic info doesnt change over the course of a browser session
4040
- const dynamicInfoCache = new Map();
4041
- const getCacheKey$1 = (networkId, netuid) => `${networkId}:${netuid}`;
4042
- const fetchDynamicInfoByNetuid = async (connector, networkId, miniMetadata, uniqueNetuids) => {
4043
- const fetchInfo = async netuid => {
4044
- if (netuid === SUBTENSOR_ROOT_NETUID) return null;
4045
- const cacheKey = getCacheKey$1(networkId, netuid);
4046
- if (!dynamicInfoCache.has(cacheKey)) {
4047
- await viem.withRetry(async () => {
4048
- const result = await fetchRuntimeCallResult(connector, networkId, miniMetadata.data, "SubnetInfoRuntimeApi", "get_dynamic_info", [netuid]);
4049
- dynamicInfoCache.set(cacheKey, result); // Cache successful response
4050
-
4051
- return result;
4052
- }, {
4053
- delay: 500,
4054
- retryCount: 3
4055
- });
4056
- }
4057
- return dynamicInfoCache.get(cacheKey) ?? null;
4058
- };
4059
- const results = await Promise.all(uniqueNetuids.map(async netuid => [netuid, await fetchInfo(netuid)]));
4060
- return lodashEs.fromPairs(results);
4061
- };
4062
-
4063
4306
  const getOtherType = input => `other-${input}`;
4064
4307
 
4065
4308
  /**
@@ -4500,17 +4743,6 @@ const fetchBalances$2 = async ({
4500
4743
  // now for each balance that includes nomPoolStaking, we need to fetch the metadata for the pool
4501
4744
  const nomPoolQueries = buildNomPoolQueries(networkId, partialBalances, miniMetadata);
4502
4745
  const balances = await fetchRpcQueryPack(connector, networkId, nomPoolQueries);
4503
-
4504
- // TODO ⚠️ dedupe locks
4505
-
4506
- const subtensorBalances$ = getSubtensorStakingBalances$(connector, networkId, balanceDefs, miniMetadata);
4507
- const subtensorBalancesByAddress = await rxjs.firstValueFrom(subtensorBalances$);
4508
- for (const [address, subtensorBalances] of Object.entries(subtensorBalancesByAddress)) {
4509
- const balance = balances.find(b => b.address === address);
4510
- if (balance?.values) balance.values = [...balance.values.filter(({
4511
- source
4512
- }) => source !== "subtensor-staking"), ...subtensorBalances];
4513
- }
4514
4746
  return {
4515
4747
  success: balances,
4516
4748
  errors: []
@@ -4599,7 +4831,6 @@ const getMiniMetadata$2 = ({
4599
4831
  };
4600
4832
  const existentialDeposit = tryGetConstantValue(metadataRpc, "Balances", "ExistentialDeposit")?.toString();
4601
4833
  const nominationPoolsPalletId = tryGetConstantValue(metadataRpc, "NominationPools", "PalletId")?.asText();
4602
- const hasSubtensorPallet = !!tryGetConstantValue(metadataRpc, "SubtensorModule", "KeySwapCost");
4603
4834
  const hasFreezesItem = Boolean(unifiedMetadata.pallets.find(({
4604
4835
  name
4605
4836
  }) => name === "Balances")?.storage?.items.find(({
@@ -4619,15 +4850,6 @@ const getMiniMetadata$2 = ({
4619
4850
  }, {
4620
4851
  pallet: "Staking",
4621
4852
  items: ["Ledger"]
4622
- }, {
4623
- pallet: "SubtensorModule",
4624
- items: ["StakingHotkeys", "Stake"]
4625
- }], [{
4626
- runtimeApi: "StakeInfoRuntimeApi",
4627
- methods: ["get_stake_info_for_coldkey"]
4628
- }, {
4629
- runtimeApi: "SubnetInfoRuntimeApi",
4630
- methods: ["get_dynamic_info"]
4631
4853
  }]);
4632
4854
  return {
4633
4855
  id,
@@ -4639,8 +4861,7 @@ const getMiniMetadata$2 = ({
4639
4861
  extra: {
4640
4862
  useLegacyTransferableCalculation,
4641
4863
  existentialDeposit,
4642
- nominationPoolsPalletId,
4643
- hasSubtensorPallet
4864
+ nominationPoolsPalletId
4644
4865
  }
4645
4866
  };
4646
4867
  };
@@ -4750,19 +4971,12 @@ const subscribeBalances$2 = ({
4750
4971
  // could be use as shared observable key if we decide to cache the sub
4751
4972
  const balanceDefs = getBalanceDefs(tokensWithAddresses);
4752
4973
  const baseQueries = buildBaseQueries(networkId, balanceDefs, miniMetadata);
4753
- const baseBalances$ = getRpcQueryPack$(connector, networkId, baseQueries).pipe(rxjs.switchMap(partialBalances => {
4974
+ return getRpcQueryPack$(connector, networkId, baseQueries).pipe(rxjs.switchMap(partialBalances => {
4754
4975
  // now for each balance that includes nomPoolStaking, we need to fetch the metadata for the pool
4755
4976
  const nomPoolQueries = buildNomPoolQueries(networkId, partialBalances, miniMetadata);
4756
4977
  return getRpcQueryPack$(connector, networkId, nomPoolQueries);
4757
- }));
4758
- const subtensorBalancesByAddress$ = getSubtensorStakingBalances$(connector, networkId, balanceDefs, miniMetadata);
4759
- return rxjs.combineLatest([baseBalances$, subtensorBalancesByAddress$]).pipe(rxjs.map(([baseBalances, subtensorBalancesByAddress]) => ({
4760
- success: [...baseBalances.map(b => ({
4761
- ...b,
4762
- values: [...(b.values?.filter(({
4763
- source
4764
- }) => source !== "subtensor-staking") ?? []), ...(subtensorBalancesByAddress[b.address] ?? [])]
4765
- }))],
4978
+ }), rxjs.map(balances => ({
4979
+ success: balances,
4766
4980
  errors: []
4767
4981
  })));
4768
4982
  };
@@ -4794,8 +5008,7 @@ const SubNativeMiniMetadataExtraSchema = z__default.default.strictObject({
4794
5008
  disable: z__default.default.boolean().optional(),
4795
5009
  useLegacyTransferableCalculation: z__default.default.boolean().optional(),
4796
5010
  existentialDeposit: z__default.default.string().optional(),
4797
- nominationPoolsPalletId: z__default.default.string().optional(),
4798
- hasSubtensorPallet: z__default.default.boolean().optional()
5011
+ nominationPoolsPalletId: z__default.default.string().optional()
4799
5012
  });
4800
5013
 
4801
5014
  // Do not use this type outside of this module
@@ -6598,7 +6811,7 @@ const SubTokensMiniMetadataExtraSchema = z__default.default.strictObject({
6598
6811
  palletId: z__default.default.string()
6599
6812
  });
6600
6813
 
6601
- const BALANCE_MODULES = [SubNativeBalanceModule, SubAssetsBalanceModule, SubHydrationBalanceModule, SubForeignAssetsBalanceModule, SubPsp22BalanceModule, SubTokensBalanceModule, EvmErc20BalanceModule, EvmUniswapV2BalanceModule, EvmNativeBalanceModule, SolNativeBalanceModule, SolSplBalanceModule];
6814
+ const BALANCE_MODULES = [SubNativeBalanceModule, SubAssetsBalanceModule, SubDTaoBalanceModule, SubHydrationBalanceModule, SubForeignAssetsBalanceModule, SubPsp22BalanceModule, SubTokensBalanceModule, EvmErc20BalanceModule, EvmUniswapV2BalanceModule, EvmNativeBalanceModule, SolNativeBalanceModule, SolSplBalanceModule];
6602
6815
 
6603
6816
  // share requests as all modules will call this at once
6604
6817
  const CACHE$1 = new Map();
@@ -6754,7 +6967,8 @@ class BalancesProvider {
6754
6967
  balances: results.flatMap(result => result.balances.map(b => isStale && b.status !== "live" ? {
6755
6968
  ...b,
6756
6969
  status: "stale"
6757
- } : b)).sort(sortByBalanceId)
6970
+ } : b)).sort(sortByBalanceId),
6971
+ failedBalanceIds: results.flatMap(result => result.failedBalanceIds)
6758
6972
  })), rxjs.distinctUntilChanged(lodashEs.isEqual));
6759
6973
  }
6760
6974
  fetchBalances(addressesByTokenId) {
@@ -6795,17 +7009,25 @@ class BalancesProvider {
6795
7009
  });
6796
7010
  return rxjs.of({
6797
7011
  status: "live",
6798
- balances: []
7012
+ balances: [],
7013
+ failedBalanceIds: []
6799
7014
  });
6800
7015
  }
6801
7016
  }
6802
7017
  }));
6803
7018
  }), rxjs.map(results => {
7019
+ // for each balance that could not be fetched, see if we have a stored balance and return it, marked as stale
7020
+ const errorBalanceIds = results.flatMap(result => result.failedBalanceIds);
7021
+ const staleBalances = errorBalanceIds.map(balanceId => this.#storage.value.balances[balanceId]).filter(util.isNotNil).map(b => ({
7022
+ ...b,
7023
+ status: "stale"
7024
+ }));
6804
7025
  return {
6805
7026
  status: results.some(({
6806
7027
  status
6807
7028
  }) => status === "initialising") ? "initialising" : "live",
6808
- balances: results.flatMap(result => result.balances).sort(sortByBalanceId)
7029
+ balances: results.flatMap(result => result.balances).concat(staleBalances).sort(sortByBalanceId),
7030
+ failedBalanceIds: []
6809
7031
  };
6810
7032
  }), rxjs.distinctUntilChanged(lodashEs.isEqual));
6811
7033
  }
@@ -6817,7 +7039,8 @@ class BalancesProvider {
6817
7039
  }, () => {
6818
7040
  if (!tokensWithAddresses.length) return rxjs.of({
6819
7041
  status: "live",
6820
- balances: []
7042
+ balances: [],
7043
+ failedBalanceIds: []
6821
7044
  });
6822
7045
  const moduleAddressesByTokenId = lodashEs.fromPairs(tokensWithAddresses.map(([token, addresses]) => [token.id, addresses]));
6823
7046
 
@@ -6830,7 +7053,8 @@ class BalancesProvider {
6830
7053
  log.warn("[balances] no substrate connector or miniMetadata for module", mod.type);
6831
7054
  return rxjs.defer(() => rxjs.of({
6832
7055
  status: "initialising",
6833
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7056
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7057
+ failedBalanceIds: []
6834
7058
  }));
6835
7059
  }
6836
7060
  const moduleBalances$ = this.getNetworkMiniMetadatas$(networkId).pipe(rxjs.map(miniMetadatas => miniMetadatas.find(m => m.source === mod.type)), rxjs.switchMap(miniMetadata => mod.subscribeBalances({
@@ -6840,10 +7064,22 @@ class BalancesProvider {
6840
7064
  miniMetadata: miniMetadata
6841
7065
  })), rxjs.catchError(() => rxjs.EMPTY),
6842
7066
  // don't emit, let provider mark balances stale
6843
- rxjs.map(results => ({
7067
+ rxjs.tap(results => {
7068
+ if (results.dynamicTokens?.length) {
7069
+ // register missing tokens in the chaindata provider
7070
+ this.#chaindataProvider.registerDynamicTokens(results.dynamicTokens);
7071
+ }
7072
+ }), rxjs.map(results => ({
6844
7073
  status: "live",
6845
7074
  // exclude zero balances
6846
- balances: results.success.filter(b => new Balance(b).total.planck > 0n)
7075
+ balances: results.success.filter(b => new Balance(b).total.planck > 0n),
7076
+ failedBalanceIds: results.errors.map(({
7077
+ tokenId,
7078
+ address
7079
+ }) => getBalanceId({
7080
+ tokenId,
7081
+ address
7082
+ }))
6847
7083
  })), rxjs.tap(results => {
6848
7084
  this.updateStorage$(balanceIds, results);
6849
7085
  }),
@@ -6856,7 +7092,8 @@ class BalancesProvider {
6856
7092
  // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6857
7093
  return rxjs.defer(() => moduleBalances$.pipe(rxjs.startWith({
6858
7094
  status: "initialising",
6859
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7095
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7096
+ failedBalanceIds: []
6860
7097
  })));
6861
7098
  });
6862
7099
  }
@@ -6868,7 +7105,8 @@ class BalancesProvider {
6868
7105
  }, () => {
6869
7106
  if (!tokensWithAddresses.length) return rxjs.of({
6870
7107
  status: "live",
6871
- balances: []
7108
+ balances: [],
7109
+ failedBalanceIds: []
6872
7110
  });
6873
7111
  const moduleAddressesByTokenId = lodashEs.fromPairs(tokensWithAddresses.map(([token, addresses]) => [token.id, addresses]));
6874
7112
 
@@ -6881,7 +7119,8 @@ class BalancesProvider {
6881
7119
  log.warn("[balances] no ethereum connector for module", mod.type);
6882
7120
  return rxjs.defer(() => rxjs.of({
6883
7121
  status: "initialising",
6884
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7122
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7123
+ failedBalanceIds: []
6885
7124
  }));
6886
7125
  }
6887
7126
  const moduleBalances$ = mod.subscribeBalances({
@@ -6893,7 +7132,14 @@ class BalancesProvider {
6893
7132
  rxjs.map(results => ({
6894
7133
  status: "live",
6895
7134
  // exclude zero balances
6896
- balances: results.success.filter(b => new Balance(b).total.planck > 0n)
7135
+ balances: results.success.filter(b => new Balance(b).total.planck > 0n),
7136
+ failedBalanceIds: results.errors.map(({
7137
+ tokenId,
7138
+ address
7139
+ }) => getBalanceId({
7140
+ tokenId,
7141
+ address
7142
+ }))
6897
7143
  })), rxjs.tap(results => {
6898
7144
  this.updateStorage$(balanceIds, results);
6899
7145
  }),
@@ -6906,7 +7152,8 @@ class BalancesProvider {
6906
7152
  // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6907
7153
  return rxjs.defer(() => moduleBalances$.pipe(rxjs.startWith({
6908
7154
  status: "initialising",
6909
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7155
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7156
+ failedBalanceIds: []
6910
7157
  })));
6911
7158
  });
6912
7159
  }
@@ -6918,7 +7165,8 @@ class BalancesProvider {
6918
7165
  }, () => {
6919
7166
  if (!tokensWithAddresses.length) return rxjs.of({
6920
7167
  status: "live",
6921
- balances: []
7168
+ balances: [],
7169
+ failedBalanceIds: []
6922
7170
  });
6923
7171
  const moduleAddressesByTokenId = lodashEs.fromPairs(tokensWithAddresses.map(([token, addresses]) => [token.id, addresses]));
6924
7172
 
@@ -6931,7 +7179,8 @@ class BalancesProvider {
6931
7179
  log.warn("[balances] no solana connector for module", mod.type);
6932
7180
  return rxjs.defer(() => rxjs.of({
6933
7181
  status: "initialising",
6934
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7182
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7183
+ failedBalanceIds: []
6935
7184
  }));
6936
7185
  }
6937
7186
  const moduleBalances$ = mod.subscribeBalances({
@@ -6943,7 +7192,14 @@ class BalancesProvider {
6943
7192
  rxjs.map(results => ({
6944
7193
  status: "live",
6945
7194
  // exclude zero balances
6946
- balances: results.success.filter(b => new Balance(b).total.planck > 0n)
7195
+ balances: results.success.filter(b => new Balance(b).total.planck > 0n),
7196
+ failedBalanceIds: results.errors.map(({
7197
+ tokenId,
7198
+ address
7199
+ }) => getBalanceId({
7200
+ tokenId,
7201
+ address
7202
+ }))
6947
7203
  })), rxjs.tap(results => {
6948
7204
  this.updateStorage$(balanceIds, results);
6949
7205
  }),
@@ -6956,7 +7212,8 @@ class BalancesProvider {
6956
7212
  // defer the startWith call to start with up to date balances each time the observable is re-subscribed to
6957
7213
  return rxjs.defer(() => moduleBalances$.pipe(rxjs.startWith({
6958
7214
  status: "initialising",
6959
- balances: this.getStoredBalances(moduleAddressesByTokenId)
7215
+ balances: this.getStoredBalances(moduleAddressesByTokenId),
7216
+ failedBalanceIds: []
6960
7217
  })));
6961
7218
  });
6962
7219
  }
@@ -6964,13 +7221,19 @@ class BalancesProvider {
6964
7221
  if (balancesResult.status !== "live") return;
6965
7222
  const storage = this.#storage.getValue();
6966
7223
  const balances = lodashEs.assign({}, storage.balances,
6967
- // delete all balances expected in the result set. because if they are not present it means they are empty.
6968
- lodashEs.fromPairs(balanceIds.map(balanceId => [balanceId, undefined])), lodashEs.keyBy(
7224
+ // delete all balances expected in the result set (except the ones that failed). because if they are not present it means they are empty.
7225
+ lodashEs.fromPairs(balanceIds.filter(bid => !balancesResult.failedBalanceIds.includes(bid)).map(balanceId => [balanceId, undefined])), lodashEs.keyBy(
6969
7226
  // storage balances must have status "cache", because they are used as start value when initialising subsequent subscriptions
6970
7227
  balancesResult.balances.map(b => ({
6971
7228
  ...b,
6972
7229
  status: "cache"
6973
7230
  })), b => getBalanceId(b)));
7231
+
7232
+ // update status of stale balances
7233
+ for (const errorBalanceId of balancesResult.failedBalanceIds) {
7234
+ const balance = balances[errorBalanceId];
7235
+ if (balance) balance.status = "stale";
7236
+ }
6974
7237
  this.#storage.next(lodashEs.assign({}, storage, {
6975
7238
  balances
6976
7239
  }));
@@ -7112,6 +7375,7 @@ Object.defineProperty(exports, "MINIMETADATA_VERSION", {
7112
7375
  enumerable: true,
7113
7376
  get: function () { return chaindataProvider.MINIMETADATA_VERSION; }
7114
7377
  });
7378
+ exports.ALPHA_PRICE_SCALE = ALPHA_PRICE_SCALE;
7115
7379
  exports.BALANCE_MODULES = BALANCE_MODULES;
7116
7380
  exports.Balance = Balance;
7117
7381
  exports.BalanceFormatter = BalanceFormatter;
@@ -7126,17 +7390,15 @@ exports.EvmNativeTokenConfigSchema = EvmNativeTokenConfigSchema;
7126
7390
  exports.EvmUniswapV2BalanceModule = EvmUniswapV2BalanceModule;
7127
7391
  exports.EvmUniswapV2TokenConfigSchema = EvmUniswapV2TokenConfigSchema;
7128
7392
  exports.FiatSumBalancesFormatter = FiatSumBalancesFormatter;
7129
- exports.ONE_ALPHA_TOKEN = ONE_ALPHA_TOKEN;
7130
7393
  exports.PlanckSumBalancesFormatter = PlanckSumBalancesFormatter;
7131
- exports.SCALE_FACTOR = SCALE_FACTOR;
7132
- exports.SUBTENSOR_MIN_STAKE_AMOUNT_PLANK = SUBTENSOR_MIN_STAKE_AMOUNT_PLANK;
7133
- exports.SUBTENSOR_ROOT_NETUID = SUBTENSOR_ROOT_NETUID;
7134
7394
  exports.SolNativeBalanceModule = SolNativeBalanceModule;
7135
7395
  exports.SolNativeTokenConfigSchema = SolNativeTokenConfigSchema;
7136
7396
  exports.SolSplBalanceModule = SolSplBalanceModule;
7137
7397
  exports.SolSplTokenConfigSchema = SolSplTokenConfigSchema;
7138
7398
  exports.SubAssetsBalanceModule = SubAssetsBalanceModule;
7139
7399
  exports.SubAssetsTokenConfigSchema = SubAssetsTokenConfigSchema;
7400
+ exports.SubDTaoBalanceModule = SubDTaoBalanceModule;
7401
+ exports.SubDTaoTokenConfigSchema = SubDTaoTokenConfigSchema;
7140
7402
  exports.SubForeignAssetsBalanceModule = SubForeignAssetsBalanceModule;
7141
7403
  exports.SubForeignAssetsTokenConfigSchema = SubForeignAssetsTokenConfigSchema;
7142
7404
  exports.SubHydrationBalanceModule = SubHydrationBalanceModule;
@@ -7152,10 +7414,9 @@ exports.SubTokensMiniMetadataExtraSchema = SubTokensMiniMetadataExtraSchema;
7152
7414
  exports.SubTokensModuleConfigSchema = SubTokensModuleConfigSchema;
7153
7415
  exports.SubTokensTokenConfigSchema = SubTokensTokenConfigSchema;
7154
7416
  exports.SumBalancesFormatter = SumBalancesFormatter;
7417
+ exports.TAO_DECIMALS = TAO_DECIMALS;
7155
7418
  exports.abiMulticall = abiMulticall;
7156
- exports.calculateAlphaPrice = calculateAlphaPrice;
7157
- exports.calculateTaoAmountFromAlpha = calculateTaoAmountFromAlpha;
7158
- exports.calculateTaoFromDynamicInfo = calculateTaoFromDynamicInfo;
7419
+ exports.alphaToTao = alphaToTao;
7159
7420
  exports.deriveMiniMetadataId = deriveMiniMetadataId;
7160
7421
  exports.erc20BalancesAggregatorAbi = erc20BalancesAggregatorAbi;
7161
7422
  exports.excludeFromFeePayableLocks = excludeFromFeePayableLocks;
@@ -7163,8 +7424,11 @@ exports.excludeFromTransferableAmount = excludeFromTransferableAmount;
7163
7424
  exports.filterBaseLocks = filterBaseLocks;
7164
7425
  exports.filterMirrorTokens = filterMirrorTokens;
7165
7426
  exports.getBalanceId = getBalanceId;
7427
+ exports.getDTaoTokenRates = getDTaoTokenRates;
7166
7428
  exports.getLockTitle = getLockTitle;
7167
7429
  exports.getLockedType = getLockedType;
7430
+ exports.getScaledAlphaPrice = getScaledAlphaPrice;
7168
7431
  exports.getValueId = getValueId;
7169
7432
  exports.includeInTotalExtraAmount = includeInTotalExtraAmount;
7433
+ exports.taoToAlpha = taoToAlpha;
7170
7434
  exports.uniswapV2PairAbi = uniswapV2PairAbi;