@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.
Files changed (60) hide show
  1. package/cli/src/bytecode.js +28 -30
  2. package/cli/src/index.js +51 -86
  3. package/package.json +1 -1
  4. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  5. package/sdk/src/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  6. package/sdk/src/_generated/_dependencies/source/0x1/index.js +3 -6
  7. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  8. package/sdk/src/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  9. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.d.ts +4 -4
  10. package/sdk/src/_generated/_dependencies/source/0x1/string/structs.js +21 -59
  11. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  12. package/sdk/src/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  13. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  14. package/sdk/src/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  15. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  16. package/sdk/src/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  17. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.d.ts +52 -52
  18. package/sdk/src/_generated/_dependencies/source/0x2/coin/structs.js +206 -223
  19. package/sdk/src/_generated/_dependencies/source/0x2/index.js +3 -6
  20. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  21. package/sdk/src/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  22. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.d.ts +4 -4
  23. package/sdk/src/_generated/_dependencies/source/0x2/sui/structs.js +19 -24
  24. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.d.ts +7 -7
  25. package/sdk/src/_generated/_dependencies/source/0x2/table/structs.js +31 -36
  26. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.d.ts +5 -5
  27. package/sdk/src/_generated/_dependencies/source/0x2/url/structs.js +20 -25
  28. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.d.ts +5 -5
  29. package/sdk/src/_generated/_dependencies/source/0x2/vec-map/structs.js +57 -97
  30. package/sdk/src/_generated/_dependencies/source/0x3/index.js +3 -6
  31. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.d.ts +60 -60
  32. package/sdk/src/_generated/_dependencies/source/0x3/staking-pool/structs.js +170 -218
  33. package/sdk/src/_generated/_framework/reified.d.ts +2 -2
  34. package/sdk/src/_generated/_framework/reified.js +27 -40
  35. package/sdk/src/_generated/_framework/util.d.ts +2 -14
  36. package/sdk/src/_generated/_framework/util.js +26 -40
  37. package/sdk/src/_generated/_framework/vector.d.ts +4 -4
  38. package/sdk/src/_generated/_framework/vector.js +16 -21
  39. package/sdk/src/_generated/liquid_staking/cell/structs.d.ts +4 -4
  40. package/sdk/src/_generated/liquid_staking/cell/structs.js +31 -36
  41. package/sdk/src/_generated/liquid_staking/fees/functions.js +55 -75
  42. package/sdk/src/_generated/liquid_staking/fees/structs.d.ts +21 -21
  43. package/sdk/src/_generated/liquid_staking/fees/structs.js +58 -65
  44. package/sdk/src/_generated/liquid_staking/index.js +6 -10
  45. package/sdk/src/_generated/liquid_staking/liquid-staking/functions.js +86 -107
  46. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.d.ts +98 -98
  47. package/sdk/src/_generated/liquid_staking/liquid-staking/structs.js +264 -320
  48. package/sdk/src/_generated/liquid_staking/storage/structs.d.ts +31 -31
  49. package/sdk/src/_generated/liquid_staking/storage/structs.js +85 -125
  50. package/sdk/src/_generated/liquid_staking/version/structs.d.ts +4 -4
  51. package/sdk/src/_generated/liquid_staking/version/structs.js +19 -24
  52. package/sdk/src/_generated/liquid_staking/weight/functions.js +44 -56
  53. package/sdk/src/_generated/liquid_staking/weight/structs.d.ts +41 -41
  54. package/sdk/src/_generated/liquid_staking/weight/structs.js +128 -141
  55. package/sdk/src/client.d.ts +16 -16
  56. package/sdk/src/client.js +39 -82
  57. package/sdk/src/index.js +2 -18
  58. package/sdk/src/lib/index.js +1 -17
  59. package/sdk/src/lib/transactions.d.ts +1 -1
  60. package/sdk/src/lib/transactions.js +3 -8
@@ -1,4 +1,4 @@
1
- import { SuiClient, ValidatorApy } from "@mysten/sui/client";
1
+ import { SuiJsonRpcClient, ValidatorApy } from "@mysten/sui/jsonRpc";
2
2
  import { Transaction, TransactionObjectInput } from "@mysten/sui/transactions";
3
3
  import BigNumber from "bignumber.js";
4
4
  import { LiquidStakingInfo } from "./_generated/liquid_staking/liquid-staking/structs";
@@ -15,51 +15,51 @@ export interface FeeConfigArgs {
15
15
  export declare const SUILEND_VALIDATOR_ADDRESS = "0xce8e537664ba5d1d5a6a857b17bd142097138706281882be6805e17065ecde89";
16
16
  export declare const SPRING_SUI_UPGRADE_CAP_ID = "0x4dc657b6c0fe896f4b94fee1ceac96312dde0a36b94e799caaec30deb53dcd67";
17
17
  export declare const ADMIN_ADDRESS = "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25";
18
- export declare function getLatestPackageId(client: SuiClient, upgradeCapId: string): Promise<string>;
18
+ export declare function getLatestPackageId(client: SuiJsonRpcClient, upgradeCapId: string): Promise<string>;
19
19
  export declare class LstClient {
20
20
  liquidStakingObject: LiquidStakingObjectInfo;
21
- client: SuiClient;
22
- static initialize(client: SuiClient, liquidStakingObjectInfo: LiquidStakingObjectInfo, _publishedAt?: string, logPackageId?: boolean): Promise<LstClient>;
21
+ client: SuiJsonRpcClient;
22
+ static initialize(client: SuiJsonRpcClient, liquidStakingObjectInfo: LiquidStakingObjectInfo, _publishedAt?: string, logPackageId?: boolean): Promise<LstClient>;
23
23
  static createNewLst(tx: Transaction, treasuryCap: string, coinType: string): TransactionObjectInput;
24
- static getWeightHookAdminCapId(client: SuiClient, address: string, coinType: string): Promise<string | null | undefined>;
25
- constructor(liquidStakingObject: LiquidStakingObjectInfo, client: SuiClient);
24
+ static getWeightHookAdminCapId(client: SuiJsonRpcClient, address: string, coinType: string): Promise<string | null | undefined>;
25
+ constructor(liquidStakingObject: LiquidStakingObjectInfo, client: SuiJsonRpcClient);
26
26
  getAdminCapId(address: string): Promise<string | null | undefined>;
27
27
  mint(tx: Transaction, suiCoinId: TransactionObjectInput): {
28
- $kind: "NestedResult";
29
28
  NestedResult: [number, number];
29
+ $kind: "NestedResult";
30
30
  };
31
31
  mintAmountAndRebalance(tx: Transaction, address: string, amount: string): {
32
- $kind: "NestedResult";
33
32
  NestedResult: [number, number];
33
+ $kind: "NestedResult";
34
34
  };
35
35
  mintAmountAndRebalanceAndSendToUser(tx: Transaction, address: string, amount: string): void;
36
36
  redeem(tx: Transaction, lstId: TransactionObjectInput): {
37
- $kind: "NestedResult";
38
37
  NestedResult: [number, number];
39
- };
40
- redeemAmountAndRebalance(tx: Transaction, address: string, amount: string, client: SuiClient): Promise<{
41
38
  $kind: "NestedResult";
39
+ };
40
+ redeemAmountAndRebalance(tx: Transaction, address: string, amount: string, client: SuiJsonRpcClient): Promise<{
42
41
  NestedResult: [number, number];
42
+ $kind: "NestedResult";
43
43
  }>;
44
- redeemAmountAndRebalanceAndSendToUser(tx: Transaction, address: string, amount: string, client: SuiClient): Promise<void>;
44
+ redeemAmountAndRebalanceAndSendToUser(tx: Transaction, address: string, amount: string, client: SuiJsonRpcClient): Promise<void>;
45
45
  increaseValidatorStake(tx: Transaction, adminCapId: TransactionObjectInput, validatorAddress: string, suiAmount: number): void;
46
46
  decreaseValidatorStake(tx: Transaction, adminCapId: TransactionObjectInput, validatorAddress: string, targetUnstakeSuiAmount: bigint): void;
47
47
  collectFees(tx: Transaction, weightHookAdminCapId: TransactionObjectInput): {
48
- $kind: "NestedResult";
49
48
  NestedResult: [number, number];
49
+ $kind: "NestedResult";
50
50
  };
51
51
  collectFeesAndSendToUser(tx: Transaction, weightHookAdminCapId: TransactionObjectInput, address: string): void;
52
52
  updateFees(tx: Transaction, weightHookAdminCapId: TransactionObjectInput, feeConfigArgs: FeeConfigArgs): void;
53
53
  initializeWeightHook(tx: Transaction, adminCapId: TransactionObjectInput): {
54
- $kind: "NestedResult";
55
54
  NestedResult: [number, number];
55
+ $kind: "NestedResult";
56
56
  };
57
57
  setValidatorAddressesAndWeights(tx: Transaction, weightHookId: TransactionObjectInput, weightHookAdminCap: TransactionObjectInput, validatorAddressesAndWeights: Record<string, number>): void;
58
58
  rebalance(tx: Transaction, weightHookId: TransactionObjectInput): void;
59
59
  getSpringSuiApy(_validatorApys?: ValidatorApy[]): Promise<BigNumber>;
60
60
  }
61
- export declare const fetchLiquidStakingInfo: (info: LiquidStakingObjectInfo, client: SuiClient) => Promise<LiquidStakingInfo<any>>;
62
- export declare const fetchRegistryLiquidStakingInfoMap: (client: SuiClient) => Promise<{
61
+ export declare const fetchLiquidStakingInfo: (info: LiquidStakingObjectInfo, client: SuiJsonRpcClient) => Promise<LiquidStakingInfo<any>>;
62
+ export declare const fetchRegistryLiquidStakingInfoMap: (client: SuiJsonRpcClient) => Promise<{
63
63
  [x: string]: LiquidStakingObjectInfo | {
64
64
  id: any;
65
65
  type: string;
package/sdk/src/client.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,26 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
41
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
42
8
  });
43
9
  };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.fetchRegistryLiquidStakingInfoMap = exports.fetchLiquidStakingInfo = exports.LstClient = exports.ADMIN_ADDRESS = exports.SPRING_SUI_UPGRADE_CAP_ID = exports.SUILEND_VALIDATOR_ADDRESS = void 0;
49
- exports.getLatestPackageId = getLatestPackageId;
50
- const utils_1 = require("@mysten/sui/utils");
51
- const bignumber_js_1 = __importDefault(require("bignumber.js"));
52
- const reified_1 = require("./_generated/_framework/reified");
53
- const liquid_staking_1 = require("./_generated/liquid_staking");
54
- const functions_1 = require("./_generated/liquid_staking/fees/functions");
55
- const generated = __importStar(require("./_generated/liquid_staking/liquid-staking/functions"));
56
- const structs_1 = require("./_generated/liquid_staking/liquid-staking/structs");
57
- const weightHookGenerated = __importStar(require("./_generated/liquid_staking/weight/functions"));
58
- const structs_2 = require("./_generated/liquid_staking/weight/structs");
10
+ import { SUI_DECIMALS, normalizeStructTag } from "@mysten/sui/utils";
11
+ import BigNumber from "bignumber.js";
12
+ import { phantom } from "./_generated/_framework/reified";
13
+ import { PACKAGE_ID, setPublishedAt } from "./_generated/liquid_staking";
14
+ import { newBuilder, setRedeemFeeBps, setSpreadFeeBps, setSuiMintFeeBps, toFeeConfig, } from "./_generated/liquid_staking/fees/functions";
15
+ import * as generated from "./_generated/liquid_staking/liquid-staking/functions";
16
+ import { LiquidStakingInfo } from "./_generated/liquid_staking/liquid-staking/structs";
17
+ import * as weightHookGenerated from "./_generated/liquid_staking/weight/functions";
18
+ import { WeightHook } from "./_generated/liquid_staking/weight/structs";
59
19
  const SUI_SYSTEM_STATE_ID = "0x0000000000000000000000000000000000000000000000000000000000000005";
60
- exports.SUILEND_VALIDATOR_ADDRESS = "0xce8e537664ba5d1d5a6a857b17bd142097138706281882be6805e17065ecde89";
61
- exports.SPRING_SUI_UPGRADE_CAP_ID = "0x4dc657b6c0fe896f4b94fee1ceac96312dde0a36b94e799caaec30deb53dcd67";
62
- exports.ADMIN_ADDRESS = "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25";
63
- function getLatestPackageId(client, upgradeCapId) {
20
+ export const SUILEND_VALIDATOR_ADDRESS = "0xce8e537664ba5d1d5a6a857b17bd142097138706281882be6805e17065ecde89";
21
+ export const SPRING_SUI_UPGRADE_CAP_ID = "0x4dc657b6c0fe896f4b94fee1ceac96312dde0a36b94e799caaec30deb53dcd67";
22
+ export const ADMIN_ADDRESS = "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25";
23
+ export function getLatestPackageId(client, upgradeCapId) {
64
24
  return __awaiter(this, void 0, void 0, function* () {
65
25
  var _a;
66
26
  const object = yield client.getObject({
@@ -72,19 +32,19 @@ function getLatestPackageId(client, upgradeCapId) {
72
32
  return ((_a = object.data) === null || _a === void 0 ? void 0 : _a.content).fields.package;
73
33
  });
74
34
  }
75
- class LstClient {
35
+ export class LstClient {
76
36
  static initialize(client, liquidStakingObjectInfo, _publishedAt, logPackageId) {
77
37
  return __awaiter(this, void 0, void 0, function* () {
78
- const publishedAt = _publishedAt !== null && _publishedAt !== void 0 ? _publishedAt : (yield getLatestPackageId(client, exports.SPRING_SUI_UPGRADE_CAP_ID));
38
+ const publishedAt = _publishedAt !== null && _publishedAt !== void 0 ? _publishedAt : (yield getLatestPackageId(client, SPRING_SUI_UPGRADE_CAP_ID));
79
39
  if (logPackageId)
80
40
  console.log("@suilend/springsui-sdk | publishedAt:", publishedAt);
81
- (0, liquid_staking_1.setPublishedAt)(publishedAt);
41
+ setPublishedAt(publishedAt);
82
42
  return new LstClient(liquidStakingObjectInfo, client);
83
43
  });
84
44
  }
85
45
  static createNewLst(tx, treasuryCap, coinType) {
86
- const [feeConfigBuilder] = (0, functions_1.newBuilder)(tx);
87
- const [feeConfig] = (0, functions_1.toFeeConfig)(tx, feeConfigBuilder);
46
+ const [feeConfigBuilder] = newBuilder(tx);
47
+ const [feeConfig] = toFeeConfig(tx, feeConfigBuilder);
88
48
  const [adminCap, liquidStakingInfo] = generated.createLst(tx, coinType, {
89
49
  feeConfig,
90
50
  lstTreasuryCap: treasuryCap,
@@ -97,12 +57,12 @@ class LstClient {
97
57
  });
98
58
  tx.moveCall({
99
59
  target: `0x2::transfer::public_share_object`,
100
- typeArguments: [`${structs_1.LiquidStakingInfo.$typeName}<${coinType}>`],
60
+ typeArguments: [`${LiquidStakingInfo.$typeName}<${coinType}>`],
101
61
  arguments: [liquidStakingInfo],
102
62
  });
103
63
  tx.moveCall({
104
64
  target: `0x2::transfer::public_share_object`,
105
- typeArguments: [`${structs_2.WeightHook.$typeName}<${coinType}>`],
65
+ typeArguments: [`${WeightHook.$typeName}<${coinType}>`],
106
66
  arguments: [weightHook],
107
67
  });
108
68
  return weightHookAdminCap;
@@ -113,7 +73,7 @@ class LstClient {
113
73
  const res = (yield client.getOwnedObjects({
114
74
  owner: address,
115
75
  filter: {
116
- StructType: `${liquid_staking_1.PACKAGE_ID}::weight::WeightHookAdminCap<${coinType}>`,
76
+ StructType: `${PACKAGE_ID}::weight::WeightHookAdminCap<${coinType}>`,
117
77
  },
118
78
  })).data;
119
79
  if (res.length == 0) {
@@ -132,7 +92,7 @@ class LstClient {
132
92
  const res = (yield this.client.getOwnedObjects({
133
93
  owner: address,
134
94
  filter: {
135
- StructType: `${liquid_staking_1.PACKAGE_ID}::liquid_staking::AdminCap<${this.liquidStakingObject.type}>`,
95
+ StructType: `${PACKAGE_ID}::liquid_staking::AdminCap<${this.liquidStakingObject.type}>`,
136
96
  },
137
97
  })).data;
138
98
  if (res.length == 0) {
@@ -226,29 +186,29 @@ class LstClient {
226
186
  tx.transferObjects([sui], address);
227
187
  }
228
188
  updateFees(tx, weightHookAdminCapId, feeConfigArgs) {
229
- let [builder] = (0, functions_1.newBuilder)(tx);
189
+ let [builder] = newBuilder(tx);
230
190
  if (feeConfigArgs.mintFeeBps != null) {
231
191
  console.log(`Setting mint fee bps to ${feeConfigArgs.mintFeeBps}`);
232
- builder = (0, functions_1.setSuiMintFeeBps)(tx, {
192
+ builder = setSuiMintFeeBps(tx, {
233
193
  self: builder,
234
194
  fee: BigInt(feeConfigArgs.mintFeeBps),
235
195
  })[0];
236
196
  }
237
197
  if (feeConfigArgs.redeemFeeBps != null) {
238
198
  console.log(`Setting redeem fee bps to ${feeConfigArgs.redeemFeeBps}`);
239
- builder = (0, functions_1.setRedeemFeeBps)(tx, {
199
+ builder = setRedeemFeeBps(tx, {
240
200
  self: builder,
241
201
  fee: BigInt(feeConfigArgs.redeemFeeBps),
242
202
  })[0];
243
203
  }
244
204
  if (feeConfigArgs.spreadFeeBps != null) {
245
205
  console.log(`Setting spread fee bps to ${feeConfigArgs.spreadFeeBps}`);
246
- builder = (0, functions_1.setSpreadFeeBps)(tx, {
206
+ builder = setSpreadFeeBps(tx, {
247
207
  self: builder,
248
208
  fee: BigInt(feeConfigArgs.spreadFeeBps),
249
209
  })[0];
250
210
  }
251
- const [feeConfig] = (0, functions_1.toFeeConfig)(tx, builder);
211
+ const [feeConfig] = toFeeConfig(tx, builder);
252
212
  weightHookGenerated.updateFees(tx, this.liquidStakingObject.type, {
253
213
  self: this.liquidStakingObject.weightHookId,
254
214
  liquidStakingInfo: this.liquidStakingObject.id,
@@ -262,7 +222,7 @@ class LstClient {
262
222
  tx.moveCall({
263
223
  target: `0x2::transfer::public_share_object`,
264
224
  typeArguments: [
265
- `${structs_2.WeightHook.$typeName}<${this.liquidStakingObject.type}>`,
225
+ `${WeightHook.$typeName}<${this.liquidStakingObject.type}>`,
266
226
  ],
267
227
  arguments: [weightHook],
268
228
  });
@@ -302,27 +262,25 @@ class LstClient {
302
262
  return __awaiter(this, void 0, void 0, function* () {
303
263
  var _a, _b;
304
264
  const validatorApys = _validatorApys !== null && _validatorApys !== void 0 ? _validatorApys : (yield this.client.getValidatorsApy()).apys;
305
- const liquidStakingInfo = yield (0, exports.fetchLiquidStakingInfo)(this.liquidStakingObject, this.client);
306
- const totalSuiSupply = new bignumber_js_1.default(liquidStakingInfo.storage.totalSuiSupply.toString()).div(10 ** utils_1.SUI_DECIMALS);
307
- const spreadFeePercent = new bignumber_js_1.default((_b = (_a = liquidStakingInfo.feeConfig.element) === null || _a === void 0 ? void 0 : _a.spreadFeeBps.toString()) !== null && _b !== void 0 ? _b : 0).div(100);
308
- return new bignumber_js_1.default(totalSuiSupply.gt(0)
265
+ const liquidStakingInfo = yield fetchLiquidStakingInfo(this.liquidStakingObject, this.client);
266
+ const totalSuiSupply = new BigNumber(liquidStakingInfo.storage.totalSuiSupply.toString()).div(10 ** SUI_DECIMALS);
267
+ const spreadFeePercent = new BigNumber((_b = (_a = liquidStakingInfo.feeConfig.element) === null || _a === void 0 ? void 0 : _a.spreadFeeBps.toString()) !== null && _b !== void 0 ? _b : 0).div(100);
268
+ return new BigNumber(totalSuiSupply.gt(0)
309
269
  ? liquidStakingInfo.storage.validatorInfos
310
270
  .reduce((acc, validatorInfo) => {
311
271
  var _a, _b;
312
- const validatorApy = new bignumber_js_1.default((_b = (_a = validatorApys.find((_apy) => _apy.address === validatorInfo.validatorAddress)) === null || _a === void 0 ? void 0 : _a.apy) !== null && _b !== void 0 ? _b : 0);
313
- const validatorTotalSuiAmount = new bignumber_js_1.default(validatorInfo.totalSuiAmount.toString()).div(10 ** utils_1.SUI_DECIMALS);
272
+ const validatorApy = new BigNumber((_b = (_a = validatorApys.find((_apy) => _apy.address === validatorInfo.validatorAddress)) === null || _a === void 0 ? void 0 : _a.apy) !== null && _b !== void 0 ? _b : 0);
273
+ const validatorTotalSuiAmount = new BigNumber(validatorInfo.totalSuiAmount.toString()).div(10 ** SUI_DECIMALS);
314
274
  return acc.plus(validatorApy.times(validatorTotalSuiAmount));
315
- }, new bignumber_js_1.default(0))
275
+ }, new BigNumber(0))
316
276
  .div(totalSuiSupply)
317
- : new bignumber_js_1.default(0)).times(new bignumber_js_1.default(1).minus(spreadFeePercent.div(100)));
277
+ : new BigNumber(0)).times(new BigNumber(1).minus(spreadFeePercent.div(100)));
318
278
  });
319
279
  }
320
280
  }
321
- exports.LstClient = LstClient;
322
281
  // user functions
323
- const fetchLiquidStakingInfo = (info, client) => structs_1.LiquidStakingInfo.fetch(client, (0, reified_1.phantom)(info.type), info.id);
324
- exports.fetchLiquidStakingInfo = fetchLiquidStakingInfo;
325
- const fetchRegistryLiquidStakingInfoMap = (client) => __awaiter(void 0, void 0, void 0, function* () {
282
+ export const fetchLiquidStakingInfo = (info, client) => LiquidStakingInfo.fetch(client, phantom(info.type), info.id);
283
+ export const fetchRegistryLiquidStakingInfoMap = (client) => __awaiter(void 0, void 0, void 0, function* () {
326
284
  const REGISTRY_ID = "0x06d6b6881ef14ad1a8cc29d1f97ba3397ecea56af5afa0642093e981b1fda3f4";
327
285
  const registryObjectIds = [];
328
286
  let cursor = null;
@@ -346,7 +304,7 @@ const fetchRegistryLiquidStakingInfoMap = (client) => __awaiter(void 0, void 0,
346
304
  var _a;
347
305
  const fields = ((_a = obj.data) === null || _a === void 0 ? void 0 : _a.content).fields;
348
306
  const id = fields.value.fields.liquid_staking_info_id;
349
- const coinType = (0, utils_1.normalizeStructTag)(fields.name.fields.name);
307
+ const coinType = normalizeStructTag(fields.name.fields.name);
350
308
  if ([
351
309
  "0x460c669acd3f294dc4247a6877ec2532340ffde76162ab201e72fe95355830e7::asui::ASUI",
352
310
  "0x752f18582da315f9104bb8b7828188c474e64f23255ed9fd231ed3fa883f27e0::tt_sui::TT_SUI",
@@ -365,4 +323,3 @@ const fetchRegistryLiquidStakingInfoMap = (client) => __awaiter(void 0, void 0,
365
323
  }, {});
366
324
  return LIQUID_STAKING_INFO_MAP;
367
325
  });
368
- exports.fetchRegistryLiquidStakingInfoMap = fetchRegistryLiquidStakingInfoMap;
package/sdk/src/index.js CHANGED
@@ -1,18 +1,2 @@
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("./lib"), exports);
18
- __exportStar(require("./client"), exports);
1
+ export * from "./lib";
2
+ export * from "./client";
@@ -1,17 +1 @@
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("./transactions"), exports);
1
+ export * from "./transactions";
@@ -1,7 +1,7 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
2
  import { LstClient } from "../client";
3
3
  export declare const convertLstsAndRebalance: (inLstClient: LstClient, outLstClient: LstClient, transaction: Transaction, address: string, amount: string) => Promise<{
4
- $kind: "NestedResult";
5
4
  NestedResult: [number, number];
5
+ $kind: "NestedResult";
6
6
  }>;
7
7
  export declare const convertLstsAndRebalanceAndSendToUser: (inLstClient: LstClient, outLstClient: LstClient, transaction: Transaction, address: string, amount: string) => Promise<void>;
@@ -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,17 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.convertLstsAndRebalanceAndSendToUser = exports.convertLstsAndRebalance = void 0;
13
- const convertLstsAndRebalance = (inLstClient, outLstClient, transaction, address, amount) => __awaiter(void 0, void 0, void 0, function* () {
10
+ export const convertLstsAndRebalance = (inLstClient, outLstClient, transaction, address, amount) => __awaiter(void 0, void 0, void 0, function* () {
14
11
  const suiCoin = yield inLstClient.redeemAmountAndRebalance(transaction, address, amount, inLstClient.client);
15
12
  const lstCoin = outLstClient.mint(transaction, suiCoin);
16
13
  outLstClient.rebalance(transaction, outLstClient.liquidStakingObject.weightHookId);
17
14
  return lstCoin;
18
15
  });
19
- exports.convertLstsAndRebalance = convertLstsAndRebalance;
20
- const convertLstsAndRebalanceAndSendToUser = (inLstClient, outLstClient, transaction, address, amount) => __awaiter(void 0, void 0, void 0, function* () {
21
- const lstCoin = yield (0, exports.convertLstsAndRebalance)(inLstClient, outLstClient, transaction, address, amount);
16
+ export const convertLstsAndRebalanceAndSendToUser = (inLstClient, outLstClient, transaction, address, amount) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const lstCoin = yield convertLstsAndRebalance(inLstClient, outLstClient, transaction, address, amount);
22
18
  transaction.transferObjects([lstCoin], address);
23
19
  });
24
- exports.convertLstsAndRebalanceAndSendToUser = convertLstsAndRebalanceAndSendToUser;