@pear-protocol/symmio-client 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +7 -10
- package/dist/index.d.ts +7 -10
- package/dist/index.js +29 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -38
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +125 -7
- package/dist/react/index.d.ts +125 -7
- package/dist/react/index.js +1094 -110
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1091 -111
- package/dist/react/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -31,8 +31,6 @@ type SymmioSDKConfig = {
|
|
|
31
31
|
signatureStoreAddress?: Address;
|
|
32
32
|
muonBaseUrls?: string[];
|
|
33
33
|
muonAppName?: string;
|
|
34
|
-
/** Base URL for the hedger API (required for instant trading). */
|
|
35
|
-
hedgerBaseUrl?: string;
|
|
36
34
|
};
|
|
37
35
|
declare enum PositionType {
|
|
38
36
|
LONG = 0,
|
|
@@ -394,7 +392,6 @@ declare class SymmioSDK {
|
|
|
394
392
|
private _collateral;
|
|
395
393
|
private _clearingHouse?;
|
|
396
394
|
private _signatureStore?;
|
|
397
|
-
private _hedgerBaseUrl?;
|
|
398
395
|
constructor(options: {
|
|
399
396
|
chainId: number;
|
|
400
397
|
publicClient: PublicClient;
|
|
@@ -482,7 +479,6 @@ declare class SymmioSDK {
|
|
|
482
479
|
grantRole: (role: Hex, grantee: Address) => Promise<`0x${string}`>;
|
|
483
480
|
revokeRole: (role: Hex, revokee: Address) => Promise<`0x${string}`>;
|
|
484
481
|
};
|
|
485
|
-
private _requireHedgerUrl;
|
|
486
482
|
get instant(): {
|
|
487
483
|
/** Creates a SIWE message for instant trading authentication. */
|
|
488
484
|
createSiweMessage: (params: CreateSiweMessageParams) => SiweMessageResult;
|
|
@@ -19591,6 +19587,7 @@ declare const ALL_TRADING_SELECTORS: Hex[];
|
|
|
19591
19587
|
/**
|
|
19592
19588
|
* Default configuration values for Symmio SDK.
|
|
19593
19589
|
*/
|
|
19590
|
+
|
|
19594
19591
|
/** Market order deadline: 5 minutes */
|
|
19595
19592
|
declare const MARKET_ORDER_DEADLINE = 300n;
|
|
19596
19593
|
/** Limit order deadline: ~10 years */
|
|
@@ -19860,27 +19857,27 @@ declare function createSiweMessage(params: CreateSiweMessageParams): SiweMessage
|
|
|
19860
19857
|
/**
|
|
19861
19858
|
* Fetches a nonce from the hedger for SIWE authentication.
|
|
19862
19859
|
*/
|
|
19863
|
-
declare function getNonce(
|
|
19860
|
+
declare function getNonce(chainId: number, subAccount: Address): Promise<string>;
|
|
19864
19861
|
/**
|
|
19865
19862
|
* Exchanges a signed SIWE message for an access token from the hedger.
|
|
19866
19863
|
*/
|
|
19867
|
-
declare function login(
|
|
19864
|
+
declare function login(chainId: number, params: InstantLoginParams): Promise<InstantAuthToken>;
|
|
19868
19865
|
/**
|
|
19869
19866
|
* Opens a position instantly via the hedger's off-chain endpoint.
|
|
19870
19867
|
*/
|
|
19871
|
-
declare function instantOpen(
|
|
19868
|
+
declare function instantOpen(chainId: number, params: InstantOpenParams, accessToken: string): Promise<InstantOpenResponse>;
|
|
19872
19869
|
/**
|
|
19873
19870
|
* Closes a position instantly via the hedger's off-chain endpoint.
|
|
19874
19871
|
*/
|
|
19875
|
-
declare function instantClose(
|
|
19872
|
+
declare function instantClose(chainId: number, params: InstantCloseParams, accessToken: string): Promise<InstantCloseResponse>;
|
|
19876
19873
|
/**
|
|
19877
19874
|
* Cancels a pending instant close request.
|
|
19878
19875
|
*/
|
|
19879
|
-
declare function cancelInstantClose(
|
|
19876
|
+
declare function cancelInstantClose(chainId: number, quoteId: string, accessToken: string): Promise<void>;
|
|
19880
19877
|
/**
|
|
19881
19878
|
* Fetches the list of open (pending) instant close requests for an account.
|
|
19882
19879
|
*/
|
|
19883
|
-
declare function getOpenInstantCloses(
|
|
19880
|
+
declare function getOpenInstantCloses(chainId: number, account: Address, accessToken: string): Promise<unknown[]>;
|
|
19884
19881
|
|
|
19885
19882
|
declare const instant_cancelInstantClose: typeof cancelInstantClose;
|
|
19886
19883
|
declare const instant_createSiweMessage: typeof createSiweMessage;
|
package/dist/index.d.ts
CHANGED
|
@@ -31,8 +31,6 @@ type SymmioSDKConfig = {
|
|
|
31
31
|
signatureStoreAddress?: Address;
|
|
32
32
|
muonBaseUrls?: string[];
|
|
33
33
|
muonAppName?: string;
|
|
34
|
-
/** Base URL for the hedger API (required for instant trading). */
|
|
35
|
-
hedgerBaseUrl?: string;
|
|
36
34
|
};
|
|
37
35
|
declare enum PositionType {
|
|
38
36
|
LONG = 0,
|
|
@@ -394,7 +392,6 @@ declare class SymmioSDK {
|
|
|
394
392
|
private _collateral;
|
|
395
393
|
private _clearingHouse?;
|
|
396
394
|
private _signatureStore?;
|
|
397
|
-
private _hedgerBaseUrl?;
|
|
398
395
|
constructor(options: {
|
|
399
396
|
chainId: number;
|
|
400
397
|
publicClient: PublicClient;
|
|
@@ -482,7 +479,6 @@ declare class SymmioSDK {
|
|
|
482
479
|
grantRole: (role: Hex, grantee: Address) => Promise<`0x${string}`>;
|
|
483
480
|
revokeRole: (role: Hex, revokee: Address) => Promise<`0x${string}`>;
|
|
484
481
|
};
|
|
485
|
-
private _requireHedgerUrl;
|
|
486
482
|
get instant(): {
|
|
487
483
|
/** Creates a SIWE message for instant trading authentication. */
|
|
488
484
|
createSiweMessage: (params: CreateSiweMessageParams) => SiweMessageResult;
|
|
@@ -19591,6 +19587,7 @@ declare const ALL_TRADING_SELECTORS: Hex[];
|
|
|
19591
19587
|
/**
|
|
19592
19588
|
* Default configuration values for Symmio SDK.
|
|
19593
19589
|
*/
|
|
19590
|
+
|
|
19594
19591
|
/** Market order deadline: 5 minutes */
|
|
19595
19592
|
declare const MARKET_ORDER_DEADLINE = 300n;
|
|
19596
19593
|
/** Limit order deadline: ~10 years */
|
|
@@ -19860,27 +19857,27 @@ declare function createSiweMessage(params: CreateSiweMessageParams): SiweMessage
|
|
|
19860
19857
|
/**
|
|
19861
19858
|
* Fetches a nonce from the hedger for SIWE authentication.
|
|
19862
19859
|
*/
|
|
19863
|
-
declare function getNonce(
|
|
19860
|
+
declare function getNonce(chainId: number, subAccount: Address): Promise<string>;
|
|
19864
19861
|
/**
|
|
19865
19862
|
* Exchanges a signed SIWE message for an access token from the hedger.
|
|
19866
19863
|
*/
|
|
19867
|
-
declare function login(
|
|
19864
|
+
declare function login(chainId: number, params: InstantLoginParams): Promise<InstantAuthToken>;
|
|
19868
19865
|
/**
|
|
19869
19866
|
* Opens a position instantly via the hedger's off-chain endpoint.
|
|
19870
19867
|
*/
|
|
19871
|
-
declare function instantOpen(
|
|
19868
|
+
declare function instantOpen(chainId: number, params: InstantOpenParams, accessToken: string): Promise<InstantOpenResponse>;
|
|
19872
19869
|
/**
|
|
19873
19870
|
* Closes a position instantly via the hedger's off-chain endpoint.
|
|
19874
19871
|
*/
|
|
19875
|
-
declare function instantClose(
|
|
19872
|
+
declare function instantClose(chainId: number, params: InstantCloseParams, accessToken: string): Promise<InstantCloseResponse>;
|
|
19876
19873
|
/**
|
|
19877
19874
|
* Cancels a pending instant close request.
|
|
19878
19875
|
*/
|
|
19879
|
-
declare function cancelInstantClose(
|
|
19876
|
+
declare function cancelInstantClose(chainId: number, quoteId: string, accessToken: string): Promise<void>;
|
|
19880
19877
|
/**
|
|
19881
19878
|
* Fetches the list of open (pending) instant close requests for an account.
|
|
19882
19879
|
*/
|
|
19883
|
-
declare function getOpenInstantCloses(
|
|
19880
|
+
declare function getOpenInstantCloses(chainId: number, account: Address, accessToken: string): Promise<unknown[]>;
|
|
19884
19881
|
|
|
19885
19882
|
declare const instant_cancelInstantClose: typeof cancelInstantClose;
|
|
19886
19883
|
declare const instant_createSiweMessage: typeof createSiweMessage;
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,10 @@ var MUON_BASE_URLS = [
|
|
|
82
82
|
];
|
|
83
83
|
var MUON_APP_NAME = "symmio";
|
|
84
84
|
var MUON_REQUEST_TIMEOUT = 15e3;
|
|
85
|
+
var HEDGER_BASE_URLS = {
|
|
86
|
+
[42161 /* ARBITRUM */]: "https://www.perps-streaming.com/v1/42161a/0x6273242a7E88b3De90822b31648C212215caaFE4",
|
|
87
|
+
[8453 /* BASE */]: "https://www.perps-streaming.com/v1/8453a/0x6273242a7E88b3De90822b31648C212215caaFE4"
|
|
88
|
+
};
|
|
85
89
|
var SymmioSDKError = class extends Error {
|
|
86
90
|
constructor(message, code) {
|
|
87
91
|
super(message);
|
|
@@ -24108,6 +24112,13 @@ __export(instant_exports, {
|
|
|
24108
24112
|
instantOpen: () => instantOpen,
|
|
24109
24113
|
login: () => login
|
|
24110
24114
|
});
|
|
24115
|
+
function getHedgerBaseUrl(chainId) {
|
|
24116
|
+
const baseUrl = HEDGER_BASE_URLS[chainId];
|
|
24117
|
+
if (!baseUrl) {
|
|
24118
|
+
throw new Error(`No hedger base URL configured for chain ${chainId}.`);
|
|
24119
|
+
}
|
|
24120
|
+
return baseUrl;
|
|
24121
|
+
}
|
|
24111
24122
|
function createSiweMessage(params) {
|
|
24112
24123
|
const version = params.version ?? "1";
|
|
24113
24124
|
const issuedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -24129,7 +24140,8 @@ function createSiweMessage(params) {
|
|
|
24129
24140
|
].join("\n");
|
|
24130
24141
|
return { message, issuedAt, expirationTime };
|
|
24131
24142
|
}
|
|
24132
|
-
async function getNonce(
|
|
24143
|
+
async function getNonce(chainId, subAccount) {
|
|
24144
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24133
24145
|
const url = new URL(`nonce/${subAccount}`, hedgerBaseUrl).href;
|
|
24134
24146
|
const response = await fetch(url);
|
|
24135
24147
|
if (!response.ok) {
|
|
@@ -24138,7 +24150,8 @@ async function getNonce(hedgerBaseUrl, subAccount) {
|
|
|
24138
24150
|
const data = await response.json();
|
|
24139
24151
|
return data.nonce;
|
|
24140
24152
|
}
|
|
24141
|
-
async function login(
|
|
24153
|
+
async function login(chainId, params) {
|
|
24154
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24142
24155
|
const url = new URL("login", hedgerBaseUrl).href;
|
|
24143
24156
|
const body = {
|
|
24144
24157
|
account_address: params.accountAddress,
|
|
@@ -24168,7 +24181,8 @@ async function login(hedgerBaseUrl, params) {
|
|
|
24168
24181
|
issuedAt: params.issuedAt
|
|
24169
24182
|
};
|
|
24170
24183
|
}
|
|
24171
|
-
async function instantOpen(
|
|
24184
|
+
async function instantOpen(chainId, params, accessToken) {
|
|
24185
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24172
24186
|
const url = new URL("instant_open", hedgerBaseUrl).href;
|
|
24173
24187
|
const body = {
|
|
24174
24188
|
symbolId: params.symbolId,
|
|
@@ -24199,7 +24213,8 @@ async function instantOpen(hedgerBaseUrl, params, accessToken) {
|
|
|
24199
24213
|
}
|
|
24200
24214
|
return response.json();
|
|
24201
24215
|
}
|
|
24202
|
-
async function instantClose(
|
|
24216
|
+
async function instantClose(chainId, params, accessToken) {
|
|
24217
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24203
24218
|
const url = new URL("instant_close", hedgerBaseUrl).href;
|
|
24204
24219
|
const body = {
|
|
24205
24220
|
quote_id: params.quoteId,
|
|
@@ -24222,7 +24237,8 @@ async function instantClose(hedgerBaseUrl, params, accessToken) {
|
|
|
24222
24237
|
}
|
|
24223
24238
|
return response.json();
|
|
24224
24239
|
}
|
|
24225
|
-
async function cancelInstantClose(
|
|
24240
|
+
async function cancelInstantClose(chainId, quoteId, accessToken) {
|
|
24241
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24226
24242
|
const url = new URL(`instant_close/${quoteId}`, hedgerBaseUrl).href;
|
|
24227
24243
|
const response = await fetch(url, {
|
|
24228
24244
|
method: "DELETE",
|
|
@@ -24238,7 +24254,8 @@ async function cancelInstantClose(hedgerBaseUrl, quoteId, accessToken) {
|
|
|
24238
24254
|
);
|
|
24239
24255
|
}
|
|
24240
24256
|
}
|
|
24241
|
-
async function getOpenInstantCloses(
|
|
24257
|
+
async function getOpenInstantCloses(chainId, account, accessToken) {
|
|
24258
|
+
const hedgerBaseUrl = getHedgerBaseUrl(chainId);
|
|
24242
24259
|
const url = new URL(`instant_close/${account}`, hedgerBaseUrl).href;
|
|
24243
24260
|
const response = await fetch(url, {
|
|
24244
24261
|
headers: {
|
|
@@ -24265,7 +24282,6 @@ var SymmioSDK = class {
|
|
|
24265
24282
|
_collateral;
|
|
24266
24283
|
_clearingHouse;
|
|
24267
24284
|
_signatureStore;
|
|
24268
|
-
_hedgerBaseUrl;
|
|
24269
24285
|
constructor(options) {
|
|
24270
24286
|
this.chainId = options.chainId;
|
|
24271
24287
|
this._publicClient = options.publicClient;
|
|
@@ -24282,7 +24298,6 @@ var SymmioSDK = class {
|
|
|
24282
24298
|
this._signatureStore = cfg.signatureStoreAddress ?? getAddress(SIGNATURE_STORE_ADDRESS, this.chainId, "SignatureStore");
|
|
24283
24299
|
} catch {
|
|
24284
24300
|
}
|
|
24285
|
-
this._hedgerBaseUrl = cfg.hedgerBaseUrl;
|
|
24286
24301
|
this.muon = new MuonClient({
|
|
24287
24302
|
baseUrls: cfg.muonBaseUrls ?? MUON_BASE_URLS,
|
|
24288
24303
|
appName: cfg.muonAppName ?? MUON_APP_NAME
|
|
@@ -24440,46 +24455,22 @@ var SymmioSDK = class {
|
|
|
24440
24455
|
};
|
|
24441
24456
|
}
|
|
24442
24457
|
// ─── Instant Trading Module ──────────────────────────────────
|
|
24443
|
-
_requireHedgerUrl() {
|
|
24444
|
-
if (!this._hedgerBaseUrl) {
|
|
24445
|
-
throw new Error(
|
|
24446
|
-
"hedgerBaseUrl is required for instant trading. Pass it in the SDK config."
|
|
24447
|
-
);
|
|
24448
|
-
}
|
|
24449
|
-
return this._hedgerBaseUrl;
|
|
24450
|
-
}
|
|
24451
24458
|
get instant() {
|
|
24452
24459
|
return {
|
|
24453
24460
|
/** Creates a SIWE message for instant trading authentication. */
|
|
24454
24461
|
createSiweMessage: (params) => createSiweMessage(params),
|
|
24455
24462
|
/** Fetches a nonce from the hedger for SIWE authentication. */
|
|
24456
|
-
getNonce: (subAccount) => getNonce(this.
|
|
24463
|
+
getNonce: (subAccount) => getNonce(this.chainId, subAccount),
|
|
24457
24464
|
/** Exchanges a signed SIWE message for an access token. */
|
|
24458
|
-
login: (params) => login(this.
|
|
24465
|
+
login: (params) => login(this.chainId, params),
|
|
24459
24466
|
/** Opens a position instantly via the hedger (off-chain). */
|
|
24460
|
-
open: (params, accessToken) => instantOpen(
|
|
24461
|
-
this._requireHedgerUrl(),
|
|
24462
|
-
params,
|
|
24463
|
-
accessToken
|
|
24464
|
-
),
|
|
24467
|
+
open: (params, accessToken) => instantOpen(this.chainId, params, accessToken),
|
|
24465
24468
|
/** Closes a position instantly via the hedger (off-chain). */
|
|
24466
|
-
close: (params, accessToken) => instantClose(
|
|
24467
|
-
this._requireHedgerUrl(),
|
|
24468
|
-
params,
|
|
24469
|
-
accessToken
|
|
24470
|
-
),
|
|
24469
|
+
close: (params, accessToken) => instantClose(this.chainId, params, accessToken),
|
|
24471
24470
|
/** Cancels a pending instant close request. */
|
|
24472
|
-
cancelClose: (quoteId, accessToken) => cancelInstantClose(
|
|
24473
|
-
this._requireHedgerUrl(),
|
|
24474
|
-
quoteId,
|
|
24475
|
-
accessToken
|
|
24476
|
-
),
|
|
24471
|
+
cancelClose: (quoteId, accessToken) => cancelInstantClose(this.chainId, quoteId, accessToken),
|
|
24477
24472
|
/** Fetches the list of open instant close requests for an account. */
|
|
24478
|
-
getOpenCloses: (account, accessToken) => getOpenInstantCloses(
|
|
24479
|
-
this._requireHedgerUrl(),
|
|
24480
|
-
account,
|
|
24481
|
-
accessToken
|
|
24482
|
-
)
|
|
24473
|
+
getOpenCloses: (account, accessToken) => getOpenInstantCloses(this.chainId, account, accessToken)
|
|
24483
24474
|
};
|
|
24484
24475
|
}
|
|
24485
24476
|
// ─── Muon Signatures ──────────────────────────────────────────
|