@bluefin-exchange/pro-sdk 0.1.61 → 0.2.0-pre-release.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/dist/{example.js → cjs/example.js} +3 -0
- package/dist/cjs/example.js.map +1 -0
- package/dist/{index.js → cjs/index.js} +1 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/{src → cjs/src}/api.js +75 -1
- package/dist/cjs/src/api.js.map +1 -0
- package/dist/{src → cjs/src}/base.js +5 -1
- package/dist/cjs/src/base.js.map +1 -0
- package/dist/{src → cjs/src}/common.js +1 -0
- package/dist/cjs/src/common.js.map +1 -0
- package/dist/{src → cjs/src}/configuration.js +1 -0
- package/dist/cjs/src/configuration.js.map +1 -0
- package/dist/{src → cjs/src}/index.js +1 -0
- package/dist/cjs/src/index.js.map +1 -0
- package/dist/{src → cjs/src}/request-signer.js +11 -0
- package/dist/cjs/src/request-signer.js.map +1 -0
- package/dist/{src → cjs/src}/sdk.js +47 -4
- package/dist/cjs/src/sdk.js.map +1 -0
- package/dist/{src → cjs/src}/utils.js +1 -0
- package/dist/cjs/src/utils.js.map +1 -0
- package/dist/{src → cjs/src}/websocket.js +1 -0
- package/dist/cjs/src/websocket.js.map +1 -0
- package/dist/esm/example.js +218 -0
- package/dist/esm/example.js.map +1 -0
- package/dist/esm/index.js +18 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/src/api.js +4318 -0
- package/dist/esm/src/api.js.map +1 -0
- package/dist/esm/src/base.js +69 -0
- package/dist/esm/src/base.js.map +1 -0
- package/dist/esm/src/common.js +162 -0
- package/dist/esm/src/common.js.map +1 -0
- package/dist/esm/src/configuration.js +45 -0
- package/dist/esm/src/configuration.js.map +1 -0
- package/dist/esm/src/index.js +23 -0
- package/dist/esm/src/index.js.map +1 -0
- package/dist/esm/src/request-signer.js +231 -0
- package/dist/esm/src/request-signer.js.map +1 -0
- package/dist/esm/src/sdk.js +786 -0
- package/dist/esm/src/sdk.js.map +1 -0
- package/dist/esm/src/utils.js +10 -0
- package/dist/esm/src/utils.js.map +1 -0
- package/dist/esm/src/websocket.js +159 -0
- package/dist/esm/src/websocket.js.map +1 -0
- package/dist/types/example.d.ts +2 -0
- package/dist/types/example.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/{src → types/src}/api.d.ts +126 -47
- package/dist/types/src/api.d.ts.map +1 -0
- package/dist/{src → types/src}/base.d.ts +1 -0
- package/dist/types/src/base.d.ts.map +1 -0
- package/dist/{src → types/src}/common.d.ts +1 -0
- package/dist/types/src/common.d.ts.map +1 -0
- package/dist/{src → types/src}/configuration.d.ts +1 -0
- package/dist/types/src/configuration.d.ts.map +1 -0
- package/dist/{src → types/src}/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/{src → types/src}/request-signer.d.ts +6 -1
- package/dist/types/src/request-signer.d.ts.map +1 -0
- package/dist/{src → types/src}/sdk.d.ts +12 -1
- package/dist/types/src/sdk.d.ts.map +1 -0
- package/dist/{src → types/src}/utils.d.ts +1 -0
- package/dist/types/src/utils.d.ts.map +1 -0
- package/dist/{src → types/src}/websocket.d.ts +1 -0
- package/dist/types/src/websocket.d.ts.map +1 -0
- package/package.json +21 -7
- package/dist/example.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/example.ts +0 -323
- package/index.ts +0 -1
- package/openapitools.json +0 -24
- package/src/.openapi-generator/FILES +0 -128
- package/src/.openapi-generator/VERSION +0 -1
- package/src/.openapi-generator-ignore +0 -28
- package/src/README.md +0 -46
- package/src/api.ts +0 -8918
- package/src/base.ts +0 -86
- package/src/common.ts +0 -150
- package/src/configuration.ts +0 -115
- package/src/docs/Account.md +0 -64
- package/src/docs/AccountAggregatedTradeUpdate.md +0 -21
- package/src/docs/AccountAuthorizationRequest.md +0 -24
- package/src/docs/AccountAuthorizationRequestSignedFields.md +0 -28
- package/src/docs/AccountCommandFailureUpdate.md +0 -29
- package/src/docs/AccountDataApi.md +0 -374
- package/src/docs/AccountDataStream.md +0 -21
- package/src/docs/AccountEventReason.md +0 -25
- package/src/docs/AccountEventType.md +0 -21
- package/src/docs/AccountFundingRateHistory.md +0 -20
- package/src/docs/AccountFundingRateHistoryData.md +0 -30
- package/src/docs/AccountMarketPreference.md +0 -22
- package/src/docs/AccountOrderUpdate.md +0 -71
- package/src/docs/AccountPositionLeverageUpdateRequest.md +0 -22
- package/src/docs/AccountPositionLeverageUpdateRequestSignedFields.md +0 -30
- package/src/docs/AccountPositionUpdate.md +0 -47
- package/src/docs/AccountPreference.md +0 -24
- package/src/docs/AccountStreamMessage.md +0 -25
- package/src/docs/AccountStreamMessagePayload.md +0 -153
- package/src/docs/AccountSubscriptionMessage.md +0 -25
- package/src/docs/AccountTradeUpdate.md +0 -21
- package/src/docs/AccountTransactionUpdate.md +0 -31
- package/src/docs/AccountUpdate.md +0 -61
- package/src/docs/ActiveOrderUpdate.md +0 -65
- package/src/docs/AdjustIsolatedMarginRequest.md +0 -22
- package/src/docs/AdjustIsolatedMarginRequestSignedFields.md +0 -32
- package/src/docs/AdjustMarginOperation.md +0 -11
- package/src/docs/AffiliateIntervalOverview.md +0 -56
- package/src/docs/AffiliateLeaderDashboard.md +0 -38
- package/src/docs/AffiliateMetadata.md +0 -36
- package/src/docs/AffiliateMetadataFees.md +0 -31
- package/src/docs/AffiliateOnboardResponse.md +0 -22
- package/src/docs/AffiliateOverview.md +0 -46
- package/src/docs/AffiliateSummary.md +0 -30
- package/src/docs/Asset.md +0 -29
- package/src/docs/AssetConfig.md +0 -28
- package/src/docs/AuthApi.md +0 -243
- package/src/docs/AuthorizedWallet.md +0 -24
- package/src/docs/CampaignMetadata.md +0 -28
- package/src/docs/CampaignRewards.md +0 -18
- package/src/docs/CancelOrdersRequest.md +0 -23
- package/src/docs/CancelOrdersResponse.md +0 -21
- package/src/docs/CandlePriceType.md +0 -14
- package/src/docs/CandlestickUpdate.md +0 -41
- package/src/docs/CommandFailureReasonCode.md +0 -24
- package/src/docs/ContractsConfig.md +0 -31
- package/src/docs/CreateOrderRequest.md +0 -36
- package/src/docs/CreateOrderRequestSignedFields.md +0 -40
- package/src/docs/CreateOrderResponse.md +0 -20
- package/src/docs/EpochConfigs.md +0 -34
- package/src/docs/EpochConfigsResponse.md +0 -24
- package/src/docs/EpochMetadata.md +0 -30
- package/src/docs/Error.md +0 -22
- package/src/docs/ExchangeApi.md +0 -473
- package/src/docs/ExchangeInfoResponse.md +0 -30
- package/src/docs/FailedCommandType.md +0 -12
- package/src/docs/FeeConfigs.md +0 -33
- package/src/docs/FundingRateEntry.md +0 -24
- package/src/docs/GetAffiliateIntervalOverview200Response.md +0 -26
- package/src/docs/GetAffiliateLeaderDashboard200Response.md +0 -26
- package/src/docs/GetAffiliateOverview200Response.md +0 -26
- package/src/docs/IntervalMetadata.md +0 -28
- package/src/docs/IntervalRewards.md +0 -30
- package/src/docs/KlineInterval.md +0 -36
- package/src/docs/LoginRequest.md +0 -25
- package/src/docs/LoginResponse.md +0 -26
- package/src/docs/MarginType.md +0 -13
- package/src/docs/MarkPriceUpdate.md +0 -26
- package/src/docs/Market.md +0 -82
- package/src/docs/MarketDataStreamName.md +0 -142
- package/src/docs/MarketEventType.md +0 -25
- package/src/docs/MarketPriceUpdate.md +0 -26
- package/src/docs/MarketStatus.md +0 -16
- package/src/docs/MarketStreamMessage.md +0 -23
- package/src/docs/MarketStreamMessagePayload.md +0 -123
- package/src/docs/MarketSubscriptionMessage.md +0 -23
- package/src/docs/MarketSubscriptionStreams.md +0 -23
- package/src/docs/OnboardAffiliateRequest.md +0 -26
- package/src/docs/OnboardAffiliateRequestSocialUserNames.md +0 -27
- package/src/docs/OnboardRefereeRequest.md +0 -20
- package/src/docs/OpenOrderResponse.md +0 -64
- package/src/docs/Operators.md +0 -28
- package/src/docs/OraclePriceUpdate.md +0 -26
- package/src/docs/OrderCancelReason.md +0 -65
- package/src/docs/OrderCancellationFailureReason.md +0 -19
- package/src/docs/OrderCancellationUpdate.md +0 -35
- package/src/docs/OrderSide.md +0 -13
- package/src/docs/OrderStatus.md +0 -25
- package/src/docs/OrderTimeInForce.md +0 -15
- package/src/docs/OrderType.md +0 -29
- package/src/docs/OrderbookDepthResponse.md +0 -38
- package/src/docs/OrderbookDiffDepthUpdate.md +0 -30
- package/src/docs/OrderbookPartialDepthUpdate.md +0 -30
- package/src/docs/Position.md +0 -52
- package/src/docs/PositionSide.md +0 -13
- package/src/docs/RecentTradesUpdates.md +0 -20
- package/src/docs/RefereeOnboardResponse.md +0 -20
- package/src/docs/RefreshTokenRequest.md +0 -20
- package/src/docs/RefreshTokenResponse.md +0 -26
- package/src/docs/RewardsApi.md +0 -859
- package/src/docs/RewardsSummary.md +0 -26
- package/src/docs/SelfTradePreventionType.md +0 -15
- package/src/docs/StatsEntry.md +0 -26
- package/src/docs/StatsInterval.md +0 -14
- package/src/docs/StatsResponse.md +0 -20
- package/src/docs/StreamsApi.md +0 -126
- package/src/docs/SubscriptionResponseMessage.md +0 -23
- package/src/docs/SubscriptionType.md +0 -11
- package/src/docs/TickerAllUpdate.md +0 -20
- package/src/docs/TickerResponse.md +0 -82
- package/src/docs/TickerUpdate.md +0 -83
- package/src/docs/Trade.md +0 -54
- package/src/docs/TradeApi.md +0 -589
- package/src/docs/TradeSide.md +0 -13
- package/src/docs/TradeType.md +0 -15
- package/src/docs/TradingFees.md +0 -24
- package/src/docs/Transaction.md +0 -34
- package/src/docs/TransactionType.md +0 -25
- package/src/docs/UpdateAccountPreferenceRequest.md +0 -24
- package/src/docs/UpdateAffiliateFeeConfigRequest.md +0 -20
- package/src/docs/UserCampaignRewards.md +0 -48
- package/src/docs/WithdrawRequest.md +0 -22
- package/src/docs/WithdrawRequestSignedFields.md +0 -30
- package/src/git_push.sh +0 -57
- package/src/index.ts +0 -6
- package/src/request-signer.ts +0 -405
- package/src/sdk.ts +0 -982
- package/src/utils.ts +0 -6
- package/src/websocket.ts +0 -165
- package/tsconfig.json +0 -23
package/example.ts
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountDataStream,
|
|
3
|
-
TradeType,
|
|
4
|
-
TransactionType,
|
|
5
|
-
KlineInterval,
|
|
6
|
-
CandlePriceType,
|
|
7
|
-
OrderType,
|
|
8
|
-
OrderSide,
|
|
9
|
-
MarketDataStreamName,
|
|
10
|
-
MarketStreamMessage,
|
|
11
|
-
MarketEventType,
|
|
12
|
-
AccountStreamMessage,
|
|
13
|
-
AccountEventType,
|
|
14
|
-
OrderTimeInForce,
|
|
15
|
-
OrderParams,
|
|
16
|
-
Market,
|
|
17
|
-
BluefinRequestSigner,
|
|
18
|
-
BluefinProSdk,
|
|
19
|
-
makeSigner,
|
|
20
|
-
} from "./index";
|
|
21
|
-
|
|
22
|
-
import { hexToBytes } from "@noble/hashes/utils";
|
|
23
|
-
import { SuiClient, Ed25519Keypair } from "@firefly-exchange/library-sui";
|
|
24
|
-
|
|
25
|
-
// Configure logging
|
|
26
|
-
const logger = {
|
|
27
|
-
info: (message: string) =>
|
|
28
|
-
console.log(new Date().toISOString(), "-", message),
|
|
29
|
-
error: (message: string) =>
|
|
30
|
-
console.error(new Date().toISOString(), "-", message),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// Handle market data stream events
|
|
34
|
-
async function handleMarketDataEvent(msg: MarketStreamMessage): Promise<void> {
|
|
35
|
-
if (msg.event == MarketEventType.OraclePriceUpdate) {
|
|
36
|
-
logger.info(`OraclePriceUpdate: ${JSON.stringify(msg)}`);
|
|
37
|
-
}
|
|
38
|
-
if (msg.event == MarketEventType.MarkPriceUpdate) {
|
|
39
|
-
logger.info(`MarkPriceUpdate: ${JSON.stringify(msg)}`);
|
|
40
|
-
}
|
|
41
|
-
if (msg.event == MarketEventType.MarketPriceUpdate) {
|
|
42
|
-
logger.info(`MarketPriceUpdate: ${JSON.stringify(msg)}`);
|
|
43
|
-
}
|
|
44
|
-
if (msg.event == MarketEventType.CandlestickUpdate) {
|
|
45
|
-
logger.info(`CandlestickUpdate: ${JSON.stringify(msg)}`);
|
|
46
|
-
}
|
|
47
|
-
if (msg.event == MarketEventType.OrderbookDiffDepthUpdate) {
|
|
48
|
-
logger.info(`OrderbookDiffDepthUpdate: ${JSON.stringify(msg)}`);
|
|
49
|
-
}
|
|
50
|
-
if (msg.event == MarketEventType.OrderbookPartialDepthUpdate) {
|
|
51
|
-
logger.info(`OrderbookPartialDepthUpdate: ${JSON.stringify(msg)}`);
|
|
52
|
-
}
|
|
53
|
-
if (msg.event == MarketEventType.RecentTradesUpdates) {
|
|
54
|
-
logger.info(`RecentTradesUpdates: ${JSON.stringify(msg)}`);
|
|
55
|
-
}
|
|
56
|
-
if (msg.event == MarketEventType.TickerAllUpdate) {
|
|
57
|
-
logger.info(`TickerAllUpdate: ${JSON.stringify(msg)}`);
|
|
58
|
-
}
|
|
59
|
-
if (msg.event == MarketEventType.TickerUpdate) {
|
|
60
|
-
logger.info(`TickerUpdate: ${JSON.stringify(msg)}`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Handle account data stream events
|
|
65
|
-
async function handleAccountDataEvent(
|
|
66
|
-
msg: AccountStreamMessage
|
|
67
|
-
): Promise<void> {
|
|
68
|
-
if (msg.event == AccountEventType.AccountUpdate) {
|
|
69
|
-
logger.info(`AccountUpdate: ${JSON.stringify(msg)}`);
|
|
70
|
-
}
|
|
71
|
-
if (msg.event == AccountEventType.AccountTradeUpdate) {
|
|
72
|
-
logger.info(`AccountTradeUpdate: ${JSON.stringify(msg)}`);
|
|
73
|
-
}
|
|
74
|
-
if (msg.event == AccountEventType.AccountPositionUpdate) {
|
|
75
|
-
logger.info(`AccountPositionUpdate: ${JSON.stringify(msg)}`);
|
|
76
|
-
}
|
|
77
|
-
if (msg.event == AccountEventType.AccountOrderUpdate) {
|
|
78
|
-
// if (msg.actual_instance instanceof ActiveOrderUpdate) {
|
|
79
|
-
// logger.info(`ActiveOrderUpdate: ${JSON.stringify(msg.actual_instance)}`);
|
|
80
|
-
// }
|
|
81
|
-
// if (msg.actual_instance instanceof OrderCancellationUpdate) {
|
|
82
|
-
// logger.info(
|
|
83
|
-
// `OrderCancellationUpdate: ${JSON.stringify(msg.actual_instance)}`
|
|
84
|
-
// );
|
|
85
|
-
// }
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async function main() {
|
|
90
|
-
// Create wallet from mnemonic
|
|
91
|
-
// const suiWallet = Ed25519Keypair.deriveKeypair(
|
|
92
|
-
// // "dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge",
|
|
93
|
-
// "know puzzle puzzle table miss member token image loop velvet skin legend clarify affair wisdom alert lucky unveil mean two question nice spatial grape"
|
|
94
|
-
// );
|
|
95
|
-
|
|
96
|
-
const suiWallet = Ed25519Keypair.fromSecretKey(
|
|
97
|
-
hexToBytes(
|
|
98
|
-
"3427d19dcf5781f0874c36c78aec22c03acda435d69efcbf249e8821793567a1"
|
|
99
|
-
)
|
|
100
|
-
);
|
|
101
|
-
const otherSuiWallet = Ed25519Keypair.fromSecretKey(
|
|
102
|
-
hexToBytes(
|
|
103
|
-
"1269e3f8279bed96907a6e809a93eea2528926abbdf56584f43544859fa8c0da"
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
logger.info(`Sui Address: ${suiWallet.getPublicKey().toSuiAddress()}`);
|
|
107
|
-
logger.info(`Other Sui Address: ${otherSuiWallet.getPublicKey().toSuiAddress()}`);
|
|
108
|
-
|
|
109
|
-
const bfSigner = new BluefinRequestSigner(makeSigner(suiWallet, false));
|
|
110
|
-
const otherBfSigner = new BluefinRequestSigner(makeSigner(otherSuiWallet, false));
|
|
111
|
-
const client = new BluefinProSdk(
|
|
112
|
-
bfSigner,
|
|
113
|
-
"testnet",
|
|
114
|
-
new SuiClient({ url: "https://fullnode.testnet.sui.io:443" })
|
|
115
|
-
);
|
|
116
|
-
await client.initialize();
|
|
117
|
-
|
|
118
|
-
// Example: Creating SDK with custom time offset
|
|
119
|
-
// const customTime = Date.now() + 5000; // 5 seconds in the future
|
|
120
|
-
// const clientWithTimeOffset = new BluefinProSdk(
|
|
121
|
-
// bfSigner,
|
|
122
|
-
// "testnet",
|
|
123
|
-
// new SuiClient({ url: "https://fullnode.testnet.sui.io:443" }),
|
|
124
|
-
// { currentTimeMs: customTime }
|
|
125
|
-
// );
|
|
126
|
-
// await clientWithTimeOffset.initialize();
|
|
127
|
-
//
|
|
128
|
-
// Later, you can update the time offset:
|
|
129
|
-
// const newCustomTime = Date.now() + 10000; // 10 seconds in the future
|
|
130
|
-
// clientWithTimeOffset.updateCurrentTimeMs(newCustomTime);
|
|
131
|
-
|
|
132
|
-
try {
|
|
133
|
-
// Disable for now as the account does not have enough coins
|
|
134
|
-
// await client.deposit((0.03*1e9).toString());
|
|
135
|
-
|
|
136
|
-
// Get Market Data from Exchange Data API
|
|
137
|
-
const exchangeInfo = (await client.exchangeDataApi.getExchangeInfo()).data;
|
|
138
|
-
logger.info(`Exchange Info: ${JSON.stringify(exchangeInfo)}`);
|
|
139
|
-
|
|
140
|
-
// Find the first market available if any
|
|
141
|
-
const perpMarket =
|
|
142
|
-
exchangeInfo.markets.length > 0
|
|
143
|
-
? exchangeInfo.markets[0]
|
|
144
|
-
: (() => {
|
|
145
|
-
throw new Error("No market is available");
|
|
146
|
-
})();
|
|
147
|
-
logger.info(`Selected market: ${JSON.stringify(perpMarket)}`);
|
|
148
|
-
|
|
149
|
-
const symbol = perpMarket.symbol;
|
|
150
|
-
|
|
151
|
-
// Get market data
|
|
152
|
-
const candleStick = (
|
|
153
|
-
await client.exchangeDataApi.getCandlestickData(
|
|
154
|
-
symbol,
|
|
155
|
-
KlineInterval._1m,
|
|
156
|
-
CandlePriceType.Oracle
|
|
157
|
-
)
|
|
158
|
-
).data;
|
|
159
|
-
logger.info(`Candle stick: ${JSON.stringify(candleStick)}`);
|
|
160
|
-
|
|
161
|
-
const rewards = (
|
|
162
|
-
await client.rewardsDataApi.getCampaignRewards(
|
|
163
|
-
"TRADE_AND_EARN",
|
|
164
|
-
suiWallet.toSuiAddress(),
|
|
165
|
-
)
|
|
166
|
-
).data;
|
|
167
|
-
logger.info(`Rewards: ${JSON.stringify(rewards)}`);
|
|
168
|
-
|
|
169
|
-
const depth = (await client.exchangeDataApi.getOrderbookDepth(symbol)).data;
|
|
170
|
-
logger.info(`Depth: ${JSON.stringify(depth)}`);
|
|
171
|
-
|
|
172
|
-
const ticker = (await client.exchangeDataApi.getMarketTicker(symbol)).data;
|
|
173
|
-
logger.info(`Exchange Market ticker: ${JSON.stringify(ticker)}`);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const recentTrades = (await client.exchangeDataApi.getRecentTrades(symbol))
|
|
177
|
-
.data;
|
|
178
|
-
logger.info(`Recent Trades: ${JSON.stringify(recentTrades)}`);
|
|
179
|
-
|
|
180
|
-
const fundingRateHistory = (
|
|
181
|
-
await client.exchangeDataApi.getFundingRateHistory(symbol)
|
|
182
|
-
).data;
|
|
183
|
-
logger.info(`Funding Rate History: ${JSON.stringify(fundingRateHistory)}`);
|
|
184
|
-
|
|
185
|
-
const stats = (
|
|
186
|
-
await client.exchangeDataApi.getExchangeStats()
|
|
187
|
-
).data;
|
|
188
|
-
logger.info(`Stats: ${JSON.stringify(stats)}`);
|
|
189
|
-
|
|
190
|
-
// Account Data API calls
|
|
191
|
-
const accountTrades = (
|
|
192
|
-
await client.accountDataApi.getAccountTrades(
|
|
193
|
-
symbol,
|
|
194
|
-
Date.now() - 10000000,
|
|
195
|
-
Date.now(),
|
|
196
|
-
1000,
|
|
197
|
-
TradeType.Order,
|
|
198
|
-
1
|
|
199
|
-
)
|
|
200
|
-
).data;
|
|
201
|
-
logger.info(`Trades History ${JSON.stringify(accountTrades)}`);
|
|
202
|
-
|
|
203
|
-
const depositHistory = (
|
|
204
|
-
await client.accountDataApi.getAccountTransactionHistory(
|
|
205
|
-
[TransactionType.Deposit, TransactionType.Withdraw],
|
|
206
|
-
symbol,
|
|
207
|
-
Date.now() - 10000000,
|
|
208
|
-
Date.now(),
|
|
209
|
-
1000,
|
|
210
|
-
1
|
|
211
|
-
)
|
|
212
|
-
).data;
|
|
213
|
-
logger.info(`Deposits history: ${JSON.stringify(depositHistory)}`);
|
|
214
|
-
|
|
215
|
-
const accountDetails = (
|
|
216
|
-
await client.accountDataApi.getAccountDetails(suiWallet.getPublicKey().toSuiAddress())
|
|
217
|
-
).data;
|
|
218
|
-
logger.info(`Account Details: ${JSON.stringify(accountDetails)}`);
|
|
219
|
-
|
|
220
|
-
const accountPreferences = (
|
|
221
|
-
await client.accountDataApi.getAccountPreferences()
|
|
222
|
-
).data;
|
|
223
|
-
logger.info(`Account Preferences: ${JSON.stringify(accountPreferences)}`);
|
|
224
|
-
|
|
225
|
-
const accountFundingrateHistory = (
|
|
226
|
-
await client.accountDataApi.getAccountFundingRateHistory()
|
|
227
|
-
).data;
|
|
228
|
-
logger.info(
|
|
229
|
-
`Account Funding Rate history: ${JSON.stringify(
|
|
230
|
-
accountFundingrateHistory
|
|
231
|
-
)}`
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
// Set up WebSocket listeners
|
|
235
|
-
const accountDataListener = await client.createAccountDataStreamListener(
|
|
236
|
-
handleAccountDataEvent
|
|
237
|
-
);
|
|
238
|
-
const marketDataListener = await client.createMarketDataStreamListener(
|
|
239
|
-
handleMarketDataEvent
|
|
240
|
-
);
|
|
241
|
-
|
|
242
|
-
await accountDataListener.send(
|
|
243
|
-
JSON.stringify({
|
|
244
|
-
method: "Subscribe",
|
|
245
|
-
dataStreams: [
|
|
246
|
-
AccountDataStream.AccountOrderUpdate,
|
|
247
|
-
AccountDataStream.AccountPositionUpdate,
|
|
248
|
-
AccountDataStream.AccountTradeUpdate,
|
|
249
|
-
AccountDataStream.AccountTransactionUpdate,
|
|
250
|
-
AccountDataStream.AccountUpdate,
|
|
251
|
-
],
|
|
252
|
-
})
|
|
253
|
-
);
|
|
254
|
-
|
|
255
|
-
await marketDataListener.send(
|
|
256
|
-
JSON.stringify({
|
|
257
|
-
method: "Subscribe",
|
|
258
|
-
dataStreams: [
|
|
259
|
-
{
|
|
260
|
-
symbol: symbol,
|
|
261
|
-
streams: [
|
|
262
|
-
MarketDataStreamName.MarkPrice,
|
|
263
|
-
MarketDataStreamName.RecentTrade,
|
|
264
|
-
MarketDataStreamName.OraclePrice,
|
|
265
|
-
MarketDataStreamName.Ticker,
|
|
266
|
-
MarketDataStreamName.TickerAll,
|
|
267
|
-
MarketDataStreamName.DiffDepth500Ms,
|
|
268
|
-
MarketDataStreamName.PartialDepth5,
|
|
269
|
-
],
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
})
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
// Place order
|
|
276
|
-
const orderParams: OrderParams = {
|
|
277
|
-
clientOrderId: "123456",
|
|
278
|
-
type: OrderType.Limit,
|
|
279
|
-
symbol: symbol,
|
|
280
|
-
priceE9: "10000000",
|
|
281
|
-
quantityE9: "100000000000",
|
|
282
|
-
side: OrderSide.Long,
|
|
283
|
-
leverageE9: "1000000000",
|
|
284
|
-
isIsolated: false,
|
|
285
|
-
expiresAtMillis: Date.now() + 6 * 60 * 1000,
|
|
286
|
-
postOnly: false,
|
|
287
|
-
reduceOnly: false,
|
|
288
|
-
timeInForce: OrderTimeInForce.Gtt,
|
|
289
|
-
};
|
|
290
|
-
|
|
291
|
-
const orderCreationResult = (await client.createOrder(orderParams)).data;
|
|
292
|
-
logger.info(
|
|
293
|
-
`Order Creation Result: ${JSON.stringify(orderCreationResult)}`
|
|
294
|
-
);
|
|
295
|
-
|
|
296
|
-
logger.info("Update Leverage to 2");
|
|
297
|
-
await client.updateLeverage(symbol, "2000000000");
|
|
298
|
-
|
|
299
|
-
// Withdraw 10 USD
|
|
300
|
-
await client.withdraw("USDC", "10000000000");
|
|
301
|
-
logger.info("Withdraw request success");
|
|
302
|
-
|
|
303
|
-
await client.authorizeAccount(otherBfSigner.getAddress());
|
|
304
|
-
logger.info("Authorize account request success");
|
|
305
|
-
|
|
306
|
-
await client.deauthorizeAccount(otherBfSigner.getAddress());
|
|
307
|
-
logger.info("Deauthorize account request success");
|
|
308
|
-
|
|
309
|
-
await client.adjustIsolatedMargin(symbol, "10000000000", true);
|
|
310
|
-
logger.info("Adjust isolated margin request success");
|
|
311
|
-
|
|
312
|
-
// Keep connection alive
|
|
313
|
-
await new Promise((resolve) => setTimeout(resolve, 50000));
|
|
314
|
-
} finally {
|
|
315
|
-
await client.dispose();
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// Run the main function
|
|
320
|
-
main().catch((error) => {
|
|
321
|
-
console.error("Error in main:", error);
|
|
322
|
-
process.exit(1);
|
|
323
|
-
});
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src/index";
|
package/openapitools.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
|
|
3
|
-
"spaces": 2,
|
|
4
|
-
"generator-cli": {
|
|
5
|
-
"version": "7.13.0"
|
|
6
|
-
},
|
|
7
|
-
"generatorName": "typescript-axios",
|
|
8
|
-
"additionalProperties": {
|
|
9
|
-
"hideGenerationTimestamp": true,
|
|
10
|
-
"avoidBoxedModels": true,
|
|
11
|
-
"packageName": "bluefin-pro-api-client",
|
|
12
|
-
"preferInterface": false,
|
|
13
|
-
"typescriptThreePlus": true,
|
|
14
|
-
"npmName": "@bluefin/api-client",
|
|
15
|
-
"npmVersion": "1.0.0",
|
|
16
|
-
"nullSafeAdditionalProps": true,
|
|
17
|
-
"enumNameSuffix": "Enum",
|
|
18
|
-
"modelPropertyNaming": "camelCase",
|
|
19
|
-
"paramNaming": "camelCase",
|
|
20
|
-
"sortParamsByRequiredFlag": true,
|
|
21
|
-
"enablePostProcessFile": false,
|
|
22
|
-
"generateAliasAsModel": false
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
.gitignore
|
|
2
|
-
.npmignore
|
|
3
|
-
api.ts
|
|
4
|
-
base.ts
|
|
5
|
-
common.ts
|
|
6
|
-
configuration.ts
|
|
7
|
-
docs/Account.md
|
|
8
|
-
docs/AccountAggregatedTradeUpdate.md
|
|
9
|
-
docs/AccountAuthorizationRequest.md
|
|
10
|
-
docs/AccountAuthorizationRequestSignedFields.md
|
|
11
|
-
docs/AccountCommandFailureUpdate.md
|
|
12
|
-
docs/AccountDataApi.md
|
|
13
|
-
docs/AccountDataStream.md
|
|
14
|
-
docs/AccountEventReason.md
|
|
15
|
-
docs/AccountEventType.md
|
|
16
|
-
docs/AccountFundingRateHistory.md
|
|
17
|
-
docs/AccountFundingRateHistoryData.md
|
|
18
|
-
docs/AccountMarketPreference.md
|
|
19
|
-
docs/AccountOrderUpdate.md
|
|
20
|
-
docs/AccountPositionLeverageUpdateRequest.md
|
|
21
|
-
docs/AccountPositionLeverageUpdateRequestSignedFields.md
|
|
22
|
-
docs/AccountPositionUpdate.md
|
|
23
|
-
docs/AccountPreference.md
|
|
24
|
-
docs/AccountStreamMessage.md
|
|
25
|
-
docs/AccountStreamMessagePayload.md
|
|
26
|
-
docs/AccountSubscriptionMessage.md
|
|
27
|
-
docs/AccountTradeUpdate.md
|
|
28
|
-
docs/AccountTransactionUpdate.md
|
|
29
|
-
docs/AccountUpdate.md
|
|
30
|
-
docs/ActiveOrderUpdate.md
|
|
31
|
-
docs/AdjustIsolatedMarginRequest.md
|
|
32
|
-
docs/AdjustIsolatedMarginRequestSignedFields.md
|
|
33
|
-
docs/AdjustMarginOperation.md
|
|
34
|
-
docs/AffiliateIntervalOverview.md
|
|
35
|
-
docs/AffiliateLeaderDashboard.md
|
|
36
|
-
docs/AffiliateMetadata.md
|
|
37
|
-
docs/AffiliateOnboardResponse.md
|
|
38
|
-
docs/AffiliateOverview.md
|
|
39
|
-
docs/AffiliateSummary.md
|
|
40
|
-
docs/Asset.md
|
|
41
|
-
docs/AssetConfig.md
|
|
42
|
-
docs/AuthApi.md
|
|
43
|
-
docs/AuthorizedWallet.md
|
|
44
|
-
docs/CampaignMetadata.md
|
|
45
|
-
docs/CancelOrdersRequest.md
|
|
46
|
-
docs/CancelOrdersResponse.md
|
|
47
|
-
docs/CandlePriceType.md
|
|
48
|
-
docs/CandlestickUpdate.md
|
|
49
|
-
docs/CommandFailureReasonCode.md
|
|
50
|
-
docs/ContractsConfig.md
|
|
51
|
-
docs/CreateOrderRequest.md
|
|
52
|
-
docs/CreateOrderRequestSignedFields.md
|
|
53
|
-
docs/CreateOrderResponse.md
|
|
54
|
-
docs/EpochConfigs.md
|
|
55
|
-
docs/EpochConfigsResponse.md
|
|
56
|
-
docs/EpochMetadata.md
|
|
57
|
-
docs/Error.md
|
|
58
|
-
docs/ExchangeApi.md
|
|
59
|
-
docs/ExchangeInfoResponse.md
|
|
60
|
-
docs/FailedCommandType.md
|
|
61
|
-
docs/FeeConfigs.md
|
|
62
|
-
docs/FundingRateEntry.md
|
|
63
|
-
docs/GetAffiliateIntervalOverview200Response.md
|
|
64
|
-
docs/GetAffiliateLeaderDashboard200Response.md
|
|
65
|
-
docs/GetAffiliateOverview200Response.md
|
|
66
|
-
docs/IntervalMetadata.md
|
|
67
|
-
docs/IntervalRewards.md
|
|
68
|
-
docs/KlineInterval.md
|
|
69
|
-
docs/LoginRequest.md
|
|
70
|
-
docs/LoginResponse.md
|
|
71
|
-
docs/MarginType.md
|
|
72
|
-
docs/MarkPriceUpdate.md
|
|
73
|
-
docs/Market.md
|
|
74
|
-
docs/MarketDataStreamName.md
|
|
75
|
-
docs/MarketEventType.md
|
|
76
|
-
docs/MarketPriceUpdate.md
|
|
77
|
-
docs/MarketStatus.md
|
|
78
|
-
docs/MarketStreamMessage.md
|
|
79
|
-
docs/MarketStreamMessagePayload.md
|
|
80
|
-
docs/MarketSubscriptionMessage.md
|
|
81
|
-
docs/MarketSubscriptionStreams.md
|
|
82
|
-
docs/OnboardAffiliateRequest.md
|
|
83
|
-
docs/OnboardAffiliateRequestSocialUserNames.md
|
|
84
|
-
docs/OnboardRefereeRequest.md
|
|
85
|
-
docs/OpenOrderResponse.md
|
|
86
|
-
docs/Operators.md
|
|
87
|
-
docs/OraclePriceUpdate.md
|
|
88
|
-
docs/OrderCancelReason.md
|
|
89
|
-
docs/OrderCancellationFailureReason.md
|
|
90
|
-
docs/OrderCancellationUpdate.md
|
|
91
|
-
docs/OrderSide.md
|
|
92
|
-
docs/OrderStatus.md
|
|
93
|
-
docs/OrderTimeInForce.md
|
|
94
|
-
docs/OrderType.md
|
|
95
|
-
docs/OrderbookDepthResponse.md
|
|
96
|
-
docs/OrderbookDiffDepthUpdate.md
|
|
97
|
-
docs/OrderbookPartialDepthUpdate.md
|
|
98
|
-
docs/Position.md
|
|
99
|
-
docs/PositionSide.md
|
|
100
|
-
docs/RecentTradesUpdates.md
|
|
101
|
-
docs/RefereeOnboardResponse.md
|
|
102
|
-
docs/RefreshTokenRequest.md
|
|
103
|
-
docs/RefreshTokenResponse.md
|
|
104
|
-
docs/RewardsApi.md
|
|
105
|
-
docs/RewardsSummary.md
|
|
106
|
-
docs/SelfTradePreventionType.md
|
|
107
|
-
docs/StatsEntry.md
|
|
108
|
-
docs/StatsInterval.md
|
|
109
|
-
docs/StatsResponse.md
|
|
110
|
-
docs/StreamsApi.md
|
|
111
|
-
docs/SubscriptionResponseMessage.md
|
|
112
|
-
docs/SubscriptionType.md
|
|
113
|
-
docs/TickerAllUpdate.md
|
|
114
|
-
docs/TickerResponse.md
|
|
115
|
-
docs/TickerUpdate.md
|
|
116
|
-
docs/Trade.md
|
|
117
|
-
docs/TradeApi.md
|
|
118
|
-
docs/TradeSide.md
|
|
119
|
-
docs/TradeType.md
|
|
120
|
-
docs/TradingFees.md
|
|
121
|
-
docs/Transaction.md
|
|
122
|
-
docs/TransactionType.md
|
|
123
|
-
docs/UpdateAccountPreferenceRequest.md
|
|
124
|
-
docs/UpdateAffiliateFeeConfigRequest.md
|
|
125
|
-
docs/UserCampaignRewards.md
|
|
126
|
-
docs/WithdrawRequest.md
|
|
127
|
-
docs/WithdrawRequestSignedFields.md
|
|
128
|
-
git_push.sh
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
7.13.0
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# OpenAPI Generator Ignore
|
|
2
|
-
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
3
|
-
|
|
4
|
-
# Use this file to prevent files from being overwritten by the generator.
|
|
5
|
-
# The patterns follow closely to .gitignore or .dockerignore.
|
|
6
|
-
|
|
7
|
-
# As an example, the C# client generator defines ApiClient.cs.
|
|
8
|
-
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
9
|
-
#ApiClient.cs
|
|
10
|
-
|
|
11
|
-
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
12
|
-
#foo/*/qux
|
|
13
|
-
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
14
|
-
|
|
15
|
-
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
16
|
-
#foo/**/qux
|
|
17
|
-
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
18
|
-
|
|
19
|
-
# You can also negate patterns with an exclamation (!).
|
|
20
|
-
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
21
|
-
#docs/*.md
|
|
22
|
-
# Then explicitly reverse the ignore rule for a single file:
|
|
23
|
-
#!docs/README.md
|
|
24
|
-
|
|
25
|
-
index.ts
|
|
26
|
-
package.json
|
|
27
|
-
README.md
|
|
28
|
-
tsconfig.json
|
package/src/README.md
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
## @bluefin/api-client@1.0.0
|
|
2
|
-
|
|
3
|
-
This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments:
|
|
4
|
-
|
|
5
|
-
Environment
|
|
6
|
-
* Node.js
|
|
7
|
-
* Webpack
|
|
8
|
-
* Browserify
|
|
9
|
-
|
|
10
|
-
Language level
|
|
11
|
-
* ES5 - you must have a Promises/A+ library installed
|
|
12
|
-
* ES6
|
|
13
|
-
|
|
14
|
-
Module system
|
|
15
|
-
* CommonJS
|
|
16
|
-
* ES6 module system
|
|
17
|
-
|
|
18
|
-
It can be used in both TypeScript and JavaScript. In TypeScript, the definition will be automatically resolved via `package.json`. ([Reference](https://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html))
|
|
19
|
-
|
|
20
|
-
### Building
|
|
21
|
-
|
|
22
|
-
To build and compile the typescript sources to javascript use:
|
|
23
|
-
```
|
|
24
|
-
npm install
|
|
25
|
-
npm run build
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Publishing
|
|
29
|
-
|
|
30
|
-
First build the package then run `npm publish`
|
|
31
|
-
|
|
32
|
-
### Consuming
|
|
33
|
-
|
|
34
|
-
navigate to the folder of your consuming project and run one of the following commands.
|
|
35
|
-
|
|
36
|
-
_published:_
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
npm install @bluefin/api-client@1.0.0 --save
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
_unPublished (not recommended):_
|
|
43
|
-
|
|
44
|
-
```
|
|
45
|
-
npm install PATH_TO_GENERATED_PACKAGE --save
|
|
46
|
-
```
|