@nadohq/client 0.1.0-alpha.1
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/README.md +3 -0
- package/dist/apis/base.cjs +66 -0
- package/dist/apis/base.cjs.map +1 -0
- package/dist/apis/base.d.cts +23 -0
- package/dist/apis/base.d.ts +23 -0
- package/dist/apis/base.js +41 -0
- package/dist/apis/base.js.map +1 -0
- package/dist/apis/market/MarketExecuteAPI.cjs +169 -0
- package/dist/apis/market/MarketExecuteAPI.cjs.map +1 -0
- package/dist/apis/market/MarketExecuteAPI.d.cts +57 -0
- package/dist/apis/market/MarketExecuteAPI.d.ts +57 -0
- package/dist/apis/market/MarketExecuteAPI.js +144 -0
- package/dist/apis/market/MarketExecuteAPI.js.map +1 -0
- package/dist/apis/market/MarketQueryAPI.cjs +191 -0
- package/dist/apis/market/MarketQueryAPI.cjs.map +1 -0
- package/dist/apis/market/MarketQueryAPI.d.cts +127 -0
- package/dist/apis/market/MarketQueryAPI.d.ts +127 -0
- package/dist/apis/market/MarketQueryAPI.js +166 -0
- package/dist/apis/market/MarketQueryAPI.js.map +1 -0
- package/dist/apis/market/index.cjs +38 -0
- package/dist/apis/market/index.cjs.map +1 -0
- package/dist/apis/market/index.d.cts +18 -0
- package/dist/apis/market/index.d.ts +18 -0
- package/dist/apis/market/index.js +11 -0
- package/dist/apis/market/index.js.map +1 -0
- package/dist/apis/market/types.cjs +19 -0
- package/dist/apis/market/types.cjs.map +1 -0
- package/dist/apis/market/types.d.cts +26 -0
- package/dist/apis/market/types.d.ts +26 -0
- package/dist/apis/market/types.js +1 -0
- package/dist/apis/market/types.js.map +1 -0
- package/dist/apis/perp/PerpExecuteAPI.cjs +36 -0
- package/dist/apis/perp/PerpExecuteAPI.cjs.map +1 -0
- package/dist/apis/perp/PerpExecuteAPI.d.cts +13 -0
- package/dist/apis/perp/PerpExecuteAPI.d.ts +13 -0
- package/dist/apis/perp/PerpExecuteAPI.js +11 -0
- package/dist/apis/perp/PerpExecuteAPI.js.map +1 -0
- package/dist/apis/perp/PerpQueryAPI.cjs +47 -0
- package/dist/apis/perp/PerpQueryAPI.cjs.map +1 -0
- package/dist/apis/perp/PerpQueryAPI.d.cts +23 -0
- package/dist/apis/perp/PerpQueryAPI.d.ts +23 -0
- package/dist/apis/perp/PerpQueryAPI.js +22 -0
- package/dist/apis/perp/PerpQueryAPI.js.map +1 -0
- package/dist/apis/perp/index.cjs +35 -0
- package/dist/apis/perp/index.cjs.map +1 -0
- package/dist/apis/perp/index.d.cts +16 -0
- package/dist/apis/perp/index.d.ts +16 -0
- package/dist/apis/perp/index.js +10 -0
- package/dist/apis/perp/index.js.map +1 -0
- package/dist/apis/spot/BaseSpotAPI.cjs +55 -0
- package/dist/apis/spot/BaseSpotAPI.cjs.map +1 -0
- package/dist/apis/spot/BaseSpotAPI.d.cts +19 -0
- package/dist/apis/spot/BaseSpotAPI.d.ts +19 -0
- package/dist/apis/spot/BaseSpotAPI.js +30 -0
- package/dist/apis/spot/BaseSpotAPI.js.map +1 -0
- package/dist/apis/spot/SpotExecuteAPI.cjs +108 -0
- package/dist/apis/spot/SpotExecuteAPI.cjs.map +1 -0
- package/dist/apis/spot/SpotExecuteAPI.d.cts +28 -0
- package/dist/apis/spot/SpotExecuteAPI.d.ts +28 -0
- package/dist/apis/spot/SpotExecuteAPI.js +88 -0
- package/dist/apis/spot/SpotExecuteAPI.js.map +1 -0
- package/dist/apis/spot/SpotQueryAPI.cjs +74 -0
- package/dist/apis/spot/SpotQueryAPI.cjs.map +1 -0
- package/dist/apis/spot/SpotQueryAPI.d.cts +35 -0
- package/dist/apis/spot/SpotQueryAPI.d.ts +35 -0
- package/dist/apis/spot/SpotQueryAPI.js +49 -0
- package/dist/apis/spot/SpotQueryAPI.js.map +1 -0
- package/dist/apis/spot/index.cjs +38 -0
- package/dist/apis/spot/index.cjs.map +1 -0
- package/dist/apis/spot/index.d.cts +23 -0
- package/dist/apis/spot/index.d.ts +23 -0
- package/dist/apis/spot/index.js +11 -0
- package/dist/apis/spot/index.js.map +1 -0
- package/dist/apis/spot/types.cjs +19 -0
- package/dist/apis/spot/types.cjs.map +1 -0
- package/dist/apis/spot/types.d.cts +23 -0
- package/dist/apis/spot/types.d.ts +23 -0
- package/dist/apis/spot/types.js +1 -0
- package/dist/apis/spot/types.js.map +1 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs +59 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs.map +1 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.cts +26 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.ts +26 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.js +34 -0
- package/dist/apis/subaccount/SubaccountExecuteAPI.js.map +1 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs +84 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs.map +1 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.d.cts +51 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.d.ts +51 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.js +61 -0
- package/dist/apis/subaccount/SubaccountQueryAPI.js.map +1 -0
- package/dist/apis/subaccount/index.cjs +68 -0
- package/dist/apis/subaccount/index.cjs.map +1 -0
- package/dist/apis/subaccount/index.d.cts +27 -0
- package/dist/apis/subaccount/index.d.ts +27 -0
- package/dist/apis/subaccount/index.js +41 -0
- package/dist/apis/subaccount/index.js.map +1 -0
- package/dist/apis/subaccount/types.cjs +19 -0
- package/dist/apis/subaccount/types.cjs.map +1 -0
- package/dist/apis/subaccount/types.d.cts +9 -0
- package/dist/apis/subaccount/types.d.ts +9 -0
- package/dist/apis/subaccount/types.js +1 -0
- package/dist/apis/subaccount/types.js.map +1 -0
- package/dist/apis/types.cjs +19 -0
- package/dist/apis/types.cjs.map +1 -0
- package/dist/apis/types.d.cts +9 -0
- package/dist/apis/types.d.ts +9 -0
- package/dist/apis/types.js +1 -0
- package/dist/apis/types.js.map +1 -0
- package/dist/apis/ws/WebSocketExecuteAPI.cjs +73 -0
- package/dist/apis/ws/WebSocketExecuteAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketExecuteAPI.d.cts +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.d.ts +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.js +48 -0
- package/dist/apis/ws/WebSocketExecuteAPI.js.map +1 -0
- package/dist/apis/ws/WebSocketQueryAPI.cjs +42 -0
- package/dist/apis/ws/WebSocketQueryAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketQueryAPI.d.cts +23 -0
- package/dist/apis/ws/WebSocketQueryAPI.d.ts +23 -0
- package/dist/apis/ws/WebSocketQueryAPI.js +17 -0
- package/dist/apis/ws/WebSocketQueryAPI.js.map +1 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs +61 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs.map +1 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.cts +37 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.ts +37 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.js +36 -0
- package/dist/apis/ws/WebSocketSubscriptionAPI.js.map +1 -0
- package/dist/apis/ws/index.cjs +42 -0
- package/dist/apis/ws/index.cjs.map +1 -0
- package/dist/apis/ws/index.d.cts +22 -0
- package/dist/apis/ws/index.d.ts +22 -0
- package/dist/apis/ws/index.js +17 -0
- package/dist/apis/ws/index.js.map +1 -0
- package/dist/client.cjs +79 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +57 -0
- package/dist/client.d.ts +57 -0
- package/dist/client.js +54 -0
- package/dist/client.js.map +1 -0
- package/dist/context.cjs +125 -0
- package/dist/context.cjs.map +1 -0
- package/dist/context.d.cts +42 -0
- package/dist/context.d.ts +42 -0
- package/dist/context.js +109 -0
- package/dist/context.js.map +1 -0
- package/dist/createNadoClient.cjs +35 -0
- package/dist/createNadoClient.cjs.map +1 -0
- package/dist/createNadoClient.d.cts +42 -0
- package/dist/createNadoClient.d.ts +42 -0
- package/dist/createNadoClient.js +12 -0
- package/dist/createNadoClient.js.map +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
- package/src/apis/base.ts +52 -0
- package/src/apis/market/MarketExecuteAPI.ts +169 -0
- package/src/apis/market/MarketQueryAPI.ts +214 -0
- package/src/apis/market/index.ts +7 -0
- package/src/apis/market/types.ts +58 -0
- package/src/apis/perp/PerpExecuteAPI.ts +8 -0
- package/src/apis/perp/PerpQueryAPI.ts +25 -0
- package/src/apis/perp/index.ts +5 -0
- package/src/apis/spot/BaseSpotAPI.ts +30 -0
- package/src/apis/spot/SpotExecuteAPI.ts +102 -0
- package/src/apis/spot/SpotQueryAPI.ts +53 -0
- package/src/apis/spot/index.ts +10 -0
- package/src/apis/spot/types.ts +44 -0
- package/src/apis/subaccount/SubaccountExecuteAPI.ts +32 -0
- package/src/apis/subaccount/SubaccountQueryAPI.ts +78 -0
- package/src/apis/subaccount/index.ts +44 -0
- package/src/apis/subaccount/types.ts +16 -0
- package/src/apis/types.ts +11 -0
- package/src/apis/ws/WebSocketExecuteAPI.ts +70 -0
- package/src/apis/ws/WebSocketQueryAPI.ts +25 -0
- package/src/apis/ws/WebSocketSubscriptionAPI.ts +62 -0
- package/src/apis/ws/index.ts +21 -0
- package/src/client.ts +67 -0
- package/src/context.ts +165 -0
- package/src/createNadoClient.ts +20 -0
- package/src/index.ts +15 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EngineWithdrawCollateralParams, EngineTransferQuoteParams, EngineMintVlpParams, EngineBurnVlpParams } from '@nadohq/engine-client';
|
|
2
|
+
import { BigDecimalish } from '@nadohq/utils';
|
|
3
|
+
import { OptionalSignatureParams, OptionalSubaccountOwner } from '../types.js';
|
|
4
|
+
|
|
5
|
+
type ProductIdOrTokenAddress = {
|
|
6
|
+
productId: number;
|
|
7
|
+
} | {
|
|
8
|
+
tokenAddress: string;
|
|
9
|
+
};
|
|
10
|
+
type TokenQueryParams = {
|
|
11
|
+
address: string;
|
|
12
|
+
} & ProductIdOrTokenAddress;
|
|
13
|
+
type ApproveAllowanceParams = ProductIdOrTokenAddress & {
|
|
14
|
+
amount: BigDecimalish;
|
|
15
|
+
};
|
|
16
|
+
type GetTokenWalletBalanceParams = TokenQueryParams;
|
|
17
|
+
type GetTokenAllowanceParams = TokenQueryParams;
|
|
18
|
+
type WithdrawCollateralParams = OptionalSignatureParams<OptionalSubaccountOwner<EngineWithdrawCollateralParams>>;
|
|
19
|
+
type TransferQuoteParams = OptionalSignatureParams<OptionalSubaccountOwner<EngineTransferQuoteParams>>;
|
|
20
|
+
type MintVlpParams = OptionalSignatureParams<OptionalSubaccountOwner<EngineMintVlpParams>>;
|
|
21
|
+
type BurnVlpParams = OptionalSignatureParams<OptionalSubaccountOwner<EngineBurnVlpParams>>;
|
|
22
|
+
|
|
23
|
+
export type { ApproveAllowanceParams, BurnVlpParams, GetTokenAllowanceParams, GetTokenWalletBalanceParams, MintVlpParams, ProductIdOrTokenAddress, TransferQuoteParams, WithdrawCollateralParams };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/apis/subaccount/SubaccountExecuteAPI.ts
|
|
21
|
+
var SubaccountExecuteAPI_exports = {};
|
|
22
|
+
__export(SubaccountExecuteAPI_exports, {
|
|
23
|
+
SubaccountExecuteAPI: () => SubaccountExecuteAPI
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(SubaccountExecuteAPI_exports);
|
|
26
|
+
var import_base = require("../base.cjs");
|
|
27
|
+
var SubaccountExecuteAPI = class extends import_base.BaseNadoAPI {
|
|
28
|
+
/**
|
|
29
|
+
* Liquidates a subaccount
|
|
30
|
+
*
|
|
31
|
+
* @param params
|
|
32
|
+
*/
|
|
33
|
+
async liquidateSubaccount(params) {
|
|
34
|
+
return this.context.engineClient.liquidateSubaccount({
|
|
35
|
+
...params,
|
|
36
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
37
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
38
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount
|
|
43
|
+
*
|
|
44
|
+
* @param params
|
|
45
|
+
*/
|
|
46
|
+
async linkSigner(params) {
|
|
47
|
+
return this.context.engineClient.linkSigner({
|
|
48
|
+
...params,
|
|
49
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
50
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
51
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
SubaccountExecuteAPI
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=SubaccountExecuteAPI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/SubaccountExecuteAPI.ts"],"sourcesContent":["import { BaseNadoAPI } from '../base';\nimport { LinkSignerParams, LiquidateSubaccountParams } from './types';\n\nexport class SubaccountExecuteAPI extends BaseNadoAPI {\n /**\n * Liquidates a subaccount\n *\n * @param params\n */\n async liquidateSubaccount(params: LiquidateSubaccountParams) {\n return this.context.engineClient.liquidateSubaccount({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n /**\n * Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount\n *\n * @param params\n */\n async linkSigner(params: LinkSignerParams) {\n return this.context.engineClient.linkSigner({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAGrB,IAAM,uBAAN,cAAmC,wBAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpD,MAAM,oBAAoB,QAAmC;AAC3D,WAAO,KAAK,QAAQ,aAAa,oBAAoB;AAAA,MACnD,GAAG;AAAA,MACH,iBAAiB,KAAK,2BAA2B,MAAM;AAAA,MACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;AAAA,MAC/D,SAAS,KAAK,+BAA+B,MAAM;AAAA,IACrD,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,WAAW,QAA0B;AACzC,WAAO,KAAK,QAAQ,aAAa,WAAW;AAAA,MAC1C,GAAG;AAAA,MACH,iBAAiB,KAAK,2BAA2B,MAAM;AAAA,MACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;AAAA,MAC/D,SAAS,KAAK,+BAA+B,MAAM;AAAA,IACrD,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _nadohq_engine_client from '@nadohq/engine-client';
|
|
2
|
+
import { BaseNadoAPI } from '../base.cjs';
|
|
3
|
+
import { LiquidateSubaccountParams, LinkSignerParams } from './types.cjs';
|
|
4
|
+
import '@nadohq/contracts';
|
|
5
|
+
import '../../context.cjs';
|
|
6
|
+
import '@nadohq/indexer-client';
|
|
7
|
+
import '@nadohq/trigger-client';
|
|
8
|
+
import 'viem';
|
|
9
|
+
import '../types.cjs';
|
|
10
|
+
|
|
11
|
+
declare class SubaccountExecuteAPI extends BaseNadoAPI {
|
|
12
|
+
/**
|
|
13
|
+
* Liquidates a subaccount
|
|
14
|
+
*
|
|
15
|
+
* @param params
|
|
16
|
+
*/
|
|
17
|
+
liquidateSubaccount(params: LiquidateSubaccountParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"liquidate_subaccount">>;
|
|
18
|
+
/**
|
|
19
|
+
* Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount
|
|
20
|
+
*
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
linkSigner(params: LinkSignerParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"link_signer">>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { SubaccountExecuteAPI };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as _nadohq_engine_client from '@nadohq/engine-client';
|
|
2
|
+
import { BaseNadoAPI } from '../base.js';
|
|
3
|
+
import { LiquidateSubaccountParams, LinkSignerParams } from './types.js';
|
|
4
|
+
import '@nadohq/contracts';
|
|
5
|
+
import '../../context.js';
|
|
6
|
+
import '@nadohq/indexer-client';
|
|
7
|
+
import '@nadohq/trigger-client';
|
|
8
|
+
import 'viem';
|
|
9
|
+
import '../types.js';
|
|
10
|
+
|
|
11
|
+
declare class SubaccountExecuteAPI extends BaseNadoAPI {
|
|
12
|
+
/**
|
|
13
|
+
* Liquidates a subaccount
|
|
14
|
+
*
|
|
15
|
+
* @param params
|
|
16
|
+
*/
|
|
17
|
+
liquidateSubaccount(params: LiquidateSubaccountParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"liquidate_subaccount">>;
|
|
18
|
+
/**
|
|
19
|
+
* Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount
|
|
20
|
+
*
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
linkSigner(params: LinkSignerParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"link_signer">>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { SubaccountExecuteAPI };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// src/apis/subaccount/SubaccountExecuteAPI.ts
|
|
2
|
+
import { BaseNadoAPI } from "../base.js";
|
|
3
|
+
var SubaccountExecuteAPI = class extends BaseNadoAPI {
|
|
4
|
+
/**
|
|
5
|
+
* Liquidates a subaccount
|
|
6
|
+
*
|
|
7
|
+
* @param params
|
|
8
|
+
*/
|
|
9
|
+
async liquidateSubaccount(params) {
|
|
10
|
+
return this.context.engineClient.liquidateSubaccount({
|
|
11
|
+
...params,
|
|
12
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
13
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
14
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount
|
|
19
|
+
*
|
|
20
|
+
* @param params
|
|
21
|
+
*/
|
|
22
|
+
async linkSigner(params) {
|
|
23
|
+
return this.context.engineClient.linkSigner({
|
|
24
|
+
...params,
|
|
25
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
26
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
27
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
SubaccountExecuteAPI
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=SubaccountExecuteAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/SubaccountExecuteAPI.ts"],"sourcesContent":["import { BaseNadoAPI } from '../base';\nimport { LinkSignerParams, LiquidateSubaccountParams } from './types';\n\nexport class SubaccountExecuteAPI extends BaseNadoAPI {\n /**\n * Liquidates a subaccount\n *\n * @param params\n */\n async liquidateSubaccount(params: LiquidateSubaccountParams) {\n return this.context.engineClient.liquidateSubaccount({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n /**\n * Links a signer to a subaccount to allow them to sign transactions on behalf of the subaccount\n *\n * @param params\n */\n async linkSigner(params: LinkSignerParams) {\n return this.context.engineClient.linkSigner({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n}\n"],"mappings":";AAAA,SAAS,mBAAmB;AAGrB,IAAM,uBAAN,cAAmC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpD,MAAM,oBAAoB,QAAmC;AAC3D,WAAO,KAAK,QAAQ,aAAa,oBAAoB;AAAA,MACnD,GAAG;AAAA,MACH,iBAAiB,KAAK,2BAA2B,MAAM;AAAA,MACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;AAAA,MAC/D,SAAS,KAAK,+BAA+B,MAAM;AAAA,IACrD,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,WAAW,QAA0B;AACzC,WAAO,KAAK,QAAQ,aAAa,WAAW;AAAA,MAC1C,GAAG;AAAA,MACH,iBAAiB,KAAK,2BAA2B,MAAM;AAAA,MACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;AAAA,MAC/D,SAAS,KAAK,+BAA+B,MAAM;AAAA,IACrD,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/apis/subaccount/SubaccountQueryAPI.ts
|
|
21
|
+
var SubaccountQueryAPI_exports = {};
|
|
22
|
+
__export(SubaccountQueryAPI_exports, {
|
|
23
|
+
SubaccountQueryAPI: () => SubaccountQueryAPI
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(SubaccountQueryAPI_exports);
|
|
26
|
+
var import_contracts = require("@nadohq/contracts");
|
|
27
|
+
var import_base = require("../base.cjs");
|
|
28
|
+
var SubaccountQueryAPI = class extends import_base.BaseNadoAPI {
|
|
29
|
+
/**
|
|
30
|
+
* Returns a comprehensive summary for a subaaccount, including its balances and health
|
|
31
|
+
*
|
|
32
|
+
* @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}
|
|
33
|
+
*/
|
|
34
|
+
async getSubaccountSummary(params) {
|
|
35
|
+
return (0, import_contracts.getSubaccountSummary)(this.paramsWithContracts(params));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the subaccount state according to the offchain engine
|
|
39
|
+
* @param params
|
|
40
|
+
*/
|
|
41
|
+
async getEngineSubaccountSummary(params) {
|
|
42
|
+
return this.context.engineClient.getSubaccountSummary(params);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the estimated subaccount state from offchain engine after a series of proposed txs
|
|
46
|
+
* @param params
|
|
47
|
+
*/
|
|
48
|
+
async getEngineEstimatedSubaccountSummary(params) {
|
|
49
|
+
return this.context.engineClient.getEstimatedSubaccountSummary(params);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Gets the isolated positions for a subaccount
|
|
53
|
+
* @param params
|
|
54
|
+
*/
|
|
55
|
+
async getIsolatedPositions(params) {
|
|
56
|
+
return this.context.engineClient.getIsolatedPositions(params);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Queries engine to get subaccount fee rates
|
|
60
|
+
* @param params
|
|
61
|
+
*/
|
|
62
|
+
async getSubaccountFeeRates(params) {
|
|
63
|
+
return this.context.engineClient.getSubaccountFeeRates(params);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves the current signer and link signer rate limit from the indexer
|
|
67
|
+
* @param params
|
|
68
|
+
*/
|
|
69
|
+
async getSubaccountLinkedSignerWithRateLimit(params) {
|
|
70
|
+
return this.context.indexerClient.getLinkedSignerWithRateLimit(params);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves referral code for an address
|
|
74
|
+
* @param params
|
|
75
|
+
*/
|
|
76
|
+
async getReferralCode(params) {
|
|
77
|
+
return this.context.indexerClient.getReferralCode(params);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
SubaccountQueryAPI
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=SubaccountQueryAPI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/SubaccountQueryAPI.ts"],"sourcesContent":["import {\n getSubaccountSummary,\n GetSubaccountSummaryParams,\n} from '@nadohq/contracts';\nimport {\n GetEngineEstimatedSubaccountSummaryParams,\n GetEngineIsolatedPositionsParams,\n GetEngineSubaccountFeeRatesParams,\n GetEngineSubaccountSummaryParams,\n} from '@nadohq/engine-client';\nimport {\n GetIndexerLinkedSignerParams,\n GetIndexerReferralCodeParams,\n} from '@nadohq/indexer-client';\nimport { BaseNadoAPI } from '../base';\n\nexport class SubaccountQueryAPI extends BaseNadoAPI {\n /**\n * Returns a comprehensive summary for a subaaccount, including its balances and health\n *\n * @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}\n */\n async getSubaccountSummary(params: GetSubaccountSummaryParams) {\n return getSubaccountSummary(this.paramsWithContracts(params));\n }\n\n /**\n * Gets the subaccount state according to the offchain engine\n * @param params\n */\n async getEngineSubaccountSummary(params: GetEngineSubaccountSummaryParams) {\n return this.context.engineClient.getSubaccountSummary(params);\n }\n\n /**\n * Gets the estimated subaccount state from offchain engine after a series of proposed txs\n * @param params\n */\n async getEngineEstimatedSubaccountSummary(\n params: GetEngineEstimatedSubaccountSummaryParams,\n ) {\n return this.context.engineClient.getEstimatedSubaccountSummary(params);\n }\n\n /**\n * Gets the isolated positions for a subaccount\n * @param params\n */\n async getIsolatedPositions(params: GetEngineIsolatedPositionsParams) {\n return this.context.engineClient.getIsolatedPositions(params);\n }\n\n /**\n * Queries engine to get subaccount fee rates\n * @param params\n */\n async getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams) {\n return this.context.engineClient.getSubaccountFeeRates(params);\n }\n\n /**\n * Retrieves the current signer and link signer rate limit from the indexer\n * @param params\n */\n async getSubaccountLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ) {\n return this.context.indexerClient.getLinkedSignerWithRateLimit(params);\n }\n\n /**\n * Retrieves referral code for an address\n * @param params\n */\n async getReferralCode(params: GetIndexerReferralCodeParams) {\n return this.context.indexerClient.getReferralCode(params);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAGO;AAWP,kBAA4B;AAErB,IAAM,qBAAN,cAAiC,wBAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlD,MAAM,qBAAqB,QAAoC;AAC7D,eAAO,uCAAqB,KAAK,oBAAoB,MAAM,CAAC;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,2BAA2B,QAA0C;AACzE,WAAO,KAAK,QAAQ,aAAa,qBAAqB,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,oCACJ,QACA;AACA,WAAO,KAAK,QAAQ,aAAa,8BAA8B,MAAM;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,qBAAqB,QAA0C;AACnE,WAAO,KAAK,QAAQ,aAAa,qBAAqB,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,sBAAsB,QAA2C;AACrE,WAAO,KAAK,QAAQ,aAAa,sBAAsB,MAAM;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,uCACJ,QACA;AACA,WAAO,KAAK,QAAQ,cAAc,6BAA6B,MAAM;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,gBAAgB,QAAsC;AAC1D,WAAO,KAAK,QAAQ,cAAc,gBAAgB,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _nadohq_indexer_client from '@nadohq/indexer-client';
|
|
2
|
+
import { GetIndexerLinkedSignerParams, GetIndexerReferralCodeParams } from '@nadohq/indexer-client';
|
|
3
|
+
import * as _nadohq_engine_client from '@nadohq/engine-client';
|
|
4
|
+
import { GetEngineSubaccountSummaryParams, GetEngineEstimatedSubaccountSummaryParams, GetEngineIsolatedPositionsParams, GetEngineSubaccountFeeRatesParams } from '@nadohq/engine-client';
|
|
5
|
+
import * as _nadohq_contracts from '@nadohq/contracts';
|
|
6
|
+
import { GetSubaccountSummaryParams } from '@nadohq/contracts';
|
|
7
|
+
import { BaseNadoAPI } from '../base.cjs';
|
|
8
|
+
import '../../context.cjs';
|
|
9
|
+
import '@nadohq/trigger-client';
|
|
10
|
+
import 'viem';
|
|
11
|
+
|
|
12
|
+
declare class SubaccountQueryAPI extends BaseNadoAPI {
|
|
13
|
+
/**
|
|
14
|
+
* Returns a comprehensive summary for a subaaccount, including its balances and health
|
|
15
|
+
*
|
|
16
|
+
* @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}
|
|
17
|
+
*/
|
|
18
|
+
getSubaccountSummary(params: GetSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the subaccount state according to the offchain engine
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
getEngineSubaccountSummary(params: GetEngineSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the estimated subaccount state from offchain engine after a series of proposed txs
|
|
26
|
+
* @param params
|
|
27
|
+
*/
|
|
28
|
+
getEngineEstimatedSubaccountSummary(params: GetEngineEstimatedSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the isolated positions for a subaccount
|
|
31
|
+
* @param params
|
|
32
|
+
*/
|
|
33
|
+
getIsolatedPositions(params: GetEngineIsolatedPositionsParams): Promise<_nadohq_engine_client.GetEngineIsolatedPositionsResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Queries engine to get subaccount fee rates
|
|
36
|
+
* @param params
|
|
37
|
+
*/
|
|
38
|
+
getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams): Promise<_nadohq_engine_client.GetEngineSubaccountFeeRatesResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the current signer and link signer rate limit from the indexer
|
|
41
|
+
* @param params
|
|
42
|
+
*/
|
|
43
|
+
getSubaccountLinkedSignerWithRateLimit(params: GetIndexerLinkedSignerParams): Promise<_nadohq_indexer_client.GetIndexerLinkedSignerResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves referral code for an address
|
|
46
|
+
* @param params
|
|
47
|
+
*/
|
|
48
|
+
getReferralCode(params: GetIndexerReferralCodeParams): Promise<_nadohq_indexer_client.GetIndexerReferralCodeResponse>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { SubaccountQueryAPI };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _nadohq_indexer_client from '@nadohq/indexer-client';
|
|
2
|
+
import { GetIndexerLinkedSignerParams, GetIndexerReferralCodeParams } from '@nadohq/indexer-client';
|
|
3
|
+
import * as _nadohq_engine_client from '@nadohq/engine-client';
|
|
4
|
+
import { GetEngineSubaccountSummaryParams, GetEngineEstimatedSubaccountSummaryParams, GetEngineIsolatedPositionsParams, GetEngineSubaccountFeeRatesParams } from '@nadohq/engine-client';
|
|
5
|
+
import * as _nadohq_contracts from '@nadohq/contracts';
|
|
6
|
+
import { GetSubaccountSummaryParams } from '@nadohq/contracts';
|
|
7
|
+
import { BaseNadoAPI } from '../base.js';
|
|
8
|
+
import '../../context.js';
|
|
9
|
+
import '@nadohq/trigger-client';
|
|
10
|
+
import 'viem';
|
|
11
|
+
|
|
12
|
+
declare class SubaccountQueryAPI extends BaseNadoAPI {
|
|
13
|
+
/**
|
|
14
|
+
* Returns a comprehensive summary for a subaaccount, including its balances and health
|
|
15
|
+
*
|
|
16
|
+
* @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}
|
|
17
|
+
*/
|
|
18
|
+
getSubaccountSummary(params: GetSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the subaccount state according to the offchain engine
|
|
21
|
+
* @param params
|
|
22
|
+
*/
|
|
23
|
+
getEngineSubaccountSummary(params: GetEngineSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Gets the estimated subaccount state from offchain engine after a series of proposed txs
|
|
26
|
+
* @param params
|
|
27
|
+
*/
|
|
28
|
+
getEngineEstimatedSubaccountSummary(params: GetEngineEstimatedSubaccountSummaryParams): Promise<_nadohq_contracts.SubaccountSummaryResponse>;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the isolated positions for a subaccount
|
|
31
|
+
* @param params
|
|
32
|
+
*/
|
|
33
|
+
getIsolatedPositions(params: GetEngineIsolatedPositionsParams): Promise<_nadohq_engine_client.GetEngineIsolatedPositionsResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Queries engine to get subaccount fee rates
|
|
36
|
+
* @param params
|
|
37
|
+
*/
|
|
38
|
+
getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams): Promise<_nadohq_engine_client.GetEngineSubaccountFeeRatesResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the current signer and link signer rate limit from the indexer
|
|
41
|
+
* @param params
|
|
42
|
+
*/
|
|
43
|
+
getSubaccountLinkedSignerWithRateLimit(params: GetIndexerLinkedSignerParams): Promise<_nadohq_indexer_client.GetIndexerLinkedSignerResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves referral code for an address
|
|
46
|
+
* @param params
|
|
47
|
+
*/
|
|
48
|
+
getReferralCode(params: GetIndexerReferralCodeParams): Promise<_nadohq_indexer_client.GetIndexerReferralCodeResponse>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { SubaccountQueryAPI };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// src/apis/subaccount/SubaccountQueryAPI.ts
|
|
2
|
+
import {
|
|
3
|
+
getSubaccountSummary
|
|
4
|
+
} from "@nadohq/contracts";
|
|
5
|
+
import { BaseNadoAPI } from "../base.js";
|
|
6
|
+
var SubaccountQueryAPI = class extends BaseNadoAPI {
|
|
7
|
+
/**
|
|
8
|
+
* Returns a comprehensive summary for a subaaccount, including its balances and health
|
|
9
|
+
*
|
|
10
|
+
* @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}
|
|
11
|
+
*/
|
|
12
|
+
async getSubaccountSummary(params) {
|
|
13
|
+
return getSubaccountSummary(this.paramsWithContracts(params));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Gets the subaccount state according to the offchain engine
|
|
17
|
+
* @param params
|
|
18
|
+
*/
|
|
19
|
+
async getEngineSubaccountSummary(params) {
|
|
20
|
+
return this.context.engineClient.getSubaccountSummary(params);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the estimated subaccount state from offchain engine after a series of proposed txs
|
|
24
|
+
* @param params
|
|
25
|
+
*/
|
|
26
|
+
async getEngineEstimatedSubaccountSummary(params) {
|
|
27
|
+
return this.context.engineClient.getEstimatedSubaccountSummary(params);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Gets the isolated positions for a subaccount
|
|
31
|
+
* @param params
|
|
32
|
+
*/
|
|
33
|
+
async getIsolatedPositions(params) {
|
|
34
|
+
return this.context.engineClient.getIsolatedPositions(params);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Queries engine to get subaccount fee rates
|
|
38
|
+
* @param params
|
|
39
|
+
*/
|
|
40
|
+
async getSubaccountFeeRates(params) {
|
|
41
|
+
return this.context.engineClient.getSubaccountFeeRates(params);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the current signer and link signer rate limit from the indexer
|
|
45
|
+
* @param params
|
|
46
|
+
*/
|
|
47
|
+
async getSubaccountLinkedSignerWithRateLimit(params) {
|
|
48
|
+
return this.context.indexerClient.getLinkedSignerWithRateLimit(params);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Retrieves referral code for an address
|
|
52
|
+
* @param params
|
|
53
|
+
*/
|
|
54
|
+
async getReferralCode(params) {
|
|
55
|
+
return this.context.indexerClient.getReferralCode(params);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
export {
|
|
59
|
+
SubaccountQueryAPI
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=SubaccountQueryAPI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/SubaccountQueryAPI.ts"],"sourcesContent":["import {\n getSubaccountSummary,\n GetSubaccountSummaryParams,\n} from '@nadohq/contracts';\nimport {\n GetEngineEstimatedSubaccountSummaryParams,\n GetEngineIsolatedPositionsParams,\n GetEngineSubaccountFeeRatesParams,\n GetEngineSubaccountSummaryParams,\n} from '@nadohq/engine-client';\nimport {\n GetIndexerLinkedSignerParams,\n GetIndexerReferralCodeParams,\n} from '@nadohq/indexer-client';\nimport { BaseNadoAPI } from '../base';\n\nexport class SubaccountQueryAPI extends BaseNadoAPI {\n /**\n * Returns a comprehensive summary for a subaaccount, including its balances and health\n *\n * @see {@link getSubaccountSummary:CONTRACTS | getSubaccountSummary}\n */\n async getSubaccountSummary(params: GetSubaccountSummaryParams) {\n return getSubaccountSummary(this.paramsWithContracts(params));\n }\n\n /**\n * Gets the subaccount state according to the offchain engine\n * @param params\n */\n async getEngineSubaccountSummary(params: GetEngineSubaccountSummaryParams) {\n return this.context.engineClient.getSubaccountSummary(params);\n }\n\n /**\n * Gets the estimated subaccount state from offchain engine after a series of proposed txs\n * @param params\n */\n async getEngineEstimatedSubaccountSummary(\n params: GetEngineEstimatedSubaccountSummaryParams,\n ) {\n return this.context.engineClient.getEstimatedSubaccountSummary(params);\n }\n\n /**\n * Gets the isolated positions for a subaccount\n * @param params\n */\n async getIsolatedPositions(params: GetEngineIsolatedPositionsParams) {\n return this.context.engineClient.getIsolatedPositions(params);\n }\n\n /**\n * Queries engine to get subaccount fee rates\n * @param params\n */\n async getSubaccountFeeRates(params: GetEngineSubaccountFeeRatesParams) {\n return this.context.engineClient.getSubaccountFeeRates(params);\n }\n\n /**\n * Retrieves the current signer and link signer rate limit from the indexer\n * @param params\n */\n async getSubaccountLinkedSignerWithRateLimit(\n params: GetIndexerLinkedSignerParams,\n ) {\n return this.context.indexerClient.getLinkedSignerWithRateLimit(params);\n }\n\n /**\n * Retrieves referral code for an address\n * @param params\n */\n async getReferralCode(params: GetIndexerReferralCodeParams) {\n return this.context.indexerClient.getReferralCode(params);\n }\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAEK;AAWP,SAAS,mBAAmB;AAErB,IAAM,qBAAN,cAAiC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlD,MAAM,qBAAqB,QAAoC;AAC7D,WAAO,qBAAqB,KAAK,oBAAoB,MAAM,CAAC;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,2BAA2B,QAA0C;AACzE,WAAO,KAAK,QAAQ,aAAa,qBAAqB,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,oCACJ,QACA;AACA,WAAO,KAAK,QAAQ,aAAa,8BAA8B,MAAM;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,qBAAqB,QAA0C;AACnE,WAAO,KAAK,QAAQ,aAAa,qBAAqB,MAAM;AAAA,EAC9D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,sBAAsB,QAA2C;AACrE,WAAO,KAAK,QAAQ,aAAa,sBAAsB,MAAM;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,uCACJ,QACA;AACA,WAAO,KAAK,QAAQ,cAAc,6BAA6B,MAAM;AAAA,EACvE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,gBAAgB,QAAsC;AAC1D,WAAO,KAAK,QAAQ,cAAc,gBAAgB,MAAM;AAAA,EAC1D;AACF;","names":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/apis/subaccount/index.ts
|
|
22
|
+
var subaccount_exports = {};
|
|
23
|
+
__export(subaccount_exports, {
|
|
24
|
+
SubaccountAPI: () => SubaccountAPI
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(subaccount_exports);
|
|
27
|
+
var import_contracts = require("@nadohq/contracts");
|
|
28
|
+
var import_utils = require("@nadohq/utils");
|
|
29
|
+
var import_ts_mixer = require("ts-mixer");
|
|
30
|
+
var import_accounts = require("viem/accounts");
|
|
31
|
+
var import_SubaccountExecuteAPI = require("./SubaccountExecuteAPI.cjs");
|
|
32
|
+
var import_SubaccountQueryAPI = require("./SubaccountQueryAPI.cjs");
|
|
33
|
+
__reExport(subaccount_exports, require("./types.cjs"), module.exports);
|
|
34
|
+
var SubaccountAPI = class extends (0, import_ts_mixer.Mixin)(
|
|
35
|
+
import_SubaccountExecuteAPI.SubaccountExecuteAPI,
|
|
36
|
+
import_SubaccountQueryAPI.SubaccountQueryAPI
|
|
37
|
+
) {
|
|
38
|
+
/**
|
|
39
|
+
* Given the current context, create a "standard" link signer Account for the subaccount
|
|
40
|
+
* The "standard" linked signer private key is deterministically generated so that the frontend running on
|
|
41
|
+
* different clients can have a consistent private key for the subaccount linked signer.
|
|
42
|
+
*
|
|
43
|
+
* @param subaccountName
|
|
44
|
+
*/
|
|
45
|
+
async createStandardLinkedSigner(subaccountName) {
|
|
46
|
+
const walletClient = this.context.walletClient;
|
|
47
|
+
if (!walletClient) {
|
|
48
|
+
throw new import_utils.WalletNotProvidedError();
|
|
49
|
+
}
|
|
50
|
+
const privateKey = await (0, import_contracts.createDeterministicLinkedSignerPrivateKey)({
|
|
51
|
+
chainId: walletClient.chain.id,
|
|
52
|
+
endpointAddress: this.getEndpointAddress(),
|
|
53
|
+
walletClient,
|
|
54
|
+
subaccountName,
|
|
55
|
+
subaccountOwner: walletClient.account.address
|
|
56
|
+
});
|
|
57
|
+
return {
|
|
58
|
+
privateKey,
|
|
59
|
+
account: (0, import_accounts.privateKeyToAccount)(privateKey)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
SubaccountAPI,
|
|
66
|
+
...require("./types.cjs")
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/index.ts"],"sourcesContent":["import { createDeterministicLinkedSignerPrivateKey } from '@nadohq/contracts';\nimport { WalletNotProvidedError } from '@nadohq/utils';\nimport { Mixin } from 'ts-mixer';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { SubaccountExecuteAPI } from './SubaccountExecuteAPI';\nimport { SubaccountQueryAPI } from './SubaccountQueryAPI';\nimport { CreateStandardLinkedSignerResult } from './types';\n\nexport * from './types';\n\nexport class SubaccountAPI extends Mixin(\n SubaccountExecuteAPI,\n SubaccountQueryAPI,\n) {\n /**\n * Given the current context, create a \"standard\" link signer Account for the subaccount\n * The \"standard\" linked signer private key is deterministically generated so that the frontend running on\n * different clients can have a consistent private key for the subaccount linked signer.\n *\n * @param subaccountName\n */\n async createStandardLinkedSigner(\n subaccountName: string,\n ): Promise<CreateStandardLinkedSignerResult> {\n const walletClient = this.context.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const privateKey = await createDeterministicLinkedSignerPrivateKey({\n chainId: walletClient.chain.id,\n endpointAddress: this.getEndpointAddress(),\n walletClient,\n subaccountName,\n subaccountOwner: walletClient.account.address,\n });\n\n return {\n privateKey,\n account: privateKeyToAccount(privateKey),\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0D;AAC1D,mBAAuC;AACvC,sBAAsB;AACtB,sBAAoC;AACpC,kCAAqC;AACrC,gCAAmC;AAGnC,+BAAc,wBARd;AAUO,IAAM,gBAAN,kBAA4B;AAAA,EACjC;AAAA,EACA;AACF,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,2BACJ,gBAC2C;AAC3C,UAAM,eAAe,KAAK,QAAQ;AAElC,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,oCAAuB;AAAA,IACnC;AAEA,UAAM,aAAa,UAAM,4DAA0C;AAAA,MACjE,SAAS,aAAa,MAAM;AAAA,MAC5B,iBAAiB,KAAK,mBAAmB;AAAA,MACzC;AAAA,MACA;AAAA,MACA,iBAAiB,aAAa,QAAQ;AAAA,IACxC,CAAC;AAED,WAAO;AAAA,MACL;AAAA,MACA,aAAS,qCAAoB,UAAU;AAAA,IACzC;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as ts_mixer_dist_types_types from 'ts-mixer/dist/types/types';
|
|
2
|
+
import { SubaccountExecuteAPI } from './SubaccountExecuteAPI.cjs';
|
|
3
|
+
import { SubaccountQueryAPI } from './SubaccountQueryAPI.cjs';
|
|
4
|
+
import { CreateStandardLinkedSignerResult } from './types.cjs';
|
|
5
|
+
export { LinkSignerParams, LiquidateSubaccountParams } from './types.cjs';
|
|
6
|
+
import '@nadohq/engine-client';
|
|
7
|
+
import '../base.cjs';
|
|
8
|
+
import '@nadohq/contracts';
|
|
9
|
+
import '../../context.cjs';
|
|
10
|
+
import '@nadohq/indexer-client';
|
|
11
|
+
import '@nadohq/trigger-client';
|
|
12
|
+
import 'viem';
|
|
13
|
+
import '../types.cjs';
|
|
14
|
+
|
|
15
|
+
declare const SubaccountAPI_base: ts_mixer_dist_types_types.Class<any[], SubaccountExecuteAPI & SubaccountQueryAPI, typeof SubaccountExecuteAPI & typeof SubaccountQueryAPI>;
|
|
16
|
+
declare class SubaccountAPI extends SubaccountAPI_base {
|
|
17
|
+
/**
|
|
18
|
+
* Given the current context, create a "standard" link signer Account for the subaccount
|
|
19
|
+
* The "standard" linked signer private key is deterministically generated so that the frontend running on
|
|
20
|
+
* different clients can have a consistent private key for the subaccount linked signer.
|
|
21
|
+
*
|
|
22
|
+
* @param subaccountName
|
|
23
|
+
*/
|
|
24
|
+
createStandardLinkedSigner(subaccountName: string): Promise<CreateStandardLinkedSignerResult>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { CreateStandardLinkedSignerResult, SubaccountAPI };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as ts_mixer_dist_types_types from 'ts-mixer/dist/types/types';
|
|
2
|
+
import { SubaccountExecuteAPI } from './SubaccountExecuteAPI.js';
|
|
3
|
+
import { SubaccountQueryAPI } from './SubaccountQueryAPI.js';
|
|
4
|
+
import { CreateStandardLinkedSignerResult } from './types.js';
|
|
5
|
+
export { LinkSignerParams, LiquidateSubaccountParams } from './types.js';
|
|
6
|
+
import '@nadohq/engine-client';
|
|
7
|
+
import '../base.js';
|
|
8
|
+
import '@nadohq/contracts';
|
|
9
|
+
import '../../context.js';
|
|
10
|
+
import '@nadohq/indexer-client';
|
|
11
|
+
import '@nadohq/trigger-client';
|
|
12
|
+
import 'viem';
|
|
13
|
+
import '../types.js';
|
|
14
|
+
|
|
15
|
+
declare const SubaccountAPI_base: ts_mixer_dist_types_types.Class<any[], SubaccountExecuteAPI & SubaccountQueryAPI, typeof SubaccountExecuteAPI & typeof SubaccountQueryAPI>;
|
|
16
|
+
declare class SubaccountAPI extends SubaccountAPI_base {
|
|
17
|
+
/**
|
|
18
|
+
* Given the current context, create a "standard" link signer Account for the subaccount
|
|
19
|
+
* The "standard" linked signer private key is deterministically generated so that the frontend running on
|
|
20
|
+
* different clients can have a consistent private key for the subaccount linked signer.
|
|
21
|
+
*
|
|
22
|
+
* @param subaccountName
|
|
23
|
+
*/
|
|
24
|
+
createStandardLinkedSigner(subaccountName: string): Promise<CreateStandardLinkedSignerResult>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { CreateStandardLinkedSignerResult, SubaccountAPI };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// src/apis/subaccount/index.ts
|
|
2
|
+
import { createDeterministicLinkedSignerPrivateKey } from "@nadohq/contracts";
|
|
3
|
+
import { WalletNotProvidedError } from "@nadohq/utils";
|
|
4
|
+
import { Mixin } from "ts-mixer";
|
|
5
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
6
|
+
import { SubaccountExecuteAPI } from "./SubaccountExecuteAPI.js";
|
|
7
|
+
import { SubaccountQueryAPI } from "./SubaccountQueryAPI.js";
|
|
8
|
+
export * from "./types.js";
|
|
9
|
+
var SubaccountAPI = class extends Mixin(
|
|
10
|
+
SubaccountExecuteAPI,
|
|
11
|
+
SubaccountQueryAPI
|
|
12
|
+
) {
|
|
13
|
+
/**
|
|
14
|
+
* Given the current context, create a "standard" link signer Account for the subaccount
|
|
15
|
+
* The "standard" linked signer private key is deterministically generated so that the frontend running on
|
|
16
|
+
* different clients can have a consistent private key for the subaccount linked signer.
|
|
17
|
+
*
|
|
18
|
+
* @param subaccountName
|
|
19
|
+
*/
|
|
20
|
+
async createStandardLinkedSigner(subaccountName) {
|
|
21
|
+
const walletClient = this.context.walletClient;
|
|
22
|
+
if (!walletClient) {
|
|
23
|
+
throw new WalletNotProvidedError();
|
|
24
|
+
}
|
|
25
|
+
const privateKey = await createDeterministicLinkedSignerPrivateKey({
|
|
26
|
+
chainId: walletClient.chain.id,
|
|
27
|
+
endpointAddress: this.getEndpointAddress(),
|
|
28
|
+
walletClient,
|
|
29
|
+
subaccountName,
|
|
30
|
+
subaccountOwner: walletClient.account.address
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
privateKey,
|
|
34
|
+
account: privateKeyToAccount(privateKey)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
SubaccountAPI
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/apis/subaccount/index.ts"],"sourcesContent":["import { createDeterministicLinkedSignerPrivateKey } from '@nadohq/contracts';\nimport { WalletNotProvidedError } from '@nadohq/utils';\nimport { Mixin } from 'ts-mixer';\nimport { privateKeyToAccount } from 'viem/accounts';\nimport { SubaccountExecuteAPI } from './SubaccountExecuteAPI';\nimport { SubaccountQueryAPI } from './SubaccountQueryAPI';\nimport { CreateStandardLinkedSignerResult } from './types';\n\nexport * from './types';\n\nexport class SubaccountAPI extends Mixin(\n SubaccountExecuteAPI,\n SubaccountQueryAPI,\n) {\n /**\n * Given the current context, create a \"standard\" link signer Account for the subaccount\n * The \"standard\" linked signer private key is deterministically generated so that the frontend running on\n * different clients can have a consistent private key for the subaccount linked signer.\n *\n * @param subaccountName\n */\n async createStandardLinkedSigner(\n subaccountName: string,\n ): Promise<CreateStandardLinkedSignerResult> {\n const walletClient = this.context.walletClient;\n\n if (!walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const privateKey = await createDeterministicLinkedSignerPrivateKey({\n chainId: walletClient.chain.id,\n endpointAddress: this.getEndpointAddress(),\n walletClient,\n subaccountName,\n subaccountOwner: walletClient.account.address,\n });\n\n return {\n privateKey,\n account: privateKeyToAccount(privateKey),\n };\n }\n}\n"],"mappings":";AAAA,SAAS,iDAAiD;AAC1D,SAAS,8BAA8B;AACvC,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,0BAA0B;AAGnC,cAAc;AAEP,IAAM,gBAAN,cAA4B;AAAA,EACjC;AAAA,EACA;AACF,EAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,2BACJ,gBAC2C;AAC3C,UAAM,eAAe,KAAK,QAAQ;AAElC,QAAI,CAAC,cAAc;AACjB,YAAM,IAAI,uBAAuB;AAAA,IACnC;AAEA,UAAM,aAAa,MAAM,0CAA0C;AAAA,MACjE,SAAS,aAAa,MAAM;AAAA,MAC5B,iBAAiB,KAAK,mBAAmB;AAAA,MACzC;AAAA,MACA;AAAA,MACA,iBAAiB,aAAa,QAAQ;AAAA,IACxC,CAAC;AAED,WAAO;AAAA,MACL;AAAA,MACA,SAAS,oBAAoB,UAAU;AAAA,IACzC;AAAA,EACF;AACF;","names":[]}
|