@defisaver/positions-sdk 0.0.69 → 0.0.70
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/aaveV3/index.js +1 -1
- package/cjs/markets/aave/marketAssets.js +1 -1
- package/cjs/markets/llamaLend/index.js +1 -1
- package/cjs/staking/staking.js +11 -4
- package/cjs/types/llamaLend.js +2 -2
- package/esm/aaveV3/index.js +1 -1
- package/esm/markets/aave/marketAssets.js +1 -1
- package/esm/markets/llamaLend/index.js +1 -1
- package/esm/staking/staking.js +11 -4
- package/esm/types/llamaLend.js +2 -2
- package/package.json +1 -1
- package/src/aaveV3/index.ts +1 -1
- package/src/staking/staking.ts +1 -1
package/cjs/aaveV3/index.js
CHANGED
|
@@ -140,7 +140,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
140
140
|
if (nativeAsset && facilitatorsList && discountRate && minDiscountTokenBalance && minGhoBalanceForDiscount && ghoDiscountedPerDiscountToken) {
|
|
141
141
|
const facilitatorBucket = yield ghoContract.methods.getFacilitatorBucket(facilitatorsList[0]).call();
|
|
142
142
|
const availableFacilitatorCap = (0, tokens_1.assetAmountInEth)(new decimal_js_1.default(facilitatorBucket[0]).sub(facilitatorBucket[1]).toString(), 'GHO');
|
|
143
|
-
borrowCap = decimal_js_1.default.min(borrowCap,
|
|
143
|
+
borrowCap = decimal_js_1.default.min(borrowCap, (0, tokens_1.assetAmountInEth)(facilitatorBucket[0], 'GHO')).toString();
|
|
144
144
|
discountRateOnBorrow = (0, exports.aaveV3CalculateDiscountRate)(tokenMarket.totalBorrow.toString(), '3160881469228662060510133', // stkAAVE total supply
|
|
145
145
|
discountRate, minDiscountTokenBalance, minGhoBalanceForDiscount, ghoDiscountedPerDiscountToken);
|
|
146
146
|
}
|
|
@@ -7,7 +7,7 @@ exports.morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WBTC',
|
|
|
7
7
|
exports.morphoAaveV3AssetEthMarket = [
|
|
8
8
|
'ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT',
|
|
9
9
|
];
|
|
10
|
-
exports.aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH'];
|
|
10
|
+
exports.aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH'];
|
|
11
11
|
exports.aaveV3AssetsDefaultMarketOpt = [
|
|
12
12
|
'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
|
|
13
13
|
];
|
|
@@ -44,7 +44,7 @@ const getLlamaLendMarketData = (market, network = 1) => (0, exports.LlamaLendMar
|
|
|
44
44
|
exports.getLlamaLendMarketData = getLlamaLendMarketData;
|
|
45
45
|
const getLlamaLendMarketFromControllerAddress = (controllerAddress, network) => {
|
|
46
46
|
const markets = (0, exports.LlamaLendMarkets)(network);
|
|
47
|
-
const market = Object.values(markets).find((
|
|
47
|
+
const market = Object.values(markets).find((tempMarket) => tempMarket.controllerAddress === controllerAddress);
|
|
48
48
|
if (!market)
|
|
49
49
|
throw new Error('Market not found');
|
|
50
50
|
return market;
|
package/cjs/staking/staking.js
CHANGED
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getSUSDeApy = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const v3_sdk_1 = require("@stakewise/v3-sdk");
|
|
17
18
|
const contracts_1 = require("../contracts");
|
|
18
19
|
const common_1 = require("../types/common");
|
|
19
20
|
const constants_1 = require("../constants");
|
|
@@ -93,12 +94,16 @@ const getSUSDeApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
93
94
|
});
|
|
94
95
|
exports.getSUSDeApy = getSUSDeApy;
|
|
95
96
|
const getWeEthApr = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
-
const res = yield fetch('https://
|
|
97
|
+
const res = yield fetch('https://app.defisaver.com/api/staking/apy?asset=weETH');
|
|
97
98
|
const data = yield res.json();
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
return data.apy;
|
|
100
|
+
});
|
|
101
|
+
const getOsETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const sdk = new v3_sdk_1.StakeWiseSDK({ network: v3_sdk_1.Network.Mainnet });
|
|
103
|
+
const apy = yield sdk.osToken.getAPY();
|
|
104
|
+
return apy;
|
|
100
105
|
});
|
|
101
|
-
exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH'];
|
|
106
|
+
exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH'];
|
|
102
107
|
const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
|
|
103
108
|
try {
|
|
104
109
|
if (asset === 'stETH' || asset === 'wstETH')
|
|
@@ -113,6 +118,8 @@ const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefine
|
|
|
113
118
|
return (0, exports.getSUSDeApy)();
|
|
114
119
|
if (asset === 'weETH')
|
|
115
120
|
return getWeEthApr();
|
|
121
|
+
if (asset === 'osETH')
|
|
122
|
+
return getOsETHApy();
|
|
116
123
|
}
|
|
117
124
|
catch (e) {
|
|
118
125
|
console.error(`Failed to fetch APY for ${asset}`);
|
package/cjs/types/llamaLend.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LlamaLendStatus = exports.LlamaLendVersions = exports.LLVersionsArb = exports.LLVersionsEth = void 0;
|
|
4
4
|
var LLVersionsEth;
|
|
5
5
|
(function (LLVersionsEth) {
|
|
6
|
-
//long only
|
|
6
|
+
// long only
|
|
7
7
|
LLVersionsEth["LLWstethCrvusd"] = "llamaLendwstETHcrvUSD";
|
|
8
8
|
LLVersionsEth["LLSusdeCrvusd"] = "llamaLendsUSDecrvUSD";
|
|
9
9
|
// long and short crv
|
|
@@ -18,7 +18,7 @@ var LLVersionsEth;
|
|
|
18
18
|
})(LLVersionsEth || (exports.LLVersionsEth = LLVersionsEth = {}));
|
|
19
19
|
var LLVersionsArb;
|
|
20
20
|
(function (LLVersionsArb) {
|
|
21
|
-
//long only
|
|
21
|
+
// long only
|
|
22
22
|
LLVersionsArb["LLArbCrvusd"] = "llamaLendArbcrvUSD";
|
|
23
23
|
LLVersionsArb["LLFxnCrvusd"] = "llamaLendFXNcrvUSD";
|
|
24
24
|
LLVersionsArb["LLWbtcCrvusd"] = "llamaLendWBTCcrvUSD";
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -131,7 +131,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
131
131
|
if (nativeAsset && facilitatorsList && discountRate && minDiscountTokenBalance && minGhoBalanceForDiscount && ghoDiscountedPerDiscountToken) {
|
|
132
132
|
const facilitatorBucket = yield ghoContract.methods.getFacilitatorBucket(facilitatorsList[0]).call();
|
|
133
133
|
const availableFacilitatorCap = assetAmountInEth(new Dec(facilitatorBucket[0]).sub(facilitatorBucket[1]).toString(), 'GHO');
|
|
134
|
-
borrowCap = Dec.min(borrowCap,
|
|
134
|
+
borrowCap = Dec.min(borrowCap, assetAmountInEth(facilitatorBucket[0], 'GHO')).toString();
|
|
135
135
|
discountRateOnBorrow = aaveV3CalculateDiscountRate(tokenMarket.totalBorrow.toString(), '3160881469228662060510133', // stkAAVE total supply
|
|
136
136
|
discountRate, minDiscountTokenBalance, minGhoBalanceForDiscount, ghoDiscountedPerDiscountToken);
|
|
137
137
|
}
|
|
@@ -4,7 +4,7 @@ export const morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WB
|
|
|
4
4
|
export const morphoAaveV3AssetEthMarket = [
|
|
5
5
|
'ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT',
|
|
6
6
|
];
|
|
7
|
-
export const aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH'];
|
|
7
|
+
export const aaveV3AssetsDefaultMarketEth = ['ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH'];
|
|
8
8
|
export const aaveV3AssetsDefaultMarketOpt = [
|
|
9
9
|
'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
|
|
10
10
|
];
|
|
@@ -28,7 +28,7 @@ export const LlamaLendMarkets = (networkId) => ({
|
|
|
28
28
|
export const getLlamaLendMarketData = (market, network = 1) => LlamaLendMarkets(network)[market];
|
|
29
29
|
export const getLlamaLendMarketFromControllerAddress = (controllerAddress, network) => {
|
|
30
30
|
const markets = LlamaLendMarkets(network);
|
|
31
|
-
const market = Object.values(markets).find((
|
|
31
|
+
const market = Object.values(markets).find((tempMarket) => tempMarket.controllerAddress === controllerAddress);
|
|
32
32
|
if (!market)
|
|
33
33
|
throw new Error('Market not found');
|
|
34
34
|
return market;
|
package/esm/staking/staking.js
CHANGED
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
|
+
import { StakeWiseSDK, Network } from '@stakewise/v3-sdk';
|
|
11
12
|
import { CbEthContract, LidoContract, PotContract, REthContract, wstETHContract, } from '../contracts';
|
|
12
13
|
import { NetworkNumber } from '../types/common';
|
|
13
14
|
import { BLOCKS_IN_A_YEAR, SECONDS_PER_YEAR, AVG_BLOCK_TIME } from '../constants';
|
|
@@ -82,12 +83,16 @@ export const getSUSDeApy = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
82
83
|
return data.apy;
|
|
83
84
|
});
|
|
84
85
|
const getWeEthApr = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
-
const res = yield fetch('https://
|
|
86
|
+
const res = yield fetch('https://app.defisaver.com/api/staking/apy?asset=weETH');
|
|
86
87
|
const data = yield res.json();
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
return data.apy;
|
|
89
|
+
});
|
|
90
|
+
const getOsETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
const sdk = new StakeWiseSDK({ network: Network.Mainnet });
|
|
92
|
+
const apy = yield sdk.osToken.getAPY();
|
|
93
|
+
return apy;
|
|
89
94
|
});
|
|
90
|
-
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH'];
|
|
95
|
+
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH'];
|
|
91
96
|
export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
|
|
92
97
|
try {
|
|
93
98
|
if (asset === 'stETH' || asset === 'wstETH')
|
|
@@ -102,6 +107,8 @@ export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = u
|
|
|
102
107
|
return getSUSDeApy();
|
|
103
108
|
if (asset === 'weETH')
|
|
104
109
|
return getWeEthApr();
|
|
110
|
+
if (asset === 'osETH')
|
|
111
|
+
return getOsETHApy();
|
|
105
112
|
}
|
|
106
113
|
catch (e) {
|
|
107
114
|
console.error(`Failed to fetch APY for ${asset}`);
|
package/esm/types/llamaLend.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export var LLVersionsEth;
|
|
2
2
|
(function (LLVersionsEth) {
|
|
3
|
-
//long only
|
|
3
|
+
// long only
|
|
4
4
|
LLVersionsEth["LLWstethCrvusd"] = "llamaLendwstETHcrvUSD";
|
|
5
5
|
LLVersionsEth["LLSusdeCrvusd"] = "llamaLendsUSDecrvUSD";
|
|
6
6
|
// long and short crv
|
|
@@ -15,7 +15,7 @@ export var LLVersionsEth;
|
|
|
15
15
|
})(LLVersionsEth || (LLVersionsEth = {}));
|
|
16
16
|
export var LLVersionsArb;
|
|
17
17
|
(function (LLVersionsArb) {
|
|
18
|
-
//long only
|
|
18
|
+
// long only
|
|
19
19
|
LLVersionsArb["LLArbCrvusd"] = "llamaLendArbcrvUSD";
|
|
20
20
|
LLVersionsArb["LLFxnCrvusd"] = "llamaLendFXNcrvUSD";
|
|
21
21
|
LLVersionsArb["LLWbtcCrvusd"] = "llamaLendWBTCcrvUSD";
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -183,7 +183,7 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
183
183
|
const facilitatorBucket = await ghoContract.methods.getFacilitatorBucket(facilitatorsList[0]).call();
|
|
184
184
|
const availableFacilitatorCap = assetAmountInEth(new Dec(facilitatorBucket[0]).sub(facilitatorBucket[1]).toString(), 'GHO');
|
|
185
185
|
|
|
186
|
-
borrowCap = Dec.min(borrowCap,
|
|
186
|
+
borrowCap = Dec.min(borrowCap, assetAmountInEth(facilitatorBucket[0],'GHO')).toString();
|
|
187
187
|
|
|
188
188
|
discountRateOnBorrow = aaveV3CalculateDiscountRate(
|
|
189
189
|
tokenMarket.totalBorrow.toString(),
|
package/src/staking/staking.ts
CHANGED
|
@@ -85,7 +85,7 @@ export const getSUSDeApy = async () => {
|
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
const getWeEthApr = async () => {
|
|
88
|
-
const res = await fetch('
|
|
88
|
+
const res = await fetch('https://app.defisaver.com/api/staking/apy?asset=weETH');
|
|
89
89
|
const data = await res.json();
|
|
90
90
|
return data.apy;
|
|
91
91
|
};
|