@defisaver/positions-sdk 0.0.165 → 0.0.166

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.
@@ -4,6 +4,7 @@ export declare const getStETHApr: (web3: Web3, fromBlock?: number, blockNumber?:
4
4
  export declare const getCbETHApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
5
5
  export declare const getREthApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
6
6
  export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
7
+ export declare const getSsrApy: () => Promise<string>;
7
8
  export declare const STAKING_ASSETS: string[];
8
9
  export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<any> | "0" | undefined;
9
10
  export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
15
+ exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getSsrApy = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
16
16
  const decimal_js_1 = __importDefault(require("decimal.js"));
17
17
  const contracts_1 = require("../contracts");
18
18
  const common_1 = require("../types/common");
@@ -86,6 +86,12 @@ const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, vo
86
86
  .toString();
87
87
  });
88
88
  exports.getDsrApy = getDsrApy;
89
+ const getSsrApy = () => __awaiter(void 0, void 0, void 0, function* () {
90
+ const res = yield fetch('https://app.defisaver.com/api/sky/data');
91
+ const data = yield res.json();
92
+ return new decimal_js_1.default(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
93
+ });
94
+ exports.getSsrApy = getSsrApy;
89
95
  const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
90
96
  console.log('getSuperOETHApy');
91
97
  const res = yield fetch('https://origin.squids.live/origin-squid/graphql', {
@@ -109,7 +115,7 @@ const getApyFromDfsApi = (asset) => __awaiter(void 0, void 0, void 0, function*
109
115
  const data = yield res.json();
110
116
  return data.apy;
111
117
  });
112
- exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb'];
118
+ exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
113
119
  const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
114
120
  console.log('getStakingApy', asset, blockNumber, fromBlock);
115
121
  try {
@@ -137,6 +143,8 @@ const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefine
137
143
  return getApyFromDfsApi('pufETH');
138
144
  if (asset === 'wsuperOETHb')
139
145
  return getSuperOETHApy();
146
+ if (asset === 'sUSDS')
147
+ return (0, exports.getSsrApy)();
140
148
  }
141
149
  catch (e) {
142
150
  console.error(`Failed to fetch APY for ${asset}`);
@@ -4,6 +4,7 @@ export declare const getStETHApr: (web3: Web3, fromBlock?: number, blockNumber?:
4
4
  export declare const getCbETHApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
5
5
  export declare const getREthApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
6
6
  export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
7
+ export declare const getSsrApy: () => Promise<string>;
7
8
  export declare const STAKING_ASSETS: string[];
8
9
  export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<any> | "0" | undefined;
9
10
  export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
@@ -76,6 +76,11 @@ export const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, voi
76
76
  .mul(100)
77
77
  .toString();
78
78
  });
79
+ export const getSsrApy = () => __awaiter(void 0, void 0, void 0, function* () {
80
+ const res = yield fetch('https://app.defisaver.com/api/sky/data');
81
+ const data = yield res.json();
82
+ return new Dec(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
83
+ });
79
84
  const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
80
85
  console.log('getSuperOETHApy');
81
86
  const res = yield fetch('https://origin.squids.live/origin-squid/graphql', {
@@ -99,7 +104,7 @@ const getApyFromDfsApi = (asset) => __awaiter(void 0, void 0, void 0, function*
99
104
  const data = yield res.json();
100
105
  return data.apy;
101
106
  });
102
- export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb'];
107
+ export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
103
108
  export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
104
109
  console.log('getStakingApy', asset, blockNumber, fromBlock);
105
110
  try {
@@ -127,6 +132,8 @@ export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = u
127
132
  return getApyFromDfsApi('pufETH');
128
133
  if (asset === 'wsuperOETHb')
129
134
  return getSuperOETHApy();
135
+ if (asset === 'sUSDS')
136
+ return getSsrApy();
130
137
  }
131
138
  catch (e) {
132
139
  console.error(`Failed to fetch APY for ${asset}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defisaver/positions-sdk",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
4
4
  "description": "",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
@@ -36,6 +36,7 @@
36
36
  "chai": "^4.3.8",
37
37
  "dotenv": "^16.3.1",
38
38
  "eslint": "^8.49.0",
39
+ "eslint-plugin-import": "^2.31.0",
39
40
  "mocha": "^10.2.0",
40
41
  "ts-node": "^10.9.2",
41
42
  "typechain": "^8.3.1",
@@ -77,6 +77,12 @@ export const getDsrApy = async (web3: Web3, blockNumber: 'latest' | number = 'la
77
77
  .toString();
78
78
  };
79
79
 
80
+ export const getSsrApy = async () => {
81
+ const res = await fetch('https://app.defisaver.com/api/sky/data');
82
+ const data = await res.json();
83
+ return new Dec(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
84
+ };
85
+
80
86
  const getSuperOETHApy = async () => {
81
87
  console.log('getSuperOETHApy');
82
88
  const res = await fetch('https://origin.squids.live/origin-squid/graphql', {
@@ -103,7 +109,7 @@ const getApyFromDfsApi = async (asset: string) => {
103
109
  return data.apy;
104
110
  };
105
111
 
106
- export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb'];
112
+ export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
107
113
 
108
114
  export const getStakingApy = (asset: string, web3: Web3, blockNumber: 'latest' | number = 'latest', fromBlock: number | undefined = undefined) => {
109
115
  console.log('getStakingApy', asset, blockNumber, fromBlock);
@@ -120,6 +126,7 @@ export const getStakingApy = (asset: string, web3: Web3, blockNumber: 'latest' |
120
126
  if (asset === 'rsETH' || asset === 'wrsETH') return getApyFromDfsApi('rsETH');
121
127
  if (asset === 'pufETH') return getApyFromDfsApi('pufETH');
122
128
  if (asset === 'wsuperOETHb') return getSuperOETHApy();
129
+ if (asset === 'sUSDS') return getSsrApy();
123
130
  } catch (e) {
124
131
  console.error(`Failed to fetch APY for ${asset}`);
125
132
  return '0';