@symmio/trading-core 4.1.0 → 4.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.
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -87
- package/dist/pools/add-market/to-created-pool.d.ts.map +1 -1
- package/dist/pools/add-market/to-created-pool.js +4 -0
- package/dist/pools/add-market/to-created-pool.js.map +1 -1
- package/dist/pools/add-market/types.d.ts +8 -0
- package/dist/pools/add-market/types.d.ts.map +1 -1
- package/dist/pools/auth/authenticate-listing.d.ts +3 -1
- package/dist/pools/auth/authenticate-listing.d.ts.map +1 -1
- package/dist/pools/auth/authenticate-listing.js +28 -23
- package/dist/pools/auth/authenticate-listing.js.map +1 -1
- package/dist/pools/auth/can-reuse-listing-challenge.d.ts +5 -0
- package/dist/pools/auth/can-reuse-listing-challenge.d.ts.map +1 -0
- package/dist/pools/auth/can-reuse-listing-challenge.js +9 -0
- package/dist/pools/auth/can-reuse-listing-challenge.js.map +1 -0
- package/dist/pools/auth/query.d.ts +15 -0
- package/dist/pools/auth/query.d.ts.map +1 -1
- package/dist/pools/auth/query.js +28 -4
- package/dist/pools/auth/query.js.map +1 -1
- package/dist/pools/auth/to-siwe.d.ts +5 -1
- package/dist/pools/auth/to-siwe.d.ts.map +1 -1
- package/dist/pools/auth/to-siwe.js +4 -2
- package/dist/pools/auth/to-siwe.js.map +1 -1
- package/dist/pools/auth/types.d.ts +2 -0
- package/dist/pools/auth/types.d.ts.map +1 -1
- package/dist/pools/cancel-withdraw/cancel-withdraw.js +1 -1
- package/dist/pools/cancel-withdraw/cancel-withdraw.js.map +1 -1
- package/dist/pools/claim-history/get-pool-claim.d.ts +11 -0
- package/dist/pools/claim-history/get-pool-claim.d.ts.map +1 -0
- package/dist/pools/claim-history/get-pool-claim.js +25 -0
- package/dist/pools/claim-history/get-pool-claim.js.map +1 -0
- package/dist/pools/claim-history/index.d.ts +1 -0
- package/dist/pools/claim-history/index.d.ts.map +1 -1
- package/dist/pools/claim-history/to-pool-claim.d.ts.map +1 -1
- package/dist/pools/claim-history/to-pool-claim.js +2 -0
- package/dist/pools/claim-history/to-pool-claim.js.map +1 -1
- package/dist/pools/composition.d.ts +16 -0
- package/dist/pools/composition.d.ts.map +1 -0
- package/dist/pools/composition.js +39 -0
- package/dist/pools/composition.js.map +1 -0
- package/dist/pools/empty-pool-profit.d.ts +4 -0
- package/dist/pools/empty-pool-profit.d.ts.map +1 -0
- package/dist/pools/empty-pool-profit.js +17 -0
- package/dist/pools/empty-pool-profit.js.map +1 -0
- package/dist/pools/index.d.ts +8 -0
- package/dist/pools/index.d.ts.map +1 -1
- package/dist/pools/listing-config/to-listing-config.d.ts +5 -1
- package/dist/pools/listing-config/to-listing-config.d.ts.map +1 -1
- package/dist/pools/listing-config/to-listing-config.js +19 -8
- package/dist/pools/listing-config/to-listing-config.js.map +1 -1
- package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts +37 -0
- package/dist/pools/maintenance-fees/get-pool-maintenance-fees.d.ts.map +1 -0
- package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js +35 -0
- package/dist/pools/maintenance-fees/get-pool-maintenance-fees.js.map +1 -0
- package/dist/pools/maintenance-fees/index.d.ts +3 -0
- package/dist/pools/maintenance-fees/index.d.ts.map +1 -0
- package/dist/pools/maintenance-fees/query.d.ts +11 -0
- package/dist/pools/maintenance-fees/query.d.ts.map +1 -0
- package/dist/pools/maintenance-fees/query.js +21 -0
- package/dist/pools/maintenance-fees/query.js.map +1 -0
- package/dist/pools/market-config/to-listing-market-config.d.ts +6 -1
- package/dist/pools/market-config/to-listing-market-config.d.ts.map +1 -1
- package/dist/pools/market-config/to-listing-market-config.js +1 -0
- package/dist/pools/market-config/to-listing-market-config.js.map +1 -1
- package/dist/pools/market-config/types.d.ts +5 -0
- package/dist/pools/market-config/types.d.ts.map +1 -1
- package/dist/pools/market-config/types.js.map +1 -1
- package/dist/pools/market-data/get-pool-market-data.d.ts +14 -0
- package/dist/pools/market-data/get-pool-market-data.d.ts.map +1 -0
- package/dist/pools/market-data/get-pool-market-data.js +25 -0
- package/dist/pools/market-data/get-pool-market-data.js.map +1 -0
- package/dist/pools/market-data/index.d.ts +2 -0
- package/dist/pools/market-data/index.d.ts.map +1 -0
- package/dist/pools/market-detail/to-listing-market-detail.d.ts +5 -1
- package/dist/pools/market-detail/to-listing-market-detail.d.ts.map +1 -1
- package/dist/pools/market-detail/to-listing-market-detail.js +45 -33
- package/dist/pools/market-detail/to-listing-market-detail.js.map +1 -1
- package/dist/pools/markets/to-listing-market.d.ts +13 -1
- package/dist/pools/markets/to-listing-market.d.ts.map +1 -1
- package/dist/pools/markets/to-listing-market.js +24 -12
- package/dist/pools/markets/to-listing-market.js.map +1 -1
- package/dist/pools/open-positions/calculate-pool-open-positions.d.ts +39 -0
- package/dist/pools/open-positions/calculate-pool-open-positions.d.ts.map +1 -0
- package/dist/pools/open-positions/calculate-pool-open-positions.js +83 -0
- package/dist/pools/open-positions/calculate-pool-open-positions.js.map +1 -0
- package/dist/pools/open-positions/get-pool-open-positions.d.ts +17 -0
- package/dist/pools/open-positions/get-pool-open-positions.d.ts.map +1 -0
- package/dist/pools/open-positions/get-pool-open-positions.js +39 -0
- package/dist/pools/open-positions/get-pool-open-positions.js.map +1 -0
- package/dist/pools/open-positions/index.d.ts +4 -0
- package/dist/pools/open-positions/index.d.ts.map +1 -0
- package/dist/pools/open-positions/query.d.ts +17 -0
- package/dist/pools/open-positions/query.d.ts.map +1 -0
- package/dist/pools/open-positions/query.js +21 -0
- package/dist/pools/open-positions/query.js.map +1 -0
- package/dist/pools/portfolio/calculate-pool-portfolio.d.ts +66 -0
- package/dist/pools/portfolio/calculate-pool-portfolio.d.ts.map +1 -0
- package/dist/pools/portfolio/calculate-pool-portfolio.js +96 -0
- package/dist/pools/portfolio/calculate-pool-portfolio.js.map +1 -0
- package/dist/pools/portfolio/get-pool-portfolio.d.ts +19 -0
- package/dist/pools/portfolio/get-pool-portfolio.d.ts.map +1 -0
- package/dist/pools/portfolio/get-pool-portfolio.js +88 -0
- package/dist/pools/portfolio/get-pool-portfolio.js.map +1 -0
- package/dist/pools/portfolio/index.d.ts +4 -0
- package/dist/pools/portfolio/index.d.ts.map +1 -0
- package/dist/pools/portfolio/query.d.ts +17 -0
- package/dist/pools/portfolio/query.d.ts.map +1 -0
- package/dist/pools/portfolio/query.js +21 -0
- package/dist/pools/portfolio/query.js.map +1 -0
- package/dist/pools/portfolio/read-positions.d.ts +4 -0
- package/dist/pools/portfolio/read-positions.d.ts.map +1 -0
- package/dist/pools/portfolio/read-positions.js +31 -0
- package/dist/pools/portfolio/read-positions.js.map +1 -0
- package/dist/pools/position/calculate-pool-position.d.ts +85 -0
- package/dist/pools/position/calculate-pool-position.d.ts.map +1 -0
- package/dist/pools/position/calculate-pool-position.js +59 -0
- package/dist/pools/position/calculate-pool-position.js.map +1 -0
- package/dist/pools/position/get-pool-position.d.ts +22 -0
- package/dist/pools/position/get-pool-position.d.ts.map +1 -0
- package/dist/pools/position/get-pool-position.js +47 -0
- package/dist/pools/position/get-pool-position.js.map +1 -0
- package/dist/pools/position/index.d.ts +4 -0
- package/dist/pools/position/index.d.ts.map +1 -0
- package/dist/pools/position/query.d.ts +17 -0
- package/dist/pools/position/query.d.ts.map +1 -0
- package/dist/pools/position/query.js +21 -0
- package/dist/pools/position/query.js.map +1 -0
- package/dist/pools/position/sum-deposits.d.ts +10 -0
- package/dist/pools/position/sum-deposits.d.ts.map +1 -0
- package/dist/pools/position/sum-deposits.js +35 -0
- package/dist/pools/position/sum-deposits.js.map +1 -0
- package/dist/pools/profit/get-user-profit.d.ts +4 -0
- package/dist/pools/profit/get-user-profit.d.ts.map +1 -1
- package/dist/pools/profit/get-user-profit.js +18 -12
- package/dist/pools/profit/get-user-profit.js.map +1 -1
- package/dist/pools/profit/to-user-pool-profit.d.ts +22 -4
- package/dist/pools/profit/to-user-pool-profit.d.ts.map +1 -1
- package/dist/pools/profit/to-user-pool-profit.js +28 -12
- package/dist/pools/profit/to-user-pool-profit.js.map +1 -1
- package/dist/pools/quotes/get-pool-quotes.d.ts +8 -1
- package/dist/pools/quotes/get-pool-quotes.d.ts.map +1 -1
- package/dist/pools/quotes/get-pool-quotes.js +8 -1
- package/dist/pools/quotes/get-pool-quotes.js.map +1 -1
- package/dist/pools/quotes/query-document.d.ts.map +1 -1
- package/dist/pools/quotes/query-document.js +1 -1
- package/dist/pools/quotes/query-document.js.map +1 -1
- package/dist/pools/quotes/to-pool-quote.d.ts.map +1 -1
- package/dist/pools/quotes/to-pool-quote.js +13 -0
- package/dist/pools/quotes/to-pool-quote.js.map +1 -1
- package/dist/pools/rewards/query.js +25 -25
- package/dist/pools/statistics/calculate-pool-statistics.d.ts +69 -0
- package/dist/pools/statistics/calculate-pool-statistics.d.ts.map +1 -0
- package/dist/pools/statistics/calculate-pool-statistics.js +42 -0
- package/dist/pools/statistics/calculate-pool-statistics.js.map +1 -0
- package/dist/pools/statistics/get-pool-statistics.d.ts +29 -0
- package/dist/pools/statistics/get-pool-statistics.d.ts.map +1 -0
- package/dist/pools/statistics/get-pool-statistics.js +61 -0
- package/dist/pools/statistics/get-pool-statistics.js.map +1 -0
- package/dist/pools/statistics/index.d.ts +4 -0
- package/dist/pools/statistics/index.d.ts.map +1 -0
- package/dist/pools/statistics/query.d.ts +17 -0
- package/dist/pools/statistics/query.d.ts.map +1 -0
- package/dist/pools/statistics/query.js +21 -0
- package/dist/pools/statistics/query.js.map +1 -0
- package/dist/pools/token-metadata/get-listing-token-metadata.d.ts +32 -0
- package/dist/pools/token-metadata/get-listing-token-metadata.d.ts.map +1 -0
- package/dist/pools/token-metadata/get-listing-token-metadata.js +43 -0
- package/dist/pools/token-metadata/get-listing-token-metadata.js.map +1 -0
- package/dist/pools/token-metadata/index.d.ts +3 -0
- package/dist/pools/token-metadata/index.d.ts.map +1 -0
- package/dist/pools/token-metadata/query.d.ts +11 -0
- package/dist/pools/token-metadata/query.d.ts.map +1 -0
- package/dist/pools/token-metadata/query.js +21 -0
- package/dist/pools/token-metadata/query.js.map +1 -0
- package/dist/pools/token-support/check-listing-token-support.d.ts +23 -0
- package/dist/pools/token-support/check-listing-token-support.d.ts.map +1 -0
- package/dist/pools/token-support/check-listing-token-support.js +36 -0
- package/dist/pools/token-support/check-listing-token-support.js.map +1 -0
- package/dist/pools/token-support/index.d.ts +3 -0
- package/dist/pools/token-support/index.d.ts.map +1 -0
- package/dist/pools/token-support/query.d.ts +11 -0
- package/dist/pools/token-support/query.d.ts.map +1 -0
- package/dist/pools/token-support/query.js +21 -0
- package/dist/pools/token-support/query.js.map +1 -0
- package/dist/pools/trade-history/calculate-history-metrics.d.ts +12 -0
- package/dist/pools/trade-history/calculate-history-metrics.d.ts.map +1 -0
- package/dist/pools/trade-history/calculate-history-metrics.js +36 -0
- package/dist/pools/trade-history/calculate-history-metrics.js.map +1 -0
- package/dist/pools/trade-history/get-pool-trade-history.d.ts +21 -1
- package/dist/pools/trade-history/get-pool-trade-history.d.ts.map +1 -1
- package/dist/pools/trade-history/get-pool-trade-history.js +57 -18
- package/dist/pools/trade-history/get-pool-trade-history.js.map +1 -1
- package/dist/pools/trade-history/query-document.d.ts.map +1 -1
- package/dist/pools/trade-history/query-document.js +1 -1
- package/dist/pools/trade-history/query-document.js.map +1 -1
- package/dist/pools/transactions/get-pool-transaction-range.d.ts +6 -0
- package/dist/pools/transactions/get-pool-transaction-range.d.ts.map +1 -0
- package/dist/pools/transactions/get-pool-transaction-range.js +26 -0
- package/dist/pools/transactions/get-pool-transaction-range.js.map +1 -0
- package/dist/pools/transactions/index.d.ts +1 -0
- package/dist/pools/transactions/index.d.ts.map +1 -1
- package/dist/pools/types/generated/listing-backend.js +34 -10
- package/dist/pools/types/generated/listing-backend.js.map +1 -1
- package/dist/pools/types.d.ts +129 -6
- package/dist/pools/types.d.ts.map +1 -1
- package/dist/pools/types.js.map +1 -1
- package/dist/pools/user-markets/get-user-listing-markets.d.ts +2 -0
- package/dist/pools/user-markets/get-user-listing-markets.d.ts.map +1 -1
- package/dist/pools/user-markets/get-user-listing-markets.js.map +1 -1
- package/dist/pools/user-markets/to-user-listing-market.js +1 -1
- package/dist/pools/user-markets/to-user-listing-market.js.map +1 -1
- package/dist/pools/user-transactions/get-user-transactions.d.ts +2 -0
- package/dist/pools/user-transactions/get-user-transactions.d.ts.map +1 -1
- package/dist/pools/user-transactions/get-user-transactions.js.map +1 -1
- package/dist/pools/user-transactions/to-user-transaction.d.ts +5 -1
- package/dist/pools/user-transactions/to-user-transaction.d.ts.map +1 -1
- package/dist/pools/user-transactions/to-user-transaction.js +3 -0
- package/dist/pools/user-transactions/to-user-transaction.js.map +1 -1
- package/dist/quotes/liquidation/calculate-liquidation-price.d.ts +5 -1
- package/dist/quotes/liquidation/calculate-liquidation-price.d.ts.map +1 -1
- package/dist/quotes/liquidation/calculate-liquidation-price.js +1 -1
- package/dist/quotes/liquidation/calculate-liquidation-price.js.map +1 -1
- package/dist/quotes/upnl/calculate-quote-pnl.d.ts.map +1 -1
- package/dist/quotes/upnl/calculate-quote-pnl.js +8 -8
- package/dist/quotes/upnl/calculate-quote-pnl.js.map +1 -1
- package/dist/quotes/upnl/calculate-quote-upnl.d.ts +2 -2
- package/dist/quotes/upnl/calculate-quote-upnl.d.ts.map +1 -1
- package/dist/quotes/upnl/calculate-quote-upnl.js +16 -15
- package/dist/quotes/upnl/calculate-quote-upnl.js.map +1 -1
- package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts +2 -2
- package/dist/symmio-subgraph/types/generated/analytics/gql.d.ts.map +1 -1
- package/dist/symmio-subgraph/types/generated/analytics/gql.js +2 -2
- package/dist/symmio-subgraph/types/generated/analytics/gql.js.map +1 -1
- package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts +21 -0
- package/dist/symmio-subgraph/types/generated/analytics/graphql.d.ts.map +1 -1
- package/dist/symmio-subgraph/types/generated/analytics/graphql.js +1 -1
- package/dist/symmio-subgraph/types/generated/analytics/graphql.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Config } from '../../core/config/index.js';
|
|
2
|
+
import { ConfigKeyParameter } from '../../shared/types/properties.js';
|
|
3
|
+
import { QueryParameter, SymmioQueryOptions } from '../../shared/types/query.js';
|
|
2
4
|
import { AuthenticateListingParameters, AuthenticateListingReturnType } from './authenticate-listing.js';
|
|
5
|
+
import { GetListingSignInMessageParameters, GetListingSignInMessageReturnType } from './get-sign-in-message.js';
|
|
3
6
|
/**
|
|
4
7
|
* Build TanStack Mutation options for {@link authenticateListing}. Modeled as a
|
|
5
8
|
* mutation (not a query): it signs a message with the wallet and exchanges it
|
|
@@ -18,4 +21,16 @@ export declare function authenticateListingMutationOptions(config: Config): {
|
|
|
18
21
|
mutationKey: readonly ["authenticateListing"];
|
|
19
22
|
mutationFn: (variables: AuthenticateListingParameters) => Promise<AuthenticateListingReturnType>;
|
|
20
23
|
};
|
|
24
|
+
/** Stable sign-in query identity, including deployment, wallet, origin and statement. */
|
|
25
|
+
export declare function getListingSignInMessageQueryKey(options: GetListingSignInMessageParameters & ConfigKeyParameter): readonly ["getListingSignInMessage", Record<string, unknown>];
|
|
26
|
+
/** Sign-in query key. */
|
|
27
|
+
export type GetListingSignInMessageQueryKey = ReturnType<typeof getListingSignInMessageQueryKey>;
|
|
28
|
+
/** Required challenge identity plus optional query controls. */
|
|
29
|
+
export type GetListingSignInMessageOptions = GetListingSignInMessageParameters & QueryParameter<GetListingSignInMessageReturnType, Error, GetListingSignInMessageReturnType, GetListingSignInMessageQueryKey>;
|
|
30
|
+
/** Fetch a challenge without signing; React callers should normally use prefetchChallenge on useAuthenticateListing.
|
|
31
|
+
* @param config - SDK configuration.
|
|
32
|
+
* @param options - Wallet, origin, deployment and query controls.
|
|
33
|
+
* @returns Options for a single-use sign-in challenge.
|
|
34
|
+
*/
|
|
35
|
+
export declare function getListingSignInMessageQueryOptions(config: Config, options: GetListingSignInMessageOptions): SymmioQueryOptions<GetListingSignInMessageReturnType, Error, GetListingSignInMessageReturnType, GetListingSignInMessageQueryKey>;
|
|
21
36
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnF,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,6BAA6B,EACnC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAEL,KAAK,iCAAiC,EACtC,KAAK,iCAAiC,EACvC,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,MAAM;;4BAGrC,6BAA6B,KAAG,OAAO,CAAC,6BAA6B,CAAC;EAGjG;AAED,yFAAyF;AACzF,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,iCAAiC,GAAG,kBAAkB,iEAE9G;AACD,yBAAyB;AACzB,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;AACjG,gEAAgE;AAChE,MAAM,MAAM,8BAA8B,GAAG,iCAAiC,GAC5E,cAAc,CACZ,iCAAiC,EACjC,KAAK,EACL,iCAAiC,EACjC,+BAA+B,CAChC,CAAC;AACJ;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,8BAA8B,GACtC,kBAAkB,CACnB,iCAAiC,EACjC,KAAK,EACL,iCAAiC,EACjC,+BAA+B,CAChC,CAOA"}
|
package/dist/pools/auth/query.js
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { filterQueryOptions as e } from "../../shared/utils/query.js";
|
|
2
|
+
import { getListingSignInMessage as t } from "./get-sign-in-message.js";
|
|
3
|
+
import { authenticateListing as n } from "./authenticate-listing.js";
|
|
2
4
|
//#region src/pools/auth/query.ts
|
|
3
|
-
function
|
|
5
|
+
function r(e) {
|
|
4
6
|
return {
|
|
5
7
|
mutationKey: ["authenticateListing"],
|
|
6
|
-
mutationFn: (
|
|
8
|
+
mutationFn: (t) => n(e, t)
|
|
7
9
|
};
|
|
8
10
|
}
|
|
11
|
+
function i(t) {
|
|
12
|
+
return ["getListingSignInMessage", e({ ...t })];
|
|
13
|
+
}
|
|
14
|
+
function a(e, n) {
|
|
15
|
+
return {
|
|
16
|
+
...n.query,
|
|
17
|
+
queryKey: i({
|
|
18
|
+
...n,
|
|
19
|
+
configKey: o(e, n)
|
|
20
|
+
}),
|
|
21
|
+
enabled: n.query?.enabled ?? !0,
|
|
22
|
+
queryFn: () => t(e, n)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function o(e, t) {
|
|
26
|
+
try {
|
|
27
|
+
return e.getChainConfigKey(t.chainId);
|
|
28
|
+
} catch (e) {
|
|
29
|
+
if (t.query?.enabled === !1) return;
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
9
33
|
//#endregion
|
|
10
|
-
export {
|
|
34
|
+
export { r as authenticateListingMutationOptions, i as getListingSignInMessageQueryKey, a as getListingSignInMessageQueryOptions };
|
|
11
35
|
|
|
12
36
|
//# sourceMappingURL=query.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/auth/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport {\n authenticateListing,\n type AuthenticateListingParameters,\n type AuthenticateListingReturnType,\n} from \"./authenticate-listing\";\n\n/**\n * Build TanStack Mutation options for {@link authenticateListing}. Modeled as a\n * mutation (not a query): it signs a message with the wallet and exchanges it\n * for a bearer token.\n *\n * @param config - The SDK config.\n * @returns Options to pass to `useMutation`.\n *\n * @example\n * ```ts\n * const { mutateAsync } = useMutation(authenticateListingMutationOptions(config));\n * const token = await mutateAsync({ domain: \"app.example.com\", uri: \"https://app.example.com\" });\n * ```\n */\nexport function authenticateListingMutationOptions(config: Config) {\n return {\n mutationKey: [\"authenticateListing\"] as const,\n mutationFn: (variables: AuthenticateListingParameters): Promise<AuthenticateListingReturnType> =>\n authenticateListing(config, variables),\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.js","names":[],"sources":["../../../src/pools/auth/query.ts"],"sourcesContent":["import type { Config } from \"../../core/config\";\nimport type { ConfigKeyParameter } from \"../../shared/types/properties\";\nimport type { QueryParameter, SymmioQueryOptions } from \"../../shared/types/query\";\nimport { filterQueryOptions } from \"../../shared/utils/query\";\nimport {\n authenticateListing,\n type AuthenticateListingParameters,\n type AuthenticateListingReturnType,\n} from \"./authenticate-listing\";\nimport {\n getListingSignInMessage,\n type GetListingSignInMessageParameters,\n type GetListingSignInMessageReturnType,\n} from \"./get-sign-in-message\";\n\n/**\n * Build TanStack Mutation options for {@link authenticateListing}. Modeled as a\n * mutation (not a query): it signs a message with the wallet and exchanges it\n * for a bearer token.\n *\n * @param config - The SDK config.\n * @returns Options to pass to `useMutation`.\n *\n * @example\n * ```ts\n * const { mutateAsync } = useMutation(authenticateListingMutationOptions(config));\n * const token = await mutateAsync({ domain: \"app.example.com\", uri: \"https://app.example.com\" });\n * ```\n */\nexport function authenticateListingMutationOptions(config: Config) {\n return {\n mutationKey: [\"authenticateListing\"] as const,\n mutationFn: (variables: AuthenticateListingParameters): Promise<AuthenticateListingReturnType> =>\n authenticateListing(config, variables),\n };\n}\n\n/** Stable sign-in query identity, including deployment, wallet, origin and statement. */\nexport function getListingSignInMessageQueryKey(options: GetListingSignInMessageParameters & ConfigKeyParameter) {\n return [\"getListingSignInMessage\", filterQueryOptions({ ...options })] as const;\n}\n/** Sign-in query key. */\nexport type GetListingSignInMessageQueryKey = ReturnType<typeof getListingSignInMessageQueryKey>;\n/** Required challenge identity plus optional query controls. */\nexport type GetListingSignInMessageOptions = GetListingSignInMessageParameters &\n QueryParameter<\n GetListingSignInMessageReturnType,\n Error,\n GetListingSignInMessageReturnType,\n GetListingSignInMessageQueryKey\n >;\n/** Fetch a challenge without signing; React callers should normally use prefetchChallenge on useAuthenticateListing.\n * @param config - SDK configuration.\n * @param options - Wallet, origin, deployment and query controls.\n * @returns Options for a single-use sign-in challenge.\n */\nexport function getListingSignInMessageQueryOptions(\n config: Config,\n options: GetListingSignInMessageOptions,\n): SymmioQueryOptions<\n GetListingSignInMessageReturnType,\n Error,\n GetListingSignInMessageReturnType,\n GetListingSignInMessageQueryKey\n> {\n return {\n ...options.query,\n queryKey: getListingSignInMessageQueryKey({ ...options, configKey: challengeConfigKey(config, options) }),\n enabled: options.query?.enabled ?? true,\n queryFn: () => getListingSignInMessage(config, options),\n };\n}\n\nfunction challengeConfigKey(config: Config, options: GetListingSignInMessageOptions): string | undefined {\n try {\n return config.getChainConfigKey(options.chainId);\n } catch (error) {\n if (options.query?.enabled === false) return undefined;\n throw error;\n }\n}\n"],"mappings":";;;;AA6BA,SAAgB,EAAmC,GAAgB;CACjE,OAAO;EACL,aAAa,CAAC,qBAAqB;EACnC,aAAa,MACX,EAAoB,GAAQ,CAAS;CACzC;AACF;AAGA,SAAgB,EAAgC,GAAiE;CAC/G,OAAO,CAAC,2BAA2B,EAAmB,EAAE,GAAG,EAAQ,CAAC,CAAC;AACvE;AAgBA,SAAgB,EACd,GACA,GAMA;CACA,OAAO;EACL,GAAG,EAAQ;EACX,UAAU,EAAgC;GAAE,GAAG;GAAS,WAAW,EAAmB,GAAQ,CAAO;EAAE,CAAC;EACxG,SAAS,EAAQ,OAAO,WAAW;EACnC,eAAe,EAAwB,GAAQ,CAAO;CACxD;AACF;AAEA,SAAS,EAAmB,GAAgB,GAA6D;CACvG,IAAI;EACF,OAAO,EAAO,kBAAkB,EAAQ,OAAO;CACjD,SAAS,GAAO;EACd,IAAI,EAAQ,OAAO,YAAY,IAAO;EACtC,MAAM;CACR;AACF"}
|
|
@@ -7,7 +7,11 @@ import { ListingAuthToken, ListingSignInMessage, ListingSiweParams } from './typ
|
|
|
7
7
|
* @param raw - The generated `SignInMessageResponseSchema` from the backend.
|
|
8
8
|
* @returns The normalized sign-in message.
|
|
9
9
|
*/
|
|
10
|
-
export declare function toListingSignInMessage(raw: SignInMessageResponseSchema
|
|
10
|
+
export declare function toListingSignInMessage(raw: SignInMessageResponseSchema & {
|
|
11
|
+
params: {
|
|
12
|
+
expirationTime?: string | null;
|
|
13
|
+
};
|
|
14
|
+
}): ListingSignInMessage;
|
|
11
15
|
/**
|
|
12
16
|
* Rebuild the backend's `CustomSiweMessage` login payload from the normalized
|
|
13
17
|
* SIWE params, so the login request echoes back the exact message the backend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-siwe.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/to-siwe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEzF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,
|
|
1
|
+
{"version":3,"file":"to-siwe.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/to-siwe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAChH,OAAO,KAAK,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEzF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,2BAA2B,GAAG;IAAE,MAAM,EAAE;QAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,GAChF,oBAAoB,CAetB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAYhF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,KAAK,GAAG,gBAAgB,CAK/D"}
|
|
@@ -10,7 +10,8 @@ function e(e) {
|
|
|
10
10
|
chainId: e.params.chainId,
|
|
11
11
|
issuedAt: e.params.issuedAt,
|
|
12
12
|
nonce: e.params.nonce,
|
|
13
|
-
statement: e.params.statement
|
|
13
|
+
statement: e.params.statement,
|
|
14
|
+
...e.params.expirationTime == null ? {} : { expirationTime: e.params.expirationTime }
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
}
|
|
@@ -23,7 +24,8 @@ function t(e) {
|
|
|
23
24
|
chainId: e.chainId,
|
|
24
25
|
issuedAt: e.issuedAt,
|
|
25
26
|
nonce: e.nonce,
|
|
26
|
-
statement: e.statement
|
|
27
|
+
statement: e.statement,
|
|
28
|
+
...e.expirationTime == null ? {} : { expirationTime: e.expirationTime }
|
|
27
29
|
};
|
|
28
30
|
}
|
|
29
31
|
function n(e) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-siwe.js","names":[],"sources":["../../../src/pools/auth/to-siwe.ts"],"sourcesContent":["import type { CustomSiweMessage, SignInMessageResponseSchema, Token } from \"../types/generated/listing-backend\";\nimport type { ListingAuthToken, ListingSignInMessage, ListingSiweParams } from \"./types\";\n\n/**\n * Normalize the backend's raw sign-in challenge into the SDK's\n * {@link ListingSignInMessage}.\n *\n * @param raw - The generated `SignInMessageResponseSchema` from the backend.\n * @returns The normalized sign-in message.\n */\nexport function toListingSignInMessage(raw: SignInMessageResponseSchema): ListingSignInMessage {\n return {\n message: raw.message,\n params: {\n domain: raw.params.domain,\n address: raw.params.address,\n uri: raw.params.uri,\n version: raw.params.version,\n chainId: raw.params.chainId,\n issuedAt: raw.params.issuedAt,\n nonce: raw.params.nonce,\n statement: raw.params.statement,\n },\n };\n}\n\n/**\n * Rebuild the backend's `CustomSiweMessage` login payload from the normalized\n * SIWE params, so the login request echoes back the exact message the backend\n * minted.\n *\n * @param params - The normalized SIWE params from a sign-in challenge.\n * @returns The generated `CustomSiweMessage` to send in the login request.\n */\nexport function toCustomSiweMessage(params: ListingSiweParams): CustomSiweMessage {\n return {\n domain: params.domain,\n address: params.address,\n uri: params.uri,\n version: params.version,\n chainId: params.chainId,\n issuedAt: params.issuedAt,\n nonce: params.nonce,\n statement: params.statement,\n };\n}\n\n/**\n * Normalize the backend's raw `Token` into the SDK's {@link ListingAuthToken}.\n *\n * @param raw - The generated `Token` from a successful login.\n * @returns The normalized bearer token.\n */\nexport function toListingAuthToken(raw: Token): ListingAuthToken {\n return {\n accessToken: raw.accessToken,\n tokenType: raw.tokenType,\n };\n}\n"],"mappings":";AAUA,SAAgB,
|
|
1
|
+
{"version":3,"file":"to-siwe.js","names":[],"sources":["../../../src/pools/auth/to-siwe.ts"],"sourcesContent":["import type { CustomSiweMessage, SignInMessageResponseSchema, Token } from \"../types/generated/listing-backend\";\nimport type { ListingAuthToken, ListingSignInMessage, ListingSiweParams } from \"./types\";\n\n/**\n * Normalize the backend's raw sign-in challenge into the SDK's\n * {@link ListingSignInMessage}.\n *\n * @param raw - The generated `SignInMessageResponseSchema` from the backend.\n * @returns The normalized sign-in message.\n */\nexport function toListingSignInMessage(\n raw: SignInMessageResponseSchema & { params: { expirationTime?: string | null } },\n): ListingSignInMessage {\n return {\n message: raw.message,\n params: {\n domain: raw.params.domain,\n address: raw.params.address,\n uri: raw.params.uri,\n version: raw.params.version,\n chainId: raw.params.chainId,\n issuedAt: raw.params.issuedAt,\n nonce: raw.params.nonce,\n statement: raw.params.statement,\n ...(raw.params.expirationTime != null ? { expirationTime: raw.params.expirationTime } : {}),\n },\n };\n}\n\n/**\n * Rebuild the backend's `CustomSiweMessage` login payload from the normalized\n * SIWE params, so the login request echoes back the exact message the backend\n * minted.\n *\n * @param params - The normalized SIWE params from a sign-in challenge.\n * @returns The generated `CustomSiweMessage` to send in the login request.\n */\nexport function toCustomSiweMessage(params: ListingSiweParams): CustomSiweMessage {\n return {\n domain: params.domain,\n address: params.address,\n uri: params.uri,\n version: params.version,\n chainId: params.chainId,\n issuedAt: params.issuedAt,\n nonce: params.nonce,\n statement: params.statement,\n ...(params.expirationTime != null ? { expirationTime: params.expirationTime } : {}),\n };\n}\n\n/**\n * Normalize the backend's raw `Token` into the SDK's {@link ListingAuthToken}.\n *\n * @param raw - The generated `Token` from a successful login.\n * @returns The normalized bearer token.\n */\nexport function toListingAuthToken(raw: Token): ListingAuthToken {\n return {\n accessToken: raw.accessToken,\n tokenType: raw.tokenType,\n };\n}\n"],"mappings":";AAUA,SAAgB,EACd,GACsB;CACtB,OAAO;EACL,SAAS,EAAI;EACb,QAAQ;GACN,QAAQ,EAAI,OAAO;GACnB,SAAS,EAAI,OAAO;GACpB,KAAK,EAAI,OAAO;GAChB,SAAS,EAAI,OAAO;GACpB,SAAS,EAAI,OAAO;GACpB,UAAU,EAAI,OAAO;GACrB,OAAO,EAAI,OAAO;GAClB,WAAW,EAAI,OAAO;GACtB,GAAI,EAAI,OAAO,kBAAkB,OAAuD,CAAC,IAAjD,EAAE,gBAAgB,EAAI,OAAO,eAAe;EACtF;CACF;AACF;AAUA,SAAgB,EAAoB,GAA8C;CAChF,OAAO;EACL,QAAQ,EAAO;EACf,SAAS,EAAO;EAChB,KAAK,EAAO;EACZ,SAAS,EAAO;EAChB,SAAS,EAAO;EAChB,UAAU,EAAO;EACjB,OAAO,EAAO;EACd,WAAW,EAAO;EAClB,GAAI,EAAO,kBAAkB,OAAmD,CAAC,IAA7C,EAAE,gBAAgB,EAAO,eAAe;CAC9E;AACF;AAQA,SAAgB,EAAmB,GAA8B;CAC/D,OAAO;EACL,aAAa,EAAI;EACjB,WAAW,EAAI;CACjB;AACF"}
|
|
@@ -32,6 +32,8 @@ export interface ListingSiweParams {
|
|
|
32
32
|
nonce: string;
|
|
33
33
|
/** Human-readable assertion the user signs. */
|
|
34
34
|
statement: string;
|
|
35
|
+
/** Optional SIWE expiry, echoed unchanged in the exchange. */
|
|
36
|
+
expirationTime?: string;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* The listing backend's sign-in challenge: the full message to sign plus the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/pools/auth/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,qFAAqF;IACrF,MAAM,EAAE,iBAAiB,CAAC;CAC3B"}
|
|
@@ -7,7 +7,7 @@ import { isAxiosError as a } from "axios";
|
|
|
7
7
|
async function o(o, s) {
|
|
8
8
|
let { url: c } = n(o, { chainId: s.chainId });
|
|
9
9
|
try {
|
|
10
|
-
return i((await r(s.withdrawId, {
|
|
10
|
+
return i((await r(encodeURIComponent(s.withdrawId), {
|
|
11
11
|
baseURL: c,
|
|
12
12
|
headers: { Authorization: `Bearer ${s.accessToken}` }
|
|
13
13
|
})).data);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancel-withdraw.js","names":[],"sources":["../../../src/pools/cancel-withdraw/cancel-withdraw.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type { PoolCancelWithdrawResult } from \"../types\";\nimport { cancelWithdrawV2MarketWithdrawWithdrawIdDelete } from \"../types/generated/listing-backend\";\nimport { toCancelWithdrawResult } from \"./to-cancel-withdraw-result\";\n\n/**\n * Parameters for {@link cancelWithdraw}.\n *\n * Pool listing is chain-level, so this takes only a `chainId`: the listing\n * backend is resolved from the chain. The endpoint is authed and scoped to the\n * caller — a user may only cancel their own queued withdrawal.\n */\nexport type CancelWithdrawParameters = Compute<\n ChainIdParameter & {\n /**\n * Bearer token from `authenticateListing`; required — the endpoint is authed.\n * Sent as the `Authorization: Bearer <token>` header; a bad or expired token\n * yields a `401`.\n */\n accessToken: string;\n /**\n * Id of the queued withdrawal to cancel — the `transactionId` of the pending\n * `withdraw` row from the pool's transaction history (`getPoolTransactions`),\n * whose `status` is still `PENDING`.\n */\n withdrawId: string;\n }\n>;\n\n/**\n * Return type of {@link cancelWithdraw}: the cancellation receipt — the affected\n * transaction id and its resulting status.\n */\nexport type CancelWithdrawReturnType = PoolCancelWithdrawResult;\n\n/**\n * Cancel a queued LP withdrawal — remove a pending withdrawal from the pool's\n * withdrawal queue before it settles.\n *\n * `DELETE`s `/v2/market/withdraw/{withdrawId}` with the caller's bearer token.\n * The `withdrawId` is the `transactionId` of a still-`PENDING` `withdraw` row\n * from {@link getPoolTransactions}. On success the shares return to the user's\n * available balance, so refetch {@link getUserProfit} to see `availableLpAmount`\n * rise and `pendingWithdrawLpAmount` fall. Enigma-only.\n *\n * @param config - The SDK config.\n * @param parameters - The bearer token and the queued withdrawal's id.\n * @returns The cancellation receipt: the transaction id and its resulting status.\n * @throws {SymmApiError} `CANCEL_WITHDRAW_FAILED` when the endpoint request fails — including a `401` on a bad or expired token, a `404` for an unknown id, and the service's rejection when the withdrawal has already settled (no longer cancelable), which surface with the service's message and status as-is.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide the cancel action instead.\n *\n * @example\n * ```ts\n * const receipt = await cancelWithdraw(config, {\n * accessToken: token.accessToken,\n * withdrawId: pendingWithdrawal.transactionId,\n * });\n * ```\n */\nexport async function cancelWithdraw(\n config: Config,\n parameters: CancelWithdrawParameters,\n): Promise<CancelWithdrawReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n try {\n const response = await cancelWithdrawV2MarketWithdrawWithdrawIdDelete(parameters.withdrawId, {\n baseURL,\n headers: { Authorization: `Bearer ${parameters.accessToken}` },\n });\n\n return toCancelWithdrawResult(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"CANCEL_WITHDRAW_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"CANCEL_WITHDRAW_FAILED\",\n `Failed to cancel withdrawal: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AAgEA,eAAsB,EACpB,GACA,GACmC;CACnC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC;CAEtF,IAAI;EAMF,OAAO,GAAuB,MALP,EAA+C,EAAW,
|
|
1
|
+
{"version":3,"file":"cancel-withdraw.js","names":[],"sources":["../../../src/pools/cancel-withdraw/cancel-withdraw.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter, Compute } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type { PoolCancelWithdrawResult } from \"../types\";\nimport { cancelWithdrawV2MarketWithdrawWithdrawIdDelete } from \"../types/generated/listing-backend\";\nimport { toCancelWithdrawResult } from \"./to-cancel-withdraw-result\";\n\n/**\n * Parameters for {@link cancelWithdraw}.\n *\n * Pool listing is chain-level, so this takes only a `chainId`: the listing\n * backend is resolved from the chain. The endpoint is authed and scoped to the\n * caller — a user may only cancel their own queued withdrawal.\n */\nexport type CancelWithdrawParameters = Compute<\n ChainIdParameter & {\n /**\n * Bearer token from `authenticateListing`; required — the endpoint is authed.\n * Sent as the `Authorization: Bearer <token>` header; a bad or expired token\n * yields a `401`.\n */\n accessToken: string;\n /**\n * Id of the queued withdrawal to cancel — the `transactionId` of the pending\n * `withdraw` row from the pool's transaction history (`getPoolTransactions`),\n * whose `status` is still `PENDING`.\n */\n withdrawId: string;\n }\n>;\n\n/**\n * Return type of {@link cancelWithdraw}: the cancellation receipt — the affected\n * transaction id and its resulting status.\n */\nexport type CancelWithdrawReturnType = PoolCancelWithdrawResult;\n\n/**\n * Cancel a queued LP withdrawal — remove a pending withdrawal from the pool's\n * withdrawal queue before it settles.\n *\n * `DELETE`s `/v2/market/withdraw/{withdrawId}` with the caller's bearer token.\n * The `withdrawId` is the `transactionId` of a still-`PENDING` `withdraw` row\n * from {@link getPoolTransactions}. On success the shares return to the user's\n * available balance, so refetch {@link getUserProfit} to see `availableLpAmount`\n * rise and `pendingWithdrawLpAmount` fall. Enigma-only.\n *\n * @param config - The SDK config.\n * @param parameters - The bearer token and the queued withdrawal's id.\n * @returns The cancellation receipt: the transaction id and its resulting status.\n * @throws {SymmApiError} `CANCEL_WITHDRAW_FAILED` when the endpoint request fails — including a `401` on a bad or expired token, a `404` for an unknown id, and the service's rejection when the withdrawal has already settled (no longer cancelable), which surface with the service's message and status as-is.\n * @throws {SymmError} `LISTING_NOT_CONFIGURED` when the chain has no listing\n * backend. Gate with `supportsListingService` to hide the cancel action instead.\n *\n * @example\n * ```ts\n * const receipt = await cancelWithdraw(config, {\n * accessToken: token.accessToken,\n * withdrawId: pendingWithdrawal.transactionId,\n * });\n * ```\n */\nexport async function cancelWithdraw(\n config: Config,\n parameters: CancelWithdrawParameters,\n): Promise<CancelWithdrawReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n\n try {\n const response = await cancelWithdrawV2MarketWithdrawWithdrawIdDelete(encodeURIComponent(parameters.withdrawId), {\n baseURL,\n headers: { Authorization: `Bearer ${parameters.accessToken}` },\n });\n\n return toCancelWithdrawResult(response.data);\n } catch (err) {\n if (err instanceof SymmError) throw err;\n\n if (isAxiosError(err)) {\n throw SymmApiError.fromAxios(err, { code: \"CANCEL_WITHDRAW_FAILED\", baseURL });\n }\n\n throw new SymmError(\n \"api\",\n \"CANCEL_WITHDRAW_FAILED\",\n `Failed to cancel withdrawal: ${err instanceof Error ? err.message : String(err)}`,\n { cause: err instanceof Error ? err : undefined },\n );\n }\n}\n"],"mappings":";;;;;;AAgEA,eAAsB,EACpB,GACA,GACmC;CACnC,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC;CAEtF,IAAI;EAMF,OAAO,GAAuB,MALP,EAA+C,mBAAmB,EAAW,UAAU,GAAG;GAC/G;GACA,SAAS,EAAE,eAAe,UAAU,EAAW,cAAc;EAC/D,CAAC,GAEsC,IAAI;CAC7C,SAAS,GAAK;EAOZ,MANI,aAAe,IAAiB,IAEhC,EAAa,CAAG,IACZ,EAAa,UAAU,GAAK;GAAE,MAAM;GAA0B;EAAQ,CAAC,IAGzE,IAAI,EACR,OACA,0BACA,gCAAgC,aAAe,QAAQ,EAAI,UAAU,OAAO,CAAG,KAC/E,EAAE,OAAO,aAAe,QAAQ,IAAM,KAAA,EAAU,CAClD;CACF;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Config } from '../../core/config/index.js';
|
|
2
|
+
import { ChainIdParameter } from '../../shared/types/properties.js';
|
|
3
|
+
import { PoolClaim } from '../types.js';
|
|
4
|
+
/** Identity and bearer token for a single accepted claim. */
|
|
5
|
+
export type GetPoolClaimParameters = ChainIdParameter & {
|
|
6
|
+
claimRequestId: string;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
};
|
|
9
|
+
/** Read a claim by its UUID, independently of a history page's current filters. */
|
|
10
|
+
export declare function getPoolClaim(config: Config, parameters: GetPoolClaimParameters): Promise<PoolClaim>;
|
|
11
|
+
//# sourceMappingURL=get-pool-claim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-pool-claim.d.ts","sourceRoot":"","sources":["../../../src/pools/claim-history/get-pool-claim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAI1C,6DAA6D;AAC7D,MAAM,MAAM,sBAAsB,GAAG,gBAAgB,GAAG;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAExG,mFAAmF;AACnF,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CAYzG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SymmApiError as e } from "../../shared/errors/symm-error.js";
|
|
2
|
+
import { resolveListingService as t } from "../resolve-listing.js";
|
|
3
|
+
import { getClaimProfitV2ClaimClaimRequestIdGet as n } from "../types/generated/listing-backend.js";
|
|
4
|
+
import { toPoolClaim as r } from "./to-pool-claim.js";
|
|
5
|
+
import { isAxiosError as i } from "axios";
|
|
6
|
+
//#region src/pools/claim-history/get-pool-claim.ts
|
|
7
|
+
async function a(a, o) {
|
|
8
|
+
let { url: s } = t(a, o);
|
|
9
|
+
try {
|
|
10
|
+
let { data: e } = await n(o.claimRequestId, {
|
|
11
|
+
baseURL: s,
|
|
12
|
+
headers: { Authorization: `Bearer ${o.accessToken}` }
|
|
13
|
+
});
|
|
14
|
+
return r(e);
|
|
15
|
+
} catch (t) {
|
|
16
|
+
throw i(t) ? e.fromAxios(t, {
|
|
17
|
+
code: "GET_POOL_CLAIM_FAILED",
|
|
18
|
+
baseURL: s
|
|
19
|
+
}) : t;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { a as getPoolClaim };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=get-pool-claim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-pool-claim.js","names":[],"sources":["../../../src/pools/claim-history/get-pool-claim.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter } from \"../../shared/types/properties\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport type { PoolClaim } from \"../types\";\nimport { getClaimProfitV2ClaimClaimRequestIdGet } from \"../types/generated/listing-backend\";\nimport { toPoolClaim } from \"./to-pool-claim\";\n\n/** Identity and bearer token for a single accepted claim. */\nexport type GetPoolClaimParameters = ChainIdParameter & { claimRequestId: string; accessToken: string };\n\n/** Read a claim by its UUID, independently of a history page's current filters. */\nexport async function getPoolClaim(config: Config, parameters: GetPoolClaimParameters): Promise<PoolClaim> {\n const { url: baseURL } = resolveListingService(config, parameters);\n try {\n const { data } = await getClaimProfitV2ClaimClaimRequestIdGet(parameters.claimRequestId, {\n baseURL,\n headers: { Authorization: `Bearer ${parameters.accessToken}` },\n });\n return toPoolClaim(data);\n } catch (error) {\n if (isAxiosError(error)) throw SymmApiError.fromAxios(error, { code: \"GET_POOL_CLAIM_FAILED\", baseURL });\n throw error;\n }\n}\n"],"mappings":";;;;;;AAaA,eAAsB,EAAa,GAAgB,GAAwD;CACzG,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,CAAU;CACjE,IAAI;EACF,IAAM,EAAE,YAAS,MAAM,EAAuC,EAAW,gBAAgB;GACvF;GACA,SAAS,EAAE,eAAe,UAAU,EAAW,cAAc;EAC/D,CAAC;EACD,OAAO,EAAY,CAAI;CACzB,SAAS,GAAO;EAEd,MADI,EAAa,CAAK,IAAS,EAAa,UAAU,GAAO;GAAE,MAAM;GAAyB;EAAQ,CAAC,IACjG;CACR;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pools/claim-history/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pools/claim-history/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-pool-claim.d.ts","sourceRoot":"","sources":["../../../src/pools/claim-history/to-pool-claim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAE7G;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,sBAAsB,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"to-pool-claim.d.ts","sourceRoot":"","sources":["../../../src/pools/claim-history/to-pool-claim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAE7G;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,sBAAsB,GAAG,SAAS,CAUlE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,0BAA0B,GAAG,oBAAoB,CAK5F"}
|
|
@@ -3,6 +3,8 @@ import { parseListingValue as e } from "../markets/to-listing-market.js";
|
|
|
3
3
|
function t(t) {
|
|
4
4
|
return {
|
|
5
5
|
claimRequestId: t.claim_request_id,
|
|
6
|
+
walletId: t.wallet_id,
|
|
7
|
+
marketId: t.market_id,
|
|
6
8
|
accountAddress: t.account_address,
|
|
7
9
|
amount: e(t.amount) ?? 0n,
|
|
8
10
|
transactionHash: t.transaction_hash ?? null,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-pool-claim.js","names":[],"sources":["../../../src/pools/claim-history/to-pool-claim.ts"],"sourcesContent":["import { parseListingValue } from \"../markets/to-listing-market\";\nimport type { PoolClaim, PoolClaimHistoryPage } from \"../types\";\nimport type { GetClaimResponseSchema, SearchClaimsResponseSchema } from \"../types/generated/listing-backend\";\n\n/**\n * Map one raw claim record into the SDK's {@link PoolClaim}.\n *\n * `amount` is the claimed USDC in **plain decimal units** (`\"0.0377\"`), the same\n * form as `claimable_reward` on `/v2/profit` — it is scaled up with\n * {@link parseListingValue} to the SDK's uniform 18-decimal `bigint`. The wire's\n * internal `wallet_id` / `market_id` UUIDs are dropped; they address rows in the\n * service, not anything a consumer renders.\n *\n * @param raw - One claim record from the search response.\n * @returns The normalized claim.\n */\nexport function toPoolClaim(raw: GetClaimResponseSchema): PoolClaim {\n return {\n claimRequestId: raw.claim_request_id,\n accountAddress: raw.account_address,\n amount: parseListingValue(raw.amount) ?? 0n,\n transactionHash: raw.transaction_hash ?? null,\n time: raw.create_time,\n };\n}\n\n/**\n * Map the `/v2/claim/search` envelope into a {@link PoolClaimHistoryPage}.\n *\n * @param raw - The response body.\n * @returns The normalized page. `count` is the total across all pages.\n */\nexport function toPoolClaimHistoryPage(raw: SearchClaimsResponseSchema): PoolClaimHistoryPage {\n return {\n count: raw.total,\n items: (raw.data ?? []).map(toPoolClaim),\n };\n}\n"],"mappings":";;AAgBA,SAAgB,EAAY,GAAwC;CAClE,OAAO;EACL,gBAAgB,EAAI;EACpB,gBAAgB,EAAI;EACpB,QAAQ,EAAkB,EAAI,MAAM,KAAK;EACzC,iBAAiB,EAAI,oBAAoB;EACzC,MAAM,EAAI;CACZ;AACF;AAQA,SAAgB,EAAuB,GAAuD;CAC5F,OAAO;EACL,OAAO,EAAI;EACX,QAAQ,EAAI,QAAQ,CAAC,GAAG,IAAI,CAAW;CACzC;AACF"}
|
|
1
|
+
{"version":3,"file":"to-pool-claim.js","names":[],"sources":["../../../src/pools/claim-history/to-pool-claim.ts"],"sourcesContent":["import { parseListingValue } from \"../markets/to-listing-market\";\nimport type { PoolClaim, PoolClaimHistoryPage } from \"../types\";\nimport type { GetClaimResponseSchema, SearchClaimsResponseSchema } from \"../types/generated/listing-backend\";\n\n/**\n * Map one raw claim record into the SDK's {@link PoolClaim}.\n *\n * `amount` is the claimed USDC in **plain decimal units** (`\"0.0377\"`), the same\n * form as `claimable_reward` on `/v2/profit` — it is scaled up with\n * {@link parseListingValue} to the SDK's uniform 18-decimal `bigint`. The wire's\n * internal `wallet_id` / `market_id` UUIDs are dropped; they address rows in the\n * service, not anything a consumer renders.\n *\n * @param raw - One claim record from the search response.\n * @returns The normalized claim.\n */\nexport function toPoolClaim(raw: GetClaimResponseSchema): PoolClaim {\n return {\n claimRequestId: raw.claim_request_id,\n walletId: raw.wallet_id,\n marketId: raw.market_id,\n accountAddress: raw.account_address,\n amount: parseListingValue(raw.amount) ?? 0n,\n transactionHash: raw.transaction_hash ?? null,\n time: raw.create_time,\n };\n}\n\n/**\n * Map the `/v2/claim/search` envelope into a {@link PoolClaimHistoryPage}.\n *\n * @param raw - The response body.\n * @returns The normalized page. `count` is the total across all pages.\n */\nexport function toPoolClaimHistoryPage(raw: SearchClaimsResponseSchema): PoolClaimHistoryPage {\n return {\n count: raw.total,\n items: (raw.data ?? []).map(toPoolClaim),\n };\n}\n"],"mappings":";;AAgBA,SAAgB,EAAY,GAAwC;CAClE,OAAO;EACL,gBAAgB,EAAI;EACpB,UAAU,EAAI;EACd,UAAU,EAAI;EACd,gBAAgB,EAAI;EACpB,QAAQ,EAAkB,EAAI,MAAM,KAAK;EACzC,iBAAiB,EAAI,oBAAoB;EACzC,MAAM,EAAI;CACZ;AACF;AAQA,SAAgB,EAAuB,GAAuD;CAC5F,OAAO;EACL,OAAO,EAAI;EACX,QAAQ,EAAI,QAAQ,CAAC,GAAG,IAAI,CAAW;CACzC;AACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** A source that could not supply a complete snapshot. Never contains credentials or response bodies. */
|
|
2
|
+
export interface PoolReadGap {
|
|
3
|
+
/** Read family, such as deposits, profit, detail, or listed. */
|
|
4
|
+
source: string;
|
|
5
|
+
/** Exact pool address, when the gap belongs to one pool. */
|
|
6
|
+
tokenContractAddress?: string;
|
|
7
|
+
/** Failed requests are distinct from bounded or repeated pagination. */
|
|
8
|
+
reason: "failed" | "truncated" | "repeated-page" | "ambiguous-address";
|
|
9
|
+
}
|
|
10
|
+
export declare function units(value: bigint | null | undefined): number | null;
|
|
11
|
+
export declare function readOptional<T>(read: () => Promise<T>, gaps: PoolReadGap[], source: string, tokenContractAddress?: string): Promise<T | null>;
|
|
12
|
+
export declare function readPages<T>(read: (offset: number) => Promise<{
|
|
13
|
+
items: T[];
|
|
14
|
+
total: number;
|
|
15
|
+
}>, identity: (item: T) => string, gaps: PoolReadGap[], source: string, maxPages?: number): Promise<T[]>;
|
|
16
|
+
//# sourceMappingURL=composition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.d.ts","sourceRoot":"","sources":["../../src/pools/composition.ts"],"names":[],"mappings":"AAEA,yGAAyG;AACzG,MAAM,WAAW,WAAW;IAC1B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,eAAe,GAAG,mBAAmB,CAAC;CACxE;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAErE;AAED,wBAAsB,YAAY,CAAC,CAAC,EAClC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,oBAAoB,CAAC,EAAE,MAAM,GAC5B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAUnB;AAED,wBAAsB,SAAS,CAAC,CAAC,EAC/B,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,EAChE,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,EAC7B,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,QAAQ,SAAK,GACZ,OAAO,CAAC,CAAC,EAAE,CAAC,CAmBd"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { formatUnits as e } from "viem";
|
|
2
|
+
//#region src/pools/composition.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
return t == null ? null : Number(e(t, 18));
|
|
5
|
+
}
|
|
6
|
+
async function n(e, t, n, r) {
|
|
7
|
+
try {
|
|
8
|
+
return await e();
|
|
9
|
+
} catch (e) {
|
|
10
|
+
if (e && typeof e == "object" && "status" in e && (e.status === 401 || e.status === 403)) throw e;
|
|
11
|
+
return t.push({
|
|
12
|
+
source: n,
|
|
13
|
+
tokenContractAddress: r,
|
|
14
|
+
reason: "failed"
|
|
15
|
+
}), null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function r(e, t, r, i, a = 10) {
|
|
19
|
+
let o = /* @__PURE__ */ new Map(), s = 0;
|
|
20
|
+
for (let c = 0; c < a; c++) {
|
|
21
|
+
let a = await n(() => e(s), r, i);
|
|
22
|
+
if (a == null) return [...o.values()];
|
|
23
|
+
let c = o.size;
|
|
24
|
+
for (let e of a.items) o.set(t(e), e);
|
|
25
|
+
if (s += a.items.length, o.size >= a.total) return [...o.values()];
|
|
26
|
+
if (o.size === c) return r.push({
|
|
27
|
+
source: i,
|
|
28
|
+
reason: "repeated-page"
|
|
29
|
+
}), [...o.values()];
|
|
30
|
+
}
|
|
31
|
+
return r.push({
|
|
32
|
+
source: i,
|
|
33
|
+
reason: "truncated"
|
|
34
|
+
}), [...o.values()];
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { n as readOptional, r as readPages, t as units };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=composition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composition.js","names":[],"sources":["../../src/pools/composition.ts"],"sourcesContent":["import { formatUnits } from \"viem\";\n\n/** A source that could not supply a complete snapshot. Never contains credentials or response bodies. */\nexport interface PoolReadGap {\n /** Read family, such as deposits, profit, detail, or listed. */\n source: string;\n /** Exact pool address, when the gap belongs to one pool. */\n tokenContractAddress?: string;\n /** Failed requests are distinct from bounded or repeated pagination. */\n reason: \"failed\" | \"truncated\" | \"repeated-page\" | \"ambiguous-address\";\n}\n\nexport function units(value: bigint | null | undefined): number | null {\n return value == null ? null : Number(formatUnits(value, 18));\n}\n\nexport async function readOptional<T>(\n read: () => Promise<T>,\n gaps: PoolReadGap[],\n source: string,\n tokenContractAddress?: string,\n): Promise<T | null> {\n try {\n return await read();\n } catch (error) {\n // Expired sessions must remain actionable errors, not partial portfolios.\n if (error && typeof error === \"object\" && \"status\" in error && (error.status === 401 || error.status === 403))\n throw error;\n gaps.push({ source, tokenContractAddress, reason: \"failed\" });\n return null;\n }\n}\n\nexport async function readPages<T>(\n read: (offset: number) => Promise<{ items: T[]; total: number }>,\n identity: (item: T) => string,\n gaps: PoolReadGap[],\n source: string,\n maxPages = 10,\n): Promise<T[]> {\n const values = new Map<string, T>();\n let offset = 0;\n for (let page = 0; page < maxPages; page++) {\n const result = await readOptional(() => read(offset), gaps, source);\n // A later page failing must not erase holdings discovered on earlier pages.\n // The gap still prevents callers from treating partial history as complete.\n if (result == null) return [...values.values()];\n const previousSize = values.size;\n for (const item of result.items) values.set(identity(item), item);\n offset += result.items.length;\n if (values.size >= result.total) return [...values.values()];\n if (values.size === previousSize) {\n gaps.push({ source, reason: \"repeated-page\" });\n return [...values.values()];\n }\n }\n gaps.push({ source, reason: \"truncated\" });\n return [...values.values()];\n}\n"],"mappings":";;AAYA,SAAgB,EAAM,GAAiD;CACrE,OAAO,KAAS,OAAO,OAAO,OAAO,EAAY,GAAO,EAAE,CAAC;AAC7D;AAEA,eAAsB,EACpB,GACA,GACA,GACA,GACmB;CACnB,IAAI;EACF,OAAO,MAAM,EAAK;CACpB,SAAS,GAAO;EAEd,IAAI,KAAS,OAAO,KAAU,YAAY,YAAY,MAAU,EAAM,WAAW,OAAO,EAAM,WAAW,MACvG,MAAM;EAER,OADA,EAAK,KAAK;GAAE;GAAQ;GAAsB,QAAQ;EAAS,CAAC,GACrD;CACT;AACF;AAEA,eAAsB,EACpB,GACA,GACA,GACA,GACA,IAAW,IACG;CACd,IAAM,oBAAS,IAAI,IAAe,GAC9B,IAAS;CACb,KAAK,IAAI,IAAO,GAAG,IAAO,GAAU,KAAQ;EAC1C,IAAM,IAAS,MAAM,QAAmB,EAAK,CAAM,GAAG,GAAM,CAAM;EAGlE,IAAI,KAAU,MAAM,OAAO,CAAC,GAAG,EAAO,OAAO,CAAC;EAC9C,IAAM,IAAe,EAAO;EAC5B,KAAK,IAAM,KAAQ,EAAO,OAAO,EAAO,IAAI,EAAS,CAAI,GAAG,CAAI;EAEhE,IADA,KAAU,EAAO,MAAM,QACnB,EAAO,QAAQ,EAAO,OAAO,OAAO,CAAC,GAAG,EAAO,OAAO,CAAC;EAC3D,IAAI,EAAO,SAAS,GAElB,OADA,EAAK,KAAK;GAAE;GAAQ,QAAQ;EAAgB,CAAC,GACtC,CAAC,GAAG,EAAO,OAAO,CAAC;CAE9B;CAEA,OADA,EAAK,KAAK;EAAE;EAAQ,QAAQ;CAAY,CAAC,GAClC,CAAC,GAAG,EAAO,OAAO,CAAC;AAC5B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-pool-profit.d.ts","sourceRoot":"","sources":["../../src/pools/empty-pool-profit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,iFAAiF;AACjF,wBAAgB,eAAe,IAAI,cAAc,CAWhD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
//#region src/pools/empty-pool-profit.ts
|
|
2
|
+
function e() {
|
|
3
|
+
return {
|
|
4
|
+
userBalanceInTokens: 0n,
|
|
5
|
+
userBalanceInUsdc: 0n,
|
|
6
|
+
userLpAmount: 0n,
|
|
7
|
+
pendingWithdrawLpAmount: 0n,
|
|
8
|
+
availableLpAmount: 0n,
|
|
9
|
+
userDepositedTokenAmount: 0n,
|
|
10
|
+
claimableReward: 0n,
|
|
11
|
+
claimedReward: 0n
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { e as emptyPoolProfit };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=empty-pool-profit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-pool-profit.js","names":[],"sources":["../../src/pools/empty-pool-profit.ts"],"sourcesContent":["import type { UserPoolProfit } from \"./types\";\n\n/** A confirmed absence of an LP position, never a fallback for a failed read. */\nexport function emptyPoolProfit(): UserPoolProfit {\n return {\n userBalanceInTokens: 0n,\n userBalanceInUsdc: 0n,\n userLpAmount: 0n,\n pendingWithdrawLpAmount: 0n,\n availableLpAmount: 0n,\n userDepositedTokenAmount: 0n,\n claimableReward: 0n,\n claimedReward: 0n,\n };\n}\n"],"mappings":";AAGA,SAAgB,IAAkC;CAChD,OAAO;EACL,qBAAqB;EACrB,mBAAmB;EACnB,cAAc;EACd,yBAAyB;EACzB,mBAAmB;EACnB,0BAA0B;EAC1B,iBAAiB;EACjB,eAAe;CACjB;AACF"}
|
package/dist/pools/index.d.ts
CHANGED
|
@@ -6,9 +6,14 @@ export * from './claim-history/index.js';
|
|
|
6
6
|
export * from './deposit-address/index.js';
|
|
7
7
|
export * from './listing-config/index.js';
|
|
8
8
|
export * from './listing-status/index.js';
|
|
9
|
+
export * from './maintenance-fees/index.js';
|
|
9
10
|
export * from './market-config/index.js';
|
|
11
|
+
export * from './market-data/index.js';
|
|
10
12
|
export * from './market-detail/index.js';
|
|
11
13
|
export * from './markets/index.js';
|
|
14
|
+
export * from './open-positions/index.js';
|
|
15
|
+
export * from './portfolio/index.js';
|
|
16
|
+
export * from './position/index.js';
|
|
12
17
|
export * from './profit/index.js';
|
|
13
18
|
export * from './quotes/index.js';
|
|
14
19
|
export * from './refund/index.js';
|
|
@@ -16,7 +21,10 @@ export * from './resolve-listing.js';
|
|
|
16
21
|
export * from './resolve-pool-source.js';
|
|
17
22
|
export * from './retry-listing/index.js';
|
|
18
23
|
export * from './rewards/index.js';
|
|
24
|
+
export * from './statistics/index.js';
|
|
25
|
+
export * from './token-metadata/index.js';
|
|
19
26
|
export * from './token-price/index.js';
|
|
27
|
+
export * from './token-support/index.js';
|
|
20
28
|
export * from './trade-history/index.js';
|
|
21
29
|
export * from './transactions/index.js';
|
|
22
30
|
export * from './types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pools/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pools/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,mBAAmB,CAAC;AAClC,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
|
|
@@ -12,5 +12,9 @@ import { ClientConfigResponse } from '../types/generated/listing-backend.js';
|
|
|
12
12
|
* @param raw - The service's `/v2/configs` response body.
|
|
13
13
|
* @returns The normalized listing config.
|
|
14
14
|
*/
|
|
15
|
-
export declare function toListingConfig(raw: ClientConfigResponse
|
|
15
|
+
export declare function toListingConfig(raw: Omit<Partial<ClientConfigResponse>, "rate_limits"> & {
|
|
16
|
+
rate_limits?: Partial<ClientConfigResponse["rate_limits"]>;
|
|
17
|
+
minimum_initial_deposit_usdc?: string | null;
|
|
18
|
+
recommended_initial_deposit_usdc?: string | null;
|
|
19
|
+
}): ListingConfig;
|
|
16
20
|
//# sourceMappingURL=to-listing-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-listing-config.d.ts","sourceRoot":"","sources":["../../../src/pools/listing-config/to-listing-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAA0C,MAAM,UAAU,CAAC;AAEtF,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,oCAAoC,CAAC;AAe5G;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,oBAAoB,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"to-listing-config.d.ts","sourceRoot":"","sources":["../../../src/pools/listing-config/to-listing-config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAA0C,MAAM,UAAU,CAAC;AAEtF,OAAO,KAAK,EAAE,oBAAoB,EAA+B,MAAM,oCAAoC,CAAC;AAe5G;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,aAAa,CAAC,GAAG;IACxD,WAAW,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3D,4BAA4B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,gCAAgC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClD,GACA,aAAa,CAsCf"}
|
|
@@ -7,17 +7,28 @@ function t(e) {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
function n(n) {
|
|
10
|
-
let r = {
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
let r = "minimum_initial_deposit_usdc" in n && typeof n.minimum_initial_deposit_usdc == "string" ? n.minimum_initial_deposit_usdc : void 0, i = "recommended_initial_deposit_usdc" in n && typeof n.recommended_initial_deposit_usdc == "string" ? n.recommended_initial_deposit_usdc : void 0, a = r != null || i != null, o = e(a ? r : n.minimum_deposit_usdc), s = e(n.recommended_deposit_usdc ?? i), c = n.max_leverage_bounds, l = c && Number.isFinite(c.minimum) && Number.isFinite(c.maximum) && c.minimum <= c.maximum ? {
|
|
11
|
+
minimum: c.minimum,
|
|
12
|
+
maximum: c.maximum
|
|
13
|
+
} : null, u = {
|
|
14
|
+
marketConfigUpdatesPerDay: n.rate_limits?.market_config_updates_per_day ?? null,
|
|
15
|
+
profitClaimsPerDay: n.rate_limits?.profit_claims_per_day ?? null
|
|
13
16
|
};
|
|
14
17
|
return {
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
recommendedDepositUsdc: s,
|
|
19
|
+
minimumDepositUsdc: o,
|
|
20
|
+
legacyUniversalDepositFloorUsdc: a ? e(n.minimum_deposit_usdc) : null,
|
|
21
|
+
reportedListingFeeUsdc: e(n.listing_fee_usdc),
|
|
22
|
+
maxLeverageBounds: l,
|
|
23
|
+
reportedMarketConfigUpdatesPerDay: n.rate_limits?.market_config_updates_per_day ?? null,
|
|
24
|
+
reportedProfitClaimsPerDay: n.rate_limits?.profit_claims_per_day ?? null,
|
|
25
|
+
reportedProtocolRewardSharePercent: n.protocol_reward_share_percent ?? null,
|
|
26
|
+
recommendedInitialDepositUsdc: s ?? 0n,
|
|
27
|
+
minimumInitialDepositUsdc: o ?? 0n,
|
|
17
28
|
listingFeeUsdc: e(n.listing_fee_usdc) ?? 0n,
|
|
18
|
-
supportedDepositChains: n.supported_deposit_chains.map(t),
|
|
19
|
-
rateLimits:
|
|
20
|
-
protocolRewardSharePercent: n.protocol_reward_share_percent
|
|
29
|
+
supportedDepositChains: (n.supported_deposit_chains ?? []).map(t),
|
|
30
|
+
rateLimits: u,
|
|
31
|
+
protocolRewardSharePercent: n.protocol_reward_share_percent ?? 0
|
|
21
32
|
};
|
|
22
33
|
}
|
|
23
34
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-listing-config.js","names":[],"sources":["../../../src/pools/listing-config/to-listing-config.ts"],"sourcesContent":["import { toListingValue } from \"../markets/to-listing-market\";\nimport type { ListingConfig, ListingDepositChain, ListingRateLimits } from \"../types\";\nimport { ListingDepositChainId } from \"../types\";\nimport type { ClientConfigResponse, SupportedDepositChainConfig } from \"../types/generated/listing-backend\";\n\n/**\n * Map one raw `SupportedDepositChainConfig` into a {@link ListingDepositChain}.\n *\n * @param raw - One entry of the config's `supported_deposit_chains` array.\n * @returns The normalized deposit chain.\n */\nfunction toListingDepositChain(raw: SupportedDepositChainConfig): ListingDepositChain {\n return {\n chainId: raw.chain_id as ListingDepositChainId,\n chainName: raw.chain_name,\n };\n}\n\n/**\n * Map the listing service's raw `ClientConfigResponse` into the SDK's\n * {@link ListingConfig}.\n *\n * The three `*_usdc` figures are required 18-decimal strings; each is parsed\n * with {@link toListingValue} and defaulted to `0n` if the service ever returns\n * a malformed value (`toListingValue` returns `null` there). The wire's\n * snake_case becomes the SDK's camelCase.\n *\n * @param raw - The service's `/v2/configs` response body.\n * @returns The normalized listing config.\n */\nexport function toListingConfig(raw: ClientConfigResponse): ListingConfig {\n const rateLimits: ListingRateLimits = {\n marketConfigUpdatesPerDay: raw.rate_limits
|
|
1
|
+
{"version":3,"file":"to-listing-config.js","names":[],"sources":["../../../src/pools/listing-config/to-listing-config.ts"],"sourcesContent":["import { toListingValue } from \"../markets/to-listing-market\";\nimport type { ListingConfig, ListingDepositChain, ListingRateLimits } from \"../types\";\nimport { ListingDepositChainId } from \"../types\";\nimport type { ClientConfigResponse, SupportedDepositChainConfig } from \"../types/generated/listing-backend\";\n\n/**\n * Map one raw `SupportedDepositChainConfig` into a {@link ListingDepositChain}.\n *\n * @param raw - One entry of the config's `supported_deposit_chains` array.\n * @returns The normalized deposit chain.\n */\nfunction toListingDepositChain(raw: SupportedDepositChainConfig): ListingDepositChain {\n return {\n chainId: raw.chain_id as ListingDepositChainId,\n chainName: raw.chain_name,\n };\n}\n\n/**\n * Map the listing service's raw `ClientConfigResponse` into the SDK's\n * {@link ListingConfig}.\n *\n * The three `*_usdc` figures are required 18-decimal strings; each is parsed\n * with {@link toListingValue} and defaulted to `0n` if the service ever returns\n * a malformed value (`toListingValue` returns `null` there). The wire's\n * snake_case becomes the SDK's camelCase.\n *\n * @param raw - The service's `/v2/configs` response body.\n * @returns The normalized listing config.\n */\nexport function toListingConfig(\n raw: Omit<Partial<ClientConfigResponse>, \"rate_limits\"> & {\n rate_limits?: Partial<ClientConfigResponse[\"rate_limits\"]>;\n minimum_initial_deposit_usdc?: string | null;\n recommended_initial_deposit_usdc?: string | null;\n },\n): ListingConfig {\n const legacyMinimum =\n \"minimum_initial_deposit_usdc\" in raw && typeof raw.minimum_initial_deposit_usdc === \"string\"\n ? raw.minimum_initial_deposit_usdc\n : undefined;\n const legacyRecommended =\n \"recommended_initial_deposit_usdc\" in raw && typeof raw.recommended_initial_deposit_usdc === \"string\"\n ? raw.recommended_initial_deposit_usdc\n : undefined;\n const isLegacy = legacyMinimum != null || legacyRecommended != null;\n const minimumDepositUsdc = toListingValue(isLegacy ? legacyMinimum : raw.minimum_deposit_usdc);\n const recommendedDepositUsdc = toListingValue(raw.recommended_deposit_usdc ?? legacyRecommended);\n const bounds = raw.max_leverage_bounds;\n const maxLeverageBounds =\n bounds && Number.isFinite(bounds.minimum) && Number.isFinite(bounds.maximum) && bounds.minimum <= bounds.maximum\n ? { minimum: bounds.minimum, maximum: bounds.maximum }\n : null;\n const rateLimits: ListingRateLimits = {\n marketConfigUpdatesPerDay: raw.rate_limits?.market_config_updates_per_day ?? null,\n profitClaimsPerDay: raw.rate_limits?.profit_claims_per_day ?? null,\n };\n\n return {\n recommendedDepositUsdc,\n minimumDepositUsdc,\n legacyUniversalDepositFloorUsdc: isLegacy ? toListingValue(raw.minimum_deposit_usdc) : null,\n reportedListingFeeUsdc: toListingValue(raw.listing_fee_usdc),\n maxLeverageBounds,\n reportedMarketConfigUpdatesPerDay: raw.rate_limits?.market_config_updates_per_day ?? null,\n reportedProfitClaimsPerDay: raw.rate_limits?.profit_claims_per_day ?? null,\n reportedProtocolRewardSharePercent: raw.protocol_reward_share_percent ?? null,\n recommendedInitialDepositUsdc: recommendedDepositUsdc ?? 0n,\n minimumInitialDepositUsdc: minimumDepositUsdc ?? 0n,\n listingFeeUsdc: toListingValue(raw.listing_fee_usdc) ?? 0n,\n supportedDepositChains: (raw.supported_deposit_chains ?? []).map(toListingDepositChain),\n rateLimits,\n protocolRewardSharePercent: raw.protocol_reward_share_percent ?? 0,\n };\n}\n"],"mappings":";;AAWA,SAAS,EAAsB,GAAuD;CACpF,OAAO;EACL,SAAS,EAAI;EACb,WAAW,EAAI;CACjB;AACF;AAcA,SAAgB,EACd,GAKe;CACf,IAAM,IACJ,kCAAkC,KAAO,OAAO,EAAI,gCAAiC,WACjF,EAAI,+BACJ,KAAA,GACA,IACJ,sCAAsC,KAAO,OAAO,EAAI,oCAAqC,WACzF,EAAI,mCACJ,KAAA,GACA,IAAW,KAAiB,QAAQ,KAAqB,MACzD,IAAqB,EAAe,IAAW,IAAgB,EAAI,oBAAoB,GACvF,IAAyB,EAAe,EAAI,4BAA4B,CAAiB,GACzF,IAAS,EAAI,qBACb,IACJ,KAAU,OAAO,SAAS,EAAO,OAAO,KAAK,OAAO,SAAS,EAAO,OAAO,KAAK,EAAO,WAAW,EAAO,UACrG;EAAE,SAAS,EAAO;EAAS,SAAS,EAAO;CAAQ,IACnD,MACA,IAAgC;EACpC,2BAA2B,EAAI,aAAa,iCAAiC;EAC7E,oBAAoB,EAAI,aAAa,yBAAyB;CAChE;CAEA,OAAO;EACL;EACA;EACA,iCAAiC,IAAW,EAAe,EAAI,oBAAoB,IAAI;EACvF,wBAAwB,EAAe,EAAI,gBAAgB;EAC3D;EACA,mCAAmC,EAAI,aAAa,iCAAiC;EACrF,4BAA4B,EAAI,aAAa,yBAAyB;EACtE,oCAAoC,EAAI,iCAAiC;EACzE,+BAA+B,KAA0B;EACzD,2BAA2B,KAAsB;EACjD,gBAAgB,EAAe,EAAI,gBAAgB,KAAK;EACxD,yBAAyB,EAAI,4BAA4B,CAAC,GAAG,IAAI,CAAqB;EACtF;EACA,4BAA4B,EAAI,iCAAiC;CACnE;AACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Config } from '../../core/config/index.js';
|
|
2
|
+
import { ChainIdParameter } from '../../shared/types/properties.js';
|
|
3
|
+
/** One maintenance sale, with monetary values at 18 decimals. */
|
|
4
|
+
export interface PoolMaintenanceFee {
|
|
5
|
+
/** Tokens sold. */ tokenAmount: bigint;
|
|
6
|
+
/** USDC received. */ usdcAmount: bigint;
|
|
7
|
+
/** Execution time in Unix seconds. */ timestamp: number;
|
|
8
|
+
/** On-chain hash, when supplied. */ transactionHash: string | null;
|
|
9
|
+
}
|
|
10
|
+
/** Paginated maintenance sales. */
|
|
11
|
+
export interface PoolMaintenanceFees {
|
|
12
|
+
/** Total records. */ total: number;
|
|
13
|
+
/** This page's sales. */ items: PoolMaintenanceFee[];
|
|
14
|
+
}
|
|
15
|
+
/** Inputs for {@link getPoolMaintenanceFees}. Deployment chainId is separate from depositChain. */
|
|
16
|
+
export type GetPoolMaintenanceFeesParameters = ChainIdParameter & {
|
|
17
|
+
/** Pool token address. */
|
|
18
|
+
tokenContractAddress: string;
|
|
19
|
+
/** Chain the pool token lives on. */
|
|
20
|
+
depositChain: number;
|
|
21
|
+
/** Page size. */
|
|
22
|
+
limit?: number;
|
|
23
|
+
/** Page offset. */
|
|
24
|
+
offset?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Result of {@link getPoolMaintenanceFees}. */
|
|
27
|
+
export type GetPoolMaintenanceFeesReturnType = PoolMaintenanceFees;
|
|
28
|
+
/**
|
|
29
|
+
* Read a pool's maintenance-sale history from the configured listing service.
|
|
30
|
+
* @param config - SDK configuration.
|
|
31
|
+
* @param parameters - Token identity and request parameters.
|
|
32
|
+
* @returns The normalized service result.
|
|
33
|
+
* @example
|
|
34
|
+
* await getPoolMaintenanceFees(config, { chainId: 42161, depositChain: 0, tokenContractAddress: mint });
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPoolMaintenanceFees(config: Config, parameters: GetPoolMaintenanceFeesParameters): Promise<GetPoolMaintenanceFeesReturnType>;
|
|
37
|
+
//# sourceMappingURL=get-pool-maintenance-fees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-pool-maintenance-fees.d.ts","sourceRoot":"","sources":["../../../src/pools/maintenance-fees/get-pool-maintenance-fees.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAKtE,iEAAiE;AACjE,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,WAAW,EAAE,MAAM,CAAC;IACxC,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC;IACzC,sCAAsC,CAAC,SAAS,EAAE,MAAM,CAAC;IACzD,oCAAoC,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CACrE;AACD,mCAAmC;AACnC,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,CAAC,KAAK,EAAE,MAAM,CAAC;IACpC,yBAAyB,CAAC,KAAK,EAAE,kBAAkB,EAAE,CAAC;CACvD;AACD,mGAAmG;AACnG,MAAM,MAAM,gCAAgC,GAAG,gBAAgB,GAAG;IAChE,0BAA0B;IAC1B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,gDAAgD;AAChD,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,CAAC;AAEnE;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,gCAAgC,GAC3C,OAAO,CAAC,gCAAgC,CAAC,CA0B3C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SymmApiError as e, SymmError as t } from "../../shared/errors/symm-error.js";
|
|
2
|
+
import { resolveListingService as n } from "../resolve-listing.js";
|
|
3
|
+
import { getMaintenanceFeeRecordsV2MarketMaintenanceFeesGet as r } from "../types/generated/listing-backend.js";
|
|
4
|
+
import { toListingValue as i } from "../markets/to-listing-market.js";
|
|
5
|
+
import { isAxiosError as a } from "axios";
|
|
6
|
+
//#region src/pools/maintenance-fees/get-pool-maintenance-fees.ts
|
|
7
|
+
async function o(o, s) {
|
|
8
|
+
let { url: c } = n(o, { chainId: s.chainId });
|
|
9
|
+
try {
|
|
10
|
+
let { data: e } = await r({
|
|
11
|
+
market_address: s.tokenContractAddress,
|
|
12
|
+
chain_id: s.depositChain,
|
|
13
|
+
limit: s.limit,
|
|
14
|
+
offset: s.offset
|
|
15
|
+
}, { baseURL: c });
|
|
16
|
+
return {
|
|
17
|
+
total: e.total,
|
|
18
|
+
items: e.items.map((e) => ({
|
|
19
|
+
tokenAmount: i(e.token_amount) ?? 0n,
|
|
20
|
+
usdcAmount: i(e.usdc_amount) ?? 0n,
|
|
21
|
+
timestamp: e.timestamp / 1e3,
|
|
22
|
+
transactionHash: e.tx_hash ?? null
|
|
23
|
+
}))
|
|
24
|
+
};
|
|
25
|
+
} catch (n) {
|
|
26
|
+
throw n instanceof t ? n : a(n) ? e.fromAxios(n, {
|
|
27
|
+
code: "GET_POOL_MAINTENANCE_FEES_FAILED",
|
|
28
|
+
baseURL: c
|
|
29
|
+
}) : new t("api", "GET_POOL_MAINTENANCE_FEES_FAILED", "Listing request failed", { cause: n });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { o as getPoolMaintenanceFees };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=get-pool-maintenance-fees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-pool-maintenance-fees.js","names":[],"sources":["../../../src/pools/maintenance-fees/get-pool-maintenance-fees.ts"],"sourcesContent":["import { isAxiosError } from \"axios\";\nimport type { Config } from \"../../core/config\";\nimport { SymmApiError, SymmError } from \"../../shared/errors/symm-error\";\nimport type { ChainIdParameter } from \"../../shared/types/properties\";\nimport { toListingValue } from \"../markets/to-listing-market\";\nimport { resolveListingService } from \"../resolve-listing\";\nimport { getMaintenanceFeeRecordsV2MarketMaintenanceFeesGet } from \"../types/generated/listing-backend\";\n\n/** One maintenance sale, with monetary values at 18 decimals. */\nexport interface PoolMaintenanceFee {\n /** Tokens sold. */ tokenAmount: bigint;\n /** USDC received. */ usdcAmount: bigint;\n /** Execution time in Unix seconds. */ timestamp: number;\n /** On-chain hash, when supplied. */ transactionHash: string | null;\n}\n/** Paginated maintenance sales. */\nexport interface PoolMaintenanceFees {\n /** Total records. */ total: number;\n /** This page's sales. */ items: PoolMaintenanceFee[];\n}\n/** Inputs for {@link getPoolMaintenanceFees}. Deployment chainId is separate from depositChain. */\nexport type GetPoolMaintenanceFeesParameters = ChainIdParameter & {\n /** Pool token address. */\n tokenContractAddress: string;\n /** Chain the pool token lives on. */\n depositChain: number;\n /** Page size. */\n limit?: number;\n /** Page offset. */\n offset?: number;\n};\n/** Result of {@link getPoolMaintenanceFees}. */\nexport type GetPoolMaintenanceFeesReturnType = PoolMaintenanceFees;\n\n/**\n * Read a pool's maintenance-sale history from the configured listing service.\n * @param config - SDK configuration.\n * @param parameters - Token identity and request parameters.\n * @returns The normalized service result.\n * @example\n * await getPoolMaintenanceFees(config, { chainId: 42161, depositChain: 0, tokenContractAddress: mint });\n */\nexport async function getPoolMaintenanceFees(\n config: Config,\n parameters: GetPoolMaintenanceFeesParameters,\n): Promise<GetPoolMaintenanceFeesReturnType> {\n const { url: baseURL } = resolveListingService(config, { chainId: parameters.chainId });\n try {\n const { data } = await getMaintenanceFeeRecordsV2MarketMaintenanceFeesGet(\n {\n market_address: parameters.tokenContractAddress,\n chain_id: parameters.depositChain,\n limit: parameters.limit,\n offset: parameters.offset,\n },\n { baseURL },\n );\n return {\n total: data.total,\n items: data.items.map((row) => ({\n tokenAmount: toListingValue(row.token_amount) ?? 0n,\n usdcAmount: toListingValue(row.usdc_amount) ?? 0n,\n timestamp: row.timestamp / 1000,\n transactionHash: row.tx_hash ?? null,\n })),\n };\n } catch (error) {\n if (error instanceof SymmError) throw error;\n if (isAxiosError(error)) throw SymmApiError.fromAxios(error, { code: \"GET_POOL_MAINTENANCE_FEES_FAILED\", baseURL });\n throw new SymmError(\"api\", \"GET_POOL_MAINTENANCE_FEES_FAILED\", \"Listing request failed\", { cause: error });\n }\n}\n"],"mappings":";;;;;;AA0CA,eAAsB,EACpB,GACA,GAC2C;CAC3C,IAAM,EAAE,KAAK,MAAY,EAAsB,GAAQ,EAAE,SAAS,EAAW,QAAQ,CAAC;CACtF,IAAI;EACF,IAAM,EAAE,YAAS,MAAM,EACrB;GACE,gBAAgB,EAAW;GAC3B,UAAU,EAAW;GACrB,OAAO,EAAW;GAClB,QAAQ,EAAW;EACrB,GACA,EAAE,WAAQ,CACZ;EACA,OAAO;GACL,OAAO,EAAK;GACZ,OAAO,EAAK,MAAM,KAAK,OAAS;IAC9B,aAAa,EAAe,EAAI,YAAY,KAAK;IACjD,YAAY,EAAe,EAAI,WAAW,KAAK;IAC/C,WAAW,EAAI,YAAY;IAC3B,iBAAiB,EAAI,WAAW;GAClC,EAAE;EACJ;CACF,SAAS,GAAO;EAGd,MAFI,aAAiB,IAAiB,IAClC,EAAa,CAAK,IAAS,EAAa,UAAU,GAAO;GAAE,MAAM;GAAoC;EAAQ,CAAC,IAC5G,IAAI,EAAU,OAAO,oCAAoC,0BAA0B,EAAE,OAAO,EAAM,CAAC;CAC3G;AACF"}
|