@typus/typus-sdk 1.7.10 → 1.7.12
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/dist/src/constants/token.d.ts +1 -1
- package/dist/src/constants/token.js +14 -1
- package/dist/src/typus-dov-single-v2/authority-entry.d.ts +59 -0
- package/dist/src/typus-dov-single-v2/authority-entry.js +77 -0
- package/dist/src/typus-dov-single-v2/otc-entry.d.ts +2 -1
- package/dist/src/typus-dov-single-v2/otc-entry.js +16 -20
- package/dist/src/typus-hedge/index.d.ts +2 -0
- package/dist/src/typus-hedge/index.js +22 -0
- package/dist/src/typus-hedge/user-entry.d.ts +74 -0
- package/dist/src/typus-hedge/user-entry.js +155 -0
- package/dist/src/typus-hedge/view-function.d.ts +75 -0
- package/dist/src/typus-hedge/view-function.js +269 -0
- package/dist/src/utils/typusConfig.d.ts +11 -0
- package/dist/src/utils/typusConfig.js +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@ export declare const tokenType: {
|
|
|
9
9
|
[key in TOKEN]: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export type TOKEN = "SUI" | "CETUS" | "TURBOS" | "NAVX" | "SCA" | "DEEP" | "BLUE" | "TYPUS" | "NS" | "WAL" | "HAEDAL" | "FUD" | "BLUB" | "LIQ" | "HIPPO" | "MFUD" | "MBLUB" | "MLIQ" | "BUCK" | "USDY" | "AUSD" | "USDC" | "wSOL" | "wAPT" | "WBTC" | "wETH" | "wUSDC" | "wUSDT" | "sbETH" | "sbUSDT" | "VSUI" | "HASUI" | "AFSUI" | "SPSUI" | "STSUI" | "INJ" | "JUP" | "SEI" | "JPY" | "XAU" | "DOGE" | "HYPE" | "XRP" | "sSCA" | "
|
|
12
|
+
export type TOKEN = "SUI" | "CETUS" | "TURBOS" | "NAVX" | "SCA" | "DEEP" | "BLUE" | "TYPUS" | "NS" | "WAL" | "HAEDAL" | "FUD" | "BLUB" | "LIQ" | "HIPPO" | "MFUD" | "MBLUB" | "MLIQ" | "BUCK" | "USDY" | "AUSD" | "USDC" | "wSOL" | "wAPT" | "WBTC" | "wETH" | "wUSDC" | "wUSDT" | "sbETH" | "sbUSDT" | "sbBTC" | "LBTC" | "xBTC" | "TBTC" | "VSUI" | "HASUI" | "AFSUI" | "SPSUI" | "STSUI" | "INJ" | "JUP" | "SEI" | "JPY" | "XAU" | "DOGE" | "HYPE" | "XRP" | "sSCA" | "TEXP" | "USD";
|
|
13
13
|
export declare const oracle: {
|
|
14
14
|
MAINNET: {
|
|
15
15
|
[key in TOKEN]?: string;
|
|
@@ -168,9 +168,13 @@ function typeArgToAsset(typeArg) {
|
|
|
168
168
|
case "0x3e8e9423d80e1774a7ca128fccd8bf5f1f7753be658c5e645929037f7c819040::lbtc::LBTC": // MAINNET
|
|
169
169
|
return "LBTC";
|
|
170
170
|
case "0x876a4b7bce8aeaef60464c11f4026903e9afacab79b9b142686158aa86560b50::xbtc::XBTC": // MAINNET
|
|
171
|
-
return "xBTC";
|
|
172
171
|
case "0x8ec68007c61b79244decfecc7f1e024ff60a9354dcb1ff37af94ad03f7e71d2e::xbtc::XBTC": // TESTNET
|
|
173
172
|
return "xBTC";
|
|
173
|
+
case "0xaafb102dd0902f5055cadecd687fb5b71ca82ef0e0285d90afde828ec58ca96b::btc::BTC": // MAINNET
|
|
174
|
+
return "sbBTC";
|
|
175
|
+
case "0x77045f1b9f811a7a8fb9ebd085b5b0c55c5cb0d1520ff55f7037f89b5da9f5f1::TBTC::TBTC": // MAINNET
|
|
176
|
+
case "0xee81baea02ef47860153569bc2f86eafb58baa81aab4e5b910950a4c72aae861::tbtc::TBTC": // TESTNET
|
|
177
|
+
return "TBTC";
|
|
174
178
|
case "0x732f66e6e97c0f6b7250a5f43dc3576e225ae6e7578862a9b122915f6ff63988::xau::XAU": // MAINNET
|
|
175
179
|
case "0x3ec6cda6b1d7003290004674e82d56530f354b4754f63334cf988a1bcd5535a4::xau::XAU": // TESTNET
|
|
176
180
|
return "XAU";
|
|
@@ -222,6 +226,8 @@ function assetToDecimal(asset) {
|
|
|
222
226
|
case "HYPE":
|
|
223
227
|
case "XRP":
|
|
224
228
|
case "DOGE":
|
|
229
|
+
case "TBTC":
|
|
230
|
+
case "sbBTC":
|
|
225
231
|
return 8;
|
|
226
232
|
case "USDC":
|
|
227
233
|
case "wUSDC":
|
|
@@ -292,6 +298,8 @@ exports.tokenType = {
|
|
|
292
298
|
DOGE: "0x292dd8bc71bff5714f79dd7d9c15bfc6e22bbfb07ef40bf320d61cd050dad929::doge::DOGE",
|
|
293
299
|
HYPE: "0x0746c122ecb19321768fb0dcfb34d237933fe306df05dc7bcd7140609a106ca5::hype::HYPE",
|
|
294
300
|
XRP: "0x188faaaa44e6276295ab92fdd3eb353e5f25fc35b9d965a5b8243f336af65b78::xrp::XRP",
|
|
301
|
+
sbBTC: "0xaafb102dd0902f5055cadecd687fb5b71ca82ef0e0285d90afde828ec58ca96b::btc::BTC",
|
|
302
|
+
TBTC: "0x77045f1b9f811a7a8fb9ebd085b5b0c55c5cb0d1520ff55f7037f89b5da9f5f1::TBTC::TBTC",
|
|
295
303
|
},
|
|
296
304
|
TESTNET: {
|
|
297
305
|
SUI: "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI",
|
|
@@ -342,6 +350,8 @@ exports.tokenType = {
|
|
|
342
350
|
DOGE: "",
|
|
343
351
|
HYPE: "",
|
|
344
352
|
XRP: "",
|
|
353
|
+
TBTC: "0xee81baea02ef47860153569bc2f86eafb58baa81aab4e5b910950a4c72aae861::tbtc::TBTC",
|
|
354
|
+
sbBTC: "",
|
|
345
355
|
},
|
|
346
356
|
};
|
|
347
357
|
exports.oracle = {
|
|
@@ -400,6 +410,7 @@ exports.oracle = {
|
|
|
400
410
|
NS: "0x4481ebc6a26ac72abb9ecbedba60fcba87440f1306c125c1bdf61d1248af4482",
|
|
401
411
|
JPY: "0xe4d5eaa453ffc3ee3a76b885b7a7d97756df5d4624d7d467c5d6da51f286f82b",
|
|
402
412
|
XAU: "0x172101af6fbaab02b2663ed7c502152431fed5d76ac865ac3ccad134c92d91db",
|
|
413
|
+
TBTC: "0x383cb3519e51c62d84ec54e2fca3438c43a83967738b364c20f0f2a662a668d5",
|
|
403
414
|
},
|
|
404
415
|
};
|
|
405
416
|
exports.tokenRegistry = {
|
|
@@ -427,5 +438,7 @@ exports.tokenRegistry = {
|
|
|
427
438
|
AUSD: "0xd87ea623f4f2635d66f59d7defaeb96e0147e0cdd8f5406756433d8d8849f785",
|
|
428
439
|
MFUD: "0x7ad87901531693f1baa541712947860dcc543617e11b14993ad70d20daf159c6",
|
|
429
440
|
MBLUB: "0x7c36d8c1b2b569676d9a3f4c73487ec49b483111cc0abf4b0d5654e026ac3d3a",
|
|
441
|
+
xBTC: "0x0701eee55ccf6ec7706e5a9b1c99c0733b49c3958f8f5a3503aea2e192706493",
|
|
442
|
+
TBTC: "0x94c1289dc6b129db6d5efc0ec49bde0e574e6ec34788b2f0fc8948ce5ed7d28a",
|
|
430
443
|
},
|
|
431
444
|
};
|
|
@@ -51,3 +51,62 @@ export declare function getUpdateConfigTx(config: TypusConfig, tx: Transaction,
|
|
|
51
51
|
depositIncentiveBpDivisorDecimal?: string;
|
|
52
52
|
};
|
|
53
53
|
}[]): Promise<Transaction>;
|
|
54
|
+
/**
|
|
55
|
+
public entry fun deposit_collateral_navi<TOKEN>(
|
|
56
|
+
registry: &mut Registry,
|
|
57
|
+
index: u64,
|
|
58
|
+
storage: &mut lending_core::storage::Storage,
|
|
59
|
+
pool: &mut lending_core::pool::Pool<TOKEN>,
|
|
60
|
+
asset: u8,
|
|
61
|
+
incentive_v2: &mut lending_core::incentive_v2::Incentive,
|
|
62
|
+
incentive_v3: &mut lending_core::incentive_v3::Incentive,
|
|
63
|
+
coin: Coin<TOKEN>,
|
|
64
|
+
clock: &Clock,
|
|
65
|
+
ctx: &mut TxContext,
|
|
66
|
+
) {
|
|
67
|
+
*/
|
|
68
|
+
export declare function depositCollateralNavi(config: TypusConfig, tx: Transaction, input: {
|
|
69
|
+
typeArguments: string[];
|
|
70
|
+
index: string;
|
|
71
|
+
raiseCoins: string[];
|
|
72
|
+
raiseAmount: string;
|
|
73
|
+
naviStorage: string;
|
|
74
|
+
naviPool: string;
|
|
75
|
+
naviAsset: number;
|
|
76
|
+
naviIncentiveV2: string;
|
|
77
|
+
naviIncentiveV3: string;
|
|
78
|
+
}): void;
|
|
79
|
+
/**
|
|
80
|
+
public entry fun withdraw_collateral_navi<TOKEN>(
|
|
81
|
+
registry: &mut Registry,
|
|
82
|
+
index: u64,
|
|
83
|
+
oracle_config: &mut OracleConfig,
|
|
84
|
+
price_oracle: &mut PriceOracle,
|
|
85
|
+
supra_oracle_holder: &SupraOracle::SupraSValueFeed::OracleHolder,
|
|
86
|
+
pyth_price_info: &pyth::price_info::PriceInfoObject,
|
|
87
|
+
feed_address: address,
|
|
88
|
+
storage: &mut lending_core::storage::Storage,
|
|
89
|
+
pool: &mut lending_core::pool::Pool<TOKEN>,
|
|
90
|
+
asset: u8,
|
|
91
|
+
incentive_v2: &mut lending_core::incentive_v2::Incentive,
|
|
92
|
+
incentive_v3: &mut lending_core::incentive_v3::Incentive,
|
|
93
|
+
amount: Option<u64>,
|
|
94
|
+
clock: &Clock,
|
|
95
|
+
ctx: &mut TxContext,
|
|
96
|
+
) {
|
|
97
|
+
*/
|
|
98
|
+
export declare function withdrawCollateralNavi(config: TypusConfig, tx: Transaction, input: {
|
|
99
|
+
typeArguments: string[];
|
|
100
|
+
index: string;
|
|
101
|
+
naviOracleConfig: string;
|
|
102
|
+
naviPriceOracle: string;
|
|
103
|
+
naviSupraOracleHolder: string;
|
|
104
|
+
naviPythPriceInfo: string;
|
|
105
|
+
naviFeedAddress: string;
|
|
106
|
+
naviStorage: string;
|
|
107
|
+
naviPool: string;
|
|
108
|
+
naviAsset: number;
|
|
109
|
+
naviIncentiveV2: string;
|
|
110
|
+
naviIncentiveV3: string;
|
|
111
|
+
amount: string | undefined;
|
|
112
|
+
}): void;
|
|
@@ -37,6 +37,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getUpdateConfigTx = getUpdateConfigTx;
|
|
40
|
+
exports.depositCollateralNavi = depositCollateralNavi;
|
|
41
|
+
exports.withdrawCollateralNavi = withdrawCollateralNavi;
|
|
42
|
+
var constants_1 = require("../../src/constants");
|
|
43
|
+
var utils_1 = require("../../src/utils");
|
|
40
44
|
/**
|
|
41
45
|
public(friend) entry fun update_config(
|
|
42
46
|
registry: &mut Registry,
|
|
@@ -100,3 +104,76 @@ function getUpdateConfigTx(config, tx, requests) {
|
|
|
100
104
|
});
|
|
101
105
|
});
|
|
102
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
public entry fun deposit_collateral_navi<TOKEN>(
|
|
109
|
+
registry: &mut Registry,
|
|
110
|
+
index: u64,
|
|
111
|
+
storage: &mut lending_core::storage::Storage,
|
|
112
|
+
pool: &mut lending_core::pool::Pool<TOKEN>,
|
|
113
|
+
asset: u8,
|
|
114
|
+
incentive_v2: &mut lending_core::incentive_v2::Incentive,
|
|
115
|
+
incentive_v3: &mut lending_core::incentive_v3::Incentive,
|
|
116
|
+
coin: Coin<TOKEN>,
|
|
117
|
+
clock: &Clock,
|
|
118
|
+
ctx: &mut TxContext,
|
|
119
|
+
) {
|
|
120
|
+
*/
|
|
121
|
+
function depositCollateralNavi(config, tx, input) {
|
|
122
|
+
var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
|
|
123
|
+
tx.moveCall({
|
|
124
|
+
target: "".concat(config.package.dovSingle, "::tds_authorized_entry::deposit_collateral_navi"),
|
|
125
|
+
typeArguments: input.typeArguments,
|
|
126
|
+
arguments: [
|
|
127
|
+
tx.object(config.registry.dov.dovSingle),
|
|
128
|
+
tx.pure.u64(input.index),
|
|
129
|
+
tx.object(input.naviStorage),
|
|
130
|
+
tx.object(input.naviPool),
|
|
131
|
+
tx.pure.u8(input.naviAsset),
|
|
132
|
+
tx.object(input.naviIncentiveV2),
|
|
133
|
+
tx.object(input.naviIncentiveV3),
|
|
134
|
+
tx.object(coin),
|
|
135
|
+
tx.object(constants_1.CLOCK),
|
|
136
|
+
],
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
public entry fun withdraw_collateral_navi<TOKEN>(
|
|
141
|
+
registry: &mut Registry,
|
|
142
|
+
index: u64,
|
|
143
|
+
oracle_config: &mut OracleConfig,
|
|
144
|
+
price_oracle: &mut PriceOracle,
|
|
145
|
+
supra_oracle_holder: &SupraOracle::SupraSValueFeed::OracleHolder,
|
|
146
|
+
pyth_price_info: &pyth::price_info::PriceInfoObject,
|
|
147
|
+
feed_address: address,
|
|
148
|
+
storage: &mut lending_core::storage::Storage,
|
|
149
|
+
pool: &mut lending_core::pool::Pool<TOKEN>,
|
|
150
|
+
asset: u8,
|
|
151
|
+
incentive_v2: &mut lending_core::incentive_v2::Incentive,
|
|
152
|
+
incentive_v3: &mut lending_core::incentive_v3::Incentive,
|
|
153
|
+
amount: Option<u64>,
|
|
154
|
+
clock: &Clock,
|
|
155
|
+
ctx: &mut TxContext,
|
|
156
|
+
) {
|
|
157
|
+
*/
|
|
158
|
+
function withdrawCollateralNavi(config, tx, input) {
|
|
159
|
+
tx.moveCall({
|
|
160
|
+
target: "".concat(config.package.dovSingle, "::tds_authorized_entry::withdraw_collateral_navi"),
|
|
161
|
+
typeArguments: input.typeArguments,
|
|
162
|
+
arguments: [
|
|
163
|
+
tx.object(config.registry.dov.dovSingle),
|
|
164
|
+
tx.pure.u64(input.index),
|
|
165
|
+
tx.object(input.naviOracleConfig),
|
|
166
|
+
tx.object(input.naviPriceOracle),
|
|
167
|
+
tx.object(input.naviSupraOracleHolder),
|
|
168
|
+
tx.object(input.naviPythPriceInfo),
|
|
169
|
+
tx.pure.address(input.naviFeedAddress),
|
|
170
|
+
tx.object(input.naviStorage),
|
|
171
|
+
tx.object(input.naviPool),
|
|
172
|
+
tx.pure.u8(input.naviAsset),
|
|
173
|
+
tx.object(input.naviIncentiveV2),
|
|
174
|
+
tx.object(input.naviIncentiveV3),
|
|
175
|
+
tx.pure.option("u64", input.amount),
|
|
176
|
+
tx.object(constants_1.CLOCK),
|
|
177
|
+
],
|
|
178
|
+
});
|
|
179
|
+
}
|
|
@@ -21,7 +21,7 @@ export declare function addOtcConfig(config: TypusConfig, tx: Transaction, input
|
|
|
21
21
|
price: string;
|
|
22
22
|
fee_bp: string;
|
|
23
23
|
expiration_ts_ms: string;
|
|
24
|
-
}):
|
|
24
|
+
}): void;
|
|
25
25
|
/**
|
|
26
26
|
entry fun remove_otc_config(
|
|
27
27
|
registry: &mut Registry,
|
|
@@ -50,6 +50,7 @@ export declare function otc(config: TypusConfig, tx: Transaction, input: {
|
|
|
50
50
|
amount: string;
|
|
51
51
|
}): Promise<void>;
|
|
52
52
|
export interface OtcConfig {
|
|
53
|
+
index: string;
|
|
53
54
|
round: string;
|
|
54
55
|
size: string;
|
|
55
56
|
price: string;
|
|
@@ -60,24 +60,19 @@ var constants_2 = require("../../src/constants");
|
|
|
60
60
|
) {
|
|
61
61
|
*/
|
|
62
62
|
function addOtcConfig(config, tx, input) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
tx.pure.u64(input.expiration_ts_ms),
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
});
|
|
63
|
+
tx.moveCall({
|
|
64
|
+
target: "".concat(config.package.dovSingle, "::tds_otc_entry::add_otc_config"),
|
|
65
|
+
typeArguments: [],
|
|
66
|
+
arguments: [
|
|
67
|
+
tx.object(config.registry.dov.dovSingle),
|
|
68
|
+
tx.pure.address(input.user),
|
|
69
|
+
tx.pure.u64(input.index),
|
|
70
|
+
tx.pure.u64(input.round),
|
|
71
|
+
tx.pure.u64(input.size),
|
|
72
|
+
tx.pure.u64(input.price),
|
|
73
|
+
tx.pure.u64(input.fee_bp),
|
|
74
|
+
tx.pure.u64(input.expiration_ts_ms),
|
|
75
|
+
],
|
|
81
76
|
});
|
|
82
77
|
}
|
|
83
78
|
/**
|
|
@@ -113,10 +108,10 @@ function otc(config, tx, input) {
|
|
|
113
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
109
|
var coin, balance;
|
|
115
110
|
return __generator(this, function (_a) {
|
|
116
|
-
coin = (0, utils_1.splitCoins)(tx, input.typeArguments[
|
|
111
|
+
coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount);
|
|
117
112
|
balance = tx.moveCall({
|
|
118
113
|
target: "0x2::coin::into_balance",
|
|
119
|
-
typeArguments: [input.typeArguments[
|
|
114
|
+
typeArguments: [input.typeArguments[1]],
|
|
120
115
|
arguments: [tx.object(coin)],
|
|
121
116
|
});
|
|
122
117
|
tx.moveCall({
|
|
@@ -153,6 +148,7 @@ function getUserOtcConfigs(config, input) {
|
|
|
153
148
|
return [2 /*return*/, reader.readVec(function (reader) {
|
|
154
149
|
reader.readULEB();
|
|
155
150
|
return {
|
|
151
|
+
index: reader.read64(),
|
|
156
152
|
round: reader.read64(),
|
|
157
153
|
size: reader.read64(),
|
|
158
154
|
price: reader.read64(),
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./user-entry"), exports);
|
|
18
|
+
__exportStar(require("./view-function"), exports);
|
|
19
|
+
// export * from "./authority-entry";
|
|
20
|
+
// export * from "./function";
|
|
21
|
+
// export * from "./history";
|
|
22
|
+
// export * from "./token-user-entry";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
2
|
+
import { TypusConfig } from "../../src/utils";
|
|
3
|
+
/**
|
|
4
|
+
public fun raise_fund<MAIN_TOKEN, HEDGE_TOKEN>(
|
|
5
|
+
typus_version: &TypusVersion,
|
|
6
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
7
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
8
|
+
version: &Version,
|
|
9
|
+
registry: &mut Registry,
|
|
10
|
+
index: u64,
|
|
11
|
+
account: Option<address>,
|
|
12
|
+
raise_main_balance: Balance<MAIN_TOKEN>,
|
|
13
|
+
raise_hedge_balance: Balance<HEDGE_TOKEN>,
|
|
14
|
+
raise_from_deactivating: u64,
|
|
15
|
+
raise_from_inactive: u64,
|
|
16
|
+
clock: &Clock,
|
|
17
|
+
ctx: &mut TxContext,
|
|
18
|
+
) {
|
|
19
|
+
*/
|
|
20
|
+
export declare function raiseFund(config: TypusConfig, tx: Transaction, input: {
|
|
21
|
+
typeArguments: string[];
|
|
22
|
+
index: string;
|
|
23
|
+
raiseMainCoins: string[];
|
|
24
|
+
raiseMainAmount: string;
|
|
25
|
+
raiseHedgeCoins: string[];
|
|
26
|
+
raiseHedgeAmount: string;
|
|
27
|
+
raiseFromDeactivating: boolean;
|
|
28
|
+
raiseFromInactive: boolean;
|
|
29
|
+
}): void;
|
|
30
|
+
/**
|
|
31
|
+
public fun reduce_fund<MAIN_TOKEN, HEDGE_TOKEN>(
|
|
32
|
+
typus_version: &TypusVersion,
|
|
33
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
34
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
35
|
+
version: &mut Version,
|
|
36
|
+
registry: &mut Registry,
|
|
37
|
+
index: u64,
|
|
38
|
+
account: Option<address>,
|
|
39
|
+
reduce_from_warmup: u64,
|
|
40
|
+
reduce_from_active: u64,
|
|
41
|
+
reduce_from_inactive: bool,
|
|
42
|
+
fee: Balance<SUI>,
|
|
43
|
+
clock: &Clock,
|
|
44
|
+
ctx: &mut TxContext,
|
|
45
|
+
): (Balance<MAIN_TOKEN>, Balance<HEDGE_TOKEN>) {
|
|
46
|
+
*/
|
|
47
|
+
export declare function reduceFund(config: TypusConfig, tx: Transaction, input: {
|
|
48
|
+
typeArguments: string[];
|
|
49
|
+
index: string;
|
|
50
|
+
reduceFromWarmup: string;
|
|
51
|
+
reduceFromActive: string;
|
|
52
|
+
reduceFromInactive: boolean;
|
|
53
|
+
feeAmount: string;
|
|
54
|
+
user: string;
|
|
55
|
+
}): void;
|
|
56
|
+
/**
|
|
57
|
+
public fun snapshot(
|
|
58
|
+
typus_version: &TypusVersion,
|
|
59
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
60
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
61
|
+
version: &mut Version,
|
|
62
|
+
registry: &mut Registry,
|
|
63
|
+
index: u64,
|
|
64
|
+
account: Option<address>,
|
|
65
|
+
clock: &Clock,
|
|
66
|
+
ctx: &mut TxContext,
|
|
67
|
+
) {
|
|
68
|
+
*/
|
|
69
|
+
export declare function snapshot(config: TypusConfig, tx: Transaction, input: {
|
|
70
|
+
typeArguments: string[];
|
|
71
|
+
index: string;
|
|
72
|
+
receipts: string[] | TransactionObjectArgument[];
|
|
73
|
+
user: string;
|
|
74
|
+
}): void;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.raiseFund = raiseFund;
|
|
20
|
+
exports.reduceFund = reduceFund;
|
|
21
|
+
exports.snapshot = snapshot;
|
|
22
|
+
var utils_1 = require("@mysten/sui/dist/cjs/utils");
|
|
23
|
+
var constants_1 = require("../../src/constants");
|
|
24
|
+
var utils_2 = require("../../src/utils");
|
|
25
|
+
/**
|
|
26
|
+
public fun raise_fund<MAIN_TOKEN, HEDGE_TOKEN>(
|
|
27
|
+
typus_version: &TypusVersion,
|
|
28
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
29
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
30
|
+
version: &Version,
|
|
31
|
+
registry: &mut Registry,
|
|
32
|
+
index: u64,
|
|
33
|
+
account: Option<address>,
|
|
34
|
+
raise_main_balance: Balance<MAIN_TOKEN>,
|
|
35
|
+
raise_hedge_balance: Balance<HEDGE_TOKEN>,
|
|
36
|
+
raise_from_deactivating: u64,
|
|
37
|
+
raise_from_inactive: u64,
|
|
38
|
+
clock: &Clock,
|
|
39
|
+
ctx: &mut TxContext,
|
|
40
|
+
) {
|
|
41
|
+
*/
|
|
42
|
+
function raiseFund(config, tx, input) {
|
|
43
|
+
var mainCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[0], input.raiseMainCoins, input.raiseMainAmount);
|
|
44
|
+
var hedgeCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount);
|
|
45
|
+
var mainBalance = tx.moveCall({
|
|
46
|
+
target: "0x2::coin::into_balance",
|
|
47
|
+
typeArguments: [input.typeArguments[0]],
|
|
48
|
+
arguments: [tx.object(mainCoin)],
|
|
49
|
+
});
|
|
50
|
+
var hedgeBalance = tx.moveCall({
|
|
51
|
+
target: "0x2::coin::into_balance",
|
|
52
|
+
typeArguments: [input.typeArguments[1]],
|
|
53
|
+
arguments: [tx.object(hedgeCoin)],
|
|
54
|
+
});
|
|
55
|
+
tx.moveCall({
|
|
56
|
+
target: "".concat(config.package.hedge.hedge, "::typus_hedge::raise_fund"),
|
|
57
|
+
typeArguments: input.typeArguments,
|
|
58
|
+
arguments: [
|
|
59
|
+
tx.object(config.version.typus),
|
|
60
|
+
tx.object(config.registry.typus.leaderboard),
|
|
61
|
+
tx.object(config.registry.typus.user),
|
|
62
|
+
tx.object(config.version.hedge.hedge),
|
|
63
|
+
tx.object(config.registry.hedge),
|
|
64
|
+
tx.pure.u64(input.index),
|
|
65
|
+
tx.pure.option("address", null),
|
|
66
|
+
tx.object(mainBalance),
|
|
67
|
+
tx.object(hedgeBalance),
|
|
68
|
+
tx.pure.bool(input.raiseFromDeactivating),
|
|
69
|
+
tx.pure.bool(input.raiseFromInactive),
|
|
70
|
+
tx.object(constants_1.CLOCK),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
public fun reduce_fund<MAIN_TOKEN, HEDGE_TOKEN>(
|
|
76
|
+
typus_version: &TypusVersion,
|
|
77
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
78
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
79
|
+
version: &mut Version,
|
|
80
|
+
registry: &mut Registry,
|
|
81
|
+
index: u64,
|
|
82
|
+
account: Option<address>,
|
|
83
|
+
reduce_from_warmup: u64,
|
|
84
|
+
reduce_from_active: u64,
|
|
85
|
+
reduce_from_inactive: bool,
|
|
86
|
+
fee: Balance<SUI>,
|
|
87
|
+
clock: &Clock,
|
|
88
|
+
ctx: &mut TxContext,
|
|
89
|
+
): (Balance<MAIN_TOKEN>, Balance<HEDGE_TOKEN>) {
|
|
90
|
+
*/
|
|
91
|
+
function reduceFund(config, tx, input) {
|
|
92
|
+
var _a = __read(tx.splitCoins(tx.gas, [tx.pure.u64(input.feeAmount)]), 1), feeCoin = _a[0];
|
|
93
|
+
var feeBalance = tx.moveCall({
|
|
94
|
+
target: "0x2::coin::into_balance",
|
|
95
|
+
typeArguments: [utils_1.SUI_TYPE_ARG],
|
|
96
|
+
arguments: [tx.object(feeCoin)],
|
|
97
|
+
});
|
|
98
|
+
var result = tx.moveCall({
|
|
99
|
+
target: "".concat(config.package.hedge.hedge, "::typus_hedge::reduce_fund"),
|
|
100
|
+
typeArguments: input.typeArguments,
|
|
101
|
+
arguments: [
|
|
102
|
+
tx.object(config.version.typus),
|
|
103
|
+
tx.object(config.registry.typus.leaderboard),
|
|
104
|
+
tx.object(config.registry.typus.user),
|
|
105
|
+
tx.object(config.version.hedge.hedge),
|
|
106
|
+
tx.object(config.registry.hedge),
|
|
107
|
+
tx.pure.u64(input.index),
|
|
108
|
+
tx.pure.option("address", null),
|
|
109
|
+
tx.pure.u64(input.reduceFromWarmup),
|
|
110
|
+
tx.pure.u64(input.reduceFromActive),
|
|
111
|
+
tx.pure.bool(input.reduceFromInactive),
|
|
112
|
+
tx.object(feeBalance),
|
|
113
|
+
tx.object(constants_1.CLOCK),
|
|
114
|
+
],
|
|
115
|
+
});
|
|
116
|
+
tx.moveCall({
|
|
117
|
+
target: "".concat(config.package.framework, "::utils::transfer_balance"),
|
|
118
|
+
typeArguments: [input.typeArguments[0]],
|
|
119
|
+
arguments: [tx.object(result[0]), tx.pure.address(input.user)],
|
|
120
|
+
});
|
|
121
|
+
tx.moveCall({
|
|
122
|
+
target: "".concat(config.package.framework, "::utils::transfer_balance"),
|
|
123
|
+
typeArguments: [input.typeArguments[1]],
|
|
124
|
+
arguments: [tx.object(result[1]), tx.pure.address(input.user)],
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
public fun snapshot(
|
|
129
|
+
typus_version: &TypusVersion,
|
|
130
|
+
typus_leaderboard_registry: &mut TypusLeaderboardRegistry,
|
|
131
|
+
typus_user_registry: &mut TypusUserRegistry,
|
|
132
|
+
version: &mut Version,
|
|
133
|
+
registry: &mut Registry,
|
|
134
|
+
index: u64,
|
|
135
|
+
account: Option<address>,
|
|
136
|
+
clock: &Clock,
|
|
137
|
+
ctx: &mut TxContext,
|
|
138
|
+
) {
|
|
139
|
+
*/
|
|
140
|
+
function snapshot(config, tx, input) {
|
|
141
|
+
tx.moveCall({
|
|
142
|
+
target: "".concat(config.package.hedge.hedge, "::typus_hedge::snapshot"),
|
|
143
|
+
typeArguments: input.typeArguments,
|
|
144
|
+
arguments: [
|
|
145
|
+
tx.object(config.version.typus),
|
|
146
|
+
tx.object(config.registry.typus.leaderboard),
|
|
147
|
+
tx.object(config.registry.typus.user),
|
|
148
|
+
tx.object(config.version.hedge.hedge),
|
|
149
|
+
tx.object(config.registry.hedge),
|
|
150
|
+
tx.pure.u64(input.index),
|
|
151
|
+
tx.pure.option("address", null),
|
|
152
|
+
tx.object(constants_1.CLOCK),
|
|
153
|
+
],
|
|
154
|
+
});
|
|
155
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TypusConfig } from "../../src/utils";
|
|
2
|
+
import { TypusBidReceipt } from "../../src/auto-bid/view-function";
|
|
3
|
+
export interface Vault {
|
|
4
|
+
id: string;
|
|
5
|
+
depositToken: string;
|
|
6
|
+
rewardToken: string[];
|
|
7
|
+
info: Info;
|
|
8
|
+
config: Config;
|
|
9
|
+
share: BigVector;
|
|
10
|
+
shareSupply: ShareSupply;
|
|
11
|
+
u64Padding: string[];
|
|
12
|
+
bcsPadding: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface Info {
|
|
15
|
+
index: string;
|
|
16
|
+
round: string;
|
|
17
|
+
portfolio_vault_index: string;
|
|
18
|
+
refresh_ts_ms: string;
|
|
19
|
+
status: string;
|
|
20
|
+
lending_enabled: string;
|
|
21
|
+
price_mbp: string;
|
|
22
|
+
mbp_incentivised: string;
|
|
23
|
+
fixed_incentivised: string;
|
|
24
|
+
token_decimal: string;
|
|
25
|
+
lending_apr_mbp: string;
|
|
26
|
+
creation_ts_ms: string;
|
|
27
|
+
dov_vault_index_add_one_up: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Config {
|
|
30
|
+
capacity: string;
|
|
31
|
+
lot_size: string;
|
|
32
|
+
min_size: string;
|
|
33
|
+
fee_bp: string;
|
|
34
|
+
utilization_rate_bp: string;
|
|
35
|
+
exp_per_hour_bp: string;
|
|
36
|
+
incentive_mbp: string;
|
|
37
|
+
incentive_fixed: string;
|
|
38
|
+
point_per_hour_bp: string;
|
|
39
|
+
exercise_fee_bp: string;
|
|
40
|
+
exit_fee_bp: string;
|
|
41
|
+
exit_fee_amount: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ShareSupply {
|
|
44
|
+
active_share: string;
|
|
45
|
+
deactivating_share: string;
|
|
46
|
+
inactive_share: string;
|
|
47
|
+
warmup_share: string;
|
|
48
|
+
snapshot_share: string;
|
|
49
|
+
reward_share: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface BigVector {
|
|
52
|
+
id: string;
|
|
53
|
+
element_type: string;
|
|
54
|
+
slice_idx: string;
|
|
55
|
+
slice_size: number;
|
|
56
|
+
length: string;
|
|
57
|
+
}
|
|
58
|
+
export declare function getBigVectorData(config: TypusConfig, bigVector: BigVector): Promise<any[]>;
|
|
59
|
+
export declare function getVaultData(config: TypusConfig, input: {
|
|
60
|
+
indexes: string[];
|
|
61
|
+
}): Promise<{
|
|
62
|
+
[key: string]: [Vault, TypusBidReceipt | null];
|
|
63
|
+
}>;
|
|
64
|
+
export interface Share {
|
|
65
|
+
user: string;
|
|
66
|
+
share: ShareSupply;
|
|
67
|
+
u64Padding: string[];
|
|
68
|
+
bcsPadding: string[];
|
|
69
|
+
}
|
|
70
|
+
export declare function getShareData(config: TypusConfig, input: {
|
|
71
|
+
user: string;
|
|
72
|
+
indexes: string[];
|
|
73
|
+
}): Promise<{
|
|
74
|
+
[key: string]: Share[];
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,269 @@
|
|
|
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 = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["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.getBigVectorData = getBigVectorData;
|
|
40
|
+
exports.getVaultData = getVaultData;
|
|
41
|
+
exports.getShareData = getShareData;
|
|
42
|
+
var transactions_1 = require("@mysten/sui/transactions");
|
|
43
|
+
var client_1 = require("@mysten/sui/client");
|
|
44
|
+
var bcs_1 = require("@mysten/bcs");
|
|
45
|
+
var utils_1 = require("../../src/utils");
|
|
46
|
+
var constants_1 = require("../../src/constants");
|
|
47
|
+
function getBigVectorData(config, bigVector) {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var provider, results, i, df, result;
|
|
50
|
+
var _a;
|
|
51
|
+
return __generator(this, function (_b) {
|
|
52
|
+
switch (_b.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
55
|
+
results = [];
|
|
56
|
+
i = 0;
|
|
57
|
+
_b.label = 1;
|
|
58
|
+
case 1:
|
|
59
|
+
if (!(i <= Number(bigVector.slice_idx))) return [3 /*break*/, 4];
|
|
60
|
+
return [4 /*yield*/, provider.getDynamicFieldObject({
|
|
61
|
+
parentId: bigVector.id,
|
|
62
|
+
name: {
|
|
63
|
+
type: "u64",
|
|
64
|
+
value: "".concat(i),
|
|
65
|
+
},
|
|
66
|
+
})];
|
|
67
|
+
case 2:
|
|
68
|
+
df = _b.sent();
|
|
69
|
+
result = (_a = df.data) === null || _a === void 0 ? void 0 : _a.content.fields.value.fields.vector.map(function (x) { return x.fields; });
|
|
70
|
+
results = results.concat(result);
|
|
71
|
+
_b.label = 3;
|
|
72
|
+
case 3:
|
|
73
|
+
i++;
|
|
74
|
+
return [3 /*break*/, 1];
|
|
75
|
+
case 4: return [2 /*return*/, results];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function getVaultData(config, input) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var provider, transaction, results, bytes, reader, result;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
87
|
+
transaction = new transactions_1.Transaction();
|
|
88
|
+
transaction.moveCall({
|
|
89
|
+
target: "".concat(config.package.safu, "::view_function::get_vault_data_bcs"),
|
|
90
|
+
typeArguments: ["".concat(config.package.framework, "::vault::TypusBidReceipt")],
|
|
91
|
+
arguments: [transaction.object(config.registry.safu.safu), transaction.pure.vector("u64", input.indexes)],
|
|
92
|
+
});
|
|
93
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transaction, sender: constants_1.SENDER })];
|
|
94
|
+
case 1:
|
|
95
|
+
results = (_a.sent()).results;
|
|
96
|
+
bytes = results[results.length - 1].returnValues[0][0];
|
|
97
|
+
reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
98
|
+
result = {};
|
|
99
|
+
reader.readVec(function (reader) {
|
|
100
|
+
reader.readULEB();
|
|
101
|
+
var id = (0, utils_1.AddressFromBytes)(reader.readBytes(32));
|
|
102
|
+
var depositToken = String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB())));
|
|
103
|
+
var rewardToken = reader.readVec(function (reader) {
|
|
104
|
+
return String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB())));
|
|
105
|
+
});
|
|
106
|
+
var infoArray = reader.readVec(function (reader) {
|
|
107
|
+
return reader.read64();
|
|
108
|
+
});
|
|
109
|
+
var configArray = reader.readVec(function (reader) {
|
|
110
|
+
return reader.read64();
|
|
111
|
+
});
|
|
112
|
+
var info = {
|
|
113
|
+
index: infoArray[0],
|
|
114
|
+
round: infoArray[1],
|
|
115
|
+
portfolio_vault_index: infoArray[2],
|
|
116
|
+
refresh_ts_ms: infoArray[3],
|
|
117
|
+
status: infoArray[4],
|
|
118
|
+
lending_enabled: infoArray[5],
|
|
119
|
+
price_mbp: infoArray[6],
|
|
120
|
+
mbp_incentivised: infoArray[7],
|
|
121
|
+
fixed_incentivised: infoArray[8],
|
|
122
|
+
token_decimal: infoArray[9],
|
|
123
|
+
lending_apr_mbp: infoArray[10],
|
|
124
|
+
creation_ts_ms: infoArray[11],
|
|
125
|
+
dov_vault_index_add_one_up: infoArray[12],
|
|
126
|
+
};
|
|
127
|
+
var config = {
|
|
128
|
+
capacity: configArray[0],
|
|
129
|
+
lot_size: configArray[1],
|
|
130
|
+
min_size: configArray[2],
|
|
131
|
+
fee_bp: configArray[3],
|
|
132
|
+
utilization_rate_bp: configArray[4],
|
|
133
|
+
exp_per_hour_bp: configArray[5],
|
|
134
|
+
incentive_mbp: configArray[6],
|
|
135
|
+
incentive_fixed: configArray[7],
|
|
136
|
+
point_per_hour_bp: configArray[8],
|
|
137
|
+
exercise_fee_bp: configArray[9],
|
|
138
|
+
exit_fee_bp: configArray[10],
|
|
139
|
+
exit_fee_amount: configArray[11],
|
|
140
|
+
};
|
|
141
|
+
// skip BigVector
|
|
142
|
+
var bigVector = {
|
|
143
|
+
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
144
|
+
element_type: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))), // element_type
|
|
145
|
+
slice_idx: reader.read64(), // slice_idx
|
|
146
|
+
slice_size: reader.read32(), // slice_size
|
|
147
|
+
length: reader.read64(), // length
|
|
148
|
+
};
|
|
149
|
+
var shareSupplyArray = reader.readVec(function (reader) {
|
|
150
|
+
return reader.read64();
|
|
151
|
+
});
|
|
152
|
+
var shareSupply = {
|
|
153
|
+
active_share: shareSupplyArray[0],
|
|
154
|
+
deactivating_share: shareSupplyArray[1],
|
|
155
|
+
inactive_share: shareSupplyArray[2],
|
|
156
|
+
warmup_share: shareSupplyArray[3],
|
|
157
|
+
snapshot_share: shareSupplyArray[4],
|
|
158
|
+
reward_share: shareSupplyArray.slice(5),
|
|
159
|
+
};
|
|
160
|
+
var u64Padding = reader.readVec(function (reader) {
|
|
161
|
+
return reader.read64();
|
|
162
|
+
});
|
|
163
|
+
var bcsPadding = reader.readVec(function (reader) {
|
|
164
|
+
return reader.read8();
|
|
165
|
+
});
|
|
166
|
+
var has_bid_receipt = reader.read8() > 0;
|
|
167
|
+
if (has_bid_receipt) {
|
|
168
|
+
result[info.index] = [
|
|
169
|
+
{
|
|
170
|
+
id: id,
|
|
171
|
+
depositToken: depositToken,
|
|
172
|
+
rewardToken: rewardToken,
|
|
173
|
+
info: info,
|
|
174
|
+
config: config,
|
|
175
|
+
share: bigVector,
|
|
176
|
+
shareSupply: shareSupply,
|
|
177
|
+
u64Padding: u64Padding,
|
|
178
|
+
bcsPadding: bcsPadding,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
182
|
+
vid: (0, utils_1.AddressFromBytes)(reader.readBytes(32)),
|
|
183
|
+
index: reader.read64(),
|
|
184
|
+
metadata: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.readULEB()))),
|
|
185
|
+
u64_padding: reader.readVec(function (reader) {
|
|
186
|
+
return reader.read64();
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
result[info.index] = [
|
|
193
|
+
{
|
|
194
|
+
id: id,
|
|
195
|
+
depositToken: depositToken,
|
|
196
|
+
rewardToken: rewardToken,
|
|
197
|
+
info: info,
|
|
198
|
+
config: config,
|
|
199
|
+
share: bigVector,
|
|
200
|
+
shareSupply: shareSupply,
|
|
201
|
+
u64Padding: u64Padding,
|
|
202
|
+
bcsPadding: bcsPadding,
|
|
203
|
+
},
|
|
204
|
+
null,
|
|
205
|
+
];
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
return [2 /*return*/, result];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function getShareData(config, input) {
|
|
214
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
215
|
+
var provider, transaction, results, bytes, reader, result;
|
|
216
|
+
return __generator(this, function (_a) {
|
|
217
|
+
switch (_a.label) {
|
|
218
|
+
case 0:
|
|
219
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
220
|
+
transaction = new transactions_1.Transaction();
|
|
221
|
+
transaction.moveCall({
|
|
222
|
+
target: "".concat(config.package.safu, "::view_function::get_share_data_bcs"),
|
|
223
|
+
typeArguments: [],
|
|
224
|
+
arguments: [
|
|
225
|
+
transaction.object(config.registry.safu.safu),
|
|
226
|
+
transaction.pure.address(input.user),
|
|
227
|
+
transaction.pure.vector("u64", input.indexes),
|
|
228
|
+
],
|
|
229
|
+
});
|
|
230
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transaction, sender: constants_1.SENDER })];
|
|
231
|
+
case 1:
|
|
232
|
+
results = (_a.sent()).results;
|
|
233
|
+
bytes = results[results.length - 1].returnValues[0][0];
|
|
234
|
+
reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
235
|
+
result = {};
|
|
236
|
+
reader.readVec(function (reader, i) {
|
|
237
|
+
reader.read8();
|
|
238
|
+
var share = reader.readVec(function (reader) {
|
|
239
|
+
var user = (0, utils_1.AddressFromBytes)(reader.readBytes(32));
|
|
240
|
+
var shareSupplyArray = reader.readVec(function (reader) {
|
|
241
|
+
return reader.read64();
|
|
242
|
+
});
|
|
243
|
+
var shareSupply = {
|
|
244
|
+
active_share: shareSupplyArray[0],
|
|
245
|
+
deactivating_share: shareSupplyArray[1],
|
|
246
|
+
inactive_share: shareSupplyArray[2],
|
|
247
|
+
warmup_share: shareSupplyArray[3],
|
|
248
|
+
snapshot_share: shareSupplyArray[4],
|
|
249
|
+
reward_share: shareSupplyArray.slice(5),
|
|
250
|
+
};
|
|
251
|
+
return {
|
|
252
|
+
user: user,
|
|
253
|
+
share: shareSupply,
|
|
254
|
+
u64Padding: reader.readVec(function (reader) {
|
|
255
|
+
return reader.read64();
|
|
256
|
+
}),
|
|
257
|
+
bcsPadding: reader.readVec(function (reader) {
|
|
258
|
+
return reader.read8();
|
|
259
|
+
}),
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
var index = input.indexes.pop();
|
|
263
|
+
result[index] = share;
|
|
264
|
+
});
|
|
265
|
+
return [2 /*return*/, result];
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
@@ -30,6 +30,11 @@ export interface Package {
|
|
|
30
30
|
optionAirdrop: string;
|
|
31
31
|
veTypus: string;
|
|
32
32
|
};
|
|
33
|
+
hedge: {
|
|
34
|
+
hedge: string;
|
|
35
|
+
hedge_perp_dov: string;
|
|
36
|
+
hedge_momentum: string;
|
|
37
|
+
};
|
|
33
38
|
}
|
|
34
39
|
export interface Version {
|
|
35
40
|
perp: {
|
|
@@ -46,6 +51,11 @@ export interface Version {
|
|
|
46
51
|
optionAirdrop: string;
|
|
47
52
|
veTypus: string;
|
|
48
53
|
};
|
|
54
|
+
hedge: {
|
|
55
|
+
hedge: string;
|
|
56
|
+
hedge_perp_dov: string;
|
|
57
|
+
hedge_momentum: string;
|
|
58
|
+
};
|
|
49
59
|
}
|
|
50
60
|
export interface Registry {
|
|
51
61
|
dice: {
|
|
@@ -79,6 +89,7 @@ export interface Registry {
|
|
|
79
89
|
improvementProposal: string;
|
|
80
90
|
veTypus: string;
|
|
81
91
|
};
|
|
92
|
+
hedge: string;
|
|
82
93
|
}
|
|
83
94
|
export interface Object {
|
|
84
95
|
nftTransferPolicy: string;
|
|
@@ -130,7 +130,7 @@ var TypusConfig = /** @class */ (function () {
|
|
|
130
130
|
}());
|
|
131
131
|
exports.TypusConfig = TypusConfig;
|
|
132
132
|
// (async () => {
|
|
133
|
-
// let config = TypusConfig.local("../typus-config/config-
|
|
133
|
+
// let config = TypusConfig.local("../typus-config/config-mainnet.json");
|
|
134
134
|
// console.log(config);
|
|
135
135
|
// console.log(config.rpcEndpoint);
|
|
136
136
|
// })();
|