@defisaver/positions-sdk 2.1.7 → 2.1.9-dev-spark-1
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +64 -64
- package/cjs/aaveV3/index.js +3 -3
- package/cjs/aaveV3/merit.js +3 -0
- package/cjs/aaveV3/merkl.d.ts +1 -1
- package/cjs/config/contracts.d.ts +20 -0
- package/cjs/config/contracts.js +20 -0
- package/cjs/fluid/index.js +40 -12
- package/cjs/helpers/aaveHelpers/index.d.ts +1 -1
- package/cjs/helpers/aaveHelpers/index.js +6 -4
- package/cjs/helpers/morphoBlueHelpers/index.d.ts +1 -1
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/helpers/sparkHelpers/index.d.ts +4 -4
- package/cjs/helpers/sparkHelpers/index.js +12 -12
- package/cjs/markets/aave/index.js +1 -1
- package/cjs/markets/aave/marketAssets.d.ts +4 -0
- package/cjs/markets/aave/marketAssets.js +5 -1
- package/cjs/markets/compound/index.js +11 -0
- package/cjs/markets/compound/marketsAssets.d.ts +7 -0
- package/cjs/markets/compound/marketsAssets.js +7 -0
- package/cjs/markets/fluid/index.d.ts +4 -0
- package/cjs/markets/fluid/index.js +4 -0
- package/cjs/markets/spark/marketAssets.d.ts +1 -0
- package/cjs/markets/spark/marketAssets.js +1 -0
- package/cjs/portfolio/index.js +1 -1
- package/cjs/services/utils.d.ts +8 -4
- package/cjs/services/utils.js +30 -10
- package/cjs/services/viem.d.ts +54 -15
- package/cjs/services/viem.js +2 -0
- package/cjs/spark/index.d.ts +3 -1
- package/cjs/spark/index.js +24 -14
- package/cjs/staking/eligibility.js +1 -6
- package/cjs/types/common.d.ts +4 -2
- package/cjs/types/common.js +2 -0
- package/cjs/types/fluid.d.ts +7 -3
- package/cjs/types/fluid.js +4 -0
- package/cjs/types/spark.d.ts +3 -1
- package/esm/aaveV3/index.js +4 -4
- package/esm/aaveV3/merit.js +3 -0
- package/esm/aaveV3/merkl.d.ts +1 -1
- package/esm/config/contracts.d.ts +20 -0
- package/esm/config/contracts.js +20 -0
- package/esm/fluid/index.js +40 -12
- package/esm/helpers/aaveHelpers/index.d.ts +1 -1
- package/esm/helpers/aaveHelpers/index.js +7 -5
- package/esm/helpers/morphoBlueHelpers/index.d.ts +1 -1
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/helpers/sparkHelpers/index.d.ts +4 -4
- package/esm/helpers/sparkHelpers/index.js +13 -13
- package/esm/markets/aave/index.js +1 -1
- package/esm/markets/aave/marketAssets.d.ts +4 -0
- package/esm/markets/aave/marketAssets.js +4 -0
- package/esm/markets/compound/index.js +11 -0
- package/esm/markets/compound/marketsAssets.d.ts +7 -0
- package/esm/markets/compound/marketsAssets.js +7 -0
- package/esm/markets/fluid/index.d.ts +4 -0
- package/esm/markets/fluid/index.js +4 -0
- package/esm/markets/spark/marketAssets.d.ts +1 -0
- package/esm/markets/spark/marketAssets.js +1 -0
- package/esm/portfolio/index.js +1 -1
- package/esm/services/utils.d.ts +8 -4
- package/esm/services/utils.js +21 -5
- package/esm/services/viem.d.ts +54 -15
- package/esm/services/viem.js +3 -1
- package/esm/spark/index.d.ts +3 -1
- package/esm/spark/index.js +25 -15
- package/esm/staking/eligibility.js +1 -6
- package/esm/types/common.d.ts +4 -2
- package/esm/types/common.js +2 -0
- package/esm/types/fluid.d.ts +7 -3
- package/esm/types/fluid.js +4 -0
- package/esm/types/spark.d.ts +3 -1
- package/package.json +47 -47
- package/src/aaveV2/index.ts +240 -240
- package/src/aaveV3/index.ts +614 -614
- package/src/aaveV3/merit.ts +97 -94
- package/src/aaveV3/merkl.ts +74 -74
- package/src/claiming/aaveV3.ts +154 -154
- package/src/claiming/compV3.ts +22 -22
- package/src/claiming/index.ts +12 -12
- package/src/claiming/king.ts +66 -66
- package/src/claiming/morphoBlue.ts +118 -118
- package/src/claiming/spark.ts +225 -225
- package/src/compoundV2/index.ts +244 -244
- package/src/compoundV3/index.ts +274 -274
- package/src/config/contracts.ts +1251 -1231
- package/src/constants/index.ts +10 -10
- package/src/contracts.ts +120 -120
- package/src/curveUsd/index.ts +254 -254
- package/src/eulerV2/index.ts +324 -324
- package/src/exchange/index.ts +25 -25
- package/src/fluid/index.ts +1668 -1638
- package/src/helpers/aaveHelpers/index.ts +187 -185
- package/src/helpers/compoundHelpers/index.ts +283 -283
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +222 -222
- package/src/helpers/fluidHelpers/index.ts +326 -326
- package/src/helpers/index.ts +10 -10
- package/src/helpers/liquityV2Helpers/index.ts +82 -82
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +52 -52
- package/src/helpers/morphoBlueHelpers/index.ts +396 -396
- package/src/helpers/sparkHelpers/index.ts +158 -155
- package/src/index.ts +47 -47
- package/src/liquity/index.ts +159 -159
- package/src/liquityV2/index.ts +657 -657
- package/src/llamaLend/index.ts +305 -305
- package/src/maker/index.ts +223 -223
- package/src/markets/aave/index.ts +116 -116
- package/src/markets/aave/marketAssets.ts +54 -49
- package/src/markets/compound/index.ts +238 -227
- package/src/markets/compound/marketsAssets.ts +97 -90
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2460 -2456
- package/src/markets/index.ts +25 -25
- package/src/markets/liquityV2/index.ts +102 -102
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +12 -11
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoBlue/index.ts +274 -274
- package/src/portfolio/index.ts +570 -570
- package/src/services/priceService.ts +159 -159
- package/src/services/utils.ts +115 -99
- package/src/services/viem.ts +34 -32
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +465 -445
- package/src/staking/eligibility.ts +53 -59
- package/src/staking/index.ts +1 -1
- package/src/staking/staking.ts +170 -170
- package/src/types/aave.ts +189 -189
- package/src/types/claiming.ts +109 -109
- package/src/types/common.ts +107 -105
- package/src/types/compound.ts +136 -136
- package/src/types/curveUsd.ts +123 -123
- package/src/types/euler.ts +175 -175
- package/src/types/fluid.ts +452 -448
- package/src/types/index.ts +13 -13
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +126 -126
- package/src/types/llamaLend.ts +159 -159
- package/src/types/maker.ts +63 -63
- package/src/types/merit.ts +1 -1
- package/src/types/merkl.ts +70 -70
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/portfolio.ts +60 -60
- package/src/types/spark.ts +136 -135
- package/src/umbrella/index.ts +69 -69
- package/src/umbrella/umbrellaUtils.ts +29 -29
- package/CLAUDE.md +0 -32
package/esm/services/viem.d.ts
CHANGED
|
@@ -7,14 +7,11 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
7
7
|
readonly apiUrl: "https://api.etherscan.io/api";
|
|
8
8
|
};
|
|
9
9
|
};
|
|
10
|
-
blockTime
|
|
10
|
+
blockTime: 12000;
|
|
11
11
|
contracts: {
|
|
12
|
-
readonly ensRegistry: {
|
|
13
|
-
readonly address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";
|
|
14
|
-
};
|
|
15
12
|
readonly ensUniversalResolver: {
|
|
16
|
-
readonly address: "
|
|
17
|
-
readonly blockCreated:
|
|
13
|
+
readonly address: "0xeeeeeeee14d718c2b47d9923deab1335e144eeee";
|
|
14
|
+
readonly blockCreated: 23085558;
|
|
18
15
|
};
|
|
19
16
|
readonly multicall3: {
|
|
20
17
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
@@ -29,6 +26,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
29
26
|
readonly symbol: "ETH";
|
|
30
27
|
readonly decimals: 18;
|
|
31
28
|
};
|
|
29
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
32
30
|
rpcUrls: {
|
|
33
31
|
readonly default: {
|
|
34
32
|
readonly http: readonly ["https://eth.merkle.io"];
|
|
@@ -101,6 +99,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
101
99
|
readonly symbol: "ETH";
|
|
102
100
|
readonly decimals: 18;
|
|
103
101
|
};
|
|
102
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
104
103
|
rpcUrls: {
|
|
105
104
|
readonly default: {
|
|
106
105
|
readonly http: readonly ["https://mainnet.optimism.io"];
|
|
@@ -174,16 +173,16 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
174
173
|
r: import("viem").Hex;
|
|
175
174
|
s: import("viem").Hex;
|
|
176
175
|
v: bigint;
|
|
176
|
+
value: bigint;
|
|
177
|
+
gas: bigint;
|
|
177
178
|
to: import("viem").Address | null;
|
|
178
179
|
from: import("viem").Address;
|
|
179
|
-
gas: bigint;
|
|
180
180
|
nonce: number;
|
|
181
|
-
value: bigint;
|
|
182
181
|
blockHash: `0x${string}` | null;
|
|
183
182
|
blockNumber: bigint | null;
|
|
183
|
+
transactionIndex: number | null;
|
|
184
184
|
hash: import("viem").Hash;
|
|
185
185
|
input: import("viem").Hex;
|
|
186
|
-
transactionIndex: number | null;
|
|
187
186
|
typeHex: import("viem").Hex | null;
|
|
188
187
|
accessList?: undefined | undefined;
|
|
189
188
|
authorizationList?: undefined | undefined;
|
|
@@ -352,7 +351,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
352
351
|
readonly apiUrl: "https://api.arbiscan.io/api";
|
|
353
352
|
};
|
|
354
353
|
};
|
|
355
|
-
blockTime
|
|
354
|
+
blockTime: 250;
|
|
356
355
|
contracts: {
|
|
357
356
|
readonly multicall3: {
|
|
358
357
|
readonly address: "0xca11bde05977b3631167028862be2a173976ca11";
|
|
@@ -367,6 +366,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
367
366
|
readonly symbol: "ETH";
|
|
368
367
|
readonly decimals: 18;
|
|
369
368
|
};
|
|
369
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
370
370
|
rpcUrls: {
|
|
371
371
|
readonly default: {
|
|
372
372
|
readonly http: readonly ["https://arb1.arbitrum.io/rpc"];
|
|
@@ -441,6 +441,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
441
441
|
readonly symbol: "ETH";
|
|
442
442
|
readonly decimals: 18;
|
|
443
443
|
};
|
|
444
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
444
445
|
rpcUrls: {
|
|
445
446
|
readonly default: {
|
|
446
447
|
readonly http: readonly ["https://mainnet.base.org"];
|
|
@@ -514,16 +515,16 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
514
515
|
r: import("viem").Hex;
|
|
515
516
|
s: import("viem").Hex;
|
|
516
517
|
v: bigint;
|
|
518
|
+
value: bigint;
|
|
519
|
+
gas: bigint;
|
|
517
520
|
to: import("viem").Address | null;
|
|
518
521
|
from: import("viem").Address;
|
|
519
|
-
gas: bigint;
|
|
520
522
|
nonce: number;
|
|
521
|
-
value: bigint;
|
|
522
523
|
blockHash: `0x${string}` | null;
|
|
523
524
|
blockNumber: bigint | null;
|
|
525
|
+
transactionIndex: number | null;
|
|
524
526
|
hash: import("viem").Hash;
|
|
525
527
|
input: import("viem").Hex;
|
|
526
|
-
transactionIndex: number | null;
|
|
527
528
|
typeHex: import("viem").Hex | null;
|
|
528
529
|
accessList?: undefined | undefined;
|
|
529
530
|
authorizationList?: undefined | undefined;
|
|
@@ -703,8 +704,8 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
703
704
|
readonly blockCreated: 6682888;
|
|
704
705
|
};
|
|
705
706
|
readonly ensUniversalResolver: {
|
|
706
|
-
readonly address: "
|
|
707
|
-
readonly blockCreated:
|
|
707
|
+
readonly address: "0x4D41762915F83c76EcaF6776d9b08076aA32b492";
|
|
708
|
+
readonly blockCreated: 22222151;
|
|
708
709
|
};
|
|
709
710
|
};
|
|
710
711
|
ensTlds: readonly [".linea.eth"];
|
|
@@ -715,6 +716,7 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
715
716
|
readonly symbol: "ETH";
|
|
716
717
|
readonly decimals: 18;
|
|
717
718
|
};
|
|
719
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
718
720
|
rpcUrls: {
|
|
719
721
|
readonly default: {
|
|
720
722
|
readonly http: readonly ["https://rpc.linea.build"];
|
|
@@ -730,6 +732,40 @@ export declare const getViemChain: (network: NetworkNumber) => {
|
|
|
730
732
|
};
|
|
731
733
|
formatters?: undefined;
|
|
732
734
|
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
735
|
+
} | {
|
|
736
|
+
blockExplorers: {
|
|
737
|
+
readonly default: {
|
|
738
|
+
readonly name: "PlasmaScan";
|
|
739
|
+
readonly url: "https://plasmascan.to";
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
blockTime?: number | undefined | undefined;
|
|
743
|
+
contracts: {
|
|
744
|
+
readonly multicall3: {
|
|
745
|
+
readonly address: "0xcA11bde05977b3631167028862bE2a173976CA11";
|
|
746
|
+
readonly blockCreated: 0;
|
|
747
|
+
};
|
|
748
|
+
};
|
|
749
|
+
ensTlds?: readonly string[] | undefined;
|
|
750
|
+
id: 9745;
|
|
751
|
+
name: "Plasma";
|
|
752
|
+
nativeCurrency: {
|
|
753
|
+
readonly name: "Plasma";
|
|
754
|
+
readonly symbol: "XPL";
|
|
755
|
+
readonly decimals: 18;
|
|
756
|
+
};
|
|
757
|
+
experimental_preconfirmationTime?: number | undefined | undefined;
|
|
758
|
+
rpcUrls: {
|
|
759
|
+
readonly default: {
|
|
760
|
+
readonly http: readonly ["https://rpc.plasma.to"];
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
sourceId?: number | undefined | undefined;
|
|
764
|
+
testnet?: boolean | undefined | undefined;
|
|
765
|
+
custom?: Record<string, unknown> | undefined;
|
|
766
|
+
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
767
|
+
formatters?: undefined;
|
|
768
|
+
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
733
769
|
};
|
|
734
770
|
export declare const getViemProvider: (provider: EthereumProvider, network: NetworkNumber, options?: any) => {
|
|
735
771
|
account: undefined;
|
|
@@ -741,6 +777,7 @@ export declare const getViemProvider: (provider: EthereumProvider, network: Netw
|
|
|
741
777
|
request?: (parameters: import("viem").CcipRequestParameters) => Promise<import("viem/_types/utils/ccip").CcipRequestReturnType>;
|
|
742
778
|
} | undefined;
|
|
743
779
|
chain: undefined;
|
|
780
|
+
experimental_blockTag?: import("viem").BlockTag | undefined;
|
|
744
781
|
key: string;
|
|
745
782
|
name: string;
|
|
746
783
|
pollingInterval: number;
|
|
@@ -7579,6 +7616,7 @@ export declare const getViemProvider: (provider: EthereumProvider, network: Netw
|
|
|
7579
7616
|
simulateBlocks: <const calls extends readonly unknown[]>(args: import("viem").SimulateBlocksParameters<calls>) => Promise<import("viem").SimulateBlocksReturnType<calls>>;
|
|
7580
7617
|
simulateCalls: <const calls extends readonly unknown[]>(args: import("viem").SimulateCallsParameters<calls>) => Promise<import("viem").SimulateCallsReturnType<calls>>;
|
|
7581
7618
|
simulateContract: <const abi extends import("viem").Abi | readonly unknown[], functionName extends import("viem").ContractFunctionName<abi, "nonpayable" | "payable">, const args_1 extends import("viem").ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>, chainOverride extends import("viem").Chain | undefined, accountOverride extends import("viem").Account | import("viem").Address | undefined = undefined>(args: import("viem").SimulateContractParameters<abi, functionName, args_1, undefined, chainOverride, accountOverride>) => Promise<import("viem").SimulateContractReturnType<abi, functionName, args_1, undefined, import("viem").Account | undefined, chainOverride, accountOverride>>;
|
|
7619
|
+
verifyHash: (args: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>;
|
|
7582
7620
|
verifyMessage: (args: import("viem").VerifyMessageActionParameters) => Promise<import("viem").VerifyMessageActionReturnType>;
|
|
7583
7621
|
verifySiweMessage: (args: import("viem/_types/actions/siwe/verifySiweMessage").VerifySiweMessageParameters) => Promise<import("viem/_types/actions/siwe/verifySiweMessage").VerifySiweMessageReturnType>;
|
|
7584
7622
|
verifyTypedData: (args: import("viem").VerifyTypedDataActionParameters) => Promise<import("viem").VerifyTypedDataActionReturnType>;
|
|
@@ -7596,6 +7634,7 @@ export declare const getViemProvider: (provider: EthereumProvider, network: Netw
|
|
|
7596
7634
|
cacheTime?: undefined;
|
|
7597
7635
|
ccipRead?: undefined;
|
|
7598
7636
|
chain?: undefined;
|
|
7637
|
+
experimental_blockTag?: undefined;
|
|
7599
7638
|
key?: undefined;
|
|
7600
7639
|
name?: undefined;
|
|
7601
7640
|
pollingInterval?: undefined;
|
package/esm/services/viem.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPublicClient, custom } from 'viem';
|
|
2
|
-
import { arbitrum, base, mainnet, optimism, linea, } from 'viem/chains';
|
|
2
|
+
import { arbitrum, base, mainnet, optimism, linea, plasma, } from 'viem/chains';
|
|
3
3
|
import { NetworkNumber } from '../types/common';
|
|
4
4
|
export const getViemChain = (network) => {
|
|
5
5
|
switch (network) {
|
|
@@ -13,6 +13,8 @@ export const getViemChain = (network) => {
|
|
|
13
13
|
return base;
|
|
14
14
|
case NetworkNumber.Linea:
|
|
15
15
|
return linea;
|
|
16
|
+
case NetworkNumber.Plasma:
|
|
17
|
+
return plasma;
|
|
16
18
|
default:
|
|
17
19
|
throw new Error(`Unsupported network: ${network}`);
|
|
18
20
|
}
|
package/esm/spark/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from 'viem';
|
|
2
2
|
import { Blockish, EthAddress, EthereumProvider, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
-
import { SparkEModeCategoryDataMapping, SparkAssetsData, SparkMarketData, SparkMarketsData, SparkPositionData, SparkUsedAssets } from '../types';
|
|
3
|
+
import { SparkEModeCategoryDataMapping, SparkAssetsData, SparkMarketData, SparkMarketsData, SparkPositionData, SparkUsedAssets, EModeCategoriesData } from '../types';
|
|
4
4
|
export declare const sparkEmodeCategoriesMapping: (extractedState: {
|
|
5
5
|
assetsData: SparkAssetsData;
|
|
6
6
|
}, usedAssets: SparkUsedAssets) => {
|
|
@@ -32,9 +32,11 @@ export declare const getSparkAccountBalances: (provider: EthereumProvider, netwo
|
|
|
32
32
|
export declare const _getSparkAccountData: (provider: Client, network: NetworkNumber, address: EthAddress, extractedState: {
|
|
33
33
|
selectedMarket: SparkMarketData;
|
|
34
34
|
assetsData: SparkAssetsData;
|
|
35
|
+
eModeCategoriesData: EModeCategoriesData;
|
|
35
36
|
}) => Promise<SparkPositionData>;
|
|
36
37
|
export declare const getSparkAccountData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, extractedState: {
|
|
37
38
|
selectedMarket: SparkMarketData;
|
|
38
39
|
assetsData: SparkAssetsData;
|
|
40
|
+
eModeCategoriesData: EModeCategoriesData;
|
|
39
41
|
}) => Promise<SparkPositionData>;
|
|
40
42
|
export declare const getSparkFullPositionData: (provider: EthereumProvider, network: NetworkNumber, address: EthAddress, market: SparkMarketData) => Promise<SparkPositionData>;
|
package/esm/spark/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tokens';
|
|
12
|
-
import { IncentiveKind,
|
|
12
|
+
import { IncentiveKind, } from '../types/common';
|
|
13
13
|
import { ethToWeth, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
14
14
|
import { calculateNetApy, getStakingApy, STAKING_ASSETS, } from '../staking';
|
|
15
15
|
import { SparkViewContractViem, SparkIncentiveDataProviderContractViem, createViemContractFromConfigFunc, } from '../contracts';
|
|
@@ -49,18 +49,17 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
|
|
|
49
49
|
const marketAddress = selectedMarket.providerAddress;
|
|
50
50
|
const loanInfoContract = SparkViewContractViem(provider, network);
|
|
51
51
|
const sparkIncentivesContract = SparkIncentiveDataProviderContractViem(provider, network);
|
|
52
|
-
|
|
52
|
+
// eslint-disable-next-line prefer-const
|
|
53
|
+
let [loanInfo, rewardInfo] = yield Promise.all([
|
|
53
54
|
loanInfoContract.read.getFullTokensInfo([marketAddress, selectedMarket.assets.map(a => getAssetInfo(ethToWeth(a)).address)]),
|
|
54
|
-
|
|
55
|
+
sparkIncentivesContract.read.getReservesIncentivesData([marketAddress]),
|
|
55
56
|
]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, {});
|
|
63
|
-
}
|
|
57
|
+
rewardInfo = rewardInfo.reduce((all, market) => {
|
|
58
|
+
// eslint-disable-next-line no-param-reassign
|
|
59
|
+
all[market.underlyingAsset] = market;
|
|
60
|
+
return all;
|
|
61
|
+
}, {});
|
|
62
|
+
const eModeCategoriesData = {};
|
|
64
63
|
const assetsData = yield Promise.all(loanInfo
|
|
65
64
|
.map((market, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
65
|
const symbol = selectedMarket.assets[i];
|
|
@@ -75,6 +74,15 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
|
|
|
75
74
|
if (new Dec(marketLiquidity).lt(0)) {
|
|
76
75
|
marketLiquidity = '0';
|
|
77
76
|
}
|
|
77
|
+
eModeCategoriesData[+market.emodeCategory.toString()] = {
|
|
78
|
+
id: +market.emodeCategory.toString(),
|
|
79
|
+
label: market.label,
|
|
80
|
+
liquidationBonus: new Dec(market.liquidationBonus).div(10000).toString(),
|
|
81
|
+
liquidationRatio: new Dec(market.liquidationThreshold).div(10000).toString(),
|
|
82
|
+
collateralFactor: new Dec(market.ltv).div(10000).toString(),
|
|
83
|
+
collateralAssets: eModeCategoriesData[+market.emodeCategory.toString()] ? [...eModeCategoriesData[+market.emodeCategory.toString()].collateralAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
|
|
84
|
+
borrowAssets: eModeCategoriesData[+market.emodeCategory.toString()] ? [...eModeCategoriesData[+market.emodeCategory.toString()].borrowAssets, selectedMarket.assets[i]] : [selectedMarket.assets[i]],
|
|
85
|
+
};
|
|
78
86
|
return ({
|
|
79
87
|
symbol: selectedMarket.assets[i],
|
|
80
88
|
isIsolated: new Dec(market.debtCeilingForIsolationMode.toString()).gt(0),
|
|
@@ -147,7 +155,7 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
|
|
|
147
155
|
return;
|
|
148
156
|
rewardForMarket.aIncentiveData.rewardsTokenInformation.forEach(supplyRewardData => {
|
|
149
157
|
if (supplyRewardData) {
|
|
150
|
-
if (supplyRewardData.emissionEndTimestamp * 1000 < Date.now())
|
|
158
|
+
if (+(supplyRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
151
159
|
return;
|
|
152
160
|
const supplyEmissionPerSecond = supplyRewardData.emissionPerSecond;
|
|
153
161
|
const supplyRewardPrice = new Dec(supplyRewardData.rewardPriceFeed).div(Math.pow(10, supplyRewardData.priceFeedDecimals))
|
|
@@ -168,7 +176,7 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
|
|
|
168
176
|
});
|
|
169
177
|
rewardForMarket.vIncentiveData.rewardsTokenInformation.forEach(borrowRewardData => {
|
|
170
178
|
if (borrowRewardData) {
|
|
171
|
-
if (borrowRewardData.emissionEndTimestamp * 1000 < Date.now())
|
|
179
|
+
if (+(borrowRewardData.emissionEndTimestamp.toString()) * 1000 < Date.now())
|
|
172
180
|
return;
|
|
173
181
|
const supplyEmissionPerSecond = borrowRewardData.emissionPerSecond;
|
|
174
182
|
const supplyRewardPrice = new Dec(borrowRewardData.rewardPriceFeed).div(Math.pow(10, borrowRewardData.priceFeedDecimals))
|
|
@@ -200,7 +208,9 @@ export const _getSparkMarketsData = (provider, network, selectedMarket) => __awa
|
|
|
200
208
|
.forEach((assetData, i) => {
|
|
201
209
|
payload[assetData.symbol] = Object.assign(Object.assign({}, assetData), { sortIndex: i });
|
|
202
210
|
});
|
|
203
|
-
|
|
211
|
+
eModeCategoriesData[0].collateralAssets = Object.values(payload).map(a => a.symbol);
|
|
212
|
+
eModeCategoriesData[0].borrowAssets = Object.values(payload).map(a => a.symbol);
|
|
213
|
+
return { assetsData: payload, eModeCategoriesData };
|
|
204
214
|
});
|
|
205
215
|
export const getSparkMarketsData = (provider, network, selectedMarket) => __awaiter(void 0, void 0, void 0, function* () { return _getSparkMarketsData(getViemProvider(provider, network), network, selectedMarket); });
|
|
206
216
|
export const EMPTY_SPARK_DATA = {
|
|
@@ -336,6 +346,6 @@ export const _getSparkAccountData = (provider, network, address, extractedState)
|
|
|
336
346
|
export const getSparkAccountData = (provider, network, address, extractedState) => __awaiter(void 0, void 0, void 0, function* () { return _getSparkAccountData(getViemProvider(provider, network), network, address, extractedState); });
|
|
337
347
|
export const getSparkFullPositionData = (provider, network, address, market) => __awaiter(void 0, void 0, void 0, function* () {
|
|
338
348
|
const marketData = yield getSparkMarketsData(provider, network, market);
|
|
339
|
-
const positionData = yield getSparkAccountData(provider, network, address, { assetsData: marketData.assetsData, selectedMarket: market });
|
|
349
|
+
const positionData = yield getSparkAccountData(provider, network, address, { assetsData: marketData.assetsData, selectedMarket: market, eModeCategoriesData: marketData.eModeCategoriesData });
|
|
340
350
|
return positionData;
|
|
341
351
|
});
|
|
@@ -18,12 +18,6 @@ export const isEligibleForEthenaUSDeRewards = (usedAssets, { healthRatio }) => {
|
|
|
18
18
|
const anythingBorrowedNotAllowed = Object.values(usedAssets).some((asset) => asset.isBorrowed && !allowedBorrowAssets.includes(asset.symbol));
|
|
19
19
|
if (anythingBorrowedNotAllowed)
|
|
20
20
|
return { isEligible: false, eligibleUSDAmount: '0' };
|
|
21
|
-
const totalAmountBorrowed = Object.values(usedAssets).reduce((acc, asset) => {
|
|
22
|
-
if (asset.isBorrowed) {
|
|
23
|
-
return acc.add(asset.borrowedUsd);
|
|
24
|
-
}
|
|
25
|
-
return acc;
|
|
26
|
-
}, new Dec(0)).toString();
|
|
27
21
|
if (new Dec(healthRatio).gte(2.5))
|
|
28
22
|
return { isEligible: false, eligibleUSDAmount: '0' }; // health ratio must be below 2.5
|
|
29
23
|
const halfAmountSupplied = new Dec(totalAmountSupplied).div(2).toString();
|
|
@@ -54,4 +48,5 @@ export const EligibilityMapping = {
|
|
|
54
48
|
[IncentiveEligibilityId.AaveV3EthenaLiquidLeverage]: isEligibleForEthenaUSDeRewards,
|
|
55
49
|
[IncentiveEligibilityId.AaveV3ArbitrumEthSupply]: isEligibleForAaveV3ArbitrumEthSupply,
|
|
56
50
|
[IncentiveEligibilityId.AaveV3ArbitrumETHLSBorrow]: isEligibleForAaveV3ArbitrumETHLSBorrow,
|
|
51
|
+
[IncentiveEligibilityId.AaveV3EthenaLiquidLeveragePlasma]: isEligibleForEthenaUSDeRewards,
|
|
57
52
|
};
|
package/esm/types/common.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare enum IncentiveKind {
|
|
|
5
5
|
export declare enum IncentiveEligibilityId {
|
|
6
6
|
AaveV3EthenaLiquidLeverage = "0x7361e6f04060154e0268a8402b073cbf97e11ae3BORROW_BL",
|
|
7
7
|
AaveV3ArbitrumEthSupply = "0x5d16261c6715a653248269861bbacf68a9774cde",
|
|
8
|
-
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351"
|
|
8
|
+
AaveV3ArbitrumETHLSBorrow = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351",
|
|
9
|
+
AaveV3EthenaLiquidLeveragePlasma = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL"
|
|
9
10
|
}
|
|
10
11
|
export interface IncentiveData {
|
|
11
12
|
token: string;
|
|
@@ -23,7 +24,8 @@ export declare enum NetworkNumber {
|
|
|
23
24
|
Opt = 10,
|
|
24
25
|
Arb = 42161,
|
|
25
26
|
Base = 8453,
|
|
26
|
-
Linea = 59144
|
|
27
|
+
Linea = 59144,
|
|
28
|
+
Plasma = 9745
|
|
27
29
|
}
|
|
28
30
|
export type Networkish = string | NetworkNumber;
|
|
29
31
|
export interface MMAssetData {
|
package/esm/types/common.js
CHANGED
|
@@ -8,6 +8,7 @@ export var IncentiveEligibilityId;
|
|
|
8
8
|
IncentiveEligibilityId["AaveV3EthenaLiquidLeverage"] = "0x7361e6f04060154e0268a8402b073cbf97e11ae3BORROW_BL";
|
|
9
9
|
IncentiveEligibilityId["AaveV3ArbitrumEthSupply"] = "0x5d16261c6715a653248269861bbacf68a9774cde";
|
|
10
10
|
IncentiveEligibilityId["AaveV3ArbitrumETHLSBorrow"] = "0x0c84331e39d6658Cd6e6b9ba04736cC4c4734351";
|
|
11
|
+
IncentiveEligibilityId["AaveV3EthenaLiquidLeveragePlasma"] = "0x67264783f1e9a2af8627a235853057a6fc975bd2BORROW_BL";
|
|
11
12
|
})(IncentiveEligibilityId || (IncentiveEligibilityId = {}));
|
|
12
13
|
export var NetworkNumber;
|
|
13
14
|
(function (NetworkNumber) {
|
|
@@ -16,4 +17,5 @@ export var NetworkNumber;
|
|
|
16
17
|
NetworkNumber[NetworkNumber["Arb"] = 42161] = "Arb";
|
|
17
18
|
NetworkNumber[NetworkNumber["Base"] = 8453] = "Base";
|
|
18
19
|
NetworkNumber[NetworkNumber["Linea"] = 59144] = "Linea";
|
|
20
|
+
NetworkNumber[NetworkNumber["Plasma"] = 9745] = "Plasma";
|
|
19
21
|
})(NetworkNumber || (NetworkNumber = {}));
|
package/esm/types/fluid.d.ts
CHANGED
|
@@ -149,21 +149,25 @@ export declare enum FluidMainnetDepositToken {
|
|
|
149
149
|
USDC = "USDC",
|
|
150
150
|
USDT = "USDT",
|
|
151
151
|
GHO = "GHO",
|
|
152
|
-
sUSDS = "sUSDS"
|
|
152
|
+
sUSDS = "sUSDS",
|
|
153
|
+
USDtb = "USDtb"
|
|
153
154
|
}
|
|
154
155
|
export declare enum FluidArbitrumDepositToken {
|
|
155
156
|
ETH = "ETH",
|
|
156
157
|
wstETH = "wstETH",
|
|
157
158
|
USDC = "USDC",
|
|
158
159
|
USDT = "USDT",
|
|
159
|
-
ARB = "ARB"
|
|
160
|
+
ARB = "ARB",
|
|
161
|
+
GHO = "GHO",
|
|
162
|
+
sUSDS = "sUSDS"
|
|
160
163
|
}
|
|
161
164
|
export declare enum FluidBaseDepositToken {
|
|
162
165
|
ETH = "ETH",
|
|
163
166
|
USDC = "USDC",
|
|
164
167
|
wstETH = "wstETH",
|
|
165
168
|
EURC = "EURC",
|
|
166
|
-
sUSDS = "sUSDS"
|
|
169
|
+
sUSDS = "sUSDS",
|
|
170
|
+
GHO = "GHO"
|
|
167
171
|
}
|
|
168
172
|
export type FluidDepositTokenByNetwork = {
|
|
169
173
|
[NetworkNumber.Eth]: FluidMainnetDepositToken;
|
package/esm/types/fluid.js
CHANGED
|
@@ -133,6 +133,7 @@ export var FluidMainnetDepositToken;
|
|
|
133
133
|
FluidMainnetDepositToken["USDT"] = "USDT";
|
|
134
134
|
FluidMainnetDepositToken["GHO"] = "GHO";
|
|
135
135
|
FluidMainnetDepositToken["sUSDS"] = "sUSDS";
|
|
136
|
+
FluidMainnetDepositToken["USDtb"] = "USDtb";
|
|
136
137
|
})(FluidMainnetDepositToken || (FluidMainnetDepositToken = {}));
|
|
137
138
|
export var FluidArbitrumDepositToken;
|
|
138
139
|
(function (FluidArbitrumDepositToken) {
|
|
@@ -141,6 +142,8 @@ export var FluidArbitrumDepositToken;
|
|
|
141
142
|
FluidArbitrumDepositToken["USDC"] = "USDC";
|
|
142
143
|
FluidArbitrumDepositToken["USDT"] = "USDT";
|
|
143
144
|
FluidArbitrumDepositToken["ARB"] = "ARB";
|
|
145
|
+
FluidArbitrumDepositToken["GHO"] = "GHO";
|
|
146
|
+
FluidArbitrumDepositToken["sUSDS"] = "sUSDS";
|
|
144
147
|
})(FluidArbitrumDepositToken || (FluidArbitrumDepositToken = {}));
|
|
145
148
|
export var FluidBaseDepositToken;
|
|
146
149
|
(function (FluidBaseDepositToken) {
|
|
@@ -149,6 +152,7 @@ export var FluidBaseDepositToken;
|
|
|
149
152
|
FluidBaseDepositToken["wstETH"] = "wstETH";
|
|
150
153
|
FluidBaseDepositToken["EURC"] = "EURC";
|
|
151
154
|
FluidBaseDepositToken["sUSDS"] = "sUSDS";
|
|
155
|
+
FluidBaseDepositToken["GHO"] = "GHO";
|
|
152
156
|
})(FluidBaseDepositToken || (FluidBaseDepositToken = {}));
|
|
153
157
|
export var FluidVaultType;
|
|
154
158
|
(function (FluidVaultType) {
|
package/esm/types/spark.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EModeCategoriesData } from './aave';
|
|
1
2
|
import { EthAddress, MMAssetData, MMPositionData, MMUsedAsset, NetworkNumber } from './common';
|
|
2
3
|
export declare enum SparkVersions {
|
|
3
4
|
SparkV1 = "v1default"
|
|
@@ -53,6 +54,7 @@ export interface SparkAssetsData {
|
|
|
53
54
|
}
|
|
54
55
|
export type SparkMarketsData = {
|
|
55
56
|
assetsData: SparkAssetsData;
|
|
57
|
+
eModeCategoriesData: EModeCategoriesData;
|
|
56
58
|
};
|
|
57
59
|
export interface SparkUsedAsset extends MMUsedAsset {
|
|
58
60
|
stableBorrowRate: string;
|
|
@@ -71,7 +73,7 @@ export interface SparkUsedAssets {
|
|
|
71
73
|
export interface SparkHelperCommon {
|
|
72
74
|
usedAssets: SparkUsedAssets;
|
|
73
75
|
eModeCategory: number;
|
|
74
|
-
|
|
76
|
+
eModeCategoriesData?: EModeCategoriesData;
|
|
75
77
|
assetsData: SparkAssetsData;
|
|
76
78
|
selectedMarket?: SparkMarketData;
|
|
77
79
|
network?: NetworkNumber;
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@defisaver/positions-sdk",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "./cjs/index.js",
|
|
6
|
-
"module": "./esm/index.js",
|
|
7
|
-
"types": "./esm/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
|
|
10
|
-
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
-
"build": "npm run lint && npm run build:cjs && npm run build:esm",
|
|
12
|
-
"dev": "tsc -p tsconfig.json --watch",
|
|
13
|
-
"lint": "eslint src/ --fix",
|
|
14
|
-
"lint-check": "eslint src/",
|
|
15
|
-
"test": "mocha tests
|
|
16
|
-
"test-single": "mocha ./tests/$npm_config_name.ts",
|
|
17
|
-
"test:debugger": "mocha --inspect-brk tests/*",
|
|
18
|
-
"version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
|
|
19
|
-
},
|
|
20
|
-
"keywords": [],
|
|
21
|
-
"author": "",
|
|
22
|
-
"license": "ISC",
|
|
23
|
-
"dependencies": {
|
|
24
|
-
"@defisaver/tokens": "^1.7.5",
|
|
25
|
-
"@types/lodash": "^4.17.15",
|
|
26
|
-
"@types/memoizee": "^0.4.12",
|
|
27
|
-
"decimal.js": "^10.6.0",
|
|
28
|
-
"lodash": "^4.17.21",
|
|
29
|
-
"memoizee": "^0.4.17",
|
|
30
|
-
"viem": "^2.
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@defisaver/eslint-config": "^1.0.1",
|
|
34
|
-
"@metamask/eth-json-rpc-middleware": "^15.0.1",
|
|
35
|
-
"@metamask/eth-json-rpc-provider": "^4.1.6",
|
|
36
|
-
"@types/chai": "^5.0.0",
|
|
37
|
-
"@types/mocha": "^10.0.9",
|
|
38
|
-
"chai": "^4.3.8",
|
|
39
|
-
"dotenv": "^16.3.1",
|
|
40
|
-
"eslint": "^8.49.0",
|
|
41
|
-
"eslint-plugin-import": "^2.31.0",
|
|
42
|
-
"mocha": "^10.2.0",
|
|
43
|
-
"nock": "^14.0.0",
|
|
44
|
-
"ts-node": "^10.9.2",
|
|
45
|
-
"typescript": "^5.2.2"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@defisaver/positions-sdk",
|
|
3
|
+
"version": "2.1.9-dev-spark-1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./cjs/index.js",
|
|
6
|
+
"module": "./esm/index.js",
|
|
7
|
+
"types": "./esm/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json",
|
|
10
|
+
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
|
|
11
|
+
"build": "npm run lint && npm run build:cjs && npm run build:esm",
|
|
12
|
+
"dev": "tsc -p tsconfig.json --watch",
|
|
13
|
+
"lint": "eslint src/ --fix",
|
|
14
|
+
"lint-check": "eslint src/",
|
|
15
|
+
"test": "mocha tests/spark.ts",
|
|
16
|
+
"test-single": "mocha ./tests/$npm_config_name.ts",
|
|
17
|
+
"test:debugger": "mocha --inspect-brk tests/*",
|
|
18
|
+
"version-bump": "git commit -am \"Version bump to $(npm version patch | cut -c 2-)\""
|
|
19
|
+
},
|
|
20
|
+
"keywords": [],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@defisaver/tokens": "^1.7.5",
|
|
25
|
+
"@types/lodash": "^4.17.15",
|
|
26
|
+
"@types/memoizee": "^0.4.12",
|
|
27
|
+
"decimal.js": "^10.6.0",
|
|
28
|
+
"lodash": "^4.17.21",
|
|
29
|
+
"memoizee": "^0.4.17",
|
|
30
|
+
"viem": "^2.37.9"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@defisaver/eslint-config": "^1.0.1",
|
|
34
|
+
"@metamask/eth-json-rpc-middleware": "^15.0.1",
|
|
35
|
+
"@metamask/eth-json-rpc-provider": "^4.1.6",
|
|
36
|
+
"@types/chai": "^5.0.0",
|
|
37
|
+
"@types/mocha": "^10.0.9",
|
|
38
|
+
"chai": "^4.3.8",
|
|
39
|
+
"dotenv": "^16.3.1",
|
|
40
|
+
"eslint": "^8.49.0",
|
|
41
|
+
"eslint-plugin-import": "^2.31.0",
|
|
42
|
+
"mocha": "^10.2.0",
|
|
43
|
+
"nock": "^14.0.0",
|
|
44
|
+
"ts-node": "^10.9.2",
|
|
45
|
+
"typescript": "^5.2.2"
|
|
46
|
+
}
|
|
47
|
+
}
|