@suilend/sdk 13.4.0 → 13.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -17
- package/utils/interpolate.d.ts +2 -0
- package/utils/interpolate.js +18 -0
- package/utils/simulate.js +1 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"13.
|
|
1
|
+
{"name":"@suilend/sdk","version":"13.5.0","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./mmt":"./mmt.js","./strategies":"./strategies.js","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/proCompatible":"./lib/proCompatible.js","./lib/pyth":"./lib/pyth.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.js","./margin":"./margin/index.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils/feedId":"./utils/feedId.js","./utils":"./utils/index.js","./utils/interpolate":"./utils/interpolate.js","./utils/obligation":"./utils/obligation.js","./utils/priceGuard":"./utils/priceGuard.js","./utils/simulate":"./utils/simulate.js","./_generated/_envs":"./_generated/_envs/index.js","./_generated/_envs/mainnet":"./_generated/_envs/mainnet.js","./_generated/_framework/env":"./_generated/_framework/env.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./margin/margin/admin_cap":"./margin/margin/admin_cap.js","./margin/margin/market":"./margin/margin/market.js","./margin/margin/permissions":"./margin/margin/permissions.js","./margin/margin/position":"./margin/margin/position.js","./margin/margin/router":"./margin/margin/router.js","./margin/margin/version":"./margin/margin/version.js","./margin/utils":"./margin/utils/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/pyth-2/price-identifier/structs":"./_generated/_dependencies/pyth-2/price-identifier/structs.js","./_generated/_dependencies/std/ascii/structs":"./_generated/_dependencies/std/ascii/structs.js","./_generated/_dependencies/std/option/structs":"./_generated/_dependencies/std/option/structs.js","./_generated/_dependencies/std/type-name/structs":"./_generated/_dependencies/std/type-name/structs.js","./_generated/_dependencies/sui/bag/structs":"./_generated/_dependencies/sui/bag/structs.js","./_generated/_dependencies/sui/balance/structs":"./_generated/_dependencies/sui/balance/structs.js","./_generated/_dependencies/sui/object/structs":"./_generated/_dependencies/sui/object/structs.js","./_generated/_dependencies/sui/object-table/structs":"./_generated/_dependencies/sui/object-table/structs.js","./margin/margin/deps/std/type_name":"./margin/margin/deps/std/type_name.js","./margin/margin/deps/sui/vec_set":"./margin/margin/deps/sui/vec_set.js","./margin/margin/deps/suilend/lending_market":"./margin/margin/deps/suilend/lending_market.js"},"types":"./index.d.ts","scripts":{"codegen":"node ./codegen.js","codegen:install":"node ./install-codegen.js","build":"rm -rf ./dist && tsc && node ./fix-esm-imports.js","typecheck":"tsc --noEmit && tsc --noEmit -p tsconfig.test.json","test":"vitest run","lint:ci":"yarn run typecheck","prettier":"prettier --write src/ tests/","release":"yarn run build && node ./release.js && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/fireflyprotocol/lending-mono.git","directory":"ts/sdks/sdk"},"dependencies":{"@bluefin-exchange/bluefin7k-aggregator-sdk":"7.6.3","@cetusprotocol/aggregator-sdk":"1.7.3","@flowx-finance/sdk":"2.1.0","@pythnetwork/hermes-client":"3.1.0","@pythnetwork/pyth-sui-js":"4.0.0","@suilend/springsui-sdk":"4.1.0","bignumber.js":"11.1.5","bn.js":"5.2.5","crypto-js":"4.2.0","lodash":"4.18.1","p-limit":"7.3.3","uuid":"14.0.2"},"devDependencies":{"@mysten/bcs":"2.1.2","@mysten/sui":"2.33.1","@suilend/sui-core":"2.1.0","@tsconfig/recommended":"1.0.13","@types/bn.js":"5.2.0","@types/lodash":"4.17.25","@types/node":"26.6.4","fast-check":"4.10.2","prettier":"3.9.9","ts-node":"10.9.2","typescript":"6.0.3","vite":"8.3.2","vitest":"5.0.3"},"peerDependencies":{"@mysten/bcs":"^2.1.1","@mysten/sui":">=2.22.1 <3","@suilend/sui-core":"^2.0.1"},"type":"module"}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
import { ParsedReserve } from "../parsers/reserve";
|
|
3
3
|
export * from "./events";
|
|
4
|
+
export * from "./interpolate";
|
|
4
5
|
export * from "./obligation";
|
|
5
6
|
export * from "./priceGuard";
|
|
6
7
|
export * from "./simulate";
|
|
7
8
|
export declare const toHexString: (bytes: number[]) => string;
|
|
8
9
|
export declare const reserveSort: (reserves: ParsedReserve[], aCoinType: string, bCoinType: string) => number;
|
|
9
|
-
export declare const linearlyInterpolate: (array: any[], xKey: string, yKey: string, _xValue: number | BigNumber) => BigNumber;
|
|
10
10
|
/**
|
|
11
11
|
* Bisection method to find the optimal value that satisfies a condition
|
|
12
12
|
* @param left - Left boundary of the search range
|
package/utils/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import BigNumber from "bignumber.js";
|
|
2
2
|
export * from "./events.js";
|
|
3
|
+
export * from "./interpolate.js";
|
|
3
4
|
export * from "./obligation.js";
|
|
4
5
|
export * from "./priceGuard.js";
|
|
5
6
|
export * from "./simulate.js";
|
|
@@ -16,23 +17,6 @@ export const reserveSort = (reserves, aCoinType, bCoinType) => {
|
|
|
16
17
|
else
|
|
17
18
|
return aReserveIndex > -1 ? -1 : 1;
|
|
18
19
|
};
|
|
19
|
-
export const linearlyInterpolate = (array, xKey, yKey, _xValue) => {
|
|
20
|
-
let i = 1;
|
|
21
|
-
while (i < array.length) {
|
|
22
|
-
const leftXValue = new BigNumber(array[i - 1][xKey]);
|
|
23
|
-
const leftYValue = new BigNumber(array[i - 1][yKey]);
|
|
24
|
-
const xValue = new BigNumber(_xValue);
|
|
25
|
-
const rightXValue = new BigNumber(array[i][xKey]);
|
|
26
|
-
const rightYValue = new BigNumber(array[i][yKey]);
|
|
27
|
-
if (xValue.gte(leftXValue) && xValue.lte(rightXValue)) {
|
|
28
|
-
const weight = new BigNumber(xValue.minus(leftXValue)).div(rightXValue.minus(leftXValue));
|
|
29
|
-
return leftYValue.plus(weight.times(rightYValue.minus(leftYValue)));
|
|
30
|
-
}
|
|
31
|
-
i = i + 1;
|
|
32
|
-
}
|
|
33
|
-
// Should never reach here
|
|
34
|
-
return new BigNumber(0);
|
|
35
|
-
};
|
|
36
20
|
/**
|
|
37
21
|
* Bisection method to find the optimal value that satisfies a condition
|
|
38
22
|
* @param left - Left boundary of the search range
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
export const linearlyInterpolate = (array, xKey, yKey, _xValue) => {
|
|
3
|
+
let i = 1;
|
|
4
|
+
while (i < array.length) {
|
|
5
|
+
const leftXValue = new BigNumber(array[i - 1][xKey]);
|
|
6
|
+
const leftYValue = new BigNumber(array[i - 1][yKey]);
|
|
7
|
+
const xValue = new BigNumber(_xValue);
|
|
8
|
+
const rightXValue = new BigNumber(array[i][xKey]);
|
|
9
|
+
const rightYValue = new BigNumber(array[i][yKey]);
|
|
10
|
+
if (xValue.gte(leftXValue) && xValue.lte(rightXValue)) {
|
|
11
|
+
const weight = new BigNumber(xValue.minus(leftXValue)).div(rightXValue.minus(leftXValue));
|
|
12
|
+
return leftYValue.plus(weight.times(rightYValue.minus(leftYValue)));
|
|
13
|
+
}
|
|
14
|
+
i = i + 1;
|
|
15
|
+
}
|
|
16
|
+
// Should never reach here
|
|
17
|
+
return new BigNumber(0);
|
|
18
|
+
};
|
package/utils/simulate.js
CHANGED
|
@@ -5,8 +5,8 @@ import { v4 as uuidv4 } from "uuid";
|
|
|
5
5
|
import { Decimal } from "../_generated/suilend/decimal/structs.js";
|
|
6
6
|
import { UserReward, } from "../_generated/suilend/liquidity-mining/structs.js";
|
|
7
7
|
import { WAD } from "../lib/constants.js";
|
|
8
|
-
import { linearlyInterpolate } from "../utils/index.js";
|
|
9
8
|
import { normalizeFeedId } from "./feedId.js";
|
|
9
|
+
import { linearlyInterpolate } from "./interpolate.js";
|
|
10
10
|
/**
|
|
11
11
|
* @deprecated since version 1.0.8. Use `calculateUtilizationPercent` instead.
|
|
12
12
|
*/
|