@nadohq/client 0.15.0 → 0.18.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/BaseSpotAPI-BeTjhXT_.d.cts +14 -0
- package/dist/BaseSpotAPI-BeTjhXT_.d.cts.map +1 -0
- package/dist/BaseSpotAPI-Ck64kyYt.d.ts +14 -0
- package/dist/BaseSpotAPI-Ck64kyYt.d.ts.map +1 -0
- package/dist/MarketExecuteAPI-BBp0Nn6N.d.cts +55 -0
- package/dist/MarketExecuteAPI-BBp0Nn6N.d.cts.map +1 -0
- package/dist/MarketExecuteAPI-_S9-rNsv.d.ts +55 -0
- package/dist/MarketExecuteAPI-_S9-rNsv.d.ts.map +1 -0
- package/dist/MarketQueryAPI-Dhb8hWiD.d.cts +118 -0
- package/dist/MarketQueryAPI-Dhb8hWiD.d.cts.map +1 -0
- package/dist/MarketQueryAPI-Dz8FrVPK.d.ts +118 -0
- package/dist/MarketQueryAPI-Dz8FrVPK.d.ts.map +1 -0
- package/dist/PerpExecuteAPI-C0APgWq4.d.cts +7 -0
- package/dist/PerpExecuteAPI-C0APgWq4.d.cts.map +1 -0
- package/dist/PerpExecuteAPI-DPNJdARF.d.ts +7 -0
- package/dist/PerpExecuteAPI-DPNJdARF.d.ts.map +1 -0
- package/dist/PerpQueryAPI-RGhdNhoJ.d.cts +19 -0
- package/dist/PerpQueryAPI-RGhdNhoJ.d.cts.map +1 -0
- package/dist/PerpQueryAPI-tJbMmCcO.d.ts +19 -0
- package/dist/PerpQueryAPI-tJbMmCcO.d.ts.map +1 -0
- package/dist/SpotExecuteAPI-UWnX_Hm4.d.ts +22 -0
- package/dist/SpotExecuteAPI-UWnX_Hm4.d.ts.map +1 -0
- package/dist/SpotExecuteAPI-b07ixUz2.d.cts +22 -0
- package/dist/SpotExecuteAPI-b07ixUz2.d.cts.map +1 -0
- package/dist/SpotQueryAPI-CfZcvt4p.d.ts +36 -0
- package/dist/SpotQueryAPI-CfZcvt4p.d.ts.map +1 -0
- package/dist/SpotQueryAPI-DS85MzQB.d.cts +36 -0
- package/dist/SpotQueryAPI-DS85MzQB.d.cts.map +1 -0
- package/dist/SubaccountExecuteAPI-DhHBzzdk.d.cts +21 -0
- package/dist/SubaccountExecuteAPI-DhHBzzdk.d.cts.map +1 -0
- package/dist/SubaccountExecuteAPI-KApMbONz.d.ts +21 -0
- package/dist/SubaccountExecuteAPI-KApMbONz.d.ts.map +1 -0
- package/dist/SubaccountQueryAPI-C9h3epmM.d.cts +40 -0
- package/dist/SubaccountQueryAPI-C9h3epmM.d.cts.map +1 -0
- package/dist/SubaccountQueryAPI-DnLcgfiM.d.ts +40 -0
- package/dist/SubaccountQueryAPI-DnLcgfiM.d.ts.map +1 -0
- package/dist/WebSocketExecuteAPI-7gLrCoXN.d.cts +44 -0
- package/dist/WebSocketExecuteAPI-7gLrCoXN.d.cts.map +1 -0
- package/dist/WebSocketExecuteAPI-DHhKag16.d.ts +44 -0
- package/dist/WebSocketExecuteAPI-DHhKag16.d.ts.map +1 -0
- package/dist/WebSocketQueryAPI-B9vBQo5q.d.ts +20 -0
- package/dist/WebSocketQueryAPI-B9vBQo5q.d.ts.map +1 -0
- package/dist/WebSocketQueryAPI-BMLp4dCH.d.cts +20 -0
- package/dist/WebSocketQueryAPI-BMLp4dCH.d.cts.map +1 -0
- package/dist/WebSocketSubscriptionAPI-bApRHac8.d.cts +34 -0
- package/dist/WebSocketSubscriptionAPI-bApRHac8.d.cts.map +1 -0
- package/dist/WebSocketSubscriptionAPI-qUFRFcRI.d.ts +34 -0
- package/dist/WebSocketSubscriptionAPI-qUFRFcRI.d.ts.map +1 -0
- package/dist/apis/base.cjs +30 -60
- package/dist/apis/base.cjs.map +1 -1
- package/dist/apis/base.d.cts +2 -22
- package/dist/apis/base.d.ts +2 -22
- package/dist/apis/base.js +28 -34
- package/dist/apis/base.js.map +1 -1
- package/dist/apis/market/MarketExecuteAPI.cjs +164 -190
- package/dist/apis/market/MarketExecuteAPI.cjs.map +1 -1
- package/dist/apis/market/MarketExecuteAPI.d.cts +2 -61
- package/dist/apis/market/MarketExecuteAPI.d.ts +2 -61
- package/dist/apis/market/MarketExecuteAPI.js +162 -164
- package/dist/apis/market/MarketExecuteAPI.js.map +1 -1
- package/dist/apis/market/MarketQueryAPI.cjs +157 -181
- package/dist/apis/market/MarketQueryAPI.cjs.map +1 -1
- package/dist/apis/market/MarketQueryAPI.d.cts +2 -124
- package/dist/apis/market/MarketQueryAPI.d.ts +2 -124
- package/dist/apis/market/MarketQueryAPI.js +155 -155
- package/dist/apis/market/MarketQueryAPI.js.map +1 -1
- package/dist/apis/market/index.cjs +8 -36
- package/dist/apis/market/index.cjs.map +1 -1
- package/dist/apis/market/index.d.cts +3 -19
- package/dist/apis/market/index.d.ts +3 -19
- package/dist/apis/market/index.js +6 -8
- package/dist/apis/market/index.js.map +1 -1
- package/dist/apis/market/types.cjs +0 -19
- package/dist/apis/market/types.d.cts +2 -41
- package/dist/apis/market/types.d.ts +2 -41
- package/dist/apis/market/types.js +1 -1
- package/dist/apis/perp/PerpExecuteAPI.cjs +6 -31
- package/dist/apis/perp/PerpExecuteAPI.cjs.map +1 -1
- package/dist/apis/perp/PerpExecuteAPI.d.cts +2 -12
- package/dist/apis/perp/PerpExecuteAPI.d.ts +2 -12
- package/dist/apis/perp/PerpExecuteAPI.js +5 -6
- package/dist/apis/perp/PerpExecuteAPI.js.map +1 -1
- package/dist/apis/perp/PerpQueryAPI.cjs +20 -44
- package/dist/apis/perp/PerpQueryAPI.cjs.map +1 -1
- package/dist/apis/perp/PerpQueryAPI.d.cts +2 -23
- package/dist/apis/perp/PerpQueryAPI.d.ts +2 -23
- package/dist/apis/perp/PerpQueryAPI.js +18 -18
- package/dist/apis/perp/PerpQueryAPI.js.map +1 -1
- package/dist/apis/perp/index.cjs +8 -33
- package/dist/apis/perp/index.cjs.map +1 -1
- package/dist/apis/perp/index.d.cts +2 -16
- package/dist/apis/perp/index.d.ts +2 -16
- package/dist/apis/perp/index.js +6 -7
- package/dist/apis/perp/index.js.map +1 -1
- package/dist/apis/spot/BaseSpotAPI.cjs +21 -51
- package/dist/apis/spot/BaseSpotAPI.cjs.map +1 -1
- package/dist/apis/spot/BaseSpotAPI.d.cts +2 -18
- package/dist/apis/spot/BaseSpotAPI.d.ts +2 -18
- package/dist/apis/spot/BaseSpotAPI.js +19 -28
- package/dist/apis/spot/BaseSpotAPI.js.map +1 -1
- package/dist/apis/spot/SpotExecuteAPI.cjs +72 -104
- package/dist/apis/spot/SpotExecuteAPI.cjs.map +1 -1
- package/dist/apis/spot/SpotExecuteAPI.d.cts +2 -27
- package/dist/apis/spot/SpotExecuteAPI.d.ts +2 -27
- package/dist/apis/spot/SpotExecuteAPI.js +70 -85
- package/dist/apis/spot/SpotExecuteAPI.js.map +1 -1
- package/dist/apis/spot/SpotQueryAPI.cjs +34 -71
- package/dist/apis/spot/SpotQueryAPI.cjs.map +1 -1
- package/dist/apis/spot/SpotQueryAPI.d.cts +2 -35
- package/dist/apis/spot/SpotQueryAPI.d.ts +2 -35
- package/dist/apis/spot/SpotQueryAPI.js +32 -45
- package/dist/apis/spot/SpotQueryAPI.js.map +1 -1
- package/dist/apis/spot/index.cjs +11 -36
- package/dist/apis/spot/index.cjs.map +1 -1
- package/dist/apis/spot/index.d.cts +3 -23
- package/dist/apis/spot/index.d.ts +3 -23
- package/dist/apis/spot/index.js +9 -8
- package/dist/apis/spot/index.js.map +1 -1
- package/dist/apis/spot/types.cjs +0 -19
- package/dist/apis/spot/types.d.cts +2 -27
- package/dist/apis/spot/types.d.ts +2 -27
- package/dist/apis/spot/types.js +1 -1
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs +32 -56
- package/dist/apis/subaccount/SubaccountExecuteAPI.cjs.map +1 -1
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.cts +2 -26
- package/dist/apis/subaccount/SubaccountExecuteAPI.d.ts +2 -26
- package/dist/apis/subaccount/SubaccountExecuteAPI.js +30 -30
- package/dist/apis/subaccount/SubaccountExecuteAPI.js.map +1 -1
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs +48 -72
- package/dist/apis/subaccount/SubaccountQueryAPI.cjs.map +1 -1
- package/dist/apis/subaccount/SubaccountQueryAPI.d.cts +2 -44
- package/dist/apis/subaccount/SubaccountQueryAPI.d.ts +2 -44
- package/dist/apis/subaccount/SubaccountQueryAPI.js +46 -46
- package/dist/apis/subaccount/SubaccountQueryAPI.js.map +1 -1
- package/dist/apis/subaccount/index.cjs +32 -64
- package/dist/apis/subaccount/index.cjs.map +1 -1
- package/dist/apis/subaccount/index.d.cts +3 -27
- package/dist/apis/subaccount/index.d.ts +3 -27
- package/dist/apis/subaccount/index.js +30 -39
- package/dist/apis/subaccount/index.js.map +1 -1
- package/dist/apis/subaccount/types.cjs +0 -19
- package/dist/apis/subaccount/types.d.cts +2 -9
- package/dist/apis/subaccount/types.d.ts +2 -9
- package/dist/apis/subaccount/types.js +1 -1
- package/dist/apis/types.cjs +0 -19
- package/dist/apis/types.d.cts +2 -9
- package/dist/apis/types.d.ts +2 -9
- package/dist/apis/types.js +1 -1
- package/dist/apis/ws/WebSocketExecuteAPI.cjs +42 -70
- package/dist/apis/ws/WebSocketExecuteAPI.cjs.map +1 -1
- package/dist/apis/ws/WebSocketExecuteAPI.d.cts +2 -48
- package/dist/apis/ws/WebSocketExecuteAPI.d.ts +2 -48
- package/dist/apis/ws/WebSocketExecuteAPI.js +40 -44
- package/dist/apis/ws/WebSocketExecuteAPI.js.map +1 -1
- package/dist/apis/ws/WebSocketQueryAPI.cjs +19 -39
- package/dist/apis/ws/WebSocketQueryAPI.cjs.map +1 -1
- package/dist/apis/ws/WebSocketQueryAPI.d.cts +2 -23
- package/dist/apis/ws/WebSocketQueryAPI.d.ts +2 -23
- package/dist/apis/ws/WebSocketQueryAPI.js +17 -13
- package/dist/apis/ws/WebSocketQueryAPI.js.map +1 -1
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs +40 -58
- package/dist/apis/ws/WebSocketSubscriptionAPI.cjs.map +1 -1
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.cts +2 -37
- package/dist/apis/ws/WebSocketSubscriptionAPI.d.ts +2 -37
- package/dist/apis/ws/WebSocketSubscriptionAPI.js +38 -32
- package/dist/apis/ws/WebSocketSubscriptionAPI.js.map +1 -1
- package/dist/apis/ws/index.cjs +18 -39
- package/dist/apis/ws/index.cjs.map +1 -1
- package/dist/apis/ws/index.d.cts +2 -22
- package/dist/apis/ws/index.d.ts +2 -22
- package/dist/apis/ws/index.js +13 -10
- package/dist/apis/ws/index.js.map +1 -1
- package/dist/base-B92wTsrc.d.ts +20 -0
- package/dist/base-B92wTsrc.d.ts.map +1 -0
- package/dist/base-BYkH_-5-.d.cts +20 -0
- package/dist/base-BYkH_-5-.d.cts.map +1 -0
- package/dist/client.cjs +53 -77
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +28 -49
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.ts +28 -49
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +46 -46
- package/dist/client.js.map +1 -1
- package/dist/context-YHVv2kD4.d.cts +44 -0
- package/dist/context-YHVv2kD4.d.cts.map +1 -0
- package/dist/context-YfcGQ0Sr.d.ts +44 -0
- package/dist/context-YfcGQ0Sr.d.ts.map +1 -0
- package/dist/context.cjs +92 -122
- package/dist/context.cjs.map +1 -1
- package/dist/context.d.cts +2 -42
- package/dist/context.d.ts +2 -42
- package/dist/context.js +90 -105
- package/dist/context.js.map +1 -1
- package/dist/createNadoClient.cjs +15 -32
- package/dist/createNadoClient.cjs.map +1 -1
- package/dist/createNadoClient.d.cts +5 -32
- package/dist/createNadoClient.d.cts.map +1 -0
- package/dist/createNadoClient.d.ts +5 -32
- package/dist/createNadoClient.d.ts.map +1 -0
- package/dist/createNadoClient.js +13 -8
- package/dist/createNadoClient.js.map +1 -1
- package/dist/index-BFQPcj2w.d.cts +9 -0
- package/dist/index-BFQPcj2w.d.cts.map +1 -0
- package/dist/index-CSG04f_b.d.cts +12 -0
- package/dist/index-CSG04f_b.d.cts.map +1 -0
- package/dist/index-Cc2RdeRK.d.cts +19 -0
- package/dist/index-Cc2RdeRK.d.cts.map +1 -0
- package/dist/index-DIX4yJe-.d.ts +9 -0
- package/dist/index-DIX4yJe-.d.ts.map +1 -0
- package/dist/index-DVJ1Mu6s.d.ts +9 -0
- package/dist/index-DVJ1Mu6s.d.ts.map +1 -0
- package/dist/index-DkTJs2nZ.d.cts +9 -0
- package/dist/index-DkTJs2nZ.d.cts.map +1 -0
- package/dist/index-Dw9iFeeU.d.ts +19 -0
- package/dist/index-Dw9iFeeU.d.ts.map +1 -0
- package/dist/index-Mhjd1FK8.d.ts +12 -0
- package/dist/index-Mhjd1FK8.d.ts.map +1 -0
- package/dist/index-RtQYDuRY.d.ts +19 -0
- package/dist/index-RtQYDuRY.d.ts.map +1 -0
- package/dist/index-jTtf55U_.d.cts +19 -0
- package/dist/index-jTtf55U_.d.cts.map +1 -0
- package/dist/index.cjs +50 -44
- package/dist/index.d.cts +15 -32
- package/dist/index.d.ts +15 -32
- package/dist/index.js +9 -10
- package/dist/types-B-tOIIKl.d.ts +29 -0
- package/dist/types-B-tOIIKl.d.ts.map +1 -0
- package/dist/types-B6oFoDTo.d.ts +11 -0
- package/dist/types-B6oFoDTo.d.ts.map +1 -0
- package/dist/types-BFFzjzRy.d.ts +43 -0
- package/dist/types-BFFzjzRy.d.ts.map +1 -0
- package/dist/types-BWRdhQd_.d.cts +11 -0
- package/dist/types-BWRdhQd_.d.cts.map +1 -0
- package/dist/types-C5DKLOen.d.ts +11 -0
- package/dist/types-C5DKLOen.d.ts.map +1 -0
- package/dist/types-CCj4QJO8.d.cts +29 -0
- package/dist/types-CCj4QJO8.d.cts.map +1 -0
- package/dist/types-D27__G6_.d.cts +11 -0
- package/dist/types-D27__G6_.d.cts.map +1 -0
- package/dist/types-YBdM1sun.d.cts +43 -0
- package/dist/types-YBdM1sun.d.cts.map +1 -0
- package/package.json +11 -11
- package/dist/apis/market/types.cjs.map +0 -1
- package/dist/apis/market/types.js.map +0 -1
- package/dist/apis/spot/types.cjs.map +0 -1
- package/dist/apis/spot/types.js.map +0 -1
- package/dist/apis/subaccount/types.cjs.map +0 -1
- package/dist/apis/subaccount/types.js.map +0 -1
- package/dist/apis/types.cjs.map +0 -1
- package/dist/apis/types.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
|
@@ -1,107 +1,75 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_apis_spot_BaseSpotAPI = require("./BaseSpotAPI.cjs");
|
|
3
|
+
let _nadohq_shared = require("@nadohq/shared");
|
|
4
|
+
//#region src/apis/spot/SpotExecuteAPI.ts
|
|
5
|
+
var SpotExecuteAPI = class extends require_apis_spot_BaseSpotAPI.BaseSpotAPI {
|
|
6
|
+
async deposit(params) {
|
|
7
|
+
return (0, _nadohq_shared.depositCollateral)({
|
|
8
|
+
endpoint: this.context.contracts.endpoint,
|
|
9
|
+
subaccountName: params.subaccountName,
|
|
10
|
+
productId: params.productId,
|
|
11
|
+
amount: params.amount,
|
|
12
|
+
referralCode: params.referralCode
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async withdraw(params) {
|
|
16
|
+
return this.context.engineClient.withdrawCollateral({
|
|
17
|
+
...params,
|
|
18
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
19
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
20
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async approveAllowance(params) {
|
|
24
|
+
const tokenContract = await this.getTokenContractForProduct(params);
|
|
25
|
+
if (!(0, _nadohq_shared.isWriteableContract)(tokenContract)) throw new Error("Token contract does not permit writes. Is a wallet client provided?");
|
|
26
|
+
return (0, _nadohq_shared.approveDepositAllowance)({
|
|
27
|
+
amount: params.amount,
|
|
28
|
+
endpoint: this.context.contracts.endpoint,
|
|
29
|
+
tokenContract
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Transfers quote between subaccounts under the same wallet.
|
|
34
|
+
*
|
|
35
|
+
* @param params
|
|
36
|
+
*/
|
|
37
|
+
async transferQuote(params) {
|
|
38
|
+
return this.context.engineClient.transferQuote({
|
|
39
|
+
...params,
|
|
40
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
41
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
42
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async mintNlp(params) {
|
|
46
|
+
return this.context.engineClient.mintNlp({
|
|
47
|
+
...params,
|
|
48
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
49
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
50
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async burnNlp(params) {
|
|
54
|
+
return this.context.engineClient.burnNlp({
|
|
55
|
+
...params,
|
|
56
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
57
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
58
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async _mintMockERC20(params) {
|
|
62
|
+
if (!this.context.walletClient) throw new _nadohq_shared.WalletNotProvidedError();
|
|
63
|
+
const config = await this.context.contracts.spotEngine.read.getConfig([params.productId]);
|
|
64
|
+
return this.context.walletClient.writeContract({
|
|
65
|
+
abi: _nadohq_shared.MOCK_ERC20_ABI,
|
|
66
|
+
address: config.token,
|
|
67
|
+
functionName: "mint",
|
|
68
|
+
args: [this.getWalletClientAddress(), (0, _nadohq_shared.toBigInt)(params.amount)]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
9
71
|
};
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
72
|
+
//#endregion
|
|
73
|
+
exports.SpotExecuteAPI = SpotExecuteAPI;
|
|
19
74
|
|
|
20
|
-
// src/apis/spot/SpotExecuteAPI.ts
|
|
21
|
-
var SpotExecuteAPI_exports = {};
|
|
22
|
-
__export(SpotExecuteAPI_exports, {
|
|
23
|
-
SpotExecuteAPI: () => SpotExecuteAPI
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(SpotExecuteAPI_exports);
|
|
26
|
-
var import_shared = require("@nadohq/shared");
|
|
27
|
-
var import_BaseSpotAPI = require("./BaseSpotAPI.cjs");
|
|
28
|
-
var SpotExecuteAPI = class extends import_BaseSpotAPI.BaseSpotAPI {
|
|
29
|
-
async deposit(params) {
|
|
30
|
-
return (0, import_shared.depositCollateral)({
|
|
31
|
-
endpoint: this.context.contracts.endpoint,
|
|
32
|
-
subaccountName: params.subaccountName,
|
|
33
|
-
productId: params.productId,
|
|
34
|
-
amount: params.amount,
|
|
35
|
-
referralCode: params.referralCode
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
async withdraw(params) {
|
|
39
|
-
return this.context.engineClient.withdrawCollateral({
|
|
40
|
-
...params,
|
|
41
|
-
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
42
|
-
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
43
|
-
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
async approveAllowance(params) {
|
|
47
|
-
const tokenContract = await this.getTokenContractForProduct(params);
|
|
48
|
-
if (!(0, import_shared.isWriteableContract)(tokenContract)) {
|
|
49
|
-
throw new Error(
|
|
50
|
-
"Token contract does not permit writes. Is a wallet client provided?"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
return (0, import_shared.approveDepositAllowance)({
|
|
54
|
-
amount: params.amount,
|
|
55
|
-
endpoint: this.context.contracts.endpoint,
|
|
56
|
-
tokenContract
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Transfers quote between subaccounts under the same wallet.
|
|
61
|
-
*
|
|
62
|
-
* @param params
|
|
63
|
-
*/
|
|
64
|
-
async transferQuote(params) {
|
|
65
|
-
return this.context.engineClient.transferQuote({
|
|
66
|
-
...params,
|
|
67
|
-
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
68
|
-
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
69
|
-
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
async mintNlp(params) {
|
|
73
|
-
return this.context.engineClient.mintNlp({
|
|
74
|
-
...params,
|
|
75
|
-
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
76
|
-
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
77
|
-
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async burnNlp(params) {
|
|
81
|
-
return this.context.engineClient.burnNlp({
|
|
82
|
-
...params,
|
|
83
|
-
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
84
|
-
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
85
|
-
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
async _mintMockERC20(params) {
|
|
89
|
-
if (!this.context.walletClient) {
|
|
90
|
-
throw new import_shared.WalletNotProvidedError();
|
|
91
|
-
}
|
|
92
|
-
const config = await this.context.contracts.spotEngine.read.getConfig([
|
|
93
|
-
params.productId
|
|
94
|
-
]);
|
|
95
|
-
return this.context.walletClient.writeContract({
|
|
96
|
-
abi: import_shared.MOCK_ERC20_ABI,
|
|
97
|
-
address: config.token,
|
|
98
|
-
functionName: "mint",
|
|
99
|
-
args: [this.getWalletClientAddress(), (0, import_shared.toBigInt)(params.amount)]
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
-
0 && (module.exports = {
|
|
105
|
-
SpotExecuteAPI
|
|
106
|
-
});
|
|
107
75
|
//# sourceMappingURL=SpotExecuteAPI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',\n args: [this.getWalletClientAddress(), toBigInt(params.amount)],\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpotExecuteAPI.cjs","names":["BaseSpotAPI","WalletNotProvidedError","MOCK_ERC20_ABI"],"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',\n args: [this.getWalletClientAddress(), toBigInt(params.amount)],\n });\n }\n}\n"],"mappings":";;;;AAmBA,IAAa,iBAAb,cAAoCA,8BAAAA,YAAY;CAC9C,MAAM,QAAQ,QAAiC;EAC7C,QAAA,GAAA,eAAA,mBAAyB;GACvB,UAAU,KAAK,QAAQ,UAAU;GACjC,gBAAgB,OAAO;GACvB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,cAAc,OAAO;EACvB,CAAC;CACH;CAEA,MAAM,SAAS,QAAkC;EAC/C,OAAO,KAAK,QAAQ,aAAa,mBAAmB;GAClD,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,iBAAiB,QAAgC;EACrD,MAAM,gBAAgB,MAAM,KAAK,2BAA2B,MAAM;EAClE,IAAI,EAAA,GAAA,eAAA,qBAAqB,aAAa,GACpC,MAAM,IAAI,MACR,qEACF;EAGF,QAAA,GAAA,eAAA,yBAA+B;GAC7B,QAAQ,OAAO;GACf,UAAU,KAAK,QAAQ,UAAU;GACjC;EACF,CAAC;CACH;;;;;;CAOA,MAAM,cAAc,QAA6B;EAC/C,OAAO,KAAK,QAAQ,aAAa,cAAc;GAC7C,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;GAC/D,SAAS,KAAK,+BAA+B,MAAM;EACrD,CAAC;CACH;CAEA,MAAM,QAAQ,QAAuB;EACnC,OAAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,QAAQ,QAAuB;EACnC,OAAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,eAAe,QAA6B;EAChD,IAAI,CAAC,KAAK,QAAQ,cAChB,MAAM,IAAIC,eAAAA,uBAAuB;EAGnC,MAAM,SAAS,MAAM,KAAK,QAAQ,UAAU,WAAW,KAAK,UAAU,CACpE,OAAO,SACT,CAAC;EAED,OAAO,KAAK,QAAQ,aAAa,cAAc;GAC7C,KAAKC,eAAAA;GACL,SAAS,OAAO;GAChB,cAAc;GACd,MAAM,CAAC,KAAK,uBAAuB,IAAA,GAAA,eAAA,UAAY,OAAO,MAAM,CAAC;EAC/D,CAAC;CACH;AACF"}
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { BaseSpotAPI } from './BaseSpotAPI.cjs';
|
|
4
|
-
import { WithdrawCollateralParams, ApproveAllowanceParams, TransferQuoteParams, MintNlpParams, BurnNlpParams, MintMockERC20Params } from './types.cjs';
|
|
5
|
-
import '../base.cjs';
|
|
6
|
-
import '../../context.cjs';
|
|
7
|
-
import '@nadohq/indexer-client';
|
|
8
|
-
import '@nadohq/trigger-client';
|
|
9
|
-
import 'viem';
|
|
10
|
-
import '../types.cjs';
|
|
11
|
-
|
|
12
|
-
declare class SpotExecuteAPI extends BaseSpotAPI {
|
|
13
|
-
deposit(params: DepositCollateralParams): Promise<`0x${string}`>;
|
|
14
|
-
withdraw(params: WithdrawCollateralParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"withdraw_collateral">>;
|
|
15
|
-
approveAllowance(params: ApproveAllowanceParams): Promise<`0x${string}`>;
|
|
16
|
-
/**
|
|
17
|
-
* Transfers quote between subaccounts under the same wallet.
|
|
18
|
-
*
|
|
19
|
-
* @param params
|
|
20
|
-
*/
|
|
21
|
-
transferQuote(params: TransferQuoteParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"transfer_quote">>;
|
|
22
|
-
mintNlp(params: MintNlpParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"mint_nlp">>;
|
|
23
|
-
burnNlp(params: BurnNlpParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"burn_nlp">>;
|
|
24
|
-
_mintMockERC20(params: MintMockERC20Params): Promise<`0x${string}`>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { SpotExecuteAPI };
|
|
1
|
+
import { t as SpotExecuteAPI } from "../../SpotExecuteAPI-b07ixUz2.cjs";
|
|
2
|
+
export { SpotExecuteAPI };
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { BaseSpotAPI } from './BaseSpotAPI.js';
|
|
4
|
-
import { WithdrawCollateralParams, ApproveAllowanceParams, TransferQuoteParams, MintNlpParams, BurnNlpParams, MintMockERC20Params } from './types.js';
|
|
5
|
-
import '../base.js';
|
|
6
|
-
import '../../context.js';
|
|
7
|
-
import '@nadohq/indexer-client';
|
|
8
|
-
import '@nadohq/trigger-client';
|
|
9
|
-
import 'viem';
|
|
10
|
-
import '../types.js';
|
|
11
|
-
|
|
12
|
-
declare class SpotExecuteAPI extends BaseSpotAPI {
|
|
13
|
-
deposit(params: DepositCollateralParams): Promise<`0x${string}`>;
|
|
14
|
-
withdraw(params: WithdrawCollateralParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"withdraw_collateral">>;
|
|
15
|
-
approveAllowance(params: ApproveAllowanceParams): Promise<`0x${string}`>;
|
|
16
|
-
/**
|
|
17
|
-
* Transfers quote between subaccounts under the same wallet.
|
|
18
|
-
*
|
|
19
|
-
* @param params
|
|
20
|
-
*/
|
|
21
|
-
transferQuote(params: TransferQuoteParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"transfer_quote">>;
|
|
22
|
-
mintNlp(params: MintNlpParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"mint_nlp">>;
|
|
23
|
-
burnNlp(params: BurnNlpParams): Promise<_nadohq_engine_client.EngineServerExecuteSuccessResult<"burn_nlp">>;
|
|
24
|
-
_mintMockERC20(params: MintMockERC20Params): Promise<`0x${string}`>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export { SpotExecuteAPI };
|
|
1
|
+
import { t as SpotExecuteAPI } from "../../SpotExecuteAPI-UWnX_Hm4.js";
|
|
2
|
+
export { SpotExecuteAPI };
|
|
@@ -1,89 +1,74 @@
|
|
|
1
|
-
// src/apis/spot/SpotExecuteAPI.ts
|
|
2
|
-
import {
|
|
3
|
-
approveDepositAllowance,
|
|
4
|
-
depositCollateral,
|
|
5
|
-
isWriteableContract,
|
|
6
|
-
MOCK_ERC20_ABI,
|
|
7
|
-
toBigInt,
|
|
8
|
-
WalletNotProvidedError
|
|
9
|
-
} from "@nadohq/shared";
|
|
10
1
|
import { BaseSpotAPI } from "./BaseSpotAPI.js";
|
|
2
|
+
import { MOCK_ERC20_ABI, WalletNotProvidedError, approveDepositAllowance, depositCollateral, isWriteableContract, toBigInt } from "@nadohq/shared";
|
|
3
|
+
//#region src/apis/spot/SpotExecuteAPI.ts
|
|
11
4
|
var SpotExecuteAPI = class extends BaseSpotAPI {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
]);
|
|
78
|
-
return this.context.walletClient.writeContract({
|
|
79
|
-
abi: MOCK_ERC20_ABI,
|
|
80
|
-
address: config.token,
|
|
81
|
-
functionName: "mint",
|
|
82
|
-
args: [this.getWalletClientAddress(), toBigInt(params.amount)]
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
export {
|
|
87
|
-
SpotExecuteAPI
|
|
5
|
+
async deposit(params) {
|
|
6
|
+
return depositCollateral({
|
|
7
|
+
endpoint: this.context.contracts.endpoint,
|
|
8
|
+
subaccountName: params.subaccountName,
|
|
9
|
+
productId: params.productId,
|
|
10
|
+
amount: params.amount,
|
|
11
|
+
referralCode: params.referralCode
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async withdraw(params) {
|
|
15
|
+
return this.context.engineClient.withdrawCollateral({
|
|
16
|
+
...params,
|
|
17
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
18
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
19
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async approveAllowance(params) {
|
|
23
|
+
const tokenContract = await this.getTokenContractForProduct(params);
|
|
24
|
+
if (!isWriteableContract(tokenContract)) throw new Error("Token contract does not permit writes. Is a wallet client provided?");
|
|
25
|
+
return approveDepositAllowance({
|
|
26
|
+
amount: params.amount,
|
|
27
|
+
endpoint: this.context.contracts.endpoint,
|
|
28
|
+
tokenContract
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Transfers quote between subaccounts under the same wallet.
|
|
33
|
+
*
|
|
34
|
+
* @param params
|
|
35
|
+
*/
|
|
36
|
+
async transferQuote(params) {
|
|
37
|
+
return this.context.engineClient.transferQuote({
|
|
38
|
+
...params,
|
|
39
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
40
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),
|
|
41
|
+
chainId: this.getWalletClientChainIdIfNeeded(params)
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async mintNlp(params) {
|
|
45
|
+
return this.context.engineClient.mintNlp({
|
|
46
|
+
...params,
|
|
47
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
48
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
49
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async burnNlp(params) {
|
|
53
|
+
return this.context.engineClient.burnNlp({
|
|
54
|
+
...params,
|
|
55
|
+
subaccountOwner: this.getSubaccountOwnerIfNeeded(params),
|
|
56
|
+
chainId: this.getWalletClientChainIdIfNeeded(params),
|
|
57
|
+
verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress()
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async _mintMockERC20(params) {
|
|
61
|
+
if (!this.context.walletClient) throw new WalletNotProvidedError();
|
|
62
|
+
const config = await this.context.contracts.spotEngine.read.getConfig([params.productId]);
|
|
63
|
+
return this.context.walletClient.writeContract({
|
|
64
|
+
abi: MOCK_ERC20_ABI,
|
|
65
|
+
address: config.token,
|
|
66
|
+
functionName: "mint",
|
|
67
|
+
args: [this.getWalletClientAddress(), toBigInt(params.amount)]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
88
70
|
};
|
|
71
|
+
//#endregion
|
|
72
|
+
export { SpotExecuteAPI };
|
|
73
|
+
|
|
89
74
|
//# sourceMappingURL=SpotExecuteAPI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',\n args: [this.getWalletClientAddress(), toBigInt(params.amount)],\n });\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpotExecuteAPI.js","names":[],"sources":["../../../src/apis/spot/SpotExecuteAPI.ts"],"sourcesContent":["import {\n approveDepositAllowance,\n depositCollateral,\n DepositCollateralParams,\n isWriteableContract,\n MOCK_ERC20_ABI,\n toBigInt,\n WalletNotProvidedError,\n} from '@nadohq/shared';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport {\n ApproveAllowanceParams,\n BurnNlpParams,\n MintMockERC20Params,\n MintNlpParams,\n TransferQuoteParams,\n WithdrawCollateralParams,\n} from './types';\n\nexport class SpotExecuteAPI extends BaseSpotAPI {\n async deposit(params: DepositCollateralParams) {\n return depositCollateral({\n endpoint: this.context.contracts.endpoint,\n subaccountName: params.subaccountName,\n productId: params.productId,\n amount: params.amount,\n referralCode: params.referralCode,\n });\n }\n\n async withdraw(params: WithdrawCollateralParams) {\n return this.context.engineClient.withdrawCollateral({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async approveAllowance(params: ApproveAllowanceParams) {\n const tokenContract = await this.getTokenContractForProduct(params);\n if (!isWriteableContract(tokenContract)) {\n throw new Error(\n 'Token contract does not permit writes. Is a wallet client provided?',\n );\n }\n\n return approveDepositAllowance({\n amount: params.amount,\n endpoint: this.context.contracts.endpoint,\n tokenContract,\n });\n }\n\n /**\n * Transfers quote between subaccounts under the same wallet.\n *\n * @param params\n */\n async transferQuote(params: TransferQuoteParams) {\n return this.context.engineClient.transferQuote({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n });\n }\n\n async mintNlp(params: MintNlpParams) {\n return this.context.engineClient.mintNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async burnNlp(params: BurnNlpParams) {\n return this.context.engineClient.burnNlp({\n ...params,\n subaccountOwner: this.getSubaccountOwnerIfNeeded(params),\n chainId: this.getWalletClientChainIdIfNeeded(params),\n verifyingAddr: params.verifyingAddr ?? this.getEndpointAddress(),\n });\n }\n\n async _mintMockERC20(params: MintMockERC20Params) {\n if (!this.context.walletClient) {\n throw new WalletNotProvidedError();\n }\n\n const config = await this.context.contracts.spotEngine.read.getConfig([\n params.productId,\n ]);\n\n return this.context.walletClient.writeContract({\n abi: MOCK_ERC20_ABI,\n address: config.token,\n functionName: 'mint',\n args: [this.getWalletClientAddress(), toBigInt(params.amount)],\n });\n }\n}\n"],"mappings":";;;AAmBA,IAAa,iBAAb,cAAoC,YAAY;CAC9C,MAAM,QAAQ,QAAiC;EAC7C,OAAO,kBAAkB;GACvB,UAAU,KAAK,QAAQ,UAAU;GACjC,gBAAgB,OAAO;GACvB,WAAW,OAAO;GAClB,QAAQ,OAAO;GACf,cAAc,OAAO;EACvB,CAAC;CACH;CAEA,MAAM,SAAS,QAAkC;EAC/C,OAAO,KAAK,QAAQ,aAAa,mBAAmB;GAClD,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,iBAAiB,QAAgC;EACrD,MAAM,gBAAgB,MAAM,KAAK,2BAA2B,MAAM;EAClE,IAAI,CAAC,oBAAoB,aAAa,GACpC,MAAM,IAAI,MACR,qEACF;EAGF,OAAO,wBAAwB;GAC7B,QAAQ,OAAO;GACf,UAAU,KAAK,QAAQ,UAAU;GACjC;EACF,CAAC;CACH;;;;;;CAOA,MAAM,cAAc,QAA6B;EAC/C,OAAO,KAAK,QAAQ,aAAa,cAAc;GAC7C,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;GAC/D,SAAS,KAAK,+BAA+B,MAAM;EACrD,CAAC;CACH;CAEA,MAAM,QAAQ,QAAuB;EACnC,OAAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,QAAQ,QAAuB;EACnC,OAAO,KAAK,QAAQ,aAAa,QAAQ;GACvC,GAAG;GACH,iBAAiB,KAAK,2BAA2B,MAAM;GACvD,SAAS,KAAK,+BAA+B,MAAM;GACnD,eAAe,OAAO,iBAAiB,KAAK,mBAAmB;EACjE,CAAC;CACH;CAEA,MAAM,eAAe,QAA6B;EAChD,IAAI,CAAC,KAAK,QAAQ,cAChB,MAAM,IAAI,uBAAuB;EAGnC,MAAM,SAAS,MAAM,KAAK,QAAQ,UAAU,WAAW,KAAK,UAAU,CACpE,OAAO,SACT,CAAC;EAED,OAAO,KAAK,QAAQ,aAAa,cAAc;GAC7C,KAAK;GACL,SAAS,OAAO;GAChB,cAAc;GACd,MAAM,CAAC,KAAK,uBAAuB,GAAG,SAAS,OAAO,MAAM,CAAC;EAC/D,CAAC;CACH;AACF"}
|
|
@@ -1,74 +1,37 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_apis_spot_BaseSpotAPI = require("./BaseSpotAPI.cjs");
|
|
3
|
+
let _nadohq_shared = require("@nadohq/shared");
|
|
4
|
+
//#region src/apis/spot/SpotQueryAPI.ts
|
|
5
|
+
var SpotQueryAPI = class extends require_apis_spot_BaseSpotAPI.BaseSpotAPI {
|
|
6
|
+
/**
|
|
7
|
+
* Gets the estimated max withdrawable amount for a product
|
|
8
|
+
* @param params
|
|
9
|
+
*/
|
|
10
|
+
async getMaxWithdrawable(params) {
|
|
11
|
+
return this.context.engineClient.getMaxWithdrawable(params);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Queries engine to determine maximum quote amount for minting NLP.
|
|
15
|
+
*
|
|
16
|
+
* @param params
|
|
17
|
+
*/
|
|
18
|
+
async getMaxMintNlpAmount(params) {
|
|
19
|
+
return this.context.engineClient.getMaxMintNlpAmount(params);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Helper to get current token balance in the user's wallet (i.e. not in a Nado subaccount)
|
|
23
|
+
*/
|
|
24
|
+
async getTokenWalletBalance({ address, ...rest }) {
|
|
25
|
+
return (await this.getTokenContractForProduct(rest)).read.balanceOf([(0, _nadohq_shared.getValidatedAddress)(address)]);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Helper to get current token allowance
|
|
29
|
+
*/
|
|
30
|
+
async getTokenAllowance({ address, ...rest }) {
|
|
31
|
+
return (0, _nadohq_shared.toBigNumber)(await (await this.getTokenContractForProduct(rest)).read.allowance([(0, _nadohq_shared.getValidatedAddress)(address), this.getEndpointAddress()]));
|
|
32
|
+
}
|
|
9
33
|
};
|
|
10
|
-
|
|
11
|
-
|
|
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);
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.SpotQueryAPI = SpotQueryAPI;
|
|
19
36
|
|
|
20
|
-
// src/apis/spot/SpotQueryAPI.ts
|
|
21
|
-
var SpotQueryAPI_exports = {};
|
|
22
|
-
__export(SpotQueryAPI_exports, {
|
|
23
|
-
SpotQueryAPI: () => SpotQueryAPI
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(SpotQueryAPI_exports);
|
|
26
|
-
var import_shared = require("@nadohq/shared");
|
|
27
|
-
var import_BaseSpotAPI = require("./BaseSpotAPI.cjs");
|
|
28
|
-
var SpotQueryAPI = class extends import_BaseSpotAPI.BaseSpotAPI {
|
|
29
|
-
/**
|
|
30
|
-
* Gets the estimated max withdrawable amount for a product
|
|
31
|
-
* @param params
|
|
32
|
-
*/
|
|
33
|
-
async getMaxWithdrawable(params) {
|
|
34
|
-
return this.context.engineClient.getMaxWithdrawable(params);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Queries engine to determine maximum quote amount for minting NLP.
|
|
38
|
-
*
|
|
39
|
-
* @param params
|
|
40
|
-
*/
|
|
41
|
-
async getMaxMintNlpAmount(params) {
|
|
42
|
-
return this.context.engineClient.getMaxMintNlpAmount(params);
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Helper to get current token balance in the user's wallet (i.e. not in a Nado subaccount)
|
|
46
|
-
*/
|
|
47
|
-
async getTokenWalletBalance({
|
|
48
|
-
address,
|
|
49
|
-
...rest
|
|
50
|
-
}) {
|
|
51
|
-
const token = await this.getTokenContractForProduct(rest);
|
|
52
|
-
return token.read.balanceOf([(0, import_shared.getValidatedAddress)(address)]);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Helper to get current token allowance
|
|
56
|
-
*/
|
|
57
|
-
async getTokenAllowance({
|
|
58
|
-
address,
|
|
59
|
-
...rest
|
|
60
|
-
}) {
|
|
61
|
-
const token = await this.getTokenContractForProduct(rest);
|
|
62
|
-
return (0, import_shared.toBigNumber)(
|
|
63
|
-
await token.read.allowance([
|
|
64
|
-
(0, import_shared.getValidatedAddress)(address),
|
|
65
|
-
this.getEndpointAddress()
|
|
66
|
-
])
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
-
0 && (module.exports = {
|
|
72
|
-
SpotQueryAPI
|
|
73
|
-
});
|
|
74
37
|
//# sourceMappingURL=SpotQueryAPI.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/apis/spot/SpotQueryAPI.ts"],"sourcesContent":["import {\n GetEngineMaxMintNlpAmountParams,\n GetEngineMaxWithdrawableParams,\n} from '@nadohq/engine-client';\nimport { getValidatedAddress, toBigNumber } from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport { GetTokenAllowanceParams, GetTokenWalletBalanceParams } from './types';\n\nexport class SpotQueryAPI extends BaseSpotAPI {\n /**\n * Gets the estimated max withdrawable amount for a product\n * @param params\n */\n async getMaxWithdrawable(params: GetEngineMaxWithdrawableParams) {\n return this.context.engineClient.getMaxWithdrawable(params);\n }\n\n /**\n * Queries engine to determine maximum quote amount for minting NLP.\n *\n * @param params\n */\n async getMaxMintNlpAmount(params: GetEngineMaxMintNlpAmountParams) {\n return this.context.engineClient.getMaxMintNlpAmount(params);\n }\n\n /**\n * Helper to get current token balance in the user's wallet (i.e. not in a Nado subaccount)\n */\n async getTokenWalletBalance({\n address,\n ...rest\n }: GetTokenWalletBalanceParams): Promise<bigint> {\n const token = await this.getTokenContractForProduct(rest);\n return token.read.balanceOf([getValidatedAddress(address)]);\n }\n\n /**\n * Helper to get current token allowance\n */\n async getTokenAllowance({\n address,\n ...rest\n }: GetTokenAllowanceParams): Promise<BigNumber> {\n const token = await this.getTokenContractForProduct(rest);\n return toBigNumber(\n await token.read.allowance([\n getValidatedAddress(address),\n this.getEndpointAddress(),\n ]),\n );\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpotQueryAPI.cjs","names":["BaseSpotAPI"],"sources":["../../../src/apis/spot/SpotQueryAPI.ts"],"sourcesContent":["import {\n GetEngineMaxMintNlpAmountParams,\n GetEngineMaxWithdrawableParams,\n} from '@nadohq/engine-client';\nimport { getValidatedAddress, toBigNumber } from '@nadohq/shared';\nimport BigNumber from 'bignumber.js';\nimport { BaseSpotAPI } from './BaseSpotAPI';\nimport { GetTokenAllowanceParams, GetTokenWalletBalanceParams } from './types';\n\nexport class SpotQueryAPI extends BaseSpotAPI {\n /**\n * Gets the estimated max withdrawable amount for a product\n * @param params\n */\n async getMaxWithdrawable(params: GetEngineMaxWithdrawableParams) {\n return this.context.engineClient.getMaxWithdrawable(params);\n }\n\n /**\n * Queries engine to determine maximum quote amount for minting NLP.\n *\n * @param params\n */\n async getMaxMintNlpAmount(params: GetEngineMaxMintNlpAmountParams) {\n return this.context.engineClient.getMaxMintNlpAmount(params);\n }\n\n /**\n * Helper to get current token balance in the user's wallet (i.e. not in a Nado subaccount)\n */\n async getTokenWalletBalance({\n address,\n ...rest\n }: GetTokenWalletBalanceParams): Promise<bigint> {\n const token = await this.getTokenContractForProduct(rest);\n return token.read.balanceOf([getValidatedAddress(address)]);\n }\n\n /**\n * Helper to get current token allowance\n */\n async getTokenAllowance({\n address,\n ...rest\n }: GetTokenAllowanceParams): Promise<BigNumber> {\n const token = await this.getTokenContractForProduct(rest);\n return toBigNumber(\n await token.read.allowance([\n getValidatedAddress(address),\n this.getEndpointAddress(),\n ]),\n );\n }\n}\n"],"mappings":";;;;AASA,IAAa,eAAb,cAAkCA,8BAAAA,YAAY;;;;;CAK5C,MAAM,mBAAmB,QAAwC;EAC/D,OAAO,KAAK,QAAQ,aAAa,mBAAmB,MAAM;CAC5D;;;;;;CAOA,MAAM,oBAAoB,QAAyC;EACjE,OAAO,KAAK,QAAQ,aAAa,oBAAoB,MAAM;CAC7D;;;;CAKA,MAAM,sBAAsB,EAC1B,SACA,GAAG,QAC4C;EAE/C,QAAO,MADa,KAAK,2BAA2B,IAAI,GAC3C,KAAK,UAAU,EAAA,GAAA,eAAA,qBAAqB,OAAO,CAAC,CAAC;CAC5D;;;;CAKA,MAAM,kBAAkB,EACtB,SACA,GAAG,QAC2C;EAE9C,QAAA,GAAA,eAAA,aACE,OAAM,MAFY,KAAK,2BAA2B,IAAI,GAE1C,KAAK,UAAU,EAAA,GAAA,eAAA,qBACL,OAAO,GAC3B,KAAK,mBAAmB,CAC1B,CAAC,CACH;CACF;AACF"}
|
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { BaseSpotAPI } from './BaseSpotAPI.cjs';
|
|
4
|
-
import { GetTokenWalletBalanceParams, GetTokenAllowanceParams } from './types.cjs';
|
|
5
|
-
import '@nadohq/shared';
|
|
6
|
-
import '../base.cjs';
|
|
7
|
-
import '../../context.cjs';
|
|
8
|
-
import '@nadohq/indexer-client';
|
|
9
|
-
import '@nadohq/trigger-client';
|
|
10
|
-
import 'viem';
|
|
11
|
-
import '../types.cjs';
|
|
12
|
-
|
|
13
|
-
declare class SpotQueryAPI extends BaseSpotAPI {
|
|
14
|
-
/**
|
|
15
|
-
* Gets the estimated max withdrawable amount for a product
|
|
16
|
-
* @param params
|
|
17
|
-
*/
|
|
18
|
-
getMaxWithdrawable(params: GetEngineMaxWithdrawableParams): Promise<BigNumber__default>;
|
|
19
|
-
/**
|
|
20
|
-
* Queries engine to determine maximum quote amount for minting NLP.
|
|
21
|
-
*
|
|
22
|
-
* @param params
|
|
23
|
-
*/
|
|
24
|
-
getMaxMintNlpAmount(params: GetEngineMaxMintNlpAmountParams): Promise<BigNumber__default>;
|
|
25
|
-
/**
|
|
26
|
-
* Helper to get current token balance in the user's wallet (i.e. not in a Nado subaccount)
|
|
27
|
-
*/
|
|
28
|
-
getTokenWalletBalance({ address, ...rest }: GetTokenWalletBalanceParams): Promise<bigint>;
|
|
29
|
-
/**
|
|
30
|
-
* Helper to get current token allowance
|
|
31
|
-
*/
|
|
32
|
-
getTokenAllowance({ address, ...rest }: GetTokenAllowanceParams): Promise<BigNumber__default>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { SpotQueryAPI };
|
|
1
|
+
import { t as SpotQueryAPI } from "../../SpotQueryAPI-DS85MzQB.cjs";
|
|
2
|
+
export { SpotQueryAPI };
|