@suilend/sdk 3.0.3 → 3.0.5

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 (68) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.js +4 -4
  2. package/_generated/_dependencies/source/0x1/option/structs.js +4 -4
  3. package/_generated/_dependencies/source/0x1/type-name/structs.js +4 -4
  4. package/_generated/_dependencies/source/0x2/bag/structs.js +4 -4
  5. package/_generated/_dependencies/source/0x2/balance/structs.js +3 -3
  6. package/_generated/_dependencies/source/0x2/object/structs.js +3 -3
  7. package/_generated/_dependencies/source/0x2/object-table/structs.js +4 -4
  8. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +3 -3
  9. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +4 -4
  10. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +5 -5
  11. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +4 -4
  12. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +5 -5
  13. package/_generated/_framework/reified.js +2 -2
  14. package/_generated/_framework/vector.js +2 -2
  15. package/_generated/suilend/cell/structs.js +4 -4
  16. package/_generated/suilend/decimal/structs.js +3 -3
  17. package/_generated/suilend/lending-market/functions.js +4 -4
  18. package/_generated/suilend/lending-market/structs.js +11 -11
  19. package/_generated/suilend/lending-market-registry/functions.js +2 -2
  20. package/_generated/suilend/liquidity-mining/structs.js +9 -9
  21. package/_generated/suilend/obligation/structs.js +8 -8
  22. package/_generated/suilend/rate-limiter/functions.js +2 -2
  23. package/_generated/suilend/rate-limiter/structs.js +4 -4
  24. package/_generated/suilend/reserve/structs.js +12 -12
  25. package/_generated/suilend/reserve-config/functions.js +2 -2
  26. package/_generated/suilend/reserve-config/structs.js +5 -5
  27. package/api/index.js +1 -1
  28. package/client.js +32 -50
  29. package/index.js +7 -7
  30. package/lib/index.js +5 -5
  31. package/lib/initialize.js +8 -8
  32. package/lib/liquidityMining.js +3 -3
  33. package/lib/pythAdapter.d.ts +1 -2
  34. package/lib/pythAdapter.js +96 -17
  35. package/lib/strategyOwnerCap.js +2 -2
  36. package/margin/margin/admin_cap.d.ts +1 -4
  37. package/margin/margin/admin_cap.js +15 -9
  38. package/margin/margin/deps/std/type_name.d.ts +9 -10
  39. package/margin/margin/deps/std/type_name.js +17 -14
  40. package/margin/margin/deps/sui/vec_set.d.ts +3 -5
  41. package/margin/margin/deps/sui/vec_set.js +9 -6
  42. package/margin/margin/deps/suilend/lending_market.d.ts +1 -4
  43. package/margin/margin/deps/suilend/lending_market.js +9 -6
  44. package/margin/margin/market.d.ts +22 -67
  45. package/margin/margin/market.js +86 -108
  46. package/margin/margin/permissions.d.ts +9 -16
  47. package/margin/margin/permissions.js +29 -29
  48. package/margin/margin/position.d.ts +12 -35
  49. package/margin/margin/position.js +84 -67
  50. package/margin/margin/router.d.ts +10 -50
  51. package/margin/margin/router.js +102 -71
  52. package/margin/margin/version.d.ts +1 -4
  53. package/margin/margin/version.js +7 -4
  54. package/margin/utils/index.d.ts +9 -9
  55. package/margin/utils/index.js +32 -29
  56. package/package.json +1 -1
  57. package/parsers/apiReserveAssetDataEvent.js +1 -1
  58. package/parsers/index.js +5 -5
  59. package/parsers/lendingMarket.js +2 -2
  60. package/parsers/obligation.js +1 -1
  61. package/parsers/rateLimiter.js +1 -1
  62. package/parsers/reserve.js +3 -3
  63. package/strategies.js +101 -42
  64. package/swap/index.js +2 -2
  65. package/swap/transaction.js +5 -14
  66. package/utils/index.js +3 -3
  67. package/utils/obligation.js +39 -30
  68. package/utils/simulate.js +4 -4
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../../../_framework/reified";
11
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified";
12
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
- import { PKG_V13 } from "../index";
10
+ import * as reified from "../../../../_framework/reified.js";
11
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified.js";
12
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
13
+ import { PKG_V13 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== Char =============================== */
16
16
  export function isChar(type) {
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../../../_framework/reified";
11
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../../../_framework/reified";
12
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
- import { PKG_V13 } from "../index";
10
+ import * as reified from "../../../../_framework/reified.js";
11
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../../../_framework/reified.js";
12
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
13
+ import { PKG_V13 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== Option =============================== */
16
16
  export function isOption(type) {
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { String } from "../ascii/structs";
13
- import { PKG_V13 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { String } from "../ascii/structs.js";
13
+ import { PKG_V13 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== TypeName =============================== */
16
16
  export function isTypeName(type) {
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V30 } from "../index";
13
- import { UID } from "../object/structs";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V30 } from "../index.js";
13
+ import { UID } from "../object/structs.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== Bag =============================== */
16
16
  export function isBag(type) {
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V30 } from "../index";
10
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V30 } from "../index.js";
13
13
  import { bcs } from "@mysten/sui/bcs";
14
14
  /* ============================== Balance =============================== */
15
15
  export function isBalance(type) {
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V30 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V30 } from "../index.js";
13
13
  import { bcs } from "@mysten/sui/bcs";
14
14
  import { fromHex, toHex } from "@mysten/sui/utils";
15
15
  /* ============================== ID =============================== */
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V30 } from "../index";
13
- import { UID } from "../object/structs";
10
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V30 } from "../index.js";
13
+ import { UID } from "../object/structs.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== ObjectTable =============================== */
16
16
  export function isObjectTable(type) {
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V1 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V1 } from "../index.js";
13
13
  import { bcs } from "@mysten/sui/bcs";
14
14
  /* ============================== I64 =============================== */
15
15
  export function isI64(type) {
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { I64 } from "../i64/structs";
13
- import { PKG_V1 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { I64 } from "../i64/structs.js";
13
+ import { PKG_V1 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== Price =============================== */
16
16
  export function isPrice(type) {
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { PKG_V1 } from "../index";
13
- import { PriceIdentifier } from "../price-identifier/structs";
14
- import { Price } from "../price/structs";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { PKG_V1 } from "../index.js";
13
+ import { PriceIdentifier } from "../price-identifier/structs.js";
14
+ import { Price } from "../price/structs.js";
15
15
  import { bcs } from "@mysten/sui/bcs";
16
16
  /* ============================== PriceFeed =============================== */
17
17
  export function isPriceFeed(type) {
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../../../_framework/reified";
11
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified";
12
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
13
- import { PKG_V1 } from "../index";
10
+ import * as reified from "../../../../_framework/reified.js";
11
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../../../_framework/reified.js";
12
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
13
+ import { PKG_V1 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== PriceIdentifier =============================== */
16
16
  export function isPriceIdentifier(type) {
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../../../_framework/util";
12
- import { UID } from "../../0x2/object/structs";
13
- import { PKG_V1 } from "../index";
14
- import { PriceFeed } from "../price-feed/structs";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../../../_framework/util.js";
12
+ import { UID } from "../../0x2/object/structs.js";
13
+ import { PKG_V1 } from "../index.js";
14
+ import { PriceFeed } from "../price-feed/structs.js";
15
15
  import { bcs } from "@mysten/sui/bcs";
16
16
  /* ============================== PriceInfo =============================== */
17
17
  export function isPriceInfo(type) {
@@ -1,8 +1,8 @@
1
1
  import { bcs } from "@mysten/sui/bcs";
2
2
  import { fromHex, toHex } from "@mysten/sui/utils";
3
- import { compressSuiType, parseTypeName } from "./util";
3
+ import { compressSuiType, parseTypeName } from "./util.js";
4
4
  // for backwards compatibility
5
- export { vector } from "./vector";
5
+ export { vector } from "./vector.js";
6
6
  export function phantom(type) {
7
7
  if (typeof type === "string") {
8
8
  return {
@@ -1,6 +1,6 @@
1
1
  import { bcs } from "@mysten/sui/bcs";
2
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, toBcs, fieldToJSON, } from "./reified";
3
- import { composeSuiType } from "./util";
2
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, toBcs, fieldToJSON, } from "./reified.js";
3
+ import { composeSuiType } from "./util.js";
4
4
  export class Vector {
5
5
  constructor(typeArgs, elements) {
6
6
  this.__VectorClass = true;
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { Option } from "../../_dependencies/source/0x1/option/structs";
11
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../_framework/reified";
12
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
13
- import { PKG_V1 } from "../index";
10
+ import { Option } from "../../_dependencies/source/0x1/option/structs.js";
11
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, toBcs, } from "../../_framework/reified.js";
12
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
13
+ import { PKG_V1 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== Cell =============================== */
16
16
  export function isCell(type) {
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
12
- import { PKG_V1 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
12
+ import { PKG_V1 } from "../index.js";
13
13
  import { bcs } from "@mysten/sui/bcs";
14
14
  /* ============================== Decimal =============================== */
15
15
  export function isDecimal(type) {
@@ -1,7 +1,7 @@
1
- import { PUBLISHED_AT } from "..";
2
- import { ID } from "../../_dependencies/source/0x2/object/structs";
3
- import { obj, option, pure } from "../../_framework/util";
4
- import { RateLimiterExemption } from "./structs";
1
+ import { PUBLISHED_AT } from "../index.js";
2
+ import { ID } from "../../_dependencies/source/0x2/object/structs.js";
3
+ import { obj, option, pure } from "../../_framework/util.js";
4
+ import { RateLimiterExemption } from "./structs.js";
5
5
  export function borrow(tx, typeArgs, args) {
6
6
  return tx.moveCall({
7
7
  target: `${PUBLISHED_AT}::lending_market::borrow`,
@@ -7,17 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../_framework/reified";
11
- import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
12
- import { ObjectTable } from "../../_dependencies/source/0x2/object-table/structs";
13
- import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
14
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified";
15
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
16
- import { Decimal } from "../decimal/structs";
17
- import { PKG_V1, PKG_V10 } from "../index";
18
- import { Obligation } from "../obligation/structs";
19
- import { RateLimiter } from "../rate-limiter/structs";
20
- import { Reserve } from "../reserve/structs";
10
+ import * as reified from "../../_framework/reified.js";
11
+ import { TypeName } from "../../_dependencies/source/0x1/type-name/structs.js";
12
+ import { ObjectTable } from "../../_dependencies/source/0x2/object-table/structs.js";
13
+ import { ID, UID } from "../../_dependencies/source/0x2/object/structs.js";
14
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified.js";
15
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
16
+ import { Decimal } from "../decimal/structs.js";
17
+ import { PKG_V1, PKG_V10 } from "../index.js";
18
+ import { Obligation } from "../obligation/structs.js";
19
+ import { RateLimiter } from "../rate-limiter/structs.js";
20
+ import { Reserve } from "../reserve/structs.js";
21
21
  import { bcs } from "@mysten/sui/bcs";
22
22
  import { fromHex, toHex } from "@mysten/sui/utils";
23
23
  /* ============================== MintEvent =============================== */
@@ -1,5 +1,5 @@
1
- import { PUBLISHED_AT } from "..";
2
- import { obj } from "../../_framework/util";
1
+ import { PUBLISHED_AT } from "../index.js";
2
+ import { obj } from "../../_framework/util.js";
3
3
  export function init(tx) {
4
4
  return tx.moveCall({
5
5
  target: `${PUBLISHED_AT}::lending_market_registry::init`,
@@ -7,15 +7,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../_framework/reified";
11
- import { Option } from "../../_dependencies/source/0x1/option/structs";
12
- import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
13
- import { Bag } from "../../_dependencies/source/0x2/bag/structs";
14
- import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
15
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified";
16
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
17
- import { Decimal } from "../decimal/structs";
18
- import { PKG_V1 } from "../index";
10
+ import * as reified from "../../_framework/reified.js";
11
+ import { Option } from "../../_dependencies/source/0x1/option/structs.js";
12
+ import { TypeName } from "../../_dependencies/source/0x1/type-name/structs.js";
13
+ import { Bag } from "../../_dependencies/source/0x2/bag/structs.js";
14
+ import { ID, UID } from "../../_dependencies/source/0x2/object/structs.js";
15
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified.js";
16
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
17
+ import { Decimal } from "../decimal/structs.js";
18
+ import { PKG_V1 } from "../index.js";
19
19
  import { bcs } from "@mysten/sui/bcs";
20
20
  /* ============================== PoolReward =============================== */
21
21
  export function isPoolReward(type) {
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../_framework/reified";
11
- import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
12
- import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
13
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified";
14
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
15
- import { Decimal } from "../decimal/structs";
16
- import { PKG_V1, PKG_V11 } from "../index";
17
- import { UserRewardManager } from "../liquidity-mining/structs";
10
+ import * as reified from "../../_framework/reified.js";
11
+ import { TypeName } from "../../_dependencies/source/0x1/type-name/structs.js";
12
+ import { ID, UID } from "../../_dependencies/source/0x2/object/structs.js";
13
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, fieldToJSON, phantom, } from "../../_framework/reified.js";
14
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
15
+ import { Decimal } from "../decimal/structs.js";
16
+ import { PKG_V1, PKG_V11 } from "../index.js";
17
+ import { UserRewardManager } from "../liquidity-mining/structs.js";
18
18
  import { bcs } from "@mysten/sui/bcs";
19
19
  import { fromHex, toHex } from "@mysten/sui/utils";
20
20
  /* ============================== Borrow =============================== */
@@ -1,5 +1,5 @@
1
- import { PUBLISHED_AT } from "..";
2
- import { obj, pure } from "../../_framework/util";
1
+ import { PUBLISHED_AT } from "../index.js";
2
+ import { obj, pure } from "../../_framework/util.js";
3
3
  export function new_(tx, args) {
4
4
  return tx.moveCall({
5
5
  target: `${PUBLISHED_AT}::rate_limiter::new`,
@@ -7,10 +7,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified";
11
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
12
- import { Decimal } from "../decimal/structs";
13
- import { PKG_V1 } from "../index";
10
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, phantom, } from "../../_framework/reified.js";
11
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
12
+ import { Decimal } from "../decimal/structs.js";
13
+ import { PKG_V1 } from "../index.js";
14
14
  import { bcs } from "@mysten/sui/bcs";
15
15
  /* ============================== RateLimiter =============================== */
16
16
  export function isRateLimiter(type) {
@@ -7,18 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../_framework/reified";
11
- import { TypeName } from "../../_dependencies/source/0x1/type-name/structs";
12
- import { Balance, Supply, } from "../../_dependencies/source/0x2/balance/structs";
13
- import { ID, UID } from "../../_dependencies/source/0x2/object/structs";
14
- import { PriceIdentifier } from "../../_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs";
15
- import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../_framework/reified";
16
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
17
- import { Cell } from "../cell/structs";
18
- import { Decimal } from "../decimal/structs";
19
- import { PKG_V1, PKG_V8 } from "../index";
20
- import { PoolRewardManager } from "../liquidity-mining/structs";
21
- import { ReserveConfig } from "../reserve-config/structs";
10
+ import * as reified from "../../_framework/reified.js";
11
+ import { TypeName } from "../../_dependencies/source/0x1/type-name/structs.js";
12
+ import { Balance, Supply, } from "../../_dependencies/source/0x2/balance/structs.js";
13
+ import { ID, UID } from "../../_dependencies/source/0x2/object/structs.js";
14
+ import { PriceIdentifier } from "../../_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js";
15
+ import { assertFieldsWithTypesArgsMatch, assertReifiedTypeArgsMatch, decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, extractType, phantom, } from "../../_framework/reified.js";
16
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
17
+ import { Cell } from "../cell/structs.js";
18
+ import { Decimal } from "../decimal/structs.js";
19
+ import { PKG_V1, PKG_V8 } from "../index.js";
20
+ import { PoolRewardManager } from "../liquidity-mining/structs.js";
21
+ import { ReserveConfig } from "../reserve-config/structs.js";
22
22
  import { bcs } from "@mysten/sui/bcs";
23
23
  import { fromHex, toHex } from "@mysten/sui/utils";
24
24
  /* ============================== BalanceKey =============================== */
@@ -1,5 +1,5 @@
1
- import { PUBLISHED_AT } from "..";
2
- import { generic, obj, pure } from "../../_framework/util";
1
+ import { PUBLISHED_AT } from "../index.js";
2
+ import { generic, obj, pure } from "../../_framework/util.js";
3
3
  export function set(tx, typeArgs, args) {
4
4
  return tx.moveCall({
5
5
  target: `${PUBLISHED_AT}::reserve_config::set`,
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import * as reified from "../../_framework/reified";
11
- import { Bag } from "../../_dependencies/source/0x2/bag/structs";
12
- import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../_framework/reified";
13
- import { composeSuiType, compressSuiType, } from "../../_framework/util";
14
- import { PKG_V1 } from "../index";
10
+ import * as reified from "../../_framework/reified.js";
11
+ import { Bag } from "../../_dependencies/source/0x2/bag/structs.js";
12
+ import { decodeFromFields, decodeFromFieldsWithTypes, decodeFromJSONField, fieldToJSON, phantom, } from "../../_framework/reified.js";
13
+ import { composeSuiType, compressSuiType, } from "../../_framework/util.js";
14
+ import { PKG_V1 } from "../index.js";
15
15
  import { bcs } from "@mysten/sui/bcs";
16
16
  /* ============================== ReserveConfig =============================== */
17
17
  export function isReserveConfig(type) {
package/api/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./events";
1
+ export * from "./events.js";
package/client.js CHANGED
@@ -9,20 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_ID, normalizeStructTag, toHex, } from "@mysten/sui/utils";
11
11
  import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
12
- import { extractCTokenCoinType, getAllCoins, mergeAllCoins, } from "@suilend/sui-fe";
13
- import { PriceInfoObject } from "./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs";
14
- import { phantom } from "./_generated/_framework/reified";
15
- import { PKG_V10, setPublishedAt } from "./_generated/suilend";
16
- import { PACKAGE_ID, PUBLISHED_AT } from "./_generated/suilend";
17
- import { addPoolReward, addReserve, addReserveV2, borrowRequest, cancelPoolReward, changeReservePriceFeed, claimFees, claimRewards, claimRewardsAndDeposit, closePoolReward, depositCtokensIntoObligation, depositLiquidityAndMintCtokens, fulfillLiquidityRequest, liquidate, migrate, newObligationOwnerCap, rebalanceStaker, redeemCtokensAndWithdrawLiquidityRequest, refreshReservePrice, repay, setFeeReceivers, unstakeSuiFromStaker, updateRateLimiterConfig, updateReserveConfig, withdrawCtokens, } from "./_generated/suilend/lending-market/functions";
18
- import { LendingMarket, ObligationOwnerCap, } from "./_generated/suilend/lending-market/structs";
19
- import { createLendingMarket } from "./_generated/suilend/lending-market-registry/functions";
20
- import { Obligation } from "./_generated/suilend/obligation/structs";
21
- import { newConfig as createRateLimiterConfig, } from "./_generated/suilend/rate-limiter/functions";
22
- import { createReserveConfig, } from "./_generated/suilend/reserve-config/functions";
23
- import { PRIMARY_PYTH_ENDPOINT } from "./lib/pyth";
24
- import { createJsonRpcAdapter } from "./lib/pythAdapter";
25
- import { Side } from "./lib/types";
12
+ import { extractCTokenCoinType, getAllCoins, getSpendableCoin, } from "@suilend/sui-fe";
13
+ import { PriceInfoObject } from "./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js";
14
+ import { phantom } from "./_generated/_framework/reified.js";
15
+ import { PKG_V10, setPublishedAt } from "./_generated/suilend/index.js";
16
+ import { PACKAGE_ID, PUBLISHED_AT } from "./_generated/suilend/index.js";
17
+ import { addPoolReward, addReserve, addReserveV2, borrowRequest, cancelPoolReward, changeReservePriceFeed, claimFees, claimRewards, claimRewardsAndDeposit, closePoolReward, depositCtokensIntoObligation, depositLiquidityAndMintCtokens, fulfillLiquidityRequest, liquidate, migrate, newObligationOwnerCap, rebalanceStaker, redeemCtokensAndWithdrawLiquidityRequest, refreshReservePrice, repay, setFeeReceivers, unstakeSuiFromStaker, updateRateLimiterConfig, updateReserveConfig, withdrawCtokens, } from "./_generated/suilend/lending-market/functions.js";
18
+ import { LendingMarket, ObligationOwnerCap, } from "./_generated/suilend/lending-market/structs.js";
19
+ import { createLendingMarket } from "./_generated/suilend/lending-market-registry/functions.js";
20
+ import { Obligation } from "./_generated/suilend/obligation/structs.js";
21
+ import { newConfig as createRateLimiterConfig, } from "./_generated/suilend/rate-limiter/functions.js";
22
+ import { createReserveConfig, } from "./_generated/suilend/reserve-config/functions.js";
23
+ import { PRIMARY_PYTH_ENDPOINT } from "./lib/pyth.js";
24
+ import { createJsonRpcAdapter } from "./lib/pythAdapter.js";
25
+ import { Side } from "./lib/types.js";
26
26
  const SUI_COINTYPE = "0x2::sui::SUI";
27
27
  const NORMALIZED_SUI_COINTYPE = normalizeStructTag(SUI_COINTYPE);
28
28
  const isSui = (coinType) => normalizeStructTag(coinType) === NORMALIZED_SUI_COINTYPE;
@@ -86,7 +86,7 @@ export class SuilendClient {
86
86
  }
87
87
  static getFeeReceivers(suiGrpcClient, lendingMarketId) {
88
88
  return __awaiter(this, void 0, void 0, function* () {
89
- var _a, _b, _c, _d;
89
+ var _a, _b;
90
90
  const { dynamicField } = yield suiGrpcClient.getDynamicField({
91
91
  parentId: lendingMarketId,
92
92
  name: {
@@ -94,9 +94,13 @@ export class SuilendClient {
94
94
  bcs: new Uint8Array([0]),
95
95
  },
96
96
  });
97
- const value = dynamicField.value;
98
- const receivers = (_b = (_a = value.json) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.receivers;
99
- const weights = (_d = (_c = value.json) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.weights;
97
+ const { object } = yield suiGrpcClient.getObject({
98
+ objectId: dynamicField.fieldId,
99
+ include: { json: true },
100
+ });
101
+ const json = object.json;
102
+ const receivers = (_a = json === null || json === void 0 ? void 0 : json.value) === null || _a === void 0 ? void 0 : _a.receivers;
103
+ const weights = (_b = json === null || json === void 0 ? void 0 : json.value) === null || _b === void 0 ? void 0 : _b.weights;
100
104
  return { receivers, weights };
101
105
  });
102
106
  }
@@ -104,7 +108,7 @@ export class SuilendClient {
104
108
  const [ownerCap, lendingMarket] = createLendingMarket(transaction, lendingMarketType, transaction.object(registryId));
105
109
  transaction.moveCall({
106
110
  target: `0x2::transfer::public_share_object`,
107
- typeArguments: [`${LendingMarket.$typeName}<${lendingMarketType}>}`],
111
+ typeArguments: [`${LendingMarket.$typeName}<${lendingMarketType}>`],
108
112
  arguments: [lendingMarket],
109
113
  });
110
114
  return ownerCap;
@@ -188,16 +192,7 @@ export class SuilendClient {
188
192
  }
189
193
  addReward(ownerId_1, lendingMarketOwnerCapId_1, reserveArrayIndex_1, isDepositReward_1, rewardCoinType_1, rewardValue_1, startTimeMs_1, endTimeMs_1, transaction_1) {
190
194
  return __awaiter(this, arguments, void 0, function* (ownerId, lendingMarketOwnerCapId, reserveArrayIndex, isDepositReward, rewardCoinType, rewardValue, startTimeMs, endTimeMs, transaction, mergeCoins = true) {
191
- const coins = (yield this.suiGrpcClient.listCoins({
192
- owner: ownerId,
193
- coinType: rewardCoinType,
194
- })).objects;
195
- if (coins.length > 1 && !isSui(rewardCoinType) && mergeCoins) {
196
- transaction.mergeCoins(transaction.object(coins[0].objectId), coins.map((c) => transaction.object(c.objectId)).slice(1));
197
- }
198
- const [rewardCoin] = transaction.splitCoins(isSui(rewardCoinType)
199
- ? transaction.gas
200
- : transaction.object(coins[0].objectId), [rewardValue]);
195
+ const rewardCoin = yield getSpendableCoin(this.suiGrpcClient, ownerId, rewardCoinType, rewardValue, transaction, mergeCoins);
201
196
  return addPoolReward(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
202
197
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
203
198
  lendingMarket: transaction.object(this.lendingMarket.id),
@@ -421,21 +416,13 @@ export class SuilendClient {
421
416
  }
422
417
  depositIntoObligation(ownerId, coinType, value, transaction, obligationOwnerCap) {
423
418
  return __awaiter(this, void 0, void 0, function* () {
424
- const coins = yield getAllCoins(this.suiGrpcClient, ownerId, coinType);
425
- const mergeCoin = mergeAllCoins(coinType, transaction, coins);
426
- const [sendCoin] = transaction.splitCoins(isSui(coinType)
427
- ? transaction.gas
428
- : transaction.object(mergeCoin.objectId), [value]);
419
+ const sendCoin = yield getSpendableCoin(this.suiGrpcClient, ownerId, coinType, value, transaction);
429
420
  this.deposit(sendCoin, coinType, obligationOwnerCap, transaction);
430
421
  });
431
422
  }
432
423
  depositLiquidityAndGetCTokens(ownerId, coinType, value, transaction) {
433
424
  return __awaiter(this, void 0, void 0, function* () {
434
- const coins = yield getAllCoins(this.suiGrpcClient, ownerId, coinType);
435
- const mergeCoin = mergeAllCoins(coinType, transaction, coins);
436
- const [sendCoin] = transaction.splitCoins(isSui(coinType)
437
- ? transaction.gas
438
- : transaction.object(mergeCoin.objectId), [value]);
425
+ const sendCoin = yield getSpendableCoin(this.suiGrpcClient, ownerId, coinType, value, transaction);
439
426
  const [ctokens] = depositLiquidityAndMintCtokens(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
440
427
  lendingMarket: transaction.object(this.lendingMarket.id),
441
428
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
@@ -545,11 +532,7 @@ export class SuilendClient {
545
532
  }
546
533
  repayIntoObligation(ownerId, obligationId, coinType, value, transaction) {
547
534
  return __awaiter(this, void 0, void 0, function* () {
548
- const coins = yield getAllCoins(this.suiGrpcClient, ownerId, coinType);
549
- const mergeCoin = mergeAllCoins(coinType, transaction, coins);
550
- const [sendCoin] = transaction.splitCoins(isSui(coinType)
551
- ? transaction.gas
552
- : transaction.object(mergeCoin.objectId), [value]);
535
+ const sendCoin = yield getSpendableCoin(this.suiGrpcClient, ownerId, coinType, value, transaction);
553
536
  const result = this.repay(obligationId, coinType, sendCoin, transaction);
554
537
  transaction.transferObjects([sendCoin], transaction.pure.address(ownerId));
555
538
  return result;
@@ -604,13 +587,12 @@ export class SuilendClient {
604
587
  }
605
588
  redeemCtokensAndWithdrawLiquidity(ownerId, ctokenCoinTypes, transaction) {
606
589
  return __awaiter(this, void 0, void 0, function* () {
607
- const mergeCoinMap = {};
608
590
  for (const ctokenCoinType of ctokenCoinTypes) {
609
591
  const coins = yield getAllCoins(this.suiGrpcClient, ownerId, ctokenCoinType);
610
- const mergeCoin = mergeAllCoins(ctokenCoinType, transaction, coins);
611
- mergeCoinMap[ctokenCoinType] = mergeCoin;
612
- }
613
- for (const [ctokenCoinType, mergeCoin] of Object.entries(mergeCoinMap)) {
592
+ const totalBalance = coins.reduce((sum, c) => sum + BigInt(c.balance), BigInt(0));
593
+ if (totalBalance === BigInt(0))
594
+ throw new Error(`No ${ctokenCoinType} coins found for redeem`);
595
+ const ctokenCoin = yield getSpendableCoin(this.suiGrpcClient, ownerId, ctokenCoinType, totalBalance.toString(), transaction);
614
596
  const coinType = extractCTokenCoinType(ctokenCoinType);
615
597
  const [exemption] = transaction.moveCall({
616
598
  target: `0x1::option::none`,
@@ -619,7 +601,7 @@ export class SuilendClient {
619
601
  ],
620
602
  arguments: [],
621
603
  });
622
- const [redeemCoin] = this.redeem(transaction.object(mergeCoin.objectId), coinType, exemption, transaction);
604
+ const [redeemCoin] = this.redeem(ctokenCoin, coinType, exemption, transaction);
623
605
  transaction.transferObjects([redeemCoin], transaction.pure.address(ownerId));
624
606
  }
625
607
  });