@defisaver/positions-sdk 2.1.22-dev-savings-5 → 2.1.22-dev-savings-6
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.
|
@@ -5,3 +5,5 @@ import * as yearnVaultsOptions from './options';
|
|
|
5
5
|
export { yearnVaultsOptions, };
|
|
6
6
|
export declare const _getYearnVaultData: (provider: Client, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]) => Promise<SavingsVaultData>;
|
|
7
7
|
export declare function getYearnVaultData(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]): Promise<SavingsVaultData>;
|
|
8
|
+
export declare const _getYearnVaultExchangeRate: (provider: Client, yearnVault: YearnVault) => Promise<string>;
|
|
9
|
+
export declare function getYearnVaultExchangeRate(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault): Promise<string>;
|
|
@@ -45,8 +45,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports._getYearnVaultData = exports.yearnVaultsOptions = void 0;
|
|
48
|
+
exports._getYearnVaultExchangeRate = exports._getYearnVaultData = exports.yearnVaultsOptions = void 0;
|
|
49
49
|
exports.getYearnVaultData = getYearnVaultData;
|
|
50
|
+
exports.getYearnVaultExchangeRate = getYearnVaultExchangeRate;
|
|
50
51
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
51
52
|
const tokens_1 = require("@defisaver/tokens");
|
|
52
53
|
const viem_1 = require("../../services/viem");
|
|
@@ -95,3 +96,18 @@ function getYearnVaultData(provider, network, yearnVault, accounts) {
|
|
|
95
96
|
}), network, yearnVault, accounts);
|
|
96
97
|
});
|
|
97
98
|
}
|
|
99
|
+
const _getYearnVaultExchangeRate = (provider, yearnVault) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const yearnVaultContract = (0, contracts_1.getYearnVaultContractViem)(provider, yearnVault.address);
|
|
101
|
+
const [tokenSupply, underlyingSupply] = yield Promise.all([
|
|
102
|
+
yearnVaultContract.read.totalSupply(),
|
|
103
|
+
yearnVaultContract.read.totalAssets(),
|
|
104
|
+
]);
|
|
105
|
+
const exchangeRate = new decimal_js_1.default(underlyingSupply).div(tokenSupply).toString();
|
|
106
|
+
return exchangeRate;
|
|
107
|
+
});
|
|
108
|
+
exports._getYearnVaultExchangeRate = _getYearnVaultExchangeRate;
|
|
109
|
+
function getYearnVaultExchangeRate(provider, network, yearnVault) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
return (0, exports._getYearnVaultExchangeRate)((0, viem_1.getViemProvider)(provider, network), yearnVault);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -5,3 +5,5 @@ import * as yearnVaultsOptions from './options';
|
|
|
5
5
|
export { yearnVaultsOptions, };
|
|
6
6
|
export declare const _getYearnVaultData: (provider: Client, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]) => Promise<SavingsVaultData>;
|
|
7
7
|
export declare function getYearnVaultData(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault, accounts: EthAddress[]): Promise<SavingsVaultData>;
|
|
8
|
+
export declare const _getYearnVaultExchangeRate: (provider: Client, yearnVault: YearnVault) => Promise<string>;
|
|
9
|
+
export declare function getYearnVaultExchangeRate(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault): Promise<string>;
|
|
@@ -54,3 +54,17 @@ export function getYearnVaultData(provider, network, yearnVault, accounts) {
|
|
|
54
54
|
}), network, yearnVault, accounts);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
export const _getYearnVaultExchangeRate = (provider, yearnVault) => __awaiter(void 0, void 0, void 0, function* () {
|
|
58
|
+
const yearnVaultContract = getYearnVaultContractViem(provider, yearnVault.address);
|
|
59
|
+
const [tokenSupply, underlyingSupply] = yield Promise.all([
|
|
60
|
+
yearnVaultContract.read.totalSupply(),
|
|
61
|
+
yearnVaultContract.read.totalAssets(),
|
|
62
|
+
]);
|
|
63
|
+
const exchangeRate = new Dec(underlyingSupply).div(tokenSupply).toString();
|
|
64
|
+
return exchangeRate;
|
|
65
|
+
});
|
|
66
|
+
export function getYearnVaultExchangeRate(provider, network, yearnVault) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
return _getYearnVaultExchangeRate(getViemProvider(provider, network), yearnVault);
|
|
69
|
+
});
|
|
70
|
+
}
|
package/package.json
CHANGED
|
@@ -55,4 +55,20 @@ export async function getYearnVaultData(provider: EthereumProvider, network: Net
|
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
}), network, yearnVault, accounts);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const _getYearnVaultExchangeRate = async (provider: Client, yearnVault: YearnVault): Promise<string> => {
|
|
61
|
+
const yearnVaultContract = getYearnVaultContractViem(provider, yearnVault.address);
|
|
62
|
+
|
|
63
|
+
const [tokenSupply, underlyingSupply] = await Promise.all([
|
|
64
|
+
yearnVaultContract.read.totalSupply(),
|
|
65
|
+
yearnVaultContract.read.totalAssets(),
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
const exchangeRate = new Dec(underlyingSupply).div(tokenSupply).toString();
|
|
69
|
+
return exchangeRate;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export async function getYearnVaultExchangeRate(provider: EthereumProvider, network: NetworkNumber, yearnVault: YearnVault): Promise<string> {
|
|
73
|
+
return _getYearnVaultExchangeRate(getViemProvider(provider, network), yearnVault);
|
|
58
74
|
}
|