@talismn/balances 1.0.8 → 1.1.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 (23) hide show
  1. package/dist/declarations/src/modules/index.d.ts +12 -1
  2. package/dist/declarations/src/modules/substrate-dtao/alphaPrice.d.ts +5 -0
  3. package/dist/declarations/src/modules/substrate-dtao/config.d.ts +5 -0
  4. package/dist/declarations/src/modules/substrate-dtao/fetchBalances.d.ts +3 -0
  5. package/dist/declarations/src/modules/substrate-dtao/fetchTokens.d.ts +3 -0
  6. package/dist/declarations/src/modules/substrate-dtao/getDtaoTokenRates.d.ts +11 -0
  7. package/dist/declarations/src/modules/substrate-dtao/getMiniMetadata.d.ts +3 -0
  8. package/dist/declarations/src/modules/substrate-dtao/getTransferCallData.d.ts +3 -0
  9. package/dist/declarations/src/modules/substrate-dtao/index.d.ts +4 -0
  10. package/dist/declarations/src/modules/substrate-dtao/module.d.ts +3 -0
  11. package/dist/declarations/src/modules/substrate-dtao/subscribeBalances.d.ts +3 -0
  12. package/dist/declarations/src/modules/substrate-dtao/types.d.ts +17 -0
  13. package/dist/declarations/src/modules/substrate-native/index.d.ts +0 -1
  14. package/dist/declarations/src/modules/substrate-native/types.d.ts +0 -1
  15. package/dist/declarations/src/types/IBalanceModule.d.ts +4 -0
  16. package/dist/declarations/src/types/balances.d.ts +26 -10
  17. package/dist/declarations/src/types/balancetypes.d.ts +1 -1
  18. package/dist/talismn-balances.cjs.dev.js +568 -348
  19. package/dist/talismn-balances.cjs.prod.js +568 -348
  20. package/dist/talismn-balances.esm.js +565 -346
  21. package/package.json +6 -6
  22. package/dist/declarations/src/modules/substrate-native/bittensor/getSubtensorStakingBalances.d.ts +0 -9
  23. package/dist/declarations/src/modules/substrate-native/bittensor/subtensor.d.ts +0 -20
@@ -15,7 +15,6 @@ export declare const BALANCE_MODULES: (import("../types/IBalanceModule").IBalanc
15
15
  useLegacyTransferableCalculation?: boolean | undefined;
16
16
  existentialDeposit?: string | undefined;
17
17
  nominationPoolsPalletId?: string | undefined;
18
- hasSubtensorPallet?: boolean | undefined;
19
18
  }> | import("../types/IBalanceModule").IBalanceModule<"substrate-assets", {
20
19
  assetId: string;
21
20
  symbol?: string | undefined;
@@ -27,6 +26,17 @@ export declare const BALANCE_MODULES: (import("../types/IBalanceModule").IBalanc
27
26
  coingeckoId?: string | undefined;
28
27
  noDiscovery?: boolean | undefined;
29
28
  mirrorOf?: string | undefined;
29
+ }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-dtao", {
30
+ netuid: number;
31
+ symbol?: string | undefined;
32
+ networkId?: string | undefined;
33
+ isDefault?: boolean | undefined;
34
+ decimals?: number | undefined;
35
+ name?: string | undefined;
36
+ logo?: string | undefined;
37
+ coingeckoId?: string | undefined;
38
+ noDiscovery?: boolean | undefined;
39
+ mirrorOf?: string | undefined;
30
40
  }, unknown, unknown> | import("../types/IBalanceModule").IBalanceModule<"substrate-hydration", {
31
41
  onChainId: number;
32
42
  symbol?: string | undefined;
@@ -140,6 +150,7 @@ export * from "./substrate-foreignassets";
140
150
  export * from "./substrate-hydration";
141
151
  export * from "./substrate-psp22";
142
152
  export * from "./substrate-tokens";
153
+ export * from "./substrate-dtao";
143
154
  export * from "./sol-native";
144
155
  export * from "./sol-spl";
145
156
  export * from "./abis";
@@ -0,0 +1,5 @@
1
+ export declare const TAO_DECIMALS = 9n;
2
+ export declare const ALPHA_PRICE_SCALE: bigint;
3
+ export declare const getScaledAlphaPrice: (alphaIn: bigint, taoIn: bigint) => bigint;
4
+ export declare const alphaToTao: (alpha: bigint, scaledAlphaPrice: bigint) => bigint;
5
+ export declare const taoToAlpha: (tao: bigint, scaledAlphaPrice: bigint) => bigint;
@@ -0,0 +1,5 @@
1
+ import z from "zod/v4";
2
+ import { SubDTaoTokenConfigSchema } from "./types";
3
+ export declare const MODULE_TYPE: "substrate-dtao";
4
+ export declare const PLATFORM: "polkadot";
5
+ export type TokenConfig = z.infer<typeof SubDTaoTokenConfigSchema>;
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE } from "./config";
3
+ export declare const fetchBalances: IBalanceModule<typeof MODULE_TYPE>["fetchBalances"];
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE, TokenConfig } from "./config";
3
+ export declare const fetchTokens: IBalanceModule<typeof MODULE_TYPE, TokenConfig>["fetchTokens"];
@@ -0,0 +1,11 @@
1
+ import { SubDTaoToken } from "@talismn/chaindata-provider";
2
+ import { TokenRatesList } from "@talismn/token-rates";
3
+ /**
4
+ * To be used for tokens that don't have a coingecko id
5
+ *
6
+ * @param token
7
+ * @param tokenRates
8
+ * @param scaledAlphaPrice
9
+ * @returns
10
+ */
11
+ export declare const getDTaoTokenRates: (token: SubDTaoToken, tokenRates: TokenRatesList, scaledAlphaPrice: string | bigint) => import("@talismn/token-rates").TokenRates | null;
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE } from "./config";
3
+ export declare const getMiniMetadata: IBalanceModule<typeof MODULE_TYPE>["getMiniMetadata"];
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE } from "./config";
3
+ export declare const getTransferCallData: IBalanceModule<typeof MODULE_TYPE>["getTransferCallData"];
@@ -0,0 +1,4 @@
1
+ export * from "./module";
2
+ export * from "./types";
3
+ export * from "./getDtaoTokenRates";
4
+ export * from "./alphaPrice";
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE, TokenConfig } from "./config";
3
+ export declare const SubDTaoBalanceModule: IBalanceModule<typeof MODULE_TYPE, TokenConfig>;
@@ -0,0 +1,3 @@
1
+ import { IBalanceModule } from "../../types/IBalanceModule";
2
+ import { MODULE_TYPE } from "./config";
3
+ export declare const subscribeBalances: IBalanceModule<typeof MODULE_TYPE>["subscribeBalances"];
@@ -0,0 +1,17 @@
1
+ import z from "zod/v4";
2
+ export declare const SubDTaoTokenConfigSchema: z.ZodObject<{
3
+ symbol: z.ZodOptional<z.ZodString>;
4
+ networkId: z.ZodOptional<z.ZodString>;
5
+ isDefault: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
6
+ decimals: z.ZodOptional<z.ZodInt>;
7
+ name: z.ZodOptional<z.ZodOptional<z.ZodString>>;
8
+ logo: z.ZodOptional<z.ZodOptional<z.ZodString>>;
9
+ coingeckoId: z.ZodOptional<z.ZodOptional<z.ZodString>>;
10
+ noDiscovery: z.ZodOptional<z.ZodOptional<z.ZodBoolean>>;
11
+ mirrorOf: z.ZodOptional<z.ZodOptional<z.ZodString>>;
12
+ netuid: z.ZodNumber;
13
+ }, z.core.$strict>;
14
+ export type SubDTaoTokenConfig = z.infer<typeof SubDTaoTokenConfigSchema>;
15
+ export type SubDTaoBalanceMeta = {
16
+ scaledAlphaPrice: string;
17
+ };
@@ -1,4 +1,3 @@
1
1
  export * from "./module";
2
2
  export * from "./types";
3
- export * from "./bittensor/subtensor";
4
3
  export * from "./util/lockTypes";
@@ -20,6 +20,5 @@ export declare const SubNativeMiniMetadataExtraSchema: z.ZodObject<{
20
20
  useLegacyTransferableCalculation: z.ZodOptional<z.ZodBoolean>;
21
21
  existentialDeposit: z.ZodOptional<z.ZodString>;
22
22
  nominationPoolsPalletId: z.ZodOptional<z.ZodString>;
23
- hasSubtensorPallet: z.ZodOptional<z.ZodBoolean>;
24
23
  }, z.core.$strict>;
25
24
  export type SubNativeMiniMetadataExtra = z.infer<typeof SubNativeMiniMetadataExtraSchema>;
@@ -27,6 +27,10 @@ export type FetchBalanceErrors = Array<{
27
27
  export type FetchBalanceResults = {
28
28
  success: IBalance[];
29
29
  errors: FetchBalanceErrors;
30
+ /**
31
+ * tokens identified at runtime while fetching balances, that were not part of the original request
32
+ */
33
+ dynamicTokens?: Token[];
30
34
  };
31
35
  export interface IBalanceModule<Type extends TokenType, TokenConfig = unknown, ModuleConfig = unknown, MiniMetadataExtra = unknown> {
32
36
  type: Type;
@@ -171,13 +171,14 @@ export declare class Balance {
171
171
  "substrate-native"?: {
172
172
  disable?: boolean | undefined;
173
173
  } | undefined;
174
- "substrate-assets"?: undefined;
175
- "substrate-psp22"?: undefined;
174
+ "substrate-assets"?: Record<string, never> | undefined;
175
+ "substrate-psp22"?: Record<string, never> | undefined;
176
176
  "substrate-tokens"?: {
177
177
  palletId?: string | undefined;
178
178
  } | undefined;
179
- "substrate-foreignassets"?: undefined;
180
- "substrate-hydration"?: undefined;
179
+ "substrate-foreignassets"?: Record<string, never> | undefined;
180
+ "substrate-hydration"?: Record<string, never> | undefined;
181
+ "substrate-dtao"?: Record<string, never> | undefined;
181
182
  } | undefined;
182
183
  } | {
183
184
  id: string;
@@ -213,9 +214,9 @@ export declare class Balance {
213
214
  Multicall3?: `0x${string}` | undefined;
214
215
  } | undefined;
215
216
  balancesConfig?: {
216
- "evm-native"?: undefined;
217
- "evm-erc20"?: undefined;
218
- "evm-uniswapv2"?: undefined;
217
+ "evm-native"?: Record<string, never> | undefined;
218
+ "evm-erc20"?: Record<string, never> | undefined;
219
+ "evm-uniswapv2"?: Record<string, never> | undefined;
219
220
  } | undefined;
220
221
  } | {
221
222
  id: string;
@@ -239,8 +240,8 @@ export declare class Balance {
239
240
  logo?: string | undefined;
240
241
  themeColor?: string | undefined;
241
242
  balancesConfig?: {
242
- "sol-native"?: undefined;
243
- "sol-spl"?: undefined;
243
+ "sol-native"?: Record<string, never> | undefined;
244
+ "sol-spl"?: Record<string, never> | undefined;
244
245
  } | undefined;
245
246
  } | null;
246
247
  get tokenId(): string;
@@ -311,6 +312,22 @@ export declare class Balance {
311
312
  noDiscovery?: boolean | undefined;
312
313
  mirrorOf?: string | undefined;
313
314
  isFrozen?: boolean | undefined;
315
+ } | {
316
+ id: string;
317
+ networkId: string;
318
+ decimals: number;
319
+ symbol: string;
320
+ type: "substrate-dtao";
321
+ platform: "polkadot";
322
+ netuid: number;
323
+ isDefault?: boolean | undefined;
324
+ name?: string | undefined;
325
+ logo?: string | undefined;
326
+ coingeckoId?: string | undefined;
327
+ noDiscovery?: boolean | undefined;
328
+ mirrorOf?: string | undefined;
329
+ subnetName?: string | undefined;
330
+ hotkey?: string | undefined;
314
331
  } | {
315
332
  id: string;
316
333
  networkId: string;
@@ -451,7 +468,6 @@ export declare class Balance {
451
468
  get locked(): BalanceFormatter;
452
469
  get locks(): FormattedAmount<AmountWithLabel<string>, string>[];
453
470
  get nompools(): FormattedAmount<AmountWithLabel<string>, string>[];
454
- get subtensor(): FormattedAmount<AmountWithLabel<string>, string>[];
455
471
  /** The extra balance of this token */
456
472
  get extra(): ExtraAmount<string>[] | undefined;
457
473
  /** @deprecated Use balance.locked */
@@ -30,7 +30,7 @@ export type BalanceJson = IBalance;
30
30
  export type BalanceJsonList = Record<string, BalanceJson>;
31
31
  /** An unlabelled amount of a balance */
32
32
  export type Amount = string;
33
- export type BalanceStatusTypes = "free" | "reserved" | "locked" | "extra" | "nompool" | "subtensor";
33
+ export type BalanceStatusTypes = "free" | "reserved" | "locked" | "extra" | "nompool";
34
34
  /** A labelled amount of a balance */
35
35
  type BaseAmountWithLabel<TLabel extends string> = {
36
36
  type: BalanceStatusTypes;