@typus/typus-sdk 1.1.44 → 1.1.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.
- package/lib/utils/nft-staking/authorized-entry.d.ts +0 -1
- package/lib/utils/nft-staking/authorized-entry.js +1 -17
- package/lib/utils/nft-staking/user-entry.d.ts +2 -0
- package/lib/utils/nft-staking/user-entry.js +39 -1
- package/lib/utils/tails-exp-dice/fetch.d.ts +7 -0
- package/lib/utils/tails-exp-dice/fetch.js +148 -62
- package/lib/utils/typus-dov-single-v2/user-entry.d.ts +5 -1
- package/lib/utils/typus-dov-single-v2/user-entry.js +18 -3
- package/package.json +2 -2
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
2
2
|
export declare function getSetProfitSharingTx(gasBudget: number, packageId: string, registry: string, level_profits: number[], amount: number): Promise<TransactionBlock>;
|
|
3
3
|
export declare function getAllocateProfitSharingTx(gasBudget: number, packageId: string, registry: string, users: string[]): Promise<TransactionBlock>;
|
|
4
|
-
export declare function getClaimProfitSharingTx(gasBudget: number, packageId: string, registry: string): Promise<TransactionBlock>;
|
|
@@ -52,7 +52,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.
|
|
55
|
+
exports.getAllocateProfitSharingTx = exports.getSetProfitSharingTx = void 0;
|
|
56
56
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
57
57
|
function getSetProfitSharingTx(gasBudget, packageId, registry, level_profits, amount) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -87,19 +87,3 @@ function getAllocateProfitSharingTx(gasBudget, packageId, registry, users) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
exports.getAllocateProfitSharingTx = getAllocateProfitSharingTx;
|
|
90
|
-
function getClaimProfitSharingTx(gasBudget, packageId, registry) {
|
|
91
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
-
var tx;
|
|
93
|
-
return __generator(this, function (_a) {
|
|
94
|
-
tx = new transactions_1.TransactionBlock();
|
|
95
|
-
tx.moveCall({
|
|
96
|
-
target: "".concat(packageId, "::tails_staking::claim_profit_sharing"),
|
|
97
|
-
typeArguments: ["0x2::sui::SUI"],
|
|
98
|
-
arguments: [tx.object(registry)],
|
|
99
|
-
});
|
|
100
|
-
tx.setGasBudget(gasBudget);
|
|
101
|
-
return [2 /*return*/, tx];
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
exports.getClaimProfitSharingTx = getClaimProfitSharingTx;
|
|
@@ -23,6 +23,7 @@ export declare function getTransferNftsTx(gasBudget: number, nftPackageId: strin
|
|
|
23
23
|
)
|
|
24
24
|
*/
|
|
25
25
|
export declare function getStakeNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string): Promise<TransactionBlock>;
|
|
26
|
+
export declare function getSwitchNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string): Promise<TransactionBlock>;
|
|
26
27
|
export declare function getCreateKioskAndLockNftTx(kioskClient: KioskClient, gasBudget: number, nftPackageId: string, policy: string, nft_id: string, singer: string): Promise<TransactionBlock>;
|
|
27
28
|
/**
|
|
28
29
|
public fun unstake_nft(
|
|
@@ -82,3 +83,4 @@ export declare function consumeExpCoinUnstakedTx(gasBudget: number, nftPackageId
|
|
|
82
83
|
)
|
|
83
84
|
*/
|
|
84
85
|
export declare function consumeExpCoinStakedTx(gasBudget: number, nftPackageId: string, typeArguments: string[], registry: string, exp_coins: string[], amount: string): Promise<TransactionBlock>;
|
|
86
|
+
export declare function getClaimProfitSharingTx(gasBudget: number, packageId: string, registry: string): Promise<TransactionBlock>;
|
|
@@ -52,7 +52,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.consumeExpCoinStakedTx = exports.consumeExpCoinUnstakedTx = exports.getLevelUpTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getCompoundTx = exports.getDepositTx = exports.getNewBidTx = exports.getSnapshotTx = exports.getDailyAttendTx = exports.getUnstakeNftTx = exports.getCreateKioskAndLockNftTx = exports.getStakeNftTx = exports.getTransferNftsTx = exports.getTransferNftTx = void 0;
|
|
55
|
+
exports.getClaimProfitSharingTx = exports.consumeExpCoinStakedTx = exports.consumeExpCoinUnstakedTx = exports.getLevelUpTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getCompoundTx = exports.getDepositTx = exports.getNewBidTx = exports.getSnapshotTx = exports.getDailyAttendTx = exports.getUnstakeNftTx = exports.getCreateKioskAndLockNftTx = exports.getSwitchNftTx = exports.getStakeNftTx = exports.getTransferNftsTx = exports.getTransferNftTx = void 0;
|
|
56
56
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
57
57
|
var constants_1 = require("../../constants");
|
|
58
58
|
var kiosk_1 = require("@mysten/kiosk");
|
|
@@ -131,6 +131,23 @@ function getStakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
exports.getStakeNftTx = getStakeNftTx;
|
|
134
|
+
function getSwitchNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_id) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var tx, _a, coin;
|
|
137
|
+
return __generator(this, function (_b) {
|
|
138
|
+
tx = new transactions_1.TransactionBlock();
|
|
139
|
+
_a = __read(tx.splitCoins(tx.gas, [tx.pure(50000000)]), 1), coin = _a[0];
|
|
140
|
+
tx.moveCall({
|
|
141
|
+
target: "".concat(nftPackageId, "::tails_staking::switch_nft"),
|
|
142
|
+
typeArguments: [],
|
|
143
|
+
arguments: [tx.object(registry), tx.object(kiosk), tx.object(kiosk_cap), tx.pure(nft_id), tx.object(constants_1.CLOCK), coin],
|
|
144
|
+
});
|
|
145
|
+
tx.setGasBudget(gasBudget);
|
|
146
|
+
return [2 /*return*/, tx];
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
exports.getSwitchNftTx = getSwitchNftTx;
|
|
134
151
|
function getCreateKioskAndLockNftTx(kioskClient, gasBudget, nftPackageId, policy, nft_id, singer) {
|
|
135
152
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
153
|
var tx, kioskTx, kiosk, kioskCap;
|
|
@@ -176,6 +193,11 @@ function getUnstakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap) {
|
|
|
176
193
|
typeArguments: [],
|
|
177
194
|
arguments: [tx.object(registry), tx.object(constants_1.CLOCK)],
|
|
178
195
|
});
|
|
196
|
+
tx.moveCall({
|
|
197
|
+
target: "".concat(nftPackageId, "::tails_staking::claim_profit_sharing"),
|
|
198
|
+
typeArguments: ["0x2::sui::SUI"],
|
|
199
|
+
arguments: [tx.object(registry)],
|
|
200
|
+
});
|
|
179
201
|
tx.moveCall({
|
|
180
202
|
target: "".concat(nftPackageId, "::tails_staking::unstake_nft"),
|
|
181
203
|
typeArguments: [],
|
|
@@ -463,3 +485,19 @@ function consumeExpCoinStakedTx(gasBudget, nftPackageId, typeArguments, registry
|
|
|
463
485
|
});
|
|
464
486
|
}
|
|
465
487
|
exports.consumeExpCoinStakedTx = consumeExpCoinStakedTx;
|
|
488
|
+
function getClaimProfitSharingTx(gasBudget, packageId, registry) {
|
|
489
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
490
|
+
var tx;
|
|
491
|
+
return __generator(this, function (_a) {
|
|
492
|
+
tx = new transactions_1.TransactionBlock();
|
|
493
|
+
tx.moveCall({
|
|
494
|
+
target: "".concat(packageId, "::tails_staking::claim_profit_sharing"),
|
|
495
|
+
typeArguments: ["0x2::sui::SUI"],
|
|
496
|
+
arguments: [tx.object(registry)],
|
|
497
|
+
});
|
|
498
|
+
tx.setGasBudget(gasBudget);
|
|
499
|
+
return [2 /*return*/, tx];
|
|
500
|
+
});
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
exports.getClaimProfitSharingTx = getClaimProfitSharingTx;
|
|
@@ -30,6 +30,7 @@ export interface Game {
|
|
|
30
30
|
vrf_input_2: number[] | null;
|
|
31
31
|
}
|
|
32
32
|
export declare function getHistory(provider: SuiClient, dicePackage: string, playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
33
|
+
export declare function parseHistory(datas: any, playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
33
34
|
interface DrawDisplay {
|
|
34
35
|
game_id: string;
|
|
35
36
|
player: string;
|
|
@@ -40,6 +41,12 @@ interface DrawDisplay {
|
|
|
40
41
|
bet_amount: string;
|
|
41
42
|
exp: string;
|
|
42
43
|
}
|
|
44
|
+
export interface LeaderBoard {
|
|
45
|
+
player: string;
|
|
46
|
+
total_bet_amount: number;
|
|
47
|
+
total_earn_exp: number;
|
|
48
|
+
}
|
|
49
|
+
export declare function getLeaderBoard(drawDisplays: DrawDisplay[]): Promise<LeaderBoard[]>;
|
|
43
50
|
export interface ProfitSharing {
|
|
44
51
|
level_profits: string[];
|
|
45
52
|
level_users: string[];
|
|
@@ -35,8 +35,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
38
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.calculateLevelReward = exports.getProfitSharing = exports.getHistory = exports.getPlaygrounds = void 0;
|
|
50
|
+
exports.calculateLevelReward = exports.getProfitSharing = exports.getLeaderBoard = exports.parseHistory = exports.getHistory = exports.getPlaygrounds = void 0;
|
|
40
51
|
var token_1 = require("../token");
|
|
41
52
|
function getPlaygrounds(provider, diceRegistry) {
|
|
42
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -79,6 +90,7 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
79
90
|
game_config: game_config,
|
|
80
91
|
is_active: fields.is_active,
|
|
81
92
|
};
|
|
93
|
+
// console.log(playground);
|
|
82
94
|
return playground;
|
|
83
95
|
});
|
|
84
96
|
return [2 /*return*/, result];
|
|
@@ -89,7 +101,7 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
89
101
|
exports.getPlaygrounds = getPlaygrounds;
|
|
90
102
|
function getHistory(provider, dicePackage, playgrounds) {
|
|
91
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
-
var eventFilter,
|
|
104
|
+
var eventFilter, result, history, nextPage;
|
|
93
105
|
return __generator(this, function (_a) {
|
|
94
106
|
switch (_a.label) {
|
|
95
107
|
case 0:
|
|
@@ -98,57 +110,118 @@ function getHistory(provider, dicePackage, playgrounds) {
|
|
|
98
110
|
};
|
|
99
111
|
return [4 /*yield*/, provider.queryEvents({ query: eventFilter, order: "descending" })];
|
|
100
112
|
case 1:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
break;
|
|
118
|
-
case "2":
|
|
119
|
-
result_1 += " C";
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
var result_2 = "".concat(Number(drawEvent.answer_2) / 100);
|
|
123
|
-
switch (drawEvent.result_2) {
|
|
124
|
-
case "0":
|
|
125
|
-
result_2 += " W";
|
|
126
|
-
break;
|
|
127
|
-
case "1":
|
|
128
|
-
result_2 += " L";
|
|
129
|
-
break;
|
|
130
|
-
case "2":
|
|
131
|
-
result_2 += " C";
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
var display = {
|
|
135
|
-
game_id: drawEvent.game_id,
|
|
136
|
-
player: drawEvent.player,
|
|
137
|
-
guess_1: guess_1,
|
|
138
|
-
guess_2: guess_2,
|
|
139
|
-
result_1: result_1,
|
|
140
|
-
result_2: result_2,
|
|
141
|
-
bet_amount: "".concat(Number(drawEvent.stake_amount) / Math.pow(10, decimal), " ").concat(asset),
|
|
142
|
-
exp: "".concat(Number(drawEvent.exp), " EXP"),
|
|
143
|
-
};
|
|
144
|
-
return display;
|
|
145
|
-
});
|
|
146
|
-
return [2 /*return*/, result];
|
|
113
|
+
result = _a.sent();
|
|
114
|
+
return [4 /*yield*/, parseHistory(result.data, playgrounds)];
|
|
115
|
+
case 2:
|
|
116
|
+
history = _a.sent();
|
|
117
|
+
_a.label = 3;
|
|
118
|
+
case 3:
|
|
119
|
+
if (!result.hasNextPage) return [3 /*break*/, 6];
|
|
120
|
+
return [4 /*yield*/, provider.queryEvents({ query: eventFilter, order: "descending", cursor: result.nextCursor })];
|
|
121
|
+
case 4:
|
|
122
|
+
result = _a.sent();
|
|
123
|
+
return [4 /*yield*/, parseHistory(result.data, playgrounds)];
|
|
124
|
+
case 5:
|
|
125
|
+
nextPage = _a.sent();
|
|
126
|
+
history = history.concat(nextPage);
|
|
127
|
+
return [3 /*break*/, 3];
|
|
128
|
+
case 6: return [2 /*return*/, history];
|
|
147
129
|
}
|
|
148
130
|
});
|
|
149
131
|
});
|
|
150
132
|
}
|
|
151
133
|
exports.getHistory = getHistory;
|
|
134
|
+
function parseHistory(datas, playgrounds) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var result;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
result = datas.map(function (event) {
|
|
139
|
+
var drawEvent = event.parsedJson;
|
|
140
|
+
var playground = playgrounds[Number(drawEvent.index)];
|
|
141
|
+
var coinType = "0x" + playground.stake_token;
|
|
142
|
+
var asset = (0, token_1.typeArgToAsset)(coinType);
|
|
143
|
+
var decimal = (0, token_1.assetToDecimal)(asset);
|
|
144
|
+
var guess_1 = (drawEvent.larger_than_1 ? "> " : "< ") + "".concat(Number(drawEvent.guess_1) / 100);
|
|
145
|
+
var guess_2 = (drawEvent.larger_than_2 ? "> " : "< ") + "".concat(Number(drawEvent.guess_2) / 100);
|
|
146
|
+
var result_1 = "".concat(Number(drawEvent.answer_1) / 100);
|
|
147
|
+
switch (drawEvent.result_1) {
|
|
148
|
+
case "0":
|
|
149
|
+
result_1 += " W";
|
|
150
|
+
break;
|
|
151
|
+
case "1":
|
|
152
|
+
result_1 += " L";
|
|
153
|
+
break;
|
|
154
|
+
case "2":
|
|
155
|
+
result_1 += " C";
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
var result_2 = "".concat(Number(drawEvent.answer_2) / 100);
|
|
159
|
+
switch (drawEvent.result_2) {
|
|
160
|
+
case "0":
|
|
161
|
+
result_2 += " W";
|
|
162
|
+
break;
|
|
163
|
+
case "1":
|
|
164
|
+
result_2 += " L";
|
|
165
|
+
break;
|
|
166
|
+
case "2":
|
|
167
|
+
result_2 += " C";
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
var display = {
|
|
171
|
+
game_id: drawEvent.game_id,
|
|
172
|
+
player: drawEvent.player,
|
|
173
|
+
guess_1: guess_1,
|
|
174
|
+
guess_2: guess_2,
|
|
175
|
+
result_1: result_1,
|
|
176
|
+
result_2: result_2,
|
|
177
|
+
bet_amount: "".concat(Number(drawEvent.stake_amount) / Math.pow(10, decimal), " ").concat(asset),
|
|
178
|
+
exp: "".concat(Number(drawEvent.exp), " EXP"),
|
|
179
|
+
};
|
|
180
|
+
return display;
|
|
181
|
+
});
|
|
182
|
+
return [2 /*return*/, result];
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
exports.parseHistory = parseHistory;
|
|
187
|
+
function getLeaderBoard(drawDisplays) {
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var leaderBoard, _loop_1, drawDisplays_1, drawDisplays_1_1, drawDisplay;
|
|
190
|
+
var e_1, _a;
|
|
191
|
+
return __generator(this, function (_b) {
|
|
192
|
+
leaderBoard = [];
|
|
193
|
+
_loop_1 = function (drawDisplay) {
|
|
194
|
+
var i = leaderBoard.findIndex(function (x) { return x.player == drawDisplay.player; });
|
|
195
|
+
if (i == -1) {
|
|
196
|
+
leaderBoard.push({
|
|
197
|
+
player: drawDisplay.player,
|
|
198
|
+
total_bet_amount: Number(drawDisplay.bet_amount.split(" ")[0]),
|
|
199
|
+
total_earn_exp: Number(drawDisplay.exp.split(" ")[0]),
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
leaderBoard[i].total_bet_amount += Number(drawDisplay.bet_amount.split(" ")[0]);
|
|
204
|
+
leaderBoard[i].total_earn_exp += Number(drawDisplay.exp.split(" ")[0]);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
try {
|
|
208
|
+
for (drawDisplays_1 = __values(drawDisplays), drawDisplays_1_1 = drawDisplays_1.next(); !drawDisplays_1_1.done; drawDisplays_1_1 = drawDisplays_1.next()) {
|
|
209
|
+
drawDisplay = drawDisplays_1_1.value;
|
|
210
|
+
_loop_1(drawDisplay);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
214
|
+
finally {
|
|
215
|
+
try {
|
|
216
|
+
if (drawDisplays_1_1 && !drawDisplays_1_1.done && (_a = drawDisplays_1.return)) _a.call(drawDisplays_1);
|
|
217
|
+
}
|
|
218
|
+
finally { if (e_1) throw e_1.error; }
|
|
219
|
+
}
|
|
220
|
+
return [2 /*return*/, leaderBoard];
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
exports.getLeaderBoard = getLeaderBoard;
|
|
152
225
|
function getProfitSharing(provider, diceProfitSharing) {
|
|
153
226
|
var _a, _b;
|
|
154
227
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -179,14 +252,16 @@ function calculateLevelReward(totalRewards, levelShares, numOfHolders) {
|
|
|
179
252
|
var originalLevelRewards = originalRewardPerHolder.map(function (reward, index) { return reward * numOfHolders[index]; });
|
|
180
253
|
var distributedRewards = originalLevelRewards.reduce(function (acc, reward) { return acc + reward; }, 0);
|
|
181
254
|
var emptyLevelRewards = totalRewards - distributedRewards;
|
|
182
|
-
// console.log("Step 1 - ",
|
|
255
|
+
// console.log("Step 1 - ", originalRewardPerHolder);
|
|
183
256
|
// Step 2: Distribute rewards from empty levels
|
|
184
|
-
var
|
|
257
|
+
var reversedOriginalRewardPerHolder = originalRewardPerHolder.slice().reverse();
|
|
258
|
+
var reversedNumOfHolders = numOfHolders.slice().reverse();
|
|
259
|
+
var reversedScaledRewardPerHolder = [];
|
|
185
260
|
if (emptyLevelRewards > 0) {
|
|
186
261
|
var undistributedRewards_1 = emptyLevelRewards;
|
|
187
262
|
var uncalculatedDistributedRewards_1 = distributedRewards;
|
|
188
|
-
|
|
189
|
-
var num =
|
|
263
|
+
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
264
|
+
var num = reversedNumOfHolders[index];
|
|
190
265
|
var scaledRewardPerHolder = num > 0
|
|
191
266
|
? uncalculatedDistributedRewards_1 > 0
|
|
192
267
|
? (rewardPerHolder * (uncalculatedDistributedRewards_1 + undistributedRewards_1)) / uncalculatedDistributedRewards_1
|
|
@@ -198,32 +273,43 @@ function calculateLevelReward(totalRewards, levelShares, numOfHolders) {
|
|
|
198
273
|
});
|
|
199
274
|
}
|
|
200
275
|
else {
|
|
201
|
-
|
|
276
|
+
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.slice();
|
|
202
277
|
}
|
|
278
|
+
// let scaledRewardPerHolder: number[] = reversedScaledRewardPerHolder.slice().reverse();
|
|
203
279
|
// console.log("Step 2 - ", scaledRewardPerHolder);
|
|
204
280
|
// Step 3: Capped level reward
|
|
205
|
-
var
|
|
281
|
+
var reversedCappedRewardPerHolder = [reversedOriginalRewardPerHolder[0]];
|
|
206
282
|
var tempHighLevelReward = 0;
|
|
207
|
-
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
283
|
+
reversedScaledRewardPerHolder.forEach(function (highLevelReward, index) {
|
|
284
|
+
var lowLevelReward = reversedScaledRewardPerHolder[index + 1] || 0;
|
|
285
|
+
tempHighLevelReward =
|
|
286
|
+
highLevelReward > 0
|
|
287
|
+
? tempHighLevelReward > 0
|
|
288
|
+
? Math.min(highLevelReward, tempHighLevelReward)
|
|
289
|
+
: highLevelReward
|
|
290
|
+
: tempHighLevelReward;
|
|
291
|
+
reversedCappedRewardPerHolder.push(tempHighLevelReward > 0 ? Math.min(lowLevelReward, tempHighLevelReward) : lowLevelReward);
|
|
213
292
|
});
|
|
293
|
+
reversedCappedRewardPerHolder.pop();
|
|
294
|
+
var cappedRewardPerHolder = reversedCappedRewardPerHolder.slice().reverse();
|
|
214
295
|
// console.log("Step 3 - ", cappedRewardPerHolder);
|
|
215
296
|
// Step 4: Distribute capped reward from Step 3 into each level
|
|
216
|
-
var distributedRewardsStep4 =
|
|
297
|
+
var distributedRewardsStep4 = reversedCappedRewardPerHolder.reduce(function (acc, reward, index) { return acc + reward * reversedNumOfHolders[index]; }, 0);
|
|
217
298
|
var undistributedRewardsStep4 = totalRewards - distributedRewardsStep4;
|
|
218
299
|
var uncalculatedDistributedRewardsStep4 = distributedRewardsStep4;
|
|
300
|
+
// console.log(distributedRewardsStep4);
|
|
301
|
+
// console.log(totalRewards);
|
|
302
|
+
// console.log(undistributedRewardsStep4);
|
|
303
|
+
// console.log(uncalculatedDistributedRewardsStep4);
|
|
219
304
|
var levelReward = cappedRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
220
|
-
var num =
|
|
305
|
+
var num = reversedNumOfHolders[index];
|
|
221
306
|
var scaledRewardPerHolder = uncalculatedDistributedRewardsStep4 > 0
|
|
222
307
|
? (rewardPerHolder * (uncalculatedDistributedRewardsStep4 + undistributedRewardsStep4)) /
|
|
223
308
|
uncalculatedDistributedRewardsStep4
|
|
224
309
|
: rewardPerHolder;
|
|
225
310
|
undistributedRewardsStep4 -= (scaledRewardPerHolder - rewardPerHolder) * num;
|
|
226
311
|
uncalculatedDistributedRewardsStep4 -= rewardPerHolder * num;
|
|
312
|
+
// console.log(undistributedRewardsStep4);
|
|
227
313
|
return Math.floor(scaledRewardPerHolder);
|
|
228
314
|
});
|
|
229
315
|
// console.log("Step 4 - ", levelReward);
|
|
@@ -56,7 +56,7 @@ export declare function getHarvestTx(gasBudget: number, typusFrameworkPackageId:
|
|
|
56
56
|
index: string;
|
|
57
57
|
receipts: string[];
|
|
58
58
|
}[]): Promise<TransactionBlock>;
|
|
59
|
-
export declare function
|
|
59
|
+
export declare function getBatchClaimHarvestWithdrawRedeemTx(gasBudget: number, typusFrameworkPackageId: string, packageId: string, registry: string, claimRequests: {
|
|
60
60
|
typeArguments: string[];
|
|
61
61
|
index: string;
|
|
62
62
|
receipts: string[];
|
|
@@ -68,6 +68,10 @@ export declare function getBatchClaimHarvestWithdrawTx(gasBudget: number, typusF
|
|
|
68
68
|
typeArguments: string[];
|
|
69
69
|
index: string;
|
|
70
70
|
receipts: string[];
|
|
71
|
+
}[], redeemRequests: {
|
|
72
|
+
typeArguments: string[];
|
|
73
|
+
index: string;
|
|
74
|
+
receipts: string[];
|
|
71
75
|
}[]): Promise<TransactionBlock>;
|
|
72
76
|
/**
|
|
73
77
|
public(friend) entry fun compound<D_TOKEN, B_TOKEN>(
|
|
@@ -52,7 +52,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.getRebateTx = exports.getExerciseTx = exports.getTransferBidReceiptTx = exports.getNewBidTx = exports.getCompoundTx = exports.
|
|
55
|
+
exports.getRebateTx = exports.getExerciseTx = exports.getTransferBidReceiptTx = exports.getNewBidTx = exports.getCompoundTx = exports.getBatchClaimHarvestWithdrawRedeemTx = exports.getHarvestTx = exports.getClaimTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getDepositTx = void 0;
|
|
56
56
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
57
57
|
var constants_1 = require("../../constants");
|
|
58
58
|
/**
|
|
@@ -248,7 +248,7 @@ function getHarvestTx(gasBudget, typusFrameworkPackageId, packageId, registry, r
|
|
|
248
248
|
});
|
|
249
249
|
}
|
|
250
250
|
exports.getHarvestTx = getHarvestTx;
|
|
251
|
-
function
|
|
251
|
+
function getBatchClaimHarvestWithdrawRedeemTx(gasBudget, typusFrameworkPackageId, packageId, registry, claimRequests, harvestRequests, withdrawRequests, redeemRequests) {
|
|
252
252
|
return __awaiter(this, void 0, void 0, function () {
|
|
253
253
|
var tx;
|
|
254
254
|
return __generator(this, function (_a) {
|
|
@@ -297,12 +297,27 @@ function getBatchClaimHarvestWithdrawTx(gasBudget, typusFrameworkPackageId, pack
|
|
|
297
297
|
],
|
|
298
298
|
});
|
|
299
299
|
});
|
|
300
|
+
redeemRequests.forEach(function (request) {
|
|
301
|
+
tx.moveCall({
|
|
302
|
+
target: "".concat(packageId, "::tds_user_entry::redeem"),
|
|
303
|
+
typeArguments: request.typeArguments,
|
|
304
|
+
arguments: [
|
|
305
|
+
tx.object(registry),
|
|
306
|
+
tx.pure(request.index),
|
|
307
|
+
tx.makeMoveVec({
|
|
308
|
+
type: "".concat(typusFrameworkPackageId, "::vault::TypusDepositReceipt"),
|
|
309
|
+
objects: request.receipts.map(function (id) { return tx.object(id); }),
|
|
310
|
+
}),
|
|
311
|
+
tx.pure(constants_1.CLOCK),
|
|
312
|
+
],
|
|
313
|
+
});
|
|
314
|
+
});
|
|
300
315
|
tx.setGasBudget(gasBudget);
|
|
301
316
|
return [2 /*return*/, tx];
|
|
302
317
|
});
|
|
303
318
|
});
|
|
304
319
|
}
|
|
305
|
-
exports.
|
|
320
|
+
exports.getBatchClaimHarvestWithdrawRedeemTx = getBatchClaimHarvestWithdrawRedeemTx;
|
|
306
321
|
/**
|
|
307
322
|
public(friend) entry fun compound<D_TOKEN, B_TOKEN>(
|
|
308
323
|
registry: &mut Registry,
|
package/package.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.46",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mysten/bcs": "^0.7.3",
|
|
8
8
|
"@mysten/kiosk": "0.7.11",
|
|
9
|
-
"@mysten/sui.js": "0.47.0",
|
|
9
|
+
"@mysten/sui.js": "^0.47.0",
|
|
10
10
|
"@types/node": "^20.5.7",
|
|
11
11
|
"bignumber.js": "^9.1.1",
|
|
12
12
|
"bs58": "^5.0.0",
|