@suilend/springsui-cli 1.0.13 → 2.0.0
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/cli/src/bytecode.js +28 -30
- package/cli/src/index.js +51 -86
- package/package.json +1 -1
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +52 -52
- package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
- package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +4 -4
- package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +7 -7
- package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +5 -5
- package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
- package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +60 -60
- package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
- package/sdk/src/_generated/_framework/reified.d.ts +2 -2
- package/sdk/src/_generated/_framework/reified.js +27 -40
- package/sdk/src/_generated/_framework/util.d.ts +2 -14
- package/sdk/src/_generated/_framework/util.js +26 -40
- package/sdk/src/_generated/_framework/vector.d.ts +4 -4
- package/sdk/src/_generated/_framework/vector.js +16 -21
- package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +4 -4
- package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
- package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
- package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +21 -21
- package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
- package/sdk/src/_generated/liquid_staking/index.js +6 -10
- package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +98 -98
- package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
- package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +31 -31
- package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
- package/sdk/src/_generated/liquid_staking/version/structs.d.ts +4 -4
- package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
- package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
- package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +41 -41
- package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
- package/sdk/src/client.d.ts +16 -16
- package/sdk/src/client.js +39 -82
- package/sdk/src/index.js +2 -18
- package/sdk/src/lib/index.js +1 -17
- package/sdk/src/lib/transactions.d.ts +1 -1
- package/sdk/src/lib/transactions.js +3 -8
package/cli/src/bytecode.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,21 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const ed25519_1 = require("@mysten/sui/keypairs/ed25519");
|
|
21
|
-
const transactions_1 = require("@mysten/sui/transactions");
|
|
22
|
-
const utils_1 = require("@mysten/sui/utils");
|
|
23
|
-
const springsui_sdk_1 = require("@suilend/springsui-sdk");
|
|
10
|
+
import assert from "assert";
|
|
11
|
+
import { bcs } from "@mysten/bcs";
|
|
12
|
+
import { update_constants, update_identifiers, } from "@mysten/move-bytecode-template";
|
|
13
|
+
import init from "@mysten/move-bytecode-template";
|
|
14
|
+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
15
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
16
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
17
|
+
import { fromBase64, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
18
|
+
import { LstClient } from "@suilend/springsui-sdk";
|
|
24
19
|
// import url from "@mysten/move-bytecode-template/move_bytecode_template_bg.wasm?url";
|
|
25
|
-
const keypair =
|
|
20
|
+
const keypair = Ed25519Keypair.fromSecretKey(fromBase64(process.env.SUI_SECRET_KEY));
|
|
26
21
|
function generate_bytecode(lst_type, // eg K_SUI
|
|
27
22
|
module_name, // eg ksui
|
|
28
23
|
symbol, // eg sSUI
|
|
@@ -30,34 +25,37 @@ name, // eg Spring SUI
|
|
|
30
25
|
description, // eg Spring SUI is a liquid staking protocol on Sui
|
|
31
26
|
img_url) {
|
|
32
27
|
const bytecode = Buffer.from("oRzrCwYAAAAKAQAMAgweAyonBFEIBVlMB6UBywEI8AJgBtADXQqtBAUMsgQoABABCwIGAhECEgITAAICAAEBBwEAAAIADAEAAQIDDAEAAQQEAgAFBQcAAAkAAQABDwUGAQACBwgJAQIDDAUBAQwDDQ0BAQwEDgoLAAUKAwQAAQQCBwQMAwICCAAHCAQAAQsCAQgAAQoCAQgFAQkAAQsBAQkAAQgABwkAAgoCCgIKAgsBAQgFBwgEAgsDAQkACwIBCQABBggEAQUBCwMBCAACCQAFDENvaW5NZXRhZGF0YQZPcHRpb24IVEVNUExBVEULVHJlYXN1cnlDYXAJVHhDb250ZXh0A1VybARjb2luD2NyZWF0ZV9jdXJyZW5jeQtkdW1teV9maWVsZARpbml0FW5ld191bnNhZmVfZnJvbV9ieXRlcwZvcHRpb24TcHVibGljX3NoYXJlX29iamVjdA9wdWJsaWNfdHJhbnNmZXIGc2VuZGVyBHNvbWUIdGVtcGxhdGUIdHJhbnNmZXIKdHhfY29udGV4dAN1cmwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICAQkKAgUEVE1QTAoCDg1UZW1wbGF0ZSBDb2luCgIaGVRlbXBsYXRlIENvaW4gRGVzY3JpcHRpb24KAiEgaHR0cHM6Ly9leGFtcGxlLmNvbS90ZW1wbGF0ZS5wbmcAAgEIAQAAAAACEgsABwAHAQcCBwMHBBEGOAAKATgBDAILAS4RBTgCCwI4AwIA=", "base64");
|
|
33
|
-
let updated =
|
|
28
|
+
let updated = update_identifiers(bytecode, {
|
|
34
29
|
TEMPLATE: lst_type,
|
|
35
30
|
template: module_name,
|
|
36
31
|
});
|
|
37
|
-
updated =
|
|
38
|
-
updated =
|
|
39
|
-
|
|
32
|
+
updated = update_constants(updated, bcs.string().serialize(symbol).toBytes(), bcs.string().serialize("TMPL").toBytes(), "Vector(U8)");
|
|
33
|
+
updated = update_constants(updated, bcs.string().serialize(name).toBytes(), // new value
|
|
34
|
+
bcs.string().serialize("Template Coin").toBytes(), // current value
|
|
40
35
|
"Vector(U8)");
|
|
41
|
-
updated =
|
|
42
|
-
|
|
36
|
+
updated = update_constants(updated, bcs.string().serialize(description).toBytes(), // new value
|
|
37
|
+
bcs.string().serialize("Template Coin Description").toBytes(), // current value
|
|
43
38
|
"Vector(U8)");
|
|
44
|
-
updated =
|
|
45
|
-
|
|
39
|
+
updated = update_constants(updated, bcs.string().serialize(img_url).toBytes(), // new value
|
|
40
|
+
bcs.string().serialize("https://example.com/template.png").toBytes(), // current value
|
|
46
41
|
"Vector(U8)");
|
|
47
42
|
return updated;
|
|
48
43
|
}
|
|
49
44
|
function main() {
|
|
50
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
46
|
var _a;
|
|
52
|
-
const client = new
|
|
47
|
+
const client = new SuiJsonRpcClient({
|
|
48
|
+
url: "https://fullnode.mainnet.sui.io",
|
|
49
|
+
network: "mainnet",
|
|
50
|
+
});
|
|
53
51
|
console.log("asdf");
|
|
54
|
-
yield (
|
|
52
|
+
yield init();
|
|
55
53
|
const bytecode = generate_bytecode("RIPLEYS_SUI", "ripleys_sui", "rSui", "Ripleys Staked Sui", "Ripleys Staked Sui is a liquid staking protocol on Sui", "https://example.com/ripleys.png");
|
|
56
54
|
// Step 1: Create the coin
|
|
57
|
-
const tx = new
|
|
55
|
+
const tx = new Transaction();
|
|
58
56
|
const [upgradeCap] = tx.publish({
|
|
59
57
|
modules: [[...bytecode]],
|
|
60
|
-
dependencies: [
|
|
58
|
+
dependencies: [normalizeSuiAddress("0x1"), normalizeSuiAddress("0x2")],
|
|
61
59
|
});
|
|
62
60
|
tx.transferObjects([upgradeCap], tx.pure.address(keypair.toSuiAddress()));
|
|
63
61
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
@@ -72,7 +70,7 @@ function main() {
|
|
|
72
70
|
console.log(txResponse);
|
|
73
71
|
// Step 2: Get the treasury Cap id from the transaction
|
|
74
72
|
const treasuryCapObjectChange = (_a = txResponse.objectChanges) === null || _a === void 0 ? void 0 : _a.find((change) => change.type === "created" && change.objectType.includes("TreasuryCap"));
|
|
75
|
-
(
|
|
73
|
+
assert((treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.type) === "created");
|
|
76
74
|
const treasuryCapId = treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.objectId;
|
|
77
75
|
const coinType = treasuryCapObjectChange === null || treasuryCapObjectChange === void 0 ? void 0 : treasuryCapObjectChange.objectType.split("<")[1].split(">")[0];
|
|
78
76
|
console.log(coinType);
|
|
@@ -89,8 +87,8 @@ function main() {
|
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
// Step 3: Create the lst
|
|
92
|
-
const tx2 = new
|
|
93
|
-
const weightHookAdminCap =
|
|
90
|
+
const tx2 = new Transaction();
|
|
91
|
+
const weightHookAdminCap = LstClient.createNewLst(tx2, treasuryCapId, coinType);
|
|
94
92
|
tx2.transferObjects([tx2.object(weightHookAdminCap)], keypair.toSuiAddress());
|
|
95
93
|
const txResponse2 = yield client.signAndExecuteTransaction({
|
|
96
94
|
transaction: tx2,
|
package/cli/src/index.js
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,30 +7,29 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
8
|
});
|
|
43
9
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const liquid_staking_1 = require("@suilend/springsui-sdk/_generated/liquid_staking");
|
|
10
|
+
import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
11
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
12
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
13
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
14
|
+
import { program } from "commander";
|
|
15
|
+
import { LstClient } from "@suilend/springsui-sdk";
|
|
16
|
+
import * as sdk from "@suilend/springsui-sdk";
|
|
17
|
+
import { PACKAGE_ID } from "@suilend/springsui-sdk/_generated/liquid_staking";
|
|
53
18
|
const LIQUID_STAKING_INFO = {
|
|
54
19
|
id: "0x15eda7330c8f99c30e430b4d82fd7ab2af3ead4ae17046fcb224aa9bad394f6b",
|
|
55
20
|
type: "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI",
|
|
56
21
|
weightHookId: "0xbbafcb2d7399c0846f8185da3f273ad5b26b3b35993050affa44cfa890f1f144",
|
|
57
22
|
};
|
|
58
23
|
const RPC_URL = "https://fullnode.mainnet.sui.io";
|
|
59
|
-
const keypair =
|
|
24
|
+
const keypair = Ed25519Keypair.fromSecretKey(fromBase64(process.env.SUI_SECRET_KEY));
|
|
60
25
|
// const keypair = Ed25519Keypair.fromSecretKey(
|
|
61
26
|
// fromHex(fs.readFileSync(process.env.SUI_SECRET_KEY_PATH!).toString()),
|
|
62
27
|
// );
|
|
63
28
|
function mint(options) {
|
|
64
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
const client = new
|
|
66
|
-
const lstClient = yield
|
|
67
|
-
const tx = new
|
|
30
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
31
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
32
|
+
const tx = new Transaction();
|
|
68
33
|
const [sui] = tx.splitCoins(tx.gas, [BigInt(options.amount)]);
|
|
69
34
|
const rSui = lstClient.mint(tx, sui);
|
|
70
35
|
tx.transferObjects([rSui], keypair.toSuiAddress());
|
|
@@ -82,14 +47,14 @@ function mint(options) {
|
|
|
82
47
|
}
|
|
83
48
|
function redeem(options) {
|
|
84
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const client = new
|
|
50
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
86
51
|
const lstCoins = yield client.getCoins({
|
|
87
52
|
owner: keypair.toSuiAddress(),
|
|
88
53
|
coinType: LIQUID_STAKING_INFO.type,
|
|
89
54
|
limit: 1000,
|
|
90
55
|
});
|
|
91
|
-
const tx = new
|
|
92
|
-
const lstClient = yield
|
|
56
|
+
const tx = new Transaction();
|
|
57
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
93
58
|
if (lstCoins.data.length > 1) {
|
|
94
59
|
tx.mergeCoins(lstCoins.data[0].coinObjectId, lstCoins.data.slice(1).map((c) => c.coinObjectId));
|
|
95
60
|
}
|
|
@@ -112,12 +77,12 @@ function redeem(options) {
|
|
|
112
77
|
}
|
|
113
78
|
function increaseValidatorStake(options) {
|
|
114
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
const client = new
|
|
116
|
-
const lstClient = yield
|
|
80
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
81
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
117
82
|
const adminCapId = yield lstClient.getAdminCapId(keypair.toSuiAddress());
|
|
118
83
|
if (!adminCapId)
|
|
119
84
|
return;
|
|
120
|
-
const tx = new
|
|
85
|
+
const tx = new Transaction();
|
|
121
86
|
lstClient.increaseValidatorStake(tx, adminCapId, options.validatorAddress, options.amount);
|
|
122
87
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
123
88
|
transaction: tx,
|
|
@@ -133,12 +98,12 @@ function increaseValidatorStake(options) {
|
|
|
133
98
|
}
|
|
134
99
|
function decreaseValidatorStake(options) {
|
|
135
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
-
const client = new
|
|
137
|
-
const lstClient = yield
|
|
101
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
102
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
138
103
|
const adminCapId = yield lstClient.getAdminCapId(keypair.toSuiAddress());
|
|
139
104
|
if (!adminCapId)
|
|
140
105
|
return;
|
|
141
|
-
const tx = new
|
|
106
|
+
const tx = new Transaction();
|
|
142
107
|
lstClient.decreaseValidatorStake(tx, adminCapId, options.validatorIndex, options.amount);
|
|
143
108
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
144
109
|
transaction: tx,
|
|
@@ -155,18 +120,18 @@ function decreaseValidatorStake(options) {
|
|
|
155
120
|
function updateFees(options) {
|
|
156
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
157
122
|
var _a;
|
|
158
|
-
const client = new
|
|
159
|
-
const lstClient = yield
|
|
123
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
124
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
160
125
|
const adminCap = (yield client.getOwnedObjects({
|
|
161
126
|
owner: keypair.toSuiAddress(),
|
|
162
127
|
filter: {
|
|
163
|
-
StructType: `${
|
|
128
|
+
StructType: `${PACKAGE_ID}::liquid_staking::AdminCap<${LIQUID_STAKING_INFO.type}>`,
|
|
164
129
|
},
|
|
165
130
|
})).data[0];
|
|
166
131
|
const adminCapId = (_a = adminCap.data) === null || _a === void 0 ? void 0 : _a.objectId;
|
|
167
132
|
if (!adminCapId)
|
|
168
133
|
return;
|
|
169
|
-
const tx = new
|
|
134
|
+
const tx = new Transaction();
|
|
170
135
|
lstClient.updateFees(tx, adminCapId, options);
|
|
171
136
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
172
137
|
transaction: tx,
|
|
@@ -182,12 +147,12 @@ function updateFees(options) {
|
|
|
182
147
|
}
|
|
183
148
|
function initializeWeightHook(options) {
|
|
184
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
const client = new
|
|
186
|
-
const lstClient = yield
|
|
150
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
151
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
187
152
|
const adminCapId = yield lstClient.getAdminCapId(keypair.toSuiAddress());
|
|
188
153
|
if (!adminCapId)
|
|
189
154
|
return;
|
|
190
|
-
const tx = new
|
|
155
|
+
const tx = new Transaction();
|
|
191
156
|
const weightHookAdminCap = lstClient.initializeWeightHook(tx, adminCapId);
|
|
192
157
|
tx.transferObjects([weightHookAdminCap], keypair.toSuiAddress());
|
|
193
158
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
@@ -204,8 +169,8 @@ function initializeWeightHook(options) {
|
|
|
204
169
|
}
|
|
205
170
|
function setValidatorAddressesAndWeights(options) {
|
|
206
171
|
return __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
const client = new
|
|
208
|
-
const lstClient = yield
|
|
172
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
173
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
209
174
|
if (options.validators.length != options.weights.length) {
|
|
210
175
|
throw new Error("Validators and weights arrays must be of the same length");
|
|
211
176
|
}
|
|
@@ -214,10 +179,10 @@ function setValidatorAddressesAndWeights(options) {
|
|
|
214
179
|
validatorAddressesAndWeights[options.validators[i]] = options.weights[i];
|
|
215
180
|
}
|
|
216
181
|
console.log(validatorAddressesAndWeights);
|
|
217
|
-
const weightHookAdminCapId = yield
|
|
182
|
+
const weightHookAdminCapId = yield LstClient.getWeightHookAdminCapId(client, keypair.toSuiAddress(), LIQUID_STAKING_INFO.type);
|
|
218
183
|
if (!weightHookAdminCapId)
|
|
219
184
|
return;
|
|
220
|
-
const tx = new
|
|
185
|
+
const tx = new Transaction();
|
|
221
186
|
lstClient.setValidatorAddressesAndWeights(tx, LIQUID_STAKING_INFO.weightHookId, weightHookAdminCapId, validatorAddressesAndWeights);
|
|
222
187
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
223
188
|
transaction: tx,
|
|
@@ -233,9 +198,9 @@ function setValidatorAddressesAndWeights(options) {
|
|
|
233
198
|
}
|
|
234
199
|
function rebalance(options) {
|
|
235
200
|
return __awaiter(this, void 0, void 0, function* () {
|
|
236
|
-
const client = new
|
|
237
|
-
const lstClient = yield
|
|
238
|
-
const tx = new
|
|
201
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
202
|
+
const lstClient = yield LstClient.initialize(client, LIQUID_STAKING_INFO);
|
|
203
|
+
const tx = new Transaction();
|
|
239
204
|
lstClient.rebalance(tx, LIQUID_STAKING_INFO.weightHookId);
|
|
240
205
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
241
206
|
transaction: tx,
|
|
@@ -252,7 +217,7 @@ function rebalance(options) {
|
|
|
252
217
|
function createNewLst(options) {
|
|
253
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
219
|
var _a;
|
|
255
|
-
const client = new
|
|
220
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
256
221
|
const treasuryCap = yield client.getObject({
|
|
257
222
|
id: options.treasuryCap,
|
|
258
223
|
options: {
|
|
@@ -266,8 +231,8 @@ function createNewLst(options) {
|
|
|
266
231
|
return;
|
|
267
232
|
const coinType = type.substring(type.indexOf("<") + 1, type.lastIndexOf(">"));
|
|
268
233
|
console.log(coinType);
|
|
269
|
-
const tx = new
|
|
270
|
-
const weightHookAdminCap =
|
|
234
|
+
const tx = new Transaction();
|
|
235
|
+
const weightHookAdminCap = LstClient.createNewLst(tx, options.treasuryCap, coinType);
|
|
271
236
|
tx.transferObjects([tx.object(weightHookAdminCap)], keypair.toSuiAddress());
|
|
272
237
|
const txResponse = yield client.signAndExecuteTransaction({
|
|
273
238
|
transaction: tx,
|
|
@@ -281,41 +246,41 @@ function createNewLst(options) {
|
|
|
281
246
|
console.log(txResponse);
|
|
282
247
|
});
|
|
283
248
|
}
|
|
284
|
-
|
|
285
|
-
|
|
249
|
+
program.version("1.0.0").description("Spring Sui CLI");
|
|
250
|
+
program
|
|
286
251
|
.command("mint")
|
|
287
252
|
.description("mint some rSui")
|
|
288
253
|
.option("--amount <SUI>", "Amount of SUI in MIST")
|
|
289
254
|
.action(mint);
|
|
290
|
-
|
|
255
|
+
program
|
|
291
256
|
.command("redeem")
|
|
292
257
|
.description("redeem some SUI")
|
|
293
258
|
.option("--amount <LST>", "Amount of LST to redeem")
|
|
294
259
|
.action(redeem);
|
|
295
|
-
|
|
260
|
+
program
|
|
296
261
|
.command("increase-validator-stake")
|
|
297
262
|
.description("increase validator stake")
|
|
298
263
|
.option("--validator-address <VALIDATOR>", "Validator address")
|
|
299
264
|
.option("--amount <SUI>", "Amount of SUI to delegate to validator")
|
|
300
265
|
.action(increaseValidatorStake);
|
|
301
|
-
|
|
266
|
+
program
|
|
302
267
|
.command("decrease-validator-stake")
|
|
303
268
|
.description("decrease validator stake")
|
|
304
269
|
.option("--validator-index <VALIDATOR_INDEX>", "Validator index")
|
|
305
270
|
.option("--amount <SUI>", "Amount of SUI to undelegate from validator")
|
|
306
271
|
.action(decreaseValidatorStake);
|
|
307
|
-
|
|
272
|
+
program
|
|
308
273
|
.command("update-fees")
|
|
309
274
|
.description("update fees")
|
|
310
275
|
.option("--mint-fee-bps <MINT_FEE_BPS>", "Mint fee bps")
|
|
311
276
|
.option("--redeem-fee-bps <REDEEM_FEE_BPS>", "Redeem fee bps")
|
|
312
277
|
.option("--spread-fee <SPREAD_FEE>", "Spread fee")
|
|
313
278
|
.action(updateFees);
|
|
314
|
-
|
|
279
|
+
program
|
|
315
280
|
.command("fetch-state")
|
|
316
281
|
.description("fetch the current state of the liquid staking pool")
|
|
317
282
|
.action(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
318
|
-
const client = new
|
|
283
|
+
const client = new SuiJsonRpcClient({ url: RPC_URL, network: "mainnet" });
|
|
319
284
|
try {
|
|
320
285
|
const state = yield sdk.fetchLiquidStakingInfo(LIQUID_STAKING_INFO, client);
|
|
321
286
|
console.log("Current Liquid Staking State:");
|
|
@@ -325,7 +290,7 @@ commander_1.program
|
|
|
325
290
|
console.error("Error fetching state:", error);
|
|
326
291
|
}
|
|
327
292
|
}));
|
|
328
|
-
|
|
293
|
+
program
|
|
329
294
|
.command("initialize-weight-hook")
|
|
330
295
|
.description("initialize weight hook")
|
|
331
296
|
.action(initializeWeightHook);
|
|
@@ -336,19 +301,19 @@ function collect(pair, previous) {
|
|
|
336
301
|
}
|
|
337
302
|
return Object.assign(Object.assign({}, previous), { [key]: value });
|
|
338
303
|
}
|
|
339
|
-
|
|
304
|
+
program
|
|
340
305
|
.command("set-validator-addresses-and-weights")
|
|
341
306
|
.description("set validator addresses and weights")
|
|
342
307
|
.option("-v, --validators <VALIDATOR_ADDRESSES...>", "Validator addresses")
|
|
343
308
|
.option("-w, --weights <WEIGHTS...>", "Weights")
|
|
344
309
|
.action(setValidatorAddressesAndWeights);
|
|
345
|
-
|
|
310
|
+
program
|
|
346
311
|
.command("rebalance")
|
|
347
312
|
.description("rebalance the validator set")
|
|
348
313
|
.action(rebalance);
|
|
349
|
-
|
|
314
|
+
program
|
|
350
315
|
.command("create-new-lst")
|
|
351
316
|
.description("create a new liquid staking pool")
|
|
352
317
|
.option("--treasury-cap <TREASURY_CAP>", "Treasury cap")
|
|
353
318
|
.action(createNewLst);
|
|
354
|
-
|
|
319
|
+
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/springsui-cli","version":"
|
|
1
|
+
{"name":"@suilend/springsui-cli","version":"2.0.0","private":false,"description":"A CLI for interacting with the SpringSui program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./cli/src":"./cli/src/index.js","./cli/src/bytecode":"./cli/src/bytecode.js","./sdk/src/client":"./sdk/src/client.js","./sdk/src":"./sdk/src/index.js","./sdk/src/lib/transactions":"./sdk/src/lib/transactions.js","./sdk/src/lib":"./sdk/src/lib/index.js","./sdk/src/_generated/liquid_staking":"./sdk/src/_generated/liquid_staking/index.js","./sdk/src/_generated/_framework/util":"./sdk/src/_generated/_framework/util.js","./sdk/src/_generated/_framework/reified":"./sdk/src/_generated/_framework/reified.js","./sdk/src/_generated/_framework/vector":"./sdk/src/_generated/_framework/vector.js","./sdk/src/_generated/liquid_staking/weight/functions":"./sdk/src/_generated/liquid_staking/weight/functions.js","./sdk/src/_generated/liquid_staking/weight/structs":"./sdk/src/_generated/liquid_staking/weight/structs.js","./sdk/src/_generated/liquid_staking/fees/functions":"./sdk/src/_generated/liquid_staking/fees/functions.js","./sdk/src/_generated/liquid_staking/fees/structs":"./sdk/src/_generated/liquid_staking/fees/structs.js","./sdk/src/_generated/liquid_staking/liquid-staking/functions":"./sdk/src/_generated/liquid_staking/liquid-staking/functions.js","./sdk/src/_generated/liquid_staking/liquid-staking/structs":"./sdk/src/_generated/liquid_staking/liquid-staking/structs.js","./sdk/src/_generated/liquid_staking/storage/structs":"./sdk/src/_generated/liquid_staking/storage/structs.js","./sdk/src/_generated/liquid_staking/cell/structs":"./sdk/src/_generated/liquid_staking/cell/structs.js","./sdk/src/_generated/liquid_staking/version/structs":"./sdk/src/_generated/liquid_staking/version/structs.js","./sdk/src/_generated/_dependencies/source/0x3":"./sdk/src/_generated/_dependencies/source/0x3/index.js","./sdk/src/_generated/_dependencies/source/0x2":"./sdk/src/_generated/_dependencies/source/0x2/index.js","./sdk/src/_generated/_dependencies/source/0x1":"./sdk/src/_generated/_dependencies/source/0x1/index.js","./sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs":"./sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js","./sdk/src/_generated/_dependencies/source/0x2/sui/structs":"./sdk/src/_generated/_dependencies/source/0x2/sui/structs.js","./sdk/src/_generated/_dependencies/source/0x2/balance/structs":"./sdk/src/_generated/_dependencies/source/0x2/balance/structs.js","./sdk/src/_generated/_dependencies/source/0x2/url/structs":"./sdk/src/_generated/_dependencies/source/0x2/url/structs.js","./sdk/src/_generated/_dependencies/source/0x2/coin/structs":"./sdk/src/_generated/_dependencies/source/0x2/coin/structs.js","./sdk/src/_generated/_dependencies/source/0x2/object/structs":"./sdk/src/_generated/_dependencies/source/0x2/object/structs.js","./sdk/src/_generated/_dependencies/source/0x2/table/structs":"./sdk/src/_generated/_dependencies/source/0x2/table/structs.js","./sdk/src/_generated/_dependencies/source/0x2/bag/structs":"./sdk/src/_generated/_dependencies/source/0x2/bag/structs.js","./sdk/src/_generated/_dependencies/source/0x2/vec-map/structs":"./sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js","./sdk/src/_generated/_dependencies/source/0x1/ascii/structs":"./sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js","./sdk/src/_generated/_dependencies/source/0x1/option/structs":"./sdk/src/_generated/_dependencies/source/0x1/option/structs.js","./sdk/src/_generated/_dependencies/source/0x1/type-name/structs":"./sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js","./sdk/src/_generated/_dependencies/source/0x1/string/structs":"./sdk/src/_generated/_dependencies/source/0x1/string/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc --noEmit","release":"bun run build && bun ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/springsui-fe-public.git"},"bugs":{"url":"https://github.com/suilend/springsui-fe-public/issues"},"dependencies":{"commander":"^12.1.0","@mysten/move-bytecode-template":"0.1.0"},"devDependencies":{"ts-node":"^10.9.2"},"peerDependencies":{"@mysten/bcs":"2.0.1","@mysten/sui":"2.3.1"},"overrides":{"chalk":"5.3.0","strip-ansi":"7.1.0","color-convert":"2.0.1","color-name":"1.1.4","is-core-module":"2.13.1","error-ex":"1.3.2","has-ansi":"5.0.1"}}
|
|
@@ -3,7 +3,7 @@ import { PhantomReified, Reified, StructClass, ToField, ToTypeStr } from "../../
|
|
|
3
3
|
import { FieldsWithTypes } from "../../../../_framework/util";
|
|
4
4
|
import { Vector } from "../../../../_framework/vector";
|
|
5
5
|
import { PKG_V14 } from "../index";
|
|
6
|
-
import {
|
|
6
|
+
import { SuiJsonRpcClient, SuiObjectData, SuiParsedData } from "@mysten/sui/jsonRpc";
|
|
7
7
|
export declare function isChar(type: string): boolean;
|
|
8
8
|
export interface CharFields {
|
|
9
9
|
byte: ToField<"u8">;
|
|
@@ -24,8 +24,8 @@ export declare class Char implements StructClass {
|
|
|
24
24
|
static get r(): reified.StructClassReified<Char, CharFields>;
|
|
25
25
|
static phantom(): PhantomReified<ToTypeStr<Char>>;
|
|
26
26
|
static get p(): reified.PhantomReified<"0x1::ascii::Char">;
|
|
27
|
-
static get bcs(): import("@mysten/
|
|
28
|
-
byte: import("@mysten/
|
|
27
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
28
|
+
byte: import("@mysten/bcs").BcsType<number, number, "u8">;
|
|
29
29
|
}, string>;
|
|
30
30
|
static fromFields(fields: Record<string, any>): Char;
|
|
31
31
|
static fromFieldsWithTypes(item: FieldsWithTypes): Char;
|
|
@@ -42,7 +42,7 @@ export declare class Char implements StructClass {
|
|
|
42
42
|
static fromJSON(json: Record<string, any>): Char;
|
|
43
43
|
static fromSuiParsedData(content: SuiParsedData): Char;
|
|
44
44
|
static fromSuiObjectData(data: SuiObjectData): Char;
|
|
45
|
-
static fetch(client:
|
|
45
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<Char>;
|
|
46
46
|
}
|
|
47
47
|
export declare function isString(type: string): boolean;
|
|
48
48
|
export interface StringFields {
|
|
@@ -64,8 +64,8 @@ export declare class String implements StructClass {
|
|
|
64
64
|
static get r(): reified.StructClassReified<String, StringFields>;
|
|
65
65
|
static phantom(): PhantomReified<ToTypeStr<String>>;
|
|
66
66
|
static get p(): reified.PhantomReified<"0x1::ascii::String">;
|
|
67
|
-
static get bcs(): import("@mysten/
|
|
68
|
-
bytes: import("@mysten/
|
|
67
|
+
static get bcs(): import("@mysten/bcs").BcsStruct<{
|
|
68
|
+
bytes: import("@mysten/bcs").BcsType<number[], Iterable<number> & {
|
|
69
69
|
length: number;
|
|
70
70
|
}, string>;
|
|
71
71
|
}, string>;
|
|
@@ -84,5 +84,5 @@ export declare class String implements StructClass {
|
|
|
84
84
|
static fromJSON(json: Record<string, any>): String;
|
|
85
85
|
static fromSuiParsedData(content: SuiParsedData): String;
|
|
86
86
|
static fromSuiObjectData(data: SuiObjectData): String;
|
|
87
|
-
static fetch(client:
|
|
87
|
+
static fetch(client: SuiJsonRpcClient, id: string): Promise<String>;
|
|
88
88
|
}
|