@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.
- package/_generated/_dependencies/source/0x1/ascii/structs.js +4 -4
- package/_generated/_dependencies/source/0x1/option/structs.js +4 -4
- package/_generated/_dependencies/source/0x1/type-name/structs.js +4 -4
- package/_generated/_dependencies/source/0x2/bag/structs.js +4 -4
- package/_generated/_dependencies/source/0x2/balance/structs.js +3 -3
- package/_generated/_dependencies/source/0x2/object/structs.js +3 -3
- package/_generated/_dependencies/source/0x2/object-table/structs.js +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +3 -3
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +5 -5
- package/_generated/_framework/reified.js +2 -2
- package/_generated/_framework/vector.js +2 -2
- package/_generated/suilend/cell/structs.js +4 -4
- package/_generated/suilend/decimal/structs.js +3 -3
- package/_generated/suilend/lending-market/functions.js +4 -4
- package/_generated/suilend/lending-market/structs.js +11 -11
- package/_generated/suilend/lending-market-registry/functions.js +2 -2
- package/_generated/suilend/liquidity-mining/structs.js +9 -9
- package/_generated/suilend/obligation/structs.js +8 -8
- package/_generated/suilend/rate-limiter/functions.js +2 -2
- package/_generated/suilend/rate-limiter/structs.js +4 -4
- package/_generated/suilend/reserve/structs.js +12 -12
- package/_generated/suilend/reserve-config/functions.js +2 -2
- package/_generated/suilend/reserve-config/structs.js +5 -5
- package/api/index.js +1 -1
- package/client.js +32 -50
- package/index.js +7 -7
- package/lib/index.js +5 -5
- package/lib/initialize.js +8 -8
- package/lib/liquidityMining.js +3 -3
- package/lib/pythAdapter.d.ts +1 -2
- package/lib/pythAdapter.js +96 -17
- package/lib/strategyOwnerCap.js +2 -2
- package/margin/margin/admin_cap.d.ts +1 -4
- package/margin/margin/admin_cap.js +15 -9
- package/margin/margin/deps/std/type_name.d.ts +9 -10
- package/margin/margin/deps/std/type_name.js +17 -14
- package/margin/margin/deps/sui/vec_set.d.ts +3 -5
- package/margin/margin/deps/sui/vec_set.js +9 -6
- package/margin/margin/deps/suilend/lending_market.d.ts +1 -4
- package/margin/margin/deps/suilend/lending_market.js +9 -6
- package/margin/margin/market.d.ts +22 -67
- package/margin/margin/market.js +86 -108
- package/margin/margin/permissions.d.ts +9 -16
- package/margin/margin/permissions.js +29 -29
- package/margin/margin/position.d.ts +12 -35
- package/margin/margin/position.js +84 -67
- package/margin/margin/router.d.ts +10 -50
- package/margin/margin/router.js +102 -71
- package/margin/margin/version.d.ts +1 -4
- package/margin/margin/version.js +7 -4
- package/margin/utils/index.d.ts +9 -9
- package/margin/utils/index.js +32 -29
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +1 -1
- package/parsers/index.js +5 -5
- package/parsers/lendingMarket.js +2 -2
- package/parsers/obligation.js +1 -1
- package/parsers/rateLimiter.js +1 -1
- package/parsers/reserve.js +3 -3
- package/strategies.js +101 -42
- package/swap/index.js +2 -2
- package/swap/transaction.js +5 -14
- package/utils/index.js +3 -3
- package/utils/obligation.js +39 -30
- 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,
|
|
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
|
|
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
|
|
98
|
-
|
|
99
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
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(
|
|
604
|
+
const [redeemCoin] = this.redeem(ctokenCoin, coinType, exemption, transaction);
|
|
623
605
|
transaction.transferObjects([redeemCoin], transaction.pure.address(ownerId));
|
|
624
606
|
}
|
|
625
607
|
});
|