@bluefin-exchange/pro-sdk 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/example.js +21 -9
- package/dist/src/api.d.ts +128 -0
- package/dist/src/api.js +140 -0
- package/dist/src/request-signer.d.ts +15 -75
- package/dist/src/request-signer.js +114 -109
- package/dist/src/sdk.d.ts +25 -11
- package/dist/src/sdk.js +151 -21
- package/example.ts +42 -18
- package/package.json +3 -2
- package/src/api.ts +212 -0
- package/src/request-signer.ts +223 -158
- package/src/sdk.ts +216 -44
package/dist/example.js
CHANGED
|
@@ -13,6 +13,8 @@ const index_1 = require("./index");
|
|
|
13
13
|
const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
|
|
14
14
|
const index_2 = require("./index");
|
|
15
15
|
const index_3 = require("./index");
|
|
16
|
+
const utils_1 = require("@noble/hashes/utils");
|
|
17
|
+
const library_sui_1 = require("@firefly-exchange/library-sui");
|
|
16
18
|
// Configure logging
|
|
17
19
|
const logger = {
|
|
18
20
|
info: (message) => console.log(new Date().toISOString(), "-", message),
|
|
@@ -77,21 +79,27 @@ function handleAccountDataEvent(msg) {
|
|
|
77
79
|
function main() {
|
|
78
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
81
|
// Create wallet from mnemonic
|
|
80
|
-
const suiWallet =
|
|
81
|
-
// "dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge",
|
|
82
|
-
"know puzzle puzzle table miss member token image loop velvet skin legend clarify affair wisdom alert lucky unveil mean two question nice spatial grape"
|
|
82
|
+
// const suiWallet = Ed25519Keypair.deriveKeypair(
|
|
83
|
+
// // "dilemma salmon lake ceiling moral glide cute that ginger float area aunt vague remind cage mother concert inch dizzy present proud program time urge",
|
|
84
|
+
// "know puzzle puzzle table miss member token image loop velvet skin legend clarify affair wisdom alert lucky unveil mean two question nice spatial grape"
|
|
85
|
+
// );
|
|
86
|
+
const suiWallet = ed25519_1.Ed25519Keypair.fromSecretKey((0, utils_1.hexToBytes)("3427d19dcf5781f0874c36c78aec22c03acda435d69efcbf249e8821793567a1"));
|
|
83
87
|
logger.info(`Sui Address: ${suiWallet.getPublicKey().toSuiAddress()}`);
|
|
84
88
|
const bfSigner = new index_3.BluefinRequestSigner((0, index_3.makeAddressableKeyPair)(suiWallet));
|
|
85
|
-
const client = new index_2.BluefinProSdk(bfSigner, "devnet",
|
|
89
|
+
const client = new index_2.BluefinProSdk(bfSigner, "devnet", new library_sui_1.SuiClient({ url: "https://fullnode.testnet.sui.io:443" }));
|
|
86
90
|
yield client.initialize();
|
|
87
91
|
try {
|
|
92
|
+
yield client.deposit("1000");
|
|
88
93
|
// Get Market Data from Exchange Data API
|
|
89
94
|
const exchangeInfo = (yield client.exchangeDataApi.getExchangeInfo()).data;
|
|
90
95
|
logger.info(`Exchange Info: ${JSON.stringify(exchangeInfo)}`);
|
|
91
|
-
//
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
// Find SUI-PERP market
|
|
97
|
+
const perpMarket = exchangeInfo.markets.find((m) => m.symbol === "SUI-PERP");
|
|
98
|
+
if (!perpMarket) {
|
|
99
|
+
throw new Error("SUI-PERP market not found");
|
|
100
|
+
}
|
|
101
|
+
logger.info(`Selected market: ${JSON.stringify(perpMarket)}`);
|
|
102
|
+
const symbol = perpMarket.symbol;
|
|
95
103
|
// Get market data
|
|
96
104
|
const candleStick = (yield client.exchangeDataApi.getCandlestickData(symbol, index_1.KlineInterval._1m, index_1.CandlePriceType.Oracle)).data;
|
|
97
105
|
logger.info(`Candle stick: ${JSON.stringify(candleStick)}`);
|
|
@@ -154,7 +162,7 @@ function main() {
|
|
|
154
162
|
side: index_1.OrderSide.Long,
|
|
155
163
|
leverageE9: "1000000000",
|
|
156
164
|
isIsolated: false,
|
|
157
|
-
expiresAtUtcMillis: Date.now() +
|
|
165
|
+
expiresAtUtcMillis: Date.now() + 6 * 60 * 1000,
|
|
158
166
|
postOnly: false,
|
|
159
167
|
reduceOnly: false,
|
|
160
168
|
timeInForce: index_1.OrderTimeInForce.Gtt,
|
|
@@ -166,6 +174,10 @@ function main() {
|
|
|
166
174
|
// Withdraw 10 USD
|
|
167
175
|
yield client.withdraw("USDC", "10000000000");
|
|
168
176
|
logger.info("Withdraw request success");
|
|
177
|
+
yield client.authorizeAccount(bfSigner.getAddress());
|
|
178
|
+
logger.info("Authorize account request success");
|
|
179
|
+
yield client.deauthorizeAccount(bfSigner.getAddress());
|
|
180
|
+
logger.info("Deauthorize account request success");
|
|
169
181
|
// Keep connection alive
|
|
170
182
|
yield new Promise((resolve) => setTimeout(resolve, 50000));
|
|
171
183
|
}
|
package/dist/src/api.d.ts
CHANGED
|
@@ -122,6 +122,68 @@ export interface Account {
|
|
|
122
122
|
*/
|
|
123
123
|
'positions': Array<Position>;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
*
|
|
127
|
+
* @export
|
|
128
|
+
* @interface AccountAuthorizationRequest
|
|
129
|
+
*/
|
|
130
|
+
export interface AccountAuthorizationRequest {
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* @type {AccountAuthorizationRequestSignedFields}
|
|
134
|
+
* @memberof AccountAuthorizationRequest
|
|
135
|
+
*/
|
|
136
|
+
'signedFields': AccountAuthorizationRequestSignedFields;
|
|
137
|
+
/**
|
|
138
|
+
* The signature of the request, encoded from the signedFields
|
|
139
|
+
* @type {string}
|
|
140
|
+
* @memberof AccountAuthorizationRequest
|
|
141
|
+
*/
|
|
142
|
+
'signature': string;
|
|
143
|
+
/**
|
|
144
|
+
* Used to uniquely identify the request. Created by hex encoding the bcs encoded signedFields.
|
|
145
|
+
* @type {string}
|
|
146
|
+
* @memberof AccountAuthorizationRequest
|
|
147
|
+
*/
|
|
148
|
+
'requestHash': string;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* @export
|
|
153
|
+
* @interface AccountAuthorizationRequestSignedFields
|
|
154
|
+
*/
|
|
155
|
+
export interface AccountAuthorizationRequestSignedFields {
|
|
156
|
+
/**
|
|
157
|
+
* The account address of the parent account that is authorizing/deauthorizing this account
|
|
158
|
+
* @type {string}
|
|
159
|
+
* @memberof AccountAuthorizationRequestSignedFields
|
|
160
|
+
*/
|
|
161
|
+
'accountAddress': string;
|
|
162
|
+
/**
|
|
163
|
+
* The address of the account that should be authorized/deauthorized
|
|
164
|
+
* @type {string}
|
|
165
|
+
* @memberof AccountAuthorizationRequestSignedFields
|
|
166
|
+
*/
|
|
167
|
+
'authorizedAccountAddress': string;
|
|
168
|
+
/**
|
|
169
|
+
* The random generated salt. Should always be a number
|
|
170
|
+
* @type {string}
|
|
171
|
+
* @memberof AccountAuthorizationRequestSignedFields
|
|
172
|
+
*/
|
|
173
|
+
'salt': string;
|
|
174
|
+
/**
|
|
175
|
+
* the ID of the internal datastore for the target network
|
|
176
|
+
* @type {string}
|
|
177
|
+
* @memberof AccountAuthorizationRequestSignedFields
|
|
178
|
+
*/
|
|
179
|
+
'idsId': string;
|
|
180
|
+
/**
|
|
181
|
+
* The timestamp when the request was signed
|
|
182
|
+
* @type {number}
|
|
183
|
+
* @memberof AccountAuthorizationRequestSignedFields
|
|
184
|
+
*/
|
|
185
|
+
'signedAtUtcMillis': number;
|
|
186
|
+
}
|
|
125
187
|
/**
|
|
126
188
|
* Represents the type of account data stream.
|
|
127
189
|
* @export
|
|
@@ -4324,6 +4386,22 @@ export declare const TradeApiAxiosParamCreator: (configuration?: Configuration)
|
|
|
4324
4386
|
* @throws {RequiredError}
|
|
4325
4387
|
*/
|
|
4326
4388
|
postWithdraw: (withdrawRequest: WithdrawRequest, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
4389
|
+
/**
|
|
4390
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4391
|
+
* @summary Authorizes an account
|
|
4392
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4393
|
+
* @param {*} [options] Override http request option.
|
|
4394
|
+
* @throws {RequiredError}
|
|
4395
|
+
*/
|
|
4396
|
+
putAuthorizeAccount: (accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
4397
|
+
/**
|
|
4398
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4399
|
+
* @summary Deauthorizes an account
|
|
4400
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4401
|
+
* @param {*} [options] Override http request option.
|
|
4402
|
+
* @throws {RequiredError}
|
|
4403
|
+
*/
|
|
4404
|
+
putDeauthorizeAccount: (accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig) => Promise<RequestArgs>;
|
|
4327
4405
|
/**
|
|
4328
4406
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
4329
4407
|
* @summary Updates leverage for positions
|
|
@@ -4370,6 +4448,22 @@ export declare const TradeApiFp: (configuration?: Configuration) => {
|
|
|
4370
4448
|
* @throws {RequiredError}
|
|
4371
4449
|
*/
|
|
4372
4450
|
postWithdraw(withdrawRequest: WithdrawRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
|
|
4451
|
+
/**
|
|
4452
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4453
|
+
* @summary Authorizes an account
|
|
4454
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4455
|
+
* @param {*} [options] Override http request option.
|
|
4456
|
+
* @throws {RequiredError}
|
|
4457
|
+
*/
|
|
4458
|
+
putAuthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
|
|
4459
|
+
/**
|
|
4460
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4461
|
+
* @summary Deauthorizes an account
|
|
4462
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4463
|
+
* @param {*} [options] Override http request option.
|
|
4464
|
+
* @throws {RequiredError}
|
|
4465
|
+
*/
|
|
4466
|
+
putDeauthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
|
|
4373
4467
|
/**
|
|
4374
4468
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
4375
4469
|
* @summary Updates leverage for positions
|
|
@@ -4416,6 +4510,22 @@ export declare const TradeApiFactory: (configuration?: Configuration, basePath?:
|
|
|
4416
4510
|
* @throws {RequiredError}
|
|
4417
4511
|
*/
|
|
4418
4512
|
postWithdraw(withdrawRequest: WithdrawRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;
|
|
4513
|
+
/**
|
|
4514
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4515
|
+
* @summary Authorizes an account
|
|
4516
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4517
|
+
* @param {*} [options] Override http request option.
|
|
4518
|
+
* @throws {RequiredError}
|
|
4519
|
+
*/
|
|
4520
|
+
putAuthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;
|
|
4521
|
+
/**
|
|
4522
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4523
|
+
* @summary Deauthorizes an account
|
|
4524
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4525
|
+
* @param {*} [options] Override http request option.
|
|
4526
|
+
* @throws {RequiredError}
|
|
4527
|
+
*/
|
|
4528
|
+
putDeauthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): AxiosPromise<void>;
|
|
4419
4529
|
/**
|
|
4420
4530
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
4421
4531
|
* @summary Updates leverage for positions
|
|
@@ -4468,6 +4578,24 @@ export declare class TradeApi extends BaseAPI {
|
|
|
4468
4578
|
* @memberof TradeApi
|
|
4469
4579
|
*/
|
|
4470
4580
|
postWithdraw(withdrawRequest: WithdrawRequest, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
4581
|
+
/**
|
|
4582
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4583
|
+
* @summary Authorizes an account
|
|
4584
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4585
|
+
* @param {*} [options] Override http request option.
|
|
4586
|
+
* @throws {RequiredError}
|
|
4587
|
+
* @memberof TradeApi
|
|
4588
|
+
*/
|
|
4589
|
+
putAuthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
4590
|
+
/**
|
|
4591
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
4592
|
+
* @summary Deauthorizes an account
|
|
4593
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
4594
|
+
* @param {*} [options] Override http request option.
|
|
4595
|
+
* @throws {RequiredError}
|
|
4596
|
+
* @memberof TradeApi
|
|
4597
|
+
*/
|
|
4598
|
+
putDeauthorizeAccount(accountAuthorizationRequest: AccountAuthorizationRequest, options?: RawAxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
|
|
4471
4599
|
/**
|
|
4472
4600
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
4473
4601
|
* @summary Updates leverage for positions
|
package/dist/src/api.js
CHANGED
|
@@ -2088,6 +2088,72 @@ const TradeApiAxiosParamCreator = function (configuration) {
|
|
|
2088
2088
|
options: localVarRequestOptions,
|
|
2089
2089
|
};
|
|
2090
2090
|
}),
|
|
2091
|
+
/**
|
|
2092
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2093
|
+
* @summary Authorizes an account
|
|
2094
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2095
|
+
* @param {*} [options] Override http request option.
|
|
2096
|
+
* @throws {RequiredError}
|
|
2097
|
+
*/
|
|
2098
|
+
putAuthorizeAccount: (accountAuthorizationRequest_1, ...args_1) => __awaiter(this, [accountAuthorizationRequest_1, ...args_1], void 0, function* (accountAuthorizationRequest, options = {}) {
|
|
2099
|
+
// verify required parameter 'accountAuthorizationRequest' is not null or undefined
|
|
2100
|
+
(0, common_1.assertParamExists)('putAuthorizeAccount', 'accountAuthorizationRequest', accountAuthorizationRequest);
|
|
2101
|
+
const localVarPath = `/api/v1/trade/accounts/authorize`;
|
|
2102
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
2103
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
2104
|
+
let baseOptions;
|
|
2105
|
+
if (configuration) {
|
|
2106
|
+
baseOptions = configuration.baseOptions;
|
|
2107
|
+
}
|
|
2108
|
+
const localVarRequestOptions = Object.assign(Object.assign({ method: 'PUT' }, baseOptions), options);
|
|
2109
|
+
const localVarHeaderParameter = {};
|
|
2110
|
+
const localVarQueryParameter = {};
|
|
2111
|
+
// authentication bearerAuth required
|
|
2112
|
+
// http bearer authentication required
|
|
2113
|
+
yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
2114
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
2115
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
2116
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
2117
|
+
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
|
|
2118
|
+
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(accountAuthorizationRequest, localVarRequestOptions, configuration);
|
|
2119
|
+
return {
|
|
2120
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
2121
|
+
options: localVarRequestOptions,
|
|
2122
|
+
};
|
|
2123
|
+
}),
|
|
2124
|
+
/**
|
|
2125
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2126
|
+
* @summary Deauthorizes an account
|
|
2127
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2128
|
+
* @param {*} [options] Override http request option.
|
|
2129
|
+
* @throws {RequiredError}
|
|
2130
|
+
*/
|
|
2131
|
+
putDeauthorizeAccount: (accountAuthorizationRequest_1, ...args_1) => __awaiter(this, [accountAuthorizationRequest_1, ...args_1], void 0, function* (accountAuthorizationRequest, options = {}) {
|
|
2132
|
+
// verify required parameter 'accountAuthorizationRequest' is not null or undefined
|
|
2133
|
+
(0, common_1.assertParamExists)('putDeauthorizeAccount', 'accountAuthorizationRequest', accountAuthorizationRequest);
|
|
2134
|
+
const localVarPath = `/api/v1/trade/accounts/deauthorize`;
|
|
2135
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
2136
|
+
const localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
|
|
2137
|
+
let baseOptions;
|
|
2138
|
+
if (configuration) {
|
|
2139
|
+
baseOptions = configuration.baseOptions;
|
|
2140
|
+
}
|
|
2141
|
+
const localVarRequestOptions = Object.assign(Object.assign({ method: 'PUT' }, baseOptions), options);
|
|
2142
|
+
const localVarHeaderParameter = {};
|
|
2143
|
+
const localVarQueryParameter = {};
|
|
2144
|
+
// authentication bearerAuth required
|
|
2145
|
+
// http bearer authentication required
|
|
2146
|
+
yield (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration);
|
|
2147
|
+
localVarHeaderParameter['Content-Type'] = 'application/json';
|
|
2148
|
+
(0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
|
|
2149
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
2150
|
+
localVarRequestOptions.headers = Object.assign(Object.assign(Object.assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
|
|
2151
|
+
localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(accountAuthorizationRequest, localVarRequestOptions, configuration);
|
|
2152
|
+
return {
|
|
2153
|
+
url: (0, common_1.toPathString)(localVarUrlObj),
|
|
2154
|
+
options: localVarRequestOptions,
|
|
2155
|
+
};
|
|
2156
|
+
}),
|
|
2091
2157
|
/**
|
|
2092
2158
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
2093
2159
|
* @summary Updates leverage for positions
|
|
@@ -2195,6 +2261,38 @@ const TradeApiFp = function (configuration) {
|
|
|
2195
2261
|
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
2196
2262
|
});
|
|
2197
2263
|
},
|
|
2264
|
+
/**
|
|
2265
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2266
|
+
* @summary Authorizes an account
|
|
2267
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2268
|
+
* @param {*} [options] Override http request option.
|
|
2269
|
+
* @throws {RequiredError}
|
|
2270
|
+
*/
|
|
2271
|
+
putAuthorizeAccount(accountAuthorizationRequest, options) {
|
|
2272
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2273
|
+
var _a, _b, _c;
|
|
2274
|
+
const localVarAxiosArgs = yield localVarAxiosParamCreator.putAuthorizeAccount(accountAuthorizationRequest, options);
|
|
2275
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
2276
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['TradeApi.putAuthorizeAccount']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
2277
|
+
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
2278
|
+
});
|
|
2279
|
+
},
|
|
2280
|
+
/**
|
|
2281
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2282
|
+
* @summary Deauthorizes an account
|
|
2283
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2284
|
+
* @param {*} [options] Override http request option.
|
|
2285
|
+
* @throws {RequiredError}
|
|
2286
|
+
*/
|
|
2287
|
+
putDeauthorizeAccount(accountAuthorizationRequest, options) {
|
|
2288
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2289
|
+
var _a, _b, _c;
|
|
2290
|
+
const localVarAxiosArgs = yield localVarAxiosParamCreator.putDeauthorizeAccount(accountAuthorizationRequest, options);
|
|
2291
|
+
const localVarOperationServerIndex = (_a = configuration === null || configuration === void 0 ? void 0 : configuration.serverIndex) !== null && _a !== void 0 ? _a : 0;
|
|
2292
|
+
const localVarOperationServerBasePath = (_c = (_b = base_1.operationServerMap['TradeApi.putDeauthorizeAccount']) === null || _b === void 0 ? void 0 : _b[localVarOperationServerIndex]) === null || _c === void 0 ? void 0 : _c.url;
|
|
2293
|
+
return (axios, basePath) => (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
|
|
2294
|
+
});
|
|
2295
|
+
},
|
|
2198
2296
|
/**
|
|
2199
2297
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
2200
2298
|
* @summary Updates leverage for positions
|
|
@@ -2261,6 +2359,26 @@ const TradeApiFactory = function (configuration, basePath, axios) {
|
|
|
2261
2359
|
postWithdraw(withdrawRequest, options) {
|
|
2262
2360
|
return localVarFp.postWithdraw(withdrawRequest, options).then((request) => request(axios, basePath));
|
|
2263
2361
|
},
|
|
2362
|
+
/**
|
|
2363
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2364
|
+
* @summary Authorizes an account
|
|
2365
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2366
|
+
* @param {*} [options] Override http request option.
|
|
2367
|
+
* @throws {RequiredError}
|
|
2368
|
+
*/
|
|
2369
|
+
putAuthorizeAccount(accountAuthorizationRequest, options) {
|
|
2370
|
+
return localVarFp.putAuthorizeAccount(accountAuthorizationRequest, options).then((request) => request(axios, basePath));
|
|
2371
|
+
},
|
|
2372
|
+
/**
|
|
2373
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2374
|
+
* @summary Deauthorizes an account
|
|
2375
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2376
|
+
* @param {*} [options] Override http request option.
|
|
2377
|
+
* @throws {RequiredError}
|
|
2378
|
+
*/
|
|
2379
|
+
putDeauthorizeAccount(accountAuthorizationRequest, options) {
|
|
2380
|
+
return localVarFp.putDeauthorizeAccount(accountAuthorizationRequest, options).then((request) => request(axios, basePath));
|
|
2381
|
+
},
|
|
2264
2382
|
/**
|
|
2265
2383
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
2266
2384
|
* @summary Updates leverage for positions
|
|
@@ -2325,6 +2443,28 @@ class TradeApi extends base_1.BaseAPI {
|
|
|
2325
2443
|
postWithdraw(withdrawRequest, options) {
|
|
2326
2444
|
return (0, exports.TradeApiFp)(this.configuration).postWithdraw(withdrawRequest, options).then((request) => request(this.axios, this.basePath));
|
|
2327
2445
|
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Authorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2448
|
+
* @summary Authorizes an account
|
|
2449
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2450
|
+
* @param {*} [options] Override http request option.
|
|
2451
|
+
* @throws {RequiredError}
|
|
2452
|
+
* @memberof TradeApi
|
|
2453
|
+
*/
|
|
2454
|
+
putAuthorizeAccount(accountAuthorizationRequest, options) {
|
|
2455
|
+
return (0, exports.TradeApiFp)(this.configuration).putAuthorizeAccount(accountAuthorizationRequest, options).then((request) => request(this.axios, this.basePath));
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* Deauthorizes an account to trade, perform liquidations and more, on behalf of another account
|
|
2459
|
+
* @summary Deauthorizes an account
|
|
2460
|
+
* @param {AccountAuthorizationRequest} accountAuthorizationRequest
|
|
2461
|
+
* @param {*} [options] Override http request option.
|
|
2462
|
+
* @throws {RequiredError}
|
|
2463
|
+
* @memberof TradeApi
|
|
2464
|
+
*/
|
|
2465
|
+
putDeauthorizeAccount(accountAuthorizationRequest, options) {
|
|
2466
|
+
return (0, exports.TradeApiFp)(this.configuration).putDeauthorizeAccount(accountAuthorizationRequest, options).then((request) => request(this.axios, this.basePath));
|
|
2467
|
+
}
|
|
2328
2468
|
/**
|
|
2329
2469
|
* Updates leverage for positions of a given market, closes all open orders for that market
|
|
2330
2470
|
* @summary Updates leverage for positions
|
|
@@ -1,84 +1,19 @@
|
|
|
1
1
|
import { Keypair, Signer } from "@mysten/sui/cryptography";
|
|
2
|
-
import { LoginRequest,
|
|
2
|
+
import { LoginRequest, AccountPositionLeverageUpdateRequestSignedFields, CreateOrderRequestSignedFields, WithdrawRequestSignedFields, AccountAuthorizationRequestSignedFields } from "./api";
|
|
3
|
+
import { DryRunTransactionBlockResponse, SuiClient, SuiTransactionBlockResponse, TransactionBlock } from "@firefly-exchange/library-sui";
|
|
3
4
|
export interface IBluefinSigner {
|
|
4
5
|
getAddress(): string;
|
|
5
|
-
signLeverageUpdateRequest: (fields: AccountPositionLeverageUpdateRequestSignedFields) => Promise<
|
|
6
|
-
signOrderRequest: (fields: CreateOrderRequestSignedFields) => Promise<
|
|
7
|
-
signWithdrawRequest: (fields: WithdrawRequestSignedFields) => Promise<
|
|
6
|
+
signLeverageUpdateRequest: (fields: AccountPositionLeverageUpdateRequestSignedFields) => Promise<string>;
|
|
7
|
+
signOrderRequest: (fields: CreateOrderRequestSignedFields) => Promise<string>;
|
|
8
|
+
signWithdrawRequest: (fields: WithdrawRequestSignedFields) => Promise<string>;
|
|
9
|
+
signAccountAuthorizationRequest: (fields: AccountAuthorizationRequestSignedFields, isAuthorize: boolean) => Promise<string>;
|
|
8
10
|
signLoginRequest: (request: LoginRequest) => Promise<string>;
|
|
11
|
+
executeTx: (txb: TransactionBlock, suiClient: SuiClient) => Promise<DryRunTransactionBlockResponse | SuiTransactionBlockResponse>;
|
|
9
12
|
}
|
|
10
13
|
export interface IAddressable {
|
|
11
14
|
getAddress(): string;
|
|
12
15
|
}
|
|
13
16
|
export declare function makeAddressableKeyPair<T extends Keypair>(keyPair: T): T & IAddressable;
|
|
14
|
-
export declare const OrderRequestSignedFieldsBCS: import("@mysten/sui/bcs").BcsType<{
|
|
15
|
-
symbol: string;
|
|
16
|
-
accountAddress: string;
|
|
17
|
-
priceE9: string;
|
|
18
|
-
quantityE9: string;
|
|
19
|
-
leverageE9: string;
|
|
20
|
-
side: string;
|
|
21
|
-
isIsolated: boolean;
|
|
22
|
-
expiresAtUtcMillis: string;
|
|
23
|
-
salt: string;
|
|
24
|
-
idsId: string;
|
|
25
|
-
signedAtUtcMillis: string;
|
|
26
|
-
}, {
|
|
27
|
-
symbol: string;
|
|
28
|
-
accountAddress: string | Uint8Array<ArrayBufferLike>;
|
|
29
|
-
priceE9: string | number | bigint;
|
|
30
|
-
quantityE9: string | number | bigint;
|
|
31
|
-
leverageE9: string | number | bigint;
|
|
32
|
-
side: string;
|
|
33
|
-
isIsolated: boolean;
|
|
34
|
-
expiresAtUtcMillis: string | number | bigint;
|
|
35
|
-
salt: string | number | bigint;
|
|
36
|
-
idsId: string | Uint8Array<ArrayBufferLike>;
|
|
37
|
-
signedAtUtcMillis: string | number | bigint;
|
|
38
|
-
}>;
|
|
39
|
-
export declare const LeverageUpdateRequestSignedFieldsBCS: import("@mysten/sui/bcs").BcsType<{
|
|
40
|
-
accountAddress: string;
|
|
41
|
-
symbol: string;
|
|
42
|
-
leverageE9: string;
|
|
43
|
-
salt: string;
|
|
44
|
-
idsId: string;
|
|
45
|
-
signedAtUtcMillis: string;
|
|
46
|
-
}, {
|
|
47
|
-
accountAddress: string | Uint8Array<ArrayBufferLike>;
|
|
48
|
-
symbol: string;
|
|
49
|
-
leverageE9: string | number | bigint;
|
|
50
|
-
salt: string | number | bigint;
|
|
51
|
-
idsId: string | Uint8Array<ArrayBufferLike>;
|
|
52
|
-
signedAtUtcMillis: string | number | bigint;
|
|
53
|
-
}>;
|
|
54
|
-
export declare const WithdrawRequestSignedFieldsBCS: import("@mysten/sui/bcs").BcsType<{
|
|
55
|
-
assetSymbol: string;
|
|
56
|
-
accountAddress: string;
|
|
57
|
-
amountE9: string;
|
|
58
|
-
salt: string;
|
|
59
|
-
edsId: string;
|
|
60
|
-
signedAtUtcMillis: string;
|
|
61
|
-
}, {
|
|
62
|
-
assetSymbol: string;
|
|
63
|
-
accountAddress: string | Uint8Array<ArrayBufferLike>;
|
|
64
|
-
amountE9: string | number | bigint;
|
|
65
|
-
salt: string | number | bigint;
|
|
66
|
-
edsId: string | Uint8Array<ArrayBufferLike>;
|
|
67
|
-
signedAtUtcMillis: string | number | bigint;
|
|
68
|
-
}>;
|
|
69
|
-
export declare const SerializedSignatureBCS: import("@mysten/sui/bcs").BcsType<{
|
|
70
|
-
signature: number[];
|
|
71
|
-
publicKey: number[];
|
|
72
|
-
scheme: number;
|
|
73
|
-
}, {
|
|
74
|
-
signature: Iterable<number> & {
|
|
75
|
-
length: number;
|
|
76
|
-
};
|
|
77
|
-
publicKey: Iterable<number> & {
|
|
78
|
-
length: number;
|
|
79
|
-
};
|
|
80
|
-
scheme: number;
|
|
81
|
-
}>;
|
|
82
17
|
export declare class BluefinRequestSigner implements IBluefinSigner {
|
|
83
18
|
private readonly wallet;
|
|
84
19
|
constructor(wallet: Pick<Signer, "signPersonalMessage"> & IAddressable);
|
|
@@ -89,15 +24,20 @@ export declare class BluefinRequestSigner implements IBluefinSigner {
|
|
|
89
24
|
/**
|
|
90
25
|
* Sign an order request
|
|
91
26
|
*/
|
|
92
|
-
signOrderRequest(
|
|
27
|
+
signOrderRequest(signedFields: CreateOrderRequestSignedFields): Promise<string>;
|
|
93
28
|
/**
|
|
94
29
|
* Sign a withdraw request
|
|
95
30
|
*/
|
|
96
|
-
signWithdrawRequest(withdrawRequestSignedFields: WithdrawRequestSignedFields): Promise<
|
|
31
|
+
signWithdrawRequest(withdrawRequestSignedFields: WithdrawRequestSignedFields): Promise<string>;
|
|
97
32
|
/**
|
|
98
33
|
* Sign a leverage update request
|
|
99
34
|
*/
|
|
100
|
-
signLeverageUpdateRequest(
|
|
35
|
+
signLeverageUpdateRequest(signedFields: AccountPositionLeverageUpdateRequestSignedFields): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Sign an account authorization request
|
|
38
|
+
*/
|
|
39
|
+
signAccountAuthorizationRequest(signedFields: AccountAuthorizationRequestSignedFields, is_authorize: boolean): Promise<string>;
|
|
40
|
+
executeTx(txb: TransactionBlock, suiClient: SuiClient): Promise<DryRunTransactionBlockResponse | SuiTransactionBlockResponse>;
|
|
101
41
|
/**
|
|
102
42
|
* Get the wallet's address
|
|
103
43
|
*/
|