@decibeltrade/sdk 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-lint$colon$check.log +5 -0
- package/.turbo/turbo-lint.log +5 -0
- package/decibel_transactions.md +1049 -0
- package/dist/abi/abi-manager.d.ts +13 -0
- package/dist/abi/abi-manager.d.ts.map +1 -0
- package/dist/abi/abi-manager.js +21 -0
- package/dist/abi/abis.json +1322 -0
- package/dist/abi/bytecode-manager.d.ts +57 -0
- package/dist/abi/bytecode-manager.d.ts.map +1 -0
- package/dist/abi/bytecode-manager.js +62 -0
- package/dist/abi/bytecode.json +24 -0
- package/dist/abi/fetch-abis.d.ts +7 -0
- package/dist/abi/fetch-abis.d.ts.map +1 -0
- package/dist/abi/fetch-abis.js +132 -0
- package/dist/abi/fetch-bytecode.d.ts +24 -0
- package/dist/abi/fetch-bytecode.d.ts.map +1 -0
- package/dist/abi/fetch-bytecode.js +123 -0
- package/dist/abi/generate-abis.d.ts +6 -0
- package/dist/abi/generate-abis.d.ts.map +1 -0
- package/dist/abi/generate-abis.js +170 -0
- package/dist/abi/json/netna.json +1323 -0
- package/dist/abi/json/testnet.json +1315 -0
- package/dist/abi/types.d.ts +22 -0
- package/dist/abi/types.d.ts.map +1 -0
- package/dist/abi/types.js +2 -0
- package/dist/admin.d.ts +29 -0
- package/dist/admin.d.ts.map +1 -0
- package/dist/admin.js +203 -0
- package/dist/base.d.ts +42 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +176 -0
- package/dist/constants.d.ts +41 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +78 -0
- package/dist/fee-pay.d.ts +11 -0
- package/dist/fee-pay.d.ts.map +1 -0
- package/dist/fee-pay.js +30 -0
- package/dist/gas/gas-price-manager.d.ts +35 -0
- package/dist/gas/gas-price-manager.d.ts.map +1 -0
- package/dist/gas/gas-price-manager.js +93 -0
- package/dist/gas-price-manager.d.ts +31 -0
- package/dist/gas-price-manager.d.ts.map +1 -0
- package/dist/gas-price-manager.js +84 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/order-event.types.d.ts +55 -0
- package/dist/order-event.types.d.ts.map +1 -0
- package/dist/order-event.types.js +3 -0
- package/dist/order-status.d.ts +43 -0
- package/dist/order-status.d.ts.map +1 -0
- package/dist/order-status.js +86 -0
- package/dist/read/account-overview/account-overview.reader.d.ts +37 -0
- package/dist/read/account-overview/account-overview.reader.d.ts.map +1 -0
- package/dist/read/account-overview/account-overview.reader.js +35 -0
- package/dist/read/account-overview/account-overview.types.d.ts +52 -0
- package/dist/read/account-overview/account-overview.types.d.ts.map +1 -0
- package/dist/read/account-overview/account-overview.types.js +36 -0
- package/dist/read/api-wallets/api-wallets.reader.d.ts +17 -0
- package/dist/read/api-wallets/api-wallets.reader.d.ts.map +1 -0
- package/dist/read/api-wallets/api-wallets.reader.js +27 -0
- package/dist/read/api-wallets/api-wallets.types.d.ts +17 -0
- package/dist/read/api-wallets/api-wallets.types.d.ts.map +1 -0
- package/dist/read/api-wallets/api-wallets.types.js +13 -0
- package/dist/read/base-reader.d.ts +22 -0
- package/dist/read/base-reader.d.ts.map +1 -0
- package/dist/read/base-reader.js +29 -0
- package/dist/read/candlesticks/candlesticks.reader.d.ts +31 -0
- package/dist/read/candlesticks/candlesticks.reader.d.ts.map +1 -0
- package/dist/read/candlesticks/candlesticks.reader.js +43 -0
- package/dist/read/candlesticks/candlesticks.types.d.ts +45 -0
- package/dist/read/candlesticks/candlesticks.types.d.ts.map +1 -0
- package/dist/read/candlesticks/candlesticks.types.js +36 -0
- package/dist/read/delegations/delegations.reader.d.ts +15 -0
- package/dist/read/delegations/delegations.reader.d.ts.map +1 -0
- package/dist/read/delegations/delegations.reader.js +23 -0
- package/dist/read/delegations/delegations.types.d.ts +17 -0
- package/dist/read/delegations/delegations.types.d.ts.map +1 -0
- package/dist/read/delegations/delegations.types.js +13 -0
- package/dist/read/index.d.ts +105 -0
- package/dist/read/index.d.ts.map +1 -0
- package/dist/read/index.js +244 -0
- package/dist/read/leaderboard/leaderboard.reader.d.ts +21 -0
- package/dist/read/leaderboard/leaderboard.reader.d.ts.map +1 -0
- package/dist/read/leaderboard/leaderboard.reader.js +22 -0
- package/dist/read/leaderboard/leaderboard.types.d.ts +27 -0
- package/dist/read/leaderboard/leaderboard.types.d.ts.map +1 -0
- package/dist/read/leaderboard/leaderboard.types.js +14 -0
- package/dist/read/market-contexts/market-contexts.reader.d.ts +22 -0
- package/dist/read/market-contexts/market-contexts.reader.d.ts.map +1 -0
- package/dist/read/market-contexts/market-contexts.reader.js +27 -0
- package/dist/read/market-contexts/market-contexts.types.d.ts +26 -0
- package/dist/read/market-contexts/market-contexts.types.d.ts.map +1 -0
- package/dist/read/market-contexts/market-contexts.types.js +19 -0
- package/dist/read/market-depth/market-depth.reader.d.ts +30 -0
- package/dist/read/market-depth/market-depth.reader.d.ts.map +1 -0
- package/dist/read/market-depth/market-depth.reader.js +46 -0
- package/dist/read/market-depth/market-depth.types.d.ts +20 -0
- package/dist/read/market-depth/market-depth.types.d.ts.map +1 -0
- package/dist/read/market-depth/market-depth.types.js +16 -0
- package/dist/read/market-prices/market-prices.reader.d.ts +44 -0
- package/dist/read/market-prices/market-prices.reader.d.ts.map +1 -0
- package/dist/read/market-prices/market-prices.reader.js +51 -0
- package/dist/read/market-prices/market-prices.types.d.ts +48 -0
- package/dist/read/market-prices/market-prices.types.d.ts.map +1 -0
- package/dist/read/market-prices/market-prices.types.js +26 -0
- package/dist/read/market-trades/market-trades.reader.d.ts +33 -0
- package/dist/read/market-trades/market-trades.reader.d.ts.map +1 -0
- package/dist/read/market-trades/market-trades.reader.js +39 -0
- package/dist/read/market-trades/market-trades.types.d.ts +52 -0
- package/dist/read/market-trades/market-trades.types.d.ts.map +1 -0
- package/dist/read/market-trades/market-trades.types.js +23 -0
- package/dist/read/markets/markets.reader.d.ts +38 -0
- package/dist/read/markets/markets.reader.d.ts.map +1 -0
- package/dist/read/markets/markets.reader.js +80 -0
- package/dist/read/markets/markets.types.d.ts +82 -0
- package/dist/read/markets/markets.types.d.ts.map +1 -0
- package/dist/read/markets/markets.types.js +46 -0
- package/dist/read/pagination.types.d.ts +14 -0
- package/dist/read/pagination.types.d.ts.map +1 -0
- package/dist/read/pagination.types.js +12 -0
- package/dist/read/portfolio-chart/portfolio-chart.reader.d.ts +14 -0
- package/dist/read/portfolio-chart/portfolio-chart.reader.d.ts.map +1 -0
- package/dist/read/portfolio-chart/portfolio-chart.reader.js +21 -0
- package/dist/read/portfolio-chart/portfolio-chart.types.d.ts +14 -0
- package/dist/read/portfolio-chart/portfolio-chart.types.d.ts.map +1 -0
- package/dist/read/portfolio-chart/portfolio-chart.types.js +12 -0
- package/dist/read/public-vaults/public-vaults.reader.d.ts +38 -0
- package/dist/read/public-vaults/public-vaults.reader.d.ts.map +1 -0
- package/dist/read/public-vaults/public-vaults.reader.js +31 -0
- package/dist/read/public-vaults/public-vaults.types.d.ts +62 -0
- package/dist/read/public-vaults/public-vaults.types.d.ts.map +1 -0
- package/dist/read/public-vaults/public-vaults.types.js +33 -0
- package/dist/read/types.d.ts +178 -0
- package/dist/read/types.d.ts.map +1 -0
- package/dist/read/types.js +87 -0
- package/dist/read/user-active-twaps/user-active-twaps.reader.d.ts +31 -0
- package/dist/read/user-active-twaps/user-active-twaps.reader.d.ts.map +1 -0
- package/dist/read/user-active-twaps/user-active-twaps.reader.js +31 -0
- package/dist/read/user-active-twaps/user-active-twaps.types.d.ts +49 -0
- package/dist/read/user-active-twaps/user-active-twaps.types.d.ts.map +1 -0
- package/dist/read/user-active-twaps/user-active-twaps.types.js +25 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.reader.d.ts +31 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.reader.d.ts.map +1 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.reader.js +32 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.types.d.ts +46 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.types.d.ts.map +1 -0
- package/dist/read/user-bulk-orders/user-bulk-orders.types.js +24 -0
- package/dist/read/user-funding-history/user-funding-history.reader.d.ts +28 -0
- package/dist/read/user-funding-history/user-funding-history.reader.d.ts.map +1 -0
- package/dist/read/user-funding-history/user-funding-history.reader.js +32 -0
- package/dist/read/user-funding-history/user-funding-history.types.d.ts +37 -0
- package/dist/read/user-funding-history/user-funding-history.types.d.ts.map +1 -0
- package/dist/read/user-funding-history/user-funding-history.types.js +21 -0
- package/dist/read/user-notifications/user-notifications.reader.d.ts +13 -0
- package/dist/read/user-notifications/user-notifications.reader.d.ts.map +1 -0
- package/dist/read/user-notifications/user-notifications.reader.js +19 -0
- package/dist/read/user-notifications/user-notifications.types.d.ts +49 -0
- package/dist/read/user-notifications/user-notifications.types.d.ts.map +1 -0
- package/dist/read/user-notifications/user-notifications.types.js +18 -0
- package/dist/read/user-open-orders/user-open-orders.reader.d.ts +40 -0
- package/dist/read/user-open-orders/user-open-orders.reader.d.ts.map +1 -0
- package/dist/read/user-open-orders/user-open-orders.reader.js +31 -0
- package/dist/read/user-open-orders/user-open-orders.types.d.ts +76 -0
- package/dist/read/user-open-orders/user-open-orders.types.d.ts.map +1 -0
- package/dist/read/user-open-orders/user-open-orders.types.js +34 -0
- package/dist/read/user-order-history/user-order-history.reader.d.ts +40 -0
- package/dist/read/user-order-history/user-order-history.reader.d.ts.map +1 -0
- package/dist/read/user-order-history/user-order-history.reader.js +28 -0
- package/dist/read/user-order-history/user-order-history.types.d.ts +85 -0
- package/dist/read/user-order-history/user-order-history.types.d.ts.map +1 -0
- package/dist/read/user-order-history/user-order-history.types.js +37 -0
- package/dist/read/user-positions/user-positions.reader.d.ts +37 -0
- package/dist/read/user-positions/user-positions.reader.d.ts.map +1 -0
- package/dist/read/user-positions/user-positions.reader.js +41 -0
- package/dist/read/user-positions/user-positions.types.d.ts +2590 -0
- package/dist/read/user-positions/user-positions.types.d.ts.map +1 -0
- package/dist/read/user-positions/user-positions.types.js +31 -0
- package/dist/read/user-subaccounts/user-subaccounts.reader.d.ts +18 -0
- package/dist/read/user-subaccounts/user-subaccounts.reader.d.ts.map +1 -0
- package/dist/read/user-subaccounts/user-subaccounts.reader.js +28 -0
- package/dist/read/user-subaccounts/user-subaccounts.types.d.ts +21 -0
- package/dist/read/user-subaccounts/user-subaccounts.types.d.ts.map +1 -0
- package/dist/read/user-subaccounts/user-subaccounts.types.js +15 -0
- package/dist/read/user-trade-history/user-trade-history.reader.d.ts +33 -0
- package/dist/read/user-trade-history/user-trade-history.reader.d.ts.map +1 -0
- package/dist/read/user-trade-history/user-trade-history.reader.js +32 -0
- package/dist/read/user-trade-history/user-trade-history.types.d.ts +52 -0
- package/dist/read/user-trade-history/user-trade-history.types.d.ts.map +1 -0
- package/dist/read/user-trade-history/user-trade-history.types.js +26 -0
- package/dist/read/user-vaults/user-vaults.reader.d.ts +26 -0
- package/dist/read/user-vaults/user-vaults.reader.d.ts.map +1 -0
- package/dist/read/user-vaults/user-vaults.reader.js +32 -0
- package/dist/read/user-vaults/user-vaults.types.d.ts +39 -0
- package/dist/read/user-vaults/user-vaults.types.d.ts.map +1 -0
- package/dist/read/user-vaults/user-vaults.types.js +21 -0
- package/dist/read/vault/vault.reader.d.ts +95 -0
- package/dist/read/vault/vault.reader.d.ts.map +1 -0
- package/dist/read/vault/vault.reader.js +168 -0
- package/dist/read/vault/vault.types.d.ts +49 -0
- package/dist/read/vault/vault.types.d.ts.map +1 -0
- package/dist/read/vault/vault.types.js +45 -0
- package/dist/read/vaults/vaults.reader.d.ts +72 -0
- package/dist/read/vaults/vaults.reader.d.ts.map +1 -0
- package/dist/read/vaults/vaults.reader.js +63 -0
- package/dist/read/vaults/vaults.types.d.ts +140 -0
- package/dist/read/vaults/vaults.types.d.ts.map +1 -0
- package/dist/read/vaults/vaults.types.js +71 -0
- package/dist/read/ws-subscription.d.ts +21 -0
- package/dist/read/ws-subscription.d.ts.map +1 -0
- package/dist/read/ws-subscription.js +170 -0
- package/dist/subaccount-types.d.ts +24 -0
- package/dist/subaccount-types.d.ts.map +1 -0
- package/dist/subaccount-types.js +11 -0
- package/dist/transaction-builder.d.ts +14 -0
- package/dist/transaction-builder.d.ts.map +1 -0
- package/dist/transaction-builder.js +40 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.d.ts +56 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +164 -0
- package/dist/vault-types.d.ts +43 -0
- package/dist/vault-types.d.ts.map +1 -0
- package/dist/vault-types.js +11 -0
- package/dist/write.d.ts +271 -0
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +485 -0
- package/eslint.config.mjs +25 -0
- package/package.json +39 -0
- package/readme.md +257 -0
- package/sdk_reference.md +876 -0
- package/src/abi/generate-abis.ts +164 -0
- package/src/abi/json/netna.json +1323 -0
- package/src/abi/json/testnet.json +1315 -0
- package/src/abi/types.ts +23 -0
- package/src/admin.ts +284 -0
- package/src/base.ts +218 -0
- package/src/constants.ts +118 -0
- package/src/fee-pay.ts +39 -0
- package/src/gas/gas-price-manager.ts +115 -0
- package/src/index.ts +10 -0
- package/src/order-event.types.ts +65 -0
- package/src/order-status.ts +89 -0
- package/src/read/account-overview/account-overview.reader.ts +43 -0
- package/src/read/account-overview/account-overview.types.ts +45 -0
- package/src/read/base-reader.ts +41 -0
- package/src/read/candlesticks/candlesticks.reader.ts +61 -0
- package/src/read/candlesticks/candlesticks.types.ts +46 -0
- package/src/read/delegations/delegations.reader.ts +22 -0
- package/src/read/delegations/delegations.types.ts +19 -0
- package/src/read/index.ts +271 -0
- package/src/read/leaderboard/leaderboard.reader.ts +21 -0
- package/src/read/leaderboard/leaderboard.types.ts +26 -0
- package/src/read/market-contexts/market-contexts.reader.ts +26 -0
- package/src/read/market-contexts/market-contexts.types.ts +18 -0
- package/src/read/market-depth/market-depth.reader.ts +60 -0
- package/src/read/market-depth/market-depth.types.ts +24 -0
- package/src/read/market-prices/market-prices.reader.ts +61 -0
- package/src/read/market-prices/market-prices.types.ts +38 -0
- package/src/read/market-trades/market-trades.reader.ts +46 -0
- package/src/read/market-trades/market-trades.types.ts +34 -0
- package/src/read/markets/markets.reader.ts +82 -0
- package/src/read/markets/markets.types.ts +54 -0
- package/src/read/pagination.types.ts +18 -0
- package/src/read/portfolio-chart/portfolio-chart.reader.ts +20 -0
- package/src/read/portfolio-chart/portfolio-chart.types.ts +21 -0
- package/src/read/types.ts +129 -0
- package/src/read/user-active-twaps/user-active-twaps.reader.ts +36 -0
- package/src/read/user-active-twaps/user-active-twaps.types.ts +33 -0
- package/src/read/user-bulk-orders/user-bulk-orders.reader.ts +37 -0
- package/src/read/user-bulk-orders/user-bulk-orders.types.ts +32 -0
- package/src/read/user-funding-history/user-funding-history.reader.ts +38 -0
- package/src/read/user-funding-history/user-funding-history.types.ts +29 -0
- package/src/read/user-notifications/user-notifications.reader.ts +17 -0
- package/src/read/user-notifications/user-notifications.types.ts +61 -0
- package/src/read/user-open-orders/user-open-orders.reader.ts +36 -0
- package/src/read/user-open-orders/user-open-orders.types.ts +42 -0
- package/src/read/user-order-history/user-order-history.reader.ts +34 -0
- package/src/read/user-order-history/user-order-history.types.ts +44 -0
- package/src/read/user-positions/user-positions.reader.ts +55 -0
- package/src/read/user-positions/user-positions.types.ts +43 -0
- package/src/read/user-subaccounts/user-subaccounts.reader.ts +30 -0
- package/src/read/user-subaccounts/user-subaccounts.types.ts +21 -0
- package/src/read/user-trade-history/user-trade-history.reader.ts +38 -0
- package/src/read/user-trade-history/user-trade-history.types.ts +33 -0
- package/src/read/vaults/vaults.reader.ts +79 -0
- package/src/read/vaults/vaults.types.ts +106 -0
- package/src/read/ws-subscription.ts +200 -0
- package/src/subaccount-types.ts +31 -0
- package/src/transaction-builder.ts +75 -0
- package/src/utils.ts +255 -0
- package/src/write.ts +965 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MoveFunction, MoveFunctionId } from "@aptos-labs/ts-sdk";
|
|
2
|
+
export type ABIs = Record<MoveFunctionId, MoveFunction>;
|
|
3
|
+
export interface ABIData {
|
|
4
|
+
packageAddress: string;
|
|
5
|
+
network: string;
|
|
6
|
+
fullnodeUrl: string;
|
|
7
|
+
fetchedAt: string;
|
|
8
|
+
abis: ABIs;
|
|
9
|
+
errors: Array<{
|
|
10
|
+
module: string;
|
|
11
|
+
function: string;
|
|
12
|
+
error: string;
|
|
13
|
+
}>;
|
|
14
|
+
summary: {
|
|
15
|
+
totalModules: number;
|
|
16
|
+
totalFunctions: number;
|
|
17
|
+
successful: number;
|
|
18
|
+
failed: number;
|
|
19
|
+
};
|
|
20
|
+
modules: string[];
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/abi/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC;AAExD,MAAM,WAAW,OAAO;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,KAAK,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;IACH,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
package/dist/admin.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AccountAddress } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { BaseSDK } from "./base";
|
|
3
|
+
export declare class DecibelAdminDex extends BaseSDK {
|
|
4
|
+
/**
|
|
5
|
+
* Initialize the global vault system. Only callable by the admin account.
|
|
6
|
+
*/
|
|
7
|
+
initialize(collateralTokenAddr: string, collateralBalanceDecimals: number, backstopLiquidatorAddr: string): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
8
|
+
getProtocolVaultAddress(): AccountAddress;
|
|
9
|
+
initializeProtocolVault(collateralTokenAddr: string, initialFunding: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
10
|
+
delegateProtocolVaultTradingTo(vaultAddress: string, accountToDelegateTo: string): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
11
|
+
authorizeOracleAndMarkUpdate(internalOracleUpdater: string): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
12
|
+
registerMarketWithInternalOracle(name: string, szDecimals: number, minSize: number, lotSize: number, tickerSize: number, maxOpenInterest: number, maxLeverage: number, taker_in_next_block?: boolean, initial_oracle_price?: number, max_staleness_secs?: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
13
|
+
registerMarketWithPythOracle(name: string, szDecimals: number, minSize: number, lotSize: number, tickerSize: number, maxOpenInterest: number, maxLeverage: number, taker_in_next_block: boolean | undefined, pythIdentifierBytes: number[], pythMaxStalenessSecs: number, pythConfidenceIntervalThreshold: number, pythDecimals: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
14
|
+
registerMarketWithCompositeOraclePrimaryPyth(name: string, szDecimals: number, minSize: number, lotSize: number, tickerSize: number, maxOpenInterest: number, maxLeverage: number, taker_in_next_block: boolean | undefined, pythIdentifierBytes: number[], pythMaxStalenessSecs: number, pythConfidenceIntervalThreshold: number, pythDecimals: number, internalInitialPrice: number, internalMaxStalenessSecs: number, oraclesDeviationBps: number, consecutiveDeviationCount: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
15
|
+
registerMarketWithCompositeOraclePrimaryChainlink(name: string, szDecimals: number, minSize: number, lotSize: number, tickerSize: number, maxOpenInterest: number, maxLeverage: number, taker_in_next_block: boolean | undefined, rescaleDecimals: number, chainlinkFeedIdBytes: number[], chainlinkMaxStalenessSecs: number, internalMaxStalenessSecs: number, internalInitialPrice: number, oraclesDeviationBps: number, consecutiveDeviationCount: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
16
|
+
updateInternalOraclePrice(marketName: string, oraclePrice: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
17
|
+
updatePythOraclePrice(marketName: string, vaa: number[]): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
18
|
+
updatePriceToPythOnly(vaas: number[][]): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
19
|
+
updatePriceToChainlinkOnly(signedReport: number[]): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
20
|
+
mintUsdc(toAddr: AccountAddress, amount: number): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
21
|
+
setPublicMinting(allow: boolean): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the balance of USDC for an account
|
|
24
|
+
* @param addr The account address to get the balance for
|
|
25
|
+
* @returns The balance of USDC for the account
|
|
26
|
+
*/
|
|
27
|
+
usdcBalance(addr: AccountAddress): Promise<number>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +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,CACd,mBAAmB,EAAE,MAAM,EAC3B,yBAAyB,EAAE,MAAM,EACjC,sBAAsB,EAAE,MAAM;IAShC,uBAAuB,IAAI,cAAc;IAanC,uBAAuB,CAAC,mBAAmB,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IAsB3E,8BAA8B,CAAC,YAAY,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM;IAQhF,4BAA4B,CAAC,qBAAqB,EAAE,MAAM;IAQ1D,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,mBAAmB,UAAO,EAC1B,oBAAoB,SAAI,EACxB,kBAAkB,SAAK;IAoBnB,4BAA4B,CAChC,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,mBAAmB,qBAAO,EAC1B,mBAAmB,EAAE,MAAM,EAAE,EAC7B,oBAAoB,EAAE,MAAM,EAC5B,+BAA+B,EAAE,MAAM,EACvC,YAAY,EAAE,MAAM;IAsBhB,4CAA4C,CAChD,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,mBAAmB,qBAAO,EAC1B,mBAAmB,EAAE,MAAM,EAAE,EAC7B,oBAAoB,EAAE,MAAM,EAC5B,+BAA+B,EAAE,MAAM,EACvC,YAAY,EAAE,MAAM,EACpB,oBAAoB,EAAE,MAAM,EAC5B,wBAAwB,EAAE,MAAM,EAChC,mBAAmB,EAAE,MAAM,EAC3B,yBAAyB,EAAE,MAAM;IA0B7B,iDAAiD,CACrD,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,mBAAmB,qBAAO,EAC1B,eAAe,EAAE,MAAM,EACvB,oBAAoB,EAAE,MAAM,EAAE,EAC9B,yBAAyB,EAAE,MAAM,EACjC,wBAAwB,EAAE,MAAM,EAChC,oBAAoB,EAAE,MAAM,EAC5B,mBAAmB,EAAE,MAAM,EAC3B,yBAAyB,EAAE,MAAM;IAyB7B,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IASjE,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE;IASvD,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;IAQtC,0BAA0B,CAAC,YAAY,EAAE,MAAM,EAAE;IAQjD,QAAQ,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM;IAQ/C,gBAAgB,CAAC,KAAK,EAAE,OAAO;IAQrC;;;;OAIG;IACG,WAAW,CAAC,IAAI,EAAE,cAAc;CAUvC"}
|
package/dist/admin.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DecibelAdminDex = void 0;
|
|
4
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
class DecibelAdminDex extends base_1.BaseSDK {
|
|
8
|
+
/**
|
|
9
|
+
* Initialize the global vault system. Only callable by the admin account.
|
|
10
|
+
*/
|
|
11
|
+
async initialize(collateralTokenAddr, collateralBalanceDecimals, backstopLiquidatorAddr) {
|
|
12
|
+
return await this.sendTx({
|
|
13
|
+
function: `${this.config.deployment.package}::admin_apis::initialize`,
|
|
14
|
+
typeArguments: [],
|
|
15
|
+
functionArguments: [collateralTokenAddr, collateralBalanceDecimals, backstopLiquidatorAddr],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
getProtocolVaultAddress() {
|
|
19
|
+
const vaultConfigObjectAddr = (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(this.config.deployment.package), "GlobalVaultConfig");
|
|
20
|
+
const protocolVaultObjectAddr = (0, ts_sdk_1.createObjectAddress)(vaultConfigObjectAddr, "Decibel Protocol Vault");
|
|
21
|
+
return protocolVaultObjectAddr;
|
|
22
|
+
}
|
|
23
|
+
async initializeProtocolVault(collateralTokenAddr, initialFunding) {
|
|
24
|
+
return await this.sendTx({
|
|
25
|
+
function: `${this.config.deployment.package}::vault::create_and_fund_vault`,
|
|
26
|
+
typeArguments: [],
|
|
27
|
+
functionArguments: [
|
|
28
|
+
collateralTokenAddr,
|
|
29
|
+
"Decibel Protocol Vault",
|
|
30
|
+
"(description)",
|
|
31
|
+
[],
|
|
32
|
+
"DPV",
|
|
33
|
+
"",
|
|
34
|
+
"",
|
|
35
|
+
0, // fee_bps
|
|
36
|
+
0, // fee_interval
|
|
37
|
+
3 * 24 * 60 * 60, // contribution_lockup_duration_s
|
|
38
|
+
initialFunding, // initial_funding
|
|
39
|
+
true, // accepts_contributions
|
|
40
|
+
false, // delegate_to_creator
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async delegateProtocolVaultTradingTo(vaultAddress, accountToDelegateTo) {
|
|
45
|
+
return await this.sendTx({
|
|
46
|
+
function: `${this.config.deployment.package}::vault::delegate_dex_actions_to`,
|
|
47
|
+
typeArguments: [],
|
|
48
|
+
functionArguments: [vaultAddress, accountToDelegateTo, undefined],
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async authorizeOracleAndMarkUpdate(internalOracleUpdater) {
|
|
52
|
+
return await this.sendTx({
|
|
53
|
+
function: `${this.config.deployment.package}::admin_apis::add_oracle_and_mark_update_permission`,
|
|
54
|
+
typeArguments: [],
|
|
55
|
+
functionArguments: [internalOracleUpdater],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async registerMarketWithInternalOracle(name, szDecimals, minSize, lotSize, tickerSize, maxOpenInterest, maxLeverage, taker_in_next_block = true, initial_oracle_price = 1, max_staleness_secs = 60) {
|
|
59
|
+
return await this.sendTx({
|
|
60
|
+
function: `${this.config.deployment.package}::admin_apis::register_market_with_internal_oracle`,
|
|
61
|
+
typeArguments: [],
|
|
62
|
+
functionArguments: [
|
|
63
|
+
name,
|
|
64
|
+
szDecimals,
|
|
65
|
+
minSize,
|
|
66
|
+
lotSize,
|
|
67
|
+
tickerSize,
|
|
68
|
+
maxOpenInterest,
|
|
69
|
+
maxLeverage,
|
|
70
|
+
taker_in_next_block,
|
|
71
|
+
initial_oracle_price,
|
|
72
|
+
max_staleness_secs,
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async registerMarketWithPythOracle(name, szDecimals, minSize, lotSize, tickerSize, maxOpenInterest, maxLeverage, taker_in_next_block = true, pythIdentifierBytes, pythMaxStalenessSecs, pythConfidenceIntervalThreshold, pythDecimals) {
|
|
77
|
+
return await this.sendTx({
|
|
78
|
+
function: `${this.config.deployment.package}::admin_apis::register_market_with_pyth_oracle`,
|
|
79
|
+
typeArguments: [],
|
|
80
|
+
functionArguments: [
|
|
81
|
+
name,
|
|
82
|
+
szDecimals,
|
|
83
|
+
minSize,
|
|
84
|
+
lotSize,
|
|
85
|
+
tickerSize,
|
|
86
|
+
maxOpenInterest,
|
|
87
|
+
maxLeverage,
|
|
88
|
+
taker_in_next_block,
|
|
89
|
+
pythIdentifierBytes,
|
|
90
|
+
pythMaxStalenessSecs,
|
|
91
|
+
pythConfidenceIntervalThreshold,
|
|
92
|
+
pythDecimals,
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async registerMarketWithCompositeOraclePrimaryPyth(name, szDecimals, minSize, lotSize, tickerSize, maxOpenInterest, maxLeverage, taker_in_next_block = true, pythIdentifierBytes, pythMaxStalenessSecs, pythConfidenceIntervalThreshold, pythDecimals, internalInitialPrice, internalMaxStalenessSecs, oraclesDeviationBps, consecutiveDeviationCount) {
|
|
97
|
+
return await this.sendTx({
|
|
98
|
+
function: `${this.config.deployment.package}::admin_apis::register_market_with_composite_oracle_primary_pyth`,
|
|
99
|
+
typeArguments: [],
|
|
100
|
+
functionArguments: [
|
|
101
|
+
name,
|
|
102
|
+
szDecimals,
|
|
103
|
+
minSize,
|
|
104
|
+
lotSize,
|
|
105
|
+
tickerSize,
|
|
106
|
+
maxOpenInterest,
|
|
107
|
+
maxLeverage,
|
|
108
|
+
taker_in_next_block,
|
|
109
|
+
pythIdentifierBytes,
|
|
110
|
+
pythMaxStalenessSecs,
|
|
111
|
+
pythConfidenceIntervalThreshold,
|
|
112
|
+
pythDecimals,
|
|
113
|
+
internalInitialPrice,
|
|
114
|
+
internalMaxStalenessSecs,
|
|
115
|
+
oraclesDeviationBps,
|
|
116
|
+
consecutiveDeviationCount,
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async registerMarketWithCompositeOraclePrimaryChainlink(name, szDecimals, minSize, lotSize, tickerSize, maxOpenInterest, maxLeverage, taker_in_next_block = true, rescaleDecimals, chainlinkFeedIdBytes, chainlinkMaxStalenessSecs, internalMaxStalenessSecs, internalInitialPrice, oraclesDeviationBps, consecutiveDeviationCount) {
|
|
121
|
+
return await this.sendTx({
|
|
122
|
+
function: `${this.config.deployment.package}::admin_apis::register_market_with_composite_oracle_primary_chainlink`,
|
|
123
|
+
typeArguments: [],
|
|
124
|
+
functionArguments: [
|
|
125
|
+
name,
|
|
126
|
+
szDecimals,
|
|
127
|
+
minSize,
|
|
128
|
+
lotSize,
|
|
129
|
+
tickerSize,
|
|
130
|
+
maxOpenInterest,
|
|
131
|
+
maxLeverage,
|
|
132
|
+
taker_in_next_block,
|
|
133
|
+
chainlinkFeedIdBytes,
|
|
134
|
+
chainlinkMaxStalenessSecs,
|
|
135
|
+
rescaleDecimals,
|
|
136
|
+
internalInitialPrice,
|
|
137
|
+
internalMaxStalenessSecs,
|
|
138
|
+
oraclesDeviationBps,
|
|
139
|
+
consecutiveDeviationCount,
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async updateInternalOraclePrice(marketName, oraclePrice) {
|
|
144
|
+
const marketAddr = (0, utils_1.getMarketAddr)(marketName, this.config.deployment.perpEngineGlobal);
|
|
145
|
+
return await this.sendTx({
|
|
146
|
+
function: `${this.config.deployment.package}::admin_apis::update_mark_for_internal_oracle`,
|
|
147
|
+
typeArguments: [],
|
|
148
|
+
functionArguments: [marketAddr, oraclePrice, [], true],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async updatePythOraclePrice(marketName, vaa) {
|
|
152
|
+
const marketAddr = (0, utils_1.getMarketAddr)(marketName, this.config.deployment.perpEngineGlobal);
|
|
153
|
+
return await this.sendTx({
|
|
154
|
+
function: `${this.config.deployment.package}::admin_apis::update_mark_for_pyth_oracle`,
|
|
155
|
+
typeArguments: [],
|
|
156
|
+
functionArguments: [marketAddr, vaa, [], true],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async updatePriceToPythOnly(vaas) {
|
|
160
|
+
return await this.sendTx({
|
|
161
|
+
function: `${this.config.deployment.package}::pyth::update_price_feeds_with_funder`,
|
|
162
|
+
typeArguments: [],
|
|
163
|
+
functionArguments: [vaas],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
async updatePriceToChainlinkOnly(signedReport) {
|
|
167
|
+
return await this.sendTx({
|
|
168
|
+
function: `${this.config.deployment.package}::chainlink_state::verify_and_store_single_price`,
|
|
169
|
+
typeArguments: [],
|
|
170
|
+
functionArguments: [signedReport],
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async mintUsdc(toAddr, amount) {
|
|
174
|
+
return await this.sendTx({
|
|
175
|
+
function: `${this.config.deployment.package}::usdc::mint`,
|
|
176
|
+
typeArguments: [],
|
|
177
|
+
functionArguments: [toAddr, amount],
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async setPublicMinting(allow) {
|
|
181
|
+
return await this.sendTx({
|
|
182
|
+
function: `${this.config.deployment.package}::usdc::set_public_minting`,
|
|
183
|
+
typeArguments: [],
|
|
184
|
+
functionArguments: [allow],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Get the balance of USDC for an account
|
|
189
|
+
* @param addr The account address to get the balance for
|
|
190
|
+
* @returns The balance of USDC for the account
|
|
191
|
+
*/
|
|
192
|
+
async usdcBalance(addr) {
|
|
193
|
+
const balance = await this.aptos.view({
|
|
194
|
+
payload: {
|
|
195
|
+
function: `0x1::primary_fungible_store::balance`,
|
|
196
|
+
typeArguments: [`0x1::fungible_asset::Metadata`],
|
|
197
|
+
functionArguments: [addr, this.config.deployment.usdc],
|
|
198
|
+
},
|
|
199
|
+
});
|
|
200
|
+
return balance[0];
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.DecibelAdminDex = DecibelAdminDex;
|
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Account, AccountAddress, AccountAuthenticator, Aptos, InputGenerateTransactionPayloadData, PendingTransactionResponse, SimpleTransaction } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { DecibelConfig } from "./constants";
|
|
3
|
+
import { GasPriceManager } from "./gas/gas-price-manager";
|
|
4
|
+
export interface Options {
|
|
5
|
+
skipSimulate?: boolean;
|
|
6
|
+
noFeePayer?: boolean;
|
|
7
|
+
nodeApiKey?: string;
|
|
8
|
+
gasPriceManager?: GasPriceManager;
|
|
9
|
+
/**
|
|
10
|
+
* Time delta in milliseconds to add to Date.now() for expiration timestamps.
|
|
11
|
+
* Used to sync with server time when client clock is incorrect.
|
|
12
|
+
*/
|
|
13
|
+
timeDeltaMs?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class BaseSDK {
|
|
16
|
+
readonly config: DecibelConfig;
|
|
17
|
+
/**
|
|
18
|
+
* The main account
|
|
19
|
+
*/
|
|
20
|
+
readonly account: Account;
|
|
21
|
+
readonly aptos: Aptos;
|
|
22
|
+
readonly skipSimulate: boolean;
|
|
23
|
+
readonly noFeePayer: boolean;
|
|
24
|
+
private readonly chainId;
|
|
25
|
+
private readonly abi;
|
|
26
|
+
private readonly gasPriceManager;
|
|
27
|
+
/**
|
|
28
|
+
* Time delta in milliseconds to add to Date.now() for expiration timestamps.
|
|
29
|
+
*/
|
|
30
|
+
timeDeltaMs: number;
|
|
31
|
+
constructor(config: DecibelConfig,
|
|
32
|
+
/**
|
|
33
|
+
* The main account
|
|
34
|
+
*/
|
|
35
|
+
account: Account, opts?: Options);
|
|
36
|
+
private getABI;
|
|
37
|
+
private getSimulatedTx;
|
|
38
|
+
submitTx(transaction: SimpleTransaction, senderAuthenticator: AccountAuthenticator): Promise<PendingTransactionResponse>;
|
|
39
|
+
buildTx(payload: InputGenerateTransactionPayloadData, sender: AccountAddress): Promise<SimpleTransaction>;
|
|
40
|
+
protected sendTx(payload: InputGenerateTransactionPayloadData, accountOverride?: Account): Promise<import("@aptos-labs/ts-sdk").CommittedTransactionResponse>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,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;AAE1E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI1D,MAAM,WAAW,OAAO;IACtB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAMD,qBAAa,OAAO;IAahB,QAAQ,CAAC,MAAM,EAAE,aAAa;IAC9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO;IAhB3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAwB;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA8B;IAC9D;;OAEG;IACI,WAAW,EAAE,MAAM,CAAC;gBAGhB,MAAM,EAAE,aAAa;IAC9B;;OAEG;IACM,OAAO,EAAE,OAAO,EACzB,IAAI,CAAC,EAAE,OAAO;IAyBhB,OAAO,CAAC,MAAM;YAIA,cAAc;IAkCf,QAAQ,CACnB,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,oBAAoB,GACxC,OAAO,CAAC,0BAA0B,CAAC;IAWzB,OAAO,CAAC,OAAO,EAAE,mCAAmC,EAAE,MAAM,EAAE,cAAc;cAuDzE,MAAM,CAAC,OAAO,EAAE,mCAAmC,EAAE,eAAe,CAAC,EAAE,OAAO;CA4B/F"}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BaseSDK = void 0;
|
|
7
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
8
|
+
const netna_json_1 = __importDefault(require("./abi/json/netna.json"));
|
|
9
|
+
const testnet_json_1 = __importDefault(require("./abi/json/testnet.json"));
|
|
10
|
+
const constants_1 = require("./constants");
|
|
11
|
+
const fee_pay_1 = require("./fee-pay");
|
|
12
|
+
const transaction_builder_1 = require("./transaction-builder");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const chainIdToAbi = {};
|
|
15
|
+
if (constants_1.NETNA_CONFIG.chainId)
|
|
16
|
+
chainIdToAbi[constants_1.NETNA_CONFIG.chainId] = netna_json_1.default;
|
|
17
|
+
if (constants_1.TESTNET_CONFIG.chainId)
|
|
18
|
+
chainIdToAbi[constants_1.TESTNET_CONFIG.chainId] = testnet_json_1.default;
|
|
19
|
+
class BaseSDK {
|
|
20
|
+
config;
|
|
21
|
+
account;
|
|
22
|
+
aptos;
|
|
23
|
+
skipSimulate;
|
|
24
|
+
noFeePayer;
|
|
25
|
+
chainId;
|
|
26
|
+
abi = netna_json_1.default;
|
|
27
|
+
gasPriceManager;
|
|
28
|
+
/**
|
|
29
|
+
* Time delta in milliseconds to add to Date.now() for expiration timestamps.
|
|
30
|
+
*/
|
|
31
|
+
timeDeltaMs;
|
|
32
|
+
constructor(config,
|
|
33
|
+
/**
|
|
34
|
+
* The main account
|
|
35
|
+
*/
|
|
36
|
+
account, opts) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.account = account;
|
|
39
|
+
const abi = config.chainId ? chainIdToAbi[config.chainId] : null;
|
|
40
|
+
if (abi) {
|
|
41
|
+
this.abi = abi;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.abi = netna_json_1.default;
|
|
45
|
+
console.warn("Using NETNA ABI for unsupported chain id, this might cause issues with the transaction builder");
|
|
46
|
+
}
|
|
47
|
+
const aptosConfig = new ts_sdk_1.AptosConfig({
|
|
48
|
+
network: config.network,
|
|
49
|
+
fullnode: config.fullnodeUrl,
|
|
50
|
+
clientConfig: { API_KEY: opts?.nodeApiKey },
|
|
51
|
+
});
|
|
52
|
+
this.aptos = new ts_sdk_1.Aptos(aptosConfig);
|
|
53
|
+
this.skipSimulate = opts?.skipSimulate ?? false;
|
|
54
|
+
this.noFeePayer = opts?.noFeePayer ?? false;
|
|
55
|
+
this.chainId = config.chainId;
|
|
56
|
+
this.gasPriceManager = opts?.gasPriceManager;
|
|
57
|
+
this.timeDeltaMs = opts?.timeDeltaMs ?? 0;
|
|
58
|
+
}
|
|
59
|
+
getABI(functionId) {
|
|
60
|
+
return this.abi.abis[functionId] ?? null;
|
|
61
|
+
}
|
|
62
|
+
async getSimulatedTx(payload, sender) {
|
|
63
|
+
const transaction = await this.aptos.transaction.build.simple({
|
|
64
|
+
sender,
|
|
65
|
+
data: payload,
|
|
66
|
+
});
|
|
67
|
+
const [sim] = await this.aptos.transaction.simulate.simple({
|
|
68
|
+
transaction,
|
|
69
|
+
options: {
|
|
70
|
+
estimateMaxGasAmount: true,
|
|
71
|
+
estimateGasUnitPrice: true,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
if (typeof sim === "undefined") {
|
|
75
|
+
throw new Error("Transaction simulation returned no results");
|
|
76
|
+
}
|
|
77
|
+
if (!sim.max_gas_amount || !sim.gas_unit_price) {
|
|
78
|
+
throw new Error("Transaction simulation returned no results");
|
|
79
|
+
}
|
|
80
|
+
return await this.aptos.transaction.build.simple({
|
|
81
|
+
sender,
|
|
82
|
+
data: payload,
|
|
83
|
+
options: {
|
|
84
|
+
maxGasAmount: Number(sim.max_gas_amount),
|
|
85
|
+
gasUnitPrice: Number(sim.gas_unit_price),
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
async submitTx(transaction, senderAuthenticator) {
|
|
90
|
+
if (this.noFeePayer) {
|
|
91
|
+
return await this.aptos.transaction.submit.simple({
|
|
92
|
+
transaction,
|
|
93
|
+
senderAuthenticator,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return await (0, fee_pay_1.submitFeePaidTransaction)(this.config, transaction, senderAuthenticator);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async buildTx(payload, sender) {
|
|
101
|
+
const functionAbi = "function" in payload ? this.getABI(payload.function) : undefined;
|
|
102
|
+
const withFeePayer = !this.noFeePayer;
|
|
103
|
+
const replayProtectionNonce = (0, utils_1.generateRandomReplayProtectionNonce)();
|
|
104
|
+
// This should never happen, but just in case
|
|
105
|
+
if (!replayProtectionNonce) {
|
|
106
|
+
throw new Error("Unable to generate replayProtectionNonce");
|
|
107
|
+
}
|
|
108
|
+
let transaction;
|
|
109
|
+
// If we have functionAbi and chainId, we can use the sync function to generate the transaction
|
|
110
|
+
// This is faster than the async function
|
|
111
|
+
if (functionAbi && this.chainId) {
|
|
112
|
+
let gasUnitPrice;
|
|
113
|
+
if (this.gasPriceManager) {
|
|
114
|
+
// 1. Try getting from cache
|
|
115
|
+
// 2. If not available, try fetching from gasmanager, this also sets the gas price in the cache for future use
|
|
116
|
+
gasUnitPrice =
|
|
117
|
+
this.gasPriceManager.getGasPrice() ?? (await this.gasPriceManager.fetchAndSetGasPrice());
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
// 1. Fetch from network, this is a fallback, should only happen if gasPriceManager is not set
|
|
121
|
+
gasUnitPrice = (await this.aptos.getGasPriceEstimation()).gas_estimate;
|
|
122
|
+
}
|
|
123
|
+
transaction = (0, transaction_builder_1.buildSimpleTransactionSync)({
|
|
124
|
+
aptosConfig: this.aptos.config,
|
|
125
|
+
sender,
|
|
126
|
+
data: payload,
|
|
127
|
+
withFeePayer,
|
|
128
|
+
replayProtectionNonce,
|
|
129
|
+
abi: functionAbi,
|
|
130
|
+
chainId: this.chainId,
|
|
131
|
+
gasUnitPrice,
|
|
132
|
+
timeDeltaMs: this.timeDeltaMs,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// This is a fallback, should not happen, but works if due to any issues, functionAbi or chainId is not present
|
|
137
|
+
// @Todo: Pass in Abi ideally, once we update aptos-ts-sdk to not refetch abi if abi is passed in payload
|
|
138
|
+
transaction = await this.aptos.transaction.build.simple({
|
|
139
|
+
sender,
|
|
140
|
+
data: payload,
|
|
141
|
+
withFeePayer,
|
|
142
|
+
options: {
|
|
143
|
+
replayProtectionNonce,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return transaction;
|
|
148
|
+
}
|
|
149
|
+
async sendTx(payload, accountOverride) {
|
|
150
|
+
const signer = accountOverride ?? this.account;
|
|
151
|
+
const sender = signer.accountAddress;
|
|
152
|
+
if (!this.skipSimulate) {
|
|
153
|
+
const transaction = await this.getSimulatedTx(payload, sender);
|
|
154
|
+
const senderAuthenticator = this.aptos.transaction.sign({
|
|
155
|
+
signer,
|
|
156
|
+
transaction,
|
|
157
|
+
});
|
|
158
|
+
const pendingTransaction = await this.submitTx(transaction, senderAuthenticator);
|
|
159
|
+
return await this.aptos.waitForTransaction({
|
|
160
|
+
transactionHash: pendingTransaction.hash,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const transaction = await this.buildTx(payload, sender);
|
|
165
|
+
const senderAuthenticator = this.aptos.transaction.sign({
|
|
166
|
+
signer,
|
|
167
|
+
transaction,
|
|
168
|
+
});
|
|
169
|
+
const pendingTransaction = await this.submitTx(transaction, senderAuthenticator);
|
|
170
|
+
return await this.aptos.waitForTransaction({
|
|
171
|
+
transactionHash: pendingTransaction.hash,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
exports.BaseSDK = BaseSDK;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AccountAddress, Aptos, Network } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { DecibelWsSubscription } from "./read/ws-subscription";
|
|
3
|
+
export declare function getUsdcAddress(publisherAddr: string): AccountAddress;
|
|
4
|
+
export declare function getTestcAddress(publisherAddr: string): AccountAddress;
|
|
5
|
+
export declare function getPerpEngineGlobalAddress(publisherAddr: string): AccountAddress;
|
|
6
|
+
export interface DecibelConfig {
|
|
7
|
+
network: Network;
|
|
8
|
+
fullnodeUrl: string;
|
|
9
|
+
tradingHttpUrl: string;
|
|
10
|
+
tradingWsUrl: string;
|
|
11
|
+
gasStationUrl: string;
|
|
12
|
+
deployment: Deployment;
|
|
13
|
+
chainId?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface DecibelReaderDeps {
|
|
16
|
+
aptos: Aptos;
|
|
17
|
+
ws: DecibelWsSubscription;
|
|
18
|
+
config: DecibelConfig;
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Deployment {
|
|
22
|
+
package: string;
|
|
23
|
+
usdc: string;
|
|
24
|
+
testc: string;
|
|
25
|
+
perpEngineGlobal: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const NETNA_DEPLOYMENT: Deployment;
|
|
28
|
+
export declare const NETNA_CONFIG: DecibelConfig;
|
|
29
|
+
export declare const TESTNET_DEPLOYMENT: Deployment;
|
|
30
|
+
export declare const TESTNET_CONFIG: DecibelConfig;
|
|
31
|
+
export declare const LOCAL_CONFIG: DecibelConfig;
|
|
32
|
+
export declare const DOCKER_CONFIG: DecibelConfig;
|
|
33
|
+
export declare const NAMED_CONFIGS: Record<string, DecibelConfig | undefined>;
|
|
34
|
+
export declare const QUERY_PARAM_KEYS: {
|
|
35
|
+
offset: string;
|
|
36
|
+
limit: string;
|
|
37
|
+
sortKey: string;
|
|
38
|
+
sortDir: string;
|
|
39
|
+
searchTerm: string;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +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,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,kBAKnD;AAED,wBAAgB,eAAe,CAAC,aAAa,EAAE,MAAM,kBAKpD;AAED,wBAAgB,0BAA0B,CAAC,aAAa,EAAE,MAAM,kBAK/D;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;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;AAGD,eAAO,MAAM,gBAAgB,EAAE,UAK9B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,aAQ1B,CAAC;AAGF,eAAO,MAAM,kBAAkB,EAAE,UAKhC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,aAQ5B,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,CAKnE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;CAM5B,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUERY_PARAM_KEYS = exports.NAMED_CONFIGS = exports.DOCKER_CONFIG = exports.LOCAL_CONFIG = exports.TESTNET_CONFIG = exports.TESTNET_DEPLOYMENT = exports.NETNA_CONFIG = exports.NETNA_DEPLOYMENT = void 0;
|
|
4
|
+
exports.getUsdcAddress = getUsdcAddress;
|
|
5
|
+
exports.getTestcAddress = getTestcAddress;
|
|
6
|
+
exports.getPerpEngineGlobalAddress = getPerpEngineGlobalAddress;
|
|
7
|
+
const ts_sdk_1 = require("@aptos-labs/ts-sdk");
|
|
8
|
+
function getUsdcAddress(publisherAddr) {
|
|
9
|
+
return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("USDC"));
|
|
10
|
+
}
|
|
11
|
+
function getTestcAddress(publisherAddr) {
|
|
12
|
+
return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("TESTC"));
|
|
13
|
+
}
|
|
14
|
+
function getPerpEngineGlobalAddress(publisherAddr) {
|
|
15
|
+
return (0, ts_sdk_1.createObjectAddress)(ts_sdk_1.AccountAddress.fromString(publisherAddr), new TextEncoder().encode("GlobalPerpEngine"));
|
|
16
|
+
}
|
|
17
|
+
const NETNA_PACKAGE = "0xb8a5788314451ce4d2fbbad32e1bad88d4184b73943b7fe5166eab93cf1a5a95";
|
|
18
|
+
exports.NETNA_DEPLOYMENT = {
|
|
19
|
+
package: NETNA_PACKAGE,
|
|
20
|
+
usdc: getUsdcAddress(NETNA_PACKAGE).toString(),
|
|
21
|
+
testc: getTestcAddress(NETNA_PACKAGE).toString(),
|
|
22
|
+
perpEngineGlobal: getPerpEngineGlobalAddress(NETNA_PACKAGE).toString(),
|
|
23
|
+
};
|
|
24
|
+
exports.NETNA_CONFIG = {
|
|
25
|
+
network: ts_sdk_1.Network.CUSTOM,
|
|
26
|
+
fullnodeUrl: "https://api.netna.aptoslabs.com/v1",
|
|
27
|
+
tradingHttpUrl: "https://api.netna.aptoslabs.com/decibel",
|
|
28
|
+
tradingWsUrl: "wss://api.netna.aptoslabs.com/decibel/ws",
|
|
29
|
+
gasStationUrl: "https://fee-payer-dev-netna-us-central1-410192433417.us-central1.run.app",
|
|
30
|
+
deployment: exports.NETNA_DEPLOYMENT,
|
|
31
|
+
chainId: 205,
|
|
32
|
+
};
|
|
33
|
+
const TESTNET_PACKAGE = "0x1f513904b7568445e3c291a6c58cb272db017d8a72aea563d5664666221d5f75";
|
|
34
|
+
exports.TESTNET_DEPLOYMENT = {
|
|
35
|
+
package: TESTNET_PACKAGE,
|
|
36
|
+
usdc: getUsdcAddress(TESTNET_PACKAGE).toString(),
|
|
37
|
+
testc: getTestcAddress(TESTNET_PACKAGE).toString(),
|
|
38
|
+
perpEngineGlobal: getPerpEngineGlobalAddress(TESTNET_PACKAGE).toString(),
|
|
39
|
+
};
|
|
40
|
+
exports.TESTNET_CONFIG = {
|
|
41
|
+
network: ts_sdk_1.Network.TESTNET,
|
|
42
|
+
fullnodeUrl: "https://api.testnet.aptoslabs.com/v1",
|
|
43
|
+
tradingHttpUrl: "https://api.testnet.aptoslabs.com/decibel",
|
|
44
|
+
tradingWsUrl: "wss://api-ws-staging-testnet-us-central1-502735673999.us-central1.run.app",
|
|
45
|
+
gasStationUrl: "https://fee-payer-staging-testnet-us-central1-502735673999.us-central1.run.app",
|
|
46
|
+
deployment: exports.TESTNET_DEPLOYMENT,
|
|
47
|
+
chainId: 2,
|
|
48
|
+
};
|
|
49
|
+
exports.LOCAL_CONFIG = {
|
|
50
|
+
network: ts_sdk_1.Network.CUSTOM,
|
|
51
|
+
fullnodeUrl: "http://localhost:8080/v1",
|
|
52
|
+
tradingHttpUrl: "http://localhost:8084",
|
|
53
|
+
tradingWsUrl: "ws://localhost:8083",
|
|
54
|
+
gasStationUrl: "http://localhost:8085",
|
|
55
|
+
deployment: exports.NETNA_DEPLOYMENT,
|
|
56
|
+
};
|
|
57
|
+
exports.DOCKER_CONFIG = {
|
|
58
|
+
network: ts_sdk_1.Network.CUSTOM,
|
|
59
|
+
fullnodeUrl: "http://tradenet:8080/v1",
|
|
60
|
+
tradingHttpUrl: "http://trading-api-http:8080",
|
|
61
|
+
// nosemgrep: javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
|
|
62
|
+
tradingWsUrl: "ws://trading-api-ws:8080",
|
|
63
|
+
gasStationUrl: "http://fee-payer:8080",
|
|
64
|
+
deployment: exports.NETNA_DEPLOYMENT,
|
|
65
|
+
};
|
|
66
|
+
exports.NAMED_CONFIGS = {
|
|
67
|
+
netna: exports.NETNA_CONFIG,
|
|
68
|
+
local: exports.LOCAL_CONFIG,
|
|
69
|
+
docker: exports.DOCKER_CONFIG,
|
|
70
|
+
testnet: exports.TESTNET_CONFIG,
|
|
71
|
+
};
|
|
72
|
+
exports.QUERY_PARAM_KEYS = {
|
|
73
|
+
offset: "offset",
|
|
74
|
+
limit: "limit",
|
|
75
|
+
sortKey: "sort_key",
|
|
76
|
+
sortDir: "sort_dir",
|
|
77
|
+
searchTerm: "search_term",
|
|
78
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AccountAuthenticator, PendingTransactionResponse, SimpleTransaction } from "@aptos-labs/ts-sdk";
|
|
2
|
+
import { DecibelConfig } from "./constants";
|
|
3
|
+
/**
|
|
4
|
+
* Submit a transaction with fee payer support
|
|
5
|
+
* @param config The Decibel configuration containing the gas station URL
|
|
6
|
+
* @param transaction The transaction to submit
|
|
7
|
+
* @param senderAuthenticator The sender's authenticator
|
|
8
|
+
* @returns A promise that resolves to the pending transaction response
|
|
9
|
+
*/
|
|
10
|
+
export declare function submitFeePaidTransaction(config: DecibelConfig, transaction: SimpleTransaction, senderAuthenticator: AccountAuthenticator): Promise<PendingTransactionResponse>;
|
|
11
|
+
//# sourceMappingURL=fee-pay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fee-pay.d.ts","sourceRoot":"","sources":["../src/fee-pay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,iBAAiB,EAC9B,mBAAmB,EAAE,oBAAoB,GACxC,OAAO,CAAC,0BAA0B,CAAC,CAmBrC"}
|
package/dist/fee-pay.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.submitFeePaidTransaction = submitFeePaidTransaction;
|
|
4
|
+
/**
|
|
5
|
+
* Submit a transaction with fee payer support
|
|
6
|
+
* @param config The Decibel configuration containing the gas station URL
|
|
7
|
+
* @param transaction The transaction to submit
|
|
8
|
+
* @param senderAuthenticator The sender's authenticator
|
|
9
|
+
* @returns A promise that resolves to the pending transaction response
|
|
10
|
+
*/
|
|
11
|
+
async function submitFeePaidTransaction(config, transaction, senderAuthenticator) {
|
|
12
|
+
const signatureBcs = Array.from(senderAuthenticator.bcsToBytes());
|
|
13
|
+
const transactionBcs = Array.from(transaction.rawTransaction.bcsToBytes());
|
|
14
|
+
const body = JSON.stringify({
|
|
15
|
+
signature: signatureBcs,
|
|
16
|
+
transaction: transactionBcs,
|
|
17
|
+
});
|
|
18
|
+
const response = await fetch(config.gasStationUrl + "/transactions", {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json",
|
|
22
|
+
},
|
|
23
|
+
body,
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
27
|
+
}
|
|
28
|
+
// TODO(bl): Error handling
|
|
29
|
+
return (await response.json());
|
|
30
|
+
}
|