@parchment-trade/sdk 0.0.0-stage → 1.0.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/LICENSE +202 -0
- package/README.md +193 -2
- package/REFERENCE.md +338 -0
- package/SECURITY.md +25 -0
- package/dist/general/providers/index.d.ts +2 -0
- package/dist/general/providers/index.js +2 -0
- package/dist/general/providers/parchment.d.ts +1 -0
- package/dist/general/providers/parchment.js +1 -0
- package/dist/general/providers/parchmentSdk.d.ts +23 -0
- package/dist/general/providers/parchmentSdk.js +11 -0
- package/dist/general/types/configTypes.d.ts +62 -0
- package/dist/general/types/configTypes.js +1 -0
- package/dist/general/types/index.d.ts +1 -0
- package/dist/general/types/index.js +1 -0
- package/dist/general/utils/address.d.ts +49 -0
- package/dist/general/utils/address.js +110 -0
- package/dist/general/utils/caller.d.ts +58 -0
- package/dist/general/utils/caller.js +182 -0
- package/dist/general/utils/errors.d.ts +16 -0
- package/dist/general/utils/errors.js +26 -0
- package/dist/general/utils/index.d.ts +4 -0
- package/dist/general/utils/index.js +4 -0
- package/dist/general/utils/jsBigInt.d.ts +26 -0
- package/dist/general/utils/jsBigInt.js +74 -0
- package/dist/general/utils/txShape.d.ts +8 -0
- package/dist/general/utils/txShape.js +39 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/packages/index.d.ts +11 -0
- package/dist/packages/index.js +5 -0
- package/dist/packages/parchment/abortCodes.d.ts +196 -0
- package/dist/packages/parchment/abortCodes.js +522 -0
- package/dist/packages/parchment/batchClose.d.ts +268 -0
- package/dist/packages/parchment/batchClose.js +524 -0
- package/dist/packages/parchment/eventGuard.d.ts +106 -0
- package/dist/packages/parchment/eventGuard.js +119 -0
- package/dist/packages/parchment/gameCounterEvents.d.ts +59 -0
- package/dist/packages/parchment/gameCounterEvents.js +56 -0
- package/dist/packages/parchment/index.d.ts +52 -0
- package/dist/packages/parchment/index.js +30 -0
- package/dist/packages/parchment/liquidationCredit.d.ts +28 -0
- package/dist/packages/parchment/liquidationCredit.js +25 -0
- package/dist/packages/parchment/lockedMintEvents.d.ts +42 -0
- package/dist/packages/parchment/lockedMintEvents.js +46 -0
- package/dist/packages/parchment/monitoring.d.ts +369 -0
- package/dist/packages/parchment/monitoring.js +259 -0
- package/dist/packages/parchment/notes.d.ts +6 -0
- package/dist/packages/parchment/notes.js +1 -0
- package/dist/packages/parchment/onboarding.d.ts +50 -0
- package/dist/packages/parchment/onboarding.js +48 -0
- package/dist/packages/parchment/orderEffects.d.ts +207 -0
- package/dist/packages/parchment/orderEffects.js +268 -0
- package/dist/packages/parchment/orderParams.d.ts +72 -0
- package/dist/packages/parchment/orderParams.js +71 -0
- package/dist/packages/parchment/packageIds.d.ts +53 -0
- package/dist/packages/parchment/packageIds.js +149 -0
- package/dist/packages/parchment/parchment.d.ts +442 -0
- package/dist/packages/parchment/parchment.js +975 -0
- package/dist/packages/parchment/parchmentAccount.d.ts +189 -0
- package/dist/packages/parchment/parchmentAccount.js +273 -0
- package/dist/packages/parchment/parchmentMarket.d.ts +58 -0
- package/dist/packages/parchment/parchmentMarket.js +86 -0
- package/dist/packages/parchment/parchmentTypes.d.ts +2031 -0
- package/dist/packages/parchment/parchmentTypes.js +65 -0
- package/dist/packages/parchment/publicInts.d.ts +45 -0
- package/dist/packages/parchment/publicInts.js +383 -0
- package/dist/packages/parchment/reconcileEvents.d.ts +24 -0
- package/dist/packages/parchment/reconcileEvents.js +30 -0
- package/dist/packages/parchment/retainedFee.d.ts +43 -0
- package/dist/packages/parchment/retainedFee.js +68 -0
- package/dist/packages/parchment/sessionClose.d.ts +68 -0
- package/dist/packages/parchment/sessionClose.js +50 -0
- package/dist/packages/parchment/sessionKey.d.ts +78 -0
- package/dist/packages/parchment/sessionKey.js +154 -0
- package/dist/packages/parchment/slippage.d.ts +23 -0
- package/dist/packages/parchment/slippage.js +27 -0
- package/dist/packages/parchment/sponsor.d.ts +39 -0
- package/dist/packages/parchment/sponsor.js +48 -0
- package/dist/packages/parchment/stakingCalls.d.ts +33 -0
- package/dist/packages/parchment/stakingCalls.js +21 -0
- package/dist/packages/parchment/stakingEvents.d.ts +53 -0
- package/dist/packages/parchment/stakingEvents.js +71 -0
- package/dist/packages/parchment/triggerCalls.d.ts +46 -0
- package/dist/packages/parchment/triggerCalls.js +36 -0
- package/dist/packages/parchment/triggerEvents.d.ts +22 -0
- package/dist/packages/parchment/triggerEvents.js +33 -0
- package/dist/packages/parchment/triggers.d.ts +113 -0
- package/dist/packages/parchment/triggers.js +183 -0
- package/dist/packages/parchment/txBodies.d.ts +111 -0
- package/dist/packages/parchment/txBodies.js +683 -0
- package/dist/packages/parchment/txIntent.d.ts +99 -0
- package/dist/packages/parchment/txIntent.js +611 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +58 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
export const STAKING_DURATION_CAPS_UPDATED_EVENT_BCS = bcs.struct("StakingDurationCapsUpdatedEventV1", {
|
|
3
|
+
pool_id: bcs.Address,
|
|
4
|
+
max_reward_stream_ms: bcs.u64(),
|
|
5
|
+
max_min_stake_lock_ms: bcs.u64(),
|
|
6
|
+
});
|
|
7
|
+
export function decodeStakingDurationCapsUpdatedEvent(bytes) {
|
|
8
|
+
try {
|
|
9
|
+
return STAKING_DURATION_CAPS_UPDATED_EVENT_BCS.parse(bytes);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export const LOCKED_WEIGHT_SYNCED_EVENT_BCS = bcs.struct("LockedWeightSyncedEventV1", {
|
|
16
|
+
pool_id: bcs.Address,
|
|
17
|
+
owner: bcs.Address,
|
|
18
|
+
balance: bcs.u64(),
|
|
19
|
+
weight: bcs.u64(),
|
|
20
|
+
total_weight: bcs.u64(),
|
|
21
|
+
moved: bcs.u64(),
|
|
22
|
+
owed: bcs.u64(),
|
|
23
|
+
});
|
|
24
|
+
export const LOCKED_YIELD_CLAIMED_EVENT_BCS = bcs.struct("LockedYieldClaimedEventV1", {
|
|
25
|
+
pool_id: bcs.Address,
|
|
26
|
+
owner: bcs.Address,
|
|
27
|
+
amount: bcs.u64(),
|
|
28
|
+
owed: bcs.u64(),
|
|
29
|
+
});
|
|
30
|
+
export const LOCKED_YIELD_FORFEITED_EVENT_BCS = bcs.struct("LockedYieldForfeitedEventV1", {
|
|
31
|
+
pool_id: bcs.Address,
|
|
32
|
+
owner: bcs.Address,
|
|
33
|
+
amount: bcs.u64(),
|
|
34
|
+
stream_end_ms: bcs.u64(),
|
|
35
|
+
});
|
|
36
|
+
export const LOCKED_WEIGHT_BPS_UPDATED_EVENT_BCS = bcs.struct("LockedWeightBpsUpdatedEventV1", {
|
|
37
|
+
pool_id: bcs.Address,
|
|
38
|
+
bps: bcs.u64(),
|
|
39
|
+
});
|
|
40
|
+
export function decodeLockedWeightSyncedEvent(bytes) {
|
|
41
|
+
try {
|
|
42
|
+
return LOCKED_WEIGHT_SYNCED_EVENT_BCS.parse(bytes);
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export function decodeLockedYieldClaimedEvent(bytes) {
|
|
49
|
+
try {
|
|
50
|
+
return LOCKED_YIELD_CLAIMED_EVENT_BCS.parse(bytes);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function decodeLockedYieldForfeitedEvent(bytes) {
|
|
57
|
+
try {
|
|
58
|
+
return LOCKED_YIELD_FORFEITED_EVENT_BCS.parse(bytes);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function decodeLockedWeightBpsUpdatedEvent(bytes) {
|
|
65
|
+
try {
|
|
66
|
+
return LOCKED_WEIGHT_BPS_UPDATED_EVENT_BCS.parse(bytes);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Transaction, TransactionObjectArgument, TransactionResult } from "@mysten/sui/transactions";
|
|
2
|
+
type ObjectInput = string | TransactionObjectArgument;
|
|
3
|
+
type Integer = bigint | number | string;
|
|
4
|
+
type Level = Integer | null;
|
|
5
|
+
/** Direct Move call inputs. `packageId` is the `parchment_triggers` package id. */
|
|
6
|
+
export interface TriggerOpenCall {
|
|
7
|
+
packageId: string;
|
|
8
|
+
coinType: string;
|
|
9
|
+
exchange: ObjectInput;
|
|
10
|
+
market: ObjectInput;
|
|
11
|
+
account: ObjectInput;
|
|
12
|
+
config: ObjectInput;
|
|
13
|
+
margin: Integer;
|
|
14
|
+
leverage: Integer;
|
|
15
|
+
isLong: boolean;
|
|
16
|
+
minFactorBps: Integer;
|
|
17
|
+
acceptablePriceWad: Integer;
|
|
18
|
+
builderId: number | null;
|
|
19
|
+
tp: Level;
|
|
20
|
+
sl: Level;
|
|
21
|
+
clock: ObjectInput;
|
|
22
|
+
}
|
|
23
|
+
export interface TriggerOpenWithCapCall extends TriggerOpenCall {
|
|
24
|
+
cap: ObjectInput;
|
|
25
|
+
topUp: ObjectInput;
|
|
26
|
+
}
|
|
27
|
+
export interface TriggerEditCall {
|
|
28
|
+
packageId: string;
|
|
29
|
+
coinType: string;
|
|
30
|
+
account: ObjectInput;
|
|
31
|
+
position: Integer;
|
|
32
|
+
tp: Level;
|
|
33
|
+
sl: Level;
|
|
34
|
+
revision: Integer;
|
|
35
|
+
}
|
|
36
|
+
export interface TriggerEditWithCapCall extends TriggerEditCall {
|
|
37
|
+
cap: ObjectInput;
|
|
38
|
+
}
|
|
39
|
+
export interface TriggerEditAsDelegateCall extends TriggerEditCall {
|
|
40
|
+
clock: ObjectInput;
|
|
41
|
+
}
|
|
42
|
+
export declare function addRequestOpenWithTriggersCall(tx: Transaction, input: TriggerOpenWithCapCall): TransactionResult;
|
|
43
|
+
export declare function addRequestOpenWithTriggersAsDelegateCall(tx: Transaction, input: TriggerOpenCall): TransactionResult;
|
|
44
|
+
export declare function addSetTriggerLevelsCall(tx: Transaction, input: TriggerEditWithCapCall): void;
|
|
45
|
+
export declare function addSetTriggerLevelsAsDelegateCall(tx: Transaction, input: TriggerEditAsDelegateCall): void;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
const object = (tx, value) => typeof value === "string" ? tx.object(value) : value;
|
|
3
|
+
const level = (tx, value) => tx.pure(bcs.option(bcs.u128()).serialize(value));
|
|
4
|
+
export function addRequestOpenWithTriggersCall(tx, input) {
|
|
5
|
+
return tx.moveCall({
|
|
6
|
+
target: `${input.packageId}::triggers::request_open_with_triggers`, typeArguments: [input.coinType],
|
|
7
|
+
arguments: [object(tx, input.exchange), object(tx, input.market), object(tx, input.account), object(tx, input.cap),
|
|
8
|
+
object(tx, input.config), tx.pure.u64(input.margin), tx.pure.u64(input.leverage), tx.pure.bool(input.isLong),
|
|
9
|
+
tx.pure.u64(input.minFactorBps), tx.pure.u128(input.acceptablePriceWad),
|
|
10
|
+
tx.pure(bcs.option(bcs.u32()).serialize(input.builderId)), object(tx, input.topUp), level(tx, input.tp),
|
|
11
|
+
level(tx, input.sl), object(tx, input.clock)],
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function addRequestOpenWithTriggersAsDelegateCall(tx, input) {
|
|
15
|
+
return tx.moveCall({
|
|
16
|
+
target: `${input.packageId}::triggers::request_open_with_triggers_as_delegate`, typeArguments: [input.coinType],
|
|
17
|
+
arguments: [object(tx, input.exchange), object(tx, input.market), object(tx, input.account), object(tx, input.config),
|
|
18
|
+
tx.pure.u64(input.margin), tx.pure.u64(input.leverage), tx.pure.bool(input.isLong), tx.pure.u64(input.minFactorBps),
|
|
19
|
+
tx.pure.u128(input.acceptablePriceWad), tx.pure(bcs.option(bcs.u32()).serialize(input.builderId)),
|
|
20
|
+
level(tx, input.tp), level(tx, input.sl), object(tx, input.clock)],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function addSetTriggerLevelsCall(tx, input) {
|
|
24
|
+
tx.moveCall({
|
|
25
|
+
target: `${input.packageId}::triggers::set_trigger_levels`, typeArguments: [input.coinType],
|
|
26
|
+
arguments: [object(tx, input.account), object(tx, input.cap), tx.pure.u64(input.position),
|
|
27
|
+
level(tx, input.tp), level(tx, input.sl), tx.pure.u64(input.revision)],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function addSetTriggerLevelsAsDelegateCall(tx, input) {
|
|
31
|
+
tx.moveCall({
|
|
32
|
+
target: `${input.packageId}::triggers::set_trigger_levels_as_delegate`, typeArguments: [input.coinType],
|
|
33
|
+
arguments: [object(tx, input.account), tx.pure.u64(input.position), level(tx, input.tp), level(tx, input.sl),
|
|
34
|
+
tx.pure.u64(input.revision), object(tx, input.clock)],
|
|
35
|
+
});
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** BCS for `triggers::Event<TriggerLevelsCommitted>`. Prices are WAD values. */
|
|
2
|
+
export declare const TRIGGER_LEVELS_COMMITTED_BCS: import("@mysten/sui/bcs").BcsStruct<{
|
|
3
|
+
account: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
4
|
+
market: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
5
|
+
side: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
6
|
+
request_id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
7
|
+
tp: import("@mysten/sui/bcs").BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
|
|
8
|
+
sl: import("@mysten/sui/bcs").BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
|
|
9
|
+
}, string>;
|
|
10
|
+
/** BCS for `triggers::Event<TriggerLevelsSetEvent>`. */
|
|
11
|
+
export declare const TRIGGER_LEVELS_SET_EVENT_BCS: import("@mysten/sui/bcs").BcsStruct<{
|
|
12
|
+
account: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
13
|
+
position: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
14
|
+
tp: import("@mysten/sui/bcs").BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
|
|
15
|
+
sl: import("@mysten/sui/bcs").BcsType<string | null, string | number | bigint | null | undefined, "Option<u128>">;
|
|
16
|
+
revision: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
17
|
+
sender: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
18
|
+
}, string>;
|
|
19
|
+
export type TriggerLevelsCommitted = ReturnType<typeof TRIGGER_LEVELS_COMMITTED_BCS.parse>;
|
|
20
|
+
export type TriggerLevelsSetEvent = ReturnType<typeof TRIGGER_LEVELS_SET_EVENT_BCS.parse>;
|
|
21
|
+
export declare function decodeTriggerLevelsCommitted(bytes: Uint8Array): TriggerLevelsCommitted | null;
|
|
22
|
+
export declare function decodeTriggerLevelsSetEvent(bytes: Uint8Array): TriggerLevelsSetEvent | null;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { bcs } from "@mysten/sui/bcs";
|
|
2
|
+
export const TRIGGER_LEVELS_COMMITTED_BCS = bcs.struct("TriggerLevelsCommitted", {
|
|
3
|
+
account: bcs.Address,
|
|
4
|
+
market: bcs.Address,
|
|
5
|
+
side: bcs.bool(),
|
|
6
|
+
request_id: bcs.Address,
|
|
7
|
+
tp: bcs.option(bcs.u128()),
|
|
8
|
+
sl: bcs.option(bcs.u128()),
|
|
9
|
+
});
|
|
10
|
+
export const TRIGGER_LEVELS_SET_EVENT_BCS = bcs.struct("TriggerLevelsSetEvent", {
|
|
11
|
+
account: bcs.Address,
|
|
12
|
+
position: bcs.u64(),
|
|
13
|
+
tp: bcs.option(bcs.u128()),
|
|
14
|
+
sl: bcs.option(bcs.u128()),
|
|
15
|
+
revision: bcs.u64(),
|
|
16
|
+
sender: bcs.Address,
|
|
17
|
+
});
|
|
18
|
+
export function decodeTriggerLevelsCommitted(bytes) {
|
|
19
|
+
try {
|
|
20
|
+
return TRIGGER_LEVELS_COMMITTED_BCS.parse(bytes);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function decodeTriggerLevelsSetEvent(bytes) {
|
|
27
|
+
try {
|
|
28
|
+
return TRIGGER_LEVELS_SET_EVENT_BCS.parse(bytes);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/** Signed text version line. Lines are joined by `\n` with no trailing newline. */
|
|
2
|
+
export declare const TRIGGER_PROOF_VERSION = "Parchment trigger v1";
|
|
3
|
+
/** Proof lifetime the client requests: five minutes, inside the service's ten-minute window. */
|
|
4
|
+
export declare const TRIGGER_PROOF_TTL_MS: number;
|
|
5
|
+
export type TriggerKind = "tp" | "sl";
|
|
6
|
+
/**
|
|
7
|
+
* The position a proof is for: an open position, or the one the open request in transaction
|
|
8
|
+
* `openTxDigest` creates when it fills. Sign the open first, then this proof over the signed
|
|
9
|
+
* transaction's digest, save it ({@link Parchment.setTriggers}), and only then send the open: the
|
|
10
|
+
* legs are stored before the open can execute. `marketId` and `isLong` are the open's; the legs
|
|
11
|
+
* attach only to an open of that market and side. `openTxBytesBase64` is that signed transaction (BCS
|
|
12
|
+
* `TransactionData`, base64): the service reads its epoch bound from it. It is sent next to the proof, not
|
|
13
|
+
* signed, so the message needs none; {@link triggerRequestBody} requires it whenever a leg is set.
|
|
14
|
+
*/
|
|
15
|
+
export type TriggerTarget = {
|
|
16
|
+
positionId: bigint;
|
|
17
|
+
} | {
|
|
18
|
+
openTxDigest: string;
|
|
19
|
+
marketId: string;
|
|
20
|
+
isLong: boolean;
|
|
21
|
+
openTxBytesBase64?: string;
|
|
22
|
+
} | TriggerIntentTarget;
|
|
23
|
+
/**
|
|
24
|
+
* A prepared open intent: the legs for an open that is still being built, before its digest exists. Sign the
|
|
25
|
+
* proof over a fresh {@link newTriggerIntentId}, save it with `POST /triggers/prepare`
|
|
26
|
+
* ({@link triggerPrepareBody}) while the open is built, then bind the signed open to it with
|
|
27
|
+
* `POST /triggers/bind` ({@link triggerBindBody}). The open's sender must be the owner or the key that signed
|
|
28
|
+
* this proof; its own signature over the open authorizes the bind. One id binds one transaction.
|
|
29
|
+
*/
|
|
30
|
+
export interface TriggerIntentTarget {
|
|
31
|
+
/** 32 lowercase hex digits (16 random bytes), used once. */
|
|
32
|
+
intentId: string;
|
|
33
|
+
marketId: string;
|
|
34
|
+
isLong: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface TriggerProofInput {
|
|
37
|
+
owner: string;
|
|
38
|
+
accountId: string;
|
|
39
|
+
target: TriggerTarget;
|
|
40
|
+
/** Take-profit price, 1e18 base units. Null clears it. */
|
|
41
|
+
takeProfitWad: bigint | null;
|
|
42
|
+
/** Stop-loss price, 1e18 base units. Null clears it. */
|
|
43
|
+
stopLossWad: bigint | null;
|
|
44
|
+
/** Absolute expiry, unix milliseconds. */
|
|
45
|
+
expiresAtMs: bigint;
|
|
46
|
+
}
|
|
47
|
+
/** Wallet (or any key) that can sign a personal message. The owner signs the proof. */
|
|
48
|
+
export interface TriggerSigner {
|
|
49
|
+
signPersonalMessage: (message: Uint8Array) => Promise<{
|
|
50
|
+
signature: string;
|
|
51
|
+
}>;
|
|
52
|
+
}
|
|
53
|
+
export interface TriggerProof extends TriggerProofInput {
|
|
54
|
+
message: string;
|
|
55
|
+
signature: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The personal message the owner signs to set both legs of one position. Seven lines, `\n`-joined,
|
|
59
|
+
* no trailing newline: `Parchment trigger v1`, owner, account id, `position <id>` or
|
|
60
|
+
* `open <open tx digest> <market id> long|short` or `intent <intent id> <market id> long|short`, `tp <price>` or
|
|
61
|
+
* `tp none`, `sl <price>` or
|
|
62
|
+
* `sl none`, expiry ms. Addresses are `0x` plus 64 lowercase hex digits; numbers are plain
|
|
63
|
+
* decimals; the digest is base58.
|
|
64
|
+
*/
|
|
65
|
+
export declare function triggerProofMessage(input: TriggerProofInput): string;
|
|
66
|
+
/**
|
|
67
|
+
* The owner signs {@link triggerProofMessage}; `expiresAtMs` is `nowMs` plus {@link TRIGGER_PROOF_TTL_MS}.
|
|
68
|
+
* The whole request is checked first, without the signature ({@link triggerRequestBody}'s checks, including
|
|
69
|
+
* an open target's `openTxBytesBase64` against its digest; for an intent target, {@link triggerPrepareBody}'s),
|
|
70
|
+
* so a request the service would refuse never prompts the wallet for a signature.
|
|
71
|
+
*/
|
|
72
|
+
export declare function signTriggerProof(signer: TriggerSigner, input: Omit<TriggerProofInput, "expiresAtMs">, nowMs?: number): Promise<TriggerProof>;
|
|
73
|
+
/** JSON body for `POST /triggers`: the signed fields with integers as js_bigint literals. */
|
|
74
|
+
export declare function triggerRequestBody(proof: TriggerProof): Record<string, string | boolean | null>;
|
|
75
|
+
/** A fresh random intent id (16 bytes from the platform CSPRNG, as 32 lowercase hex digits). */
|
|
76
|
+
export declare function newTriggerIntentId(): string;
|
|
77
|
+
/**
|
|
78
|
+
* JSON body for `POST /triggers/prepare`: a signed proof whose target is a {@link TriggerIntentTarget}. Prices and
|
|
79
|
+
* the expiry are plain decimal strings, exactly as signed. A prepared intent needs at least one leg.
|
|
80
|
+
*/
|
|
81
|
+
export declare function triggerPrepareBody(proof: TriggerProof): Record<string, string | boolean | null>;
|
|
82
|
+
/** What `POST /triggers/bind` names: the prepared intent and the signed open that carries it. */
|
|
83
|
+
export interface TriggerBindInput {
|
|
84
|
+
owner: string;
|
|
85
|
+
accountId: string;
|
|
86
|
+
intentId: string;
|
|
87
|
+
/** The signed open `Transaction` (BCS, base64), exactly as it is sent. */
|
|
88
|
+
openTxBytesBase64: string;
|
|
89
|
+
/** Its signatures (base64); the sender's must be one (a sponsor's may ride along). */
|
|
90
|
+
signatures: string[];
|
|
91
|
+
}
|
|
92
|
+
/** JSON body for `POST /triggers/bind`. */
|
|
93
|
+
export declare function triggerBindBody(input: TriggerBindInput): {
|
|
94
|
+
owner: string;
|
|
95
|
+
accountId: string;
|
|
96
|
+
intentId: string;
|
|
97
|
+
openTxBytesBase64: string;
|
|
98
|
+
signatures: string[];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Fraction of the entry-to-liquidation distance. A stop in that last slice is near liquidation:
|
|
102
|
+
* `|stop - liq| <= NEAR_LIQ_DISTANCE_FRACTION * |entry - liq|`.
|
|
103
|
+
*/
|
|
104
|
+
export declare const NEAR_LIQ_DISTANCE_FRACTION = 0.2;
|
|
105
|
+
export type StopPlacement = "ok" | "near" | "past";
|
|
106
|
+
/**
|
|
107
|
+
* `past`: a long stop at or under liquidation, or a short stop at or over it.
|
|
108
|
+
* `near`: still on the safe side, inside the last {@link NEAR_LIQ_DISTANCE_FRACTION} of the
|
|
109
|
+
* entry-to-liquidation distance. A long's liquidation can be exactly 0 (1x): that is a real
|
|
110
|
+
* level. `ok` when the stop, the liquidation or the entry is unknown (null, NaN, negative) or the
|
|
111
|
+
* entry is not on the safe side of liquidation. All prices share one unit.
|
|
112
|
+
*/
|
|
113
|
+
export declare function stopAgainstLiquidation(side: "long" | "short", stop: number, liquidation: number | null | undefined, entry: number | null | undefined): StopPlacement;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { TransactionDataBuilder } from "@mysten/sui/transactions";
|
|
2
|
+
import { fromBase58, fromBase64, toBase58 } from "@mysten/sui/utils";
|
|
3
|
+
import { U64_MAX, normalizeAddress } from "../../general/utils/address.js";
|
|
4
|
+
import { ParchmentApiError } from "../../general/utils/errors.js";
|
|
5
|
+
import { toJsBigInt } from "../../general/utils/jsBigInt.js";
|
|
6
|
+
export const TRIGGER_PROOF_VERSION = "Parchment trigger v1";
|
|
7
|
+
export const TRIGGER_PROOF_TTL_MS = 5 * 60 * 1000;
|
|
8
|
+
const U128_MAX = (1n << 128n) - 1n;
|
|
9
|
+
export function triggerProofMessage(input) {
|
|
10
|
+
return [
|
|
11
|
+
TRIGGER_PROOF_VERSION,
|
|
12
|
+
normalizeAddress(input.owner),
|
|
13
|
+
normalizeAddress(input.accountId),
|
|
14
|
+
targetLine(input.target),
|
|
15
|
+
legLine("tp", input.takeProfitWad),
|
|
16
|
+
legLine("sl", input.stopLossWad),
|
|
17
|
+
bounded(input.expiresAtMs, "expiresAtMs", U64_MAX).toString(),
|
|
18
|
+
].join("\n");
|
|
19
|
+
}
|
|
20
|
+
export async function signTriggerProof(signer, input, nowMs = Date.now()) {
|
|
21
|
+
const proof = { ...input, expiresAtMs: BigInt(Math.floor(nowMs) + TRIGGER_PROOF_TTL_MS) };
|
|
22
|
+
const message = triggerProofMessage(proof);
|
|
23
|
+
if ("intentId" in proof.target)
|
|
24
|
+
unsignedPrepareBody(proof);
|
|
25
|
+
else
|
|
26
|
+
unsignedRequestBody(proof);
|
|
27
|
+
const { signature } = await signer.signPersonalMessage(new TextEncoder().encode(message));
|
|
28
|
+
if (typeof signature !== "string" || signature.length === 0) {
|
|
29
|
+
throw new ParchmentApiError(0, "bad_signature", "trigger signature is empty");
|
|
30
|
+
}
|
|
31
|
+
return { ...proof, message, signature };
|
|
32
|
+
}
|
|
33
|
+
export function triggerRequestBody(proof) {
|
|
34
|
+
return { ...unsignedRequestBody(proof), signature: proof.signature };
|
|
35
|
+
}
|
|
36
|
+
function unsignedRequestBody(proof) {
|
|
37
|
+
triggerProofMessage(proof);
|
|
38
|
+
const leg = (v) => (v === null ? null : toJsBigInt(v));
|
|
39
|
+
if ("intentId" in proof.target) {
|
|
40
|
+
throw new ParchmentApiError(0, "bad_request", "a prepared intent is saved with triggerPrepareBody (POST /triggers/prepare)");
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
owner: normalizeAddress(proof.owner),
|
|
44
|
+
accountId: normalizeAddress(proof.accountId),
|
|
45
|
+
...("positionId" in proof.target
|
|
46
|
+
? { positionId: toJsBigInt(proof.target.positionId) }
|
|
47
|
+
: {
|
|
48
|
+
openTxDigest: txDigest(proof.target.openTxDigest),
|
|
49
|
+
marketId: normalizeAddress(proof.target.marketId),
|
|
50
|
+
isLong: proof.target.isLong,
|
|
51
|
+
...(proof.takeProfitWad === null && proof.stopLossWad === null && proof.target.openTxBytesBase64 === undefined
|
|
52
|
+
? {}
|
|
53
|
+
: { openTxBytesBase64: openTxBytes(proof.target.openTxBytesBase64, proof.target.openTxDigest) }),
|
|
54
|
+
}),
|
|
55
|
+
takeProfitWad: leg(proof.takeProfitWad),
|
|
56
|
+
stopLossWad: leg(proof.stopLossWad),
|
|
57
|
+
expiresAtMs: toJsBigInt(proof.expiresAtMs),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function targetLine(target) {
|
|
61
|
+
if ("positionId" in target)
|
|
62
|
+
return `position ${bounded(target.positionId, "positionId", U64_MAX)}`;
|
|
63
|
+
if (typeof target.isLong !== "boolean")
|
|
64
|
+
throw new ParchmentApiError(0, "bad_request", "isLong must be a boolean");
|
|
65
|
+
const side = target.isLong ? "long" : "short";
|
|
66
|
+
if ("intentId" in target)
|
|
67
|
+
return `intent ${intentId(target.intentId)} ${normalizeAddress(target.marketId)} ${side}`;
|
|
68
|
+
return `open ${txDigest(target.openTxDigest)} ${normalizeAddress(target.marketId)} ${side}`;
|
|
69
|
+
}
|
|
70
|
+
function intentId(id) {
|
|
71
|
+
if (typeof id !== "string" || !/^[0-9a-f]{32}$/.test(id)) {
|
|
72
|
+
throw new ParchmentApiError(0, "bad_request", "intentId must be 32 lowercase hex digits");
|
|
73
|
+
}
|
|
74
|
+
return id;
|
|
75
|
+
}
|
|
76
|
+
export function newTriggerIntentId() {
|
|
77
|
+
const bytes = new Uint8Array(16);
|
|
78
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
79
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
80
|
+
}
|
|
81
|
+
export function triggerPrepareBody(proof) {
|
|
82
|
+
const body = unsignedPrepareBody(proof);
|
|
83
|
+
if (typeof proof.signature !== "string" || proof.signature.length === 0) {
|
|
84
|
+
throw new ParchmentApiError(0, "bad_signature", "trigger signature is empty");
|
|
85
|
+
}
|
|
86
|
+
return { ...body, signature: proof.signature };
|
|
87
|
+
}
|
|
88
|
+
function unsignedPrepareBody(proof) {
|
|
89
|
+
const target = proof.target;
|
|
90
|
+
if (!("intentId" in target))
|
|
91
|
+
throw new ParchmentApiError(0, "bad_request", "a prepare needs an intent target");
|
|
92
|
+
triggerProofMessage(proof);
|
|
93
|
+
if (proof.takeProfitWad === null && proof.stopLossWad === null) {
|
|
94
|
+
throw new ParchmentApiError(0, "bad_request", "a prepared intent needs a take-profit or a stop-loss");
|
|
95
|
+
}
|
|
96
|
+
const leg = (v) => (v === null ? null : v.toString());
|
|
97
|
+
return {
|
|
98
|
+
owner: normalizeAddress(proof.owner),
|
|
99
|
+
accountId: normalizeAddress(proof.accountId),
|
|
100
|
+
intentId: target.intentId,
|
|
101
|
+
marketId: normalizeAddress(target.marketId),
|
|
102
|
+
isLong: target.isLong,
|
|
103
|
+
takeProfitWad: leg(proof.takeProfitWad),
|
|
104
|
+
stopLossWad: leg(proof.stopLossWad),
|
|
105
|
+
expiresAtMs: proof.expiresAtMs.toString(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export function triggerBindBody(input) {
|
|
109
|
+
let decodes = false;
|
|
110
|
+
try {
|
|
111
|
+
decodes = typeof input.openTxBytesBase64 === "string" && TransactionDataBuilder.getDigestFromBytes(fromBase64(input.openTxBytesBase64)).length > 0;
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
decodes = false;
|
|
115
|
+
}
|
|
116
|
+
if (!decodes)
|
|
117
|
+
throw new ParchmentApiError(0, "bad_request", "openTxBytesBase64 must be the signed open transaction");
|
|
118
|
+
if (!Array.isArray(input.signatures) || input.signatures.length === 0 || input.signatures.some((s) => typeof s !== "string" || s.length === 0)) {
|
|
119
|
+
throw new ParchmentApiError(0, "bad_signature", "the signed open's signatures are required");
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
owner: normalizeAddress(input.owner),
|
|
123
|
+
accountId: normalizeAddress(input.accountId),
|
|
124
|
+
intentId: intentId(input.intentId),
|
|
125
|
+
openTxBytesBase64: input.openTxBytesBase64,
|
|
126
|
+
signatures: [...input.signatures],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function txDigest(digest) {
|
|
130
|
+
let bytes;
|
|
131
|
+
try {
|
|
132
|
+
bytes = fromBase58(digest);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
bytes = new Uint8Array();
|
|
136
|
+
}
|
|
137
|
+
if (typeof digest !== "string" || bytes.length !== 32 || toBase58(bytes) !== digest) {
|
|
138
|
+
throw new ParchmentApiError(0, "bad_request", "openTxDigest must be a transaction digest");
|
|
139
|
+
}
|
|
140
|
+
return digest;
|
|
141
|
+
}
|
|
142
|
+
function openTxBytes(bytesBase64, digest) {
|
|
143
|
+
let matches = false;
|
|
144
|
+
try {
|
|
145
|
+
matches = typeof bytesBase64 === "string" && TransactionDataBuilder.getDigestFromBytes(fromBase64(bytesBase64)) === digest;
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
matches = false;
|
|
149
|
+
}
|
|
150
|
+
if (!matches)
|
|
151
|
+
throw new ParchmentApiError(0, "bad_request", "openTxBytesBase64 must be the signed open transaction");
|
|
152
|
+
return bytesBase64;
|
|
153
|
+
}
|
|
154
|
+
function legLine(name, price) {
|
|
155
|
+
if (price === null)
|
|
156
|
+
return `${name} none`;
|
|
157
|
+
if (bounded(price, name === "tp" ? "takeProfitWad" : "stopLossWad", U128_MAX) === 0n) {
|
|
158
|
+
throw new ParchmentApiError(0, "bad_price", "trigger price must be non-zero");
|
|
159
|
+
}
|
|
160
|
+
return `${name} ${price}`;
|
|
161
|
+
}
|
|
162
|
+
function bounded(value, field, max) {
|
|
163
|
+
if (typeof value !== "bigint" || value < 0n || value > max) {
|
|
164
|
+
throw new ParchmentApiError(0, "bad_amount", `${field} is out of range`);
|
|
165
|
+
}
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
export const NEAR_LIQ_DISTANCE_FRACTION = 0.2;
|
|
169
|
+
export function stopAgainstLiquidation(side, stop, liquidation, entry) {
|
|
170
|
+
const known = (v) => typeof v === "number" && Number.isFinite(v) && v >= 0;
|
|
171
|
+
if (!known(liquidation) || !known(stop) || stop === 0)
|
|
172
|
+
return "ok";
|
|
173
|
+
if (side === "short" && liquidation === 0)
|
|
174
|
+
return "ok";
|
|
175
|
+
if (side === "long" ? stop <= liquidation : stop >= liquidation)
|
|
176
|
+
return "past";
|
|
177
|
+
if (!known(entry))
|
|
178
|
+
return "ok";
|
|
179
|
+
const span = side === "long" ? entry - liquidation : liquidation - entry;
|
|
180
|
+
if (!(span > 0))
|
|
181
|
+
return "ok";
|
|
182
|
+
return Math.abs(stop - liquidation) <= NEAR_LIQ_DISTANCE_FRACTION * span ? "near" : "ok";
|
|
183
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { type ApiParchmentExitEarlyBoundedTxBody, type ApiParchmentExitEarlyTxBody, type ApiParchmentReleaseUnlockedTxBody, type ApiParchmentSweepTxBody, type ApiParchmentSweepSurplusTxBody, type ApiParchmentClaimPendingMintTxBody, type ApiParchmentBindReferrerTxBody, type ApiParchmentBindTradingReferrerTxBody, type ApiParchmentTransferAccountTxBody, type ApiParchmentClaimQuestTxBody, type ApiParchmentClaimTxBody, type ApiParchmentClosePreviewBody, type ApiParchmentCancelOrderTxBody, type ApiParchmentEmergencyCloseAsDelegateTxBody, type ApiParchmentEmergencyCloseTxBody, type ApiParchmentExpireOrderTxBody, type ApiParchmentCloseRetiredAsDelegateTxBody, type ApiParchmentCloseRetiredTxBody, type ApiParchmentOrderRefTxBody, type ApiParchmentRequestCloseAsDelegateTxBody, type ApiParchmentRequestCloseTxBody, type ApiParchmentRequestOpenAsDelegateTxBody, type ApiParchmentRequestOpenTxBody, type ParchmentDelegateLiveness, type ApiParchmentDepositTxBody, type ApiParchmentGameTxBody, type ApiParchmentGrantDelegateTxBody, type ApiParchmentGrantCloseDelegateTxBody, type ApiParchmentGrantSessionAndTriggerTxBody, type ApiParchmentRevokeSessionAndTriggerTxBody, type ApiParchmentInstallTreasuryTxBody, type ApiParchmentAuthRegisterTxBody, type ApiParchmentLiquidateTxBody, type ApiParchmentLpHarvestTxBody, type ApiParchmentOpenAccountTxBody, type ApiParchmentOpenCratesTxBody, type ApiParchmentOpenPreviewBody, type ApiParchmentRegisterBuilderTxBody, type ApiParchmentSetBuilderCreateFeeTxBody, type ApiParchmentCreateBuilderTxBody, type ApiParchmentSetBuilderFeeTxBody, type ApiParchmentBuilderOwnerTxBody, type ApiParchmentTransferBuilderTxBody, type ApiParchmentApproveBuilderTxBody, type ApiParchmentRevokeBuilderApprovalTxBody, type ApiParchmentRevokeDelegateTxBody, type ApiParchmentSetBuilderPayoutTxBody, type ApiParchmentStakeTxBody, type ApiParchmentUnstakeTxBody, type ApiParchmentWithdrawTxBody } from "./parchmentTypes.js";
|
|
2
|
+
export declare function openPreviewBody(input: ApiParchmentOpenPreviewBody): Record<string, unknown>;
|
|
3
|
+
export declare function closePreviewBody(input: ApiParchmentClosePreviewBody): Record<string, unknown>;
|
|
4
|
+
export declare function openAccountTxBody(input: ApiParchmentOpenAccountTxBody): Record<string, unknown>;
|
|
5
|
+
/** `?builder=` code. Not an object id. Register-builder passes the service's `code_bytes` code `bad_code` for the length. */
|
|
6
|
+
export declare function builderCode(value: string, lengthCode?: string): string;
|
|
7
|
+
export declare function depositTxBody(input: ApiParchmentDepositTxBody): Record<string, unknown>;
|
|
8
|
+
export declare function withdrawTxBody(input: ApiParchmentWithdrawTxBody): Record<string, unknown>;
|
|
9
|
+
/** `order::request_open`. No oracle update: the keeper fills at the oracle mid. */
|
|
10
|
+
export declare function requestOpenTxBody(input: ApiParchmentRequestOpenTxBody): Record<string, unknown>;
|
|
11
|
+
/** Margin past `now + fill_deadline_ms` a delegation must outlive before the SDK builds a delegate request. */
|
|
12
|
+
export declare const DELEGATE_FILL_MARGIN_MS = 60000n;
|
|
13
|
+
/**
|
|
14
|
+
* Delegate-liveness pre-flight, mirroring on-chain `order::EDelegateExpiresBeforeDeadline` (order 28):
|
|
15
|
+
* refuses with `delegate_expires_before_deadline` unless the delegation expires after
|
|
16
|
+
* `now + fillDeadlineMs + DELEGATE_FILL_MARGIN_MS`. Renew the session key, then retry.
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertDelegateLiveThroughFill(delegation: ParchmentDelegateLiveness): void;
|
|
19
|
+
/** `order::request_open_as_delegate`. No AccountCap, no wallet top-up. Checks `delegation` first when given. */
|
|
20
|
+
export declare function requestOpenAsDelegateTxBody(input: ApiParchmentRequestOpenAsDelegateTxBody): Record<string, unknown>;
|
|
21
|
+
/** `order::request_close`. */
|
|
22
|
+
export declare function requestCloseTxBody(input: ApiParchmentRequestCloseTxBody): Record<string, unknown>;
|
|
23
|
+
/** `order::request_close_as_delegate`. No AccountCap, no wallet top-up. Checks `delegation` first when given. */
|
|
24
|
+
export declare function requestCloseAsDelegateTxBody(input: ApiParchmentRequestCloseAsDelegateTxBody): Record<string, unknown>;
|
|
25
|
+
/** `order::cancel`. */
|
|
26
|
+
export declare function cancelOrderTxBody(input: ApiParchmentCancelOrderTxBody): Record<string, unknown>;
|
|
27
|
+
/** `order::cancel_as_delegate`. */
|
|
28
|
+
export declare function orderRefTxBody(input: ApiParchmentOrderRefTxBody): Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* Permissionless `order::expire`. Every expiry takes an expiry price (`oracle::begin_expiry_price` on a
|
|
31
|
+
* verified signed update), on every market. When `update` is omitted, the service attaches a cached
|
|
32
|
+
* signed update that normalizes to the storage print, not the latest message. A caller update is
|
|
33
|
+
* used only when it is that print. Forwards the optional `marketId` fallback and signed update.
|
|
34
|
+
*/
|
|
35
|
+
export declare function expireOrderTxBody(input: ApiParchmentExpireOrderTxBody): Record<string, unknown>;
|
|
36
|
+
/** `order::emergency_close`. Needs a signed oracle update. */
|
|
37
|
+
export declare function emergencyCloseTxBody(input: ApiParchmentEmergencyCloseTxBody): Record<string, unknown>;
|
|
38
|
+
/** `order::emergency_close_as_delegate`. No AccountCap. */
|
|
39
|
+
export declare function emergencyCloseAsDelegateTxBody(input: ApiParchmentEmergencyCloseAsDelegateTxBody): Record<string, unknown>;
|
|
40
|
+
/** `trade::close_retired`. One-step close on a retired market. */
|
|
41
|
+
export declare function closeRetiredTxBody(input: ApiParchmentCloseRetiredTxBody): Record<string, unknown>;
|
|
42
|
+
/** `trade::close_retired_as_delegate`. No AccountCap. */
|
|
43
|
+
export declare function closeRetiredAsDelegateTxBody(input: ApiParchmentCloseRetiredAsDelegateTxBody): Record<string, unknown>;
|
|
44
|
+
export declare function liquidateTxBody(input: ApiParchmentLiquidateTxBody): Record<string, unknown>;
|
|
45
|
+
/** Default batch is 8. A caller value outside 1..=8 is rejected. */
|
|
46
|
+
export declare function sweepBatch(value: string | bigint | undefined): string;
|
|
47
|
+
export declare function sweepTxBody(input: ApiParchmentSweepTxBody): Record<string, unknown>;
|
|
48
|
+
export declare function sweepSurplusTxBody(input: ApiParchmentSweepSurplusTxBody): Record<string, unknown>;
|
|
49
|
+
export declare function claimPendingMintTxBody(input: ApiParchmentClaimPendingMintTxBody): Record<string, unknown>;
|
|
50
|
+
/** Default batch is 32. A caller value outside 1..=128 is rejected. */
|
|
51
|
+
export declare function harvestBatch(value: string | bigint | undefined): string;
|
|
52
|
+
export declare function lpHarvestTxBody(input: ApiParchmentLpHarvestTxBody): Record<string, unknown>;
|
|
53
|
+
export declare function bindReferrerTxBody(input: ApiParchmentBindReferrerTxBody): Record<string, unknown>;
|
|
54
|
+
export declare function bindTradingReferrerTxBody(input: ApiParchmentBindTradingReferrerTxBody): Record<string, unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* `POST /v1/tx/transfer-account`. A zero recipient is a local `zero_recipient` and the sender itself a local
|
|
57
|
+
* `self_transfer` (chain `account_transfer::EZeroRecipient` / `holder_book::ERecipientHasAccount`).
|
|
58
|
+
*/
|
|
59
|
+
export declare function transferAccountTxBody(input: ApiParchmentTransferAccountTxBody): Record<string, unknown>;
|
|
60
|
+
export declare function stakeTxBody(input: ApiParchmentStakeTxBody): Record<string, unknown>;
|
|
61
|
+
export declare function unstakeTxBody(input: ApiParchmentUnstakeTxBody): Record<string, unknown>;
|
|
62
|
+
export declare function claimTxBody(input: ApiParchmentClaimTxBody): Record<string, unknown>;
|
|
63
|
+
export declare function releaseUnlockedTxBody(input: ApiParchmentReleaseUnlockedTxBody): Record<string, unknown>;
|
|
64
|
+
export declare function exitEarlyTxBody(input: ApiParchmentExitEarlyTxBody): Record<string, unknown>;
|
|
65
|
+
/** `locked_mint::max_buckets()`: no ledger holds more entries. */
|
|
66
|
+
export declare const MAX_LOCKED_ENTRIES = 244;
|
|
67
|
+
/**
|
|
68
|
+
* The approved entries' `unlock_ms` and the most penalty, as decimal strings. An entry
|
|
69
|
+
* is `(unlock_ms, vest_ms)`; a listed `unlock_ms` exits every exitable entry
|
|
70
|
+
* with that unlock (the penalty bound still applies to all of them).
|
|
71
|
+
*/
|
|
72
|
+
export declare function exitEarlyBoundedTxBody(input: ApiParchmentExitEarlyBoundedTxBody): Record<string, unknown>;
|
|
73
|
+
/** The service grants its configured close-only delegate: the body names none. */
|
|
74
|
+
export declare function grantCloseDelegateTxBody(input: ApiParchmentGrantCloseDelegateTxBody): Record<string, unknown>;
|
|
75
|
+
/** `sessionDelegate` + `expiryMs`; the service adds its configured close-only delegate (a client one is refused). */
|
|
76
|
+
export declare function grantSessionAndTriggerTxBody(input: ApiParchmentGrantSessionAndTriggerTxBody): Record<string, unknown>;
|
|
77
|
+
export declare function revokeSessionAndTriggerTxBody(input: ApiParchmentRevokeSessionAndTriggerTxBody): Record<string, unknown>;
|
|
78
|
+
export declare function grantDelegateTxBody(input: ApiParchmentGrantDelegateTxBody): Record<string, unknown>;
|
|
79
|
+
/** the service's `share_bps_of`: 0..=5000 (the contract's hard cap), else `bad_share`. */
|
|
80
|
+
/** The 1% hard cap on a builder fee, in bps of profit (`constants::max_builder_fee_bps_hard`). */
|
|
81
|
+
export declare const BUILDER_FEE_HARD_BPS = 100n;
|
|
82
|
+
/**
|
|
83
|
+
* Ceiling of the admin-set self-serve creation price, $100 in USDC base units
|
|
84
|
+
* (`constants::max_builder_create_fee`). The live price is `getConfig().builders.createFee`.
|
|
85
|
+
*/
|
|
86
|
+
export declare const MAX_BUILDER_CREATE_FEE = 100000000n;
|
|
87
|
+
export declare function registerBuilderTxBody(input: ApiParchmentRegisterBuilderTxBody): Record<string, unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* `config::set_builder_create_fee` (admin): the self-serve creation price in USDC base units,
|
|
90
|
+
* `0n` (free) to {@link MAX_BUILDER_CREATE_FEE}; else `bad_amount`. the service's order: amount -> authority cap.
|
|
91
|
+
*/
|
|
92
|
+
export declare function setBuilderCreateFeeTxBody(input: ApiParchmentSetBuilderCreateFeeTxBody): Record<string, unknown>;
|
|
93
|
+
export declare function installTreasuryTxBody(input: ApiParchmentInstallTreasuryTxBody): Record<string, unknown>;
|
|
94
|
+
export declare function authRegisterTxBody(input: ApiParchmentAuthRegisterTxBody): Record<string, unknown>;
|
|
95
|
+
export declare function setBuilderPayoutTxBody(input: ApiParchmentSetBuilderPayoutTxBody): Record<string, unknown>;
|
|
96
|
+
/** `builder::create_builder`: code -> payout -> feeBps -> coin, in the service's order. */
|
|
97
|
+
export declare function createBuilderTxBody(input: ApiParchmentCreateBuilderTxBody): Record<string, unknown>;
|
|
98
|
+
/** `builder::set_builder_fee` (owner): up to the owner limit, or lower than an admin-set fee. */
|
|
99
|
+
export declare function setBuilderFeeTxBody(input: ApiParchmentSetBuilderFeeTxBody): Record<string, unknown>;
|
|
100
|
+
/** `builder::pause_builder` / `resume_builder` (owner). Neither lifts an admin suspend. */
|
|
101
|
+
export declare function builderOwnerTxBody(input: ApiParchmentBuilderOwnerTxBody): Record<string, unknown>;
|
|
102
|
+
/** `builder::transfer_owner`: one transaction by the current owner. */
|
|
103
|
+
export declare function transferBuilderTxBody(input: ApiParchmentTransferBuilderTxBody): Record<string, unknown>;
|
|
104
|
+
/** `builder::approve_builder` (AccountCap): the trader agrees to pay up to `maxFeeBps` of profit. */
|
|
105
|
+
export declare function approveBuilderTxBody(input: ApiParchmentApproveBuilderTxBody): Record<string, unknown>;
|
|
106
|
+
/** `builder::revoke_builder_approval` (AccountCap). */
|
|
107
|
+
export declare function revokeBuilderApprovalTxBody(input: ApiParchmentRevokeBuilderApprovalTxBody): Record<string, unknown>;
|
|
108
|
+
export declare function gameTxBody(input: ApiParchmentGameTxBody): Record<string, unknown>;
|
|
109
|
+
export declare function claimQuestTxBody(input: ApiParchmentClaimQuestTxBody): Record<string, unknown>;
|
|
110
|
+
export declare function openCratesTxBody(input: ApiParchmentOpenCratesTxBody): Record<string, unknown>;
|
|
111
|
+
export declare function revokeDelegateTxBody(input: ApiParchmentRevokeDelegateTxBody): Record<string, unknown>;
|