@pear-protocol/symmio-client 0.1.4 → 0.1.6
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 +67 -26
- package/dist/index.d.ts +67 -26
- package/dist/index.js +77 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +138 -7
- package/dist/react/index.d.ts +138 -7
- package/dist/react/index.js +279 -30
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +278 -32
- package/dist/react/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -23859,6 +23859,7 @@ async function getApprovalState(publicClient, tokenAddress, owner, spender, requ
|
|
|
23859
23859
|
var delegation_exports = {};
|
|
23860
23860
|
__export(delegation_exports, {
|
|
23861
23861
|
delegateAccess: () => delegateAccess,
|
|
23862
|
+
hasDelegatedAccess: () => hasDelegatedAccess,
|
|
23862
23863
|
prepareDelegateAccess: () => prepareDelegateAccess,
|
|
23863
23864
|
prepareProposeRevoke: () => prepareProposeRevoke,
|
|
23864
23865
|
prepareRevokeAccess: () => prepareRevokeAccess,
|
|
@@ -23936,6 +23937,17 @@ async function revokeAccess(walletClient, publicClient, multiAccount, params) {
|
|
|
23936
23937
|
chain: walletClient.chain
|
|
23937
23938
|
});
|
|
23938
23939
|
}
|
|
23940
|
+
async function hasDelegatedAccess(publicClient, multiAccount, params) {
|
|
23941
|
+
validateAddress(params.account, "subAccount");
|
|
23942
|
+
validateAddress(params.target, "target");
|
|
23943
|
+
const result = await publicClient.readContract({
|
|
23944
|
+
address: multiAccount,
|
|
23945
|
+
abi: MultiAccountABI,
|
|
23946
|
+
functionName: "delegatedAccesses",
|
|
23947
|
+
args: [params.account, params.target, params.selector]
|
|
23948
|
+
});
|
|
23949
|
+
return Boolean(result);
|
|
23950
|
+
}
|
|
23939
23951
|
|
|
23940
23952
|
// src/actions/signature.ts
|
|
23941
23953
|
var signature_exports = {};
|
|
@@ -24269,6 +24281,56 @@ async function getOpenInstantCloses(chainId, account, accessToken) {
|
|
|
24269
24281
|
return response.json();
|
|
24270
24282
|
}
|
|
24271
24283
|
|
|
24284
|
+
// src/actions/stats.ts
|
|
24285
|
+
var stats_exports = {};
|
|
24286
|
+
__export(stats_exports, {
|
|
24287
|
+
calculateAvailableForOrder: () => calculateAvailableForOrder,
|
|
24288
|
+
getPartyAStats: () => getPartyAStats
|
|
24289
|
+
});
|
|
24290
|
+
async function getPartyAStats(publicClient, symmioDiamond, partyA) {
|
|
24291
|
+
const result = await publicClient.readContract({
|
|
24292
|
+
address: symmioDiamond,
|
|
24293
|
+
abi: SymmioDiamondABI,
|
|
24294
|
+
functionName: "partyAStats",
|
|
24295
|
+
args: [partyA]
|
|
24296
|
+
});
|
|
24297
|
+
return {
|
|
24298
|
+
collateralBalance: result[1],
|
|
24299
|
+
allocatedBalance: result[2],
|
|
24300
|
+
availableBalance: result[3],
|
|
24301
|
+
lockedCVA: result[4],
|
|
24302
|
+
lockedLF: result[5],
|
|
24303
|
+
lockedPartyAMM: result[6],
|
|
24304
|
+
lockedPartyBMM: result[7],
|
|
24305
|
+
pendingLockedCVA: result[8],
|
|
24306
|
+
pendingLockedLF: result[9],
|
|
24307
|
+
pendingLockedPartyAMM: result[10],
|
|
24308
|
+
pendingLockedPartyBMM: result[11],
|
|
24309
|
+
positionsCount: Number(result[12]),
|
|
24310
|
+
pendingCount: Number(result[13]),
|
|
24311
|
+
nonces: 0
|
|
24312
|
+
};
|
|
24313
|
+
}
|
|
24314
|
+
function calculateAvailableForOrder(stats, upnl) {
|
|
24315
|
+
const {
|
|
24316
|
+
allocatedBalance,
|
|
24317
|
+
lockedCVA,
|
|
24318
|
+
lockedLF,
|
|
24319
|
+
lockedPartyAMM,
|
|
24320
|
+
pendingLockedCVA,
|
|
24321
|
+
pendingLockedLF,
|
|
24322
|
+
pendingLockedPartyAMM
|
|
24323
|
+
} = stats;
|
|
24324
|
+
const totalPendingLocked = pendingLockedCVA + pendingLockedLF + pendingLockedPartyAMM;
|
|
24325
|
+
if (upnl >= 0n) {
|
|
24326
|
+
const totalLocked = lockedCVA + lockedLF + lockedPartyAMM;
|
|
24327
|
+
return allocatedBalance + upnl - totalLocked - totalPendingLocked;
|
|
24328
|
+
}
|
|
24329
|
+
const absUpnl = -upnl;
|
|
24330
|
+
const consideringMm = absUpnl > lockedPartyAMM ? absUpnl : lockedPartyAMM;
|
|
24331
|
+
return allocatedBalance - lockedCVA - lockedLF - totalPendingLocked - consideringMm;
|
|
24332
|
+
}
|
|
24333
|
+
|
|
24272
24334
|
// src/client.ts
|
|
24273
24335
|
var SymmioSDK = class {
|
|
24274
24336
|
chainId;
|
|
@@ -24415,7 +24477,9 @@ var SymmioSDK = class {
|
|
|
24415
24477
|
/** Propose to revoke delegated access (starts cooldown). */
|
|
24416
24478
|
proposeRevoke: (params) => proposeRevoke(wc, pc, ma, params),
|
|
24417
24479
|
/** Revoke delegated access (after cooldown). */
|
|
24418
|
-
revokeAccess: (params) => revokeAccess(wc, pc, ma, params)
|
|
24480
|
+
revokeAccess: (params) => revokeAccess(wc, pc, ma, params),
|
|
24481
|
+
/** Reads whether a selector is delegated to a target for a sub-account. */
|
|
24482
|
+
hasAccess: (params) => hasDelegatedAccess(pc, ma, params)
|
|
24419
24483
|
};
|
|
24420
24484
|
}
|
|
24421
24485
|
// ─── Signature Module ──────────────────────────────────────────
|
|
@@ -24471,6 +24535,17 @@ var SymmioSDK = class {
|
|
|
24471
24535
|
getOpenCloses: (account, accessToken) => getOpenInstantCloses(this.chainId, account, accessToken)
|
|
24472
24536
|
};
|
|
24473
24537
|
}
|
|
24538
|
+
// ─── Stats Module ───────────────────────────────────────────
|
|
24539
|
+
get stats() {
|
|
24540
|
+
const pc = this._publicClient;
|
|
24541
|
+
const sd = this._symmioDiamond;
|
|
24542
|
+
return {
|
|
24543
|
+
/** Reads partyA statistics (balances, locks) from the Diamond contract. */
|
|
24544
|
+
getPartyAStats: (partyA) => getPartyAStats(pc, sd, partyA),
|
|
24545
|
+
/** Calculates available margin for placing orders given uPNL. */
|
|
24546
|
+
calculateAvailableForOrder: (stats, upnl) => calculateAvailableForOrder(stats, upnl)
|
|
24547
|
+
};
|
|
24548
|
+
}
|
|
24474
24549
|
// ─── Muon Signatures ──────────────────────────────────────────
|
|
24475
24550
|
async getQuoteSig(partyA, symbolId) {
|
|
24476
24551
|
return this.muon.getQuoteSig({
|
|
@@ -24804,6 +24879,6 @@ function applySlippage(price, slippagePercent, isLong) {
|
|
|
24804
24879
|
return price - price * bps / 10000n;
|
|
24805
24880
|
}
|
|
24806
24881
|
|
|
24807
|
-
export { ALL_TRADING_SELECTORS, AffiliateFeeLevel, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, ClearingHouseABI, ClearingHouseLiquidationStatus, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, ERC20ABI, FALLBACK_CHAIN_ID, InstantCloseStatus, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, MultiAccountABI, MuonClient, MuonVerifierABI, OrderType, PositionType, QuoteStatus, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, SignatureStoreABI, SoftLiquidationLevel, SupportedChainId, SymmioDiamondABI, SymmioSDK, SymmioSDKError, V3_CHAIN_IDS, account_exports as accountActions, admin_exports as adminActions, allocate_exports as allocateActions, applySlippage, approval_exports as approvalActions, calculateGasMargin, cancel_exports as cancelActions, close_exports as closeActions, delegation_exports as delegationActions, deposit_exports as depositActions, encodeCall, formatPrice, fromWei, getAddress, instant_exports as instantActions, signature_exports as signatureActions, toWei, trade_exports as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw_exports as withdrawActions, wrapInProxyCall };
|
|
24882
|
+
export { ALL_TRADING_SELECTORS, AffiliateFeeLevel, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, ClearingHouseABI, ClearingHouseLiquidationStatus, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, ERC20ABI, FALLBACK_CHAIN_ID, InstantCloseStatus, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, MultiAccountABI, MuonClient, MuonVerifierABI, OrderType, PositionType, QuoteStatus, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, SignatureStoreABI, SoftLiquidationLevel, SupportedChainId, SymmioDiamondABI, SymmioSDK, SymmioSDKError, V3_CHAIN_IDS, account_exports as accountActions, admin_exports as adminActions, allocate_exports as allocateActions, applySlippage, approval_exports as approvalActions, calculateGasMargin, cancel_exports as cancelActions, close_exports as closeActions, delegation_exports as delegationActions, deposit_exports as depositActions, encodeCall, formatPrice, fromWei, getAddress, instant_exports as instantActions, signature_exports as signatureActions, stats_exports as statsActions, toWei, trade_exports as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw_exports as withdrawActions, wrapInProxyCall };
|
|
24808
24883
|
//# sourceMappingURL=index.mjs.map
|
|
24809
24884
|
//# sourceMappingURL=index.mjs.map
|