@defisaver/positions-sdk 2.1.36 → 2.1.38
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/cjs/config/contracts.d.ts +42 -0
- package/cjs/config/contracts.js +4 -1
- package/cjs/contracts.d.ts +205 -0
- package/cjs/contracts.js +11 -2
- package/cjs/savings/index.d.ts +4 -3
- package/cjs/savings/index.js +14 -1
- package/cjs/savings/yearnV3Vaults/index.d.ts +7 -0
- package/cjs/savings/yearnV3Vaults/index.js +97 -0
- package/cjs/savings/yearnV3Vaults/options.d.ts +8 -0
- package/cjs/savings/yearnV3Vaults/options.js +53 -0
- package/cjs/savings/yearnVaults/options.js +3 -3
- package/cjs/types/savings/index.d.ts +3 -1
- package/cjs/types/savings/index.js +1 -0
- package/cjs/types/savings/yearnV3Vaults.d.ts +16 -0
- package/cjs/types/savings/yearnV3Vaults.js +11 -0
- package/esm/config/contracts.d.ts +42 -0
- package/esm/config/contracts.js +3 -0
- package/esm/contracts.d.ts +205 -0
- package/esm/contracts.js +8 -0
- package/esm/savings/index.d.ts +4 -3
- package/esm/savings/index.js +13 -1
- package/esm/savings/yearnV3Vaults/index.d.ts +7 -0
- package/esm/savings/yearnV3Vaults/index.js +56 -0
- package/esm/savings/yearnV3Vaults/options.d.ts +8 -0
- package/esm/savings/yearnV3Vaults/options.js +49 -0
- package/esm/savings/yearnVaults/options.js +3 -3
- package/esm/types/savings/index.d.ts +3 -1
- package/esm/types/savings/index.js +1 -0
- package/esm/types/savings/yearnV3Vaults.d.ts +16 -0
- package/esm/types/savings/yearnV3Vaults.js +8 -0
- package/package.json +1 -1
- package/src/config/contracts.ts +3 -0
- package/src/contracts.ts +9 -0
- package/src/savings/index.ts +13 -0
- package/src/savings/yearnV3Vaults/index.ts +61 -0
- package/src/savings/yearnV3Vaults/options.ts +56 -0
- package/src/savings/yearnVaults/options.ts +3 -3
- package/src/types/savings/index.ts +3 -1
- package/src/types/savings/yearnV3Vaults.ts +18 -0
|
@@ -3,12 +3,14 @@ import { MakerDsrType } from './makerDsr';
|
|
|
3
3
|
import { MorphoVaultType } from './morphoVaults';
|
|
4
4
|
import { SkySavingsType } from './sky';
|
|
5
5
|
import { SparkSavingsVaultType } from './sparkSavingsVaults';
|
|
6
|
+
import { YearnV3VaultType } from './yearnV3Vaults';
|
|
6
7
|
import { YearnVaultType } from './yearnVaults';
|
|
7
8
|
export * from './morphoVaults';
|
|
8
9
|
export * from './yearnVaults';
|
|
9
10
|
export * from './makerDsr';
|
|
10
11
|
export * from './sky';
|
|
11
12
|
export * from './sparkSavingsVaults';
|
|
13
|
+
export * from './yearnV3Vaults';
|
|
12
14
|
export interface SavingsVaultData {
|
|
13
15
|
poolSize: string;
|
|
14
16
|
liquidity: string;
|
|
@@ -16,4 +18,4 @@ export interface SavingsVaultData {
|
|
|
16
18
|
asset: string;
|
|
17
19
|
optionType: string;
|
|
18
20
|
}
|
|
19
|
-
export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType, SavingsVaultData>>;
|
|
21
|
+
export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType | YearnV3VaultType, SavingsVaultData>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EthAddress } from '../common';
|
|
2
|
+
export declare enum YearnV3VaultType {
|
|
3
|
+
YearnVaultV3USDC = "yearn_v3_vault_usdc",
|
|
4
|
+
YearnVaultV3USDS = "yearn_v3_vault_usds",
|
|
5
|
+
YearnVaultV3USDT = "yearn_v3_vault_usdt",
|
|
6
|
+
YearnVaultV3DAI = "yearn_v3_vault_dai",
|
|
7
|
+
YearnVaultV3WETH_1 = "yearn_v3_vault_weth_1"
|
|
8
|
+
}
|
|
9
|
+
export interface YearnV3Vault {
|
|
10
|
+
type: YearnV3VaultType;
|
|
11
|
+
address: EthAddress;
|
|
12
|
+
asset: string;
|
|
13
|
+
name: string;
|
|
14
|
+
deploymentBlock: number;
|
|
15
|
+
isLegacy: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.YearnV3VaultType = void 0;
|
|
4
|
+
var YearnV3VaultType;
|
|
5
|
+
(function (YearnV3VaultType) {
|
|
6
|
+
YearnV3VaultType["YearnVaultV3USDC"] = "yearn_v3_vault_usdc";
|
|
7
|
+
YearnV3VaultType["YearnVaultV3USDS"] = "yearn_v3_vault_usds";
|
|
8
|
+
YearnV3VaultType["YearnVaultV3USDT"] = "yearn_v3_vault_usdt";
|
|
9
|
+
YearnV3VaultType["YearnVaultV3DAI"] = "yearn_v3_vault_dai";
|
|
10
|
+
YearnV3VaultType["YearnVaultV3WETH_1"] = "yearn_v3_vault_weth_1";
|
|
11
|
+
})(YearnV3VaultType || (exports.YearnV3VaultType = YearnV3VaultType = {}));
|
|
@@ -85483,3 +85483,45 @@ export declare const SkySavings: {
|
|
|
85483
85483
|
};
|
|
85484
85484
|
};
|
|
85485
85485
|
};
|
|
85486
|
+
export declare const YearnV3Vault: {
|
|
85487
|
+
readonly abi: readonly [{
|
|
85488
|
+
readonly stateMutability: "view";
|
|
85489
|
+
readonly type: "function";
|
|
85490
|
+
readonly name: "balanceOf";
|
|
85491
|
+
readonly inputs: readonly [{
|
|
85492
|
+
readonly name: "addr";
|
|
85493
|
+
readonly type: "address";
|
|
85494
|
+
}];
|
|
85495
|
+
readonly outputs: readonly [{
|
|
85496
|
+
readonly name: "";
|
|
85497
|
+
readonly type: "uint256";
|
|
85498
|
+
}];
|
|
85499
|
+
}, {
|
|
85500
|
+
readonly stateMutability: "view";
|
|
85501
|
+
readonly type: "function";
|
|
85502
|
+
readonly name: "totalAssets";
|
|
85503
|
+
readonly inputs: readonly [];
|
|
85504
|
+
readonly outputs: readonly [{
|
|
85505
|
+
readonly name: "";
|
|
85506
|
+
readonly type: "uint256";
|
|
85507
|
+
}];
|
|
85508
|
+
}, {
|
|
85509
|
+
readonly stateMutability: "view";
|
|
85510
|
+
readonly type: "function";
|
|
85511
|
+
readonly name: "totalDebt";
|
|
85512
|
+
readonly inputs: readonly [];
|
|
85513
|
+
readonly outputs: readonly [{
|
|
85514
|
+
readonly name: "";
|
|
85515
|
+
readonly type: "uint256";
|
|
85516
|
+
}];
|
|
85517
|
+
}, {
|
|
85518
|
+
readonly stateMutability: "view";
|
|
85519
|
+
readonly type: "function";
|
|
85520
|
+
readonly name: "totalSupply";
|
|
85521
|
+
readonly inputs: readonly [];
|
|
85522
|
+
readonly outputs: readonly [{
|
|
85523
|
+
readonly name: "";
|
|
85524
|
+
readonly type: "uint256";
|
|
85525
|
+
}];
|
|
85526
|
+
}];
|
|
85527
|
+
};
|
package/esm/config/contracts.js
CHANGED
|
@@ -1289,3 +1289,6 @@ export const SkySavings = {
|
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
1291
|
};
|
|
1292
|
+
export const YearnV3Vault = {
|
|
1293
|
+
"abi": [{ "stateMutability": "view", "type": "function", "name": "balanceOf", "inputs": [{ "name": "addr", "type": "address" }], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "totalAssets", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "totalDebt", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }, { "stateMutability": "view", "type": "function", "name": "totalSupply", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] }]
|
|
1294
|
+
};
|
package/esm/contracts.d.ts
CHANGED
|
@@ -47908,6 +47908,211 @@ export declare const getErc20ContractViem: (client: Client, address: HexString)
|
|
|
47908
47908
|
readonly type: "event";
|
|
47909
47909
|
}];
|
|
47910
47910
|
};
|
|
47911
|
+
export declare const getYearnV3VaultContractViem: (client: Client, address: HexString) => {
|
|
47912
|
+
read: {
|
|
47913
|
+
totalSupply: (options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
47914
|
+
readonly stateMutability: "view";
|
|
47915
|
+
readonly type: "function";
|
|
47916
|
+
readonly name: "balanceOf";
|
|
47917
|
+
readonly inputs: readonly [{
|
|
47918
|
+
readonly name: "addr";
|
|
47919
|
+
readonly type: "address";
|
|
47920
|
+
}];
|
|
47921
|
+
readonly outputs: readonly [{
|
|
47922
|
+
readonly name: "";
|
|
47923
|
+
readonly type: "uint256";
|
|
47924
|
+
}];
|
|
47925
|
+
}, {
|
|
47926
|
+
readonly stateMutability: "view";
|
|
47927
|
+
readonly type: "function";
|
|
47928
|
+
readonly name: "totalAssets";
|
|
47929
|
+
readonly inputs: readonly [];
|
|
47930
|
+
readonly outputs: readonly [{
|
|
47931
|
+
readonly name: "";
|
|
47932
|
+
readonly type: "uint256";
|
|
47933
|
+
}];
|
|
47934
|
+
}, {
|
|
47935
|
+
readonly stateMutability: "view";
|
|
47936
|
+
readonly type: "function";
|
|
47937
|
+
readonly name: "totalDebt";
|
|
47938
|
+
readonly inputs: readonly [];
|
|
47939
|
+
readonly outputs: readonly [{
|
|
47940
|
+
readonly name: "";
|
|
47941
|
+
readonly type: "uint256";
|
|
47942
|
+
}];
|
|
47943
|
+
}, {
|
|
47944
|
+
readonly stateMutability: "view";
|
|
47945
|
+
readonly type: "function";
|
|
47946
|
+
readonly name: "totalSupply";
|
|
47947
|
+
readonly inputs: readonly [];
|
|
47948
|
+
readonly outputs: readonly [{
|
|
47949
|
+
readonly name: "";
|
|
47950
|
+
readonly type: "uint256";
|
|
47951
|
+
}];
|
|
47952
|
+
}], "totalSupply", readonly []>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
47953
|
+
totalDebt: (options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
47954
|
+
readonly stateMutability: "view";
|
|
47955
|
+
readonly type: "function";
|
|
47956
|
+
readonly name: "balanceOf";
|
|
47957
|
+
readonly inputs: readonly [{
|
|
47958
|
+
readonly name: "addr";
|
|
47959
|
+
readonly type: "address";
|
|
47960
|
+
}];
|
|
47961
|
+
readonly outputs: readonly [{
|
|
47962
|
+
readonly name: "";
|
|
47963
|
+
readonly type: "uint256";
|
|
47964
|
+
}];
|
|
47965
|
+
}, {
|
|
47966
|
+
readonly stateMutability: "view";
|
|
47967
|
+
readonly type: "function";
|
|
47968
|
+
readonly name: "totalAssets";
|
|
47969
|
+
readonly inputs: readonly [];
|
|
47970
|
+
readonly outputs: readonly [{
|
|
47971
|
+
readonly name: "";
|
|
47972
|
+
readonly type: "uint256";
|
|
47973
|
+
}];
|
|
47974
|
+
}, {
|
|
47975
|
+
readonly stateMutability: "view";
|
|
47976
|
+
readonly type: "function";
|
|
47977
|
+
readonly name: "totalDebt";
|
|
47978
|
+
readonly inputs: readonly [];
|
|
47979
|
+
readonly outputs: readonly [{
|
|
47980
|
+
readonly name: "";
|
|
47981
|
+
readonly type: "uint256";
|
|
47982
|
+
}];
|
|
47983
|
+
}, {
|
|
47984
|
+
readonly stateMutability: "view";
|
|
47985
|
+
readonly type: "function";
|
|
47986
|
+
readonly name: "totalSupply";
|
|
47987
|
+
readonly inputs: readonly [];
|
|
47988
|
+
readonly outputs: readonly [{
|
|
47989
|
+
readonly name: "";
|
|
47990
|
+
readonly type: "uint256";
|
|
47991
|
+
}];
|
|
47992
|
+
}], "totalDebt", readonly []>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
47993
|
+
balanceOf: (args: readonly [`0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
47994
|
+
readonly stateMutability: "view";
|
|
47995
|
+
readonly type: "function";
|
|
47996
|
+
readonly name: "balanceOf";
|
|
47997
|
+
readonly inputs: readonly [{
|
|
47998
|
+
readonly name: "addr";
|
|
47999
|
+
readonly type: "address";
|
|
48000
|
+
}];
|
|
48001
|
+
readonly outputs: readonly [{
|
|
48002
|
+
readonly name: "";
|
|
48003
|
+
readonly type: "uint256";
|
|
48004
|
+
}];
|
|
48005
|
+
}, {
|
|
48006
|
+
readonly stateMutability: "view";
|
|
48007
|
+
readonly type: "function";
|
|
48008
|
+
readonly name: "totalAssets";
|
|
48009
|
+
readonly inputs: readonly [];
|
|
48010
|
+
readonly outputs: readonly [{
|
|
48011
|
+
readonly name: "";
|
|
48012
|
+
readonly type: "uint256";
|
|
48013
|
+
}];
|
|
48014
|
+
}, {
|
|
48015
|
+
readonly stateMutability: "view";
|
|
48016
|
+
readonly type: "function";
|
|
48017
|
+
readonly name: "totalDebt";
|
|
48018
|
+
readonly inputs: readonly [];
|
|
48019
|
+
readonly outputs: readonly [{
|
|
48020
|
+
readonly name: "";
|
|
48021
|
+
readonly type: "uint256";
|
|
48022
|
+
}];
|
|
48023
|
+
}, {
|
|
48024
|
+
readonly stateMutability: "view";
|
|
48025
|
+
readonly type: "function";
|
|
48026
|
+
readonly name: "totalSupply";
|
|
48027
|
+
readonly inputs: readonly [];
|
|
48028
|
+
readonly outputs: readonly [{
|
|
48029
|
+
readonly name: "";
|
|
48030
|
+
readonly type: "uint256";
|
|
48031
|
+
}];
|
|
48032
|
+
}], "balanceOf", readonly [`0x${string}`]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
48033
|
+
totalAssets: (options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
48034
|
+
readonly stateMutability: "view";
|
|
48035
|
+
readonly type: "function";
|
|
48036
|
+
readonly name: "balanceOf";
|
|
48037
|
+
readonly inputs: readonly [{
|
|
48038
|
+
readonly name: "addr";
|
|
48039
|
+
readonly type: "address";
|
|
48040
|
+
}];
|
|
48041
|
+
readonly outputs: readonly [{
|
|
48042
|
+
readonly name: "";
|
|
48043
|
+
readonly type: "uint256";
|
|
48044
|
+
}];
|
|
48045
|
+
}, {
|
|
48046
|
+
readonly stateMutability: "view";
|
|
48047
|
+
readonly type: "function";
|
|
48048
|
+
readonly name: "totalAssets";
|
|
48049
|
+
readonly inputs: readonly [];
|
|
48050
|
+
readonly outputs: readonly [{
|
|
48051
|
+
readonly name: "";
|
|
48052
|
+
readonly type: "uint256";
|
|
48053
|
+
}];
|
|
48054
|
+
}, {
|
|
48055
|
+
readonly stateMutability: "view";
|
|
48056
|
+
readonly type: "function";
|
|
48057
|
+
readonly name: "totalDebt";
|
|
48058
|
+
readonly inputs: readonly [];
|
|
48059
|
+
readonly outputs: readonly [{
|
|
48060
|
+
readonly name: "";
|
|
48061
|
+
readonly type: "uint256";
|
|
48062
|
+
}];
|
|
48063
|
+
}, {
|
|
48064
|
+
readonly stateMutability: "view";
|
|
48065
|
+
readonly type: "function";
|
|
48066
|
+
readonly name: "totalSupply";
|
|
48067
|
+
readonly inputs: readonly [];
|
|
48068
|
+
readonly outputs: readonly [{
|
|
48069
|
+
readonly name: "";
|
|
48070
|
+
readonly type: "uint256";
|
|
48071
|
+
}];
|
|
48072
|
+
}], "totalAssets", readonly []>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
48073
|
+
};
|
|
48074
|
+
address: `0x${string}`;
|
|
48075
|
+
abi: readonly [{
|
|
48076
|
+
readonly stateMutability: "view";
|
|
48077
|
+
readonly type: "function";
|
|
48078
|
+
readonly name: "balanceOf";
|
|
48079
|
+
readonly inputs: readonly [{
|
|
48080
|
+
readonly name: "addr";
|
|
48081
|
+
readonly type: "address";
|
|
48082
|
+
}];
|
|
48083
|
+
readonly outputs: readonly [{
|
|
48084
|
+
readonly name: "";
|
|
48085
|
+
readonly type: "uint256";
|
|
48086
|
+
}];
|
|
48087
|
+
}, {
|
|
48088
|
+
readonly stateMutability: "view";
|
|
48089
|
+
readonly type: "function";
|
|
48090
|
+
readonly name: "totalAssets";
|
|
48091
|
+
readonly inputs: readonly [];
|
|
48092
|
+
readonly outputs: readonly [{
|
|
48093
|
+
readonly name: "";
|
|
48094
|
+
readonly type: "uint256";
|
|
48095
|
+
}];
|
|
48096
|
+
}, {
|
|
48097
|
+
readonly stateMutability: "view";
|
|
48098
|
+
readonly type: "function";
|
|
48099
|
+
readonly name: "totalDebt";
|
|
48100
|
+
readonly inputs: readonly [];
|
|
48101
|
+
readonly outputs: readonly [{
|
|
48102
|
+
readonly name: "";
|
|
48103
|
+
readonly type: "uint256";
|
|
48104
|
+
}];
|
|
48105
|
+
}, {
|
|
48106
|
+
readonly stateMutability: "view";
|
|
48107
|
+
readonly type: "function";
|
|
48108
|
+
readonly name: "totalSupply";
|
|
48109
|
+
readonly inputs: readonly [];
|
|
48110
|
+
readonly outputs: readonly [{
|
|
48111
|
+
readonly name: "";
|
|
48112
|
+
readonly type: "uint256";
|
|
48113
|
+
}];
|
|
48114
|
+
}];
|
|
48115
|
+
};
|
|
47911
48116
|
export declare const MorphoBlueViewContractViem: (client: Client, network: NetworkNumber, block?: Blockish) => {
|
|
47912
48117
|
read: {
|
|
47913
48118
|
getApyAfterValuesEstimation: (args: readonly [{
|
package/esm/contracts.js
CHANGED
|
@@ -77,6 +77,14 @@ export const getErc20ContractViem = (client, address) => {
|
|
|
77
77
|
client,
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
|
+
export const getYearnV3VaultContractViem = (client, address) => {
|
|
81
|
+
const abi = getConfigContractAbi('YearnV3Vault');
|
|
82
|
+
return getContract({
|
|
83
|
+
address,
|
|
84
|
+
abi,
|
|
85
|
+
client,
|
|
86
|
+
});
|
|
87
|
+
};
|
|
80
88
|
export const MorphoBlueViewContractViem = createViemContractFromConfigFunc('MorphoBlueView');
|
|
81
89
|
export const AaveLoanInfoV2ContractViem = createViemContractFromConfigFunc('AaveLoanInfoV2');
|
|
82
90
|
export const AaveV3ViewContractViem = createViemContractFromConfigFunc('AaveV3View');
|
package/esm/savings/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { MakerDsrType, MorphoVaultType, SkySavingsType, SparkSavingsVaultType, YearnVaultType } from '../types';
|
|
1
|
+
import { MakerDsrType, MorphoVaultType, SkySavingsType, SparkSavingsVaultType, YearnV3VaultType, YearnVaultType } from '../types';
|
|
2
2
|
import { EthAddress, EthereumProvider, NetworkNumber } from '../types/common';
|
|
3
3
|
import * as morphoVaults from './morphoVaults';
|
|
4
4
|
import * as yearnVaults from './yearnVaults';
|
|
5
5
|
import * as makerDsr from './makerDsr';
|
|
6
6
|
import * as skyOptions from './skyOptions';
|
|
7
7
|
import * as sparkSavingsVaults from './sparkSavingsVaults';
|
|
8
|
-
|
|
9
|
-
export
|
|
8
|
+
import * as yearnV3Vaults from './yearnV3Vaults';
|
|
9
|
+
export { morphoVaults, yearnVaults, makerDsr, skyOptions, sparkSavingsVaults, yearnV3Vaults, };
|
|
10
|
+
export declare const getSavingsData: (provider: EthereumProvider, network: NetworkNumber, accounts: EthAddress[]) => Promise<Partial<Record<MakerDsrType | MorphoVaultType | SkySavingsType | SparkSavingsVaultType | YearnV3VaultType | YearnVaultType, import("../types").SavingsVaultData>>>;
|
package/esm/savings/index.js
CHANGED
|
@@ -13,11 +13,13 @@ import * as yearnVaults from './yearnVaults';
|
|
|
13
13
|
import * as makerDsr from './makerDsr';
|
|
14
14
|
import * as skyOptions from './skyOptions';
|
|
15
15
|
import * as sparkSavingsVaults from './sparkSavingsVaults';
|
|
16
|
-
|
|
16
|
+
import * as yearnV3Vaults from './yearnV3Vaults';
|
|
17
|
+
export { morphoVaults, yearnVaults, makerDsr, skyOptions, sparkSavingsVaults, yearnV3Vaults, };
|
|
17
18
|
export const getSavingsData = (provider, network, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
19
|
const morphoVaultsList = Object.keys(morphoVaults.morphoVaultsOptions.MORPHO_VAULTS);
|
|
19
20
|
const yearnVaultsList = Object.keys(yearnVaults.yearnVaultsOptions.YEARN_VAULTS);
|
|
20
21
|
const sparkSavingsVaultsList = Object.keys(sparkSavingsVaults.sparkSavingsVaultsOptions.SPARK_SAVINGS_VAULTS);
|
|
22
|
+
const yearnV3VaultsList = Object.keys(yearnV3Vaults.yearnV3VaultsOptions.YEARN_V3_VAULTS);
|
|
21
23
|
const savingsData = {};
|
|
22
24
|
yield Promise.all([
|
|
23
25
|
...morphoVaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -50,6 +52,16 @@ export const getSavingsData = (provider, network, accounts) => __awaiter(void 0,
|
|
|
50
52
|
console.error(`[getSavingsData] Error fetching yearn vault ${vaultKey}:`, err);
|
|
51
53
|
}
|
|
52
54
|
})),
|
|
55
|
+
...yearnV3VaultsList.map((vaultKey) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
try {
|
|
57
|
+
const vault = yearnV3Vaults.yearnV3VaultsOptions.getYearnV3Vault(vaultKey);
|
|
58
|
+
const data = yield yearnV3Vaults.getYearnV3VaultData(provider, network, vault, accounts);
|
|
59
|
+
savingsData[vaultKey] = data;
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
console.error(`[getSavingsData] Error fetching yearn vault ${vaultKey}:`, err);
|
|
63
|
+
}
|
|
64
|
+
})),
|
|
53
65
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
66
|
try {
|
|
55
67
|
const data = yield makerDsr.getMakerDsrData(provider, network, accounts);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Client } from 'viem';
|
|
2
|
+
import { SavingsVaultData, YearnV3Vault } from '../../types';
|
|
3
|
+
import { EthAddress, EthereumProvider, NetworkNumber } from '../../types/common';
|
|
4
|
+
import * as yearnV3VaultsOptions from './options';
|
|
5
|
+
export { yearnV3VaultsOptions, };
|
|
6
|
+
export declare const _getYearnV3VaultData: (provider: Client, network: NetworkNumber, yearnV3Vault: YearnV3Vault, accounts: EthAddress[]) => Promise<SavingsVaultData>;
|
|
7
|
+
export declare function getYearnV3VaultData(provider: EthereumProvider, network: NetworkNumber, yearnV3Vault: YearnV3Vault, accounts: EthAddress[]): Promise<SavingsVaultData>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import Dec from 'decimal.js';
|
|
11
|
+
import { assetAmountInEth } from '@defisaver/tokens';
|
|
12
|
+
import { getViemProvider } from '../../services/viem';
|
|
13
|
+
import * as yearnV3VaultsOptions from './options';
|
|
14
|
+
import { getYearnV3VaultContractViem } from '../../contracts';
|
|
15
|
+
export { yearnV3VaultsOptions, };
|
|
16
|
+
export const _getYearnV3VaultData = (provider, network, yearnV3Vault, accounts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const yearnV3VaultContract = getYearnV3VaultContractViem(provider, yearnV3Vault.address);
|
|
18
|
+
const shares = {};
|
|
19
|
+
const [totalAssets, totalSupply, totalDebt] = yield Promise.all([
|
|
20
|
+
yearnV3VaultContract.read.totalAssets(),
|
|
21
|
+
yearnV3VaultContract.read.totalSupply(),
|
|
22
|
+
yearnV3VaultContract.read.totalDebt(),
|
|
23
|
+
...accounts.map((account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const share = yield yearnV3VaultContract.read.balanceOf([account]);
|
|
25
|
+
shares[account] = share;
|
|
26
|
+
})),
|
|
27
|
+
]);
|
|
28
|
+
const poolSize = assetAmountInEth(totalAssets.toString(), yearnV3Vault.asset);
|
|
29
|
+
const debt = assetAmountInEth(totalDebt.toString(), yearnV3Vault.asset);
|
|
30
|
+
// DEV: Check if true
|
|
31
|
+
const liquidity = poolSize;
|
|
32
|
+
const supplied = {};
|
|
33
|
+
accounts.forEach((account) => {
|
|
34
|
+
const share = shares[account] || BigInt(0);
|
|
35
|
+
supplied[account.toLowerCase()] = assetAmountInEth(new Dec(share).mul(totalAssets).div(totalSupply).toFixed()
|
|
36
|
+
.toString(), yearnV3Vault.asset);
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
poolSize,
|
|
40
|
+
supplied,
|
|
41
|
+
liquidity,
|
|
42
|
+
asset: yearnV3Vault.asset,
|
|
43
|
+
optionType: yearnV3Vault.type,
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
export function getYearnV3VaultData(provider, network, yearnV3Vault, accounts) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return _getYearnV3VaultData(getViemProvider(provider, network, {
|
|
49
|
+
batch: {
|
|
50
|
+
multicall: {
|
|
51
|
+
batchSize: 2500000,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
}), network, yearnV3Vault, accounts);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { YearnV3Vault, YearnV3VaultType } from '../../types';
|
|
2
|
+
export declare const YEARN_V3_VAULT_USDC: YearnV3Vault;
|
|
3
|
+
export declare const YEARN_V3_VAULT_USDS: YearnV3Vault;
|
|
4
|
+
export declare const YEARN_V3_VAULT_DAI: YearnV3Vault;
|
|
5
|
+
export declare const YEARN_V3_VAULT_USDT: YearnV3Vault;
|
|
6
|
+
export declare const YEARN_V3_VAULT_WETH_1: YearnV3Vault;
|
|
7
|
+
export declare const YEARN_V3_VAULTS: Record<YearnV3VaultType, YearnV3Vault>;
|
|
8
|
+
export declare const getYearnV3Vault: (type: YearnV3VaultType) => YearnV3Vault;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { YearnV3VaultType } from '../../types';
|
|
2
|
+
export const YEARN_V3_VAULT_USDC = {
|
|
3
|
+
type: YearnV3VaultType.YearnVaultV3USDC,
|
|
4
|
+
name: 'Yearn V3 USDC',
|
|
5
|
+
address: '0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204',
|
|
6
|
+
asset: 'USDC',
|
|
7
|
+
deploymentBlock: 19419991,
|
|
8
|
+
isLegacy: false,
|
|
9
|
+
};
|
|
10
|
+
export const YEARN_V3_VAULT_USDS = {
|
|
11
|
+
type: YearnV3VaultType.YearnVaultV3USDS,
|
|
12
|
+
name: 'Yearn V3 USDS',
|
|
13
|
+
address: '0x182863131F9a4630fF9E27830d945B1413e347E8',
|
|
14
|
+
asset: 'USDS',
|
|
15
|
+
deploymentBlock: 20917639,
|
|
16
|
+
isLegacy: false,
|
|
17
|
+
};
|
|
18
|
+
export const YEARN_V3_VAULT_DAI = {
|
|
19
|
+
type: YearnV3VaultType.YearnVaultV3DAI,
|
|
20
|
+
name: 'Yearn V3 DAI',
|
|
21
|
+
address: '0x028eC7330ff87667b6dfb0D94b954c820195336c',
|
|
22
|
+
asset: 'DAI',
|
|
23
|
+
deploymentBlock: 19419991,
|
|
24
|
+
isLegacy: false,
|
|
25
|
+
};
|
|
26
|
+
export const YEARN_V3_VAULT_USDT = {
|
|
27
|
+
type: YearnV3VaultType.YearnVaultV3USDT,
|
|
28
|
+
name: 'Yearn V3 USDT',
|
|
29
|
+
address: '0x310B7Ea7475A0B449Cfd73bE81522F1B88eFAFaa',
|
|
30
|
+
asset: 'USDT',
|
|
31
|
+
deploymentBlock: 20369520,
|
|
32
|
+
isLegacy: false,
|
|
33
|
+
};
|
|
34
|
+
export const YEARN_V3_VAULT_WETH_1 = {
|
|
35
|
+
type: YearnV3VaultType.YearnVaultV3WETH_1,
|
|
36
|
+
name: 'Yearn V3 WETH',
|
|
37
|
+
address: '0xc56413869c6CDf96496f2b1eF801fEDBdFA7dDB0',
|
|
38
|
+
asset: 'WETH',
|
|
39
|
+
deploymentBlock: 19419991,
|
|
40
|
+
isLegacy: false,
|
|
41
|
+
};
|
|
42
|
+
export const YEARN_V3_VAULTS = {
|
|
43
|
+
[YearnV3VaultType.YearnVaultV3USDC]: YEARN_V3_VAULT_USDC,
|
|
44
|
+
[YearnV3VaultType.YearnVaultV3USDS]: YEARN_V3_VAULT_USDS,
|
|
45
|
+
[YearnV3VaultType.YearnVaultV3DAI]: YEARN_V3_VAULT_DAI,
|
|
46
|
+
[YearnV3VaultType.YearnVaultV3USDT]: YEARN_V3_VAULT_USDT,
|
|
47
|
+
[YearnV3VaultType.YearnVaultV3WETH_1]: YEARN_V3_VAULT_WETH_1,
|
|
48
|
+
};
|
|
49
|
+
export const getYearnV3Vault = (type) => YEARN_V3_VAULTS[type];
|
|
@@ -4,21 +4,21 @@ export const YEARN_VAULT_DAI = {
|
|
|
4
4
|
address: '0xdA816459F1AB5631232FE5e97a05BBBb94970c95',
|
|
5
5
|
asset: 'DAI',
|
|
6
6
|
deploymentBlock: 12796965,
|
|
7
|
-
isLegacy:
|
|
7
|
+
isLegacy: true,
|
|
8
8
|
};
|
|
9
9
|
export const YEARN_VAULT_USDC = {
|
|
10
10
|
type: YearnVaultType.YearnVaultUSDC,
|
|
11
11
|
address: '0xa354F35829Ae975e850e23e9615b11Da1B3dC4DE',
|
|
12
12
|
asset: 'USDC',
|
|
13
13
|
deploymentBlock: 13513457,
|
|
14
|
-
isLegacy:
|
|
14
|
+
isLegacy: true,
|
|
15
15
|
};
|
|
16
16
|
export const YEARN_VAULT_USDT = {
|
|
17
17
|
type: YearnVaultType.YearnVaultUSDT,
|
|
18
18
|
address: '0x3B27F92C0e212C671EA351827EDF93DB27cc0c65',
|
|
19
19
|
asset: 'USDT',
|
|
20
20
|
deploymentBlock: 14980240,
|
|
21
|
-
isLegacy:
|
|
21
|
+
isLegacy: true,
|
|
22
22
|
};
|
|
23
23
|
export const YEARN_VAULTS = {
|
|
24
24
|
[YearnVaultType.YearnVaultDAI]: YEARN_VAULT_DAI,
|
|
@@ -3,12 +3,14 @@ import { MakerDsrType } from './makerDsr';
|
|
|
3
3
|
import { MorphoVaultType } from './morphoVaults';
|
|
4
4
|
import { SkySavingsType } from './sky';
|
|
5
5
|
import { SparkSavingsVaultType } from './sparkSavingsVaults';
|
|
6
|
+
import { YearnV3VaultType } from './yearnV3Vaults';
|
|
6
7
|
import { YearnVaultType } from './yearnVaults';
|
|
7
8
|
export * from './morphoVaults';
|
|
8
9
|
export * from './yearnVaults';
|
|
9
10
|
export * from './makerDsr';
|
|
10
11
|
export * from './sky';
|
|
11
12
|
export * from './sparkSavingsVaults';
|
|
13
|
+
export * from './yearnV3Vaults';
|
|
12
14
|
export interface SavingsVaultData {
|
|
13
15
|
poolSize: string;
|
|
14
16
|
liquidity: string;
|
|
@@ -16,4 +18,4 @@ export interface SavingsVaultData {
|
|
|
16
18
|
asset: string;
|
|
17
19
|
optionType: string;
|
|
18
20
|
}
|
|
19
|
-
export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType, SavingsVaultData>>;
|
|
21
|
+
export type SavingsData = Partial<Record<MorphoVaultType | YearnVaultType | MakerDsrType | SkySavingsType | SparkSavingsVaultType | YearnV3VaultType, SavingsVaultData>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EthAddress } from '../common';
|
|
2
|
+
export declare enum YearnV3VaultType {
|
|
3
|
+
YearnVaultV3USDC = "yearn_v3_vault_usdc",
|
|
4
|
+
YearnVaultV3USDS = "yearn_v3_vault_usds",
|
|
5
|
+
YearnVaultV3USDT = "yearn_v3_vault_usdt",
|
|
6
|
+
YearnVaultV3DAI = "yearn_v3_vault_dai",
|
|
7
|
+
YearnVaultV3WETH_1 = "yearn_v3_vault_weth_1"
|
|
8
|
+
}
|
|
9
|
+
export interface YearnV3Vault {
|
|
10
|
+
type: YearnV3VaultType;
|
|
11
|
+
address: EthAddress;
|
|
12
|
+
asset: string;
|
|
13
|
+
name: string;
|
|
14
|
+
deploymentBlock: number;
|
|
15
|
+
isLegacy: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var YearnV3VaultType;
|
|
2
|
+
(function (YearnV3VaultType) {
|
|
3
|
+
YearnV3VaultType["YearnVaultV3USDC"] = "yearn_v3_vault_usdc";
|
|
4
|
+
YearnV3VaultType["YearnVaultV3USDS"] = "yearn_v3_vault_usds";
|
|
5
|
+
YearnV3VaultType["YearnVaultV3USDT"] = "yearn_v3_vault_usdt";
|
|
6
|
+
YearnV3VaultType["YearnVaultV3DAI"] = "yearn_v3_vault_dai";
|
|
7
|
+
YearnV3VaultType["YearnVaultV3WETH_1"] = "yearn_v3_vault_weth_1";
|
|
8
|
+
})(YearnV3VaultType || (YearnV3VaultType = {}));
|
package/package.json
CHANGED
package/src/config/contracts.ts
CHANGED
|
@@ -1290,4 +1290,7 @@ export const SkySavings = {
|
|
|
1290
1290
|
"address": "0xa3931d71877C0E7a3148CB7Eb4463524FEc27fbD",
|
|
1291
1291
|
}
|
|
1292
1292
|
}
|
|
1293
|
+
} as const;
|
|
1294
|
+
export const YearnV3Vault = {
|
|
1295
|
+
"abi": [{"stateMutability":"view","type":"function","name":"balanceOf","inputs":[{"name":"addr","type":"address"}],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalAssets","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalDebt","inputs":[],"outputs":[{"name":"","type":"uint256"}]},{"stateMutability":"view","type":"function","name":"totalSupply","inputs":[],"outputs":[{"name":"","type":"uint256"}]}]
|
|
1293
1296
|
} as const;
|
package/src/contracts.ts
CHANGED
|
@@ -103,6 +103,15 @@ export const getErc20ContractViem = (client: Client, address: HexString) => {
|
|
|
103
103
|
});
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
export const getYearnV3VaultContractViem = (client: Client, address: HexString) => {
|
|
107
|
+
const abi = getConfigContractAbi('YearnV3Vault') as typeof configRaw['YearnV3Vault']['abi'];
|
|
108
|
+
return getContract({
|
|
109
|
+
address,
|
|
110
|
+
abi,
|
|
111
|
+
client,
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
106
115
|
export const MorphoBlueViewContractViem = createViemContractFromConfigFunc('MorphoBlueView');
|
|
107
116
|
export const AaveLoanInfoV2ContractViem = createViemContractFromConfigFunc('AaveLoanInfoV2');
|
|
108
117
|
export const AaveV3ViewContractViem = createViemContractFromConfigFunc('AaveV3View');
|