@typus/typus-sdk 1.0.44 → 1.0.46

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.
@@ -15,9 +15,8 @@ export interface SponsorRpc {
15
15
  gas_getSponsoredTransactionBlockStatus(txDigest: string): SponsoredTransactionStatus;
16
16
  }
17
17
  export declare const sponsorTransactionBlock: (gaslessTxb: any, sponsor: any, provider: any, gasBudget: any, signerAddress: any) => Promise<[SponsoredTransaction, Uint8Array]>;
18
- export declare const executeSponsorTransactionBlock: (provider: any, sponsoredResponse: any, senderSig: any) => Promise<void>;
18
+ export declare const executeSponsorTransactionBlock: (provider: any, sponsoredResponse: any, senderSig: any) => Promise<any>;
19
19
  export declare const sponsorTransactionE2E: (gaslessTxb: any, sponsor: any, provider: any, signer: any, gasBudget: any) => Promise<void>;
20
- export declare function getSponsoredDeposit(packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], amount: string, signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
21
- export declare function getSponsoredCompound(packageId: string, typeArguments: string[], registry: string, index: string, signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
22
- export declare function getSponsoredNewBid(packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, coins: string[], size: string, premium_required: string, // fe float * b_token_decimal
23
- signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
20
+ export declare function getSponsoredDeposit(sponsorApi: string, packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], amount: string, signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
21
+ export declare function getSponsoredCompound(sponsorApi: string, packageId: string, typeArguments: string[], registry: string, index: string, signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
22
+ export declare function getSponsoredNewBid(sponsorApi: string, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, coins: string[], size: string, signerAddress: string): Promise<[SponsoredTransaction, Uint8Array]>;
@@ -65,9 +65,9 @@ exports.sponsorTransactionBlock = sponsorTransactionBlock;
65
65
  // const senderSig = await signer.signTransactionBlock({ transactionBlock });
66
66
  var executeSponsorTransactionBlock = function (provider, sponsoredResponse, senderSig) { return __awaiter(void 0, void 0, void 0, function () {
67
67
  var executeResponse;
68
- var _a;
69
- return __generator(this, function (_b) {
70
- switch (_b.label) {
68
+ var _a, _b;
69
+ return __generator(this, function (_c) {
70
+ switch (_c.label) {
71
71
  case 0: return [4 /*yield*/, provider.executeTransactionBlock({
72
72
  transactionBlock: sponsoredResponse.txBytes,
73
73
  signature: [senderSig.signature, sponsoredResponse.signature],
@@ -75,10 +75,9 @@ var executeSponsorTransactionBlock = function (provider, sponsoredResponse, send
75
75
  requestType: "WaitForLocalExecution",
76
76
  })];
77
77
  case 1:
78
- executeResponse = _b.sent();
79
- console.log(executeResponse, "executeResponse");
78
+ executeResponse = _c.sent();
80
79
  console.log("Execution Status:", (_a = executeResponse.effects) === null || _a === void 0 ? void 0 : _a.status.status);
81
- return [2 /*return*/];
80
+ return [2 /*return*/, (_b = executeResponse.effects) === null || _b === void 0 ? void 0 : _b.status.status];
82
81
  }
83
82
  });
84
83
  }); };
@@ -120,7 +119,7 @@ var sponsorTransactionE2E = function (gaslessTxb, sponsor, provider, signer, gas
120
119
  });
121
120
  }); };
122
121
  exports.sponsorTransactionE2E = sponsorTransactionE2E;
123
- function getSponsoredDeposit(packageId, typeArguments, registry, index, coins, amount, signerAddress) {
122
+ function getSponsoredDeposit(sponsorApi, packageId, typeArguments, registry, index, coins, amount, signerAddress) {
124
123
  return __awaiter(this, void 0, void 0, function () {
125
124
  var jsonData, response, data, sponsoredResponse, transactionBlock;
126
125
  return __generator(this, function (_a) {
@@ -136,7 +135,7 @@ function getSponsoredDeposit(packageId, typeArguments, registry, index, coins, a
136
135
  amount: amount,
137
136
  signerAddress: signerAddress,
138
137
  });
139
- return [4 /*yield*/, fetch("https://function-1-jbw5emju3a-uc.a.run.app", {
138
+ return [4 /*yield*/, fetch(sponsorApi, {
140
139
  method: "POST",
141
140
  headers: { "Content-Type": "application/json" },
142
141
  body: jsonData,
@@ -155,7 +154,7 @@ function getSponsoredDeposit(packageId, typeArguments, registry, index, coins, a
155
154
  });
156
155
  }
157
156
  exports.getSponsoredDeposit = getSponsoredDeposit;
158
- function getSponsoredCompound(packageId, typeArguments, registry, index, signerAddress) {
157
+ function getSponsoredCompound(sponsorApi, packageId, typeArguments, registry, index, signerAddress) {
159
158
  return __awaiter(this, void 0, void 0, function () {
160
159
  var jsonData, response, data, sponsoredResponse, transactionBlock;
161
160
  return __generator(this, function (_a) {
@@ -169,7 +168,7 @@ function getSponsoredCompound(packageId, typeArguments, registry, index, signerA
169
168
  index: index,
170
169
  signerAddress: signerAddress,
171
170
  });
172
- return [4 /*yield*/, fetch("https://function-1-jbw5emju3a-uc.a.run.app", {
171
+ return [4 /*yield*/, fetch(sponsorApi, {
173
172
  method: "POST",
174
173
  headers: { "Content-Type": "application/json" },
175
174
  body: jsonData,
@@ -188,8 +187,7 @@ function getSponsoredCompound(packageId, typeArguments, registry, index, signerA
188
187
  });
189
188
  }
190
189
  exports.getSponsoredCompound = getSponsoredCompound;
191
- function getSponsoredNewBid(packageId, typeArguments, registry, index, priceOracle, coins, size, premium_required, // fe float * b_token_decimal
192
- signerAddress) {
190
+ function getSponsoredNewBid(sponsorApi, packageId, typeArguments, registry, index, priceOracle, coins, size, signerAddress) {
193
191
  return __awaiter(this, void 0, void 0, function () {
194
192
  var jsonData, response, data, sponsoredResponse, transactionBlock;
195
193
  return __generator(this, function (_a) {
@@ -204,10 +202,9 @@ signerAddress) {
204
202
  priceOracle: priceOracle,
205
203
  coins: coins,
206
204
  size: size,
207
- premium_required: premium_required,
208
205
  signerAddress: signerAddress,
209
206
  });
210
- return [4 /*yield*/, fetch("https://function-1-jbw5emju3a-uc.a.run.app", {
207
+ return [4 /*yield*/, fetch(sponsorApi, {
211
208
  method: "POST",
212
209
  headers: { "Content-Type": "application/json" },
213
210
  body: jsonData,
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getPortfolioVaults = void 0;
40
+ var sui_js_1 = require("@mysten/sui.js");
40
41
  var vault_1 = require("../typus-framework/vault");
41
42
  var dutch_1 = require("../typus-framework/dutch");
42
43
  function getPortfolioVaults(provider, registry, token_deposit_vault_registry, usd_deposit_vault_registry, bid_vault_registry, index) {
@@ -44,7 +45,9 @@ function getPortfolioVaults(provider, registry, token_deposit_vault_registry, us
44
45
  var portfolioVaultIds, portfolioVaults, tokenDepositVaultIds, usdDepositVaultIds, bidVaultIds;
45
46
  return __generator(this, function (_a) {
46
47
  switch (_a.label) {
47
- case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
48
+ case 0:
49
+ console.warn = function () { };
50
+ return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
48
51
  case 1:
49
52
  portfolioVaultIds = (_a.sent()).data
50
53
  .filter(function (x) { return (index ? x.name.value == index : true); })
@@ -62,7 +65,21 @@ function getPortfolioVaults(provider, registry, token_deposit_vault_registry, us
62
65
  var vaultId = portfolioVault.data.content.fields.id.id;
63
66
  // @ts-ignore
64
67
  var typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
65
- var assets = typeArgs.map(function (x) { return x.split("::")[2]; });
68
+ var assets = typeArgs.map(function (x) {
69
+ var typeArgs = x.split("::");
70
+ switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
71
+ case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
72
+ return "WBTC";
73
+ case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
74
+ return "WETH";
75
+ case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
76
+ return "USDC";
77
+ case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
78
+ return "USDT";
79
+ default:
80
+ return typeArgs[2];
81
+ }
82
+ });
66
83
  var oracleInfo = {
67
84
  // @ts-ignore
68
85
  price: portfolioVault.data.content.fields.info.fields.oracle_info.fields.price,
@@ -37,6 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getPortfolioVaults = void 0;
40
+ var sui_js_1 = require("@mysten/sui.js");
40
41
  var vault_1 = require("../typus-framework/vault");
41
42
  var dutch_1 = require("../typus-framework/dutch");
42
43
  function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vault_registry, index) {
@@ -45,7 +46,9 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
45
46
  var _this = this;
46
47
  return __generator(this, function (_a) {
47
48
  switch (_a.label) {
48
- case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
49
+ case 0:
50
+ console.warn = function () { };
51
+ return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
49
52
  case 1:
50
53
  portfolioVaultIds = (_a.sent()).data
51
54
  .filter(function (x) { return (index ? x.name.value == index : true); })
@@ -82,7 +85,21 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
82
85
  case 2:
83
86
  _a.sent();
84
87
  typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
85
- assets = typeArgs.map(function (x) { return x.split("::")[2]; });
88
+ assets = typeArgs.map(function (x) {
89
+ var typeArgs = x.split("::");
90
+ switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
91
+ case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
92
+ return "WBTC";
93
+ case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
94
+ return "WETH";
95
+ case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
96
+ return "USDC";
97
+ case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
98
+ return "USDT";
99
+ default:
100
+ return typeArgs[2];
101
+ }
102
+ });
86
103
  deliveryInfo =
87
104
  // @ts-ignore
88
105
  portfolioVault.data.content.fields.info.fields.delivery_info
@@ -9,7 +9,7 @@ import { TransactionBlock } from "@mysten/sui.js";
9
9
  )
10
10
  @param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
11
11
  */
12
- export declare function getDepositTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], amount: string): Promise<TransactionBlock>;
12
+ export declare function getDepositTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, coins: string[], amount: string, usingSponsoredGasCoin?: boolean): Promise<TransactionBlock>;
13
13
  /**
14
14
  public(friend) entry fun withdraw<TOKEN>(
15
15
  registry: &mut Registry,
@@ -78,4 +78,5 @@ export declare function getUnsubscribeTx(gasBudget: number, packageId: string, t
78
78
  )
79
79
  @param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
80
80
  */
81
- export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, coins: string[], size: string, premium_required: string): Promise<TransactionBlock>;
81
+ export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, coins: string[], size: string, premium_required: string, // fe float * b_token_decimal
82
+ usingSponsoredGasCoin?: boolean): Promise<TransactionBlock>;
@@ -64,12 +64,14 @@ var sui_js_1 = require("@mysten/sui.js");
64
64
  )
65
65
  @param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
66
66
  */
67
- function getDepositTx(gasBudget, packageId, typeArguments, registry, index, coins, amount) {
67
+ function getDepositTx(gasBudget, packageId, typeArguments, registry, index, coins, amount, usingSponsoredGasCoin) {
68
+ if (usingSponsoredGasCoin === void 0) { usingSponsoredGasCoin = false; }
68
69
  return __awaiter(this, void 0, void 0, function () {
69
70
  var tx, _a, coin;
70
71
  return __generator(this, function (_b) {
71
72
  tx = new sui_js_1.TransactionBlock();
72
- if (typeArguments[0] == "0x2::sui::SUI" || typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
73
+ if (!usingSponsoredGasCoin &&
74
+ (typeArguments[0] == "0x2::sui::SUI" || typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI")) {
73
75
  _a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), coin = _a[0];
74
76
  tx.moveCall({
75
77
  target: "".concat(packageId, "::typus_dov_single::deposit"),
@@ -248,13 +250,15 @@ exports.getUnsubscribeTx = getUnsubscribeTx;
248
250
  )
249
251
  @param typeArguments [Deposit Vault Token, Bid Vault Token, Oracle Token]
250
252
  */
251
- function getNewBidTx(gasBudget, packageId, typeArguments, registry, index, priceOracle, coins, size, premium_required // fe float * b_token_decimal
252
- ) {
253
+ function getNewBidTx(gasBudget, packageId, typeArguments, registry, index, priceOracle, coins, size, premium_required, // fe float * b_token_decimal
254
+ usingSponsoredGasCoin) {
255
+ if (usingSponsoredGasCoin === void 0) { usingSponsoredGasCoin = false; }
253
256
  return __awaiter(this, void 0, void 0, function () {
254
257
  var tx, _a, coin;
255
258
  return __generator(this, function (_b) {
256
259
  tx = new sui_js_1.TransactionBlock();
257
- if (typeArguments[1] == "0x2::sui::SUI" || typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
260
+ if (!usingSponsoredGasCoin &&
261
+ (typeArguments[1] == "0x2::sui::SUI" || typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI")) {
258
262
  _a = __read(tx.splitCoins(tx.gas, [tx.pure(premium_required)]), 1), coin = _a[0];
259
263
  tx.moveCall({
260
264
  target: "".concat(packageId, "::typus_dov_single::new_bid"),
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
1
  {
2
- "name": "@typus/typus-sdk",
3
- "author": "Typus",
4
- "description": "typus sdk",
5
- "version": "1.0.44",
6
- "dependencies": {
7
- "@mysten/sui.js": "^0.34.0",
8
- "@types/node": "^17.0.0",
9
- "bignumber.js": "^9.1.1",
10
- "bs58": "^4.0.1",
11
- "builtin-modules": "^1.1.1",
12
- "chai": "^4.3.7",
13
- "decimal.js": "^10.3.1",
14
- "diff": "^4.0.2",
15
- "dotenv": "^10.0.0",
16
- "encrypt-with-password": "^1.0.0",
17
- "escape-string-regexp": "^1.0.5",
18
- "esprima": "^4.0.1",
19
- "fetch": "^1.1.0",
20
- "fs.realpath": "^1.0.0",
21
- "function-bind": "^1.1.1",
22
- "glob": "^7.2.0",
23
- "has": "^1.0.3",
24
- "has-flag": "^3.0.0",
25
- "inflight": "^1.0.6",
26
- "inherits": "^2.0.4",
27
- "is-core-module": "^2.8.0",
28
- "js-sha3": "^0.8.0",
29
- "js-tokens": "^4.0.0",
30
- "js-yaml": "^3.14.1",
31
- "math-erf": "^1.0.0",
32
- "minimatch": "^3.0.4",
33
- "minimist": "^1.2.5",
34
- "mkdirp": "^0.5.5",
35
- "mocha": "^10.1.0",
36
- "moment": "^2.29.4",
37
- "node-cron": "^3.0.2",
38
- "once": "^1.4.0",
39
- "path-is-absolute": "^1.0.1",
40
- "path-parse": "^1.0.7",
41
- "random-bigint": "^0.0.1",
42
- "resolve": "^1.20.0",
43
- "rxjs": "^7.5.5",
44
- "semver": "^5.7.1",
45
- "sprintf-js": "^1.0.3",
46
- "superstruct": "^0.16.0",
47
- "supports-color": "^5.5.0",
48
- "ts-mocha": "^10.0.0",
49
- "tslib": "^1.14.1",
50
- "tsutils": "^2.29.0",
51
- "typed-rpc": "^3.0.0",
52
- "wrappy": "^1.0.2",
53
- "ws": "^8.11.0",
54
- "xmlhttprequest": "^1.8.0"
55
- },
56
- "devDependencies": {
57
- "@types/bs58": "^4.0.1",
58
- "@types/expect": "^24.3.0",
59
- "@types/mocha": "^9.0.0",
60
- "@types/rx": "^4.1.2",
61
- "prettier": "^2.5.1",
62
- "tslint": "^6.1.3",
63
- "tslint-config-prettier": "^1.18.0",
64
- "typescript": "^4.5.4"
65
- },
66
- "main": "lib/index.js",
67
- "files": [
68
- "lib"
69
- ],
70
- "types": "lib/index.d.ts",
71
- "scripts": {
72
- "test": "rm -rf lib && tsc && ts-mocha test/test*.ts",
73
- "build": "rm -rf lib && tsc"
74
- },
75
- "repository": {
76
- "type": "git",
77
- "url": "git+https://github.com/Typus-Lab/typus-sdk.git"
78
- },
79
- "license": "ISC",
80
- "bugs": {
81
- "url": "https://github.com/Typus-Lab/typus-sdk/issues"
82
- },
83
- "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
2
+ "name": "@typus/typus-sdk",
3
+ "author": "Typus",
4
+ "description": "typus sdk",
5
+ "version": "1.0.46",
6
+ "dependencies": {
7
+ "@mysten/sui.js": "^0.34.1",
8
+ "@types/node": "^17.0.0",
9
+ "bignumber.js": "^9.1.1",
10
+ "bs58": "^4.0.1",
11
+ "builtin-modules": "^1.1.1",
12
+ "chai": "^4.3.7",
13
+ "decimal.js": "^10.3.1",
14
+ "diff": "^4.0.2",
15
+ "dotenv": "^10.0.0",
16
+ "encrypt-with-password": "^1.0.0",
17
+ "escape-string-regexp": "^1.0.5",
18
+ "esprima": "^4.0.1",
19
+ "fetch": "^1.1.0",
20
+ "fs.realpath": "^1.0.0",
21
+ "function-bind": "^1.1.1",
22
+ "glob": "^7.2.0",
23
+ "has": "^1.0.3",
24
+ "has-flag": "^3.0.0",
25
+ "inflight": "^1.0.6",
26
+ "inherits": "^2.0.4",
27
+ "is-core-module": "^2.8.0",
28
+ "js-sha3": "^0.8.0",
29
+ "js-tokens": "^4.0.0",
30
+ "js-yaml": "^3.14.1",
31
+ "math-erf": "^1.0.0",
32
+ "minimatch": "^3.0.4",
33
+ "minimist": "^1.2.5",
34
+ "mkdirp": "^0.5.5",
35
+ "mocha": "^10.1.0",
36
+ "moment": "^2.29.4",
37
+ "node-cron": "^3.0.2",
38
+ "once": "^1.4.0",
39
+ "path-is-absolute": "^1.0.1",
40
+ "path-parse": "^1.0.7",
41
+ "random-bigint": "^0.0.1",
42
+ "resolve": "^1.20.0",
43
+ "rxjs": "^7.5.5",
44
+ "semver": "^5.7.1",
45
+ "sprintf-js": "^1.0.3",
46
+ "superstruct": "^0.16.0",
47
+ "supports-color": "^5.5.0",
48
+ "ts-mocha": "^10.0.0",
49
+ "tslib": "^1.14.1",
50
+ "tsutils": "^2.29.0",
51
+ "typed-rpc": "^3.0.0",
52
+ "wrappy": "^1.0.2",
53
+ "ws": "^8.11.0",
54
+ "xmlhttprequest": "^1.8.0"
55
+ },
56
+ "devDependencies": {
57
+ "@types/bs58": "^4.0.1",
58
+ "@types/expect": "^24.3.0",
59
+ "@types/mocha": "^9.0.0",
60
+ "@types/rx": "^4.1.2",
61
+ "prettier": "^2.5.1",
62
+ "tslint": "^6.1.3",
63
+ "tslint-config-prettier": "^1.18.0",
64
+ "typescript": "^4.5.4"
65
+ },
66
+ "main": "lib/index.js",
67
+ "files": [
68
+ "lib"
69
+ ],
70
+ "types": "lib/index.d.ts",
71
+ "scripts": {
72
+ "test": "rm -rf lib && tsc && ts-mocha test/test*.ts",
73
+ "build": "rm -rf lib && tsc"
74
+ },
75
+ "repository": {
76
+ "type": "git",
77
+ "url": "git+https://github.com/Typus-Lab/typus-sdk.git"
78
+ },
79
+ "license": "ISC",
80
+ "bugs": {
81
+ "url": "https://github.com/Typus-Lab/typus-sdk/issues"
82
+ },
83
+ "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
84
84
  }