@pear-protocol/symmio-client 0.3.18 → 0.3.20

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.mjs CHANGED
@@ -46,34 +46,6 @@ var SoftLiquidationLevel = /* @__PURE__ */ ((SoftLiquidationLevel2) => {
46
46
  return SoftLiquidationLevel2;
47
47
  })(SoftLiquidationLevel || {});
48
48
 
49
- // src/types/withdraw.ts
50
- var WithdrawStatus = /* @__PURE__ */ ((WithdrawStatus2) => {
51
- WithdrawStatus2[WithdrawStatus2["PENDING"] = 0] = "PENDING";
52
- WithdrawStatus2[WithdrawStatus2["PROVIDER_ACCEPTED"] = 1] = "PROVIDER_ACCEPTED";
53
- WithdrawStatus2[WithdrawStatus2["PROVIDER_REJECTED"] = 2] = "PROVIDER_REJECTED";
54
- WithdrawStatus2[WithdrawStatus2["COMPLETED"] = 3] = "COMPLETED";
55
- WithdrawStatus2[WithdrawStatus2["CANCEL_REQUESTED"] = 4] = "CANCEL_REQUESTED";
56
- WithdrawStatus2[WithdrawStatus2["CANCELLED"] = 5] = "CANCELLED";
57
- WithdrawStatus2[WithdrawStatus2["SUSPENDED"] = 6] = "SUSPENDED";
58
- return WithdrawStatus2;
59
- })(WithdrawStatus || {});
60
- var WithdrawSpeed = /* @__PURE__ */ ((WithdrawSpeed2) => {
61
- WithdrawSpeed2["STANDARD"] = "standard";
62
- WithdrawSpeed2["INSTANT"] = "instant";
63
- return WithdrawSpeed2;
64
- })(WithdrawSpeed || {});
65
- var InstantWithdrawStatus = /* @__PURE__ */ ((InstantWithdrawStatus2) => {
66
- InstantWithdrawStatus2["IDLE"] = "idle";
67
- InstantWithdrawStatus2["INITIATING"] = "initiating";
68
- InstantWithdrawStatus2["AWAITING_PROVIDER"] = "awaitingProvider";
69
- InstantWithdrawStatus2["AWAITING_COOLDOWN"] = "awaitingCooldown";
70
- InstantWithdrawStatus2["FINALIZING"] = "finalizing";
71
- InstantWithdrawStatus2["COMPLETED"] = "completed";
72
- InstantWithdrawStatus2["FAILED"] = "failed";
73
- return InstantWithdrawStatus2;
74
- })(InstantWithdrawStatus || {});
75
- var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
76
-
77
49
  // src/types/affiliate.ts
78
50
  var AffiliateFeeLevel = /* @__PURE__ */ ((AffiliateFeeLevel2) => {
79
51
  AffiliateFeeLevel2[AffiliateFeeLevel2["USER_SYMBOL"] = 0] = "USER_SYMBOL";
@@ -22892,181 +22864,6 @@ var SymmioDiamondABI = [
22892
22864
  }
22893
22865
  ];
22894
22866
 
22895
- // src/abis/WithdrawFacet.ts
22896
- var WithdrawFacetABI = [
22897
- // ─── Mutations ──────────────────────────────────────────────────
22898
- {
22899
- type: "function",
22900
- name: "initiateWithdraw",
22901
- stateMutability: "nonpayable",
22902
- inputs: [
22903
- {
22904
- name: "parts",
22905
- type: "tuple[]",
22906
- internalType: "struct WithdrawReceiverPart[]",
22907
- components: [
22908
- { name: "id", type: "uint256", internalType: "uint256" },
22909
- { name: "amount", type: "uint256", internalType: "uint256" },
22910
- { name: "chainId", type: "int256", internalType: "int256" },
22911
- { name: "receiver", type: "bytes", internalType: "bytes" },
22912
- { name: "virtualProvider", type: "address", internalType: "address" },
22913
- { name: "expressProvider", type: "address", internalType: "address" }
22914
- ]
22915
- },
22916
- { name: "speedUp", type: "bool", internalType: "bool" },
22917
- { name: "data", type: "bytes", internalType: "bytes" }
22918
- ],
22919
- outputs: [
22920
- { name: "requestId", type: "uint256", internalType: "uint256" },
22921
- { name: "cooldownEndTime", type: "uint256", internalType: "uint256" }
22922
- ]
22923
- },
22924
- {
22925
- type: "function",
22926
- name: "finalizeWithdrawRequest",
22927
- stateMutability: "nonpayable",
22928
- inputs: [
22929
- { name: "user", type: "address", internalType: "address" },
22930
- { name: "requestId", type: "uint256", internalType: "uint256" }
22931
- ],
22932
- outputs: []
22933
- },
22934
- {
22935
- type: "function",
22936
- name: "requestCancelWithdraw",
22937
- stateMutability: "nonpayable",
22938
- inputs: [{ name: "requestId", type: "uint256", internalType: "uint256" }],
22939
- outputs: []
22940
- },
22941
- // ─── Views ──────────────────────────────────────────────────────
22942
- {
22943
- type: "function",
22944
- name: "getWithdrawableTime",
22945
- stateMutability: "view",
22946
- inputs: [{ name: "user", type: "address", internalType: "address" }],
22947
- outputs: [{ name: "", type: "uint256", internalType: "uint256" }]
22948
- },
22949
- {
22950
- type: "function",
22951
- name: "getLastWithdrawRequestId",
22952
- stateMutability: "view",
22953
- inputs: [{ name: "user", type: "address", internalType: "address" }],
22954
- outputs: [{ name: "", type: "uint256", internalType: "uint256" }]
22955
- },
22956
- {
22957
- type: "function",
22958
- name: "isSpeedUpEligible",
22959
- stateMutability: "view",
22960
- inputs: [{ name: "user", type: "address", internalType: "address" }],
22961
- outputs: [{ name: "", type: "bool", internalType: "bool" }]
22962
- },
22963
- {
22964
- type: "function",
22965
- name: "isExpressProviderRegistered",
22966
- stateMutability: "view",
22967
- inputs: [{ name: "provider", type: "address", internalType: "address" }],
22968
- outputs: [{ name: "", type: "bool", internalType: "bool" }]
22969
- },
22970
- {
22971
- type: "function",
22972
- name: "isVirtualProviderRegistered",
22973
- stateMutability: "view",
22974
- inputs: [{ name: "provider", type: "address", internalType: "address" }],
22975
- outputs: [{ name: "", type: "bool", internalType: "bool" }]
22976
- },
22977
- // ─── Events ─────────────────────────────────────────────────────
22978
- {
22979
- type: "event",
22980
- name: "WithdrawInitiated",
22981
- anonymous: false,
22982
- inputs: [
22983
- { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
22984
- { name: "user", type: "address", indexed: true, internalType: "address" },
22985
- {
22986
- name: "parts",
22987
- type: "tuple[]",
22988
- indexed: false,
22989
- internalType: "struct WithdrawReceiverPart[]",
22990
- components: [
22991
- { name: "id", type: "uint256", internalType: "uint256" },
22992
- { name: "amount", type: "uint256", internalType: "uint256" },
22993
- { name: "chainId", type: "int256", internalType: "int256" },
22994
- { name: "receiver", type: "bytes", internalType: "bytes" },
22995
- { name: "virtualProvider", type: "address", internalType: "address" },
22996
- { name: "expressProvider", type: "address", internalType: "address" }
22997
- ]
22998
- },
22999
- { name: "speedUp", type: "bool", indexed: false, internalType: "bool" },
23000
- { name: "providerData", type: "bytes", indexed: false, internalType: "bytes" },
23001
- { name: "cooldownEndTime", type: "uint256", indexed: false, internalType: "uint256" }
23002
- ]
23003
- },
23004
- {
23005
- type: "event",
23006
- name: "WithdrawAccepted",
23007
- anonymous: false,
23008
- inputs: [
23009
- { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
23010
- { name: "user", type: "address", indexed: true, internalType: "address" }
23011
- ]
23012
- },
23013
- {
23014
- type: "event",
23015
- name: "WithdrawFinalized",
23016
- anonymous: false,
23017
- inputs: [
23018
- { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
23019
- { name: "user", type: "address", indexed: true, internalType: "address" }
23020
- ]
23021
- },
23022
- {
23023
- type: "event",
23024
- name: "WithdrawCancelRequested",
23025
- anonymous: false,
23026
- inputs: [
23027
- { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
23028
- { name: "user", type: "address", indexed: true, internalType: "address" }
23029
- ]
23030
- },
23031
- {
23032
- type: "event",
23033
- name: "WithdrawCancelled",
23034
- anonymous: false,
23035
- inputs: [
23036
- { name: "requestId", type: "uint256", indexed: true, internalType: "uint256" },
23037
- { name: "user", type: "address", indexed: true, internalType: "address" }
23038
- ]
23039
- },
23040
- {
23041
- type: "event",
23042
- name: "WithdrawRejected",
23043
- anonymous: false,
23044
- inputs: [
23045
- { name: "requestId", type: "uint256", indexed: false, internalType: "uint256" },
23046
- { name: "user", type: "address", indexed: false, internalType: "address" }
23047
- ]
23048
- },
23049
- {
23050
- type: "event",
23051
- name: "WithdrawSuspended",
23052
- anonymous: false,
23053
- inputs: [
23054
- { name: "requestId", type: "uint256", indexed: false, internalType: "uint256" },
23055
- { name: "user", type: "address", indexed: false, internalType: "address" }
23056
- ]
23057
- },
23058
- {
23059
- type: "event",
23060
- name: "WithdrawSpeedUpAccepted",
23061
- anonymous: false,
23062
- inputs: [
23063
- { name: "requestId", type: "uint256", indexed: false, internalType: "uint256" },
23064
- { name: "user", type: "address", indexed: false, internalType: "address" },
23065
- { name: "newCooldown", type: "uint256", indexed: false, internalType: "uint256" }
23066
- ]
23067
- }
23068
- ];
23069
-
23070
22867
  // src/abis/ClearingHouse.ts
23071
22868
  var ClearingHouseABI = [
23072
22869
  // ─── Liquidation Lifecycle ────────────────────────────────────
@@ -23495,6 +23292,12 @@ function validateAddress(address, name) {
23495
23292
  return address;
23496
23293
  }
23497
23294
  function validateAmount(amount, name) {
23295
+ if (typeof amount !== "bigint") {
23296
+ throw new SymmioSDKError(
23297
+ `${name} must be a bigint, got ${amount === void 0 ? "undefined" : typeof amount} (${amount})`,
23298
+ "INVALID_AMOUNT"
23299
+ );
23300
+ }
23498
23301
  if (amount <= 0n) {
23499
23302
  throw new SymmioSDKError(
23500
23303
  `${name} must be a positive amount, got ${amount}`,
@@ -23520,6 +23323,12 @@ function validateDeadline(deadline) {
23520
23323
  }
23521
23324
  }
23522
23325
  function validateQuantity(quantity) {
23326
+ if (typeof quantity !== "bigint") {
23327
+ throw new SymmioSDKError(
23328
+ `Quantity must be a bigint, got ${quantity === void 0 ? "undefined" : typeof quantity} (${quantity})`,
23329
+ "INVALID_QUANTITY"
23330
+ );
23331
+ }
23523
23332
  if (quantity <= 0n) {
23524
23333
  throw new SymmioSDKError(
23525
23334
  `Quantity must be positive, got ${quantity}`,
@@ -23543,17 +23352,29 @@ function normalizeSignParams(raw) {
23543
23352
  return raw ?? {};
23544
23353
  }
23545
23354
  function unwrapMuonResult(result) {
23546
- const data = result["result"];
23547
- if (!data) {
23355
+ const envelope = result["result"];
23356
+ if (!envelope) {
23548
23357
  throw new SymmioSDKError("Invalid Muon response: missing result", "MUON_PARSE_ERROR");
23549
23358
  }
23550
- const sigData = data["data"];
23359
+ const meta = envelope["data"] ?? {};
23551
23360
  return {
23552
- signParams: normalizeSignParams(sigData?.["signParams"] ?? data["signParams"]),
23553
- signatures: sigData?.["signatures"] ?? data["signatures"] ?? [],
23554
- init: sigData?.["init"] ?? data["init"]
23361
+ envelope,
23362
+ meta,
23363
+ computed: meta["result"] ?? {},
23364
+ signParams: normalizeSignParams(meta["signParams"] ?? envelope["signParams"]),
23365
+ signatures: meta["signatures"] ?? envelope["signatures"] ?? [],
23366
+ init: meta["init"] ?? envelope["init"]
23555
23367
  };
23556
23368
  }
23369
+ function requireBigInt(value, field) {
23370
+ if (value === void 0 || value === null || value === "") {
23371
+ throw new SymmioSDKError(
23372
+ `Invalid Muon response: missing "${field}"`,
23373
+ "MUON_PARSE_ERROR"
23374
+ );
23375
+ }
23376
+ return BigInt(value);
23377
+ }
23557
23378
  function extractSchnorrSign(signParams, signatures, init) {
23558
23379
  const inline = signParams["sigs"];
23559
23380
  if (inline?.signature !== void 0) {
@@ -23583,41 +23404,43 @@ function extractSchnorrSign(signParams, signatures, init) {
23583
23404
  nonce: nonceAddress
23584
23405
  };
23585
23406
  }
23586
- function gatewaySigOf(signatures) {
23407
+ function gatewaySigOf(envelope, signatures) {
23408
+ const shield = envelope["shieldSignature"] ?? envelope["nodeSignature"] ?? envelope["gatewaySignature"];
23409
+ if (typeof shield === "string" && shield.length > 0) return shield;
23587
23410
  return signatures?.[0]?.["signature"] ?? "0x";
23588
23411
  }
23589
23412
  function parseSingleUpnlSig(result) {
23590
- const { signParams, signatures, init } = unwrapMuonResult(result);
23413
+ const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
23591
23414
  return {
23592
- reqId: signParams["reqId"],
23593
- timestamp: BigInt(signParams["timestamp"]),
23594
- upnl: BigInt(signParams["upnl"]),
23595
- gatewaySignature: gatewaySigOf(signatures),
23415
+ reqId: signParams["reqId"] ?? envelope["reqId"],
23416
+ timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
23417
+ upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
23418
+ gatewaySignature: gatewaySigOf(envelope, signatures),
23596
23419
  sigs: extractSchnorrSign(signParams, signatures, init)
23597
23420
  };
23598
23421
  }
23599
23422
  function parseSingleUpnlAndPriceSig(result) {
23600
- const { signParams, signatures, init } = unwrapMuonResult(result);
23423
+ const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
23601
23424
  return {
23602
- reqId: signParams["reqId"],
23603
- timestamp: BigInt(signParams["timestamp"]),
23604
- upnl: BigInt(signParams["upnl"]),
23605
- price: BigInt(signParams["price"]),
23606
- gatewaySignature: gatewaySigOf(signatures),
23425
+ reqId: signParams["reqId"] ?? envelope["reqId"],
23426
+ timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
23427
+ upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
23428
+ price: requireBigInt(signParams["price"] ?? computed["price"], "price"),
23429
+ gatewaySignature: gatewaySigOf(envelope, signatures),
23607
23430
  sigs: extractSchnorrSign(signParams, signatures, init)
23608
23431
  };
23609
23432
  }
23610
23433
  function parseBatchSig(result) {
23611
- const { signParams, signatures, init } = unwrapMuonResult(result);
23612
- const prices = signParams["prices"];
23613
- const symbolIds = signParams["symbolIds"];
23434
+ const { signParams, signatures, init, envelope, meta, computed } = unwrapMuonResult(result);
23435
+ const prices = signParams["prices"] ?? computed["prices"];
23436
+ const symbolIds = signParams["symbolIds"] ?? computed["symbolIds"];
23614
23437
  return {
23615
- reqId: signParams["reqId"],
23616
- timestamp: BigInt(signParams["timestamp"]),
23617
- upnl: BigInt(signParams["upnl"]),
23438
+ reqId: signParams["reqId"] ?? envelope["reqId"],
23439
+ timestamp: requireBigInt(signParams["timestamp"] ?? meta["timestamp"], "timestamp"),
23440
+ upnl: requireBigInt(signParams["upnl"] ?? computed["uPnl"], "upnl"),
23618
23441
  prices: (prices ?? []).map((p) => BigInt(p)),
23619
23442
  symbolIds: (symbolIds ?? []).map((s) => BigInt(s)),
23620
- gatewaySignature: gatewaySigOf(signatures),
23443
+ gatewaySignature: gatewaySigOf(envelope, signatures),
23621
23444
  sigs: extractSchnorrSign(signParams, signatures, init)
23622
23445
  };
23623
23446
  }
@@ -23859,149 +23682,27 @@ async function depositAndAllocate(walletClient, publicClient, multiAccount, para
23859
23682
  // src/actions/withdraw.ts
23860
23683
  var withdraw_exports = {};
23861
23684
  __export(withdraw_exports, {
23862
- buildClassicWithdrawPart: () => buildClassicWithdrawPart,
23863
- buildExpressWithdrawPart: () => buildExpressWithdrawPart,
23864
- buildWithdrawPart: () => buildWithdrawPart,
23865
- finalizeWithdraw: () => finalizeWithdraw,
23866
- initiateWithdraw: () => initiateWithdraw,
23867
- prepareFinalizeWithdraw: () => prepareFinalizeWithdraw,
23868
- prepareInitiateWithdraw: () => prepareInitiateWithdraw,
23869
- prepareRequestCancelWithdraw: () => prepareRequestCancelWithdraw,
23870
- requestCancelWithdraw: () => requestCancelWithdraw
23685
+ prepareWithdraw: () => prepareWithdraw,
23686
+ withdraw: () => withdraw
23871
23687
  });
23872
- function encodeCall(abi, functionName, args) {
23873
- return encodeFunctionData({
23874
- abi,
23875
- functionName,
23876
- args
23877
- });
23878
- }
23879
- function wrapInProxyCall(accountDiamondAbi, subAccount, callDatas) {
23688
+ function prepareWithdraw(multiAccount, account, params) {
23689
+ validateAmount(params.amount, "withdraw amount");
23690
+ validateAddress(params.account, "account");
23880
23691
  const data = encodeFunctionData({
23881
- abi: accountDiamondAbi,
23882
- functionName: "_call",
23883
- args: [subAccount, callDatas]
23884
- });
23885
- return {
23886
- functionName: "_call",
23887
- args: [subAccount, callDatas],
23888
- data
23889
- };
23890
- }
23891
-
23892
- // src/actions/withdraw.ts
23893
- function buildClassicWithdrawPart(amount, chainId, receiver, partId = 0n) {
23894
- return {
23895
- id: partId,
23896
- amount,
23897
- chainId,
23898
- receiver,
23899
- virtualProvider: ZERO_ADDRESS,
23900
- expressProvider: ZERO_ADDRESS
23901
- };
23902
- }
23903
- function buildExpressWithdrawPart(amount, chainId, receiver, expressProvider, partId = 0n) {
23904
- return {
23905
- id: partId,
23906
- amount,
23907
- chainId,
23908
- receiver,
23909
- virtualProvider: ZERO_ADDRESS,
23910
- expressProvider
23911
- };
23912
- }
23913
- function buildWithdrawPart(amount, chainId, receiver, option, partId = 0n) {
23914
- if (option.speed === "instant" /* INSTANT */) {
23915
- return buildExpressWithdrawPart(
23916
- amount,
23917
- chainId,
23918
- receiver,
23919
- option.expressProvider,
23920
- partId
23921
- );
23922
- }
23923
- return buildClassicWithdrawPart(amount, chainId, receiver, partId);
23924
- }
23925
- function validateParts(parts) {
23926
- if (parts.length === 0) {
23927
- throw new Error("initiateWithdraw: at least one withdraw part is required");
23928
- }
23929
- for (const part of parts) {
23930
- validateAmount(part.amount, "withdraw part amount");
23931
- if (part.expressProvider !== ZERO_ADDRESS && part.expressProvider === part.virtualProvider) {
23932
- throw new Error(
23933
- "initiateWithdraw: a single provider cannot be set as both express and virtual"
23934
- );
23935
- }
23936
- }
23937
- }
23938
- function prepareInitiateWithdraw(multiAccount, account, subAccount, params) {
23939
- validateParts(params.parts);
23940
- const innerData = encodeFunctionData({
23941
- abi: WithdrawFacetABI,
23942
- functionName: "initiateWithdraw",
23943
- args: [params.parts, params.speedUp, params.providerData]
23944
- });
23945
- const proxy = wrapInProxyCall(MultiAccountABI, subAccount, [innerData]);
23946
- return {
23947
- functionName: "_call",
23948
- args: proxy.args,
23949
- config: { account, to: multiAccount, data: proxy.data, value: 0n }
23950
- };
23951
- }
23952
- function prepareFinalizeWithdraw(multiAccount, account, subAccount, params) {
23953
- validateAddress(params.user, "user");
23954
- const innerData = encodeFunctionData({
23955
- abi: WithdrawFacetABI,
23956
- functionName: "finalizeWithdrawRequest",
23957
- args: [params.user, params.requestId]
23958
- });
23959
- const proxy = wrapInProxyCall(MultiAccountABI, subAccount, [innerData]);
23960
- return {
23961
- functionName: "_call",
23962
- args: proxy.args,
23963
- config: { account, to: multiAccount, data: proxy.data, value: 0n }
23964
- };
23965
- }
23966
- function prepareRequestCancelWithdraw(multiAccount, account, subAccount, params) {
23967
- const innerData = encodeFunctionData({
23968
- abi: WithdrawFacetABI,
23969
- functionName: "requestCancelWithdraw",
23970
- args: [params.requestId]
23692
+ abi: MultiAccountABI,
23693
+ functionName: "withdrawFromAccount",
23694
+ args: [params.account, params.amount]
23971
23695
  });
23972
- const proxy = wrapInProxyCall(MultiAccountABI, subAccount, [innerData]);
23973
23696
  return {
23974
- functionName: "_call",
23975
- args: proxy.args,
23976
- config: { account, to: multiAccount, data: proxy.data, value: 0n }
23697
+ functionName: "withdrawFromAccount",
23698
+ args: [params.account, params.amount],
23699
+ config: { account, to: multiAccount, data, value: 0n }
23977
23700
  };
23978
23701
  }
23979
- async function initiateWithdraw(walletClient, publicClient, multiAccount, subAccount, params) {
23702
+ async function withdraw(walletClient, publicClient, multiAccount, params) {
23980
23703
  const account = walletClient.account?.address;
23981
23704
  if (!account) throw new Error("Wallet client has no account");
23982
- const prepared = prepareInitiateWithdraw(multiAccount, account, subAccount, params);
23983
- const gas = await publicClient.estimateGas(prepared.config);
23984
- return walletClient.sendTransaction({
23985
- ...prepared.config,
23986
- gas: calculateGasMargin(gas),
23987
- chain: walletClient.chain
23988
- });
23989
- }
23990
- async function finalizeWithdraw(walletClient, publicClient, multiAccount, subAccount, params) {
23991
- const account = walletClient.account?.address;
23992
- if (!account) throw new Error("Wallet client has no account");
23993
- const prepared = prepareFinalizeWithdraw(multiAccount, account, subAccount, params);
23994
- const gas = await publicClient.estimateGas(prepared.config);
23995
- return walletClient.sendTransaction({
23996
- ...prepared.config,
23997
- gas: calculateGasMargin(gas),
23998
- chain: walletClient.chain
23999
- });
24000
- }
24001
- async function requestCancelWithdraw(walletClient, publicClient, multiAccount, subAccount, params) {
24002
- const account = walletClient.account?.address;
24003
- if (!account) throw new Error("Wallet client has no account");
24004
- const prepared = prepareRequestCancelWithdraw(multiAccount, account, subAccount, params);
23705
+ const prepared = prepareWithdraw(multiAccount, account, params);
24005
23706
  const gas = await publicClient.estimateGas(prepared.config);
24006
23707
  return walletClient.sendTransaction({
24007
23708
  ...prepared.config,
@@ -24020,6 +23721,27 @@ __export(allocate_exports, {
24020
23721
  prepareDeallocate: () => prepareDeallocate,
24021
23722
  prepareInternalTransfer: () => prepareInternalTransfer
24022
23723
  });
23724
+ function encodeCall(abi, functionName, args) {
23725
+ return encodeFunctionData({
23726
+ abi,
23727
+ functionName,
23728
+ args
23729
+ });
23730
+ }
23731
+ function wrapInProxyCall(accountDiamondAbi, subAccount, callDatas) {
23732
+ const data = encodeFunctionData({
23733
+ abi: accountDiamondAbi,
23734
+ functionName: "_call",
23735
+ args: [subAccount, callDatas]
23736
+ });
23737
+ return {
23738
+ functionName: "_call",
23739
+ args: [subAccount, callDatas],
23740
+ data
23741
+ };
23742
+ }
23743
+
23744
+ // src/actions/allocate.ts
24023
23745
  function prepareAllocate(multiAccount, account, subAccount, params) {
24024
23746
  validateAmount(params.amount, "allocate amount");
24025
23747
  const innerData = encodeFunctionData({
@@ -25218,8 +24940,8 @@ function computeSymmNetDeposited(totals, decimals = 6) {
25218
24940
  return "0";
25219
24941
  }
25220
24942
  const deposit2 = parseRawCollateralUnits(totals.deposit);
25221
- const withdraw = parseRawCollateralUnits(totals.withdraw);
25222
- const value = deposit2 - withdraw;
24943
+ const withdraw2 = parseRawCollateralUnits(totals.withdraw);
24944
+ const value = deposit2 - withdraw2;
25223
24945
  const negative = value < 0n;
25224
24946
  const absolute = negative ? -value : value;
25225
24947
  const scale = 10n ** BigInt(decimals);
@@ -25380,6 +25102,6 @@ function normalizeSymmUpnlWebSocketMessage(raw) {
25380
25102
  };
25381
25103
  }
25382
25104
 
25383
- 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, InstantWithdrawStatus, 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, SymmioSDKError, V3_CHAIN_IDS, WithdrawFacetABI, WithdrawSpeed, WithdrawStatus, ZERO_ADDRESS, 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, computeSymmAccountOverview, computeSymmAccountOverviewFromData, computeSymmNetDeposited, computeSymmPositionUpnl, computeSymmPositionsUpnl, delegation_exports as delegationActions, deposit_exports as depositActions, encodeCall, formatPrice, fromWei, getAddress, getSymmAccountBalanceInfo, getSymmAccountData, instant_exports as instantActions, normalizeSymmUpnlWebSocketMessage, signature_exports as signatureActions, stats_exports as statsActions, toWei, trade_exports as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw_exports as withdrawActions, wrapInProxyCall };
25105
+ 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, 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, computeSymmAccountOverview, computeSymmAccountOverviewFromData, computeSymmNetDeposited, computeSymmPositionUpnl, computeSymmPositionsUpnl, delegation_exports as delegationActions, deposit_exports as depositActions, encodeCall, formatPrice, fromWei, getAddress, getSymmAccountBalanceInfo, getSymmAccountData, instant_exports as instantActions, normalizeSymmUpnlWebSocketMessage, signature_exports as signatureActions, stats_exports as statsActions, toWei, trade_exports as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw_exports as withdrawActions, wrapInProxyCall };
25384
25106
  //# sourceMappingURL=index.mjs.map
25385
25107
  //# sourceMappingURL=index.mjs.map