@suilend/sdk 2.0.4 → 3.0.2
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.d.ts +7 -11
- package/_generated/_dependencies/source/0x1/ascii/structs.js +6 -63
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -9
- package/_generated/_dependencies/source/0x1/option/structs.js +4 -42
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -7
- package/_generated/_dependencies/source/0x1/type-name/structs.js +3 -32
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -9
- package/_generated/_dependencies/source/0x2/bag/structs.js +3 -31
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -11
- package/_generated/_dependencies/source/0x2/balance/structs.js +7 -82
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -12
- package/_generated/_dependencies/source/0x2/object/structs.js +7 -61
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -9
- package/_generated/_dependencies/source/0x2/object-table/structs.js +4 -44
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +3 -31
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -13
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +3 -32
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -25
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +3 -32
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -6
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +3 -33
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +6 -64
- package/_generated/_framework/reified.d.ts +2 -4
- package/_generated/_framework/vector.d.ts +2 -12
- package/_generated/suilend/cell/structs.d.ts +4 -10
- package/_generated/suilend/cell/structs.js +4 -42
- package/_generated/suilend/decimal/structs.d.ts +4 -6
- package/_generated/suilend/decimal/structs.js +3 -32
- package/_generated/suilend/lending-market/structs.d.ts +152 -392
- package/_generated/suilend/lending-market/structs.js +50 -548
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -158
- package/_generated/suilend/liquidity-mining/structs.js +16 -169
- package/_generated/suilend/obligation/structs.d.ts +108 -148
- package/_generated/suilend/obligation/structs.js +23 -232
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -19
- package/_generated/suilend/rate-limiter/structs.js +6 -64
- package/_generated/suilend/reserve/structs.d.ts +138 -362
- package/_generated/suilend/reserve/structs.js +29 -327
- package/_generated/suilend/reserve-config/structs.d.ts +33 -37
- package/_generated/suilend/reserve-config/structs.js +6 -65
- package/client.d.ts +8 -8
- package/client.js +55 -88
- package/lib/initialize.d.ts +29 -28
- package/lib/initialize.js +20 -16
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/pythAdapter.d.ts +9 -0
- package/lib/pythAdapter.js +120 -0
- package/lib/strategyOwnerCap.d.ts +12 -7
- package/lib/strategyOwnerCap.js +159 -156
- package/margin/margin/admin_cap.d.ts +2 -2
- package/margin/margin/deps/std/type_name.d.ts +1 -1
- package/margin/margin/deps/sui/vec_set.d.ts +3 -5
- package/margin/margin/deps/suilend/lending_market.d.ts +2 -2
- package/margin/margin/market.d.ts +21 -38
- package/margin/margin/position.d.ts +47 -47
- package/margin/margin/router.d.ts +5 -5
- package/margin/margin/version.d.ts +1 -1
- package/package.json +1 -1
- package/parsers/lendingMarket.d.ts +6 -6
- package/parsers/obligation.d.ts +8 -8
- package/parsers/reserve.d.ts +8 -8
- package/strategies.d.ts +38 -21
- package/strategies.js +239 -79
- package/swap/quote.d.ts +1 -9
- package/swap/quote.js +1 -52
- package/swap/transaction.d.ts +2 -4
- package/swap/transaction.js +9 -25
- package/utils/events.d.ts +6 -5
- package/utils/events.js +11 -8
- package/utils/obligation.d.ts +6 -5
- package/utils/obligation.js +118 -117
package/swap/quote.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import { QuoteResponse as Bluefin7kQuote } from "@bluefin-exchange/bluefin7k-aggregator-sdk
|
|
1
|
+
import { QuoteResponse as Bluefin7kQuote } from "@bluefin-exchange/bluefin7k-aggregator-sdk";
|
|
2
2
|
import { RouterDataV3 as CetusQuote, AggregatorClient as CetusSdk } from "@cetusprotocol/aggregator-sdk";
|
|
3
3
|
import { AggregatorQuoter as FlowXAggregatorQuoter, GetRoutesResult as FlowXGetRoutesResult } from "@flowx-finance/sdk";
|
|
4
|
-
import { RouterCompleteTradeRoute as AftermathQuote, Aftermath as AftermathSdk } from "aftermath-ts-sdk";
|
|
5
4
|
import BigNumber from "bignumber.js";
|
|
6
5
|
import { Token } from "@suilend/sui-fe";
|
|
7
6
|
export declare enum QuoteProvider {
|
|
8
|
-
AFTERMATH = "aftermath",
|
|
9
7
|
CETUS = "cetus",
|
|
10
8
|
BLUEFIN7K = "bluefin7k",
|
|
11
9
|
FLOWX = "flowx"
|
|
12
10
|
}
|
|
13
11
|
export declare const QUOTE_PROVIDER_NAME_MAP: {
|
|
14
|
-
aftermath: string;
|
|
15
12
|
cetus: string;
|
|
16
13
|
bluefin7k: string;
|
|
17
14
|
flowx: string;
|
|
@@ -53,9 +50,6 @@ export type StandardizedQuote = {
|
|
|
53
50
|
path: StandardizedRoutePath[];
|
|
54
51
|
}[];
|
|
55
52
|
} & ({
|
|
56
|
-
provider: QuoteProvider.AFTERMATH;
|
|
57
|
-
quote: AftermathQuote;
|
|
58
|
-
} | {
|
|
59
53
|
provider: QuoteProvider.CETUS;
|
|
60
54
|
quote: CetusQuote;
|
|
61
55
|
} | {
|
|
@@ -66,12 +60,10 @@ export type StandardizedQuote = {
|
|
|
66
60
|
quote: FlowXGetRoutesResult<any, any>;
|
|
67
61
|
});
|
|
68
62
|
export declare const getAggQuotes: (sdkMap: {
|
|
69
|
-
[QuoteProvider.AFTERMATH]: AftermathSdk;
|
|
70
63
|
[QuoteProvider.CETUS]: CetusSdk;
|
|
71
64
|
[QuoteProvider.FLOWX]: FlowXAggregatorQuoter;
|
|
72
65
|
}, activeProviders: QuoteProvider[], onGetAggQuote: (quote: StandardizedQuote | null) => void, tokenIn: Token, tokenOut: Token, amountIn: string) => Promise<void>;
|
|
73
66
|
export declare const getAggSortedQuotesAll: (sdkMap: {
|
|
74
|
-
[QuoteProvider.AFTERMATH]: AftermathSdk;
|
|
75
67
|
[QuoteProvider.CETUS]: CetusSdk;
|
|
76
68
|
[QuoteProvider.FLOWX]: FlowXAggregatorQuoter;
|
|
77
69
|
}, activeProviders: QuoteProvider[], tokenIn: Token, tokenOut: Token, amountIn: string) => Promise<StandardizedQuote[]>;
|
package/swap/quote.js
CHANGED
|
@@ -7,21 +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 { getQuote as getBluefin7kQuoteOriginal, } from "@bluefin-exchange/bluefin7k-aggregator-sdk
|
|
10
|
+
import { getQuote as getBluefin7kQuoteOriginal, } from "@bluefin-exchange/bluefin7k-aggregator-sdk";
|
|
11
11
|
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
12
12
|
import BigNumber from "bignumber.js";
|
|
13
13
|
import BN from "bn.js";
|
|
14
14
|
import { v4 as uuidv4 } from "uuid";
|
|
15
|
-
import { WAD } from "../lib";
|
|
16
15
|
export var QuoteProvider;
|
|
17
16
|
(function (QuoteProvider) {
|
|
18
|
-
QuoteProvider["AFTERMATH"] = "aftermath";
|
|
19
17
|
QuoteProvider["CETUS"] = "cetus";
|
|
20
18
|
QuoteProvider["BLUEFIN7K"] = "bluefin7k";
|
|
21
19
|
QuoteProvider["FLOWX"] = "flowx";
|
|
22
20
|
})(QuoteProvider || (QuoteProvider = {}));
|
|
23
21
|
export const QUOTE_PROVIDER_NAME_MAP = {
|
|
24
|
-
[QuoteProvider.AFTERMATH]: "Aftermath",
|
|
25
22
|
[QuoteProvider.CETUS]: "Cetus",
|
|
26
23
|
[QuoteProvider.BLUEFIN7K]: "Bluefin7k",
|
|
27
24
|
[QuoteProvider.FLOWX]: "FlowX",
|
|
@@ -52,44 +49,6 @@ const getAggQuoteWrapper = (provider, getAggQuote, timeoutMs) => __awaiter(void
|
|
|
52
49
|
return null;
|
|
53
50
|
}
|
|
54
51
|
});
|
|
55
|
-
const getAftermathQuote = (sdk, tokenIn, tokenOut, amountIn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
const quote = yield sdk.Router().getCompleteTradeRouteGivenAmountIn({
|
|
57
|
-
coinInType: tokenIn.coinType,
|
|
58
|
-
coinOutType: tokenOut.coinType,
|
|
59
|
-
coinInAmount: BigInt(amountIn),
|
|
60
|
-
});
|
|
61
|
-
const standardizedQuote = {
|
|
62
|
-
id: uuidv4(),
|
|
63
|
-
provider: QuoteProvider.AFTERMATH,
|
|
64
|
-
in: {
|
|
65
|
-
coinType: tokenIn.coinType,
|
|
66
|
-
amount: new BigNumber(quote.coinIn.amount.toString()).div(10 ** tokenIn.decimals),
|
|
67
|
-
},
|
|
68
|
-
out: {
|
|
69
|
-
coinType: tokenOut.coinType,
|
|
70
|
-
amount: new BigNumber(quote.coinOut.amount.toString()).div(10 ** tokenOut.decimals),
|
|
71
|
-
},
|
|
72
|
-
routes: quote.routes.map((route, routeIndex) => ({
|
|
73
|
-
percent: new BigNumber(route.portion.toString()).div(WAD).times(100),
|
|
74
|
-
path: route.paths.map((path) => ({
|
|
75
|
-
id: uuidv4(),
|
|
76
|
-
poolId: path.poolId,
|
|
77
|
-
routeIndex,
|
|
78
|
-
provider: path.protocolName,
|
|
79
|
-
in: {
|
|
80
|
-
coinType: normalizeStructTag(path.coinIn.type),
|
|
81
|
-
amount: new BigNumber(path.coinIn.amount.toString()),
|
|
82
|
-
},
|
|
83
|
-
out: {
|
|
84
|
-
coinType: normalizeStructTag(path.coinOut.type),
|
|
85
|
-
amount: new BigNumber(path.coinOut.amount.toString()),
|
|
86
|
-
},
|
|
87
|
-
})),
|
|
88
|
-
})),
|
|
89
|
-
quote,
|
|
90
|
-
};
|
|
91
|
-
return standardizedQuote;
|
|
92
|
-
});
|
|
93
52
|
const getCetusQuote = (sdk, tokenIn, tokenOut, amountIn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
53
|
const quote = yield sdk.findRouters({
|
|
95
54
|
from: tokenIn.coinType,
|
|
@@ -248,13 +207,6 @@ const getFlowXQuote = (sdk, tokenIn, tokenOut, amountIn) => __awaiter(void 0, vo
|
|
|
248
207
|
export const getAggQuotes = (sdkMap, activeProviders, onGetAggQuote, tokenIn, tokenOut, amountIn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
208
|
const timeoutMs = 15000;
|
|
250
209
|
// Get quotes in parallel
|
|
251
|
-
// Aftermath
|
|
252
|
-
if (activeProviders.includes(QuoteProvider.AFTERMATH)) {
|
|
253
|
-
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
254
|
-
const standardizedQuote = yield getAggQuoteWrapper(QuoteProvider.AFTERMATH, () => getAftermathQuote(sdkMap[QuoteProvider.AFTERMATH], tokenIn, tokenOut, amountIn), timeoutMs);
|
|
255
|
-
onGetAggQuote(standardizedQuote);
|
|
256
|
-
}))();
|
|
257
|
-
}
|
|
258
210
|
// Cetus
|
|
259
211
|
if (activeProviders.includes(QuoteProvider.CETUS)) {
|
|
260
212
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -281,9 +233,6 @@ export const getAggSortedQuotesAll = (sdkMap, activeProviders, tokenIn, tokenOut
|
|
|
281
233
|
const timeoutMs = 1500;
|
|
282
234
|
// Get quotes in parallel
|
|
283
235
|
const quotes = yield Promise.all([
|
|
284
|
-
activeProviders.includes(QuoteProvider.AFTERMATH)
|
|
285
|
-
? getAggQuoteWrapper(QuoteProvider.AFTERMATH, () => getAftermathQuote(sdkMap[QuoteProvider.AFTERMATH], tokenIn, tokenOut, amountIn), timeoutMs)
|
|
286
|
-
: null,
|
|
287
236
|
activeProviders.includes(QuoteProvider.CETUS)
|
|
288
237
|
? getAggQuoteWrapper(QuoteProvider.CETUS, () => getCetusQuote(sdkMap[QuoteProvider.CETUS], tokenIn, tokenOut, amountIn), timeoutMs)
|
|
289
238
|
: null,
|
package/swap/transaction.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AggregatorClient as CetusSdk } from "@cetusprotocol/aggregator-sdk";
|
|
2
2
|
import { AggregatorQuoter as FlowXAggregatorQuoter } from "@flowx-finance/sdk";
|
|
3
|
-
import {
|
|
3
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
4
4
|
import { Transaction, TransactionObjectArgument } from "@mysten/sui/transactions";
|
|
5
|
-
import { Aftermath as AftermathSdk } from "aftermath-ts-sdk";
|
|
6
5
|
import { QuoteProvider, StandardizedQuote } from "./quote";
|
|
7
|
-
export declare const getSwapTransaction: (
|
|
8
|
-
[QuoteProvider.AFTERMATH]: AftermathSdk;
|
|
6
|
+
export declare const getSwapTransaction: (suiGrpcClient: SuiGrpcClient, address: string, quote: StandardizedQuote, slippagePercent: number, sdkMap: {
|
|
9
7
|
[QuoteProvider.CETUS]: CetusSdk;
|
|
10
8
|
[QuoteProvider.FLOWX]: FlowXAggregatorQuoter;
|
|
11
9
|
}, partnerIdMap: {
|
package/swap/transaction.js
CHANGED
|
@@ -7,9 +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 { BluefinXTx, buildTx as buildBluefin7kTransaction, } from "@bluefin-exchange/bluefin7k-aggregator-sdk
|
|
10
|
+
import { BluefinXTx, buildTx as buildBluefin7kTransaction, } from "@bluefin-exchange/bluefin7k-aggregator-sdk";
|
|
11
11
|
import { Coin as FlowXCoin, Commission as FlowXCommission, CommissionType as FlowXCommissionType, TradeBuilder as FlowXTradeBuilder, } from "@flowx-finance/sdk";
|
|
12
12
|
import { getAllCoins, isSui, mergeAllCoins } from "@suilend/sui-fe";
|
|
13
|
+
import { createJsonRpcAdapter } from "../lib/pythAdapter";
|
|
13
14
|
import { QuoteProvider } from "./quote";
|
|
14
15
|
const getSwapTransactionWrapper = (provider, getSwapTransaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
16
|
console.log(`[getSwapTransactionWrapper] fetching transaction for ${provider} quote`);
|
|
@@ -23,32 +24,15 @@ const getSwapTransactionWrapper = (provider, getSwapTransaction) => __awaiter(vo
|
|
|
23
24
|
throw err;
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
|
-
export const getSwapTransaction = (
|
|
27
|
-
if (quote.provider === QuoteProvider.
|
|
28
|
-
return getSwapTransactionWrapper(QuoteProvider.AFTERMATH, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
-
const { tx: transaction2, coinOutId: coinOut } = yield sdkMap[QuoteProvider.AFTERMATH]
|
|
30
|
-
.Router()
|
|
31
|
-
.addTransactionForCompleteTradeRoute({
|
|
32
|
-
tx: transaction,
|
|
33
|
-
walletAddress: address,
|
|
34
|
-
completeRoute: quote.quote,
|
|
35
|
-
slippage: slippagePercent / 100,
|
|
36
|
-
coinInId: coinIn,
|
|
37
|
-
});
|
|
38
|
-
return {
|
|
39
|
-
transaction: transaction2,
|
|
40
|
-
coinOut: coinOut,
|
|
41
|
-
};
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
else if (quote.provider === QuoteProvider.CETUS) {
|
|
27
|
+
export const getSwapTransaction = (suiGrpcClient, address, quote, slippagePercent, sdkMap, partnerIdMap, transaction, coinIn) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
if (quote.provider === QuoteProvider.CETUS) {
|
|
45
29
|
return getSwapTransactionWrapper(QuoteProvider.CETUS, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
30
|
if (!coinIn) {
|
|
47
|
-
const allCoinsIn = yield getAllCoins(
|
|
31
|
+
const allCoinsIn = yield getAllCoins(suiGrpcClient, address, quote.in.coinType);
|
|
48
32
|
const mergeCoinIn = mergeAllCoins(quote.in.coinType, transaction, allCoinsIn);
|
|
49
33
|
[coinIn] = transaction.splitCoins(isSui(quote.in.coinType)
|
|
50
34
|
? transaction.gas
|
|
51
|
-
: transaction.object(mergeCoinIn.
|
|
35
|
+
: transaction.object(mergeCoinIn.objectId), [BigInt(quote.quote.amountIn.toString())]);
|
|
52
36
|
}
|
|
53
37
|
const coinOut = yield sdkMap[QuoteProvider.CETUS].routerSwap({
|
|
54
38
|
router: quote.quote,
|
|
@@ -93,11 +77,11 @@ export const getSwapTransaction = (suiClient, address, quote, slippagePercent, s
|
|
|
93
77
|
else if (quote.provider === QuoteProvider.FLOWX) {
|
|
94
78
|
return getSwapTransactionWrapper(QuoteProvider.FLOWX, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
79
|
if (!coinIn) {
|
|
96
|
-
const allCoinsIn = yield getAllCoins(
|
|
80
|
+
const allCoinsIn = yield getAllCoins(suiGrpcClient, address, quote.in.coinType);
|
|
97
81
|
const mergeCoinIn = mergeAllCoins(quote.in.coinType, transaction, allCoinsIn);
|
|
98
82
|
[coinIn] = transaction.splitCoins(isSui(quote.in.coinType)
|
|
99
83
|
? transaction.gas
|
|
100
|
-
: transaction.object(mergeCoinIn.
|
|
84
|
+
: transaction.object(mergeCoinIn.objectId), [BigInt(quote.quote.amountIn.toString())]);
|
|
101
85
|
}
|
|
102
86
|
const trade = new FlowXTradeBuilder("mainnet", quote.quote.routes)
|
|
103
87
|
.slippage((slippagePercent / 100) * 1e6)
|
|
@@ -105,7 +89,7 @@ export const getSwapTransaction = (suiClient, address, quote, slippagePercent, s
|
|
|
105
89
|
.build();
|
|
106
90
|
const coinOut = yield trade.swap({
|
|
107
91
|
coinIn: coinIn,
|
|
108
|
-
client:
|
|
92
|
+
client: createJsonRpcAdapter(suiGrpcClient),
|
|
109
93
|
tx: transaction,
|
|
110
94
|
});
|
|
111
95
|
return { transaction, coinOut: coinOut };
|
package/utils/events.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuiClientTypes } from "@mysten/sui/client";
|
|
2
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
2
3
|
type TypeName = {
|
|
3
4
|
name: string;
|
|
4
5
|
};
|
|
@@ -25,8 +26,8 @@ export declare enum SuilendTransactionModule {
|
|
|
25
26
|
Reserve = "reserve"
|
|
26
27
|
}
|
|
27
28
|
declare class TypedParamsSuiEvent<T> {
|
|
28
|
-
event:
|
|
29
|
-
constructor(event:
|
|
29
|
+
event: SuiClientTypes.Event;
|
|
30
|
+
constructor(event: SuiClientTypes.Event);
|
|
30
31
|
params(): T;
|
|
31
32
|
isType(module: SuilendTransactionModule, eventType: SuilendEventType): boolean;
|
|
32
33
|
}
|
|
@@ -171,6 +172,6 @@ export declare class ObligationDataEvent extends TypedParamsSuiEvent<{
|
|
|
171
172
|
closable: boolean;
|
|
172
173
|
}> {
|
|
173
174
|
}
|
|
174
|
-
export declare function getEvents(
|
|
175
|
-
export declare function getRedeemEvent(
|
|
175
|
+
export declare function getEvents(suiGrpcClient: SuiGrpcClient, digest: string): Promise<GenericSuilendEvent[]>;
|
|
176
|
+
export declare function getRedeemEvent(suiGrpcClient: SuiGrpcClient, digest: string): Promise<RedeemEvent | null>;
|
|
176
177
|
export {};
|
package/utils/events.js
CHANGED
|
@@ -31,10 +31,10 @@ class TypedParamsSuiEvent {
|
|
|
31
31
|
this.event = event;
|
|
32
32
|
}
|
|
33
33
|
params() {
|
|
34
|
-
return this.event.
|
|
34
|
+
return this.event.json;
|
|
35
35
|
}
|
|
36
36
|
isType(module, eventType) {
|
|
37
|
-
return this.event.
|
|
37
|
+
return this.event.eventType.includes(`${module}::${eventType}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
export class GenericSuilendEvent extends TypedParamsSuiEvent {
|
|
@@ -61,22 +61,25 @@ export class ClaimRewardEvent extends TypedParamsSuiEvent {
|
|
|
61
61
|
}
|
|
62
62
|
export class ObligationDataEvent extends TypedParamsSuiEvent {
|
|
63
63
|
}
|
|
64
|
-
export function getEvents(
|
|
64
|
+
export function getEvents(suiGrpcClient, digest) {
|
|
65
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const
|
|
66
|
+
const result = yield suiGrpcClient.getTransaction({
|
|
67
67
|
digest,
|
|
68
|
-
|
|
68
|
+
include: { events: true },
|
|
69
69
|
});
|
|
70
|
+
const tx = result.$kind === "Transaction"
|
|
71
|
+
? result.Transaction
|
|
72
|
+
: result.FailedTransaction;
|
|
70
73
|
const events = [];
|
|
71
|
-
for (const event of tx.events || []) {
|
|
74
|
+
for (const event of (tx === null || tx === void 0 ? void 0 : tx.events) || []) {
|
|
72
75
|
events.push(new GenericSuilendEvent(event));
|
|
73
76
|
}
|
|
74
77
|
return events;
|
|
75
78
|
});
|
|
76
79
|
}
|
|
77
|
-
export function getRedeemEvent(
|
|
80
|
+
export function getRedeemEvent(suiGrpcClient, digest) {
|
|
78
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
const events = yield getEvents(
|
|
82
|
+
const events = yield getEvents(suiGrpcClient, digest);
|
|
80
83
|
for (const event of events) {
|
|
81
84
|
if (event.isType(SuilendTransactionModule.LendingMarket, SuilendEventType.RedeemEvent)) {
|
|
82
85
|
return event;
|
package/utils/obligation.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuiGraphQLClient } from "@mysten/sui/graphql";
|
|
2
|
+
import { SuiGrpcClient } from "@mysten/sui/grpc";
|
|
2
3
|
import { Obligation } from "../_generated/suilend/obligation/structs";
|
|
3
4
|
import { ParsedObligation } from "../parsers";
|
|
4
|
-
export declare function fetchAllObligationsForMarketWithHandler(
|
|
5
|
-
export declare function fetchAllObligationsForMarket(
|
|
5
|
+
export declare function fetchAllObligationsForMarketWithHandler(suiGrpcClient: SuiGrpcClient, lendingMarketId: string, lendingMarketType: string, chunkHandler: (obligations: Obligation<string>[]) => Promise<void>): Promise<void>;
|
|
6
|
+
export declare function fetchAllObligationsForMarket(suiGrpcClient: SuiGrpcClient, lendingMarketId: string, lendingMarketType: string): Promise<Obligation<string>[]>;
|
|
6
7
|
export type FormattedObligationHistory = NonLiquidationHistoryEvent | LiquidationHistoryEvent;
|
|
7
8
|
export type NonLiquidationHistoryEvent = {
|
|
8
9
|
reserveId: string;
|
|
@@ -20,8 +21,8 @@ export type LiquidationHistoryEvent = {
|
|
|
20
21
|
timestampMs: number;
|
|
21
22
|
digest: string;
|
|
22
23
|
};
|
|
23
|
-
export declare function getObligationHistoryPage(
|
|
24
|
-
cursor: string | null
|
|
24
|
+
export declare function getObligationHistoryPage(suiGraphQLClient: SuiGraphQLClient, obligationId: string, maxQuantity: number, cursor: string | null): Promise<{
|
|
25
|
+
cursor: string | null;
|
|
25
26
|
history: FormattedObligationHistory[];
|
|
26
27
|
}>;
|
|
27
28
|
export declare const getWeightedBorrowsUsd: (obligation: ParsedObligation) => BigNumber;
|