@decibeltrade/sdk 0.3.1 → 0.4.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/abi/json/netna.json +792 -289
- package/dist/abi/json/testnet.json +7 -6
- package/dist/admin.d.ts +36 -0
- package/dist/admin.d.ts.map +1 -1
- package/dist/admin.js +84 -0
- package/dist/base.d.ts +1 -6
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +13 -23
- package/dist/constants.d.ts +10 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +21 -6
- package/dist/fee-pay.d.ts +3 -3
- package/dist/fee-pay.d.ts.map +1 -1
- package/dist/fee-pay.js +26 -49
- package/dist/gas/gas-price-manager.d.ts.map +1 -1
- package/dist/gas/gas-price-manager.js +3 -1
- package/dist/read/account-overview/account-overview.reader.d.ts +2 -0
- package/dist/read/account-overview/account-overview.reader.d.ts.map +1 -1
- package/dist/read/account-overview/account-overview.types.d.ts +4 -0
- package/dist/read/account-overview/account-overview.types.d.ts.map +1 -1
- package/dist/read/account-overview/account-overview.types.js +5 -0
- package/dist/read/action-utils.d.ts +12 -0
- package/dist/read/action-utils.d.ts.map +1 -0
- package/dist/read/action-utils.js +13 -0
- package/dist/read/base-reader.d.ts +1 -0
- package/dist/read/base-reader.d.ts.map +1 -1
- package/dist/read/base-reader.js +15 -0
- package/dist/read/base-reader.test.d.ts +2 -0
- package/dist/read/base-reader.test.d.ts.map +1 -0
- package/dist/read/base-reader.test.js +68 -0
- package/dist/read/global-points-stats/global-points-stats.reader.d.ts +9 -0
- package/dist/read/global-points-stats/global-points-stats.reader.d.ts.map +1 -0
- package/dist/read/global-points-stats/global-points-stats.reader.js +12 -0
- package/dist/read/global-points-stats/global-points-stats.types.d.ts +9 -0
- package/dist/read/global-points-stats/global-points-stats.types.d.ts.map +1 -0
- package/dist/read/global-points-stats/global-points-stats.types.js +5 -0
- package/dist/read/index.d.ts +13 -0
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +23 -2
- package/dist/read/market-depth/market-depth.reader.d.ts +1 -18
- package/dist/read/market-depth/market-depth.reader.d.ts.map +1 -1
- package/dist/read/market-depth/market-depth.reader.js +18 -20
- package/dist/read/market-depth/market-depth.types.d.ts +4 -2
- package/dist/read/market-depth/market-depth.types.d.ts.map +1 -1
- package/dist/read/market-depth/market-depth.types.js +3 -1
- package/dist/read/market-trades/market-trades.reader.d.ts +0 -1
- package/dist/read/market-trades/market-trades.reader.d.ts.map +1 -1
- package/dist/read/market-trades/market-trades.types.d.ts +0 -3
- package/dist/read/market-trades/market-trades.types.d.ts.map +1 -1
- package/dist/read/market-trades/market-trades.types.js +0 -1
- package/dist/read/points-leaderboard/points-leaderboard.reader.d.ts +21 -0
- package/dist/read/points-leaderboard/points-leaderboard.reader.d.ts.map +1 -0
- package/dist/read/points-leaderboard/points-leaderboard.reader.js +23 -0
- package/dist/read/points-leaderboard/points-leaderboard.types.d.ts +30 -0
- package/dist/read/points-leaderboard/points-leaderboard.types.d.ts.map +1 -0
- package/dist/read/points-leaderboard/points-leaderboard.types.js +11 -0
- package/dist/read/portfolio-chart/portfolio-chart.types.d.ts +1 -1
- package/dist/read/portfolio-chart/portfolio-chart.types.d.ts.map +1 -1
- package/dist/read/referrals/referrals.reader.d.ts +98 -0
- package/dist/read/referrals/referrals.reader.d.ts.map +1 -0
- package/dist/read/referrals/referrals.reader.js +92 -0
- package/dist/read/referrals/referrals.types.d.ts +136 -0
- package/dist/read/referrals/referrals.types.d.ts.map +1 -0
- package/dist/read/referrals/referrals.types.js +85 -0
- package/dist/read/streaks/streaks.reader.d.ts +19 -0
- package/dist/read/streaks/streaks.reader.d.ts.map +1 -0
- package/dist/read/streaks/streaks.reader.js +19 -0
- package/dist/read/streaks/streaks.types.d.ts +17 -0
- package/dist/read/streaks/streaks.types.d.ts.map +1 -0
- package/dist/read/streaks/streaks.types.js +10 -0
- package/dist/read/tier/tier.reader.d.ts +21 -0
- package/dist/read/tier/tier.reader.d.ts.map +1 -0
- package/dist/read/tier/tier.reader.js +19 -0
- package/dist/read/tier/tier.types.d.ts +25 -0
- package/dist/read/tier/tier.types.d.ts.map +1 -0
- package/dist/read/tier/tier.types.js +13 -0
- package/dist/read/trading-amps/trading-amps.reader.d.ts +18 -0
- package/dist/read/trading-amps/trading-amps.reader.d.ts.map +1 -0
- package/dist/read/trading-amps/trading-amps.reader.js +23 -0
- package/dist/read/trading-amps/trading-amps.types.d.ts +25 -0
- package/dist/read/trading-amps/trading-amps.types.d.ts.map +1 -0
- package/dist/read/trading-amps/trading-amps.types.js +10 -0
- package/dist/read/types.d.ts +6 -0
- package/dist/read/types.d.ts.map +1 -1
- package/dist/read/types.js +6 -0
- package/dist/read/user-funding-history/user-funding-history.reader.d.ts +1 -2
- package/dist/read/user-funding-history/user-funding-history.reader.d.ts.map +1 -1
- package/dist/read/user-funding-history/user-funding-history.types.d.ts +8 -4
- package/dist/read/user-funding-history/user-funding-history.types.d.ts.map +1 -1
- package/dist/read/user-funding-history/user-funding-history.types.js +1 -2
- package/dist/read/user-notifications/user-notifications.types.d.ts +0 -2
- package/dist/read/user-notifications/user-notifications.types.d.ts.map +1 -1
- package/dist/read/user-open-orders/user-open-orders.reader.d.ts +0 -2
- package/dist/read/user-open-orders/user-open-orders.reader.d.ts.map +1 -1
- package/dist/read/user-open-orders/user-open-orders.types.d.ts +0 -6
- package/dist/read/user-open-orders/user-open-orders.types.d.ts.map +1 -1
- package/dist/read/user-open-orders/user-open-orders.types.js +0 -2
- package/dist/read/user-order-history/user-order-history.reader.d.ts +0 -2
- package/dist/read/user-order-history/user-order-history.reader.d.ts.map +1 -1
- package/dist/read/user-order-history/user-order-history.types.d.ts +0 -6
- package/dist/read/user-order-history/user-order-history.types.d.ts.map +1 -1
- package/dist/read/user-order-history/user-order-history.types.js +0 -2
- package/dist/read/user-positions/user-positions.reader.d.ts +1 -0
- package/dist/read/user-positions/user-positions.reader.d.ts.map +1 -1
- package/dist/read/user-positions/user-positions.types.d.ts +220 -10
- package/dist/read/user-positions/user-positions.types.d.ts.map +1 -1
- package/dist/read/user-positions/user-positions.types.js +1 -0
- package/dist/read/user-trade-history/user-trade-history.reader.d.ts +5 -2
- package/dist/read/user-trade-history/user-trade-history.reader.d.ts.map +1 -1
- package/dist/read/user-trade-history/user-trade-history.types.d.ts +36 -9
- package/dist/read/user-trade-history/user-trade-history.types.d.ts.map +1 -1
- package/dist/read/user-trade-history/user-trade-history.types.js +4 -1
- package/dist/read/vaults/vaults.reader.d.ts +2 -0
- package/dist/read/vaults/vaults.reader.d.ts.map +1 -1
- package/dist/read/vaults/vaults.reader.js +4 -0
- package/dist/read/vaults/vaults.types.d.ts +18 -0
- package/dist/read/vaults/vaults.types.d.ts.map +1 -1
- package/dist/read/vaults/vaults.types.js +17 -0
- package/dist/read/ws-subscription.d.ts +1 -1
- package/dist/read/ws-subscription.d.ts.map +1 -1
- package/dist/read/ws-subscription.js +9 -1
- package/dist/release-config.d.ts +2 -0
- package/dist/release-config.d.ts.map +1 -1
- package/dist/release-config.js +6 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/write.d.ts +12 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +11 -1
- package/package.json +1 -1
- package/readme.md +7 -48
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"packageAddress": "0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f",
|
|
3
3
|
"network": "testnet",
|
|
4
4
|
"fullnodeUrl": "https://api.testnet.aptoslabs.com/v1",
|
|
5
|
-
"fetchedAt": "2026-02-
|
|
5
|
+
"fetchedAt": "2026-02-14T00:08:07.405Z",
|
|
6
6
|
"abis": {
|
|
7
7
|
"0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::admin_apis::initialize": {
|
|
8
8
|
"name": "initialize",
|
|
@@ -138,7 +138,8 @@
|
|
|
138
138
|
"generic_type_params": [],
|
|
139
139
|
"params": [
|
|
140
140
|
"&signer",
|
|
141
|
-
"0x1::object::Object<0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::perp_market::PerpMarket>"
|
|
141
|
+
"0x1::object::Object<0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::perp_market::PerpMarket>",
|
|
142
|
+
"u64"
|
|
142
143
|
],
|
|
143
144
|
"return": []
|
|
144
145
|
},
|
|
@@ -360,8 +361,8 @@
|
|
|
360
361
|
],
|
|
361
362
|
"return": []
|
|
362
363
|
},
|
|
363
|
-
"0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::admin_apis::
|
|
364
|
-
"name": "
|
|
364
|
+
"0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::admin_apis::set_market_cooldown_period_micros": {
|
|
365
|
+
"name": "set_market_cooldown_period_micros",
|
|
365
366
|
"visibility": "private",
|
|
366
367
|
"is_entry": true,
|
|
367
368
|
"is_view": false,
|
|
@@ -1848,8 +1849,8 @@
|
|
|
1848
1849
|
"vector<address>"
|
|
1849
1850
|
]
|
|
1850
1851
|
},
|
|
1851
|
-
"0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::perp_engine::
|
|
1852
|
-
"name": "
|
|
1852
|
+
"0x952535c3049e52f195f26798c2f1340d7dd5100edbe0f464e520a974d16fbe9f::perp_engine::market_cooldown_period_micros": {
|
|
1853
|
+
"name": "market_cooldown_period_micros",
|
|
1853
1854
|
"visibility": "public",
|
|
1854
1855
|
"is_entry": false,
|
|
1855
1856
|
"is_view": true,
|
package/dist/admin.d.ts
CHANGED
|
@@ -30,5 +30,41 @@ export declare class DecibelAdminDex extends BaseSDK {
|
|
|
30
30
|
* @returns The balance of USDC for the account
|
|
31
31
|
*/
|
|
32
32
|
usdcBalance(addr: AccountAddress): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the max open interest for a market (unit-based)
|
|
35
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
36
|
+
* @returns The max open interest in szDecimals units as a string to preserve precision
|
|
37
|
+
*/
|
|
38
|
+
getMaxOpenInterest(marketName: string): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* Decrease the max open interest for a market (unit-based)
|
|
41
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
42
|
+
* @param newOpenInterest The new max open interest in szDecimals units (must be lower than current)
|
|
43
|
+
*/
|
|
44
|
+
decreaseMarketOpenInterest(marketName: string, newOpenInterest: number | bigint): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* Increase the max open interest for a market (unit-based)
|
|
47
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
48
|
+
* @param newOpenInterest The new max open interest in szDecimals units (must be higher than current)
|
|
49
|
+
*/
|
|
50
|
+
increaseMarketOpenInterest(marketName: string, newOpenInterest: number | bigint): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Get the max notional open interest for a market
|
|
53
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
54
|
+
* @returns The max notional open interest in collateral units (USDC decimals) as a string to preserve precision for large values
|
|
55
|
+
*/
|
|
56
|
+
getMaxNotionalOpenInterest(marketName: string): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Decrease the max notional open interest for a market
|
|
59
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
60
|
+
* @param newNotionalOpenInterest The new max notional open interest in collateral units (must be lower than current)
|
|
61
|
+
*/
|
|
62
|
+
decreaseMarketNotionalOpenInterest(marketName: string, newNotionalOpenInterest: number | bigint): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
63
|
+
/**
|
|
64
|
+
* Increase the max notional open interest for a market
|
|
65
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
66
|
+
* @param newNotionalOpenInterest The new max notional open interest in collateral units (must be higher than current)
|
|
67
|
+
*/
|
|
68
|
+
increaseMarketNotionalOpenInterest(marketName: string, newNotionalOpenInterest: number | bigint): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
33
69
|
}
|
|
34
70
|
//# sourceMappingURL=admin.d.ts.map
|
package/dist/admin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGjC,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;OAEG;IACG,UAAU,CAAC,mBAAmB,EAAE,MAAM,EAAE,sBAAsB,EAAE,MAAM;IAQ5E,uBAAuB,IAAI,cAAc;IAanC,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAuB3E,8BAA8B,CAAC,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM;IAQhF,gDAAgD,CACpD,YAAY,EAAE,MAAM,EACpB,qCAAqC,EAAE,OAAO;IAS1C,4BAA4B,CAAC,qBAAqB,EAAE,MAAM;IAQ1D,qBAAqB,CAAC,cAAc,EAAE,MAAM;IAQ5C,kBAAkB,CAAC,cAAc,EAAE,MAAM;IAQzC,qBAAqB,CAAC,cAAc,EAAE,MAAM;IAQ5C,gCAAgC,CACpC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,gBAAgB,EAAE,MAAM,EACxB,mBAAmB,UAAO,EAC1B,oBAAoB,SAAI,EACxB,kBAAkB,SAAK;IAqBnB,4BAA4B,CAChC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,M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max open interest for a market (unit-based)
|
|
242
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
243
|
+
* @returns The max open interest in szDecimals units as a string to preserve precision
|
|
244
|
+
*/
|
|
245
|
+
async getMaxOpenInterest(marketName) {
|
|
246
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
247
|
+
const result = await this.aptos.view({
|
|
248
|
+
payload: {
|
|
249
|
+
function: `${this.config.deployment.package}::perp_engine::get_max_open_interest`,
|
|
250
|
+
typeArguments: [],
|
|
251
|
+
functionArguments: [marketAddr.toString()],
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
return result[0];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Decrease the max open interest for a market (unit-based)
|
|
258
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
259
|
+
* @param newOpenInterest The new max open interest in szDecimals units (must be lower than current)
|
|
260
|
+
*/
|
|
261
|
+
async decreaseMarketOpenInterest(marketName, newOpenInterest) {
|
|
262
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
263
|
+
return await this.sendTx({
|
|
264
|
+
function: `${this.config.deployment.package}::admin_apis::decrease_market_open_interest`,
|
|
265
|
+
typeArguments: [],
|
|
266
|
+
functionArguments: [marketAddr.toString(), newOpenInterest.toString()],
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Increase the max open interest for a market (unit-based)
|
|
271
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
272
|
+
* @param newOpenInterest The new max open interest in szDecimals units (must be higher than current)
|
|
273
|
+
*/
|
|
274
|
+
async increaseMarketOpenInterest(marketName, newOpenInterest) {
|
|
275
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
276
|
+
return await this.sendTx({
|
|
277
|
+
function: `${this.config.deployment.package}::admin_apis::increase_market_open_interest`,
|
|
278
|
+
typeArguments: [],
|
|
279
|
+
functionArguments: [marketAddr.toString(), newOpenInterest.toString()],
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Get the max notional open interest for a market
|
|
284
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
285
|
+
* @returns The max notional open interest in collateral units (USDC decimals) as a string to preserve precision for large values
|
|
286
|
+
*/
|
|
287
|
+
async getMaxNotionalOpenInterest(marketName) {
|
|
288
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
289
|
+
const result = await this.aptos.view({
|
|
290
|
+
payload: {
|
|
291
|
+
function: `${this.config.deployment.package}::perp_engine::get_max_notional_open_interest`,
|
|
292
|
+
typeArguments: [],
|
|
293
|
+
functionArguments: [marketAddr.toString()],
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
return result[0];
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Decrease the max notional open interest for a market
|
|
300
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
301
|
+
* @param newNotionalOpenInterest The new max notional open interest in collateral units (must be lower than current)
|
|
302
|
+
*/
|
|
303
|
+
async decreaseMarketNotionalOpenInterest(marketName, newNotionalOpenInterest) {
|
|
304
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
305
|
+
return await this.sendTx({
|
|
306
|
+
function: `${this.config.deployment.package}::admin_apis::decrease_market_notional_open_interest`,
|
|
307
|
+
typeArguments: [],
|
|
308
|
+
functionArguments: [marketAddr.toString(), newNotionalOpenInterest.toString()],
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Increase the max notional open interest for a market
|
|
313
|
+
* @param marketName The market name (e.g., "BTC/USD")
|
|
314
|
+
* @param newNotionalOpenInterest The new max notional open interest in collateral units (must be higher than current)
|
|
315
|
+
*/
|
|
316
|
+
async increaseMarketNotionalOpenInterest(marketName, newNotionalOpenInterest) {
|
|
317
|
+
const marketAddr = getMarketAddr(marketName, this.config.deployment.perpEngineGlobal);
|
|
318
|
+
return await this.sendTx({
|
|
319
|
+
function: `${this.config.deployment.package}::admin_apis::increase_market_notional_open_interest`,
|
|
320
|
+
typeArguments: [],
|
|
321
|
+
functionArguments: [marketAddr.toString(), newNotionalOpenInterest.toString()],
|
|
322
|
+
});
|
|
323
|
+
}
|
|
240
324
|
}
|
package/dist/base.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { DecibelConfig } from "./constants";
|
|
|
3
3
|
import { GasPriceManager } from "./gas/gas-price-manager";
|
|
4
4
|
export interface Options {
|
|
5
5
|
skipSimulate?: boolean;
|
|
6
|
-
noFeePayer?: boolean;
|
|
7
6
|
nodeApiKey?: string;
|
|
8
7
|
gasPriceManager?: GasPriceManager;
|
|
9
8
|
/**
|
|
@@ -20,11 +19,7 @@ export declare class BaseSDK {
|
|
|
20
19
|
readonly account: Account;
|
|
21
20
|
readonly aptos: Aptos;
|
|
22
21
|
readonly skipSimulate: boolean;
|
|
23
|
-
readonly
|
|
24
|
-
/**
|
|
25
|
-
* Whether we're using the new GasStationClient (API key based) vs legacy gasStationUrl
|
|
26
|
-
*/
|
|
27
|
-
private readonly useGasStationClient;
|
|
22
|
+
private readonly useGasStation;
|
|
28
23
|
private readonly chainId;
|
|
29
24
|
private readonly abi;
|
|
30
25
|
private readonly gasPriceManager;
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,cAAc,EACd,oBAAoB,EACpB,KAAK,EAGL,mCAAmC,EAGnC,0BAA0B,EAC1B,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,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R,MAAM,CAAC,OAAO,EAAE,mCAAmC,EAAE,eAAe,CAAC,EAAE,OAAO;IA2DvF,2BAA2B,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM;CAOjE"}
|
package/dist/base.js
CHANGED
|
@@ -3,7 +3,6 @@ import { Aptos, AptosConfig, } from "@aptos-labs/ts-sdk";
|
|
|
3
3
|
import netnaAbis from "./abi/json/netna.json";
|
|
4
4
|
import testnetAbis from "./abi/json/testnet.json";
|
|
5
5
|
import { NETNA_CONFIG, TESTNET_CONFIG } from "./constants";
|
|
6
|
-
import { submitFeePaidTransaction } from "./fee-pay";
|
|
7
6
|
import { buildSimpleTransactionSync } from "./transaction-builder";
|
|
8
7
|
import { generateRandomReplayProtectionNonce, getPrimarySubaccountAddr } from "./utils";
|
|
9
8
|
const chainIdToAbi = {};
|
|
@@ -16,11 +15,7 @@ export class BaseSDK {
|
|
|
16
15
|
account;
|
|
17
16
|
aptos;
|
|
18
17
|
skipSimulate;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Whether we're using the new GasStationClient (API key based) vs legacy gasStationUrl
|
|
22
|
-
*/
|
|
23
|
-
useGasStationClient;
|
|
18
|
+
useGasStation;
|
|
24
19
|
chainId;
|
|
25
20
|
abi = netnaAbis;
|
|
26
21
|
gasPriceManager;
|
|
@@ -43,9 +38,8 @@ export class BaseSDK {
|
|
|
43
38
|
this.abi = netnaAbis;
|
|
44
39
|
console.warn("Using NETNA ABI for unsupported chain id, this might cause issues with the transaction builder");
|
|
45
40
|
}
|
|
46
|
-
this.
|
|
47
|
-
|
|
48
|
-
const pluginSettings = this.useGasStationClient && config.gasStationApiKey
|
|
41
|
+
this.useGasStation = !!config.gasStationApiKey;
|
|
42
|
+
const pluginSettings = this.useGasStation && config.gasStationApiKey
|
|
49
43
|
? {
|
|
50
44
|
TRANSACTION_SUBMITTER: new GasStationTransactionSubmitter(new GasStationClient({
|
|
51
45
|
network: config.network,
|
|
@@ -58,7 +52,9 @@ export class BaseSDK {
|
|
|
58
52
|
const aptosConfig = new AptosConfig({
|
|
59
53
|
network: config.network,
|
|
60
54
|
fullnode: config.fullnodeUrl,
|
|
61
|
-
clientConfig:
|
|
55
|
+
clientConfig: config.additionalHeaders
|
|
56
|
+
? { HEADERS: config.additionalHeaders }
|
|
57
|
+
: { API_KEY: opts?.nodeApiKey },
|
|
62
58
|
pluginSettings,
|
|
63
59
|
});
|
|
64
60
|
this.aptos = new Aptos(aptosConfig);
|
|
@@ -71,22 +67,16 @@ export class BaseSDK {
|
|
|
71
67
|
return this.abi.abis[functionId] ?? null;
|
|
72
68
|
}
|
|
73
69
|
async submitTx(transaction, senderAuthenticator) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// Legacy: use custom fee payer service via gasStationUrl
|
|
84
|
-
return await submitFeePaidTransaction(this.config, transaction, senderAuthenticator);
|
|
85
|
-
}
|
|
70
|
+
// When gasStationApiKey is set, the GasStationTransactionSubmitter plugin
|
|
71
|
+
// handles fee payer signing automatically. Otherwise, submits directly (self-pay).
|
|
72
|
+
return await this.aptos.transaction.submit.simple({
|
|
73
|
+
transaction,
|
|
74
|
+
senderAuthenticator,
|
|
75
|
+
});
|
|
86
76
|
}
|
|
87
77
|
async buildTx({ maxGasAmount, gasUnitPrice, ...payload }, sender) {
|
|
88
78
|
const functionAbi = "function" in payload ? this.getABI(payload.function) : undefined;
|
|
89
|
-
const withFeePayer =
|
|
79
|
+
const withFeePayer = this.useGasStation;
|
|
90
80
|
const replayProtectionNonce = generateRandomReplayProtectionNonce();
|
|
91
81
|
// This should never happen, but just in case
|
|
92
82
|
if (!replayProtectionNonce) {
|
package/dist/constants.d.ts
CHANGED
|
@@ -10,18 +10,22 @@ export interface DecibelConfig extends ReleaseConfig {
|
|
|
10
10
|
tradingHttpUrl: string;
|
|
11
11
|
tradingWsUrl: string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Example: "https://api.netna.aptoslabs.com/gs/v1"
|
|
13
|
+
* Base URL for the Geomi Gas Station API.
|
|
14
|
+
* Example: "https://api.testnet.aptoslabs.com/gs/v1"
|
|
16
15
|
*/
|
|
17
16
|
gasStationUrl?: string;
|
|
18
17
|
/**
|
|
19
|
-
* API key for
|
|
18
|
+
* API key for Geomi Gas Station Client.
|
|
20
19
|
* When provided, uses GasStationClient with gasStationUrl as base URL.
|
|
21
20
|
*/
|
|
22
21
|
gasStationApiKey?: string;
|
|
23
22
|
deployment: Deployment;
|
|
24
23
|
chainId?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Additional HTTP headers to include in all requests (Node API, trading API, WebSocket).
|
|
26
|
+
* When set, replaces API key auth. All headers are passed through as-is.
|
|
27
|
+
*/
|
|
28
|
+
additionalHeaders?: Record<string, string>;
|
|
25
29
|
}
|
|
26
30
|
export interface DecibelReaderDeps {
|
|
27
31
|
aptos: Aptos;
|
|
@@ -38,6 +42,8 @@ export interface Deployment {
|
|
|
38
42
|
export declare const NETNA_CONFIG: DecibelConfig;
|
|
39
43
|
export declare const TESTNET_DEPLOYMENT: Deployment;
|
|
40
44
|
export declare const TESTNET_CONFIG: DecibelConfig;
|
|
45
|
+
export declare const PREDEPOSIT_DEPLOYMENT: Deployment;
|
|
46
|
+
export declare const PREDEPOSIT_CONFIG: DecibelConfig;
|
|
41
47
|
export declare const MAINNET_DEPLOYMENT: Deployment;
|
|
42
48
|
export declare const MAINNET_CONFIG: DecibelConfig;
|
|
43
49
|
export declare const LOCAL_CONFIG: DecibelConfig;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,EAAuB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEzF,OAAO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AC,CAAC;CAC5C;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,KAAK,CAAC;IACb,EAAE,EAAE,qBAAqB,CAAC;IAC1B,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAWD,eAAO,MAAM,YAAY,EAAE,aAS1B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,UAKhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAS5B,CAAC;AAIF,eAAO,MAAM,qBAAqB,EAAE,UAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,aAU/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,UAKhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAS5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAO1B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,aAQ3B,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAOnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -19,10 +19,10 @@ const getDeployment = (pkg) => {
|
|
|
19
19
|
};
|
|
20
20
|
export const NETNA_CONFIG = {
|
|
21
21
|
network: Network.CUSTOM,
|
|
22
|
-
fullnodeUrl: "https://api.netna.
|
|
23
|
-
tradingHttpUrl: "https://api.netna.
|
|
24
|
-
tradingWsUrl: "wss://api.netna.
|
|
25
|
-
gasStationUrl: "https://api.netna.
|
|
22
|
+
fullnodeUrl: "https://api.netna.aptoslabs.com/v1",
|
|
23
|
+
tradingHttpUrl: "https://api.netna.aptoslabs.com/decibel",
|
|
24
|
+
tradingWsUrl: "wss://api.netna.aptoslabs.com/decibel/ws",
|
|
25
|
+
gasStationUrl: "https://api.netna.aptoslabs.com/gs/v1",
|
|
26
26
|
deployment: getDeployment(PACKAGE.NETNA),
|
|
27
27
|
chainId: 208,
|
|
28
28
|
...RELEASE_CONFIGS.NETNA,
|
|
@@ -44,6 +44,22 @@ export const TESTNET_CONFIG = {
|
|
|
44
44
|
...RELEASE_CONFIGS.TESTNET,
|
|
45
45
|
};
|
|
46
46
|
const MAINNET_USDC = "0xbae207659db88bea0cbead6da0ed00aac12edcdda169e591cd41c94180b46f3b";
|
|
47
|
+
export const PREDEPOSIT_DEPLOYMENT = {
|
|
48
|
+
package: PACKAGE.PREDEPOSIT,
|
|
49
|
+
usdc: MAINNET_USDC,
|
|
50
|
+
testc: getTestcAddress(PACKAGE.PREDEPOSIT).toString(),
|
|
51
|
+
perpEngineGlobal: getPerpEngineGlobalAddress(PACKAGE.PREDEPOSIT).toString(),
|
|
52
|
+
};
|
|
53
|
+
export const PREDEPOSIT_CONFIG = {
|
|
54
|
+
network: Network.MAINNET,
|
|
55
|
+
fullnodeUrl: "https://api.mainnet.aptoslabs.com/v1",
|
|
56
|
+
tradingHttpUrl: "https://api-http-prod-mainnet-predeposit-asia-northeast1-51995220960.asia-northeast1.run.app",
|
|
57
|
+
tradingWsUrl: "wss://api.mainnet.aptoslabs.com/decibel/ws",
|
|
58
|
+
gasStationUrl: "https://api.mainnet.aptoslabs.com/gs/v1",
|
|
59
|
+
deployment: PREDEPOSIT_DEPLOYMENT,
|
|
60
|
+
chainId: 1,
|
|
61
|
+
...RELEASE_CONFIGS.PREDEPOSIT,
|
|
62
|
+
};
|
|
47
63
|
export const MAINNET_DEPLOYMENT = {
|
|
48
64
|
package: PACKAGE.MAINNET,
|
|
49
65
|
usdc: MAINNET_USDC,
|
|
@@ -65,7 +81,6 @@ export const LOCAL_CONFIG = {
|
|
|
65
81
|
fullnodeUrl: "http://localhost:8080/v1",
|
|
66
82
|
tradingHttpUrl: "http://localhost:8084",
|
|
67
83
|
tradingWsUrl: "ws://localhost:8083",
|
|
68
|
-
gasStationUrl: "http://localhost:8085",
|
|
69
84
|
deployment: getDeployment(PACKAGE.NETNA),
|
|
70
85
|
...RELEASE_CONFIGS.LOCAL,
|
|
71
86
|
};
|
|
@@ -75,7 +90,6 @@ export const DOCKER_CONFIG = {
|
|
|
75
90
|
tradingHttpUrl: "http://trading-api-http:8080",
|
|
76
91
|
// nosemgrep: javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
|
|
77
92
|
tradingWsUrl: "ws://trading-api-ws:8080",
|
|
78
|
-
gasStationUrl: "http://fee-payer:8080",
|
|
79
93
|
deployment: getDeployment(PACKAGE.NETNA),
|
|
80
94
|
...RELEASE_CONFIGS.DOCKER,
|
|
81
95
|
};
|
|
@@ -84,6 +98,7 @@ export const NAMED_CONFIGS = {
|
|
|
84
98
|
local: LOCAL_CONFIG,
|
|
85
99
|
docker: DOCKER_CONFIG,
|
|
86
100
|
testnet: TESTNET_CONFIG,
|
|
101
|
+
predeposit: PREDEPOSIT_CONFIG,
|
|
87
102
|
mainnet: MAINNET_CONFIG,
|
|
88
103
|
};
|
|
89
104
|
export const QUERY_PARAM_KEYS = {
|
package/dist/fee-pay.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { AccountAuthenticator, PendingTransactionResponse, SimpleTransaction } from "@aptos-labs/ts-sdk";
|
|
2
2
|
import { DecibelConfig } from "./constants";
|
|
3
3
|
/**
|
|
4
|
-
* Submit a transaction with fee
|
|
5
|
-
*
|
|
4
|
+
* Submit a transaction with Gas Station fee sponsorship.
|
|
5
|
+
* Requires `gasStationApiKey` in the config.
|
|
6
6
|
*
|
|
7
|
-
* @param config The Decibel configuration
|
|
7
|
+
* @param config The Decibel configuration (must include gasStationApiKey)
|
|
8
8
|
* @param transaction The transaction to submit
|
|
9
9
|
* @param senderAuthenticator The sender's authenticator
|
|
10
10
|
* @returns A promise that resolves to the pending transaction response
|
package/dist/fee-pay.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee-pay.d.ts","sourceRoot":"","sources":["../src/fee-pay.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,oBAAoB,GACxC,OAAO,CAAC,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"fee-pay.d.ts","sourceRoot":"","sources":["../src/fee-pay.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,oBAAoB,GACxC,OAAO,CAAC,0BAA0B,CAAC,CA8BrC"}
|
package/dist/fee-pay.js
CHANGED
|
@@ -1,62 +1,39 @@
|
|
|
1
1
|
import { GasStationClient } from "@aptos-labs/gas-station-client";
|
|
2
2
|
import { TransactionResponseType, } from "@aptos-labs/ts-sdk";
|
|
3
3
|
/**
|
|
4
|
-
* Submit a transaction with fee
|
|
5
|
-
*
|
|
4
|
+
* Submit a transaction with Gas Station fee sponsorship.
|
|
5
|
+
* Requires `gasStationApiKey` in the config.
|
|
6
6
|
*
|
|
7
|
-
* @param config The Decibel configuration
|
|
7
|
+
* @param config The Decibel configuration (must include gasStationApiKey)
|
|
8
8
|
* @param transaction The transaction to submit
|
|
9
9
|
* @param senderAuthenticator The sender's authenticator
|
|
10
10
|
* @returns A promise that resolves to the pending transaction response
|
|
11
11
|
*/
|
|
12
12
|
export async function submitFeePaidTransaction(config, transaction, senderAuthenticator) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const gasStationClient = new GasStationClient({
|
|
16
|
-
network: config.network,
|
|
17
|
-
apiKey: config.gasStationApiKey,
|
|
18
|
-
// Use gasStationUrl as base URL for custom networks like netna
|
|
19
|
-
...(config.gasStationUrl && { baseUrl: config.gasStationUrl }),
|
|
20
|
-
});
|
|
21
|
-
const { transactionHash } = await gasStationClient.signAndSubmitTransaction({
|
|
22
|
-
transaction,
|
|
23
|
-
senderAuthenticator,
|
|
24
|
-
});
|
|
25
|
-
// Build PendingTransactionResponse from SimpleTransaction.rawTransaction
|
|
26
|
-
const rawTxn = transaction.rawTransaction;
|
|
27
|
-
return {
|
|
28
|
-
type: TransactionResponseType.Pending,
|
|
29
|
-
hash: transactionHash,
|
|
30
|
-
sender: rawTxn.sender.toString(),
|
|
31
|
-
sequence_number: rawTxn.sequence_number.toString(),
|
|
32
|
-
max_gas_amount: rawTxn.max_gas_amount.toString(),
|
|
33
|
-
gas_unit_price: rawTxn.gas_unit_price.toString(),
|
|
34
|
-
expiration_timestamp_secs: rawTxn.expiration_timestamp_secs.toString(),
|
|
35
|
-
// Payload not available from gas station response
|
|
36
|
-
payload: {},
|
|
37
|
-
};
|
|
13
|
+
if (!config.gasStationApiKey) {
|
|
14
|
+
throw new Error("gasStationApiKey is required for fee-paid transactions");
|
|
38
15
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const signatureBcs = Array.from(senderAuthenticator.bcsToBytes());
|
|
45
|
-
const transactionBcs = Array.from(transaction.rawTransaction.bcsToBytes());
|
|
46
|
-
const body = JSON.stringify({
|
|
47
|
-
signature: signatureBcs,
|
|
48
|
-
transaction: transactionBcs,
|
|
16
|
+
const gasStationClient = new GasStationClient({
|
|
17
|
+
network: config.network,
|
|
18
|
+
apiKey: config.gasStationApiKey,
|
|
19
|
+
// Use gasStationUrl as base URL for custom networks like netna
|
|
20
|
+
...(config.gasStationUrl && { baseUrl: config.gasStationUrl }),
|
|
49
21
|
});
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"Content-Type": "application/json",
|
|
54
|
-
},
|
|
55
|
-
body,
|
|
22
|
+
const { transactionHash } = await gasStationClient.signAndSubmitTransaction({
|
|
23
|
+
transaction,
|
|
24
|
+
senderAuthenticator,
|
|
56
25
|
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
26
|
+
// Build PendingTransactionResponse from SimpleTransaction.rawTransaction
|
|
27
|
+
const rawTxn = transaction.rawTransaction;
|
|
28
|
+
return {
|
|
29
|
+
type: TransactionResponseType.Pending,
|
|
30
|
+
hash: transactionHash,
|
|
31
|
+
sender: rawTxn.sender.toString(),
|
|
32
|
+
sequence_number: rawTxn.sequence_number.toString(),
|
|
33
|
+
max_gas_amount: rawTxn.max_gas_amount.toString(),
|
|
34
|
+
gas_unit_price: rawTxn.gas_unit_price.toString(),
|
|
35
|
+
expiration_timestamp_secs: rawTxn.expiration_timestamp_secs.toString(),
|
|
36
|
+
// Payload not available from gas station response
|
|
37
|
+
payload: {},
|
|
38
|
+
};
|
|
62
39
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gas-price-manager.d.ts","sourceRoot":"","sources":["../../src/gas/gas-price-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;A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"}
|
|
@@ -10,7 +10,9 @@ export class GasPriceManager {
|
|
|
10
10
|
this.aptos = new Aptos(new AptosConfig({
|
|
11
11
|
network: config.network,
|
|
12
12
|
fullnode: config.fullnodeUrl,
|
|
13
|
-
clientConfig:
|
|
13
|
+
clientConfig: config.additionalHeaders
|
|
14
|
+
? { HEADERS: config.additionalHeaders }
|
|
15
|
+
: { API_KEY: opts?.nodeApiKey },
|
|
14
16
|
}));
|
|
15
17
|
this.refreshIntervalMs = opts?.refreshIntervalMs ?? 60_000; // default to 1 minute
|
|
16
18
|
this.multiplier = opts?.multiplier ?? 2; // default to 2x multilier to ensure we have enough gas for the transactipon
|
|
@@ -29,6 +29,8 @@ export declare class AccountOverviewReader extends BaseReader {
|
|
|
29
29
|
liquidation_fees_paid: number | null;
|
|
30
30
|
liquidation_losses: number | null;
|
|
31
31
|
net_deposits?: number | null | undefined;
|
|
32
|
+
margin_deficit?: number | undefined;
|
|
33
|
+
vault_equity?: number | null | undefined;
|
|
32
34
|
}>;
|
|
33
35
|
/**
|
|
34
36
|
* Subscribe to account overview
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-overview.reader.d.ts","sourceRoot":"","sources":["../../../src/read/account-overview/account-overview.reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAE1B,wBAAwB,EAEzB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,qBAAsB,SAAQ,UAAU;IACnD;;;;OAIG;IACG,SAAS,CAAC,EACd,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACnB,EAAE,0BAA0B
|
|
1
|
+
{"version":3,"file":"account-overview.reader.d.ts","sourceRoot":"","sources":["../../../src/read/account-overview/account-overview.reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,0BAA0B,EAE1B,wBAAwB,EAEzB,MAAM,0BAA0B,CAAC;AAElC,qBAAa,qBAAsB,SAAQ,UAAU;IACnD;;;;OAIG;IACG,SAAS,CAAC,EACd,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,GACnB,EAAE,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;IAgB7B;;;;;OAKG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI;CAKlF"}
|
|
@@ -32,9 +32,11 @@ export declare const AccountOverviewSchema: z.ZodObject<{
|
|
|
32
32
|
total_margin: z.ZodNumber;
|
|
33
33
|
usdc_cross_withdrawable_balance: z.ZodNumber;
|
|
34
34
|
usdc_isolated_withdrawable_balance: z.ZodNumber;
|
|
35
|
+
margin_deficit: z.ZodOptional<z.ZodNumber>;
|
|
35
36
|
realized_pnl: z.ZodNullable<z.ZodNumber>;
|
|
36
37
|
liquidation_fees_paid: z.ZodNullable<z.ZodNumber>;
|
|
37
38
|
liquidation_losses: z.ZodNullable<z.ZodNumber>;
|
|
39
|
+
vault_equity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
38
40
|
}, z.core.$strip>;
|
|
39
41
|
export declare const AccountOverviewWsMessageSchema: z.ZodObject<{
|
|
40
42
|
account_overview: z.ZodObject<{
|
|
@@ -56,9 +58,11 @@ export declare const AccountOverviewWsMessageSchema: z.ZodObject<{
|
|
|
56
58
|
total_margin: z.ZodNumber;
|
|
57
59
|
usdc_cross_withdrawable_balance: z.ZodNumber;
|
|
58
60
|
usdc_isolated_withdrawable_balance: z.ZodNumber;
|
|
61
|
+
margin_deficit: z.ZodOptional<z.ZodNumber>;
|
|
59
62
|
realized_pnl: z.ZodNullable<z.ZodNumber>;
|
|
60
63
|
liquidation_fees_paid: z.ZodNullable<z.ZodNumber>;
|
|
61
64
|
liquidation_losses: z.ZodNullable<z.ZodNumber>;
|
|
65
|
+
vault_equity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
62
66
|
}, z.core.$strip>;
|
|
63
67
|
}, z.core.$strip>;
|
|
64
68
|
export type AccountOverview = z.infer<typeof AccountOverviewSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-overview.types.d.ts","sourceRoot":"","sources":["../../../src/read/account-overview/account-overview.types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"account-overview.types.d.ts","sourceRoot":"","sources":["../../../src/read/account-overview/account-overview.types.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,0BAA2B,SAAQ,eAAe;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BhC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;iBAEzC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC"}
|
|
@@ -26,9 +26,14 @@ export const AccountOverviewSchema = z.object({
|
|
|
26
26
|
total_margin: z.number(),
|
|
27
27
|
usdc_cross_withdrawable_balance: z.number(),
|
|
28
28
|
usdc_isolated_withdrawable_balance: z.number(),
|
|
29
|
+
/** Cross-margin deficit: 0 when healthy, negative when the account has a margin hole.
|
|
30
|
+
* When negative, new deposits partially fill this deficit before becoming available to trade. */
|
|
31
|
+
margin_deficit: z.number().optional(), // TODO: Remove optional once back-end is deployed
|
|
29
32
|
realized_pnl: z.number().nullable(),
|
|
30
33
|
liquidation_fees_paid: z.number().nullable(),
|
|
31
34
|
liquidation_losses: z.number().nullable(),
|
|
35
|
+
/** Total USDC value of vault shares held by this account. NULL when not yet available via WebSocket. */
|
|
36
|
+
vault_equity: z.number().nullable().optional(), // TODO: Remove optional once back-end is deployed
|
|
32
37
|
});
|
|
33
38
|
export const AccountOverviewWsMessageSchema = z.object({
|
|
34
39
|
account_overview: AccountOverviewSchema.omit({ volume: true }),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the position direction from a trade action.
|
|
3
|
+
*
|
|
4
|
+
* @param action - The trade action (e.g., "CloseLong", "OpenShort")
|
|
5
|
+
* @returns The position direction: "Long" or "Short"
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* getPositionDirection("CloseLong") // returns "Long"
|
|
9
|
+
* getPositionDirection("OpenShort") // returns "Short"
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPositionDirection(action: string): "Long" | "Short";
|
|
12
|
+
//# sourceMappingURL=action-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-utils.d.ts","sourceRoot":"","sources":["../../src/read/action-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAErE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the position direction from a trade action.
|
|
3
|
+
*
|
|
4
|
+
* @param action - The trade action (e.g., "CloseLong", "OpenShort")
|
|
5
|
+
* @returns The position direction: "Long" or "Short"
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* getPositionDirection("CloseLong") // returns "Long"
|
|
9
|
+
* getPositionDirection("OpenShort") // returns "Short"
|
|
10
|
+
*/
|
|
11
|
+
export function getPositionDirection(action) {
|
|
12
|
+
return action.includes("Long") ? "Long" : "Short";
|
|
13
|
+
}
|
|
@@ -6,6 +6,7 @@ export interface BaseRequestArgs {
|
|
|
6
6
|
export declare class BaseReader {
|
|
7
7
|
protected readonly deps: DecibelReaderDeps;
|
|
8
8
|
constructor(deps: DecibelReaderDeps);
|
|
9
|
+
private mergeHeaders;
|
|
9
10
|
protected getRequest<TResponseData>(args: Omit<GetRequestArgs<TResponseData>, "apiKey">): Promise<{
|
|
10
11
|
data: TResponseData;
|
|
11
12
|
status: number;
|