@deriverse/kit 1.0.20 → 1.0.22

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/index.js CHANGED
@@ -1827,10 +1827,13 @@ class Engine {
1827
1827
  */
1828
1828
  depositInstruction(args) {
1829
1829
  return __awaiter(this, void 0, void 0, function* () {
1830
+ var _a, _b;
1830
1831
  const exists = yield this.checkClient();
1831
1832
  if (this.signer == null) {
1832
1833
  throw new Error("Wallet is not connected");
1833
1834
  }
1835
+ const amount = (_a = args.amount) !== null && _a !== void 0 ? _a : 0;
1836
+ const allFunds = (_b = args.all_funds) !== null && _b !== void 0 ? _b : false;
1834
1837
  const token = this.tokens.get(args.tokenId);
1835
1838
  const tokenProgramId = (token.mask & 0x80000000) != 0 ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID;
1836
1839
  const clientTokenAccount = yield findAssociatedTokenAddress(this.signer, tokenProgramId, token.address);
@@ -1853,7 +1856,7 @@ class Engine {
1853
1856
  return {
1854
1857
  accounts: keys,
1855
1858
  programAddress: this.programId,
1856
- data: (0, instruction_models_1.depositData)(7, args.tokenId, args.amount * this.tokenDec(args.tokenId), 0, 0)
1859
+ data: (0, instruction_models_1.depositData)(7, args.tokenId, amount * this.tokenDec(args.tokenId), 0, 0, allFunds)
1857
1860
  };
1858
1861
  }
1859
1862
  else {
@@ -1883,7 +1886,7 @@ class Engine {
1883
1886
  return {
1884
1887
  accounts: keys,
1885
1888
  programAddress: this.programId,
1886
- data: (0, instruction_models_1.depositData)(7, args.tokenId, args.amount * this.tokenDec(args.tokenId), slot, refId)
1889
+ data: (0, instruction_models_1.depositData)(7, args.tokenId, amount * this.tokenDec(args.tokenId), slot, refId, allFunds)
1887
1890
  };
1888
1891
  }
1889
1892
  });
@@ -10,7 +10,7 @@ export declare function spotOrderCancelData(tag: number, side: number, instrId:
10
10
  export declare function spotMassCancelData(tag: number, instrId: number): Buffer;
11
11
  export declare function spotLpData(tag: number, side: number, instrId: number, amount: number): Buffer;
12
12
  export declare function newInstrumentData(tag: number, crncyTokenId: number, lutSlot: number, price: number): Buffer;
13
- export declare function depositData(tag: number, tokenId: number, amount: number, lutSlot: number, refId: number): Buffer;
13
+ export declare function depositData(tag: number, tokenId: number, amount: number, lutSlot: number, refId: number, allFunds: boolean): Buffer;
14
14
  export declare function feesDepositData(tag: number, tokenId: number, amount: number): Buffer;
15
15
  export declare function feesWithdrawData(tag: number, tokenId: number, amount: number): Buffer;
16
16
  export declare function perpDepositData(tag: number, instrId: number, amount: number): Buffer;
@@ -26,8 +26,8 @@ function newSpotOrderData(tag, ioc, orderType, side, instrId, price, amount) {
26
26
  buf.writeUint8(orderType, 2);
27
27
  buf.writeUint8(side, 3);
28
28
  buf.writeUint32LE(instrId, 4);
29
- buf.writeBigInt64LE(BigInt(price), 8);
30
- buf.writeBigInt64LE(BigInt(amount), 16);
29
+ buf.writeBigInt64LE(BigInt(Math.round(price)), 8);
30
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 16);
31
31
  return buf;
32
32
  }
33
33
  exports.newSpotOrderData = newSpotOrderData;
@@ -42,8 +42,8 @@ function newPerpOrderData(tag, ioc, leverage, orderType, side, instrId, price, a
42
42
  buf.writeUint16LE(0, 6);
43
43
  buf.writeUint32LE(0, 8);
44
44
  buf.writeUint32LE(instrId, 12);
45
- buf.writeBigInt64LE(BigInt(price), 16);
46
- buf.writeBigInt64LE(BigInt(amount), 24);
45
+ buf.writeBigInt64LE(BigInt(Math.round(price)), 16);
46
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 24);
47
47
  return buf;
48
48
  }
49
49
  exports.newPerpOrderData = newPerpOrderData;
@@ -71,7 +71,7 @@ function spotOrderCancelData(tag, side, instrId, orderId) {
71
71
  buf.writeUint8(side, 1);
72
72
  buf.writeUint16LE(0, 2);
73
73
  buf.writeUint32LE(instrId, 4);
74
- buf.writeBigInt64LE(BigInt(orderId), 8);
74
+ buf.writeBigInt64LE(BigInt(Math.round(orderId)), 8);
75
75
  return buf;
76
76
  }
77
77
  exports.spotOrderCancelData = spotOrderCancelData;
@@ -90,7 +90,7 @@ function spotLpData(tag, side, instrId, amount) {
90
90
  buf.writeUint8(side, 1);
91
91
  buf.writeUint16LE(0, 2);
92
92
  buf.writeUint32LE(instrId, 4);
93
- buf.writeBigInt64LE(BigInt(amount), 8);
93
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
94
94
  return buf;
95
95
  }
96
96
  exports.spotLpData = spotLpData;
@@ -102,17 +102,17 @@ function newInstrumentData(tag, crncyTokenId, lutSlot, price) {
102
102
  buf.writeUint32LE(0, 4);
103
103
  buf.writeUint32LE(crncyTokenId, 8);
104
104
  buf.writeUint32LE(lutSlot, 12);
105
- buf.writeBigInt64LE(BigInt(price), 16);
105
+ buf.writeBigInt64LE(BigInt(Math.round(price)), 16);
106
106
  return buf;
107
107
  }
108
108
  exports.newInstrumentData = newInstrumentData;
109
- function depositData(tag, tokenId, amount, lutSlot, refId) {
109
+ function depositData(tag, tokenId, amount, lutSlot, refId, allFunds) {
110
110
  let buf = Buffer.alloc(24);
111
111
  buf.writeUint8(tag, 0);
112
112
  buf.writeUint8(0, 1);
113
- buf.writeUint16LE(0, 2);
113
+ buf.writeUint16LE(allFunds ? 1 : 0, 2);
114
114
  buf.writeUint32LE(tokenId, 4);
115
- buf.writeBigInt64LE(BigInt(amount), 8);
115
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
116
116
  buf.writeUint32LE(lutSlot, 16);
117
117
  buf.writeUint32LE(refId, 20);
118
118
  return buf;
@@ -124,7 +124,7 @@ function feesDepositData(tag, tokenId, amount) {
124
124
  buf.writeUint8(0, 1);
125
125
  buf.writeUint16LE(0, 2);
126
126
  buf.writeUint32LE(tokenId, 4);
127
- buf.writeBigInt64LE(BigInt(amount), 8);
127
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
128
128
  return buf;
129
129
  }
130
130
  exports.feesDepositData = feesDepositData;
@@ -134,7 +134,7 @@ function feesWithdrawData(tag, tokenId, amount) {
134
134
  buf.writeUint8(0, 1);
135
135
  buf.writeUint16LE(0, 2);
136
136
  buf.writeUint32LE(tokenId, 4);
137
- buf.writeBigInt64LE(BigInt(amount), 8);
137
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
138
138
  return buf;
139
139
  }
140
140
  exports.feesWithdrawData = feesWithdrawData;
@@ -144,7 +144,7 @@ function perpDepositData(tag, instrId, amount) {
144
144
  buf.writeUint8(0, 1);
145
145
  buf.writeUint16LE(0, 2);
146
146
  buf.writeUint32LE(instrId, 4);
147
- buf.writeBigInt64LE(BigInt(amount), 8);
147
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
148
148
  return buf;
149
149
  }
150
150
  exports.perpDepositData = perpDepositData;
@@ -163,7 +163,7 @@ function perpWithdrawData(tag, instrId, amount) {
163
163
  buf.writeUint8(0, 1);
164
164
  buf.writeUint16LE(0, 2);
165
165
  buf.writeUint32LE(instrId, 4);
166
- buf.writeBigInt64LE(BigInt(amount), 8);
166
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
167
167
  return buf;
168
168
  }
169
169
  exports.perpWithdrawData = perpWithdrawData;
@@ -173,7 +173,7 @@ function withdrawData(tag, tokenId, amount) {
173
173
  buf.writeUint8(0, 1);
174
174
  buf.writeUint16LE(0, 2);
175
175
  buf.writeUint32LE(tokenId, 4);
176
- buf.writeBigInt64LE(BigInt(amount), 8);
176
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 8);
177
177
  return buf;
178
178
  }
179
179
  exports.withdrawData = withdrawData;
@@ -183,8 +183,8 @@ function swapData(tag, side, instrId, price, amount) {
183
183
  buf.writeUint8(side, 1);
184
184
  buf.writeUint16LE(0, 2);
185
185
  buf.writeUint32LE(instrId, 4);
186
- buf.writeBigInt64LE(BigInt(price), 8);
187
- buf.writeBigInt64LE(BigInt(amount), 16);
186
+ buf.writeBigInt64LE(BigInt(Math.round(price)), 8);
187
+ buf.writeBigInt64LE(BigInt(Math.round(amount)), 16);
188
188
  return buf;
189
189
  }
190
190
  exports.swapData = swapData;
@@ -194,12 +194,12 @@ function spotQuotesReplaceData(tag, instrId, newBidPrice, newBidQty, oldBidOrder
194
194
  buf.writeUint8(0, 1);
195
195
  buf.writeUint16LE(0, 2);
196
196
  buf.writeUint32LE(instrId, 4);
197
- buf.writeBigInt64LE(BigInt(newBidPrice), 8);
198
- buf.writeBigInt64LE(BigInt(newBidQty), 16);
199
- buf.writeBigInt64LE(BigInt(oldBidOrderId), 24);
200
- buf.writeBigInt64LE(BigInt(newAskPrice), 32);
201
- buf.writeBigInt64LE(BigInt(newAskQty), 40);
202
- buf.writeBigInt64LE(BigInt(oldAskOrderId), 48);
197
+ buf.writeBigInt64LE(BigInt(Math.round(newBidPrice)), 8);
198
+ buf.writeBigInt64LE(BigInt(Math.round(newBidQty)), 16);
199
+ buf.writeBigInt64LE(BigInt(Math.round(oldBidOrderId)), 24);
200
+ buf.writeBigInt64LE(BigInt(Math.round(newAskPrice)), 32);
201
+ buf.writeBigInt64LE(BigInt(Math.round(newAskQty)), 40);
202
+ buf.writeBigInt64LE(BigInt(Math.round(oldAskOrderId)), 48);
203
203
  return buf;
204
204
  }
205
205
  exports.spotQuotesReplaceData = spotQuotesReplaceData;
@@ -209,12 +209,12 @@ function perpQuotesReplaceData(tag, instrId, newBidPrice, newBidQty, oldBidOrder
209
209
  buf.writeUint8(0, 1);
210
210
  buf.writeUint16LE(0, 2);
211
211
  buf.writeUint32LE(instrId, 4);
212
- buf.writeBigInt64LE(BigInt(newBidPrice), 8);
213
- buf.writeBigInt64LE(BigInt(newBidQty), 16);
214
- buf.writeBigInt64LE(BigInt(oldBidOrderId), 24);
215
- buf.writeBigInt64LE(BigInt(newAskPrice), 32);
216
- buf.writeBigInt64LE(BigInt(newAskQty), 40);
217
- buf.writeBigInt64LE(BigInt(oldAskOrderId), 48);
212
+ buf.writeBigInt64LE(BigInt(Math.round(newBidPrice)), 8);
213
+ buf.writeBigInt64LE(BigInt(Math.round(newBidQty)), 16);
214
+ buf.writeBigInt64LE(BigInt(Math.round(oldBidOrderId)), 24);
215
+ buf.writeBigInt64LE(BigInt(Math.round(newAskPrice)), 32);
216
+ buf.writeBigInt64LE(BigInt(Math.round(newAskQty)), 40);
217
+ buf.writeBigInt64LE(BigInt(Math.round(oldAskOrderId)), 48);
218
218
  return buf;
219
219
  }
220
220
  exports.perpQuotesReplaceData = perpQuotesReplaceData;
@@ -278,7 +278,7 @@ function perpOrderCancelData(tag, side, instrId, orderId) {
278
278
  buf.writeUint8(side, 1);
279
279
  buf.writeUint16LE(0, 2);
280
280
  buf.writeUint32LE(instrId, 4);
281
- buf.writeBigInt64LE(BigInt(orderId), 8);
281
+ buf.writeBigInt64LE(BigInt(Math.round(orderId)), 8);
282
282
  return buf;
283
283
  }
284
284
  exports.perpOrderCancelData = perpOrderCancelData;
package/dist/types.d.ts CHANGED
@@ -357,9 +357,10 @@ export interface PerpOrderCancelArgs {
357
357
  */
358
358
  export interface DepositArgs {
359
359
  tokenId: number;
360
- amount: number;
360
+ amount?: number;
361
361
  refId?: number;
362
362
  refWallet?: Address;
363
+ all_funds?: boolean;
363
364
  }
364
365
  /**
365
366
  * Contains data about SPL tokens on main client account
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deriverse/kit",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",