@typus/typus-sdk 0.3.6 → 0.3.7
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
CHANGED
|
@@ -3,11 +3,11 @@ export declare const TOKEN_REGISTRY_BTC = "0xe0dc19dfc9023f2e86462aa37dc8fae290b
|
|
|
3
3
|
export declare const TOKEN_REGISTRY_ETH = "0x9ad1db50850079e98d5972e3d9a8fdc90b9d1f19";
|
|
4
4
|
export declare const TOKEN_REGISTRY_SUI = "0xc6128d63d24cbdb66e50cef4577e5cf36bb889e1";
|
|
5
5
|
export declare const ORACLE_PACKAGE = "0x0d4b13cc0467c0620ce54abf703faa3b419d967b";
|
|
6
|
-
export declare const COVERED_CALL_PACKAGE = "
|
|
7
|
-
export declare const COVERED_CALL_REGISTRY = "
|
|
8
|
-
export declare const COVERED_CALL_MANAGER = "
|
|
9
|
-
export declare const USER_SHARE_TABLE = "
|
|
10
|
-
export declare const MAKER_SHARE_TABLE = "
|
|
6
|
+
export declare const COVERED_CALL_PACKAGE = "0x9e02627cbd517b378cb2119862f618078246c813";
|
|
7
|
+
export declare const COVERED_CALL_REGISTRY = "0x3b94b2ead34d0f617c6302ceb2f4e4cb8ff69ae6";
|
|
8
|
+
export declare const COVERED_CALL_MANAGER = "0x10f71ab8bac2a9be4d4972e07a1ea67bef94c263";
|
|
9
|
+
export declare const USER_SHARE_TABLE = "0xa885de38c4e3a28c136ea6aa6cc49a934261042a";
|
|
10
|
+
export declare const MAKER_SHARE_TABLE = "0x70241eccfc271f3c54efc56392f5a6c77950501e";
|
|
11
11
|
export declare const DOV_PACKAGE = "0x1bf2cad8d9d4d11a8e2c981b0f6a9c9744887776";
|
|
12
12
|
export declare const TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
13
13
|
export declare const PRICE_DECIMAL = 8;
|
package/lib/constants.js
CHANGED
|
@@ -9,11 +9,11 @@ exports.TOKEN_REGISTRY_SUI = "0xc6128d63d24cbdb66e50cef4577e5cf36bb889e1"; //fak
|
|
|
9
9
|
//publish from typus-oracle
|
|
10
10
|
exports.ORACLE_PACKAGE = "0x0d4b13cc0467c0620ce54abf703faa3b419d967b";
|
|
11
11
|
//publish from typus-dov/cover_call
|
|
12
|
-
exports.COVERED_CALL_PACKAGE = "
|
|
13
|
-
exports.COVERED_CALL_REGISTRY = "
|
|
14
|
-
exports.COVERED_CALL_MANAGER = "
|
|
15
|
-
exports.USER_SHARE_TABLE = "
|
|
16
|
-
exports.MAKER_SHARE_TABLE = "
|
|
12
|
+
exports.COVERED_CALL_PACKAGE = "0x9e02627cbd517b378cb2119862f618078246c813";
|
|
13
|
+
exports.COVERED_CALL_REGISTRY = "0x3b94b2ead34d0f617c6302ceb2f4e4cb8ff69ae6";
|
|
14
|
+
exports.COVERED_CALL_MANAGER = "0x10f71ab8bac2a9be4d4972e07a1ea67bef94c263";
|
|
15
|
+
exports.USER_SHARE_TABLE = "0xa885de38c4e3a28c136ea6aa6cc49a934261042a";
|
|
16
|
+
exports.MAKER_SHARE_TABLE = "0x70241eccfc271f3c54efc56392f5a6c77950501e";
|
|
17
17
|
//publish from typus-dov/typus-dov
|
|
18
18
|
exports.DOV_PACKAGE = "0x1bf2cad8d9d4d11a8e2c981b0f6a9c9744887776";
|
|
19
19
|
exports.TEST_MINT_TOKEN = "0x672612858fcb5c6abf944638253142820c251753";
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function getBidEventsCranker(type: string, renewSec: number): Promise<void>;
|
|
2
|
+
export declare function getNewAuctionEventsCranker(type: string, renewSec: number): Promise<void>;
|
|
@@ -39,34 +39,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
39
39
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.getNewAuctionEventsCranker = exports.getBidEventsCranker = void 0;
|
|
42
43
|
var constants_1 = require("../constants");
|
|
43
44
|
var sui_js_1 = require("@mysten/sui.js");
|
|
44
45
|
var node_cron_1 = __importDefault(require("node-cron"));
|
|
45
46
|
var provider = new sui_js_1.JsonRpcProvider(sui_js_1.Network.DEVNET); //for read only operations
|
|
46
|
-
var keypair = sui_js_1.Ed25519Keypair.deriveKeypair(constants_1.TEST_MNEMONIC);
|
|
47
47
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var bidType, newAuctionType, renewSec;
|
|
48
49
|
return __generator(this, function (_a) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// throw new Error('Not a MoveEvent')
|
|
63
|
-
// }
|
|
64
|
-
console.log(event);
|
|
65
|
-
});
|
|
66
|
-
return [2 /*return*/];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); });
|
|
70
|
-
return [2 /*return*/];
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
bidType = constants_1.DOV_PACKAGE + "::dutch::NewBid<" + constants_1.TOKEN_PACKAGE + "::eth::ETH>";
|
|
53
|
+
newAuctionType = constants_1.COVERED_CALL_PACKAGE + "::covered_call::NewAuction";
|
|
54
|
+
renewSec = 10;
|
|
55
|
+
return [4 /*yield*/, getBidEventsCranker(bidType, renewSec)];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
return [4 /*yield*/, getNewAuctionEventsCranker(newAuctionType, renewSec)];
|
|
59
|
+
case 2:
|
|
60
|
+
_a.sent();
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
}
|
|
71
63
|
});
|
|
72
64
|
}); })();
|
|
65
|
+
function getBidEventsCranker(type, renewSec) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
+
var res;
|
|
68
|
+
var _this = this;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
res = [];
|
|
71
|
+
node_cron_1.default.schedule('*/' + renewSec.toString() + ' * * * * *', function () { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var events, newRes, newBid;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
console.log("listening for every " + renewSec.toString() + " s...");
|
|
77
|
+
return [4 /*yield*/, provider.getEvents(
|
|
78
|
+
/// from object id , can only get one event
|
|
79
|
+
// { Object: "0x89bc7299c684413ab81f7536603451277b8ed754" },
|
|
80
|
+
// { Transaction: "4aTaXLyCwT9geQg5PC3UAGGBMbuySFCzeJ6Cf62RrUEg"},
|
|
81
|
+
{ MoveEvent: type }, null, null)];
|
|
82
|
+
case 1:
|
|
83
|
+
events = _a.sent();
|
|
84
|
+
newRes = events.data;
|
|
85
|
+
if (newRes.length != res.length) {
|
|
86
|
+
console.log("the total bid event number now:" + events.data.length);
|
|
87
|
+
console.log("there are " + (newRes.length - res.length).toString() + " new bids");
|
|
88
|
+
newBid = newRes.filter(function (e) {
|
|
89
|
+
return res.indexOf(e) === -1;
|
|
90
|
+
});
|
|
91
|
+
newBid.map(function (e) { console.log(e.event.moveEvent.fields); });
|
|
92
|
+
res = newRes;
|
|
93
|
+
}
|
|
94
|
+
return [2 /*return*/];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}); });
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
exports.getBidEventsCranker = getBidEventsCranker;
|
|
103
|
+
function getNewAuctionEventsCranker(type, renewSec) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
return [2 /*return*/];
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.getNewAuctionEventsCranker = getNewAuctionEventsCranker;
|
package/lib/utils/fetchData.d.ts
CHANGED
|
@@ -51,6 +51,10 @@ export interface Auction {
|
|
|
51
51
|
priceConfig: PriceConfig;
|
|
52
52
|
index: string;
|
|
53
53
|
}
|
|
54
|
+
export interface DeliveryInfo {
|
|
55
|
+
deliveryPrice: string;
|
|
56
|
+
deliverySize: string;
|
|
57
|
+
}
|
|
54
58
|
export interface CoveredCallVault {
|
|
55
59
|
vaultId: string;
|
|
56
60
|
vaultIdx: string;
|
|
@@ -58,10 +62,10 @@ export interface CoveredCallVault {
|
|
|
58
62
|
config: Config;
|
|
59
63
|
vault: Vault;
|
|
60
64
|
auction: Auction;
|
|
61
|
-
|
|
65
|
+
prev: string;
|
|
62
66
|
next: string;
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
totalBidSize: string;
|
|
68
|
+
deliveryInfo: DeliveryInfo;
|
|
65
69
|
owner: string;
|
|
66
70
|
tvl: string;
|
|
67
71
|
vaultBidPrice: string;
|
|
@@ -88,7 +88,7 @@ function getVaultDataFromRegistry(registry) {
|
|
|
88
88
|
case 3:
|
|
89
89
|
_a = __read.apply(void 0, [_c.sent(), 2]), timeOracle = _a[0], _ = _a[1];
|
|
90
90
|
_loop_1 = function (objInfo) {
|
|
91
|
-
var vaultId, vaultIdx, type, asset, config, vault,
|
|
91
|
+
var vaultId, vaultIdx, type, asset, config, vault, prev, vaultConfig, vaultConfigRes, nextVaultConfig, nextVaultConfigRes, payoffConfig, payoffConfigRes, configRes, maker, regular, rolling, vaultRes, auctionRes, vaultBidPrice, auction, priceConfig, priceConfigRes, next, totalBidSize, deliveryInfo, owner, tvl, res;
|
|
92
92
|
return __generator(this, function (_d) {
|
|
93
93
|
switch (_d.label) {
|
|
94
94
|
case 0:
|
|
@@ -106,7 +106,8 @@ function getVaultDataFromRegistry(registry) {
|
|
|
106
106
|
}
|
|
107
107
|
config = objInfo.details.data.fields.value.fields.config.fields;
|
|
108
108
|
vault = objInfo.details.data.fields.value.fields.vault.fields;
|
|
109
|
-
|
|
109
|
+
prev = objInfo.details.data.fields.value.fields.prev;
|
|
110
|
+
prev = (prev != null) ? prev : 0;
|
|
110
111
|
vaultConfig = config.vault_config.fields;
|
|
111
112
|
vaultConfigRes = {
|
|
112
113
|
strikeOtmPct: vaultConfig.strike_otm_pct,
|
|
@@ -189,8 +190,8 @@ function getVaultDataFromRegistry(registry) {
|
|
|
189
190
|
_d.label = 3;
|
|
190
191
|
case 3:
|
|
191
192
|
next = objInfo.details.data.fields.value.fields.next;
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
totalBidSize = objInfo.details.data.fields.value.fields.total_bid_size;
|
|
194
|
+
deliveryInfo = objInfo.details.data.fields.value.fields.delivery_info;
|
|
194
195
|
owner = objInfo.details.data.fields.value.fields.owner;
|
|
195
196
|
tvl = Number(vault.regular_sub_vault.fields.balance) + Number(vault.rolling_sub_vault.fields.balance);
|
|
196
197
|
res = {
|
|
@@ -200,10 +201,10 @@ function getVaultDataFromRegistry(registry) {
|
|
|
200
201
|
config: configRes,
|
|
201
202
|
vault: vaultRes,
|
|
202
203
|
auction: auctionRes,
|
|
203
|
-
|
|
204
|
+
prev: prev.toString(),
|
|
204
205
|
next: next,
|
|
205
|
-
|
|
206
|
-
|
|
206
|
+
totalBidSize: totalBidSize,
|
|
207
|
+
deliveryInfo: deliveryInfo,
|
|
207
208
|
owner: owner,
|
|
208
209
|
tvl: tvl.toString(),
|
|
209
210
|
vaultBidPrice: vaultBidPrice.toString(),
|