@spritz-finance/service-client 0.8.4 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/payouts/payoutsServiceClient.d.ts +2 -1
- package/lib/payouts/payoutsServiceClient.js +9 -0
- package/lib/payouts/types.d.ts +33 -0
- package/lib/platform/platformServiceClient.d.ts +6 -1
- package/lib/platform/platformServiceClient.js +11 -0
- package/lib/platform/types.d.ts +24 -0
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * as PayoutsClient from "./payoutsServiceClient";
|
|
2
|
-
import { CryptoPayout, CryptoPayoutInput } from "./types";
|
|
2
|
+
import { CryptoPayout, CryptoPayoutInput, TreasuryBalances } from "./types";
|
|
3
3
|
export declare function requestCryptoPayout({ userId, type, network, amountFiat, referenceId, toAddress, tokenSymbol, currencyFiat, fromDispatchWallet, }: CryptoPayoutInput): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<CryptoPayout>>;
|
|
4
4
|
export declare function getPayoutFromHash({ userId, transactionHash, }: {
|
|
5
5
|
userId?: string;
|
|
@@ -22,3 +22,4 @@ export declare function submit7702Message(input: {
|
|
|
22
22
|
to: `0x${string}`;
|
|
23
23
|
chainId: number;
|
|
24
24
|
}): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<string>>;
|
|
25
|
+
export declare function getTreasuryBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<TreasuryBalances>>;
|
|
@@ -38,6 +38,7 @@ exports.requestCryptoPayout = requestCryptoPayout;
|
|
|
38
38
|
exports.getPayoutFromHash = getPayoutFromHash;
|
|
39
39
|
exports.requestWithdrawlSignature = requestWithdrawlSignature;
|
|
40
40
|
exports.submit7702Message = submit7702Message;
|
|
41
|
+
exports.getTreasuryBalances = getTreasuryBalances;
|
|
41
42
|
exports.PayoutsClient = __importStar(require("./payoutsServiceClient"));
|
|
42
43
|
const serviceClient_1 = require("../serviceClient");
|
|
43
44
|
const PAYOUTS_ENDPOINT = "/bridgebot";
|
|
@@ -74,3 +75,11 @@ async function submit7702Message(input) {
|
|
|
74
75
|
.post(`${PAYOUTS_ENDPOINT}/signers/7702`, input)
|
|
75
76
|
.then((res) => res.data);
|
|
76
77
|
}
|
|
78
|
+
// Served by bridgebot's Hono /api surface; reached through the same gateway
|
|
79
|
+
// host via the /v2/bridgebot base path (the bare /bridgebot base path maps to
|
|
80
|
+
// bridgebot's legacy REST API, which does not carry this route).
|
|
81
|
+
async function getTreasuryBalances() {
|
|
82
|
+
return serviceClient_1.baseClient
|
|
83
|
+
.get(`/v2${PAYOUTS_ENDPOINT}/api/treasury/balances`)
|
|
84
|
+
.then((res) => res.data);
|
|
85
|
+
}
|
package/lib/payouts/types.d.ts
CHANGED
|
@@ -32,3 +32,36 @@ export type CryptoPayout = {
|
|
|
32
32
|
createdAt: string;
|
|
33
33
|
updatedAt: string;
|
|
34
34
|
};
|
|
35
|
+
export type TreasuryWalletBalance = {
|
|
36
|
+
payoutType: "BRIDGE_TRANSFER" | "RAIN_CARD_DEPOSIT" | "ONRAMP_PURCHASE";
|
|
37
|
+
network: string;
|
|
38
|
+
address: string;
|
|
39
|
+
tokenSymbol: string;
|
|
40
|
+
currentBalanceUsd: string;
|
|
41
|
+
reservedUsd: string;
|
|
42
|
+
availableUsd: string;
|
|
43
|
+
floatTargetUsd: string;
|
|
44
|
+
errored: boolean;
|
|
45
|
+
};
|
|
46
|
+
export type TreasuryQueueSummary = {
|
|
47
|
+
queuedUsd: string;
|
|
48
|
+
queuedCount: number;
|
|
49
|
+
processingUsd: string;
|
|
50
|
+
processingCount: number;
|
|
51
|
+
failedUsd: string;
|
|
52
|
+
failedCount: number;
|
|
53
|
+
totalOwedUsd: string;
|
|
54
|
+
totalOwedCount: number;
|
|
55
|
+
};
|
|
56
|
+
export type TreasuryBalances = {
|
|
57
|
+
asOf: string;
|
|
58
|
+
wallets: TreasuryWalletBalance[];
|
|
59
|
+
/** All undelivered payouts across payout types. */
|
|
60
|
+
queue: TreasuryQueueSummary;
|
|
61
|
+
/**
|
|
62
|
+
* Per-payout-type breakdown — consumers tracking one provider's wallet
|
|
63
|
+
* (e.g. the Rain dispatch float) must read their own type here, not the
|
|
64
|
+
* combined queue.
|
|
65
|
+
*/
|
|
66
|
+
queueByType: Partial<Record<TreasuryWalletBalance["payoutType"], TreasuryQueueSummary>>;
|
|
67
|
+
};
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export * as PlatformClient from "./platformServiceClient";
|
|
2
|
-
import { IssuePayoutData, IssuePayoutRequest, MTBalancesData, SendPaymentData, SendPaymentRequest, TabapayBalancesResponse, TabapayFundingRequirementResponse, ValidateBillData, ValidateBillRequest } from "./types";
|
|
2
|
+
import { IssuePayoutData, IssuePayoutRequest, MTBalancesData, PlaidTreasuryBalancesData, SendPaymentData, SendPaymentRequest, TabapayBalancesResponse, TabapayFundingRequirementResponse, ValidateBillData, ValidateBillRequest } from "./types";
|
|
3
3
|
export declare function validateBill(request: ValidateBillRequest): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<ValidateBillData>>;
|
|
4
4
|
export declare function tabapayBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<TabapayBalancesResponse>>;
|
|
5
5
|
export declare function tabapayFundingRequirement(currency?: string): Promise<TabapayFundingRequirementResponse>;
|
|
6
6
|
export declare function issuePayout(request: IssuePayoutRequest): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<IssuePayoutData>>;
|
|
7
7
|
export declare function sendPayment(request: SendPaymentRequest): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<SendPaymentData>>;
|
|
8
8
|
export declare function modernTreasuryBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<MTBalancesData>>;
|
|
9
|
+
/**
|
|
10
|
+
* Balances for company bank accounts linked via Plaid (e.g. Chase), served
|
|
11
|
+
* from the platform's snapshot cache and refreshed at most every few hours.
|
|
12
|
+
*/
|
|
13
|
+
export declare function plaidTreasuryBalances(): Promise<import("../types").ApiFailure | import("../types").ApiSuccess<PlaidTreasuryBalancesData>>;
|
|
@@ -43,6 +43,7 @@ exports.tabapayFundingRequirement = tabapayFundingRequirement;
|
|
|
43
43
|
exports.issuePayout = issuePayout;
|
|
44
44
|
exports.sendPayment = sendPayment;
|
|
45
45
|
exports.modernTreasuryBalances = modernTreasuryBalances;
|
|
46
|
+
exports.plaidTreasuryBalances = plaidTreasuryBalances;
|
|
46
47
|
exports.PlatformClient = __importStar(require("./platformServiceClient"));
|
|
47
48
|
const axios_1 = __importDefault(require("axios"));
|
|
48
49
|
// @ts-expect-error no type declarations for axios-token-interceptor
|
|
@@ -93,3 +94,13 @@ async function modernTreasuryBalances() {
|
|
|
93
94
|
.get(`${MT_ENDPOINT}/balances`)
|
|
94
95
|
.then((res) => res.data);
|
|
95
96
|
}
|
|
97
|
+
const PLAID_TREASURY_ENDPOINT = "/v1/plaid-treasury";
|
|
98
|
+
/**
|
|
99
|
+
* Balances for company bank accounts linked via Plaid (e.g. Chase), served
|
|
100
|
+
* from the platform's snapshot cache and refreshed at most every few hours.
|
|
101
|
+
*/
|
|
102
|
+
async function plaidTreasuryBalances() {
|
|
103
|
+
return platformClient
|
|
104
|
+
.get(`${PLAID_TREASURY_ENDPOINT}/balances`)
|
|
105
|
+
.then((res) => res.data);
|
|
106
|
+
}
|
package/lib/platform/types.d.ts
CHANGED
|
@@ -76,3 +76,27 @@ export interface MTAccount {
|
|
|
76
76
|
export interface MTBalancesData {
|
|
77
77
|
accounts: MTAccount[];
|
|
78
78
|
}
|
|
79
|
+
export interface PlaidTreasuryAccountBalance {
|
|
80
|
+
/** Platform plaid_accounts record id. */
|
|
81
|
+
id: string;
|
|
82
|
+
plaidAccountId: string;
|
|
83
|
+
name: string;
|
|
84
|
+
mask: string | null;
|
|
85
|
+
institutionName: string | null;
|
|
86
|
+
type: string;
|
|
87
|
+
subtype: string | null;
|
|
88
|
+
/** Available balance as decimal dollars (e.g. "1234.56"), null if Plaid omits it. */
|
|
89
|
+
available: string | null;
|
|
90
|
+
/** Current balance as decimal dollars (e.g. "1234.56"), null if Plaid omits it. */
|
|
91
|
+
current: string | null;
|
|
92
|
+
currency: string | null;
|
|
93
|
+
/** ISO timestamp of when the balance was fetched from Plaid. */
|
|
94
|
+
asOf: string;
|
|
95
|
+
/** True when served from the platform's snapshot cache instead of a live Plaid call. */
|
|
96
|
+
cached: boolean;
|
|
97
|
+
/** True when the snapshot is older than the cache TTL because the Plaid refresh failed. */
|
|
98
|
+
stale: boolean;
|
|
99
|
+
}
|
|
100
|
+
export interface PlaidTreasuryBalancesData {
|
|
101
|
+
accounts: PlaidTreasuryAccountBalance[];
|
|
102
|
+
}
|