@cfxlabsinc/b2b-services
    Preparing search index...

    On-chain balances per ledger account, across every chain and asset its wallet holds: ledger_account → wallet → wallet_address → wallet_account_transaction → token. A balance is the post_balance of the latest balance change per (address, token), never a sum of amounts. A wallet several ledger accounts share shows the same holdings under each.

    Index
    instance: (...args: []) => WalletAccountBalanceQueryService = ...

    The process default: built from each dependency's own instance().

    • A correlated scalar subquery: the outer row's ledger account's balance of symbol, summed across every address and chain, coalesce'd to 0. Use it as a SELECT column (it maps to a BigNumber), inside an aggregate, or sort by its select-list alias.

      Short on purpose: list statements carry it once per balance and RDS Proxy pins a session past 16,384 bytes of text. It reads the keyed view by name.

      Parameters

      • __namedParameters: { blockTime?: Date; ledgerAccountIdColumn: SQLWrapper; symbol: string }
        • OptionalblockTime?: Date

          If provided, the balance at this point in time; otherwise the latest.

        • ledgerAccountIdColumn: SQLWrapper

          ledger_account.id, the internal int, on the outer query.

        • symbol: string

      Returns SQL<BigNumber>

      .select({
      balance: service.balanceColumn({
      ledgerAccountIdColumn: ledgerAccountTable.id,
      symbol: "MOVEUSD",
      }),
      })
    • Every asset each ledger account holds, latest or at blockTime. Every requested id is present, [] when its wallet holds nothing. An asset whose history ends at zero is still listed, with a zero total. With customerId the accounts are the customer's, read in SQL; only accounts holding something are present.

      Parameters

      • __namedParameters: ({ ledgerAccountIds: string[] } | { customerId: string }) & { blockTime?: Date }
        • { ledgerAccountIds: string[] }
        • { customerId: string }
        • OptionalblockTime?: Date

          The holdings at this point in time; otherwise the latest.

      Returns Promise<{ ok: true; value: T }>

    • One ledger account's balance changes: the balance of an (address, token) after each change, oldest first unless orderBy says otherwise.

      Parameters

      • __namedParameters: {
            blockTime: BlockTimeRange;
            ledgerAccountId: string;
            orderBy?: DbOrderByCriterion<
                PgViewWithSelection<
                    {
                        existing: true;
                        isAlias: false;
                        name: "ledger_account_balance_change";
                        schema: "b2b";
                        selectedFields: {
                            address: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgTextBuilder<[(...), ...(...)[]]>>,
                                {
                                    data: string;
                                    dataType: "string";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            blockTime: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgTimestampBuilder>,
                                {
                                    data: Date;
                                    dataType: "object date";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            chain: PgBuildColumn<
                                "ledger_account_balance_change",
                                Set$Type<SetNotNull<PgTextBuilder<(...)>>, WalletChain>,
                                {
                                    data: WalletChain;
                                    dataType: "string";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            indexWithinBlock: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgIntegerBuilder>,
                                {
                                    data: number;
                                    dataType: "number int32";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            ledgerAccountExternalId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgTextBuilder<[(...), ...(...)[]]>>,
                                {
                                    data: string;
                                    dataType: "string";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            ledgerAccountId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgIntegerBuilder>,
                                {
                                    data: number;
                                    dataType: "number int32";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            postBalance: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgNumericBuilder>,
                                {
                                    data: string;
                                    dataType: "string numeric";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            slot: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgBigInt53Builder>,
                                {
                                    data: number;
                                    dataType: "number int53";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            symbol: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgTextBuilder<[(...), ...(...)[]]>>,
                                {
                                    data: string;
                                    dataType: "string";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            tokenExternalId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgTextBuilder<[(...), ...(...)[]]>>,
                                {
                                    data: string;
                                    dataType: "string";
                                    driverParam: string;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            tokenId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgIntegerBuilder>,
                                {
                                    data: number;
                                    dataType: "number int32";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            walletAddressId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgIntegerBuilder>,
                                {
                                    data: number;
                                    dataType: "number int32";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                            walletTransactionId: PgBuildColumn<
                                "ledger_account_balance_change",
                                SetNotNull<PgIntegerBuilder>,
                                {
                                    data: number;
                                    dataType: "number int32";
                                    driverParam: string | number;
                                    enumValues: undefined;
                                    generated: undefined;
                                    hasDefault: false;
                                    hasRuntimeDefault: false;
                                    identity: undefined;
                                    isAutoincrement: false;
                                    isPrimaryKey: false;
                                    name: string;
                                    notNull: true;
                                    tableName: "ledger_account_balance_change";
                                },
                            >;
                        };
                    },
                >,
                "blockTime",
            >[];
            pageSize?: number;
            symbol?: string;
        }

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: {
                      address: string;
                      amount: BigNumber;
                      blockTime: Date;
                      chain: WalletChain;
                      symbol: string;
                      tokenId: string;
                  }[];
              };
          },
      >

    • Balances of these accounts, or every account of customerId, sampled over time, each address counted once. Both bounds truncate to the start of their day in timeZone.

      Parameters

      • __namedParameters: TimeseriesScope & {
            blockTime: BlockTimeRange;
            granularity: Granularity;
            samplePoint: "OPEN" | "CLOSE";
            symbols?: string[];
            timeZone?: string;
        }
        • blockTime: BlockTimeRange
        • granularity: Granularity
        • samplePoint: "OPEN" | "CLOSE"
        • Optionalsymbols?: string[]

          Only these assets; every asset when omitted.

        • OptionaltimeZone?: string

          IANA timezone (e.g. "America/Chicago"). Aligns day boundaries and localDate output to this timezone. Defaults to "UTC".

      Returns Promise<{ ok: true; value: { items: WalletBalanceTimeseriesItem[] } }>