@typus/typus-perp-sdk 1.1.32-codegen-exp34 → 1.1.32-codegen-exp36

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.
@@ -578,7 +578,7 @@ async function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
578
578
  ? "Order Filled (Open Position)"
579
579
  : x.sender == "0x978f65df8570a075298598a9965c18de9087f9e888eb3430fe20334f5c554cfd"
580
580
  ? "Force Close Position"
581
- : "Order Filled (Close Position)",
581
+ : x.order_type == "Increase" ? "Order Filled (Increase Position)" : "Order Filled (Close Position)",
582
582
  typeName: "OrderFilledEvent",
583
583
  order_id: x.order_id,
584
584
  position_id: x.position_id,
@@ -1,6 +1,12 @@
1
- import { Transaction } from "@mysten/sui/transactions";
1
+ import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
2
2
  import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
3
3
  import { TypusClient } from "../../src/client";
4
+ export declare function splitBidReceiptTx(client: TypusClient, tx: Transaction, input: {
5
+ index: string;
6
+ receipts: TransactionObjectArgument[];
7
+ share?: string;
8
+ recipient: string;
9
+ }): import("@mysten/sui/transactions").TransactionResult;
4
10
  export declare function createTradingOrderWithBidReceiptByAutoBid(client: TypusClient, tx: Transaction, input: {
5
11
  perpIndex: string;
6
12
  poolIndex: string;
@@ -12,6 +18,7 @@ export declare function createTradingOrderWithBidReceiptByAutoBid(client: TypusC
12
18
  bToken: TOKEN;
13
19
  signalIndex: string;
14
20
  strategyIndex: string;
21
+ share?: string;
15
22
  suiCoins?: string[];
16
23
  }): Promise<Transaction>;
17
24
  export declare function createTradingOrderWithBidReceipt(client: TypusClient, tx: Transaction, input: {
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitBidReceiptTx = splitBidReceiptTx;
3
4
  exports.createTradingOrderWithBidReceiptByAutoBid = createTradingOrderWithBidReceiptByAutoBid;
4
5
  exports.createTradingOrderWithBidReceipt = createTradingOrderWithBidReceipt;
5
6
  exports.reduceOptionCollateralPositionSize = reduceOptionCollateralPositionSize;
@@ -9,6 +10,32 @@ const constants_1 = require("@typus/typus-sdk/dist/src/constants");
9
10
  const typus_dov_single_v2_1 = require("@typus/typus-sdk/dist/src/typus-dov-single-v2");
10
11
  const user_entry_1 = require("@typus/typus-sdk/dist/src/auto-bid/user-entry");
11
12
  const __1 = require("..");
13
+ function splitBidReceiptTx(client, tx, input) {
14
+ let result = tx.moveCall({
15
+ target: `${client.config.package.dovSingle}::tds_user_entry::simple_split_bid_receipt`,
16
+ typeArguments: [],
17
+ arguments: [
18
+ tx.object(client.config.registry.dov.dovSingle),
19
+ tx.pure.u64(input.index),
20
+ tx.makeMoveVec({
21
+ type: `${client.config.packageOrigin.framework}::vault::TypusBidReceipt`,
22
+ elements: input.receipts.map((receipt) => tx.object(receipt)),
23
+ }),
24
+ tx.pure.option("u64", input.share),
25
+ ],
26
+ });
27
+ let unwrap0 = tx.moveCall({
28
+ target: `0x1::option::destroy_some`,
29
+ typeArguments: [`${client.config.packageOrigin.framework}::vault::TypusBidReceipt`],
30
+ arguments: [tx.object(result[0])],
31
+ });
32
+ tx.moveCall({
33
+ target: `${client.config.package.framework}::vault::transfer_bid_receipt`,
34
+ typeArguments: [],
35
+ arguments: [tx.object(result[1]), tx.pure.address(input.recipient)],
36
+ });
37
+ return unwrap0;
38
+ }
12
39
  async function createTradingOrderWithBidReceiptByAutoBid(client, tx, input) {
13
40
  // INPUTS
14
41
  let TOKEN = input.cToken;
@@ -22,12 +49,23 @@ async function createTradingOrderWithBidReceiptByAutoBid(client, tx, input) {
22
49
  for (let token of tokens) {
23
50
  (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
24
51
  }
25
- let collateralBidReceipt = (0, user_entry_1.getWithdrawBidReceiptTx)(client.config, tx, {
52
+ let withdrawBidReceipt = (0, user_entry_1.getWithdrawBidReceiptTx)(client.config, tx, {
26
53
  vaultIndex: input.dovIndex,
27
54
  signalIndex: input.signalIndex,
28
55
  strategyIndex: input.strategyIndex,
29
56
  user: input.user,
30
57
  });
58
+ let collateralBidReceipt = withdrawBidReceipt;
59
+ // split bid receipt
60
+ if (input.share) {
61
+ let splitBidReceipt = splitBidReceiptTx(client, tx, {
62
+ index: input.dovIndex,
63
+ receipts: [withdrawBidReceipt],
64
+ share: input.share, // if undefined, merge all receipts
65
+ recipient: input.user,
66
+ });
67
+ collateralBidReceipt = splitBidReceipt;
68
+ }
31
69
  let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
32
70
  let bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
33
71
  let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.32-codegen-exp34",
3
+ "version": "1.1.32-codegen-exp36",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
@@ -44,4 +44,4 @@
44
44
  },
45
45
  "homepage": "https://github.com/Typus-Lab/typus-perp-sdk#readme",
46
46
  "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
47
- }
47
+ }