@gmx-io/sdk 0.0.1-alpha-1
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/LICENSE +40 -0
- package/README.md +79 -0
- package/build/abis/CustomErrors.json +3254 -0
- package/build/abis/DataStore.json +1440 -0
- package/build/abis/ERC721.json +442 -0
- package/build/abis/EventEmitter.json +2065 -0
- package/build/abis/ExchangeRouter.json +1598 -0
- package/build/abis/GMT.json +522 -0
- package/build/abis/GlpManager.json +592 -0
- package/build/abis/GlvReader.json +1425 -0
- package/build/abis/GlvRouter.json +613 -0
- package/build/abis/GmxMigrator.json +657 -0
- package/build/abis/GovToken.json +1121 -0
- package/build/abis/MintableBaseToken.json +696 -0
- package/build/abis/Multicall.json +333 -0
- package/build/abis/OrderBook.json +1997 -0
- package/build/abis/OrderBookReader.json +111 -0
- package/build/abis/OrderExecutor.json +122 -0
- package/build/abis/PositionManager.json +1165 -0
- package/build/abis/PositionRouter.json +2030 -0
- package/build/abis/Reader.json +355 -0
- package/build/abis/ReaderV2.json +630 -0
- package/build/abis/ReferralStorage.json +507 -0
- package/build/abis/RewardReader.json +86 -0
- package/build/abis/RewardRouter.json +769 -0
- package/build/abis/RewardTracker.json +918 -0
- package/build/abis/Router-v2.json +605 -0
- package/build/abis/Router.json +605 -0
- package/build/abis/SubaccountRouter.json +648 -0
- package/build/abis/SyntheticsReader.json +4577 -0
- package/build/abis/SyntheticsRouter.json +77 -0
- package/build/abis/Timelock.json +1737 -0
- package/build/abis/Token.json +345 -0
- package/build/abis/Treasury.json +411 -0
- package/build/abis/UniPool.json +89 -0
- package/build/abis/UniswapV2.json +1 -0
- package/build/abis/Vault.json +3220 -0
- package/build/abis/VaultReader.json +87 -0
- package/build/abis/VaultV2.json +3019 -0
- package/build/abis/VaultV2b.json +3220 -0
- package/build/abis/Vester.json +1031 -0
- package/build/abis/WETH.json +320 -0
- package/build/abis/YieldFarm.json +599 -0
- package/build/abis/YieldToken.json +560 -0
- package/build/prebuilt/hashedMarketConfigKeys.json +3658 -0
- package/build/prebuilt/hashedMarketValuesKeys.json +1103 -0
- package/build/prebuilt/index.ts +28 -0
- package/build/src/abis/CustomErrors.json +3254 -0
- package/build/src/abis/DataStore.json +1440 -0
- package/build/src/abis/ERC721.json +442 -0
- package/build/src/abis/EventEmitter.json +2065 -0
- package/build/src/abis/ExchangeRouter.json +1598 -0
- package/build/src/abis/GMT.json +522 -0
- package/build/src/abis/GlpManager.json +591 -0
- package/build/src/abis/GlvReader.json +1424 -0
- package/build/src/abis/GlvRouter.json +612 -0
- package/build/src/abis/GmxMigrator.json +657 -0
- package/build/src/abis/GovToken.json +1121 -0
- package/build/src/abis/MintableBaseToken.json +696 -0
- package/build/src/abis/Multicall.json +333 -0
- package/build/src/abis/OrderBook.json +1997 -0
- package/build/src/abis/OrderBookReader.json +111 -0
- package/build/src/abis/OrderExecutor.json +122 -0
- package/build/src/abis/PositionManager.json +1165 -0
- package/build/src/abis/PositionRouter.json +2030 -0
- package/build/src/abis/Reader.json +355 -0
- package/build/src/abis/ReaderV2.json +630 -0
- package/build/src/abis/ReferralStorage.json +507 -0
- package/build/src/abis/RewardReader.json +86 -0
- package/build/src/abis/RewardRouter.json +769 -0
- package/build/src/abis/RewardTracker.json +918 -0
- package/build/src/abis/Router-v2.json +605 -0
- package/build/src/abis/Router.json +605 -0
- package/build/src/abis/SubaccountRouter.json +648 -0
- package/build/src/abis/SyntheticsReader.json +4577 -0
- package/build/src/abis/SyntheticsRouter.json +77 -0
- package/build/src/abis/Timelock.json +1737 -0
- package/build/src/abis/Token.json +345 -0
- package/build/src/abis/Treasury.json +411 -0
- package/build/src/abis/UniPool.json +89 -0
- package/build/src/abis/UniswapV2.json +1 -0
- package/build/src/abis/Vault.json +3220 -0
- package/build/src/abis/VaultReader.json +87 -0
- package/build/src/abis/VaultV2.json +3019 -0
- package/build/src/abis/VaultV2b.json +3220 -0
- package/build/src/abis/Vester.json +1031 -0
- package/build/src/abis/WETH.json +320 -0
- package/build/src/abis/YieldFarm.json +599 -0
- package/build/src/abis/YieldToken.json +560 -0
- package/build/src/configs/batch.d.ts +6 -0
- package/build/src/configs/batch.js +51 -0
- package/build/src/configs/chains.d.ts +37 -0
- package/build/src/configs/chains.js +90 -0
- package/build/src/configs/contracts.d.ts +2 -0
- package/build/src/configs/contracts.js +218 -0
- package/build/src/configs/dataStore.d.ts +149 -0
- package/build/src/configs/dataStore.js +276 -0
- package/build/src/configs/factors.d.ts +20 -0
- package/build/src/configs/factors.js +21 -0
- package/build/src/configs/markets.d.ts +8 -0
- package/build/src/configs/markets.js +528 -0
- package/build/src/configs/subgraph.d.ts +3 -0
- package/build/src/configs/subgraph.js +3 -0
- package/build/src/configs/tokens.d.ts +89 -0
- package/build/src/configs/tokens.js +1269 -0
- package/build/src/index.d.ts +44 -0
- package/build/src/index.js +245 -0
- package/build/src/modules/accounts/accounts.d.ts +5 -0
- package/build/src/modules/accounts/accounts.js +36 -0
- package/build/src/modules/accounts/accounts.spec.d.ts +1 -0
- package/build/src/modules/accounts/accounts.spec.js +7 -0
- package/build/src/modules/base.d.ts +9 -0
- package/build/src/modules/base.js +15 -0
- package/build/src/modules/markets/index.d.ts +26 -0
- package/build/src/modules/markets/index.js +339 -0
- package/build/src/modules/markets/markets.spec.d.ts +1 -0
- package/build/src/modules/markets/markets.spec.js +38 -0
- package/build/src/modules/markets/query-builders.d.ts +40 -0
- package/build/src/modules/markets/query-builders.js +379 -0
- package/build/src/modules/markets/types.d.ts +42 -0
- package/build/src/modules/markets/types.js +1 -0
- package/build/src/modules/oracle.d.ts +31 -0
- package/build/src/modules/oracle.js +53 -0
- package/build/src/modules/orders/orders.d.ts +60 -0
- package/build/src/modules/orders/orders.js +270 -0
- package/build/src/modules/orders/orders.spec.d.ts +1 -0
- package/build/src/modules/orders/orders.spec.js +16 -0
- package/build/src/modules/orders/transactions/cancelOrdersTxn.d.ts +6 -0
- package/build/src/modules/orders/transactions/cancelOrdersTxn.js +15 -0
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.d.ts +32 -0
- package/build/src/modules/orders/transactions/createDecreaseOrderTxn.js +98 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.d.ts +77 -0
- package/build/src/modules/orders/transactions/createIncreaseOrderTxn.js +164 -0
- package/build/src/modules/orders/transactions/createSwapOrderTxn.d.ts +16 -0
- package/build/src/modules/orders/transactions/createSwapOrderTxn.js +97 -0
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.d.ts +6 -0
- package/build/src/modules/orders/transactions/createWrapOrUnwrapTxn.js +13 -0
- package/build/src/modules/orders/transactions/updateOrderTxn.d.ts +23 -0
- package/build/src/modules/orders/transactions/updateOrderTxn.js +44 -0
- package/build/src/modules/orders/utils.d.ts +248 -0
- package/build/src/modules/orders/utils.js +151 -0
- package/build/src/modules/positions/positions.d.ts +48 -0
- package/build/src/modules/positions/positions.js +563 -0
- package/build/src/modules/positions/positions.spec.d.ts +1 -0
- package/build/src/modules/positions/positions.spec.js +25 -0
- package/build/src/modules/tokens/tokens.d.ts +26 -0
- package/build/src/modules/tokens/tokens.js +132 -0
- package/build/src/modules/tokens/tokens.spec.d.ts +1 -0
- package/build/src/modules/tokens/tokens.spec.js +19 -0
- package/build/src/modules/trades/trades.d.ts +48 -0
- package/build/src/modules/trades/trades.js +390 -0
- package/build/src/modules/trades/trades.spec.d.ts +1 -0
- package/build/src/modules/trades/trades.spec.js +14 -0
- package/build/src/prebuilt/hashedMarketConfigKeys.json +3658 -0
- package/build/src/prebuilt/hashedMarketValuesKeys.json +1103 -0
- package/build/src/prebuilt/index.d.ts +14 -0
- package/build/src/prebuilt/index.js +9 -0
- package/build/src/types/amounts.d.ts +223 -0
- package/build/src/types/amounts.js +17 -0
- package/build/src/types/fees.d.ts +34 -0
- package/build/src/types/fees.js +1 -0
- package/build/src/types/markets.d.ts +143 -0
- package/build/src/types/markets.js +1 -0
- package/build/src/types/orders.d.ts +74 -0
- package/build/src/types/orders.js +33 -0
- package/build/src/types/positions.d.ts +53 -0
- package/build/src/types/positions.js +1 -0
- package/build/src/types/referrals.d.ts +124 -0
- package/build/src/types/referrals.js +9 -0
- package/build/src/types/sdk.d.ts +32 -0
- package/build/src/types/sdk.js +1 -0
- package/build/src/types/sidecarOrders.d.ts +54 -0
- package/build/src/types/sidecarOrders.js +1 -0
- package/build/src/types/syntheticsEvents.d.ts +88 -0
- package/build/src/types/syntheticsEvents.js +1 -0
- package/build/src/types/tokens.d.ts +89 -0
- package/build/src/types/tokens.js +1 -0
- package/build/src/types/trade.d.ts +223 -0
- package/build/src/types/trade.js +17 -0
- package/build/src/types/tradeHistory.d.ts +107 -0
- package/build/src/types/tradeHistory.js +8 -0
- package/build/src/utils/LruCache.d.ts +10 -0
- package/build/src/utils/LruCache.js +45 -0
- package/build/src/utils/bigmath.d.ts +7 -0
- package/build/src/utils/bigmath.js +23 -0
- package/build/src/utils/buildUrl.d.ts +1 -0
- package/build/src/utils/buildUrl.js +5 -0
- package/build/src/utils/callContract.d.ts +17 -0
- package/build/src/utils/callContract.js +133 -0
- package/build/src/utils/common.d.ts +2 -0
- package/build/src/utils/common.js +2 -0
- package/build/src/utils/fees/estimateOraclePriceCount.d.ts +6 -0
- package/build/src/utils/fees/estimateOraclePriceCount.js +19 -0
- package/build/src/utils/fees/executionFee.d.ts +59 -0
- package/build/src/utils/fees/executionFee.js +108 -0
- package/build/src/utils/fees/index.d.ts +29 -0
- package/build/src/utils/fees/index.js +89 -0
- package/build/src/utils/fees/priceImpact.d.ts +75 -0
- package/build/src/utils/fees/priceImpact.js +287 -0
- package/build/src/utils/graphqlFetcher.d.ts +1 -0
- package/build/src/utils/graphqlFetcher.js +18 -0
- package/build/src/utils/hash.d.ts +5 -0
- package/build/src/utils/hash.js +35 -0
- package/build/src/utils/marketKeysAndConfigs.d.ts +66 -0
- package/build/src/utils/marketKeysAndConfigs.js +257 -0
- package/build/src/utils/markets.d.ts +40 -0
- package/build/src/utils/markets.js +129 -0
- package/build/src/utils/multicall.d.ts +64 -0
- package/build/src/utils/multicall.js +116 -0
- package/build/src/utils/numbers.d.ts +9 -0
- package/build/src/utils/numbers.js +30 -0
- package/build/src/utils/objects.d.ts +18 -0
- package/build/src/utils/objects.js +30 -0
- package/build/src/utils/orders.d.ts +28 -0
- package/build/src/utils/orders.js +178 -0
- package/build/src/utils/positions.d.ts +60 -0
- package/build/src/utils/positions.js +133 -0
- package/build/src/utils/prices.d.ts +15 -0
- package/build/src/utils/prices.js +34 -0
- package/build/src/utils/referrals.d.ts +2 -0
- package/build/src/utils/referrals.js +27 -0
- package/build/src/utils/simulateExecuteOrder.d.ts +16 -0
- package/build/src/utils/simulateExecuteOrder.js +143 -0
- package/build/src/utils/slidingWindowFallbackSwitcher.d.ts +24 -0
- package/build/src/utils/slidingWindowFallbackSwitcher.js +40 -0
- package/build/src/utils/subgraph.d.ts +21 -0
- package/build/src/utils/subgraph.js +72 -0
- package/build/src/utils/swapStats.d.ts +35 -0
- package/build/src/utils/swapStats.js +197 -0
- package/build/src/utils/test.d.ts +2 -0
- package/build/src/utils/test.js +24 -0
- package/build/src/utils/tokens.d.ts +18 -0
- package/build/src/utils/tokens.js +64 -0
- package/build/src/utils/trade.d.ts +10 -0
- package/build/src/utils/trade.js +32 -0
- package/build/tsconfig.tsbuildinfo +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
export type UserReferralInfo = {
|
|
2
|
+
userReferralCode: string;
|
|
3
|
+
userReferralCodeString: string;
|
|
4
|
+
referralCodeForTxn: string;
|
|
5
|
+
attachedOnChain: boolean;
|
|
6
|
+
affiliate: string;
|
|
7
|
+
tierId: number;
|
|
8
|
+
totalRebate: bigint;
|
|
9
|
+
totalRebateFactor: bigint;
|
|
10
|
+
discountShare: bigint;
|
|
11
|
+
discountFactor: bigint;
|
|
12
|
+
error?: Error;
|
|
13
|
+
};
|
|
14
|
+
export declare enum RebateDistributionType {
|
|
15
|
+
Rebate = "1",
|
|
16
|
+
Claim = "1000",
|
|
17
|
+
Discount = "2"
|
|
18
|
+
}
|
|
19
|
+
export type RebateDistribution = {
|
|
20
|
+
typeId: RebateDistributionType;
|
|
21
|
+
receiver: string;
|
|
22
|
+
markets: string[];
|
|
23
|
+
tokens: string[];
|
|
24
|
+
amounts: bigint[];
|
|
25
|
+
amountsInUsd: bigint[];
|
|
26
|
+
timestamp: number;
|
|
27
|
+
transactionHash: string;
|
|
28
|
+
id: string;
|
|
29
|
+
};
|
|
30
|
+
export type CodeOwnershipInfo = {
|
|
31
|
+
code: string;
|
|
32
|
+
codeString: string;
|
|
33
|
+
owner?: string;
|
|
34
|
+
isTaken: boolean;
|
|
35
|
+
isTakenByCurrentUser: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type ReferralCodeStats = {
|
|
38
|
+
referralCode: string;
|
|
39
|
+
trades: number;
|
|
40
|
+
tradedReferralsCount: number;
|
|
41
|
+
registeredReferralsCount: number;
|
|
42
|
+
/**
|
|
43
|
+
* This includes available testnets
|
|
44
|
+
*/
|
|
45
|
+
allOwnersOnOtherChains?: {
|
|
46
|
+
[chainId: number]: CodeOwnershipInfo;
|
|
47
|
+
};
|
|
48
|
+
volume: bigint;
|
|
49
|
+
totalRebateUsd: bigint;
|
|
50
|
+
affiliateRebateUsd: bigint;
|
|
51
|
+
discountUsd: bigint;
|
|
52
|
+
v1Data: {
|
|
53
|
+
volume: bigint;
|
|
54
|
+
totalRebateUsd: bigint;
|
|
55
|
+
affiliateRebateUsd: bigint;
|
|
56
|
+
discountUsd: bigint;
|
|
57
|
+
};
|
|
58
|
+
v2Data: {
|
|
59
|
+
volume: bigint;
|
|
60
|
+
totalRebateUsd: bigint;
|
|
61
|
+
affiliateRebateUsd: bigint;
|
|
62
|
+
discountUsd: bigint;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type AffiliateTotalStats = {
|
|
66
|
+
trades: number;
|
|
67
|
+
tradedReferralsCount: number;
|
|
68
|
+
registeredReferralsCount: number;
|
|
69
|
+
volume: bigint;
|
|
70
|
+
totalRebateUsd: bigint;
|
|
71
|
+
affiliateRebateUsd: bigint;
|
|
72
|
+
discountUsd: bigint;
|
|
73
|
+
v1Data: {
|
|
74
|
+
volume: bigint;
|
|
75
|
+
totalRebateUsd: bigint;
|
|
76
|
+
affiliateRebateUsd: bigint;
|
|
77
|
+
discountUsd: bigint;
|
|
78
|
+
};
|
|
79
|
+
v2Data: {
|
|
80
|
+
volume: bigint;
|
|
81
|
+
totalRebateUsd: bigint;
|
|
82
|
+
affiliateRebateUsd: bigint;
|
|
83
|
+
discountUsd: bigint;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export type TraderReferralTotalStats = {
|
|
87
|
+
volume: bigint;
|
|
88
|
+
discountUsd: bigint;
|
|
89
|
+
v1Data: {
|
|
90
|
+
volume: bigint;
|
|
91
|
+
discountUsd: bigint;
|
|
92
|
+
};
|
|
93
|
+
v2Data: {
|
|
94
|
+
volume: bigint;
|
|
95
|
+
discountUsd: bigint;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
export type TierInfo = {
|
|
99
|
+
id: string;
|
|
100
|
+
tierId: number;
|
|
101
|
+
discountShare: bigint;
|
|
102
|
+
};
|
|
103
|
+
export type ReferralsStats = {
|
|
104
|
+
chainId: number;
|
|
105
|
+
affiliateDistributions: RebateDistribution[];
|
|
106
|
+
traderDistributions: RebateDistribution[];
|
|
107
|
+
affiliateReferralCodesStats: ReferralCodeStats[];
|
|
108
|
+
affiliateTotalStats: AffiliateTotalStats;
|
|
109
|
+
traderReferralTotalStats: TraderReferralTotalStats;
|
|
110
|
+
codes: string[];
|
|
111
|
+
affiliateTierInfo: TierInfo;
|
|
112
|
+
};
|
|
113
|
+
export type TotalReferralsStats = {
|
|
114
|
+
total: {
|
|
115
|
+
registeredReferralsCount: number;
|
|
116
|
+
affiliateVolume: bigint;
|
|
117
|
+
affiliateRebateUsd: bigint;
|
|
118
|
+
discountUsd: bigint;
|
|
119
|
+
traderVolume: bigint;
|
|
120
|
+
};
|
|
121
|
+
chains: {
|
|
122
|
+
[chainId: number]: ReferralsStats;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export var RebateDistributionType;
|
|
2
|
+
(function (RebateDistributionType) {
|
|
3
|
+
// V1 Airdrop for Affiliates
|
|
4
|
+
RebateDistributionType["Rebate"] = "1";
|
|
5
|
+
// V2 Claim for Affiliates
|
|
6
|
+
RebateDistributionType["Claim"] = "1000";
|
|
7
|
+
// V1 Airdrop for Traders
|
|
8
|
+
RebateDistributionType["Discount"] = "2";
|
|
9
|
+
})(RebateDistributionType || (RebateDistributionType = {}));
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PublicClient, WalletClient } from "viem";
|
|
2
|
+
import { Token } from "./tokens";
|
|
3
|
+
export interface GmxSdkConfig {
|
|
4
|
+
chainId: number;
|
|
5
|
+
account?: string;
|
|
6
|
+
oracleUrl: string;
|
|
7
|
+
rpcUrl: string;
|
|
8
|
+
subgraph: {
|
|
9
|
+
stats?: string;
|
|
10
|
+
referrals?: string;
|
|
11
|
+
nissohVault?: string;
|
|
12
|
+
syntheticsStats?: string;
|
|
13
|
+
subsquid?: string;
|
|
14
|
+
};
|
|
15
|
+
publicClient?: PublicClient;
|
|
16
|
+
walletClient?: WalletClient;
|
|
17
|
+
tokens?: Token[];
|
|
18
|
+
onEmitMetricCounter?(e: {
|
|
19
|
+
event: string;
|
|
20
|
+
data: any;
|
|
21
|
+
}): void;
|
|
22
|
+
onEmitMetricTiming?(e: {
|
|
23
|
+
event: string;
|
|
24
|
+
time: number;
|
|
25
|
+
data: any;
|
|
26
|
+
}): void;
|
|
27
|
+
onEmitMetricEvent?(e: {
|
|
28
|
+
event: string;
|
|
29
|
+
isError: boolean;
|
|
30
|
+
data: any;
|
|
31
|
+
}): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { OrderTxnType, PositionOrderInfo } from "./orders";
|
|
2
|
+
import { DecreasePositionAmounts, IncreasePositionAmounts } from "./trade";
|
|
3
|
+
export type GroupPrefix = "sl" | "tp" | "limit";
|
|
4
|
+
export type EntryField = {
|
|
5
|
+
input: string;
|
|
6
|
+
value: bigint | null;
|
|
7
|
+
error: string | null;
|
|
8
|
+
};
|
|
9
|
+
export type InitialEntry = {
|
|
10
|
+
order: PositionOrderInfo | null;
|
|
11
|
+
sizeUsd: EntryField;
|
|
12
|
+
price: EntryField;
|
|
13
|
+
};
|
|
14
|
+
export type SidecarOrderEntryBase = {
|
|
15
|
+
id: string;
|
|
16
|
+
price: EntryField;
|
|
17
|
+
sizeUsd: EntryField;
|
|
18
|
+
percentage: EntryField;
|
|
19
|
+
txnType: OrderTxnType | null;
|
|
20
|
+
mode: "keepSize" | "keepPercentage" | "fitPercentage";
|
|
21
|
+
order: null | PositionOrderInfo;
|
|
22
|
+
};
|
|
23
|
+
export type SidecarSlTpOrderEntry = SidecarOrderEntryBase & {
|
|
24
|
+
increaseAmounts: undefined;
|
|
25
|
+
decreaseAmounts?: DecreasePositionAmounts;
|
|
26
|
+
};
|
|
27
|
+
export type SidecarSlTpOrderEntryValid = SidecarSlTpOrderEntry & {
|
|
28
|
+
decreaseAmounts: DecreasePositionAmounts;
|
|
29
|
+
};
|
|
30
|
+
export type SidecarLimitOrderEntry = SidecarOrderEntryBase & {
|
|
31
|
+
increaseAmounts?: IncreasePositionAmounts;
|
|
32
|
+
decreaseAmounts: undefined;
|
|
33
|
+
};
|
|
34
|
+
export type SidecarLimitOrderEntryValid = SidecarLimitOrderEntry & {
|
|
35
|
+
increaseAmounts: IncreasePositionAmounts;
|
|
36
|
+
};
|
|
37
|
+
export type SidecarOrderEntry = SidecarSlTpOrderEntry | SidecarLimitOrderEntry;
|
|
38
|
+
export type SidecarOrderEntryGroupBase<T extends SidecarOrderEntryBase> = {
|
|
39
|
+
entries: T[];
|
|
40
|
+
canAddEntry: boolean;
|
|
41
|
+
allowAddEntry: boolean;
|
|
42
|
+
addEntry: () => void;
|
|
43
|
+
updateEntry: (id: string, field: "price" | "sizeUsd" | "percentage", value: string) => void;
|
|
44
|
+
deleteEntry: (id: string) => void;
|
|
45
|
+
reset: () => void;
|
|
46
|
+
};
|
|
47
|
+
export type SidecarOrderEntryGroup = SidecarOrderEntryGroupBase<SidecarOrderEntry> & {
|
|
48
|
+
totalPnL: bigint;
|
|
49
|
+
totalPnLPercentage: bigint;
|
|
50
|
+
error?: null | {
|
|
51
|
+
price?: string;
|
|
52
|
+
percentage?: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { OrderType } from "./orders";
|
|
2
|
+
export type MultiTransactionStatus<TEventData> = {
|
|
3
|
+
key: string;
|
|
4
|
+
data?: TEventData;
|
|
5
|
+
createdTxnHash?: string;
|
|
6
|
+
cancelledTxnHash?: string;
|
|
7
|
+
updatedTxnHash?: string;
|
|
8
|
+
executedTxnHash?: string;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
isViewed?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type PositionIncreaseEvent = {
|
|
13
|
+
positionKey: string;
|
|
14
|
+
contractPositionKey: string;
|
|
15
|
+
account: string;
|
|
16
|
+
marketAddress: string;
|
|
17
|
+
collateralTokenAddress: string;
|
|
18
|
+
sizeInUsd: bigint;
|
|
19
|
+
sizeInTokens: bigint;
|
|
20
|
+
collateralAmount: bigint;
|
|
21
|
+
borrowingFactor: bigint;
|
|
22
|
+
executionPrice: bigint;
|
|
23
|
+
sizeDeltaUsd: bigint;
|
|
24
|
+
sizeDeltaInTokens: bigint;
|
|
25
|
+
longTokenFundingAmountPerSize: bigint;
|
|
26
|
+
shortTokenFundingAmountPerSize: bigint;
|
|
27
|
+
collateralDeltaAmount: bigint;
|
|
28
|
+
isLong: boolean;
|
|
29
|
+
orderType: OrderType;
|
|
30
|
+
orderKey: string;
|
|
31
|
+
increasedAtBlock: bigint;
|
|
32
|
+
};
|
|
33
|
+
export type PositionDecreaseEvent = {
|
|
34
|
+
positionKey: string;
|
|
35
|
+
contractPositionKey: string;
|
|
36
|
+
account: string;
|
|
37
|
+
marketAddress: string;
|
|
38
|
+
collateralTokenAddress: string;
|
|
39
|
+
sizeInUsd: bigint;
|
|
40
|
+
sizeInTokens: bigint;
|
|
41
|
+
sizeDeltaUsd: bigint;
|
|
42
|
+
sizeDeltaInTokens: bigint;
|
|
43
|
+
collateralAmount: bigint;
|
|
44
|
+
collateralDeltaAmount: bigint;
|
|
45
|
+
borrowingFactor: bigint;
|
|
46
|
+
longTokenFundingAmountPerSize: bigint;
|
|
47
|
+
shortTokenFundingAmountPerSize: bigint;
|
|
48
|
+
pnlUsd: bigint;
|
|
49
|
+
isLong: boolean;
|
|
50
|
+
orderType: OrderType;
|
|
51
|
+
orderKey: string;
|
|
52
|
+
decreasedAtBlock: bigint;
|
|
53
|
+
};
|
|
54
|
+
export type PendingPositionUpdate = {
|
|
55
|
+
isIncrease: boolean;
|
|
56
|
+
positionKey: string;
|
|
57
|
+
sizeDeltaUsd: bigint;
|
|
58
|
+
sizeDeltaInTokens: bigint;
|
|
59
|
+
collateralDeltaAmount: bigint;
|
|
60
|
+
updatedAt: number;
|
|
61
|
+
updatedAtBlock: bigint;
|
|
62
|
+
};
|
|
63
|
+
export type PendingPositionsUpdates = {
|
|
64
|
+
[key: string]: PendingPositionUpdate | undefined;
|
|
65
|
+
};
|
|
66
|
+
export type EventLogItems<T> = {
|
|
67
|
+
[key: string]: T;
|
|
68
|
+
};
|
|
69
|
+
export type EventLogArrayItems<T> = {
|
|
70
|
+
[key: string]: T[];
|
|
71
|
+
};
|
|
72
|
+
export type EventLogSection<T> = {
|
|
73
|
+
items: EventLogItems<T>;
|
|
74
|
+
arrayItems: EventLogArrayItems<T>;
|
|
75
|
+
};
|
|
76
|
+
export type EventLogData = {
|
|
77
|
+
addressItems: EventLogSection<string>;
|
|
78
|
+
uintItems: EventLogSection<bigint>;
|
|
79
|
+
intItems: EventLogSection<bigint>;
|
|
80
|
+
boolItems: EventLogSection<boolean>;
|
|
81
|
+
bytes32Items: EventLogSection<string>;
|
|
82
|
+
bytesItems: EventLogSection<string>;
|
|
83
|
+
stringItems: EventLogSection<string>;
|
|
84
|
+
};
|
|
85
|
+
export type EventTxnParams = {
|
|
86
|
+
transactionHash: string;
|
|
87
|
+
blockNumber: number;
|
|
88
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type Token = {
|
|
2
|
+
name: string;
|
|
3
|
+
symbol: string;
|
|
4
|
+
assetSymbol?: string;
|
|
5
|
+
baseSymbol?: string;
|
|
6
|
+
decimals: number;
|
|
7
|
+
address: string;
|
|
8
|
+
priceDecimals?: number;
|
|
9
|
+
wrappedAddress?: string;
|
|
10
|
+
coingeckoUrl?: string;
|
|
11
|
+
coingeckoSymbol?: string;
|
|
12
|
+
metamaskSymbol?: string;
|
|
13
|
+
explorerSymbol?: string;
|
|
14
|
+
explorerUrl?: string;
|
|
15
|
+
reservesUrl?: string;
|
|
16
|
+
imageUrl?: string;
|
|
17
|
+
isUsdg?: boolean;
|
|
18
|
+
isNative?: boolean;
|
|
19
|
+
isWrapped?: boolean;
|
|
20
|
+
isShortable?: boolean;
|
|
21
|
+
isStable?: boolean;
|
|
22
|
+
isSynthetic?: boolean;
|
|
23
|
+
isTempHidden?: boolean;
|
|
24
|
+
isChartDisabled?: boolean;
|
|
25
|
+
isV1Available?: boolean;
|
|
26
|
+
isPlatformToken?: boolean;
|
|
27
|
+
isPlatformTradingToken?: boolean;
|
|
28
|
+
};
|
|
29
|
+
export type TokenInfo = Token & {
|
|
30
|
+
hasMaxAvailableLong?: boolean;
|
|
31
|
+
hasMaxAvailableShort?: boolean;
|
|
32
|
+
usdgAmount?: bigint;
|
|
33
|
+
maxUsdgAmount?: bigint;
|
|
34
|
+
poolAmount?: bigint;
|
|
35
|
+
bufferAmount?: bigint;
|
|
36
|
+
managedAmount?: bigint;
|
|
37
|
+
managedUsd?: bigint;
|
|
38
|
+
availableAmount?: bigint;
|
|
39
|
+
availableUsd?: bigint;
|
|
40
|
+
guaranteedUsd?: bigint;
|
|
41
|
+
redemptionAmount?: bigint;
|
|
42
|
+
reservedAmount?: bigint;
|
|
43
|
+
balance?: bigint;
|
|
44
|
+
weight?: bigint;
|
|
45
|
+
maxPrice?: bigint;
|
|
46
|
+
maxPrimaryPrice?: bigint;
|
|
47
|
+
minPrice?: bigint;
|
|
48
|
+
minPrimaryPrice?: bigint;
|
|
49
|
+
contractMaxPrice?: bigint;
|
|
50
|
+
contractMinPrice?: bigint;
|
|
51
|
+
spread?: bigint;
|
|
52
|
+
cumulativeFundingRate?: bigint;
|
|
53
|
+
fundingRate?: bigint;
|
|
54
|
+
globalShortSize?: bigint;
|
|
55
|
+
maxAvailableLong?: bigint;
|
|
56
|
+
maxAvailableShort?: bigint;
|
|
57
|
+
maxGlobalLongSize?: bigint;
|
|
58
|
+
maxGlobalShortSize?: bigint;
|
|
59
|
+
maxLongCapacity?: bigint;
|
|
60
|
+
};
|
|
61
|
+
export type InfoTokens = {
|
|
62
|
+
[key: string]: TokenInfo;
|
|
63
|
+
};
|
|
64
|
+
export type TokenPrices = {
|
|
65
|
+
minPrice: bigint;
|
|
66
|
+
maxPrice: bigint;
|
|
67
|
+
};
|
|
68
|
+
export type TokenData = Token & {
|
|
69
|
+
prices: TokenPrices;
|
|
70
|
+
balance?: bigint;
|
|
71
|
+
totalSupply?: bigint;
|
|
72
|
+
};
|
|
73
|
+
export type TokensRatio = {
|
|
74
|
+
ratio: bigint;
|
|
75
|
+
largestToken: Token;
|
|
76
|
+
smallestToken: Token;
|
|
77
|
+
};
|
|
78
|
+
export type TokenBalancesData = {
|
|
79
|
+
[tokenAddress: string]: bigint;
|
|
80
|
+
};
|
|
81
|
+
export type TokenPricesData = {
|
|
82
|
+
[address: string]: TokenPrices;
|
|
83
|
+
};
|
|
84
|
+
export type TokensAllowanceData = {
|
|
85
|
+
[tokenAddress: string]: bigint;
|
|
86
|
+
};
|
|
87
|
+
export type TokensData = {
|
|
88
|
+
[address: string]: TokenData;
|
|
89
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { MarketInfo } from "types/markets";
|
|
2
|
+
import { FeeItem, SwapFeeItem } from "./fees";
|
|
3
|
+
import { DecreasePositionSwapType, OrderType } from "./orders";
|
|
4
|
+
export declare enum TradeType {
|
|
5
|
+
Long = "Long",
|
|
6
|
+
Short = "Short",
|
|
7
|
+
Swap = "Swap"
|
|
8
|
+
}
|
|
9
|
+
export declare enum TradeMode {
|
|
10
|
+
Market = "Market",
|
|
11
|
+
Limit = "Limit",
|
|
12
|
+
Trigger = "Trigger"
|
|
13
|
+
}
|
|
14
|
+
export declare enum TriggerThresholdType {
|
|
15
|
+
Above = ">",
|
|
16
|
+
Below = "<"
|
|
17
|
+
}
|
|
18
|
+
export type TradeFlags = {
|
|
19
|
+
isLong: boolean;
|
|
20
|
+
isShort: boolean;
|
|
21
|
+
isSwap: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* ```ts
|
|
24
|
+
* isLong || isShort
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
isPosition: boolean;
|
|
28
|
+
isIncrease: boolean;
|
|
29
|
+
isTrigger: boolean;
|
|
30
|
+
isMarket: boolean;
|
|
31
|
+
isLimit: boolean;
|
|
32
|
+
};
|
|
33
|
+
export type SwapAmounts = {
|
|
34
|
+
amountIn: bigint;
|
|
35
|
+
usdIn: bigint;
|
|
36
|
+
amountOut: bigint;
|
|
37
|
+
usdOut: bigint;
|
|
38
|
+
priceIn: bigint;
|
|
39
|
+
priceOut: bigint;
|
|
40
|
+
swapPathStats: SwapPathStats | undefined;
|
|
41
|
+
minOutputAmount: bigint;
|
|
42
|
+
uiFeeUsd?: bigint;
|
|
43
|
+
};
|
|
44
|
+
export type IncreasePositionAmounts = {
|
|
45
|
+
initialCollateralAmount: bigint;
|
|
46
|
+
initialCollateralUsd: bigint;
|
|
47
|
+
collateralDeltaAmount: bigint;
|
|
48
|
+
collateralDeltaUsd: bigint;
|
|
49
|
+
swapPathStats: SwapPathStats | undefined;
|
|
50
|
+
indexTokenAmount: bigint;
|
|
51
|
+
sizeDeltaUsd: bigint;
|
|
52
|
+
sizeDeltaInTokens: bigint;
|
|
53
|
+
estimatedLeverage?: bigint;
|
|
54
|
+
indexPrice: bigint;
|
|
55
|
+
initialCollateralPrice: bigint;
|
|
56
|
+
collateralPrice: bigint;
|
|
57
|
+
triggerPrice?: bigint;
|
|
58
|
+
triggerThresholdType?: TriggerThresholdType;
|
|
59
|
+
acceptablePrice: bigint;
|
|
60
|
+
acceptablePriceDeltaBps: bigint;
|
|
61
|
+
positionFeeUsd: bigint;
|
|
62
|
+
uiFeeUsd: bigint;
|
|
63
|
+
swapUiFeeUsd: bigint;
|
|
64
|
+
feeDiscountUsd: bigint;
|
|
65
|
+
borrowingFeeUsd: bigint;
|
|
66
|
+
fundingFeeUsd: bigint;
|
|
67
|
+
positionPriceImpactDeltaUsd: bigint;
|
|
68
|
+
};
|
|
69
|
+
export type DecreasePositionAmounts = {
|
|
70
|
+
isFullClose: boolean;
|
|
71
|
+
sizeDeltaUsd: bigint;
|
|
72
|
+
sizeDeltaInTokens: bigint;
|
|
73
|
+
collateralDeltaUsd: bigint;
|
|
74
|
+
collateralDeltaAmount: bigint;
|
|
75
|
+
indexPrice: bigint;
|
|
76
|
+
collateralPrice: bigint;
|
|
77
|
+
triggerPrice?: bigint;
|
|
78
|
+
acceptablePrice: bigint;
|
|
79
|
+
acceptablePriceDeltaBps: bigint;
|
|
80
|
+
recommendedAcceptablePriceDeltaBps: bigint;
|
|
81
|
+
estimatedPnl: bigint;
|
|
82
|
+
estimatedPnlPercentage: bigint;
|
|
83
|
+
realizedPnl: bigint;
|
|
84
|
+
realizedPnlPercentage: bigint;
|
|
85
|
+
positionFeeUsd: bigint;
|
|
86
|
+
uiFeeUsd: bigint;
|
|
87
|
+
swapUiFeeUsd: bigint;
|
|
88
|
+
feeDiscountUsd: bigint;
|
|
89
|
+
borrowingFeeUsd: bigint;
|
|
90
|
+
fundingFeeUsd: bigint;
|
|
91
|
+
swapProfitFeeUsd: bigint;
|
|
92
|
+
positionPriceImpactDeltaUsd: bigint;
|
|
93
|
+
priceImpactDiffUsd: bigint;
|
|
94
|
+
payedRemainingCollateralAmount: bigint;
|
|
95
|
+
payedOutputUsd: bigint;
|
|
96
|
+
payedRemainingCollateralUsd: bigint;
|
|
97
|
+
receiveTokenAmount: bigint;
|
|
98
|
+
receiveUsd: bigint;
|
|
99
|
+
triggerOrderType?: OrderType.LimitDecrease | OrderType.StopLossDecrease;
|
|
100
|
+
triggerThresholdType?: TriggerThresholdType;
|
|
101
|
+
decreaseSwapType: DecreasePositionSwapType;
|
|
102
|
+
};
|
|
103
|
+
export type DepositAmounts = {
|
|
104
|
+
marketTokenAmount: bigint;
|
|
105
|
+
marketTokenUsd: bigint;
|
|
106
|
+
longTokenAmount: bigint;
|
|
107
|
+
longTokenUsd: bigint;
|
|
108
|
+
glvTokenAmount: bigint;
|
|
109
|
+
glvTokenUsd: bigint;
|
|
110
|
+
shortTokenAmount: bigint;
|
|
111
|
+
shortTokenUsd: bigint;
|
|
112
|
+
swapFeeUsd: bigint;
|
|
113
|
+
uiFeeUsd: bigint;
|
|
114
|
+
swapPriceImpactDeltaUsd: bigint;
|
|
115
|
+
};
|
|
116
|
+
export type WithdrawalAmounts = {
|
|
117
|
+
marketTokenAmount: bigint;
|
|
118
|
+
marketTokenUsd: bigint;
|
|
119
|
+
longTokenAmount: bigint;
|
|
120
|
+
shortTokenAmount: bigint;
|
|
121
|
+
longTokenUsd: bigint;
|
|
122
|
+
shortTokenUsd: bigint;
|
|
123
|
+
glvTokenAmount: bigint;
|
|
124
|
+
glvTokenUsd: bigint;
|
|
125
|
+
swapFeeUsd: bigint;
|
|
126
|
+
uiFeeUsd: bigint;
|
|
127
|
+
swapPriceImpactDeltaUsd: bigint;
|
|
128
|
+
};
|
|
129
|
+
export type NextPositionValues = {
|
|
130
|
+
nextLeverage?: bigint;
|
|
131
|
+
nextLiqPrice?: bigint;
|
|
132
|
+
nextCollateralUsd?: bigint;
|
|
133
|
+
nextSizeUsd?: bigint;
|
|
134
|
+
nextPnl?: bigint;
|
|
135
|
+
nextPnlPercentage?: bigint;
|
|
136
|
+
nextEntryPrice?: bigint;
|
|
137
|
+
remainingCollateralFeesUsd?: bigint;
|
|
138
|
+
};
|
|
139
|
+
export type SwapStats = {
|
|
140
|
+
marketAddress: string;
|
|
141
|
+
tokenInAddress: string;
|
|
142
|
+
tokenOutAddress: string;
|
|
143
|
+
isWrap: boolean;
|
|
144
|
+
isUnwrap: boolean;
|
|
145
|
+
isOutLiquidity?: boolean;
|
|
146
|
+
swapFeeAmount: bigint;
|
|
147
|
+
swapFeeUsd: bigint;
|
|
148
|
+
priceImpactDeltaUsd: bigint;
|
|
149
|
+
amountIn: bigint;
|
|
150
|
+
amountInAfterFees: bigint;
|
|
151
|
+
usdIn: bigint;
|
|
152
|
+
amountOut: bigint;
|
|
153
|
+
usdOut: bigint;
|
|
154
|
+
};
|
|
155
|
+
export type SwapPathStats = {
|
|
156
|
+
swapPath: string[];
|
|
157
|
+
swapSteps: SwapStats[];
|
|
158
|
+
targetMarketAddress?: string;
|
|
159
|
+
totalSwapPriceImpactDeltaUsd: bigint;
|
|
160
|
+
totalSwapFeeUsd: bigint;
|
|
161
|
+
totalFeesDeltaUsd: bigint;
|
|
162
|
+
tokenInAddress: string;
|
|
163
|
+
tokenOutAddress: string;
|
|
164
|
+
usdOut: bigint;
|
|
165
|
+
amountOut: bigint;
|
|
166
|
+
};
|
|
167
|
+
export type MarketEdge = {
|
|
168
|
+
marketAddress: string;
|
|
169
|
+
marketInfo: MarketInfo;
|
|
170
|
+
from: string;
|
|
171
|
+
to: string;
|
|
172
|
+
};
|
|
173
|
+
export type SwapRoute = {
|
|
174
|
+
edged: MarketEdge[];
|
|
175
|
+
path: string[];
|
|
176
|
+
liquidity: bigint;
|
|
177
|
+
};
|
|
178
|
+
export type MarketsGraph = {
|
|
179
|
+
abjacencyList: {
|
|
180
|
+
[token: string]: MarketEdge[];
|
|
181
|
+
};
|
|
182
|
+
edges: MarketEdge[];
|
|
183
|
+
};
|
|
184
|
+
export type SwapEstimator = (e: MarketEdge, usdIn: bigint) => {
|
|
185
|
+
usdOut: bigint;
|
|
186
|
+
};
|
|
187
|
+
export type FindSwapPath = (usdIn: bigint, opts: {
|
|
188
|
+
byLiquidity?: boolean;
|
|
189
|
+
}) => SwapPathStats | undefined;
|
|
190
|
+
export type TradeFeesType = "swap" | "increase" | "decrease" | "edit";
|
|
191
|
+
export type TradeFees = {
|
|
192
|
+
totalFees?: FeeItem;
|
|
193
|
+
payTotalFees?: FeeItem;
|
|
194
|
+
swapFees?: SwapFeeItem[];
|
|
195
|
+
positionFee?: FeeItem;
|
|
196
|
+
swapPriceImpact?: FeeItem;
|
|
197
|
+
positionPriceImpact?: FeeItem;
|
|
198
|
+
priceImpactDiff?: FeeItem;
|
|
199
|
+
positionCollateralPriceImpact?: FeeItem;
|
|
200
|
+
collateralPriceImpactDiff?: FeeItem;
|
|
201
|
+
positionFeeFactor?: bigint;
|
|
202
|
+
borrowFee?: FeeItem;
|
|
203
|
+
fundingFee?: FeeItem;
|
|
204
|
+
uiFee?: FeeItem;
|
|
205
|
+
uiSwapFee?: FeeItem;
|
|
206
|
+
feeDiscountUsd?: bigint;
|
|
207
|
+
swapProfitFee?: FeeItem;
|
|
208
|
+
};
|
|
209
|
+
export type GmSwapFees = {
|
|
210
|
+
totalFees?: FeeItem;
|
|
211
|
+
swapFee?: FeeItem;
|
|
212
|
+
swapPriceImpact?: FeeItem;
|
|
213
|
+
uiFee?: FeeItem;
|
|
214
|
+
shiftFee?: FeeItem;
|
|
215
|
+
};
|
|
216
|
+
export type TradeSearchParams = {
|
|
217
|
+
from?: string;
|
|
218
|
+
to?: string;
|
|
219
|
+
mode?: string;
|
|
220
|
+
pool?: string;
|
|
221
|
+
collateral?: string;
|
|
222
|
+
market?: string;
|
|
223
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export var TradeType;
|
|
2
|
+
(function (TradeType) {
|
|
3
|
+
TradeType["Long"] = "Long";
|
|
4
|
+
TradeType["Short"] = "Short";
|
|
5
|
+
TradeType["Swap"] = "Swap";
|
|
6
|
+
})(TradeType || (TradeType = {}));
|
|
7
|
+
export var TradeMode;
|
|
8
|
+
(function (TradeMode) {
|
|
9
|
+
TradeMode["Market"] = "Market";
|
|
10
|
+
TradeMode["Limit"] = "Limit";
|
|
11
|
+
TradeMode["Trigger"] = "Trigger";
|
|
12
|
+
})(TradeMode || (TradeMode = {}));
|
|
13
|
+
export var TriggerThresholdType;
|
|
14
|
+
(function (TriggerThresholdType) {
|
|
15
|
+
TriggerThresholdType["Above"] = ">";
|
|
16
|
+
TriggerThresholdType["Below"] = "<";
|
|
17
|
+
})(TriggerThresholdType || (TriggerThresholdType = {}));
|