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