@typus/typus-sdk 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/lib/constants.d.ts +0 -1
- package/lib/constants.js +5 -3
- package/lib/test/mergeCoins.js +1 -2
- package/lib/test/multiple-collateral/getAuctionMaxSize.js +4 -3
- package/lib/test/{single-collateral/helper/getUserStatus.js → multiple-collateral/getBids.js} +14 -9
- package/lib/test/multiple-collateral/getMaxLossPerUnit.js +4 -3
- package/lib/test/multiple-collateral/getUserShares.js +4 -3
- package/lib/test/single-collateral/authorized/testAuthorizedNewPortfolioVault.js +1 -1
- package/lib/test/single-collateral/authorized/testAuthorizedUpdateUpcomingVaultConfig.js +1 -1
- package/lib/test/single-collateral/authorized/testAuthorizedUpdateWarmupVaultConfig.js +1 -1
- package/lib/test/single-collateral/getAuctionMaxSize.js +4 -3
- package/lib/test/single-collateral/{helper/getAuctionMaxSize.js → getBids.js} +14 -13
- package/lib/test/single-collateral/getMaxLossPerUnit.js +4 -3
- package/lib/test/single-collateral/getUserShares.js +4 -3
- package/lib/test/single-collateral/testMint.js +2 -4
- package/lib/test/single-collateral/testSDK.js +1 -2
- package/lib/test/single-collateral/user/testClaim.js +1 -1
- package/lib/test/single-collateral/user/testCompound.js +1 -1
- package/lib/test/single-collateral/user/testDeposit.js +1 -1
- package/lib/test/single-collateral/user/testHarvest.js +1 -1
- package/lib/test/single-collateral/user/testUnsubscribe.js +1 -1
- package/lib/test/single-collateral/user/testWithdraw.js +1 -1
- package/lib/test/sponsorTransaction.js +1 -1
- package/lib/utils/portfolio/multiple-collateral/authorized-entry.d.ts +102 -0
- package/lib/utils/portfolio/multiple-collateral/authorized-entry.js +295 -0
- package/lib/utils/portfolio/multiple-collateral/manager-entry.d.ts +219 -0
- package/lib/utils/portfolio/multiple-collateral/manager-entry.js +584 -0
- package/lib/utils/portfolio/multiple-collateral/portfolio-vault.js +4 -4
- package/lib/utils/portfolio/multiple-collateral/user-entry.d.ts +84 -0
- package/lib/utils/portfolio/multiple-collateral/user-entry.js +271 -0
- package/lib/utils/portfolio/single-collateral/getLeaderBoard.d.ts +2 -2
- package/lib/utils/portfolio/single-collateral/getLeaderBoard.js +30 -10
- package/lib/utils/portfolio/single-collateral/portfolio-vault.js +3 -3
- package/lib/utils/typus-framework/dutch.d.ts +2 -0
- package/lib/utils/typus-framework/dutch.js +65 -1
- package/lib/utils/typus-framework/vault.d.ts +2 -0
- package/lib/utils/typus-framework/vault.js +4 -0
- package/package.json +3 -3
- package/lib/mnemonic.json +0 -3
- package/lib/scripts/getSubVault.d.ts +0 -0
- package/lib/scripts/getSubVault.js +0 -6
- /package/lib/test/{single-collateral/helper/getAuctionMaxSize.d.ts → multiple-collateral/getBids.d.ts} +0 -0
- /package/lib/test/single-collateral/{helper/getUserStatus.d.ts → getBids.d.ts} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
/**
|
|
3
|
+
public(friend) entry fun deposit<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
4
|
+
registry: &mut Registry,
|
|
5
|
+
index: u64,
|
|
6
|
+
token_coins: vector<Coin<O_TOKEN>>,
|
|
7
|
+
usd_coins: vector<Coin<U_TOKEN>>,
|
|
8
|
+
token_amount: u64,
|
|
9
|
+
ctx: &mut TxContext
|
|
10
|
+
)
|
|
11
|
+
*/
|
|
12
|
+
export declare function getDepositTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, o_coins: string[], u_coins: string[], amount: string): Promise<TransactionBlock>;
|
|
13
|
+
/**
|
|
14
|
+
public(friend) entry fun withdraw<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
15
|
+
registry: &mut Registry,
|
|
16
|
+
index: u64,
|
|
17
|
+
share: Option<u64>,
|
|
18
|
+
ctx: &mut TxContext
|
|
19
|
+
)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getWithdrawTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, share?: string): Promise<TransactionBlock>;
|
|
22
|
+
/**
|
|
23
|
+
public(friend) entry fun claim<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
24
|
+
registry: &mut Registry,
|
|
25
|
+
index: u64,
|
|
26
|
+
ctx: &mut TxContext
|
|
27
|
+
)
|
|
28
|
+
*/
|
|
29
|
+
export declare function getClaimTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
30
|
+
/**
|
|
31
|
+
public(friend) entry fun harvest<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
32
|
+
registry: &mut Registry,
|
|
33
|
+
index: u64,
|
|
34
|
+
ctx: &mut TxContext
|
|
35
|
+
)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getHarvestTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
38
|
+
/**
|
|
39
|
+
public(friend) entry fun claim_and_harvest<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
40
|
+
registry: &mut Registry,
|
|
41
|
+
index: u64,
|
|
42
|
+
ctx: &mut TxContext
|
|
43
|
+
)
|
|
44
|
+
*/
|
|
45
|
+
export declare function getClaimAndHarvestTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string): Promise<TransactionBlock>;
|
|
46
|
+
/**
|
|
47
|
+
public(friend) entry fun compound_token<TOKEN, U_TOKEN>(
|
|
48
|
+
registry: &mut Registry,
|
|
49
|
+
index: u64,
|
|
50
|
+
usd_coins: vector<Coin<U_TOKEN>>,
|
|
51
|
+
ctx: &mut TxContext,
|
|
52
|
+
)
|
|
53
|
+
*/
|
|
54
|
+
export declare function getCompoundTokenTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, u_coins: string[]): Promise<TransactionBlock>;
|
|
55
|
+
/**
|
|
56
|
+
public(friend) entry fun compound_usd<TOKEN, O_TOKEN>(
|
|
57
|
+
registry: &mut Registry,
|
|
58
|
+
index: u64,
|
|
59
|
+
token_coins: vector<Coin<O_TOKEN>>,
|
|
60
|
+
ctx: &mut TxContext,
|
|
61
|
+
)
|
|
62
|
+
*/
|
|
63
|
+
export declare function getCompoundUsdTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, o_coins: string[]): Promise<TransactionBlock>;
|
|
64
|
+
/**
|
|
65
|
+
public(friend) entry fun unsubscribe<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
66
|
+
registry: &mut Registry,
|
|
67
|
+
index: u64,
|
|
68
|
+
share: Option<u64>,
|
|
69
|
+
ctx: &mut TxContext
|
|
70
|
+
)
|
|
71
|
+
*/
|
|
72
|
+
export declare function getUnsubscribeTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, share?: string): Promise<TransactionBlock>;
|
|
73
|
+
/**
|
|
74
|
+
public(friend) entry fun new_bid<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
75
|
+
registry: &mut Registry,
|
|
76
|
+
index: u64,
|
|
77
|
+
price_oracle: &Oracle<O_TOKEN>,
|
|
78
|
+
clock: &Clock,
|
|
79
|
+
coins: vector<Coin<B_TOKEN>>,
|
|
80
|
+
size: u64,
|
|
81
|
+
ctx: &mut TxContext,
|
|
82
|
+
)
|
|
83
|
+
*/
|
|
84
|
+
export declare function getNewBidTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string, b_coins: string[], size: string): Promise<TransactionBlock>;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getNewBidTx = exports.getUnsubscribeTx = exports.getCompoundUsdTx = exports.getCompoundTokenTx = exports.getClaimAndHarvestTx = exports.getHarvestTx = exports.getClaimTx = exports.getWithdrawTx = exports.getDepositTx = void 0;
|
|
40
|
+
var sui_js_1 = require("@mysten/sui.js");
|
|
41
|
+
/**
|
|
42
|
+
public(friend) entry fun deposit<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
43
|
+
registry: &mut Registry,
|
|
44
|
+
index: u64,
|
|
45
|
+
token_coins: vector<Coin<O_TOKEN>>,
|
|
46
|
+
usd_coins: vector<Coin<U_TOKEN>>,
|
|
47
|
+
token_amount: u64,
|
|
48
|
+
ctx: &mut TxContext
|
|
49
|
+
)
|
|
50
|
+
*/
|
|
51
|
+
function getDepositTx(gasBudget, packageId, typeArguments, registry, index, o_coins, u_coins, amount) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
+
var tx;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
tx = new sui_js_1.TransactionBlock();
|
|
56
|
+
tx.moveCall({
|
|
57
|
+
target: "".concat(packageId, "::multiple_collateral::deposit"),
|
|
58
|
+
typeArguments: typeArguments,
|
|
59
|
+
arguments: [
|
|
60
|
+
tx.pure(registry),
|
|
61
|
+
tx.pure(index),
|
|
62
|
+
tx.makeMoveVec({ objects: o_coins.map(function (id) { return tx.object(id); }) }),
|
|
63
|
+
tx.makeMoveVec({ objects: u_coins.map(function (id) { return tx.object(id); }) }),
|
|
64
|
+
tx.pure(amount),
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
tx.setGasBudget(gasBudget);
|
|
68
|
+
return [2 /*return*/, tx];
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
exports.getDepositTx = getDepositTx;
|
|
73
|
+
/**
|
|
74
|
+
public(friend) entry fun withdraw<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
75
|
+
registry: &mut Registry,
|
|
76
|
+
index: u64,
|
|
77
|
+
share: Option<u64>,
|
|
78
|
+
ctx: &mut TxContext
|
|
79
|
+
)
|
|
80
|
+
*/
|
|
81
|
+
function getWithdrawTx(gasBudget, packageId, typeArguments, registry, index, share) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
+
var tx;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
tx = new sui_js_1.TransactionBlock();
|
|
86
|
+
tx.moveCall({
|
|
87
|
+
target: "".concat(packageId, "::multiple_collateral::withdraw"),
|
|
88
|
+
typeArguments: typeArguments,
|
|
89
|
+
arguments: [tx.pure(registry), tx.pure(index), tx.pure(share ? [share] : [])],
|
|
90
|
+
});
|
|
91
|
+
tx.setGasBudget(gasBudget);
|
|
92
|
+
return [2 /*return*/, tx];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
exports.getWithdrawTx = getWithdrawTx;
|
|
97
|
+
/**
|
|
98
|
+
public(friend) entry fun claim<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
99
|
+
registry: &mut Registry,
|
|
100
|
+
index: u64,
|
|
101
|
+
ctx: &mut TxContext
|
|
102
|
+
)
|
|
103
|
+
*/
|
|
104
|
+
function getClaimTx(gasBudget, packageId, typeArguments, registry, index) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
+
var tx;
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
tx = new sui_js_1.TransactionBlock();
|
|
109
|
+
tx.moveCall({
|
|
110
|
+
target: "".concat(packageId, "::multiple_collateral::claim"),
|
|
111
|
+
typeArguments: typeArguments,
|
|
112
|
+
arguments: [tx.pure(registry), tx.pure(index)],
|
|
113
|
+
});
|
|
114
|
+
tx.setGasBudget(gasBudget);
|
|
115
|
+
return [2 /*return*/, tx];
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
exports.getClaimTx = getClaimTx;
|
|
120
|
+
/**
|
|
121
|
+
public(friend) entry fun harvest<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
122
|
+
registry: &mut Registry,
|
|
123
|
+
index: u64,
|
|
124
|
+
ctx: &mut TxContext
|
|
125
|
+
)
|
|
126
|
+
*/
|
|
127
|
+
function getHarvestTx(gasBudget, packageId, typeArguments, registry, index) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
129
|
+
var tx;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
tx = new sui_js_1.TransactionBlock();
|
|
132
|
+
tx.moveCall({
|
|
133
|
+
target: "".concat(packageId, "::multiple_collateral::harvest"),
|
|
134
|
+
typeArguments: typeArguments,
|
|
135
|
+
arguments: [tx.pure(registry), tx.pure(index)],
|
|
136
|
+
});
|
|
137
|
+
tx.setGasBudget(gasBudget);
|
|
138
|
+
return [2 /*return*/, tx];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
exports.getHarvestTx = getHarvestTx;
|
|
143
|
+
/**
|
|
144
|
+
public(friend) entry fun claim_and_harvest<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
145
|
+
registry: &mut Registry,
|
|
146
|
+
index: u64,
|
|
147
|
+
ctx: &mut TxContext
|
|
148
|
+
)
|
|
149
|
+
*/
|
|
150
|
+
function getClaimAndHarvestTx(gasBudget, packageId, typeArguments, registry, index) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
+
var tx;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
tx = new sui_js_1.TransactionBlock();
|
|
155
|
+
tx.moveCall({
|
|
156
|
+
target: "".concat(packageId, "::multiple_collateral::claim_and_harvest"),
|
|
157
|
+
typeArguments: typeArguments,
|
|
158
|
+
arguments: [tx.pure(registry), tx.pure(index)],
|
|
159
|
+
});
|
|
160
|
+
tx.setGasBudget(gasBudget);
|
|
161
|
+
return [2 /*return*/, tx];
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
exports.getClaimAndHarvestTx = getClaimAndHarvestTx;
|
|
166
|
+
/**
|
|
167
|
+
public(friend) entry fun compound_token<TOKEN, U_TOKEN>(
|
|
168
|
+
registry: &mut Registry,
|
|
169
|
+
index: u64,
|
|
170
|
+
usd_coins: vector<Coin<U_TOKEN>>,
|
|
171
|
+
ctx: &mut TxContext,
|
|
172
|
+
)
|
|
173
|
+
*/
|
|
174
|
+
function getCompoundTokenTx(gasBudget, packageId, typeArguments, registry, index, u_coins) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
+
var tx;
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
tx = new sui_js_1.TransactionBlock();
|
|
179
|
+
tx.moveCall({
|
|
180
|
+
target: "".concat(packageId, "::multiple_collateral::compound_token"),
|
|
181
|
+
typeArguments: typeArguments,
|
|
182
|
+
arguments: [tx.pure(registry), tx.pure(index), tx.makeMoveVec({ objects: u_coins.map(function (id) { return tx.object(id); }) })],
|
|
183
|
+
});
|
|
184
|
+
tx.setGasBudget(gasBudget);
|
|
185
|
+
return [2 /*return*/, tx];
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
exports.getCompoundTokenTx = getCompoundTokenTx;
|
|
190
|
+
/**
|
|
191
|
+
public(friend) entry fun compound_usd<TOKEN, O_TOKEN>(
|
|
192
|
+
registry: &mut Registry,
|
|
193
|
+
index: u64,
|
|
194
|
+
token_coins: vector<Coin<O_TOKEN>>,
|
|
195
|
+
ctx: &mut TxContext,
|
|
196
|
+
)
|
|
197
|
+
*/
|
|
198
|
+
function getCompoundUsdTx(gasBudget, packageId, typeArguments, registry, index, o_coins) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
+
var tx;
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
tx = new sui_js_1.TransactionBlock();
|
|
203
|
+
tx.moveCall({
|
|
204
|
+
target: "".concat(packageId, "::multiple_collateral::compound_usd"),
|
|
205
|
+
typeArguments: typeArguments,
|
|
206
|
+
arguments: [tx.pure(registry), tx.pure(index), tx.makeMoveVec({ objects: o_coins.map(function (id) { return tx.object(id); }) })],
|
|
207
|
+
});
|
|
208
|
+
tx.setGasBudget(gasBudget);
|
|
209
|
+
return [2 /*return*/, tx];
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
exports.getCompoundUsdTx = getCompoundUsdTx;
|
|
214
|
+
/**
|
|
215
|
+
public(friend) entry fun unsubscribe<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
216
|
+
registry: &mut Registry,
|
|
217
|
+
index: u64,
|
|
218
|
+
share: Option<u64>,
|
|
219
|
+
ctx: &mut TxContext
|
|
220
|
+
)
|
|
221
|
+
*/
|
|
222
|
+
function getUnsubscribeTx(gasBudget, packageId, typeArguments, registry, index, share) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
var tx;
|
|
225
|
+
return __generator(this, function (_a) {
|
|
226
|
+
tx = new sui_js_1.TransactionBlock();
|
|
227
|
+
tx.moveCall({
|
|
228
|
+
target: "".concat(packageId, "::multiple_collateral::unsubscribe"),
|
|
229
|
+
typeArguments: typeArguments,
|
|
230
|
+
arguments: [tx.pure(registry), tx.pure(index), tx.pure(share ? [share] : [])],
|
|
231
|
+
});
|
|
232
|
+
tx.setGasBudget(gasBudget);
|
|
233
|
+
return [2 /*return*/, tx];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
exports.getUnsubscribeTx = getUnsubscribeTx;
|
|
238
|
+
/**
|
|
239
|
+
public(friend) entry fun new_bid<O_TOKEN, U_TOKEN, B_TOKEN>(
|
|
240
|
+
registry: &mut Registry,
|
|
241
|
+
index: u64,
|
|
242
|
+
price_oracle: &Oracle<O_TOKEN>,
|
|
243
|
+
clock: &Clock,
|
|
244
|
+
coins: vector<Coin<B_TOKEN>>,
|
|
245
|
+
size: u64,
|
|
246
|
+
ctx: &mut TxContext,
|
|
247
|
+
)
|
|
248
|
+
*/
|
|
249
|
+
function getNewBidTx(gasBudget, packageId, typeArguments, registry, index, priceOracle, b_coins, size) {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
+
var tx;
|
|
252
|
+
return __generator(this, function (_a) {
|
|
253
|
+
tx = new sui_js_1.TransactionBlock();
|
|
254
|
+
tx.moveCall({
|
|
255
|
+
target: "".concat(packageId, "::multiple_collateral::new_bid"),
|
|
256
|
+
typeArguments: typeArguments,
|
|
257
|
+
arguments: [
|
|
258
|
+
tx.pure(registry),
|
|
259
|
+
tx.pure(index),
|
|
260
|
+
tx.pure(priceOracle),
|
|
261
|
+
tx.pure("0x6"),
|
|
262
|
+
tx.makeMoveVec({ objects: b_coins.map(function (id) { return tx.object(id); }) }),
|
|
263
|
+
tx.pure(size),
|
|
264
|
+
],
|
|
265
|
+
});
|
|
266
|
+
tx.setGasBudget(gasBudget);
|
|
267
|
+
return [2 /*return*/, tx];
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
exports.getNewBidTx = getNewBidTx;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function getDepositorLeaderBoard(): Promise<LeaderBoard[]>;
|
|
2
|
-
export declare function getBidderLeaderBoard(): Promise<LeaderBoard[]>;
|
|
1
|
+
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
2
|
+
export declare function getBidderLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
3
3
|
interface LeaderBoard {
|
|
4
4
|
user: string;
|
|
5
5
|
score: number;
|
|
@@ -81,16 +81,24 @@ var depositorRequestData = {
|
|
|
81
81
|
start: "now",
|
|
82
82
|
end: "now",
|
|
83
83
|
step: 1,
|
|
84
|
-
timezone: "Asia/Taipei",
|
|
85
84
|
},
|
|
86
85
|
samplesLimit: 200,
|
|
87
86
|
};
|
|
88
|
-
function getDepositorLeaderBoard() {
|
|
87
|
+
function getDepositorLeaderBoard(start, end, step) {
|
|
89
88
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
89
|
var jsonData, response, data, samples, leader_board;
|
|
91
90
|
return __generator(this, function (_a) {
|
|
92
91
|
switch (_a.label) {
|
|
93
92
|
case 0:
|
|
93
|
+
if (start) {
|
|
94
|
+
depositorRequestData.timeRange.start = start;
|
|
95
|
+
}
|
|
96
|
+
if (end) {
|
|
97
|
+
depositorRequestData.timeRange.end = end;
|
|
98
|
+
}
|
|
99
|
+
if (step) {
|
|
100
|
+
depositorRequestData.timeRange.step = step;
|
|
101
|
+
}
|
|
94
102
|
jsonData = JSON.stringify(depositorRequestData);
|
|
95
103
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
96
104
|
method: "POST",
|
|
@@ -105,9 +113,9 @@ function getDepositorLeaderBoard() {
|
|
|
105
113
|
data = _a.sent();
|
|
106
114
|
samples = data.results[0].matrix.samples;
|
|
107
115
|
leader_board = samples.map(function (element) {
|
|
108
|
-
//
|
|
109
|
-
//
|
|
110
|
-
return { user: element.metric.labels.user, score: element.values
|
|
116
|
+
// console.log("metric:", element.metric, "values: ", element.values);
|
|
117
|
+
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
118
|
+
return { user: element.metric.labels.user, score: element.values.at(-1).value };
|
|
111
119
|
});
|
|
112
120
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
113
121
|
// console.log(leader_board);
|
|
@@ -138,16 +146,24 @@ var bidderRequestData = {
|
|
|
138
146
|
start: "now",
|
|
139
147
|
end: "now",
|
|
140
148
|
step: 1,
|
|
141
|
-
timezone: "Asia/Taipei",
|
|
142
149
|
},
|
|
143
150
|
samplesLimit: 200,
|
|
144
151
|
};
|
|
145
|
-
function getBidderLeaderBoard() {
|
|
152
|
+
function getBidderLeaderBoard(start, end, step) {
|
|
146
153
|
return __awaiter(this, void 0, void 0, function () {
|
|
147
154
|
var jsonData, response, data, samples, leader_board;
|
|
148
155
|
return __generator(this, function (_a) {
|
|
149
156
|
switch (_a.label) {
|
|
150
157
|
case 0:
|
|
158
|
+
if (start) {
|
|
159
|
+
bidderRequestData.timeRange.start = start;
|
|
160
|
+
}
|
|
161
|
+
if (end) {
|
|
162
|
+
bidderRequestData.timeRange.end = end;
|
|
163
|
+
}
|
|
164
|
+
if (step) {
|
|
165
|
+
bidderRequestData.timeRange.step = step;
|
|
166
|
+
}
|
|
151
167
|
jsonData = JSON.stringify(bidderRequestData);
|
|
152
168
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
153
169
|
method: "POST",
|
|
@@ -162,9 +178,9 @@ function getBidderLeaderBoard() {
|
|
|
162
178
|
data = _a.sent();
|
|
163
179
|
samples = data.results[0].matrix.samples;
|
|
164
180
|
leader_board = samples.map(function (element) {
|
|
165
|
-
//
|
|
166
|
-
//
|
|
167
|
-
return { user: element.metric.labels.user, score: element.values
|
|
181
|
+
// console.log("metric:", element.metric, "values: ", element.values);
|
|
182
|
+
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
183
|
+
return { user: element.metric.labels.user, score: element.values.at(-1).value };
|
|
168
184
|
});
|
|
169
185
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
170
186
|
// console.log(leader_board);
|
|
@@ -175,3 +191,7 @@ function getBidderLeaderBoard() {
|
|
|
175
191
|
});
|
|
176
192
|
}
|
|
177
193
|
exports.getBidderLeaderBoard = getBidderLeaderBoard;
|
|
194
|
+
// (async () => {
|
|
195
|
+
// console.log(await getDepositorLeaderBoard("1682434800"));
|
|
196
|
+
// console.log(await getBidderLeaderBoard("1682434800"));
|
|
197
|
+
// })();
|
|
@@ -41,7 +41,7 @@ var vault_1 = require("../../typus-framework/vault");
|
|
|
41
41
|
var dutch_1 = require("../../typus-framework/dutch");
|
|
42
42
|
function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vault_registry, index) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var portfolioVaultIds, portfolioVaults, depositVaultIds,
|
|
44
|
+
var portfolioVaultIds, portfolioVaults, depositVaultIds, bidVaultIds;
|
|
45
45
|
return __generator(this, function (_a) {
|
|
46
46
|
switch (_a.label) {
|
|
47
47
|
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: registry })];
|
|
@@ -205,7 +205,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
205
205
|
options: { showContent: true },
|
|
206
206
|
})];
|
|
207
207
|
case 4:
|
|
208
|
-
|
|
208
|
+
(_a.sent())
|
|
209
209
|
.filter(function (depositVault) { return depositVault.error == undefined; })
|
|
210
210
|
.forEach(function (depositVault) {
|
|
211
211
|
// @ts-ignore
|
|
@@ -226,7 +226,7 @@ function getPortfolioVaults(provider, registry, deposit_vault_registry, bid_vaul
|
|
|
226
226
|
options: { showContent: true },
|
|
227
227
|
})];
|
|
228
228
|
case 6:
|
|
229
|
-
|
|
229
|
+
(_a.sent())
|
|
230
230
|
.filter(function (bidVault) { return bidVault.error == undefined; })
|
|
231
231
|
.forEach(function (bidVault) {
|
|
232
232
|
// @ts-ignore
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { JsonRpcProvider } from "@mysten/sui.js";
|
|
1
2
|
export interface Auction {
|
|
2
3
|
startTsMs: string;
|
|
3
4
|
endTsMs: string;
|
|
@@ -21,3 +22,4 @@ export interface Bid {
|
|
|
21
22
|
ownerAddress: string;
|
|
22
23
|
}
|
|
23
24
|
export declare function parseAuction(auction: any): Auction;
|
|
25
|
+
export declare function getBids(provider: JsonRpcProvider, auction: Auction): Promise<Bid[]>;
|
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseAuction = void 0;
|
|
39
|
+
exports.getBids = exports.parseAuction = void 0;
|
|
4
40
|
function parseAuction(auction) {
|
|
5
41
|
return {
|
|
6
42
|
startTsMs: auction.fields.start_ts_ms,
|
|
@@ -18,3 +54,31 @@ function parseAuction(auction) {
|
|
|
18
54
|
};
|
|
19
55
|
}
|
|
20
56
|
exports.parseAuction = parseAuction;
|
|
57
|
+
function getBids(provider, auction) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
+
var bidIds;
|
|
60
|
+
return __generator(this, function (_a) {
|
|
61
|
+
switch (_a.label) {
|
|
62
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({ parentId: auction.bids })];
|
|
63
|
+
case 1:
|
|
64
|
+
bidIds = (_a.sent()).data.map(function (x) { return x.objectId; });
|
|
65
|
+
return [4 /*yield*/, provider.multiGetObjects({
|
|
66
|
+
ids: bidIds,
|
|
67
|
+
options: { showContent: true },
|
|
68
|
+
})];
|
|
69
|
+
case 2: return [2 /*return*/, (_a.sent()).map(function (e) {
|
|
70
|
+
//@ts-ignore
|
|
71
|
+
var bidData = e.data.content.fields.value.fields;
|
|
72
|
+
return {
|
|
73
|
+
price: bidData.price,
|
|
74
|
+
size: bidData.size,
|
|
75
|
+
tsMs: bidData.ts_ms,
|
|
76
|
+
tokenBalance: bidData.balance,
|
|
77
|
+
ownerAddress: bidData.bidder,
|
|
78
|
+
};
|
|
79
|
+
})];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
exports.getBids = getBids;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface DepositVault {
|
|
2
|
+
token: string;
|
|
2
3
|
activeSubVault: SubVault;
|
|
3
4
|
deactivatingSubVault: SubVault;
|
|
4
5
|
inactiveSubVault: SubVault;
|
|
@@ -6,6 +7,7 @@ export interface DepositVault {
|
|
|
6
7
|
hasNext: boolean;
|
|
7
8
|
}
|
|
8
9
|
export interface BidVault {
|
|
10
|
+
token: string;
|
|
9
11
|
bidderSubVault: SubVault;
|
|
10
12
|
premiumSubVault: SubVault;
|
|
11
13
|
performanceFeeSubVault: SubVault;
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseSubVault = exports.parseBidVault = exports.parseDepositVault = void 0;
|
|
4
4
|
function parseDepositVault(depositVault) {
|
|
5
5
|
return {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
token: new RegExp(".*<.*, (.*)>").exec(depositVault.type)[1],
|
|
6
8
|
activeSubVault: parseSubVault(depositVault.fields.active_sub_vault),
|
|
7
9
|
deactivatingSubVault: parseSubVault(depositVault.fields.deactivating_sub_vault),
|
|
8
10
|
inactiveSubVault: parseSubVault(depositVault.fields.inactive_sub_vault),
|
|
@@ -13,6 +15,8 @@ function parseDepositVault(depositVault) {
|
|
|
13
15
|
exports.parseDepositVault = parseDepositVault;
|
|
14
16
|
function parseBidVault(bidVault) {
|
|
15
17
|
return {
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
token: new RegExp(".*<.*, (.*)>").exec(bidVault.type)[1],
|
|
16
20
|
bidderSubVault: parseSubVault(bidVault.fields.bidder_sub_vault),
|
|
17
21
|
premiumSubVault: parseSubVault(bidVault.fields.premium_sub_vault),
|
|
18
22
|
performanceFeeSubVault: parseSubVault(bidVault.fields.performance_fee_sub_vault),
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.22",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mysten/sui.js": "^0.32.1",
|
|
8
8
|
"@types/node": "^17.0.0",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"ts-mocha": "^10.0.0",
|
|
49
49
|
"tslib": "^1.14.1",
|
|
50
50
|
"tsutils": "^2.29.0",
|
|
51
|
+
"typed-rpc": "^3.0.0",
|
|
51
52
|
"wrappy": "^1.0.2",
|
|
52
53
|
"ws": "^8.11.0",
|
|
53
|
-
"xmlhttprequest": "^1.8.0"
|
|
54
|
-
"typed-rpc": "^3.0.0"
|
|
54
|
+
"xmlhttprequest": "^1.8.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/bs58": "^4.0.1",
|
package/lib/mnemonic.json
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|