@perpbrain/sdk 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/cjs/card.d.ts +2 -0
- package/dist/cjs/card.js +311 -0
- package/dist/cjs/cli.d.ts +3 -0
- package/dist/cjs/cli.js +33 -0
- package/dist/cjs/guarded.d.ts +12 -0
- package/dist/cjs/guarded.js +52 -0
- package/dist/cjs/guards.d.ts +154 -0
- package/dist/cjs/guards.js +855 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/receipt.d.ts +13 -0
- package/dist/cjs/receipt.js +660 -0
- package/dist/cjs/study.d.ts +29 -0
- package/dist/cjs/study.js +259 -0
- package/dist/cjs/vendor/costs.d.ts +64 -0
- package/dist/cjs/vendor/costs.js +247 -0
- package/dist/cjs/vendor/execution.d.ts +44 -0
- package/dist/cjs/vendor/execution.js +132 -0
- package/dist/cjs/vendor/fees.d.ts +17 -0
- package/dist/cjs/vendor/fees.js +82 -0
- package/dist/cjs/vendor/funding_adapter.d.ts +11 -0
- package/dist/cjs/vendor/funding_adapter.js +33 -0
- package/dist/cjs/vendor/info.d.ts +24 -0
- package/dist/cjs/vendor/info.js +55 -0
- package/dist/cjs/vendor/queries.d.ts +69 -0
- package/dist/cjs/vendor/queries.js +210 -0
- package/dist/cjs/vendor/rateLimit.d.ts +14 -0
- package/dist/cjs/vendor/rateLimit.js +57 -0
- package/dist/cjs/vendor/simDefaults.d.ts +31 -0
- package/dist/cjs/vendor/simDefaults.js +49 -0
- package/dist/cjs/vendor/simulate.d.ts +130 -0
- package/dist/cjs/vendor/simulate.js +610 -0
- package/dist/esm/card.d.ts +2 -0
- package/dist/esm/card.js +308 -0
- package/dist/esm/cli.d.ts +3 -0
- package/dist/esm/cli.js +31 -0
- package/dist/esm/guarded.d.ts +12 -0
- package/dist/esm/guarded.js +49 -0
- package/dist/esm/guards.d.ts +154 -0
- package/dist/esm/guards.js +841 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/receipt.d.ts +13 -0
- package/dist/esm/receipt.js +653 -0
- package/dist/esm/study.d.ts +29 -0
- package/dist/esm/study.js +249 -0
- package/dist/esm/vendor/costs.d.ts +64 -0
- package/dist/esm/vendor/costs.js +240 -0
- package/dist/esm/vendor/execution.d.ts +44 -0
- package/dist/esm/vendor/execution.js +122 -0
- package/dist/esm/vendor/fees.d.ts +17 -0
- package/dist/esm/vendor/fees.js +74 -0
- package/dist/esm/vendor/funding_adapter.d.ts +11 -0
- package/dist/esm/vendor/funding_adapter.js +30 -0
- package/dist/esm/vendor/info.d.ts +24 -0
- package/dist/esm/vendor/info.js +49 -0
- package/dist/esm/vendor/queries.d.ts +69 -0
- package/dist/esm/vendor/queries.js +196 -0
- package/dist/esm/vendor/rateLimit.d.ts +14 -0
- package/dist/esm/vendor/rateLimit.js +53 -0
- package/dist/esm/vendor/simDefaults.d.ts +31 -0
- package/dist/esm/vendor/simDefaults.js +44 -0
- package/dist/esm/vendor/simulate.d.ts +130 -0
- package/dist/esm/vendor/simulate.js +605 -0
- package/package.json +64 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Read-only and simulation-only SDK surface. */
|
|
2
|
+
export { CODES, HARD_MAX_DAILY_LOSS_PCT, HARD_MAX_OPEN_POSITIONS, HARD_MAX_ORDER_RATE, HARD_MAX_SLIPPAGE_BPS, PRESETS, STALE_BLOCK_MS, STALE_HALT_MS, GuardBlocked, GuardConfigError, GuardLoosenError, GuardSession, defaultGuards, defaultSnapshot, fromConfig, survivalReport, wireCode, } from "./guards.ts";
|
|
3
|
+
export type { GuardCode, GuardLimits, GuardOverrides, GuardResult, Guards, MarketSnapshot, PresetName, SimIntent, SurvivalDay, Violation, } from "./guards.ts";
|
|
4
|
+
export { guardedSimulate } from "./guarded.ts";
|
|
5
|
+
export type { GuardedSimulateResult } from "./guarded.ts";
|
|
6
|
+
export { renderReceiptCard } from "./card.ts";
|
|
7
|
+
export { costBreakdownFromReceipt, RECEIPT_KIND, RECEIPT_STATEMENT, canonical, sha256Json, verifyReceipt } from "./receipt.ts";
|
|
8
|
+
export { executionCost } from "./vendor/costs.ts";
|
|
9
|
+
export type { CostBreakdown } from "./vendor/costs.ts";
|
|
10
|
+
export type { VerifyReport } from "./receipt.ts";
|
|
11
|
+
export { InfoClient } from "./vendor/info.ts";
|
|
12
|
+
export { fees, funding, markets, orderBook, positions } from "./vendor/queries.ts";
|
|
13
|
+
export { simulate } from "./vendor/simulate.ts";
|
|
14
|
+
export type { Bar, Book, Decision, Fill, FillGuard, GuardContext, SimulateResult, } from "./vendor/simulate.ts";
|
|
15
|
+
export declare const READ_AND_SIM_TOOLS: readonly ["markets", "order_book", "funding", "positions", "fees", "simulate", "get_limits", "trigger_kill_switch", "get_cost_breakdown"];
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/** Read-only and simulation-only SDK surface. */
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.READ_AND_SIM_TOOLS = exports.simulate = exports.positions = exports.orderBook = exports.markets = exports.funding = exports.fees = exports.InfoClient = exports.executionCost = exports.verifyReceipt = exports.sha256Json = exports.canonical = exports.RECEIPT_STATEMENT = exports.RECEIPT_KIND = exports.costBreakdownFromReceipt = exports.renderReceiptCard = exports.guardedSimulate = exports.wireCode = exports.survivalReport = exports.fromConfig = exports.defaultSnapshot = exports.defaultGuards = exports.GuardSession = exports.GuardLoosenError = exports.GuardConfigError = exports.GuardBlocked = exports.STALE_HALT_MS = exports.STALE_BLOCK_MS = exports.PRESETS = exports.HARD_MAX_SLIPPAGE_BPS = exports.HARD_MAX_ORDER_RATE = exports.HARD_MAX_OPEN_POSITIONS = exports.HARD_MAX_DAILY_LOSS_PCT = exports.CODES = void 0;
|
|
5
|
+
var guards_ts_1 = require("./guards.js");
|
|
6
|
+
Object.defineProperty(exports, "CODES", { enumerable: true, get: function () { return guards_ts_1.CODES; } });
|
|
7
|
+
Object.defineProperty(exports, "HARD_MAX_DAILY_LOSS_PCT", { enumerable: true, get: function () { return guards_ts_1.HARD_MAX_DAILY_LOSS_PCT; } });
|
|
8
|
+
Object.defineProperty(exports, "HARD_MAX_OPEN_POSITIONS", { enumerable: true, get: function () { return guards_ts_1.HARD_MAX_OPEN_POSITIONS; } });
|
|
9
|
+
Object.defineProperty(exports, "HARD_MAX_ORDER_RATE", { enumerable: true, get: function () { return guards_ts_1.HARD_MAX_ORDER_RATE; } });
|
|
10
|
+
Object.defineProperty(exports, "HARD_MAX_SLIPPAGE_BPS", { enumerable: true, get: function () { return guards_ts_1.HARD_MAX_SLIPPAGE_BPS; } });
|
|
11
|
+
Object.defineProperty(exports, "PRESETS", { enumerable: true, get: function () { return guards_ts_1.PRESETS; } });
|
|
12
|
+
Object.defineProperty(exports, "STALE_BLOCK_MS", { enumerable: true, get: function () { return guards_ts_1.STALE_BLOCK_MS; } });
|
|
13
|
+
Object.defineProperty(exports, "STALE_HALT_MS", { enumerable: true, get: function () { return guards_ts_1.STALE_HALT_MS; } });
|
|
14
|
+
Object.defineProperty(exports, "GuardBlocked", { enumerable: true, get: function () { return guards_ts_1.GuardBlocked; } });
|
|
15
|
+
Object.defineProperty(exports, "GuardConfigError", { enumerable: true, get: function () { return guards_ts_1.GuardConfigError; } });
|
|
16
|
+
Object.defineProperty(exports, "GuardLoosenError", { enumerable: true, get: function () { return guards_ts_1.GuardLoosenError; } });
|
|
17
|
+
Object.defineProperty(exports, "GuardSession", { enumerable: true, get: function () { return guards_ts_1.GuardSession; } });
|
|
18
|
+
Object.defineProperty(exports, "defaultGuards", { enumerable: true, get: function () { return guards_ts_1.defaultGuards; } });
|
|
19
|
+
Object.defineProperty(exports, "defaultSnapshot", { enumerable: true, get: function () { return guards_ts_1.defaultSnapshot; } });
|
|
20
|
+
Object.defineProperty(exports, "fromConfig", { enumerable: true, get: function () { return guards_ts_1.fromConfig; } });
|
|
21
|
+
Object.defineProperty(exports, "survivalReport", { enumerable: true, get: function () { return guards_ts_1.survivalReport; } });
|
|
22
|
+
Object.defineProperty(exports, "wireCode", { enumerable: true, get: function () { return guards_ts_1.wireCode; } });
|
|
23
|
+
var guarded_ts_1 = require("./guarded.js");
|
|
24
|
+
Object.defineProperty(exports, "guardedSimulate", { enumerable: true, get: function () { return guarded_ts_1.guardedSimulate; } });
|
|
25
|
+
var card_ts_1 = require("./card.js");
|
|
26
|
+
Object.defineProperty(exports, "renderReceiptCard", { enumerable: true, get: function () { return card_ts_1.renderReceiptCard; } });
|
|
27
|
+
var receipt_ts_1 = require("./receipt.js");
|
|
28
|
+
Object.defineProperty(exports, "costBreakdownFromReceipt", { enumerable: true, get: function () { return receipt_ts_1.costBreakdownFromReceipt; } });
|
|
29
|
+
Object.defineProperty(exports, "RECEIPT_KIND", { enumerable: true, get: function () { return receipt_ts_1.RECEIPT_KIND; } });
|
|
30
|
+
Object.defineProperty(exports, "RECEIPT_STATEMENT", { enumerable: true, get: function () { return receipt_ts_1.RECEIPT_STATEMENT; } });
|
|
31
|
+
Object.defineProperty(exports, "canonical", { enumerable: true, get: function () { return receipt_ts_1.canonical; } });
|
|
32
|
+
Object.defineProperty(exports, "sha256Json", { enumerable: true, get: function () { return receipt_ts_1.sha256Json; } });
|
|
33
|
+
Object.defineProperty(exports, "verifyReceipt", { enumerable: true, get: function () { return receipt_ts_1.verifyReceipt; } });
|
|
34
|
+
var costs_ts_1 = require("./vendor/costs.js");
|
|
35
|
+
Object.defineProperty(exports, "executionCost", { enumerable: true, get: function () { return costs_ts_1.executionCost; } });
|
|
36
|
+
var info_ts_1 = require("./vendor/info.js");
|
|
37
|
+
Object.defineProperty(exports, "InfoClient", { enumerable: true, get: function () { return info_ts_1.InfoClient; } });
|
|
38
|
+
var queries_ts_1 = require("./vendor/queries.js");
|
|
39
|
+
Object.defineProperty(exports, "fees", { enumerable: true, get: function () { return queries_ts_1.fees; } });
|
|
40
|
+
Object.defineProperty(exports, "funding", { enumerable: true, get: function () { return queries_ts_1.funding; } });
|
|
41
|
+
Object.defineProperty(exports, "markets", { enumerable: true, get: function () { return queries_ts_1.markets; } });
|
|
42
|
+
Object.defineProperty(exports, "orderBook", { enumerable: true, get: function () { return queries_ts_1.orderBook; } });
|
|
43
|
+
Object.defineProperty(exports, "positions", { enumerable: true, get: function () { return queries_ts_1.positions; } });
|
|
44
|
+
var simulate_ts_1 = require("./vendor/simulate.js");
|
|
45
|
+
Object.defineProperty(exports, "simulate", { enumerable: true, get: function () { return simulate_ts_1.simulate; } });
|
|
46
|
+
exports.READ_AND_SIM_TOOLS = [
|
|
47
|
+
"markets",
|
|
48
|
+
"order_book",
|
|
49
|
+
"funding",
|
|
50
|
+
"positions",
|
|
51
|
+
"fees",
|
|
52
|
+
"simulate",
|
|
53
|
+
"get_limits",
|
|
54
|
+
"trigger_kill_switch",
|
|
55
|
+
"get_cost_breakdown",
|
|
56
|
+
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Re-derive a simulation receipt. The check is verified and reproducible. */
|
|
2
|
+
import { type CostBreakdown } from "./vendor/costs.ts";
|
|
3
|
+
export declare const RECEIPT_STATEMENT = "verified and reproducible";
|
|
4
|
+
export declare const RECEIPT_KIND = "perpbrain.sim-receipt";
|
|
5
|
+
export declare const RECEIPT_VERSION = 5;
|
|
6
|
+
export interface VerifyReport {
|
|
7
|
+
status: "VERIFIED" | "MISMATCH";
|
|
8
|
+
mismatches: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function verifyReceipt(receipt: unknown, manifest: Uint8Array, inputs: Uint8Array): VerifyReport;
|
|
11
|
+
export declare function canonical(value: unknown): string;
|
|
12
|
+
export declare function sha256Json(value: unknown): string;
|
|
13
|
+
export declare function costBreakdownFromReceipt(receipt: unknown): CostBreakdown;
|