@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.
Files changed (210) hide show
  1. package/dist/{example.js → cjs/example.js} +3 -0
  2. package/dist/cjs/example.js.map +1 -0
  3. package/dist/{index.js → cjs/index.js} +1 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/{src → cjs/src}/api.js +75 -1
  6. package/dist/cjs/src/api.js.map +1 -0
  7. package/dist/{src → cjs/src}/base.js +5 -1
  8. package/dist/cjs/src/base.js.map +1 -0
  9. package/dist/{src → cjs/src}/common.js +1 -0
  10. package/dist/cjs/src/common.js.map +1 -0
  11. package/dist/{src → cjs/src}/configuration.js +1 -0
  12. package/dist/cjs/src/configuration.js.map +1 -0
  13. package/dist/{src → cjs/src}/index.js +1 -0
  14. package/dist/cjs/src/index.js.map +1 -0
  15. package/dist/{src → cjs/src}/request-signer.js +11 -0
  16. package/dist/cjs/src/request-signer.js.map +1 -0
  17. package/dist/{src → cjs/src}/sdk.js +47 -4
  18. package/dist/cjs/src/sdk.js.map +1 -0
  19. package/dist/{src → cjs/src}/utils.js +1 -0
  20. package/dist/cjs/src/utils.js.map +1 -0
  21. package/dist/{src → cjs/src}/websocket.js +1 -0
  22. package/dist/cjs/src/websocket.js.map +1 -0
  23. package/dist/esm/example.js +218 -0
  24. package/dist/esm/example.js.map +1 -0
  25. package/dist/esm/index.js +18 -0
  26. package/dist/esm/index.js.map +1 -0
  27. package/dist/esm/src/api.js +4318 -0
  28. package/dist/esm/src/api.js.map +1 -0
  29. package/dist/esm/src/base.js +69 -0
  30. package/dist/esm/src/base.js.map +1 -0
  31. package/dist/esm/src/common.js +162 -0
  32. package/dist/esm/src/common.js.map +1 -0
  33. package/dist/esm/src/configuration.js +45 -0
  34. package/dist/esm/src/configuration.js.map +1 -0
  35. package/dist/esm/src/index.js +23 -0
  36. package/dist/esm/src/index.js.map +1 -0
  37. package/dist/esm/src/request-signer.js +231 -0
  38. package/dist/esm/src/request-signer.js.map +1 -0
  39. package/dist/esm/src/sdk.js +786 -0
  40. package/dist/esm/src/sdk.js.map +1 -0
  41. package/dist/esm/src/utils.js +10 -0
  42. package/dist/esm/src/utils.js.map +1 -0
  43. package/dist/esm/src/websocket.js +159 -0
  44. package/dist/esm/src/websocket.js.map +1 -0
  45. package/dist/types/example.d.ts +2 -0
  46. package/dist/types/example.d.ts.map +1 -0
  47. package/dist/types/index.d.ts +2 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/{src → types/src}/api.d.ts +126 -47
  50. package/dist/types/src/api.d.ts.map +1 -0
  51. package/dist/{src → types/src}/base.d.ts +1 -0
  52. package/dist/types/src/base.d.ts.map +1 -0
  53. package/dist/{src → types/src}/common.d.ts +1 -0
  54. package/dist/types/src/common.d.ts.map +1 -0
  55. package/dist/{src → types/src}/configuration.d.ts +1 -0
  56. package/dist/types/src/configuration.d.ts.map +1 -0
  57. package/dist/{src → types/src}/index.d.ts +1 -0
  58. package/dist/types/src/index.d.ts.map +1 -0
  59. package/dist/{src → types/src}/request-signer.d.ts +6 -1
  60. package/dist/types/src/request-signer.d.ts.map +1 -0
  61. package/dist/{src → types/src}/sdk.d.ts +12 -1
  62. package/dist/types/src/sdk.d.ts.map +1 -0
  63. package/dist/{src → types/src}/utils.d.ts +1 -0
  64. package/dist/types/src/utils.d.ts.map +1 -0
  65. package/dist/{src → types/src}/websocket.d.ts +1 -0
  66. package/dist/types/src/websocket.d.ts.map +1 -0
  67. package/package.json +21 -7
  68. package/dist/example.d.ts +0 -1
  69. package/dist/index.d.ts +0 -1
  70. package/example.ts +0 -323
  71. package/index.ts +0 -1
  72. package/openapitools.json +0 -24
  73. package/src/.openapi-generator/FILES +0 -128
  74. package/src/.openapi-generator/VERSION +0 -1
  75. package/src/.openapi-generator-ignore +0 -28
  76. package/src/README.md +0 -46
  77. package/src/api.ts +0 -8918
  78. package/src/base.ts +0 -86
  79. package/src/common.ts +0 -150
  80. package/src/configuration.ts +0 -115
  81. package/src/docs/Account.md +0 -64
  82. package/src/docs/AccountAggregatedTradeUpdate.md +0 -21
  83. package/src/docs/AccountAuthorizationRequest.md +0 -24
  84. package/src/docs/AccountAuthorizationRequestSignedFields.md +0 -28
  85. package/src/docs/AccountCommandFailureUpdate.md +0 -29
  86. package/src/docs/AccountDataApi.md +0 -374
  87. package/src/docs/AccountDataStream.md +0 -21
  88. package/src/docs/AccountEventReason.md +0 -25
  89. package/src/docs/AccountEventType.md +0 -21
  90. package/src/docs/AccountFundingRateHistory.md +0 -20
  91. package/src/docs/AccountFundingRateHistoryData.md +0 -30
  92. package/src/docs/AccountMarketPreference.md +0 -22
  93. package/src/docs/AccountOrderUpdate.md +0 -71
  94. package/src/docs/AccountPositionLeverageUpdateRequest.md +0 -22
  95. package/src/docs/AccountPositionLeverageUpdateRequestSignedFields.md +0 -30
  96. package/src/docs/AccountPositionUpdate.md +0 -47
  97. package/src/docs/AccountPreference.md +0 -24
  98. package/src/docs/AccountStreamMessage.md +0 -25
  99. package/src/docs/AccountStreamMessagePayload.md +0 -153
  100. package/src/docs/AccountSubscriptionMessage.md +0 -25
  101. package/src/docs/AccountTradeUpdate.md +0 -21
  102. package/src/docs/AccountTransactionUpdate.md +0 -31
  103. package/src/docs/AccountUpdate.md +0 -61
  104. package/src/docs/ActiveOrderUpdate.md +0 -65
  105. package/src/docs/AdjustIsolatedMarginRequest.md +0 -22
  106. package/src/docs/AdjustIsolatedMarginRequestSignedFields.md +0 -32
  107. package/src/docs/AdjustMarginOperation.md +0 -11
  108. package/src/docs/AffiliateIntervalOverview.md +0 -56
  109. package/src/docs/AffiliateLeaderDashboard.md +0 -38
  110. package/src/docs/AffiliateMetadata.md +0 -36
  111. package/src/docs/AffiliateMetadataFees.md +0 -31
  112. package/src/docs/AffiliateOnboardResponse.md +0 -22
  113. package/src/docs/AffiliateOverview.md +0 -46
  114. package/src/docs/AffiliateSummary.md +0 -30
  115. package/src/docs/Asset.md +0 -29
  116. package/src/docs/AssetConfig.md +0 -28
  117. package/src/docs/AuthApi.md +0 -243
  118. package/src/docs/AuthorizedWallet.md +0 -24
  119. package/src/docs/CampaignMetadata.md +0 -28
  120. package/src/docs/CampaignRewards.md +0 -18
  121. package/src/docs/CancelOrdersRequest.md +0 -23
  122. package/src/docs/CancelOrdersResponse.md +0 -21
  123. package/src/docs/CandlePriceType.md +0 -14
  124. package/src/docs/CandlestickUpdate.md +0 -41
  125. package/src/docs/CommandFailureReasonCode.md +0 -24
  126. package/src/docs/ContractsConfig.md +0 -31
  127. package/src/docs/CreateOrderRequest.md +0 -36
  128. package/src/docs/CreateOrderRequestSignedFields.md +0 -40
  129. package/src/docs/CreateOrderResponse.md +0 -20
  130. package/src/docs/EpochConfigs.md +0 -34
  131. package/src/docs/EpochConfigsResponse.md +0 -24
  132. package/src/docs/EpochMetadata.md +0 -30
  133. package/src/docs/Error.md +0 -22
  134. package/src/docs/ExchangeApi.md +0 -473
  135. package/src/docs/ExchangeInfoResponse.md +0 -30
  136. package/src/docs/FailedCommandType.md +0 -12
  137. package/src/docs/FeeConfigs.md +0 -33
  138. package/src/docs/FundingRateEntry.md +0 -24
  139. package/src/docs/GetAffiliateIntervalOverview200Response.md +0 -26
  140. package/src/docs/GetAffiliateLeaderDashboard200Response.md +0 -26
  141. package/src/docs/GetAffiliateOverview200Response.md +0 -26
  142. package/src/docs/IntervalMetadata.md +0 -28
  143. package/src/docs/IntervalRewards.md +0 -30
  144. package/src/docs/KlineInterval.md +0 -36
  145. package/src/docs/LoginRequest.md +0 -25
  146. package/src/docs/LoginResponse.md +0 -26
  147. package/src/docs/MarginType.md +0 -13
  148. package/src/docs/MarkPriceUpdate.md +0 -26
  149. package/src/docs/Market.md +0 -82
  150. package/src/docs/MarketDataStreamName.md +0 -142
  151. package/src/docs/MarketEventType.md +0 -25
  152. package/src/docs/MarketPriceUpdate.md +0 -26
  153. package/src/docs/MarketStatus.md +0 -16
  154. package/src/docs/MarketStreamMessage.md +0 -23
  155. package/src/docs/MarketStreamMessagePayload.md +0 -123
  156. package/src/docs/MarketSubscriptionMessage.md +0 -23
  157. package/src/docs/MarketSubscriptionStreams.md +0 -23
  158. package/src/docs/OnboardAffiliateRequest.md +0 -26
  159. package/src/docs/OnboardAffiliateRequestSocialUserNames.md +0 -27
  160. package/src/docs/OnboardRefereeRequest.md +0 -20
  161. package/src/docs/OpenOrderResponse.md +0 -64
  162. package/src/docs/Operators.md +0 -28
  163. package/src/docs/OraclePriceUpdate.md +0 -26
  164. package/src/docs/OrderCancelReason.md +0 -65
  165. package/src/docs/OrderCancellationFailureReason.md +0 -19
  166. package/src/docs/OrderCancellationUpdate.md +0 -35
  167. package/src/docs/OrderSide.md +0 -13
  168. package/src/docs/OrderStatus.md +0 -25
  169. package/src/docs/OrderTimeInForce.md +0 -15
  170. package/src/docs/OrderType.md +0 -29
  171. package/src/docs/OrderbookDepthResponse.md +0 -38
  172. package/src/docs/OrderbookDiffDepthUpdate.md +0 -30
  173. package/src/docs/OrderbookPartialDepthUpdate.md +0 -30
  174. package/src/docs/Position.md +0 -52
  175. package/src/docs/PositionSide.md +0 -13
  176. package/src/docs/RecentTradesUpdates.md +0 -20
  177. package/src/docs/RefereeOnboardResponse.md +0 -20
  178. package/src/docs/RefreshTokenRequest.md +0 -20
  179. package/src/docs/RefreshTokenResponse.md +0 -26
  180. package/src/docs/RewardsApi.md +0 -859
  181. package/src/docs/RewardsSummary.md +0 -26
  182. package/src/docs/SelfTradePreventionType.md +0 -15
  183. package/src/docs/StatsEntry.md +0 -26
  184. package/src/docs/StatsInterval.md +0 -14
  185. package/src/docs/StatsResponse.md +0 -20
  186. package/src/docs/StreamsApi.md +0 -126
  187. package/src/docs/SubscriptionResponseMessage.md +0 -23
  188. package/src/docs/SubscriptionType.md +0 -11
  189. package/src/docs/TickerAllUpdate.md +0 -20
  190. package/src/docs/TickerResponse.md +0 -82
  191. package/src/docs/TickerUpdate.md +0 -83
  192. package/src/docs/Trade.md +0 -54
  193. package/src/docs/TradeApi.md +0 -589
  194. package/src/docs/TradeSide.md +0 -13
  195. package/src/docs/TradeType.md +0 -15
  196. package/src/docs/TradingFees.md +0 -24
  197. package/src/docs/Transaction.md +0 -34
  198. package/src/docs/TransactionType.md +0 -25
  199. package/src/docs/UpdateAccountPreferenceRequest.md +0 -24
  200. package/src/docs/UpdateAffiliateFeeConfigRequest.md +0 -20
  201. package/src/docs/UserCampaignRewards.md +0 -48
  202. package/src/docs/WithdrawRequest.md +0 -22
  203. package/src/docs/WithdrawRequestSignedFields.md +0 -30
  204. package/src/git_push.sh +0 -57
  205. package/src/index.ts +0 -6
  206. package/src/request-signer.ts +0 -405
  207. package/src/sdk.ts +0 -982
  208. package/src/utils.ts +0 -6
  209. package/src/websocket.ts +0 -165
  210. package/tsconfig.json +0 -23
@@ -1,24 +0,0 @@
1
- # UpdateAccountPreferenceRequest
2
-
3
-
4
- ## Properties
5
-
6
- Name | Type | Description | Notes
7
- ------------ | ------------- | ------------- | -------------
8
- **language** | **string** | User preferred language. | [optional] [default to undefined]
9
- **theme** | **string** | User preferred theme. | [optional] [default to undefined]
10
- **market** | [**Array<AccountMarketPreference>**](AccountMarketPreference.md) | | [optional] [default to undefined]
11
-
12
- ## Example
13
-
14
- ```typescript
15
- import { UpdateAccountPreferenceRequest } from '@bluefin/api-client';
16
-
17
- const instance: UpdateAccountPreferenceRequest = {
18
- language,
19
- theme,
20
- market,
21
- };
22
- ```
23
-
24
- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -1,20 +0,0 @@
1
- # UpdateAffiliateFeeConfigRequest
2
-
3
-
4
- ## Properties
5
-
6
- Name | Type | Description | Notes
7
- ------------ | ------------- | ------------- | -------------
8
- **cashback** | **number** | Cashback amount to give to the referees | [default to undefined]
9
-
10
- ## Example
11
-
12
- ```typescript
13
- import { UpdateAffiliateFeeConfigRequest } from '@bluefin/api-client';
14
-
15
- const instance: UpdateAffiliateFeeConfigRequest = {
16
- cashback,
17
- };
18
- ```
19
-
20
- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -1,48 +0,0 @@
1
- # UserCampaignRewards
2
-
3
-
4
- ## Properties
5
-
6
- Name | Type | Description | Notes
7
- ------------ | ------------- | ------------- | -------------
8
- **userAddress** | **string** | User address for the rewards earned data. | [default to undefined]
9
- **campaignName** | **string** | Name of the campaign. | [default to undefined]
10
- **epochNumber** | **number** | Epoch number for the rewards earned data. | [default to undefined]
11
- **intervalNumber** | **number** | Interval number for the rewards earned data. | [default to undefined]
12
- **symbol** | **string** | Market Symbol. | [default to undefined]
13
- **status** | **string** | | [default to undefined]
14
- **blueRewardsE9** | **string** | Total blue-perp token rewards earned in the epoch (e9 format). | [default to undefined]
15
- **suiRewardsE9** | **string** | Total sui-perp token rewards earned in the epoch (e9 format). | [default to undefined]
16
- **walRewardsE9** | **string** | Total wal-perp rewards earned in the epoch (e9 format). | [default to undefined]
17
- **cashRewardsE9** | **string** | Total cash rewards earned in the epoch (e9 format). | [default to undefined]
18
- **userFeePaidE9** | **string** | Total user fee paid in the epoch (e9 format). | [default to undefined]
19
- **intervalStartDate** | **number** | Time in seconds for interval start date. | [default to undefined]
20
- **intervalEndDate** | **number** | Time in seconds for interval end date. | [default to undefined]
21
- **isDisbursed** | **boolean** | Indicates if the rewards have been disbursed. | [default to undefined]
22
- **txnDigest** | **string** | Transaction digest of the disbursement. | [default to undefined]
23
-
24
- ## Example
25
-
26
- ```typescript
27
- import { UserCampaignRewards } from '@bluefin/api-client';
28
-
29
- const instance: UserCampaignRewards = {
30
- userAddress,
31
- campaignName,
32
- epochNumber,
33
- intervalNumber,
34
- symbol,
35
- status,
36
- blueRewardsE9,
37
- suiRewardsE9,
38
- walRewardsE9,
39
- cashRewardsE9,
40
- userFeePaidE9,
41
- intervalStartDate,
42
- intervalEndDate,
43
- isDisbursed,
44
- txnDigest,
45
- };
46
- ```
47
-
48
- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -1,22 +0,0 @@
1
- # WithdrawRequest
2
-
3
-
4
- ## Properties
5
-
6
- Name | Type | Description | Notes
7
- ------------ | ------------- | ------------- | -------------
8
- **signedFields** | [**WithdrawRequestSignedFields**](WithdrawRequestSignedFields.md) | | [default to undefined]
9
- **signature** | **string** | The signature of the request, encoded from the signedFields | [default to undefined]
10
-
11
- ## Example
12
-
13
- ```typescript
14
- import { WithdrawRequest } from '@bluefin/api-client';
15
-
16
- const instance: WithdrawRequest = {
17
- signedFields,
18
- signature,
19
- };
20
- ```
21
-
22
- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
@@ -1,30 +0,0 @@
1
- # WithdrawRequestSignedFields
2
-
3
-
4
- ## Properties
5
-
6
- Name | Type | Description | Notes
7
- ------------ | ------------- | ------------- | -------------
8
- **assetSymbol** | **string** | Asset symbol of the withdrawn asset | [default to undefined]
9
- **accountAddress** | **string** | The Account Address from which to withdraw assets | [default to undefined]
10
- **amountE9** | **string** | The amount in e9 of the asset that the User will withdraw from their account | [default to undefined]
11
- **salt** | **string** | A uniqueness modifier for the request. This is added to guarantee uniqueness of the request. Usually a mix of timestamp and a random number | [default to undefined]
12
- **edsId** | **string** | the ID of the external datastore for the target network | [default to undefined]
13
- **signedAtMillis** | **number** | The timestamp in milliseconds when the HTTP Request payload has been signed | [default to undefined]
14
-
15
- ## Example
16
-
17
- ```typescript
18
- import { WithdrawRequestSignedFields } from '@bluefin/api-client';
19
-
20
- const instance: WithdrawRequestSignedFields = {
21
- assetSymbol,
22
- accountAddress,
23
- amountE9,
24
- salt,
25
- edsId,
26
- signedAtMillis,
27
- };
28
- ```
29
-
30
- [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
package/src/git_push.sh DELETED
@@ -1,57 +0,0 @@
1
- #!/bin/sh
2
- # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
- #
4
- # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
-
6
- git_user_id=$1
7
- git_repo_id=$2
8
- release_note=$3
9
- git_host=$4
10
-
11
- if [ "$git_host" = "" ]; then
12
- git_host="github.com"
13
- echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
- fi
15
-
16
- if [ "$git_user_id" = "" ]; then
17
- git_user_id="GIT_USER_ID"
18
- echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
- fi
20
-
21
- if [ "$git_repo_id" = "" ]; then
22
- git_repo_id="GIT_REPO_ID"
23
- echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
- fi
25
-
26
- if [ "$release_note" = "" ]; then
27
- release_note="Minor update"
28
- echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
- fi
30
-
31
- # Initialize the local directory as a Git repository
32
- git init
33
-
34
- # Adds the files in the local repository and stages them for commit.
35
- git add .
36
-
37
- # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
- git commit -m "$release_note"
39
-
40
- # Sets the new remote
41
- git_remote=$(git remote)
42
- if [ "$git_remote" = "" ]; then # git remote not defined
43
-
44
- if [ "$GIT_TOKEN" = "" ]; then
45
- echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
- git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
- else
48
- git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
- fi
50
-
51
- fi
52
-
53
- git pull origin master
54
-
55
- # Pushes (Forces) the changes in the local repository up to the remote repository
56
- echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
- git push origin master 2>&1 | grep -v 'To https'
package/src/index.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from "./api";
2
- export * from "./configuration";
3
- export * from "./sdk";
4
- export * from "./request-signer";
5
- export * from "./utils";
6
- export * from "./websocket";
@@ -1,405 +0,0 @@
1
- import {
2
- Keypair,
3
- Signer,
4
- parseSerializedSignature,
5
- } from "@mysten/sui/cryptography";
6
- import {
7
- LoginRequest,
8
- AccountPositionLeverageUpdateRequestSignedFields,
9
- CreateOrderRequestSignedFields,
10
- WithdrawRequestSignedFields,
11
- AccountAuthorizationRequestSignedFields,
12
- AdjustMarginOperation,
13
- AdjustIsolatedMarginRequestSignedFields,
14
- } from "./api";
15
- import {
16
- DryRunTransactionBlockResponse,
17
- SuiBlocks,
18
- SuiClient,
19
- SuiTransactionBlockResponse,
20
- TransactionBlock,
21
- } from "@firefly-exchange/library-sui";
22
-
23
- export interface IBluefinSigner {
24
- getAddress(): string;
25
- signLeverageUpdateRequest: (
26
- fields: AccountPositionLeverageUpdateRequestSignedFields
27
- ) => Promise<string>;
28
- signOrderRequest: (fields: CreateOrderRequestSignedFields) => Promise<string>;
29
- signWithdrawRequest: (fields: WithdrawRequestSignedFields) => Promise<string>;
30
- signAccountAuthorizationRequest: (fields: AccountAuthorizationRequestSignedFields, isAuthorize: boolean) => Promise<string>;
31
- signAdjustIsolatedMarginRequest: (fields: AdjustIsolatedMarginRequestSignedFields) => Promise<string>;
32
- signLoginRequest: (request: LoginRequest) => Promise<string>;
33
- executeTx: (
34
- txb: TransactionBlock,
35
- suiClient: SuiClient
36
- ) => Promise<DryRunTransactionBlockResponse | SuiTransactionBlockResponse>;
37
- }
38
-
39
- export interface ISigner {
40
- toSuiAddress(): string;
41
- isUIWallet(): boolean;
42
- }
43
-
44
-
45
- export function makeSigner<T extends Keypair>(
46
- keyPair: T,
47
- isUIWallet: boolean,
48
- ): T & ISigner {
49
- return Object.assign(keyPair, {
50
- toSuiAddress: () => keyPair.getPublicKey().toSuiAddress(),
51
- isUIWallet: () => isUIWallet
52
- });
53
- }
54
-
55
- // ------- ISerializables ---------
56
-
57
- // Enums
58
- enum ClientPayloadType {
59
- WithdrawRequest = "Bluefin Pro Withdrawal",
60
- OrderRequest = "Bluefin Pro Order",
61
- LeverageAdjustment = "Bluefin Pro Leverage Adjustment",
62
- AuthorizeAccount = "Bluefin Pro Authorize Account",
63
- AdjustIsolatedMargin = "Bluefin Pro Margin Adjustment",
64
- }
65
-
66
- enum PositionType {
67
- Isolated = "ISOLATED",
68
- Cross = "CROSS",
69
- }
70
-
71
- // Interfaces
72
- interface UIWithdrawRequest {
73
- type: string;
74
- eds: string;
75
- assetSymbol: string;
76
- account: string;
77
- amount: string;
78
- salt: string;
79
- signedAt: string;
80
- }
81
-
82
- interface UICreateOrderRequest {
83
- type: string;
84
- ids: string;
85
- account: string;
86
- market: string;
87
- price: string;
88
- quantity: string;
89
- leverage: string;
90
- side: string;
91
- positionType: string;
92
- expiration: string;
93
- salt: string;
94
- signedAt: string;
95
- }
96
-
97
- interface UIUpdateAccountPositionLeverageRequest {
98
- type: string;
99
- ids: string;
100
- account: string;
101
- market: string;
102
- leverage: string;
103
- salt: string;
104
- signedAt: string;
105
- }
106
-
107
- interface UIAuthorizeAccountRequest {
108
- type: string;
109
- ids: string;
110
- account: string;
111
- user: string;
112
- status: boolean;
113
- salt: string;
114
- signedAt: string;
115
- }
116
-
117
- interface UIDeAuthorizeAccountRequest {
118
- type: string;
119
- ids: string;
120
- account: string;
121
- user: string;
122
- status: boolean;
123
- salt: string;
124
- signedAt: string;
125
- }
126
-
127
- interface UIAdjustIsolatedMarginRequest {
128
- type: string;
129
- ids: string;
130
- account: string;
131
- market: string;
132
- add: boolean;
133
- amount: string;
134
- salt: string;
135
- signedAt: string;
136
- }
137
-
138
- // Conversion functions
139
- function toUIWithdrawRequest(
140
- val: WithdrawRequestSignedFields
141
- ): UIWithdrawRequest {
142
- return {
143
- type: ClientPayloadType.WithdrawRequest,
144
- eds: val.edsId,
145
- assetSymbol: val.assetSymbol,
146
- account: val.accountAddress,
147
- amount: val.amountE9,
148
- salt: val.salt,
149
- signedAt: val.signedAtMillis.toString(),
150
- };
151
- }
152
-
153
- function toUICreateOrderRequest(
154
- val: CreateOrderRequestSignedFields
155
- ): UICreateOrderRequest {
156
- return {
157
- type: ClientPayloadType.OrderRequest,
158
- ids: val.idsId,
159
- account: val.accountAddress,
160
- market: val.symbol,
161
- price: val.priceE9,
162
- quantity: val.quantityE9,
163
- leverage: val.leverageE9,
164
- side: val.side.toString(),
165
- positionType: val.isIsolated ? PositionType.Isolated : PositionType.Cross,
166
- expiration: val.expiresAtMillis.toString(),
167
- salt: val.salt,
168
- signedAt: val.signedAtMillis.toString(),
169
- };
170
- }
171
-
172
- function toUIUpdateAccountPositionLeverageRequest(
173
- val: AccountPositionLeverageUpdateRequestSignedFields
174
- ): UIUpdateAccountPositionLeverageRequest {
175
- return {
176
- type: ClientPayloadType.LeverageAdjustment,
177
- ids: val.idsId,
178
- account: val.accountAddress,
179
- market: val.symbol,
180
- leverage: val.leverageE9,
181
- salt: val.salt,
182
- signedAt: val.signedAtMillis.toString(),
183
- };
184
- }
185
-
186
- function toUIAuthorizeAccountRequest(
187
- val: AccountAuthorizationRequestSignedFields
188
- ): UIAuthorizeAccountRequest {
189
- return {
190
- type: ClientPayloadType.AuthorizeAccount,
191
- ids: val.idsId,
192
- account: val.accountAddress,
193
- user: val.authorizedAccountAddress,
194
- status: true,
195
- salt: val.salt,
196
- signedAt: val.signedAtMillis.toString(),
197
- };
198
- }
199
-
200
- function toUIDeAuthorizeAccountRequest(
201
- val: AccountAuthorizationRequestSignedFields
202
- ): UIDeAuthorizeAccountRequest {
203
- return {
204
- type: ClientPayloadType.AuthorizeAccount,
205
- ids: val.idsId,
206
- account: val.accountAddress,
207
- user: val.authorizedAccountAddress,
208
- status: false,
209
- salt: val.salt,
210
- signedAt: val.signedAtMillis.toString(),
211
- };
212
- }
213
-
214
- function toUIAdjustIsolatedMarginRequest(
215
- val: AdjustIsolatedMarginRequestSignedFields
216
- ): UIAdjustIsolatedMarginRequest {
217
- return {
218
- type: ClientPayloadType.AdjustIsolatedMargin,
219
- ids: val.idsId,
220
- account: val.accountAddress,
221
- market: val.symbol,
222
- add: val.operation === AdjustMarginOperation.Add,
223
- amount: val.quantityE9,
224
- salt: val.salt,
225
- signedAt: val.signedAtMillis.toString(),
226
- };
227
- }
228
-
229
- // ---------- Utils ----------
230
-
231
- function toJson(
232
- val:
233
- | UICreateOrderRequest
234
- | UIUpdateAccountPositionLeverageRequest
235
- | UIWithdrawRequest
236
- | UIAuthorizeAccountRequest
237
- | UIDeAuthorizeAccountRequest
238
- | UIAdjustIsolatedMarginRequest
239
- ): string {
240
- return JSON.stringify(val, null, 2);
241
- }
242
-
243
- // --------------------------------
244
-
245
- export class BluefinRequestSigner implements IBluefinSigner {
246
- constructor(
247
- private readonly wallet: Pick<Signer, "signPersonalMessage"> & ISigner
248
- ) {}
249
-
250
- /**
251
- * Sign the login request
252
- */
253
- async signLoginRequest(loginRequest: LoginRequest): Promise<string> {
254
- const loginRequestJson = JSON.stringify(loginRequest);
255
-
256
- const signedMessage = await this.wallet.signPersonalMessage(
257
- new TextEncoder().encode(loginRequestJson)
258
- );
259
- return signedMessage.signature;
260
- }
261
-
262
- /**
263
- * Sign an order request
264
- */
265
- async signOrderRequest(
266
- signedFields: CreateOrderRequestSignedFields
267
- ): Promise<string> {
268
- const orderJson = toJson(toUICreateOrderRequest(signedFields));
269
-
270
- const signedMessageSerialized = await this.wallet.signPersonalMessage(
271
- new TextEncoder().encode(orderJson)
272
- );
273
-
274
- const parsedSignature = parseSerializedSignature(
275
- signedMessageSerialized.signature
276
- );
277
-
278
- if (parsedSignature.signatureScheme == "MultiSig") {
279
- throw new Error("MultiSig not supported");
280
- }
281
-
282
- return signedMessageSerialized.signature;
283
- }
284
-
285
- /**
286
- * Sign a withdraw request
287
- */
288
- async signWithdrawRequest(
289
- withdrawRequestSignedFields: WithdrawRequestSignedFields
290
- ): Promise<string> {
291
- const requestJson = toJson(
292
- toUIWithdrawRequest(withdrawRequestSignedFields)
293
- );
294
-
295
- const signedMessageSerialized = await this.wallet.signPersonalMessage(
296
- new TextEncoder().encode(requestJson)
297
- );
298
-
299
- const parsedSignature = parseSerializedSignature(
300
- signedMessageSerialized.signature
301
- );
302
-
303
- if (parsedSignature.signatureScheme == "MultiSig") {
304
- throw new Error("MultiSig not supported");
305
- }
306
-
307
- return signedMessageSerialized.signature;
308
- }
309
-
310
- /**
311
- * Sign a leverage update request
312
- */
313
- async signLeverageUpdateRequest(
314
- signedFields: AccountPositionLeverageUpdateRequestSignedFields
315
- ): Promise<string> {
316
- const requestJson = toJson(
317
- toUIUpdateAccountPositionLeverageRequest(signedFields)
318
- );
319
-
320
- const signedMessageSerialized = await this.wallet.signPersonalMessage(
321
- new TextEncoder().encode(requestJson)
322
- );
323
-
324
- const parsedSignature = parseSerializedSignature(
325
- signedMessageSerialized.signature
326
- );
327
-
328
- if (parsedSignature.signatureScheme == "MultiSig") {
329
- throw new Error("MultiSig not supported");
330
- }
331
-
332
- return signedMessageSerialized.signature;
333
- }
334
-
335
- /**
336
- * Sign an account authorization request
337
- */
338
- async signAccountAuthorizationRequest(
339
- signedFields: AccountAuthorizationRequestSignedFields,
340
- is_authorize: boolean
341
- ): Promise<string> {
342
- const requestJson = toJson(
343
- is_authorize
344
- ? toUIAuthorizeAccountRequest(signedFields)
345
- : toUIDeAuthorizeAccountRequest(signedFields)
346
- );
347
-
348
- const signedMessageSerialized = await this.wallet.signPersonalMessage(
349
- new TextEncoder().encode(requestJson)
350
- );
351
-
352
- const parsedSignature = parseSerializedSignature(
353
- signedMessageSerialized.signature
354
- );
355
-
356
- if (parsedSignature.signatureScheme == "MultiSig") {
357
- throw new Error("MultiSig not supported");
358
- }
359
-
360
- return signedMessageSerialized.signature;
361
- }
362
-
363
- /**
364
- * Sign an isolated margin adjustment request
365
- */
366
- async signAdjustIsolatedMarginRequest(
367
- signedFields: AdjustIsolatedMarginRequestSignedFields
368
- ): Promise<string> {
369
- const requestJson = toJson(
370
- toUIAdjustIsolatedMarginRequest(signedFields)
371
- );
372
-
373
- const signedMessageSerialized = await this.wallet.signPersonalMessage(
374
- new TextEncoder().encode(requestJson)
375
- );
376
-
377
- const parsedSignature = parseSerializedSignature(
378
- signedMessageSerialized.signature
379
- );
380
-
381
- if (parsedSignature.signatureScheme == "MultiSig") {
382
- throw new Error("MultiSig not supported");
383
- }
384
-
385
- return signedMessageSerialized.signature;
386
- }
387
-
388
- async executeTx(txb: TransactionBlock, suiClient: SuiClient) {
389
- return SuiBlocks.execCall(txb, suiClient, this.wallet, false, this.wallet.isUIWallet());
390
- }
391
-
392
- /**
393
- * Get the wallet's address
394
- */
395
- getAddress(): string {
396
- return this.wallet.toSuiAddress();
397
- }
398
-
399
- /**
400
- * Get the wallet type (ui wallet or backend)
401
- */
402
- isUIWallet(): boolean {
403
- return this.wallet.isUIWallet();
404
- }
405
- }