@pear-protocol/symmio-client 0.3.12 → 0.3.14
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 +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +207 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +205 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +232 -2
- package/dist/react/index.d.ts +232 -2
- package/dist/react/index.js +430 -137
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +427 -138
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/provider.js +189 -136
- package/dist/react/provider.js.map +1 -1
- package/dist/react/provider.mjs +189 -136
- package/dist/react/provider.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -19843,4 +19843,50 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
|
|
|
19843
19843
|
*/
|
|
19844
19844
|
declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
|
|
19845
19845
|
|
|
19846
|
-
|
|
19846
|
+
type SymmAccountNumericValue = string | number | bigint | null | undefined;
|
|
19847
|
+
type SymmAccountBalanceInfoLike = Record<string, unknown>;
|
|
19848
|
+
interface SymmAccountOverviewInput {
|
|
19849
|
+
balanceInfo: SymmAccountBalanceInfoLike;
|
|
19850
|
+
upnl?: SymmAccountNumericValue;
|
|
19851
|
+
netDeposited?: SymmAccountNumericValue;
|
|
19852
|
+
}
|
|
19853
|
+
interface SymmAccountOverview {
|
|
19854
|
+
allocatedBalance: string;
|
|
19855
|
+
upnl: string;
|
|
19856
|
+
equity: string;
|
|
19857
|
+
totalAccountValue: string;
|
|
19858
|
+
maintenanceMargin: string;
|
|
19859
|
+
totalLocked: string;
|
|
19860
|
+
marginUsed: string;
|
|
19861
|
+
totalPendingLocked: string;
|
|
19862
|
+
availableForOrder: string;
|
|
19863
|
+
availableMargin: string;
|
|
19864
|
+
availableBalance: string;
|
|
19865
|
+
netDeposited: string;
|
|
19866
|
+
notional: string;
|
|
19867
|
+
timestamp?: number;
|
|
19868
|
+
}
|
|
19869
|
+
interface SymmDepositWithdrawalTotals {
|
|
19870
|
+
deposit?: SymmAccountNumericValue;
|
|
19871
|
+
withdraw?: SymmAccountNumericValue;
|
|
19872
|
+
}
|
|
19873
|
+
/**
|
|
19874
|
+
* Finds a single account's balance info from a core BalanceInfoResponse,
|
|
19875
|
+
* symm-pear hedger map, or a direct balance-info object.
|
|
19876
|
+
*/
|
|
19877
|
+
declare function getSymmAccountBalanceInfo(response: unknown, accountAddress?: string): SymmAccountBalanceInfoLike | undefined;
|
|
19878
|
+
/**
|
|
19879
|
+
* Mirrors symm-pear's Account Overview math:
|
|
19880
|
+
* equity = allocated balance + uPnL
|
|
19881
|
+
* maintenance margin = locked CVA + locked LF
|
|
19882
|
+
* margin used = CVA + LF + party A MM
|
|
19883
|
+
*/
|
|
19884
|
+
declare function computeSymmAccountOverview({ balanceInfo, upnl: upnlOverride, netDeposited, }: SymmAccountOverviewInput): SymmAccountOverview;
|
|
19885
|
+
/**
|
|
19886
|
+
* Computes the symm-pear net-deposited display value from balance-history
|
|
19887
|
+
* subgraph totals. Inputs must be integer raw collateral units; USDC defaults
|
|
19888
|
+
* to 6 decimals.
|
|
19889
|
+
*/
|
|
19890
|
+
declare function computeSymmNetDeposited(totals: SymmDepositWithdrawalTotals | null | undefined, decimals?: number): string;
|
|
19891
|
+
|
|
19892
|
+
export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, type CreateSiweMessageParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InstantAuthToken, type InstantCloseParams, type InstantCloseResponse, InstantCloseStatus, type InstantErrorResponse, type InstantLoginParams, type InstantOpenParams, type InstantOpenResponse, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, type SiweMessageResult, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, type SymmAccountBalanceInfoLike, type SymmAccountNumericValue, type SymmAccountOverview, type SymmAccountOverviewInput, type SymmDepositWithdrawalTotals, SymmioDiamondABI, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, computeSymmAccountOverview, computeSymmNetDeposited, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, getSymmAccountBalanceInfo, instant as instantActions, signature as signatureActions, stats as statsActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
|
package/dist/index.d.ts
CHANGED
|
@@ -19843,4 +19843,50 @@ declare function formatPrice(price: bigint, decimals: number, precision?: number
|
|
|
19843
19843
|
*/
|
|
19844
19844
|
declare function applySlippage(price: bigint, slippagePercent: number, isLong: boolean): bigint;
|
|
19845
19845
|
|
|
19846
|
-
|
|
19846
|
+
type SymmAccountNumericValue = string | number | bigint | null | undefined;
|
|
19847
|
+
type SymmAccountBalanceInfoLike = Record<string, unknown>;
|
|
19848
|
+
interface SymmAccountOverviewInput {
|
|
19849
|
+
balanceInfo: SymmAccountBalanceInfoLike;
|
|
19850
|
+
upnl?: SymmAccountNumericValue;
|
|
19851
|
+
netDeposited?: SymmAccountNumericValue;
|
|
19852
|
+
}
|
|
19853
|
+
interface SymmAccountOverview {
|
|
19854
|
+
allocatedBalance: string;
|
|
19855
|
+
upnl: string;
|
|
19856
|
+
equity: string;
|
|
19857
|
+
totalAccountValue: string;
|
|
19858
|
+
maintenanceMargin: string;
|
|
19859
|
+
totalLocked: string;
|
|
19860
|
+
marginUsed: string;
|
|
19861
|
+
totalPendingLocked: string;
|
|
19862
|
+
availableForOrder: string;
|
|
19863
|
+
availableMargin: string;
|
|
19864
|
+
availableBalance: string;
|
|
19865
|
+
netDeposited: string;
|
|
19866
|
+
notional: string;
|
|
19867
|
+
timestamp?: number;
|
|
19868
|
+
}
|
|
19869
|
+
interface SymmDepositWithdrawalTotals {
|
|
19870
|
+
deposit?: SymmAccountNumericValue;
|
|
19871
|
+
withdraw?: SymmAccountNumericValue;
|
|
19872
|
+
}
|
|
19873
|
+
/**
|
|
19874
|
+
* Finds a single account's balance info from a core BalanceInfoResponse,
|
|
19875
|
+
* symm-pear hedger map, or a direct balance-info object.
|
|
19876
|
+
*/
|
|
19877
|
+
declare function getSymmAccountBalanceInfo(response: unknown, accountAddress?: string): SymmAccountBalanceInfoLike | undefined;
|
|
19878
|
+
/**
|
|
19879
|
+
* Mirrors symm-pear's Account Overview math:
|
|
19880
|
+
* equity = allocated balance + uPnL
|
|
19881
|
+
* maintenance margin = locked CVA + locked LF
|
|
19882
|
+
* margin used = CVA + LF + party A MM
|
|
19883
|
+
*/
|
|
19884
|
+
declare function computeSymmAccountOverview({ balanceInfo, upnl: upnlOverride, netDeposited, }: SymmAccountOverviewInput): SymmAccountOverview;
|
|
19885
|
+
/**
|
|
19886
|
+
* Computes the symm-pear net-deposited display value from balance-history
|
|
19887
|
+
* subgraph totals. Inputs must be integer raw collateral units; USDC defaults
|
|
19888
|
+
* to 6 decimals.
|
|
19889
|
+
*/
|
|
19890
|
+
declare function computeSymmNetDeposited(totals: SymmDepositWithdrawalTotals | null | undefined, decimals?: number): string;
|
|
19891
|
+
|
|
19892
|
+
export { type ADLAssurance, ALL_TRADING_SELECTORS, type Account, type AccountBalance, type AccumulatedFundingRate, type AddAccountParams, type AffiliateFeeConfig, AffiliateFeeLevel, type AggregatedPosition, type AllocateParams, ApprovalState, CHAIN_NAMES, CLEARING_HOUSE_ADDRESS, CLOSE_QUOTE_SELECTOR, COLLATERAL_ADDRESS, COLLATERAL_DECIMALS, type CancelQuoteParams, type ChainId, ClearingHouseABI, type ClearingHouseLiquidation, ClearingHouseLiquidationStatus, type ClosePositionParams, type CreateSiweMessageParams, DEFAULT_PARTY_B_ADDRESS, DEFAULT_PRECISION, type DeallocateParams, type DepositAndAllocateParams, type DepositParams, ERC20ABI, FALLBACK_CHAIN_ID, type InstantAuthToken, type InstantCloseParams, type InstantCloseResponse, InstantCloseStatus, type InstantErrorResponse, type InstantLoginParams, type InstantOpenParams, type InstantOpenResponse, type InsuranceVaultConfig, type InternalTransferParams, LIMIT_ORDER_DEADLINE, LiquidationStatus, MARKET_ORDER_DEADLINE, MARKET_PRICE_COEFFICIENT, MAX_LEVERAGE, MULTI_ACCOUNT_ADDRESS, MUON_APP_NAME, MUON_BASE_URLS, type Market, MultiAccountABI, type MuonBatchParams, type MuonBatchSig, MuonClient, type MuonClientConfig, type MuonDeallocateParams, type MuonQuoteParams, type MuonSingleUpnlAndPriceSig, type MuonSingleUpnlSig, type MuonSingleUpnlWithPendingBalanceSig, MuonVerifierABI, OrderType, PositionType, type PreparedTransaction, type Quote, QuoteStatus, type RegisterAffiliateParams, SEND_QUOTE_WITH_AFFILIATE_SELECTOR, SIGNATURE_STORE_ADDRESS, STANDARD_WITHDRAW_COOLDOWN, SYMMIO_DIAMOND_ADDRESS, type SchnorrSign, type SendQuoteParams, type SetAffiliateFeeParams, SignatureStoreABI, type SiweMessageResult, SoftLiquidationLevel, type SoftLiquidationThreshold, SupportedChainId, type SymbolCategory, type SymbolType, type SymmAccountBalanceInfoLike, type SymmAccountNumericValue, type SymmAccountOverview, type SymmAccountOverviewInput, type SymmDepositWithdrawalTotals, SymmioDiamondABI, type SymmioSDKConfig, SymmioSDKError, type TransactionConfig, type TransactionReceipt, type TransactionResult, V3_CHAIN_IDS, type WithdrawParams, account as accountActions, admin as adminActions, allocate$1 as allocateActions, applySlippage, approval as approvalActions, calculateGasMargin, cancel as cancelActions, close as closeActions, computeSymmAccountOverview, computeSymmNetDeposited, delegation as delegationActions, deposit$1 as depositActions, encodeCall, formatPrice, fromWei, getAddress, getSymmAccountBalanceInfo, instant as instantActions, signature as signatureActions, stats as statsActions, toWei, trade as tradeActions, validateAddress, validateAmount, validateChainId, validateDeadline, validateQuantity, withdraw$1 as withdrawActions, wrapInProxyCall };
|
package/dist/index.js
CHANGED
|
@@ -24687,6 +24687,210 @@ function applySlippage(price, slippagePercent, isLong) {
|
|
|
24687
24687
|
return price - price * bps / 10000n;
|
|
24688
24688
|
}
|
|
24689
24689
|
|
|
24690
|
+
// src/utils/account-overview.ts
|
|
24691
|
+
var BALANCE_INFO_KEYS = [
|
|
24692
|
+
"allocatedBalance",
|
|
24693
|
+
"allocated_balance",
|
|
24694
|
+
"cva",
|
|
24695
|
+
"lf",
|
|
24696
|
+
"partyAmm",
|
|
24697
|
+
"partyAMM",
|
|
24698
|
+
"party_a_mm",
|
|
24699
|
+
"mm",
|
|
24700
|
+
"lockedPartyAMM",
|
|
24701
|
+
"upnl"
|
|
24702
|
+
];
|
|
24703
|
+
function isRecord(value) {
|
|
24704
|
+
return typeof value === "object" && value !== null;
|
|
24705
|
+
}
|
|
24706
|
+
function hasBalanceInfoShape(value) {
|
|
24707
|
+
return isRecord(value) && BALANCE_INFO_KEYS.some((key) => key in value);
|
|
24708
|
+
}
|
|
24709
|
+
function readValue(source, keys) {
|
|
24710
|
+
for (const key of keys) {
|
|
24711
|
+
if (key in source) {
|
|
24712
|
+
return source[key];
|
|
24713
|
+
}
|
|
24714
|
+
}
|
|
24715
|
+
return void 0;
|
|
24716
|
+
}
|
|
24717
|
+
function toNumber(value) {
|
|
24718
|
+
if (value === null || value === void 0 || value === "") {
|
|
24719
|
+
return 0;
|
|
24720
|
+
}
|
|
24721
|
+
if (typeof value === "bigint") {
|
|
24722
|
+
return Number(value);
|
|
24723
|
+
}
|
|
24724
|
+
const parsed = Number(value);
|
|
24725
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
24726
|
+
}
|
|
24727
|
+
function toDisplayString(value) {
|
|
24728
|
+
if (Object.is(value, -0) || Math.abs(value) < Number.EPSILON) {
|
|
24729
|
+
return "0";
|
|
24730
|
+
}
|
|
24731
|
+
return String(value);
|
|
24732
|
+
}
|
|
24733
|
+
function readNumber(source, keys) {
|
|
24734
|
+
return toNumber(readValue(source, keys));
|
|
24735
|
+
}
|
|
24736
|
+
function readTimestamp(source) {
|
|
24737
|
+
const timestamp = readValue(source, ["timestamp"]);
|
|
24738
|
+
if (timestamp === void 0 || timestamp === null) {
|
|
24739
|
+
return void 0;
|
|
24740
|
+
}
|
|
24741
|
+
const parsed = Number(timestamp);
|
|
24742
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
24743
|
+
}
|
|
24744
|
+
function getBalanceInfoContainer(response) {
|
|
24745
|
+
if (!isRecord(response)) {
|
|
24746
|
+
return void 0;
|
|
24747
|
+
}
|
|
24748
|
+
if (hasBalanceInfoShape(response)) {
|
|
24749
|
+
return response;
|
|
24750
|
+
}
|
|
24751
|
+
const data = response.data;
|
|
24752
|
+
if (isRecord(data)) {
|
|
24753
|
+
return data;
|
|
24754
|
+
}
|
|
24755
|
+
return response;
|
|
24756
|
+
}
|
|
24757
|
+
function getSymmAccountBalanceInfo(response, accountAddress) {
|
|
24758
|
+
const container = getBalanceInfoContainer(response);
|
|
24759
|
+
if (!container) {
|
|
24760
|
+
return void 0;
|
|
24761
|
+
}
|
|
24762
|
+
if (hasBalanceInfoShape(container)) {
|
|
24763
|
+
return container;
|
|
24764
|
+
}
|
|
24765
|
+
if (accountAddress) {
|
|
24766
|
+
const normalizedAddress = accountAddress.toLowerCase();
|
|
24767
|
+
const direct = container[accountAddress] ?? container[normalizedAddress];
|
|
24768
|
+
if (isRecord(direct) && hasBalanceInfoShape(direct)) {
|
|
24769
|
+
return direct;
|
|
24770
|
+
}
|
|
24771
|
+
const matchingEntry = Object.entries(container).find(
|
|
24772
|
+
([key]) => key.toLowerCase() === normalizedAddress
|
|
24773
|
+
);
|
|
24774
|
+
if (isRecord(matchingEntry?.[1]) && hasBalanceInfoShape(matchingEntry[1])) {
|
|
24775
|
+
return matchingEntry[1];
|
|
24776
|
+
}
|
|
24777
|
+
}
|
|
24778
|
+
const values = Object.values(container);
|
|
24779
|
+
if (values.length === 1 && isRecord(values[0]) && hasBalanceInfoShape(values[0])) {
|
|
24780
|
+
return values[0];
|
|
24781
|
+
}
|
|
24782
|
+
return void 0;
|
|
24783
|
+
}
|
|
24784
|
+
function computeSymmAccountOverview({
|
|
24785
|
+
balanceInfo,
|
|
24786
|
+
upnl: upnlOverride,
|
|
24787
|
+
netDeposited
|
|
24788
|
+
}) {
|
|
24789
|
+
const allocatedBalance = readNumber(balanceInfo, [
|
|
24790
|
+
"allocatedBalance",
|
|
24791
|
+
"allocated_balance"
|
|
24792
|
+
]);
|
|
24793
|
+
const cva = readNumber(balanceInfo, ["cva", "lockedCVA", "locked_cva"]);
|
|
24794
|
+
const lf = readNumber(balanceInfo, ["lf", "lockedLF", "locked_lf"]);
|
|
24795
|
+
const partyAmm = readNumber(balanceInfo, [
|
|
24796
|
+
"partyAmm",
|
|
24797
|
+
"partyAMM",
|
|
24798
|
+
"party_a_mm",
|
|
24799
|
+
"mm",
|
|
24800
|
+
"lockedPartyAMM",
|
|
24801
|
+
"locked_party_a_mm"
|
|
24802
|
+
]);
|
|
24803
|
+
const pendingCva = readNumber(balanceInfo, [
|
|
24804
|
+
"pendingCva",
|
|
24805
|
+
"pending_cva",
|
|
24806
|
+
"pendingLockedCVA",
|
|
24807
|
+
"pending_locked_cva"
|
|
24808
|
+
]);
|
|
24809
|
+
const pendingLf = readNumber(balanceInfo, [
|
|
24810
|
+
"pendingLf",
|
|
24811
|
+
"pending_lf",
|
|
24812
|
+
"pendingLockedLF",
|
|
24813
|
+
"pending_locked_lf"
|
|
24814
|
+
]);
|
|
24815
|
+
const pendingPartyAmm = readNumber(balanceInfo, [
|
|
24816
|
+
"pendingPartyAmm",
|
|
24817
|
+
"pendingPartyAMM",
|
|
24818
|
+
"pending_party_a_mm",
|
|
24819
|
+
"pendingMm",
|
|
24820
|
+
"pending_mm",
|
|
24821
|
+
"pendingLockedPartyAMM",
|
|
24822
|
+
"pending_locked_party_a_mm"
|
|
24823
|
+
]);
|
|
24824
|
+
const upnl = upnlOverride === void 0 ? readNumber(balanceInfo, ["upnl"]) : toNumber(upnlOverride);
|
|
24825
|
+
const computedTotalLocked = cva + lf + partyAmm;
|
|
24826
|
+
const totalLocked = readValue(
|
|
24827
|
+
balanceInfo,
|
|
24828
|
+
["totalLocked", "total_locked"]
|
|
24829
|
+
) === void 0 ? computedTotalLocked : readNumber(balanceInfo, ["totalLocked", "total_locked"]);
|
|
24830
|
+
const totalPendingLocked = readValue(balanceInfo, [
|
|
24831
|
+
"totalPendingLocked",
|
|
24832
|
+
"total_pending_locked"
|
|
24833
|
+
]) === void 0 ? pendingCva + pendingLf + pendingPartyAmm : readNumber(balanceInfo, ["totalPendingLocked", "total_pending_locked"]);
|
|
24834
|
+
const maintenanceMargin = cva + lf;
|
|
24835
|
+
const equity = allocatedBalance + upnl;
|
|
24836
|
+
const availableForOrder = upnl >= 0 ? allocatedBalance + upnl - totalLocked - totalPendingLocked : allocatedBalance - cva - lf - totalPendingLocked - Math.max(Math.abs(upnl), partyAmm);
|
|
24837
|
+
const availableBalance = readNumber(balanceInfo, [
|
|
24838
|
+
"availableBalance",
|
|
24839
|
+
"available_balance"
|
|
24840
|
+
]);
|
|
24841
|
+
const notional = readNumber(balanceInfo, ["notional"]);
|
|
24842
|
+
return {
|
|
24843
|
+
allocatedBalance: toDisplayString(allocatedBalance),
|
|
24844
|
+
upnl: toDisplayString(upnl),
|
|
24845
|
+
equity: toDisplayString(equity),
|
|
24846
|
+
totalAccountValue: toDisplayString(equity),
|
|
24847
|
+
maintenanceMargin: toDisplayString(maintenanceMargin),
|
|
24848
|
+
totalLocked: toDisplayString(totalLocked),
|
|
24849
|
+
marginUsed: toDisplayString(computedTotalLocked),
|
|
24850
|
+
totalPendingLocked: toDisplayString(totalPendingLocked),
|
|
24851
|
+
availableForOrder: toDisplayString(availableForOrder),
|
|
24852
|
+
availableMargin: toDisplayString(availableForOrder),
|
|
24853
|
+
availableBalance: toDisplayString(availableBalance),
|
|
24854
|
+
netDeposited: toDisplayString(toNumber(netDeposited)),
|
|
24855
|
+
notional: toDisplayString(notional),
|
|
24856
|
+
timestamp: readTimestamp(balanceInfo)
|
|
24857
|
+
};
|
|
24858
|
+
}
|
|
24859
|
+
function computeSymmNetDeposited(totals, decimals = 6) {
|
|
24860
|
+
if (!totals) {
|
|
24861
|
+
return "0";
|
|
24862
|
+
}
|
|
24863
|
+
const deposit2 = parseRawCollateralUnits(totals.deposit);
|
|
24864
|
+
const withdraw2 = parseRawCollateralUnits(totals.withdraw);
|
|
24865
|
+
const value = deposit2 - withdraw2;
|
|
24866
|
+
const negative = value < 0n;
|
|
24867
|
+
const absolute = negative ? -value : value;
|
|
24868
|
+
const scale = 10n ** BigInt(decimals);
|
|
24869
|
+
const whole = absolute / scale;
|
|
24870
|
+
const fraction = absolute % scale;
|
|
24871
|
+
const fractionText = fraction.toString().padStart(decimals, "0").replace(/0+$/, "");
|
|
24872
|
+
const amount = fractionText ? `${whole}.${fractionText}` : whole.toString();
|
|
24873
|
+
return negative ? `-${amount}` : amount;
|
|
24874
|
+
}
|
|
24875
|
+
function parseRawCollateralUnits(value) {
|
|
24876
|
+
if (value === null || value === void 0 || value === "") {
|
|
24877
|
+
return 0n;
|
|
24878
|
+
}
|
|
24879
|
+
if (typeof value === "bigint") {
|
|
24880
|
+
return value;
|
|
24881
|
+
}
|
|
24882
|
+
if (typeof value === "number") {
|
|
24883
|
+
if (!Number.isSafeInteger(value)) {
|
|
24884
|
+
throw new Error("Raw collateral unit numbers must be safe integers");
|
|
24885
|
+
}
|
|
24886
|
+
return BigInt(value);
|
|
24887
|
+
}
|
|
24888
|
+
if (!/^-?\d+$/.test(value)) {
|
|
24889
|
+
throw new Error("Raw collateral unit strings must be base-10 integers");
|
|
24890
|
+
}
|
|
24891
|
+
return BigInt(value);
|
|
24892
|
+
}
|
|
24893
|
+
|
|
24690
24894
|
exports.ALL_TRADING_SELECTORS = ALL_TRADING_SELECTORS;
|
|
24691
24895
|
exports.AffiliateFeeLevel = AffiliateFeeLevel;
|
|
24692
24896
|
exports.ApprovalState = ApprovalState;
|
|
@@ -24734,12 +24938,15 @@ exports.approvalActions = approval_exports;
|
|
|
24734
24938
|
exports.calculateGasMargin = calculateGasMargin;
|
|
24735
24939
|
exports.cancelActions = cancel_exports;
|
|
24736
24940
|
exports.closeActions = close_exports;
|
|
24941
|
+
exports.computeSymmAccountOverview = computeSymmAccountOverview;
|
|
24942
|
+
exports.computeSymmNetDeposited = computeSymmNetDeposited;
|
|
24737
24943
|
exports.delegationActions = delegation_exports;
|
|
24738
24944
|
exports.depositActions = deposit_exports;
|
|
24739
24945
|
exports.encodeCall = encodeCall;
|
|
24740
24946
|
exports.formatPrice = formatPrice;
|
|
24741
24947
|
exports.fromWei = fromWei;
|
|
24742
24948
|
exports.getAddress = getAddress;
|
|
24949
|
+
exports.getSymmAccountBalanceInfo = getSymmAccountBalanceInfo;
|
|
24743
24950
|
exports.instantActions = instant_exports;
|
|
24744
24951
|
exports.signatureActions = signature_exports;
|
|
24745
24952
|
exports.statsActions = stats_exports;
|