@typus/typus-perp-sdk 1.1.32-codegen-exp35 → 1.1.32-codegen-exp37

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.
@@ -570,7 +570,6 @@ async function getCancelOrderFromSentio(userAddress, startTimestamp, events) {
570
570
  }
571
571
  async function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
572
572
  const datas = await (0, sentio_1.getFromSentio)("OrderFilled", userAddress, startTimestamp.toString(), true);
573
- // console.log(datas);
574
573
  let order_match = datas.map((x) => {
575
574
  let base_token = toToken(x.base_token);
576
575
  let txHistory = {
@@ -578,7 +577,7 @@ async function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
578
577
  ? "Order Filled (Open Position)"
579
578
  : x.sender == "0x978f65df8570a075298598a9965c18de9087f9e888eb3430fe20334f5c554cfd"
580
579
  ? "Force Close Position"
581
- : x.order_type == "Increase" ? "Order Filled (Increase Position)" : "Order Filled (Close Position)",
580
+ : "Order Filled (Close Position)",
582
581
  typeName: "OrderFilledEvent",
583
582
  order_id: x.order_id,
584
583
  position_id: x.position_id,
@@ -609,6 +608,12 @@ async function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
609
608
  x.order_type = related.order_type;
610
609
  x.collateral = related.collateral;
611
610
  x.dov_index = related.dov_index;
611
+ // it mean filled by matching cranker
612
+ if (x.action === "Order Filled (Close Position)") {
613
+ if (x.side === related.side) {
614
+ x.action = "Order Filled (Increase Position)";
615
+ }
616
+ }
612
617
  }
613
618
  else {
614
619
  x.order_type = "Market";
@@ -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-exp35",
3
+ "version": "1.1.32-codegen-exp37",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",