@typus/typus-sdk 1.0.44 → 1.0.45
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/lib/utils/sponsorTransaction.d.ts +4 -5
- package/lib/utils/sponsorTransaction.js +11 -14
- package/lib/utils/typus-dov-double/portfolio-vault.js +16 -1
- package/lib/utils/typus-dov-single/portfolio-vault.js +16 -1
- package/lib/utils/typus-dov-single/user-entry.d.ts +3 -2
- package/lib/utils/typus-dov-single/user-entry.js +9 -5
- package/package.json +1 -1
|
@@ -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<
|
|
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,
|
|
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 (
|
|
70
|
-
switch (
|
|
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 =
|
|
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(
|
|
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(
|
|
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,
|
|
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(
|
|
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) {
|
|
@@ -62,7 +63,21 @@ function getPortfolioVaults(provider, registry, token_deposit_vault_registry, us
|
|
|
62
63
|
var vaultId = portfolioVault.data.content.fields.id.id;
|
|
63
64
|
// @ts-ignore
|
|
64
65
|
var typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
65
|
-
var assets = typeArgs.map(function (x) {
|
|
66
|
+
var assets = typeArgs.map(function (x) {
|
|
67
|
+
var typeArgs = x.split("::");
|
|
68
|
+
switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
|
|
69
|
+
case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
|
|
70
|
+
return "WBTC";
|
|
71
|
+
case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
|
|
72
|
+
return "WETH";
|
|
73
|
+
case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
|
|
74
|
+
return "USDC";
|
|
75
|
+
case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
|
|
76
|
+
return "USDT";
|
|
77
|
+
default:
|
|
78
|
+
return typeArgs[2];
|
|
79
|
+
}
|
|
80
|
+
});
|
|
66
81
|
var oracleInfo = {
|
|
67
82
|
// @ts-ignore
|
|
68
83
|
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) {
|
|
@@ -82,7 +83,21 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
82
83
|
case 2:
|
|
83
84
|
_a.sent();
|
|
84
85
|
typeArgs = new RegExp(".*<(.*), (.*), (.*)>").exec(portfolioVault.data.content.type).slice(1, 4);
|
|
85
|
-
assets = typeArgs.map(function (x) {
|
|
86
|
+
assets = typeArgs.map(function (x) {
|
|
87
|
+
var typeArgs = x.split("::");
|
|
88
|
+
switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
|
|
89
|
+
case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
|
|
90
|
+
return "WBTC";
|
|
91
|
+
case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
|
|
92
|
+
return "WETH";
|
|
93
|
+
case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
|
|
94
|
+
return "USDC";
|
|
95
|
+
case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
|
|
96
|
+
return "USDT";
|
|
97
|
+
default:
|
|
98
|
+
return typeArgs[2];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
86
101
|
deliveryInfo =
|
|
87
102
|
// @ts-ignore
|
|
88
103
|
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
|
|
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 (
|
|
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 (
|
|
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"),
|