@reyaxyz/common 0.155.2 → 0.155.3
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/README.md +1 -1
- package/dist/transactions/abis/CoreProxy.json +50 -0
- package/dist/transactions/contractAddresses.js +2 -2
- package/dist/transactions/contractAddresses.js.map +1 -1
- package/dist/transactions/index.js +1 -3
- package/dist/transactions/index.js.map +1 -1
- package/dist/transactions/sign.js +101 -56
- package/dist/transactions/sign.js.map +1 -1
- package/dist/transactions/trade.js +12 -1
- package/dist/transactions/trade.js.map +1 -1
- package/dist/types/transactions/contractAddresses.d.ts.map +1 -1
- package/dist/types/transactions/index.d.ts +0 -1
- package/dist/types/transactions/index.d.ts.map +1 -1
- package/dist/types/transactions/sign.d.ts +3 -1
- package/dist/types/transactions/sign.d.ts.map +1 -1
- package/dist/types/transactions/trade.d.ts +1 -0
- package/dist/types/transactions/trade.d.ts.map +1 -1
- package/dist/types/types.d.ts +12 -3
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types.js +6 -2
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/transactions/abis/CoreProxy.json +50 -0
- package/src/transactions/contractAddresses.ts +4 -2
- package/src/transactions/index.ts +0 -1
- package/src/transactions/sign.ts +99 -26
- package/src/transactions/trade.ts +10 -0
- package/src/types.ts +14 -3
- package/dist/transactions/abis/ConditionalOrdersGateway.json +0 -477
- package/src/transactions/abis/ConditionalOrdersGateway.json +0 -478
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StopLossOrderStatus = exports.CandleResolution = exports.FundingRateHistoryGranularity = exports.AllMarginAccountsBalanceGranularity = exports.MarginAccountCollateralsBalanceGranularity = exports.MarginAccountBalanceGranularity = exports.LpBalanceGranularity = exports.CandlesResolution = exports.MoneyInOutChainId = exports.ReyaChainId = void 0;
|
|
3
|
+
exports.StopLossOrderStatus = exports.ConditionalOrderType = exports.CandleResolution = exports.FundingRateHistoryGranularity = exports.AllMarginAccountsBalanceGranularity = exports.MarginAccountCollateralsBalanceGranularity = exports.MarginAccountBalanceGranularity = exports.LpBalanceGranularity = exports.CandlesResolution = exports.MoneyInOutChainId = exports.ReyaChainId = void 0;
|
|
4
4
|
var ReyaChainId;
|
|
5
5
|
(function (ReyaChainId) {
|
|
6
6
|
ReyaChainId[ReyaChainId["reyaNetwork"] = 1729] = "reyaNetwork";
|
|
@@ -89,9 +89,13 @@ var CandleResolution;
|
|
|
89
89
|
CandleResolution["FOUR_HOURS"] = "4HOURS";
|
|
90
90
|
CandleResolution["ONE_DAY"] = "1DAY";
|
|
91
91
|
})(CandleResolution || (exports.CandleResolution = CandleResolution = {}));
|
|
92
|
+
var ConditionalOrderType;
|
|
93
|
+
(function (ConditionalOrderType) {
|
|
94
|
+
ConditionalOrderType[ConditionalOrderType["STOP_LOSS"] = 0] = "STOP_LOSS";
|
|
95
|
+
})(ConditionalOrderType || (exports.ConditionalOrderType = ConditionalOrderType = {}));
|
|
92
96
|
var StopLossOrderStatus;
|
|
93
97
|
(function (StopLossOrderStatus) {
|
|
94
|
-
StopLossOrderStatus["
|
|
98
|
+
StopLossOrderStatus["PENDING"] = "pending";
|
|
95
99
|
StopLossOrderStatus["FILLED"] = "filled";
|
|
96
100
|
StopLossOrderStatus["CANCELLED"] = "cancelled";
|
|
97
101
|
StopLossOrderStatus["REJECTED"] = "rejected";
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;AA+BA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8DAAkB,CAAA;IAClB,gEAAqB,CAAA;AACvB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAED,IAAY,iBAYX;AAZD,WAAY,iBAAiB;IAC3B,UAAU;IACV,+EAAmB,CAAA;IACnB,oEAAc,CAAA;IACd,+EAAoB,CAAA;IACpB,2EAAmB,CAAA;IACnB,0EAAkB,CAAA;IAClB,UAAU;IACV,+EAAqB,CAAA;IACrB,oFAAwB,CAAA;IACxB,0EAAoB,CAAA;IACpB,sFAA0B,CAAA;AAC5B,CAAC,EAZW,iBAAiB,iCAAjB,iBAAiB,QAY5B;AAED,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B;AAqLD,0BAA0B;AAC1B,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,+EAAsB,CAAA;IACtB,6EAAyB,CAAA;IACzB,4EAA6B,CAAA;IAC7B,+EAAkC,CAAA;IAClC,kFAAoC,CAAA;IACpC,iFAAoC,CAAA;AACtC,CAAC,EAPW,oBAAoB,oCAApB,oBAAoB,QAO/B;AA0FD,iCAAiC;AACjC,IAAY,+BAOX;AAPD,WAAY,+BAA+B;IACzC,qGAAsB,CAAA;IACtB,mGAAyB,CAAA;IACzB,kGAA6B,CAAA;IAC7B,qGAAkC,CAAA;IAClC,wGAAoC,CAAA;IACpC,uGAAoC,CAAA;AACtC,CAAC,EAPW,+BAA+B,+CAA/B,+BAA+B,QAO1C;AAWD,6CAA6C;AAC7C,IAAY,0CAOX;AAPD,WAAY,0CAA0C;IACpD,2HAAsB,CAAA;IACtB,yHAAyB,CAAA;IACzB,wHAA6B,CAAA;IAC7B,2HAAkC,CAAA;IAClC,8HAAoC,CAAA;IACpC,6HAAoC,CAAA;AACtC,CAAC,EAPW,0CAA0C,0DAA1C,0CAA0C,QAOrD;AA6BD,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,6GAAsB,CAAA;IACtB,2GAAyB,CAAA;IACzB,0GAA6B,CAAA;IAC7B,6GAAkC,CAAA;IAClC,gHAAoC,CAAA;IACpC,+GAAoC,CAAA;AACtC,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED,gCAAgC;AAChC,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACvC,iGAAsB,CAAA;IACtB,+FAAyB,CAAA;IACzB,8FAA6B,CAAA;IAC7B,iGAAkC,CAAA;IAClC,oGAAoC,CAAA;IACpC,mGAAoC,CAAA;AACtC,CAAC,EAPW,6BAA6B,6CAA7B,6BAA6B,QAOxC;AA4YD,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,0CAAsB,CAAA;IACtB,8CAA0B,CAAA;IAC1B,6CAAyB,CAAA;IACzB,sCAAkB,CAAA;IAClB,yCAAqB,CAAA;IACrB,oCAAgB,CAAA;AAClB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAgDD,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;IACvB,4CAAqB,CAAA;AACvB,CAAC,EALW,mBAAmB,mCAAnB,mBAAmB,QAK9B","sourcesContent":["export type Address = Lowercase<string>;\nexport type TokenName = Uppercase<string>;\n\n// -- Markets --\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n fundingRateAnnualized: number;\n description: string;\n orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n minOrderSize: number;\n minOrderSizeBase: number;\n baseSpacing: number;\n};\n\nexport enum ReyaChainId {\n reyaNetwork = 1729,\n reyaCronos = 89346161,\n}\n\nexport enum MoneyInOutChainId {\n // mainnet\n ethereumMainnet = 1,\n opMainnet = 10,\n polygonMainnet = 137,\n arbitrumOne = 42161,\n baseMainnet = 8453,\n // testnet\n polygonMumbai = 80001,\n arbitrumSepolia = 421614,\n opSepolia = 11155420,\n ethereumSepolia = 11155111,\n}\n\nexport enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n id: string;\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n}\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'long' | 'short';\n\nexport type CollateralEntity = {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n exchangeRate: number;\n exchangeRateChange24HPercentage: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n marginRatioHealthDangerThreshold: number;\n marginRatioHealthWarningThreshold: number;\n isApproachingLiquidation: boolean;\n isLiquidationImminent: boolean;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n totalBalanceChange24HPercentage: number;\n livePnL: number;\n livePnLUnderlyingAsset: string;\n realizedPnL: number;\n realizedPnLUnderlyingAsset: string;\n realizedPnlHistoryTotal: number;\n totalPositionsCount: number;\n collaterals: CollateralEntity[];\n positions: PositionEntity[];\n};\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n stopLossPrice?: number;\n markPrice: number;\n orderStatus: Status;\n realisedPnl: number;\n unrealisedPnl: number;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n account: {\n name: MarginAccountEntity['name'];\n id: MarginAccountEntity['id'];\n };\n tradeXpBoost: number;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n base: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n xpEarned: number;\n};\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n apyChange24H: number;\n tokenAddress: Address;\n token: string;\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferFromMAToPoolAmount: number;\n minTransferFromPoolToMAAmount: number;\n stepSize: number;\n allowedChainsForLiquidity: MoneyInOutChainId[];\n moneyInOutConfiguration: MoneyInOutConfiguration;\n};\n\nexport type MoneyInOutConfiguration = {\n [key in MoneyInOutChainId]?: {\n minWithdrawAmount?: number;\n };\n};\n\nexport type MoneyInOutConfigurationPerTokenName = {\n [key in TokenName]?: MoneyInOutConfiguration;\n};\n\nexport type LpWithdrawBalanceEntity = {\n withdrawableBalance: number;\n poolSharePrice: number;\n accountShareBalance: number;\n};\n\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n timestamp: number;\n};\n\nexport type LpPositionEntity = {\n id: number;\n capitalInvested: number;\n currentBalance: number;\n pnl: number;\n lpPool: LpPoolEntity;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionStatus = 'confirmed' | 'pending';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n status: MarginAccountTransactionStatus;\n timestamp: number;\n};\n\nexport type TokenEntity = {\n name: TokenName;\n address: Address;\n};\n// --- Lp Pool Balance ---\nexport enum LpBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport type SocketTokenConnectors = {\n deposit: Address;\n withdraw: Address;\n};\n\nexport type GetSocketConnectorsParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n};\n\nexport type GetSocketVaultParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n};\n\nexport type GetMoneyInOutChainIdFromReyaConnectorParams = {\n reyaChainId: ReyaChainId;\n tokenName: TokenName;\n socketConnector: Address;\n};\n\nexport type GetSocketBridgeTimeParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketBridgeTimeResult = {\n bridgeTimeInMS: number;\n};\n\nexport type SocketDepositFeesEntry = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n fees: bigint;\n};\n\nexport type SocketWithdrawFeesEntry = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n fees: bigint;\n};\n\nexport type SocketDepositFees = {\n fees: bigint;\n feesInUnderlyingToken: number;\n underlyingTokenName: TokenName;\n};\n\nexport type SocketWithdrawFees = {\n fees: bigint;\n feesInUnderlyingToken: number;\n underlyingTokenName: TokenName;\n};\n\nexport type GetSocketWithdrawFeesParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetSocketWithdrawFeesResult = {\n fees: number;\n};\n\n// --- Margin Account Balance ---\nexport enum MarginAccountBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\n// --- Margin Account Collaterals Balance ---\nexport enum MarginAccountCollateralsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountCollateralsBalanceChartDataResult = {\n data: {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n token: string;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport type OwnerMetadataEntity = {\n address: Address;\n coreSigNonce: number;\n poolSigNonce: number;\n};\n\nexport type GetAllMarginAccountsBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport enum AllMarginAccountsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\n// --- Funding Rate History ----\nexport enum FundingRateHistoryGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetFundingRateChartDataResult = {\n fundingRateData: {\n timestampInMs: number;\n value: number;\n }[];\n fundingRate: number;\n};\n\nexport type GetBalancesForBridgeArgs = {\n walletAddress: string;\n};\n\nexport type DepthSimulationState = {\n spotPrice: number;\n maxOrderSizeLong: number;\n maxOrderSizeShort: number;\n netExposure: number;\n};\n\nexport type GetLpPoolDepthChartSimulationDataResult = DepthSimulationState;\n\nexport type SignatureData = {\n signature: string;\n timestamp: number;\n walletAddress: Address;\n version: string;\n};\n\nexport type SaveSignatureResult = {\n signatureSavedSuccessfully: boolean;\n};\n\n// --- Community ----\nexport type VoteDetailsEntity = {\n id: number;\n startDate: number; // timestamp in UTC milliseconds\n endDate: number; // timestamp in UTC milliseconds\n percentageToPass: number; // Example: 4%\n yesCount: number;\n noCount: number;\n voteCountToPass: number; // Example: 1453\n slug: string;\n title: string;\n // Free text, each newline represents paragraph. UI splits by \\n atm to keep stuff simple\n description: string;\n};\n\nexport type VoteContractDetailsEntity = {\n id: number;\n contractAddress: Address;\n};\n\nexport type VoteStatusEntity = {\n votingPower: number;\n hasVoted: boolean;\n};\n\n// --- XP ----\nexport type XPEntity = {\n value: number;\n valueTimestampMilliseconds: number;\n rate: number;\n};\n\nexport type GetAccountLGEStatusParams = {\n address: string; // wallet address\n};\n\nexport type GetAccountLGEStatusResult = {\n xp: XPEntity;\n currentBoost: number;\n deposited: number;\n // TODO: deprecate once UI and API are released\n currentTVL: number;\n // TODO: deprecate once UI and API are released\n currentLiquidity: number;\n};\n\nexport type GetAccountTradingXPParams = {\n address: string; // wallet address\n};\n\nexport type GetAccountTradingXPResult = {\n xp: XPEntity;\n currentBoost: number;\n openBase: number;\n};\n\nexport type GetLGEBoostRateParams = void;\n\nexport type GetLGEBoostRateResult = {\n boostRate: number;\n // 0 - 100\n boostRateProgressPercentage: number;\n};\n\nexport type GetLpTvlResult = {\n currentTVL: number;\n currentLiquidity: number;\n};\n\nexport type LeaderboardEntity = {\n address: string;\n currentBoost: number;\n liquidityXp: number;\n // current rank for user (fish, whale, shrimp)\n rank: number;\n // leaderboard ranking 1,2,3...1230,...\n ranking: number;\n tradingXp: number;\n referralXp: number;\n // TODO: XP-V4 add logic for this field\n rebalancingXp: number;\n voltzXp: number;\n totalXp: XPEntity;\n};\n\nexport type Rank = {\n rankNumber: number;\n rankLetter: string;\n rankName: string;\n};\n\nexport type LeaderboardEntityV2 = {\n address: string;\n currentBoost: number;\n liquidityXp: number;\n // current rank for user (fish, whale, shrimp)\n rank: Rank;\n promotion: 'rankUp' | 'rankDown' | 'stale';\n // leaderboard ranking 1,2,3...1230,...\n ranking: number;\n tradingXp: number;\n referralXp: number;\n // TODO: XP-V4 add logic for this field\n rebalancingXp: number;\n voltzXp: number;\n totalXp: XPEntity;\n weeklyXp: number;\n weeklyXpEntity: XPEntity;\n};\n\nexport type UserLeaderboardDataEntity = LeaderboardEntity & {\n claimedRank: number;\n currentRankPoints: number;\n nextRankPoints: number;\n nftStatus: 'collected' | 'notCollected' | 'burnt' | 'minted' | null;\n};\n\n// TODO: XP-V4 verify type\nexport type TrancheEntity = {\n value: number;\n boost: number;\n loyaltyBoost?: number;\n};\n\nexport type UserLeaderboardDataV2Entity = LeaderboardEntityV2 & {\n claimedRank: number;\n currentRankPoints: number;\n nextRankPoints: number;\n totalNfts: number;\n claimedNfts: number;\n nftStatus: 'collected' | 'notCollected' | 'burnt' | 'minted' | null;\n timeUntilRankingEvent: number;\n openInterest: number;\n deposit: number;\n lgeBoost: number;\n extraBoost: number;\n tradingBoost: number;\n // TODO: XP-V4 add logic for this field\n tranches: TrancheEntity[];\n // TODO: XP-V4 add logic for this field\n xpPerHour: number;\n};\n\nexport type GetLeaderboardParams = {\n page: number;\n perPage: number;\n};\n\nexport type GetLeaderboardByRankParams = GetLeaderboardParams & {\n rankNumber: number;\n};\n\nexport type GetLeaderboardResult = {\n data: LeaderboardEntity[];\n updateTimestampMilliseconds: number;\n totalCount: number;\n};\n\nexport type GetLeaderboardByRankResult = {\n data: LeaderboardEntityV2[];\n updateTimestampMilliseconds: number;\n totalCount: number;\n};\n\nexport type ClaimRankParams = {\n address: string;\n};\n\nexport type ClaimRankResult = {\n success: boolean;\n};\n\nexport type GetUserLeaderboardDataParams = {\n address: string;\n};\n\nexport type GetUserLeaderboardDataV2Params = GetUserLeaderboardDataParams;\n\nexport type GetUserLeaderboardDataResult = UserLeaderboardDataEntity;\n\nexport type GetUserLeaderboardDataV2Result = UserLeaderboardDataV2Entity;\n\nexport type GetUserGameStatusParams = { address: string };\n\nexport type GetSeasonOGSnapshotParams = { address: string };\n\nexport type GetUserGameStatusResult = {\n bodyId: string;\n status: 'notStarted' | 'notLockedIn' | 'lockedIn' | 'expired';\n boostRate: number;\n nextBoostStartTimestampMilliseconds: number;\n};\n\nexport type GetSeasonOGSnapshotResult = {\n overallPosition: number;\n totalXp: number;\n rank: Rank;\n};\n\nexport type GenerateGameBoostRateParams = { address: string; bodyId: string };\n\nexport type GenerateGameBoostRateResult = { boostRate: number };\n\nexport type LockGameBoostRateParams = { address: string };\n\nexport type LockGameBoostRateResult = void;\n\nexport type GetWalletReferralDetailsParams = {\n address: string;\n};\n\nexport type GetWalletReferralDetailsResult = {\n totalReferralsCount: number;\n totalReferralXP: number;\n};\n\nexport type GetWalletReferralCodeParams = {\n address: string;\n};\n\nexport type GetWalletReferralCodeResult = {\n referralCode: string;\n};\n\nexport type GetLockGameBoostTwitterUrlParams = {\n lockedInBoost: number;\n referralURL: string;\n};\n\nexport type GetLockGameBoostTwitterUrlResult = {\n tweetURL: string;\n};\n\nexport type GetReferralTwitterUrlParams = {\n referralURL: string;\n};\n\nexport type GetReferralTwitterUrlResult = {\n tweetURL: string;\n};\n\nexport type GetTradingRandomBoostParams = {\n address: string;\n marketId: number;\n};\n\nexport type GetTradingRandomBoostResult = {\n boost: number;\n};\n\nexport type GetUserTradingXpParams = {\n address: string;\n};\n\nexport type TokenEntityWithMinValue = TokenEntity & {\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferAmount: number;\n};\n\nexport type TokenInfo = {\n name: TokenName;\n address: Address;\n decimals: number;\n isRUSDUnderlying: boolean;\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferAmount: number;\n whitelistedWalletOnly?: boolean;\n};\n\n// --- TOS ----\n\nexport type TRMRiskAssessment = {\n accountExternalId: string;\n address: string;\n addressRiskIndicators: TMRRiskIndicator[];\n addressSubmitted: string;\n chain: string;\n entities: unknown[];\n trmAppUrl: string;\n};\n\nexport type TMRRiskIndicator = {\n category: string;\n categoryId: string;\n categoryRiskScoreLevel: number;\n categoryRiskScoreLevelLabel: string;\n incomingVolumeUsd: string;\n outgoingVolumeUsd: string;\n riskType: string;\n totalVolumeUsd: string;\n};\n\n// todo: deprecate after 1st tac client is deprecated\nexport type ToSVersionDetails = {\n text: string;\n version: string;\n creationTimestamp: number; // in MS\n};\n\nexport type ToSProductVersionDetails = {\n shortText: string;\n longText: string;\n version: string;\n creationTimestamp: number; // in MS\n product: string;\n};\n\nexport type SocketBridgeTransactionPoolStatus =\n | 'pending'\n | 'confirmed'\n | 'failed';\n\nexport type IpInfo = {\n ip: string;\n hostname: string;\n city: string;\n region: string;\n country: string;\n loc: string;\n org: string;\n postal: string;\n timezone: string;\n privacy: {\n vpn: boolean;\n proxy: boolean;\n tor: boolean;\n relay: boolean;\n hosting: boolean;\n service: string;\n };\n countryCode: string;\n countryFlag: {\n emoji: string;\n unicode: string;\n };\n countryFlagURL: string;\n countryCurrency: {\n code: string;\n symbol: string;\n };\n continent: {\n code: string;\n name: string;\n };\n isEU: boolean;\n};\n\nexport interface CandleMessage {\n /** Stringified JSON object of all events to be streamed. */\n contents: string;\n /** Clob pair id of the Candle message. */\n\n clobPairId: string;\n /** Resolution of the candle update. */\n\n resolution: string;\n /** Version of the websocket message. */\n\n version: string;\n}\n\nexport enum CandleResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\nexport type TransactionExecutionMetadata = {\n accountName?: string;\n accountId?: number;\n marketId?: number;\n destinationType?: 'pool' | 'account';\n action?: 'matchOrder' | 'closeOrder';\n};\n\nexport type TransactionExecutionOutput = {\n txHash: string;\n accountId?: string | null;\n coreSigNonce?: string | null;\n poolSigNonce?: string | null;\n miscellaneous?: {\n tradeXpBoost?: number;\n xpNftAwarded?: boolean;\n xpEarned?: number;\n };\n tradeDetails?: {\n executionPrice?: number;\n base?: number;\n };\n};\n\nexport type BurnNFTParams = {\n address: string;\n};\n\n// TODO: please fix implementation - we don't need boolean, void is fine\nexport type BurnNFTResult = boolean;\n\nexport type CanonicalReleaseStatus = 'pending' | 'ready' | 'completed';\n\ntype PendingWithdrawalStatus = {\n status: 'pending';\n};\n\ntype ReadyWithdrawalStatus = {\n status: 'ready';\n txHash: string;\n};\n\nexport type PendingWithdrawal = {\n tokenAmount: number;\n} & (PendingWithdrawalStatus | ReadyWithdrawalStatus);\n\nexport enum StopLossOrderStatus {\n NEW = 'new',\n FILLED = 'filled',\n CANCELLED = 'cancelled',\n REJECTED = 'rejected',\n}\n\nexport type StopLossOrder = {\n orderId: number;\n accountId: number;\n marketId: number;\n isLong: boolean;\n stopPrice: number;\n signerWallet: string;\n nonce: number;\n signature: string;\n status: StopLossOrderStatus;\n timestampMs: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["types.ts"],"names":[],"mappings":";;;AA+BA,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,8DAAkB,CAAA;IAClB,gEAAqB,CAAA;AACvB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAED,IAAY,iBAYX;AAZD,WAAY,iBAAiB;IAC3B,UAAU;IACV,+EAAmB,CAAA;IACnB,oEAAc,CAAA;IACd,+EAAoB,CAAA;IACpB,2EAAmB,CAAA;IACnB,0EAAkB,CAAA;IAClB,UAAU;IACV,+EAAqB,CAAA;IACrB,oFAAwB,CAAA;IACxB,0EAAoB,CAAA;IACpB,sFAA0B,CAAA;AAC5B,CAAC,EAZW,iBAAiB,iCAAjB,iBAAiB,QAY5B;AAED,IAAY,iBAQX;AARD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,2CAAsB,CAAA;IACtB,+CAA0B,CAAA;IAC1B,8CAAyB,CAAA;IACzB,uCAAkB,CAAA;IAClB,0CAAqB,CAAA;IACrB,qCAAgB,CAAA;AAClB,CAAC,EARW,iBAAiB,iCAAjB,iBAAiB,QAQ5B;AA4LD,0BAA0B;AAC1B,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,+EAAsB,CAAA;IACtB,6EAAyB,CAAA;IACzB,4EAA6B,CAAA;IAC7B,+EAAkC,CAAA;IAClC,kFAAoC,CAAA;IACpC,iFAAoC,CAAA;AACtC,CAAC,EAPW,oBAAoB,oCAApB,oBAAoB,QAO/B;AA0FD,iCAAiC;AACjC,IAAY,+BAOX;AAPD,WAAY,+BAA+B;IACzC,qGAAsB,CAAA;IACtB,mGAAyB,CAAA;IACzB,kGAA6B,CAAA;IAC7B,qGAAkC,CAAA;IAClC,wGAAoC,CAAA;IACpC,uGAAoC,CAAA;AACtC,CAAC,EAPW,+BAA+B,+CAA/B,+BAA+B,QAO1C;AAWD,6CAA6C;AAC7C,IAAY,0CAOX;AAPD,WAAY,0CAA0C;IACpD,2HAAsB,CAAA;IACtB,yHAAyB,CAAA;IACzB,wHAA6B,CAAA;IAC7B,2HAAkC,CAAA;IAClC,8HAAoC,CAAA;IACpC,6HAAoC,CAAA;AACtC,CAAC,EAPW,0CAA0C,0DAA1C,0CAA0C,QAOrD;AA6BD,IAAY,mCAOX;AAPD,WAAY,mCAAmC;IAC7C,6GAAsB,CAAA;IACtB,2GAAyB,CAAA;IACzB,0GAA6B,CAAA;IAC7B,6GAAkC,CAAA;IAClC,gHAAoC,CAAA;IACpC,+GAAoC,CAAA;AACtC,CAAC,EAPW,mCAAmC,mDAAnC,mCAAmC,QAO9C;AAED,gCAAgC;AAChC,IAAY,6BAOX;AAPD,WAAY,6BAA6B;IACvC,iGAAsB,CAAA;IACtB,+FAAyB,CAAA;IACzB,8FAA6B,CAAA;IAC7B,iGAAkC,CAAA;IAClC,oGAAoC,CAAA;IACpC,mGAAoC,CAAA;AACtC,CAAC,EAPW,6BAA6B,6CAA7B,6BAA6B,QAOxC;AA4YD,IAAY,gBAQX;AARD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,0CAAsB,CAAA;IACtB,8CAA0B,CAAA;IAC1B,6CAAyB,CAAA;IACzB,sCAAkB,CAAA;IAClB,yCAAqB,CAAA;IACrB,oCAAgB,CAAA;AAClB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAgDD,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC9B,yEAAa,CAAA;AACf,CAAC,EAFW,oBAAoB,oCAApB,oBAAoB,QAE/B;AAED,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,wCAAiB,CAAA;IACjB,8CAAuB,CAAA;IACvB,4CAAqB,CAAA;AACvB,CAAC,EALW,mBAAmB,mCAAnB,mBAAmB,QAK9B","sourcesContent":["export type Address = Lowercase<string>;\nexport type TokenName = Uppercase<string>;\n\n// -- Markets --\nexport type MarketOrderInfo = {\n counterpartyAccountIds: number[];\n exchangeId: number;\n};\n\nexport type MarketEntity = {\n id: number;\n ticker: string;\n underlyingAsset: string;\n quoteToken: string;\n markPrice: number;\n isActive: boolean;\n maxLeverage: number;\n volume24H: number;\n priceChange24H: number;\n priceChange24HPercentage: number;\n openInterest: number;\n fundingRate: number;\n fundingRateAnnualized: number;\n description: string;\n orderInfo: MarketOrderInfo;\n tickSizeDecimals: number;\n minOrderSize: number;\n minOrderSizeBase: number;\n baseSpacing: number;\n};\n\nexport enum ReyaChainId {\n reyaNetwork = 1729,\n reyaCronos = 89346161,\n}\n\nexport enum MoneyInOutChainId {\n // mainnet\n ethereumMainnet = 1,\n opMainnet = 10,\n polygonMainnet = 137,\n arbitrumOne = 42161,\n baseMainnet = 8453,\n // testnet\n polygonMumbai = 80001,\n arbitrumSepolia = 421614,\n opSepolia = 11155420,\n ethereumSepolia = 11155111,\n}\n\nexport enum CandlesResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\n// -- Candles --\nexport interface Candle {\n id: string;\n startedAt: string;\n ticker: string;\n resolution: CandlesResolution;\n low: string;\n high: string;\n open: string;\n close: string;\n baseTokenVolume: string;\n usdVolume: string;\n trades: number;\n startingOpenInterest: string;\n}\n\n// -- Account --\n\nexport type Status = 'OPEN' | 'CLOSED' | 'LIQUIDATED' | 'FILLED';\nexport type Side = 'long' | 'short';\n\nexport type CollateralEntity = {\n token: string;\n percentage: number;\n balance: number;\n balanceRUSD: number;\n exchangeRate: number;\n exchangeRateChange24HPercentage: number;\n};\n\nexport type MarginAccountEntity = {\n id: number;\n name: string;\n marginRatioHealth: 'danger' | 'healthy' | 'warning';\n marginRatioPercentage: number;\n marginRatioHealthDangerThreshold: number;\n marginRatioHealthWarningThreshold: number;\n isApproachingLiquidation: boolean;\n isLiquidationImminent: boolean;\n totalBalance: number;\n totalBalanceUnderlyingAsset: string;\n totalBalanceChange24HPercentage: number;\n livePnL: number;\n livePnLUnderlyingAsset: string;\n realizedPnL: number;\n realizedPnLUnderlyingAsset: string;\n realizedPnlHistoryTotal: number;\n totalPositionsCount: number;\n collaterals: CollateralEntity[];\n positions: PositionEntity[];\n};\n\nexport type ConditionalOrdersInfo = {\n stopLoss?: {\n stopLossPrice: number;\n orderId: number;\n };\n};\n\nexport type PositionEntity = {\n id: number;\n side: Side;\n size: number;\n base: number;\n price: number;\n conditionalOrdersInfo?: ConditionalOrdersInfo;\n markPrice: number;\n orderStatus: Status;\n realisedPnl: number;\n unrealisedPnl: number;\n liquidationPrice: number;\n fundingRate: number;\n market: MarketEntity;\n account: {\n name: MarginAccountEntity['name'];\n id: MarginAccountEntity['id'];\n };\n tradeXpBoost: number;\n};\n\nexport type TradingHistoryEntity = {\n id: number;\n price: number;\n priceUnderlyingToken: string;\n size: number;\n sizeUnderlyingToken: string;\n timestampMillisecondsUTC: number;\n};\n\nexport type OrderType = 'market';\n\nexport type PositionHistoryType =\n | 'long-trade'\n | 'short-trade'\n | 'long-liquidation'\n | 'short-liquidation';\n\nexport type PositionHistoryEntity = {\n id: number;\n action: PositionHistoryType;\n orderType: OrderType;\n base: number;\n executionPrice: number;\n realisedPnl?: number | null;\n fees: number;\n timestamp: number;\n market: MarketEntity;\n xpEarned: number;\n};\n\nexport type LpPoolEntity = {\n id: number;\n name: string;\n description: string;\n longDescription: string;\n readMoreLink: string;\n currentAPY: number;\n apyChange24H: number;\n tokenAddress: Address;\n token: string;\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferFromMAToPoolAmount: number;\n minTransferFromPoolToMAAmount: number;\n stepSize: number;\n allowedChainsForLiquidity: MoneyInOutChainId[];\n moneyInOutConfiguration: MoneyInOutConfiguration;\n};\n\nexport type MoneyInOutConfiguration = {\n [key in MoneyInOutChainId]?: {\n minWithdrawAmount?: number;\n };\n};\n\nexport type MoneyInOutConfigurationPerTokenName = {\n [key in TokenName]?: MoneyInOutConfiguration;\n};\n\nexport type LpWithdrawBalanceEntity = {\n withdrawableBalance: number;\n poolSharePrice: number;\n accountShareBalance: number;\n};\n\nexport type TransactionHistoryType = 'deposit' | 'withdrawal';\n\nexport type LpTransactionHistoryEntity = {\n id: number;\n type: TransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n timestamp: number;\n};\n\nexport type LpPositionEntity = {\n id: number;\n capitalInvested: number;\n currentBalance: number;\n pnl: number;\n lpPool: LpPoolEntity;\n};\n\nexport type MarginAccountTransactionHistoryType =\n | 'deposit'\n | 'withdrawal'\n | 'transfer'\n | 'auto_exchange';\n\nexport type MarginAccountTransactionStatus = 'confirmed' | 'pending';\n\nexport type MarginAccountTransactionHistoryEntity = {\n id: number;\n type: MarginAccountTransactionHistoryType;\n token: string;\n amount: number;\n transactionLink: string;\n status: MarginAccountTransactionStatus;\n timestamp: number;\n};\n\nexport type TokenEntity = {\n name: TokenName;\n address: Address;\n};\n// --- Lp Pool Balance ---\nexport enum LpBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetLpPoolBalanceChartDataResult = {\n data: {\n timestampInMs: number;\n value: number;\n }[];\n tvl: number;\n tvlChangePercentage: number;\n apy: number;\n apyChangePercentage: number;\n};\n\n// - LP Account Performance -\nexport type GetLpPoolPerformanceChartDataResult = {\n capitalInvestedData: {\n timestampInMs: number;\n value: number;\n }[];\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n capitalInvested: number;\n capitalInvestedChangePercentage: number;\n};\n\nexport type SocketTokenConnectors = {\n deposit: Address;\n withdraw: Address;\n};\n\nexport type GetSocketConnectorsParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n};\n\nexport type GetSocketVaultParams = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n};\n\nexport type GetMoneyInOutChainIdFromReyaConnectorParams = {\n reyaChainId: ReyaChainId;\n tokenName: TokenName;\n socketConnector: Address;\n};\n\nexport type GetSocketBridgeTimeParams = {\n moneyInOutChainId: MoneyInOutChainId;\n};\n\nexport type GetSocketBridgeTimeResult = {\n bridgeTimeInMS: number;\n};\n\nexport type SocketDepositFeesEntry = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n fees: bigint;\n};\n\nexport type SocketWithdrawFeesEntry = {\n moneyInOutChainId: MoneyInOutChainId;\n tokenName: TokenName;\n fees: bigint;\n};\n\nexport type SocketDepositFees = {\n fees: bigint;\n feesInUnderlyingToken: number;\n underlyingTokenName: TokenName;\n};\n\nexport type SocketWithdrawFees = {\n fees: bigint;\n feesInUnderlyingToken: number;\n underlyingTokenName: TokenName;\n};\n\nexport type GetSocketWithdrawFeesParams = {\n reyaChainId: ReyaChainId;\n tokenAddress: TokenEntity['address'];\n};\n\nexport type GetSocketWithdrawFeesResult = {\n fees: number;\n};\n\n// --- Margin Account Balance ---\nexport enum MarginAccountBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\n// --- Margin Account Collaterals Balance ---\nexport enum MarginAccountCollateralsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\nexport type GetMarginAccountCollateralsBalanceChartDataResult = {\n data: {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n token: string;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport type OwnerMetadataEntity = {\n address: Address;\n coreSigNonce: number;\n poolSigNonce: number;\n};\n\nexport type GetAllMarginAccountsBalanceChartDataResult = {\n balanceData: {\n timestampInMs: number;\n value: number;\n }[];\n balance: number;\n balanceChangePercentage: number;\n};\n\nexport enum AllMarginAccountsBalanceGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\n\n// --- Funding Rate History ----\nexport enum FundingRateHistoryGranularity {\n ONE_MINUTE = 60 * 1000,\n ONE_HOUR = 60 * 60 * 1000,\n ONE_DAY = 24 * 60 * 60 * 1000,\n ONE_WEEK = 7 * 24 * 60 * 60 * 1000,\n ONE_MONTH = 30 * 24 * 60 * 60 * 1000,\n ONE_YEAR = 365 * 24 * 60 * 60 * 1000,\n}\nexport type GetFundingRateChartDataResult = {\n fundingRateData: {\n timestampInMs: number;\n value: number;\n }[];\n fundingRate: number;\n};\n\nexport type GetBalancesForBridgeArgs = {\n walletAddress: string;\n};\n\nexport type DepthSimulationState = {\n spotPrice: number;\n maxOrderSizeLong: number;\n maxOrderSizeShort: number;\n netExposure: number;\n};\n\nexport type GetLpPoolDepthChartSimulationDataResult = DepthSimulationState;\n\nexport type SignatureData = {\n signature: string;\n timestamp: number;\n walletAddress: Address;\n version: string;\n};\n\nexport type SaveSignatureResult = {\n signatureSavedSuccessfully: boolean;\n};\n\n// --- Community ----\nexport type VoteDetailsEntity = {\n id: number;\n startDate: number; // timestamp in UTC milliseconds\n endDate: number; // timestamp in UTC milliseconds\n percentageToPass: number; // Example: 4%\n yesCount: number;\n noCount: number;\n voteCountToPass: number; // Example: 1453\n slug: string;\n title: string;\n // Free text, each newline represents paragraph. UI splits by \\n atm to keep stuff simple\n description: string;\n};\n\nexport type VoteContractDetailsEntity = {\n id: number;\n contractAddress: Address;\n};\n\nexport type VoteStatusEntity = {\n votingPower: number;\n hasVoted: boolean;\n};\n\n// --- XP ----\nexport type XPEntity = {\n value: number;\n valueTimestampMilliseconds: number;\n rate: number;\n};\n\nexport type GetAccountLGEStatusParams = {\n address: string; // wallet address\n};\n\nexport type GetAccountLGEStatusResult = {\n xp: XPEntity;\n currentBoost: number;\n deposited: number;\n // TODO: deprecate once UI and API are released\n currentTVL: number;\n // TODO: deprecate once UI and API are released\n currentLiquidity: number;\n};\n\nexport type GetAccountTradingXPParams = {\n address: string; // wallet address\n};\n\nexport type GetAccountTradingXPResult = {\n xp: XPEntity;\n currentBoost: number;\n openBase: number;\n};\n\nexport type GetLGEBoostRateParams = void;\n\nexport type GetLGEBoostRateResult = {\n boostRate: number;\n // 0 - 100\n boostRateProgressPercentage: number;\n};\n\nexport type GetLpTvlResult = {\n currentTVL: number;\n currentLiquidity: number;\n};\n\nexport type LeaderboardEntity = {\n address: string;\n currentBoost: number;\n liquidityXp: number;\n // current rank for user (fish, whale, shrimp)\n rank: number;\n // leaderboard ranking 1,2,3...1230,...\n ranking: number;\n tradingXp: number;\n referralXp: number;\n // TODO: XP-V4 add logic for this field\n rebalancingXp: number;\n voltzXp: number;\n totalXp: XPEntity;\n};\n\nexport type Rank = {\n rankNumber: number;\n rankLetter: string;\n rankName: string;\n};\n\nexport type LeaderboardEntityV2 = {\n address: string;\n currentBoost: number;\n liquidityXp: number;\n // current rank for user (fish, whale, shrimp)\n rank: Rank;\n promotion: 'rankUp' | 'rankDown' | 'stale';\n // leaderboard ranking 1,2,3...1230,...\n ranking: number;\n tradingXp: number;\n referralXp: number;\n // TODO: XP-V4 add logic for this field\n rebalancingXp: number;\n voltzXp: number;\n totalXp: XPEntity;\n weeklyXp: number;\n weeklyXpEntity: XPEntity;\n};\n\nexport type UserLeaderboardDataEntity = LeaderboardEntity & {\n claimedRank: number;\n currentRankPoints: number;\n nextRankPoints: number;\n nftStatus: 'collected' | 'notCollected' | 'burnt' | 'minted' | null;\n};\n\n// TODO: XP-V4 verify type\nexport type TrancheEntity = {\n value: number;\n boost: number;\n loyaltyBoost?: number;\n};\n\nexport type UserLeaderboardDataV2Entity = LeaderboardEntityV2 & {\n claimedRank: number;\n currentRankPoints: number;\n nextRankPoints: number;\n totalNfts: number;\n claimedNfts: number;\n nftStatus: 'collected' | 'notCollected' | 'burnt' | 'minted' | null;\n timeUntilRankingEvent: number;\n openInterest: number;\n deposit: number;\n lgeBoost: number;\n extraBoost: number;\n tradingBoost: number;\n // TODO: XP-V4 add logic for this field\n tranches: TrancheEntity[];\n // TODO: XP-V4 add logic for this field\n xpPerHour: number;\n};\n\nexport type GetLeaderboardParams = {\n page: number;\n perPage: number;\n};\n\nexport type GetLeaderboardByRankParams = GetLeaderboardParams & {\n rankNumber: number;\n};\n\nexport type GetLeaderboardResult = {\n data: LeaderboardEntity[];\n updateTimestampMilliseconds: number;\n totalCount: number;\n};\n\nexport type GetLeaderboardByRankResult = {\n data: LeaderboardEntityV2[];\n updateTimestampMilliseconds: number;\n totalCount: number;\n};\n\nexport type ClaimRankParams = {\n address: string;\n};\n\nexport type ClaimRankResult = {\n success: boolean;\n};\n\nexport type GetUserLeaderboardDataParams = {\n address: string;\n};\n\nexport type GetUserLeaderboardDataV2Params = GetUserLeaderboardDataParams;\n\nexport type GetUserLeaderboardDataResult = UserLeaderboardDataEntity;\n\nexport type GetUserLeaderboardDataV2Result = UserLeaderboardDataV2Entity;\n\nexport type GetUserGameStatusParams = { address: string };\n\nexport type GetSeasonOGSnapshotParams = { address: string };\n\nexport type GetUserGameStatusResult = {\n bodyId: string;\n status: 'notStarted' | 'notLockedIn' | 'lockedIn' | 'expired';\n boostRate: number;\n nextBoostStartTimestampMilliseconds: number;\n};\n\nexport type GetSeasonOGSnapshotResult = {\n overallPosition: number;\n totalXp: number;\n rank: Rank;\n};\n\nexport type GenerateGameBoostRateParams = { address: string; bodyId: string };\n\nexport type GenerateGameBoostRateResult = { boostRate: number };\n\nexport type LockGameBoostRateParams = { address: string };\n\nexport type LockGameBoostRateResult = void;\n\nexport type GetWalletReferralDetailsParams = {\n address: string;\n};\n\nexport type GetWalletReferralDetailsResult = {\n totalReferralsCount: number;\n totalReferralXP: number;\n};\n\nexport type GetWalletReferralCodeParams = {\n address: string;\n};\n\nexport type GetWalletReferralCodeResult = {\n referralCode: string;\n};\n\nexport type GetLockGameBoostTwitterUrlParams = {\n lockedInBoost: number;\n referralURL: string;\n};\n\nexport type GetLockGameBoostTwitterUrlResult = {\n tweetURL: string;\n};\n\nexport type GetReferralTwitterUrlParams = {\n referralURL: string;\n};\n\nexport type GetReferralTwitterUrlResult = {\n tweetURL: string;\n};\n\nexport type GetTradingRandomBoostParams = {\n address: string;\n marketId: number;\n};\n\nexport type GetTradingRandomBoostResult = {\n boost: number;\n};\n\nexport type GetUserTradingXpParams = {\n address: string;\n};\n\nexport type TokenEntityWithMinValue = TokenEntity & {\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferAmount: number;\n};\n\nexport type TokenInfo = {\n name: TokenName;\n address: Address;\n decimals: number;\n isRUSDUnderlying: boolean;\n minDepositAmount: number;\n minWithdrawAmount: number;\n minTransferAmount: number;\n whitelistedWalletOnly?: boolean;\n};\n\n// --- TOS ----\n\nexport type TRMRiskAssessment = {\n accountExternalId: string;\n address: string;\n addressRiskIndicators: TMRRiskIndicator[];\n addressSubmitted: string;\n chain: string;\n entities: unknown[];\n trmAppUrl: string;\n};\n\nexport type TMRRiskIndicator = {\n category: string;\n categoryId: string;\n categoryRiskScoreLevel: number;\n categoryRiskScoreLevelLabel: string;\n incomingVolumeUsd: string;\n outgoingVolumeUsd: string;\n riskType: string;\n totalVolumeUsd: string;\n};\n\n// todo: deprecate after 1st tac client is deprecated\nexport type ToSVersionDetails = {\n text: string;\n version: string;\n creationTimestamp: number; // in MS\n};\n\nexport type ToSProductVersionDetails = {\n shortText: string;\n longText: string;\n version: string;\n creationTimestamp: number; // in MS\n product: string;\n};\n\nexport type SocketBridgeTransactionPoolStatus =\n | 'pending'\n | 'confirmed'\n | 'failed';\n\nexport type IpInfo = {\n ip: string;\n hostname: string;\n city: string;\n region: string;\n country: string;\n loc: string;\n org: string;\n postal: string;\n timezone: string;\n privacy: {\n vpn: boolean;\n proxy: boolean;\n tor: boolean;\n relay: boolean;\n hosting: boolean;\n service: string;\n };\n countryCode: string;\n countryFlag: {\n emoji: string;\n unicode: string;\n };\n countryFlagURL: string;\n countryCurrency: {\n code: string;\n symbol: string;\n };\n continent: {\n code: string;\n name: string;\n };\n isEU: boolean;\n};\n\nexport interface CandleMessage {\n /** Stringified JSON object of all events to be streamed. */\n contents: string;\n /** Clob pair id of the Candle message. */\n\n clobPairId: string;\n /** Resolution of the candle update. */\n\n resolution: string;\n /** Version of the websocket message. */\n\n version: string;\n}\n\nexport enum CandleResolution {\n ONE_MINUTE = '1MIN',\n FIVE_MINUTES = '5MINS',\n FIFTEEN_MINUTES = '15MINS',\n THIRTY_MINUTES = '30MINS',\n ONE_HOUR = '1HOUR',\n FOUR_HOURS = '4HOURS',\n ONE_DAY = '1DAY',\n}\n\nexport type TransactionExecutionMetadata = {\n accountName?: string;\n accountId?: number;\n marketId?: number;\n destinationType?: 'pool' | 'account';\n action?: 'matchOrder' | 'closeOrder';\n};\n\nexport type TransactionExecutionOutput = {\n txHash: string;\n accountId?: string | null;\n coreSigNonce?: string | null;\n poolSigNonce?: string | null;\n miscellaneous?: {\n tradeXpBoost?: number;\n xpNftAwarded?: boolean;\n xpEarned?: number;\n };\n tradeDetails?: {\n executionPrice?: number;\n base?: number;\n };\n};\n\nexport type BurnNFTParams = {\n address: string;\n};\n\n// TODO: please fix implementation - we don't need boolean, void is fine\nexport type BurnNFTResult = boolean;\n\nexport type CanonicalReleaseStatus = 'pending' | 'ready' | 'completed';\n\ntype PendingWithdrawalStatus = {\n status: 'pending';\n};\n\ntype ReadyWithdrawalStatus = {\n status: 'ready';\n txHash: string;\n};\n\nexport type PendingWithdrawal = {\n tokenAmount: number;\n} & (PendingWithdrawalStatus | ReadyWithdrawalStatus);\n\nexport enum ConditionalOrderType {\n STOP_LOSS = 0,\n}\n\nexport enum StopLossOrderStatus {\n PENDING = 'pending',\n FILLED = 'filled',\n CANCELLED = 'cancelled',\n REJECTED = 'rejected',\n}\n\nexport type StopLossOrder = {\n orderId: number;\n accountId: number;\n marketId: number;\n isLong: boolean;\n stopPrice: number;\n signerWallet: string;\n nonce: string;\n signature: string;\n status: StopLossOrderStatus;\n timestampMs: number;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/common",
|
|
3
|
-
"version": "0.155.
|
|
3
|
+
"version": "0.155.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
44
44
|
},
|
|
45
45
|
"packageManager": "pnpm@8.3.1",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "d588a7b45d04c349ac09d10aff233fbc15c0833e"
|
|
47
47
|
}
|
|
@@ -5595,6 +5595,56 @@
|
|
|
5595
5595
|
"type": "error",
|
|
5596
5596
|
"name": "NoCounterpartiesInMatchOrder",
|
|
5597
5597
|
"inputs": []
|
|
5598
|
+
},
|
|
5599
|
+
{
|
|
5600
|
+
"type": "function",
|
|
5601
|
+
"name": "grantAccountPermissionBySig",
|
|
5602
|
+
"inputs": [
|
|
5603
|
+
{
|
|
5604
|
+
"name": "accountId",
|
|
5605
|
+
"type": "uint128",
|
|
5606
|
+
"internalType": "uint128"
|
|
5607
|
+
},
|
|
5608
|
+
{
|
|
5609
|
+
"name": "permission",
|
|
5610
|
+
"type": "bytes32",
|
|
5611
|
+
"internalType": "bytes32"
|
|
5612
|
+
},
|
|
5613
|
+
{
|
|
5614
|
+
"name": "user",
|
|
5615
|
+
"type": "address",
|
|
5616
|
+
"internalType": "address"
|
|
5617
|
+
},
|
|
5618
|
+
{
|
|
5619
|
+
"name": "sig",
|
|
5620
|
+
"type": "tuple",
|
|
5621
|
+
"internalType": "struct EIP712Signature",
|
|
5622
|
+
"components": [
|
|
5623
|
+
{
|
|
5624
|
+
"name": "v",
|
|
5625
|
+
"type": "uint8",
|
|
5626
|
+
"internalType": "uint8"
|
|
5627
|
+
},
|
|
5628
|
+
{
|
|
5629
|
+
"name": "r",
|
|
5630
|
+
"type": "bytes32",
|
|
5631
|
+
"internalType": "bytes32"
|
|
5632
|
+
},
|
|
5633
|
+
{
|
|
5634
|
+
"name": "s",
|
|
5635
|
+
"type": "bytes32",
|
|
5636
|
+
"internalType": "bytes32"
|
|
5637
|
+
},
|
|
5638
|
+
{
|
|
5639
|
+
"name": "deadline",
|
|
5640
|
+
"type": "uint256",
|
|
5641
|
+
"internalType": "uint256"
|
|
5642
|
+
}
|
|
5643
|
+
]
|
|
5644
|
+
}
|
|
5645
|
+
],
|
|
5646
|
+
"outputs": [],
|
|
5647
|
+
"stateMutability": "nonpayable"
|
|
5598
5648
|
}
|
|
5599
5649
|
]
|
|
5600
5650
|
}
|
|
@@ -14,7 +14,8 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
14
14
|
'0x9afc30bed29d636e566fd9d7dd89d51773724be6',
|
|
15
15
|
[ContractType.PERIPHERY_PROXY]:
|
|
16
16
|
'0xa45d0566144956b6012d461ad509dad2bacacaaf',
|
|
17
|
-
[ContractType.CONDITIONAL_ORDERS_PROXY]:
|
|
17
|
+
[ContractType.CONDITIONAL_ORDERS_PROXY]:
|
|
18
|
+
'0x0000000000000000000000000000000000000000',
|
|
18
19
|
},
|
|
19
20
|
[ReyaChainId.reyaNetwork]: {
|
|
20
21
|
[ContractType.CORE_PROXY]: '0xa763b6a5e09378434406c003dae6487fbbdc1a80',
|
|
@@ -22,7 +23,8 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
|
|
|
22
23
|
'0xb4b77d6180cc14472a9a7bdff01cc2459368d413',
|
|
23
24
|
[ContractType.PERIPHERY_PROXY]:
|
|
24
25
|
'0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
|
|
25
|
-
[ContractType.CONDITIONAL_ORDERS_PROXY]:
|
|
26
|
+
[ContractType.CONDITIONAL_ORDERS_PROXY]:
|
|
27
|
+
'0x0000000000000000000000000000000000000000',
|
|
26
28
|
},
|
|
27
29
|
};
|
|
28
30
|
export const getAddress = (
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './action';
|
|
2
2
|
export { abi as CoreAbi } from './abis/CoreProxy.json';
|
|
3
3
|
export { abi as PeripheryAbi } from './abis/Periphery.json';
|
|
4
|
-
export { abi as ConditionalOrdersAbi } from './abis/ConditionalOrdersGateway.json';
|
|
5
4
|
export { abi as Socket_VaultWithPayloadAbi } from './abis/socket/VaultWithPayload.json';
|
|
6
5
|
export * from './contractAddresses';
|
|
7
6
|
export * from './routerCommands';
|
package/src/transactions/sign.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
JsonRpcSigner,
|
|
3
|
+
Signature,
|
|
4
|
+
Signer,
|
|
5
|
+
TypedDataField,
|
|
6
|
+
verifyTypedData,
|
|
7
|
+
} from 'ethers';
|
|
2
8
|
import { ContractType, getAddress } from './contractAddresses';
|
|
3
9
|
import { Command } from './action';
|
|
4
10
|
import { ethers } from 'ethers';
|
|
5
|
-
import { Address, ReyaChainId } from '../types';
|
|
11
|
+
import { Address, ReyaChainId, StopLossOrderStatus } from '../types';
|
|
6
12
|
|
|
7
13
|
export type EIP712Signature = {
|
|
8
14
|
v: number;
|
|
@@ -123,17 +129,39 @@ async function signReyaTypedData(
|
|
|
123
129
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
130
|
value: Record<string, any>,
|
|
125
131
|
): Promise<Signature> {
|
|
126
|
-
const domain =
|
|
127
|
-
name: 'Reya',
|
|
128
|
-
version: '1',
|
|
129
|
-
verifyingContract: verifyingContract,
|
|
130
|
-
};
|
|
132
|
+
const domain = getReyaDomain(verifyingContract);
|
|
131
133
|
|
|
132
134
|
const signatureString = await signer.signTypedData(domain, types, value);
|
|
133
135
|
|
|
134
136
|
return Signature.from(signatureString);
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
function getReyaDomain(verifyingContract: string) {
|
|
140
|
+
return {
|
|
141
|
+
name: 'Reya',
|
|
142
|
+
version: '1',
|
|
143
|
+
verifyingContract: verifyingContract,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const conditionalOrderTypes = {
|
|
148
|
+
ConditionalOrder: [
|
|
149
|
+
{ name: 'verifyingChainId', type: 'uint256' },
|
|
150
|
+
{ name: 'deadline', type: 'uint256' },
|
|
151
|
+
{ name: 'order', type: 'ConditionalOrderDetails' },
|
|
152
|
+
],
|
|
153
|
+
ConditionalOrderDetails: [
|
|
154
|
+
{ name: 'accountId', type: 'uint128' },
|
|
155
|
+
{ name: 'marketId', type: 'uint128' },
|
|
156
|
+
{ name: 'exchangeId', type: 'uint128' },
|
|
157
|
+
{ name: 'counterpartyAccountIds', type: 'uint128[]' },
|
|
158
|
+
{ name: 'orderType', type: 'uint8' },
|
|
159
|
+
{ name: 'inputs', type: 'bytes' },
|
|
160
|
+
{ name: 'signer', type: 'address' },
|
|
161
|
+
{ name: 'nonce', type: 'uint256' },
|
|
162
|
+
],
|
|
163
|
+
};
|
|
164
|
+
|
|
137
165
|
export async function signConditionalOrder(
|
|
138
166
|
signer: Signer | JsonRpcSigner,
|
|
139
167
|
reyaChainId: ReyaChainId,
|
|
@@ -143,38 +171,85 @@ export async function signConditionalOrder(
|
|
|
143
171
|
counterpartyAccountIds: number[],
|
|
144
172
|
orderType: number,
|
|
145
173
|
inputs: string,
|
|
146
|
-
nonce:
|
|
174
|
+
nonce: string,
|
|
147
175
|
deadline: number,
|
|
148
|
-
): Promise<
|
|
149
|
-
// todo: add deadline to encoded sig
|
|
176
|
+
): Promise<string> {
|
|
150
177
|
const signature = await signReyaTypedData(
|
|
151
178
|
signer,
|
|
152
179
|
getAddress(reyaChainId, ContractType.CONDITIONAL_ORDERS_PROXY),
|
|
180
|
+
conditionalOrderTypes,
|
|
153
181
|
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
182
|
+
verifyingChainId: reyaChainId,
|
|
183
|
+
deadline: BigInt(deadline),
|
|
184
|
+
order: {
|
|
185
|
+
accountId: accountId,
|
|
186
|
+
marketId: marketId,
|
|
187
|
+
exchangeId: exchangeId,
|
|
188
|
+
counterpartyAccountIds: counterpartyAccountIds,
|
|
189
|
+
orderType: orderType,
|
|
190
|
+
inputs: inputs,
|
|
191
|
+
signer: await signer.getAddress(),
|
|
192
|
+
nonce: BigInt(nonce),
|
|
193
|
+
},
|
|
164
194
|
},
|
|
165
|
-
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
return signature.serialized;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function isConditionalOrderSignatureValid(
|
|
201
|
+
signerAddress: string,
|
|
202
|
+
signature: string,
|
|
203
|
+
reyaChainId: ReyaChainId,
|
|
204
|
+
accountId: number,
|
|
205
|
+
marketId: number,
|
|
206
|
+
exchangeId: number,
|
|
207
|
+
counterpartyAccountIds: number[],
|
|
208
|
+
orderType: number,
|
|
209
|
+
inputs: string,
|
|
210
|
+
nonce: string,
|
|
211
|
+
deadline: number,
|
|
212
|
+
): boolean {
|
|
213
|
+
// Encode the data for recovering the address
|
|
214
|
+
const domain = getReyaDomain(
|
|
215
|
+
getAddress(reyaChainId, ContractType.CONDITIONAL_ORDERS_PROXY),
|
|
216
|
+
);
|
|
217
|
+
const value = {
|
|
218
|
+
verifyingChainId: reyaChainId,
|
|
219
|
+
deadline: BigInt(deadline),
|
|
220
|
+
order: {
|
|
166
221
|
accountId: accountId,
|
|
167
222
|
marketId: marketId,
|
|
168
223
|
exchangeId: exchangeId,
|
|
169
224
|
counterpartyAccountIds: counterpartyAccountIds,
|
|
170
225
|
orderType: orderType,
|
|
171
226
|
inputs: inputs,
|
|
172
|
-
signer:
|
|
173
|
-
nonce: nonce,
|
|
227
|
+
signer: signerAddress,
|
|
228
|
+
nonce: BigInt(nonce),
|
|
174
229
|
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Recover the address
|
|
233
|
+
const recoveredAddress = verifyTypedData(
|
|
234
|
+
domain,
|
|
235
|
+
conditionalOrderTypes,
|
|
236
|
+
value,
|
|
237
|
+
signature,
|
|
175
238
|
);
|
|
176
239
|
|
|
177
|
-
return
|
|
240
|
+
return recoveredAddress === signerAddress;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export async function signCancelConditionalOrder(
|
|
244
|
+
signer: Signer | JsonRpcSigner,
|
|
245
|
+
orderId: number,
|
|
246
|
+
): Promise<string> {
|
|
247
|
+
const message = {
|
|
248
|
+
orderId: orderId,
|
|
249
|
+
status: StopLossOrderStatus.CANCELLED,
|
|
250
|
+
actionType: 'changeStatus',
|
|
251
|
+
};
|
|
252
|
+
return await signer.signMessage(JSON.stringify(message));
|
|
178
253
|
}
|
|
179
254
|
|
|
180
255
|
export async function signGrantPermission(
|
|
@@ -192,7 +267,6 @@ export async function signGrantPermission(
|
|
|
192
267
|
{
|
|
193
268
|
GrantAccountPermissionBySig: [
|
|
194
269
|
{ name: 'verifyingChainId', type: 'uint256' },
|
|
195
|
-
{ name: 'caller', type: 'address' },
|
|
196
270
|
{ name: 'accountId', type: 'uint128' },
|
|
197
271
|
{ name: 'permission', type: 'bytes32' },
|
|
198
272
|
{ name: 'user', type: 'address' },
|
|
@@ -202,7 +276,6 @@ export async function signGrantPermission(
|
|
|
202
276
|
},
|
|
203
277
|
{
|
|
204
278
|
verifyingChainId: reyaChainId,
|
|
205
|
-
caller: await signer.getAddress(),
|
|
206
279
|
accountId: accountId,
|
|
207
280
|
permission: permission,
|
|
208
281
|
user: user,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { MaxUint256 } from 'ethers';
|
|
2
3
|
|
|
3
4
|
// todo: need the ability to supply custom slippage or use a more conservative default for the slippage tolerance
|
|
4
5
|
export function calculatePriceLimitForTrade(
|
|
@@ -23,3 +24,12 @@ export function calculatePriceLimitForTrade(
|
|
|
23
24
|
);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
27
|
+
|
|
28
|
+
export function calculateMaxPriceLimit(isLong: boolean): bigint {
|
|
29
|
+
// Determine if the amount is positive or negative and adjust the price accordingly
|
|
30
|
+
if (isLong) {
|
|
31
|
+
return MaxUint256;
|
|
32
|
+
} else {
|
|
33
|
+
return BigInt(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -110,13 +110,20 @@ export type MarginAccountEntity = {
|
|
|
110
110
|
positions: PositionEntity[];
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
export type ConditionalOrdersInfo = {
|
|
114
|
+
stopLoss?: {
|
|
115
|
+
stopLossPrice: number;
|
|
116
|
+
orderId: number;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
113
120
|
export type PositionEntity = {
|
|
114
121
|
id: number;
|
|
115
122
|
side: Side;
|
|
116
123
|
size: number;
|
|
117
124
|
base: number;
|
|
118
125
|
price: number;
|
|
119
|
-
|
|
126
|
+
conditionalOrdersInfo?: ConditionalOrdersInfo;
|
|
120
127
|
markPrice: number;
|
|
121
128
|
orderStatus: Status;
|
|
122
129
|
realisedPnl: number;
|
|
@@ -860,8 +867,12 @@ export type PendingWithdrawal = {
|
|
|
860
867
|
tokenAmount: number;
|
|
861
868
|
} & (PendingWithdrawalStatus | ReadyWithdrawalStatus);
|
|
862
869
|
|
|
870
|
+
export enum ConditionalOrderType {
|
|
871
|
+
STOP_LOSS = 0,
|
|
872
|
+
}
|
|
873
|
+
|
|
863
874
|
export enum StopLossOrderStatus {
|
|
864
|
-
|
|
875
|
+
PENDING = 'pending',
|
|
865
876
|
FILLED = 'filled',
|
|
866
877
|
CANCELLED = 'cancelled',
|
|
867
878
|
REJECTED = 'rejected',
|
|
@@ -874,7 +885,7 @@ export type StopLossOrder = {
|
|
|
874
885
|
isLong: boolean;
|
|
875
886
|
stopPrice: number;
|
|
876
887
|
signerWallet: string;
|
|
877
|
-
nonce:
|
|
888
|
+
nonce: string;
|
|
878
889
|
signature: string;
|
|
879
890
|
status: StopLossOrderStatus;
|
|
880
891
|
timestampMs: number;
|