@pear-protocol/symmio-client 0.2.1 → 0.2.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 +4439 -2
- package/dist/index.d.ts +4439 -2
- package/dist/index.js +132 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -32
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +4439 -2
- package/dist/react/index.d.ts +4439 -2
- package/dist/react/index.js +143 -35
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +143 -35
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -24047,6 +24047,18 @@ var SymmioSDK = class {
|
|
|
24047
24047
|
appName: cfg.muonAppName ?? MUON_APP_NAME
|
|
24048
24048
|
});
|
|
24049
24049
|
}
|
|
24050
|
+
get walletClient() {
|
|
24051
|
+
return this._walletClient ?? null;
|
|
24052
|
+
}
|
|
24053
|
+
get isWriteReady() {
|
|
24054
|
+
return !!this._walletClient;
|
|
24055
|
+
}
|
|
24056
|
+
requireWalletClient() {
|
|
24057
|
+
if (!this._walletClient) {
|
|
24058
|
+
throw new Error("WalletClient is required for write operations");
|
|
24059
|
+
}
|
|
24060
|
+
return this._walletClient;
|
|
24061
|
+
}
|
|
24050
24062
|
// ─── Contract Addresses ────────────────────────────────────────
|
|
24051
24063
|
get addresses() {
|
|
24052
24064
|
return {
|
|
@@ -24059,14 +24071,19 @@ var SymmioSDK = class {
|
|
|
24059
24071
|
}
|
|
24060
24072
|
// ─── Account Module (MultiAccount) ─────────────────────────────
|
|
24061
24073
|
get account() {
|
|
24062
|
-
const wc = this._walletClient;
|
|
24063
24074
|
const pc = this._publicClient;
|
|
24064
24075
|
const ma = this._multiAccount;
|
|
24065
24076
|
return {
|
|
24066
24077
|
/** Creates a new account. */
|
|
24067
|
-
addAccount: (name) => addAccount(
|
|
24078
|
+
addAccount: (name) => addAccount(this.requireWalletClient(), pc, ma, name),
|
|
24068
24079
|
/** Edits an account's name. */
|
|
24069
|
-
editName: (accountAddress, name) => editAccountName(
|
|
24080
|
+
editName: (accountAddress, name) => editAccountName(
|
|
24081
|
+
this.requireWalletClient(),
|
|
24082
|
+
pc,
|
|
24083
|
+
ma,
|
|
24084
|
+
accountAddress,
|
|
24085
|
+
name
|
|
24086
|
+
),
|
|
24070
24087
|
/** Gets all accounts for a user (paginated). */
|
|
24071
24088
|
getAll: (user, start, size) => getAccounts(pc, ma, user, start, size),
|
|
24072
24089
|
/** Gets the number of accounts for a user. */
|
|
@@ -24077,71 +24094,137 @@ var SymmioSDK = class {
|
|
|
24077
24094
|
}
|
|
24078
24095
|
// ─── Deposit Module (MultiAccount) ─────────────────────────────
|
|
24079
24096
|
get deposit() {
|
|
24080
|
-
const wc = this._walletClient;
|
|
24081
24097
|
const pc = this._publicClient;
|
|
24082
24098
|
const ma = this._multiAccount;
|
|
24083
24099
|
return {
|
|
24084
24100
|
/** Standard deposit to an account. */
|
|
24085
|
-
standard: (params) => deposit(
|
|
24101
|
+
standard: (params) => deposit(this.requireWalletClient(), pc, ma, params),
|
|
24086
24102
|
/** Deposit and allocate in a single transaction. */
|
|
24087
|
-
depositAndAllocate: (params) => depositAndAllocate(
|
|
24103
|
+
depositAndAllocate: (params) => depositAndAllocate(
|
|
24104
|
+
this.requireWalletClient(),
|
|
24105
|
+
pc,
|
|
24106
|
+
ma,
|
|
24107
|
+
params
|
|
24108
|
+
)
|
|
24088
24109
|
};
|
|
24089
24110
|
}
|
|
24090
24111
|
// ─── Withdraw Module (MultiAccount) ────────────────────────────
|
|
24091
24112
|
get withdraw() {
|
|
24092
|
-
const wc = this._walletClient;
|
|
24093
24113
|
const pc = this._publicClient;
|
|
24094
24114
|
const ma = this._multiAccount;
|
|
24095
24115
|
return {
|
|
24096
24116
|
/** Withdraws collateral from an account. */
|
|
24097
|
-
withdraw: (params) => withdraw(
|
|
24117
|
+
withdraw: (params) => withdraw(this.requireWalletClient(), pc, ma, params)
|
|
24098
24118
|
};
|
|
24099
24119
|
}
|
|
24100
24120
|
// ─── Allocate / Deallocate Module (via _call proxy) ────────────
|
|
24101
24121
|
get collateral() {
|
|
24102
|
-
const wc = this._walletClient;
|
|
24103
24122
|
const pc = this._publicClient;
|
|
24104
24123
|
const ma = this._multiAccount;
|
|
24105
24124
|
return {
|
|
24106
24125
|
/** Allocate collateral to a trading account. */
|
|
24107
|
-
allocate: (subAccount, params) => allocate(
|
|
24126
|
+
allocate: (subAccount, params) => allocate(
|
|
24127
|
+
this.requireWalletClient(),
|
|
24128
|
+
pc,
|
|
24129
|
+
ma,
|
|
24130
|
+
subAccount,
|
|
24131
|
+
params
|
|
24132
|
+
),
|
|
24108
24133
|
/** Deallocate collateral (requires Muon signature). */
|
|
24109
|
-
deallocate: (subAccount, params) => deallocate(
|
|
24134
|
+
deallocate: (subAccount, params) => deallocate(
|
|
24135
|
+
this.requireWalletClient(),
|
|
24136
|
+
pc,
|
|
24137
|
+
ma,
|
|
24138
|
+
subAccount,
|
|
24139
|
+
params
|
|
24140
|
+
),
|
|
24110
24141
|
/** Transfer funds to recipient's allocated balance. */
|
|
24111
|
-
internalTransfer: (subAccount, params) => internalTransfer(
|
|
24142
|
+
internalTransfer: (subAccount, params) => internalTransfer(
|
|
24143
|
+
this.requireWalletClient(),
|
|
24144
|
+
pc,
|
|
24145
|
+
ma,
|
|
24146
|
+
subAccount,
|
|
24147
|
+
params
|
|
24148
|
+
)
|
|
24112
24149
|
};
|
|
24113
24150
|
}
|
|
24114
24151
|
// ─── Trade Module ──────────────────────────────────────────────
|
|
24115
24152
|
get trade() {
|
|
24116
|
-
const wc = this._walletClient;
|
|
24117
24153
|
const pc = this._publicClient;
|
|
24118
24154
|
const ma = this._multiAccount;
|
|
24119
24155
|
return {
|
|
24120
24156
|
/** Opens a position via sendQuoteWithAffiliate. */
|
|
24121
|
-
sendQuote: (subAccount, params) => sendQuote(
|
|
24157
|
+
sendQuote: (subAccount, params) => sendQuote(
|
|
24158
|
+
this.requireWalletClient(),
|
|
24159
|
+
pc,
|
|
24160
|
+
ma,
|
|
24161
|
+
subAccount,
|
|
24162
|
+
params
|
|
24163
|
+
),
|
|
24122
24164
|
/** Close a position. */
|
|
24123
|
-
closePosition: (subAccount, params) => closePosition(
|
|
24165
|
+
closePosition: (subAccount, params) => closePosition(
|
|
24166
|
+
this.requireWalletClient(),
|
|
24167
|
+
pc,
|
|
24168
|
+
ma,
|
|
24169
|
+
subAccount,
|
|
24170
|
+
params
|
|
24171
|
+
),
|
|
24124
24172
|
/** Cancel a pending quote. */
|
|
24125
|
-
cancelQuote: (subAccount, quoteId) => cancelQuote(
|
|
24173
|
+
cancelQuote: (subAccount, quoteId) => cancelQuote(
|
|
24174
|
+
this.requireWalletClient(),
|
|
24175
|
+
pc,
|
|
24176
|
+
ma,
|
|
24177
|
+
subAccount,
|
|
24178
|
+
quoteId
|
|
24179
|
+
),
|
|
24126
24180
|
/** Cancel a pending close request. */
|
|
24127
|
-
cancelCloseRequest: (subAccount, quoteId) => cancelCloseRequest(
|
|
24181
|
+
cancelCloseRequest: (subAccount, quoteId) => cancelCloseRequest(
|
|
24182
|
+
this.requireWalletClient(),
|
|
24183
|
+
pc,
|
|
24184
|
+
ma,
|
|
24185
|
+
subAccount,
|
|
24186
|
+
quoteId
|
|
24187
|
+
),
|
|
24128
24188
|
/** Force cancel a quote. */
|
|
24129
|
-
forceCancelQuote: (subAccount, quoteId) => forceCancelQuote(
|
|
24189
|
+
forceCancelQuote: (subAccount, quoteId) => forceCancelQuote(
|
|
24190
|
+
this.requireWalletClient(),
|
|
24191
|
+
pc,
|
|
24192
|
+
ma,
|
|
24193
|
+
subAccount,
|
|
24194
|
+
quoteId
|
|
24195
|
+
),
|
|
24130
24196
|
/** Force cancel a close request. */
|
|
24131
|
-
forceCancelCloseRequest: (subAccount, quoteId) => forceCancelCloseRequest(
|
|
24197
|
+
forceCancelCloseRequest: (subAccount, quoteId) => forceCancelCloseRequest(
|
|
24198
|
+
this.requireWalletClient(),
|
|
24199
|
+
pc,
|
|
24200
|
+
ma,
|
|
24201
|
+
subAccount,
|
|
24202
|
+
quoteId
|
|
24203
|
+
)
|
|
24132
24204
|
};
|
|
24133
24205
|
}
|
|
24134
24206
|
// ─── Approval Module ───────────────────────────────────────────
|
|
24135
24207
|
get approval() {
|
|
24136
|
-
const wc = this._walletClient;
|
|
24137
24208
|
const pc = this._publicClient;
|
|
24138
24209
|
const collateral = this._collateral;
|
|
24139
24210
|
const ma = this._multiAccount;
|
|
24140
24211
|
return {
|
|
24141
24212
|
/** Approve the MultiAccount contract to spend collateral. */
|
|
24142
|
-
approveCollateral: (amount) => approve(
|
|
24213
|
+
approveCollateral: (amount) => approve(
|
|
24214
|
+
this.requireWalletClient(),
|
|
24215
|
+
pc,
|
|
24216
|
+
collateral,
|
|
24217
|
+
ma,
|
|
24218
|
+
amount
|
|
24219
|
+
),
|
|
24143
24220
|
/** Approve any spender for any token. */
|
|
24144
|
-
approve: (token, spender, amount) => approve(
|
|
24221
|
+
approve: (token, spender, amount) => approve(
|
|
24222
|
+
this.requireWalletClient(),
|
|
24223
|
+
pc,
|
|
24224
|
+
token,
|
|
24225
|
+
spender,
|
|
24226
|
+
amount
|
|
24227
|
+
),
|
|
24145
24228
|
/** Get current allowance. */
|
|
24146
24229
|
getAllowance: (token, owner, spender) => getAllowance(pc, token, owner, spender),
|
|
24147
24230
|
/** Get token balance. */
|
|
@@ -24152,33 +24235,51 @@ var SymmioSDK = class {
|
|
|
24152
24235
|
}
|
|
24153
24236
|
// ─── Delegation Module ─────────────────────────────────────────
|
|
24154
24237
|
get delegation() {
|
|
24155
|
-
const wc = this._walletClient;
|
|
24156
24238
|
const pc = this._publicClient;
|
|
24157
24239
|
const ma = this._multiAccount;
|
|
24158
24240
|
return {
|
|
24159
24241
|
/** Delegate access to selectors. */
|
|
24160
|
-
delegateAccess: (params) => delegateAccess(
|
|
24242
|
+
delegateAccess: (params) => delegateAccess(
|
|
24243
|
+
this.requireWalletClient(),
|
|
24244
|
+
pc,
|
|
24245
|
+
ma,
|
|
24246
|
+
params
|
|
24247
|
+
),
|
|
24161
24248
|
/** Propose to revoke delegated access (starts cooldown). */
|
|
24162
|
-
proposeRevoke: (params) => proposeRevoke(
|
|
24249
|
+
proposeRevoke: (params) => proposeRevoke(
|
|
24250
|
+
this.requireWalletClient(),
|
|
24251
|
+
pc,
|
|
24252
|
+
ma,
|
|
24253
|
+
params
|
|
24254
|
+
),
|
|
24163
24255
|
/** Revoke delegated access (after cooldown). */
|
|
24164
|
-
revokeAccess: (params) => revokeAccess(
|
|
24256
|
+
revokeAccess: (params) => revokeAccess(
|
|
24257
|
+
this.requireWalletClient(),
|
|
24258
|
+
pc,
|
|
24259
|
+
ma,
|
|
24260
|
+
params
|
|
24261
|
+
),
|
|
24165
24262
|
/** Reads whether a selector is delegated to a target for a sub-account. */
|
|
24166
24263
|
hasAccess: (params) => hasDelegatedAccess(pc, ma, params)
|
|
24167
24264
|
};
|
|
24168
24265
|
}
|
|
24169
24266
|
// ─── Signature Module ──────────────────────────────────────────
|
|
24170
24267
|
get signature() {
|
|
24171
|
-
const wc = this._walletClient;
|
|
24172
24268
|
const pc = this._publicClient;
|
|
24173
24269
|
const ss = this._signatureStore;
|
|
24174
24270
|
return {
|
|
24175
24271
|
signTerms: () => {
|
|
24176
24272
|
if (!ss) throw new Error("SignatureStore not configured for this chain");
|
|
24177
|
-
return signTermsMessage(
|
|
24273
|
+
return signTermsMessage(this.requireWalletClient(), pc, ss);
|
|
24178
24274
|
},
|
|
24179
24275
|
storeSignature: (sig) => {
|
|
24180
24276
|
if (!ss) throw new Error("SignatureStore not configured for this chain");
|
|
24181
|
-
return storeSignature(
|
|
24277
|
+
return storeSignature(
|
|
24278
|
+
this.requireWalletClient(),
|
|
24279
|
+
pc,
|
|
24280
|
+
ss,
|
|
24281
|
+
sig
|
|
24282
|
+
);
|
|
24182
24283
|
},
|
|
24183
24284
|
hasSigned: (user) => {
|
|
24184
24285
|
if (!ss) throw new Error("SignatureStore not configured for this chain");
|
|
@@ -24192,12 +24293,11 @@ var SymmioSDK = class {
|
|
|
24192
24293
|
}
|
|
24193
24294
|
// ─── Admin Module ──────────────────────────────────────────────
|
|
24194
24295
|
get admin() {
|
|
24195
|
-
const wc = this._walletClient;
|
|
24196
24296
|
const pc = this._publicClient;
|
|
24197
24297
|
const sd = this._symmioDiamond;
|
|
24198
24298
|
return {
|
|
24199
|
-
grantRole: (role, grantee) => grantRole(
|
|
24200
|
-
revokeRole: (role, revokee) => revokeRole(
|
|
24299
|
+
grantRole: (role, grantee) => grantRole(this.requireWalletClient(), pc, sd, role, grantee),
|
|
24300
|
+
revokeRole: (role, revokee) => revokeRole(this.requireWalletClient(), pc, sd, role, revokee)
|
|
24201
24301
|
};
|
|
24202
24302
|
}
|
|
24203
24303
|
// ─── Instant Trading Module ──────────────────────────────────
|
|
@@ -24372,7 +24472,7 @@ function SymmProvider({
|
|
|
24372
24472
|
} = symmioConfig ?? {};
|
|
24373
24473
|
const muonBaseUrlsKey = muonBaseUrls?.join(",");
|
|
24374
24474
|
const symmioClient = react.useMemo(() => {
|
|
24375
|
-
if (!publicClient
|
|
24475
|
+
if (!publicClient) return null;
|
|
24376
24476
|
return new SymmioSDK({
|
|
24377
24477
|
chainId,
|
|
24378
24478
|
publicClient,
|
|
@@ -24382,7 +24482,6 @@ function SymmProvider({
|
|
|
24382
24482
|
}, [
|
|
24383
24483
|
publicClient,
|
|
24384
24484
|
walletClient,
|
|
24385
|
-
address,
|
|
24386
24485
|
chainId,
|
|
24387
24486
|
multiAccountAddress,
|
|
24388
24487
|
symmioDiamondAddress,
|
|
@@ -24401,6 +24500,7 @@ function SymmProvider({
|
|
|
24401
24500
|
hasPublicClient: !!publicClient,
|
|
24402
24501
|
hasWalletClient: !!walletClient,
|
|
24403
24502
|
hasAddress: !!address,
|
|
24503
|
+
isWriteReady: !!symmioClient?.isWriteReady,
|
|
24404
24504
|
symmioClientBuilt: !!symmioClient
|
|
24405
24505
|
});
|
|
24406
24506
|
}, [
|
|
@@ -24484,9 +24584,17 @@ function SymmProvider({
|
|
|
24484
24584
|
accessToken,
|
|
24485
24585
|
authToken: accessToken,
|
|
24486
24586
|
isReady: !!symmioClient && !!symmCoreClient,
|
|
24587
|
+
isWriteReady: !!symmioClient?.isWriteReady,
|
|
24487
24588
|
refreshAuth
|
|
24488
24589
|
}),
|
|
24489
|
-
[
|
|
24590
|
+
[
|
|
24591
|
+
symmioClient,
|
|
24592
|
+
symmCoreClient,
|
|
24593
|
+
chainId,
|
|
24594
|
+
address,
|
|
24595
|
+
accessToken,
|
|
24596
|
+
refreshAuth
|
|
24597
|
+
]
|
|
24490
24598
|
);
|
|
24491
24599
|
return /* @__PURE__ */ jsxRuntime.jsx(SymmContext.Provider, { value, children });
|
|
24492
24600
|
}
|