@defisaver/positions-sdk 2.1.111-merkl-auth-api-1-dev → 2.1.112
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/merkl.js +2 -2
- package/cjs/aaveV4/merkl.js +2 -2
- package/cjs/claiming/aaveV3.js +1 -5
- package/cjs/helpers/eulerHelpers/index.js +6 -6
- package/esm/aaveV3/merkl.js +3 -3
- package/esm/aaveV4/merkl.js +3 -3
- package/esm/claiming/aaveV3.js +2 -6
- package/esm/helpers/eulerHelpers/index.js +6 -6
- package/package.json +1 -1
- package/src/aaveV3/merkl.ts +3 -3
- package/src/aaveV4/merkl.ts +3 -3
- package/src/claiming/aaveV3.ts +3 -7
- package/src/helpers/eulerHelpers/index.ts +7 -7
package/cjs/aaveV3/merkl.js
CHANGED
|
@@ -40,8 +40,8 @@ const formatAaveAsset = (_symbol) => {
|
|
|
40
40
|
exports.formatAaveAsset = formatAaveAsset;
|
|
41
41
|
const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
42
|
try {
|
|
43
|
-
const res = yield fetch('https://
|
|
44
|
-
signal: AbortSignal.timeout(utils_1.
|
|
43
|
+
const res = yield fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
44
|
+
signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
|
|
45
45
|
});
|
|
46
46
|
if (!res.ok)
|
|
47
47
|
throw new Error('Failed to fetch Merkle campaigns');
|
package/cjs/aaveV4/merkl.js
CHANGED
|
@@ -34,8 +34,8 @@ const buildIncentive = (opportunity) => {
|
|
|
34
34
|
const getAaveV4MerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
35
|
const result = { hub: {}, spoke: {} };
|
|
36
36
|
try {
|
|
37
|
-
const res = yield fetch('https://
|
|
38
|
-
signal: AbortSignal.timeout(utils_1.
|
|
37
|
+
const res = yield fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
38
|
+
signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT),
|
|
39
39
|
});
|
|
40
40
|
if (!res.ok)
|
|
41
41
|
throw new Error('Failed to fetch Aave V4 Merkle campaigns');
|
package/cjs/claiming/aaveV3.js
CHANGED
|
@@ -99,7 +99,7 @@ function getMeritUnclaimedRewards(account, network) {
|
|
|
99
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
100
|
let data;
|
|
101
101
|
try {
|
|
102
|
-
const res = yield fetch(`https://
|
|
102
|
+
const res = yield fetch(`https://api-merkl.angle.money/v4/users/${account}/rewards?chainId=${network}`, { signal: AbortSignal.timeout(3000) });
|
|
103
103
|
data = yield res.json();
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
@@ -107,10 +107,6 @@ function getMeritUnclaimedRewards(account, network) {
|
|
|
107
107
|
data = [];
|
|
108
108
|
}
|
|
109
109
|
const claimableTokens = [];
|
|
110
|
-
// Merkl (or our proxy, on a non-2xx) can return a non-array error body; `fetch` doesn't throw on
|
|
111
|
-
// HTTP errors, so guard before iterating. Mirrors the app-side getMeritUnclaimedRewards.
|
|
112
|
-
if (!Array.isArray(data))
|
|
113
|
-
return claimableTokens;
|
|
114
110
|
data.forEach((item) => {
|
|
115
111
|
item.rewards.forEach(reward => {
|
|
116
112
|
const { token, amount, claimed, proofs, } = reward;
|
|
@@ -188,21 +188,21 @@ const getApyAfterValuesEstimationEulerV2 = (actions, provider, network) => __awa
|
|
|
188
188
|
const data = {};
|
|
189
189
|
for (let i = 0; i < numOfActions; i += 1) {
|
|
190
190
|
// @ts-ignore
|
|
191
|
-
const _interestRate = res[numOfActions]
|
|
191
|
+
const _interestRate = res[numOfActions][i].toString();
|
|
192
192
|
// @ts-ignore
|
|
193
|
-
const vaultInfo = res[i]
|
|
194
|
-
const decimals = vaultInfo.decimals;
|
|
193
|
+
const vaultInfo = res[i];
|
|
194
|
+
const decimals = vaultInfo.decimals.toString();
|
|
195
195
|
const borrowRate = (0, exports.getEulerV2BorrowRate)(_interestRate);
|
|
196
196
|
const amount = new decimal_js_1.default(actions[i].amount).mul(Math.pow(10, decimals)).toString();
|
|
197
197
|
const action = actions[i].action;
|
|
198
198
|
const isBorrowOperation = constants_1.borrowOperations.includes(action);
|
|
199
199
|
const { liquidityAdded, liquidityRemoved } = getLiquidityChanges(action, amount, isBorrowOperation);
|
|
200
|
-
const totalBorrows = new decimal_js_1.default(vaultInfo.totalBorrows).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
201
|
-
const totalAssets = new decimal_js_1.default(vaultInfo.totalAssets).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
200
|
+
const totalBorrows = new decimal_js_1.default(vaultInfo.totalBorrows.toString()).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
201
|
+
const totalAssets = new decimal_js_1.default(vaultInfo.totalAssets.toString()).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
202
202
|
const utilizationRate = (0, exports.getUtilizationRate)(totalBorrows, totalAssets);
|
|
203
203
|
data[vaultInfo.vaultAddr.toLowerCase()] = {
|
|
204
204
|
borrowRate,
|
|
205
|
-
supplyRate: (0, exports.getEulerV2SupplyRate)(borrowRate, utilizationRate, vaultInfo.interestFee),
|
|
205
|
+
supplyRate: (0, exports.getEulerV2SupplyRate)(borrowRate, utilizationRate, vaultInfo.interestFee.toString()),
|
|
206
206
|
};
|
|
207
207
|
}
|
|
208
208
|
return data;
|
package/esm/aaveV3/merkl.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { aprToApy } from '../moneymarket';
|
|
11
|
-
import {
|
|
11
|
+
import { DEFAULT_TIMEOUT, wethToEth } from '../services/utils';
|
|
12
12
|
import { OpportunityAction, OpportunityStatus, } from '../types';
|
|
13
13
|
export const getAaveUnderlyingSymbol = (_symbol = '') => {
|
|
14
14
|
let symbol = _symbol
|
|
@@ -35,8 +35,8 @@ export const formatAaveAsset = (_symbol) => {
|
|
|
35
35
|
};
|
|
36
36
|
export const getMerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
37
|
try {
|
|
38
|
-
const res = yield fetch('https://
|
|
39
|
-
signal: AbortSignal.timeout(
|
|
38
|
+
const res = yield fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
39
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
40
40
|
});
|
|
41
41
|
if (!res.ok)
|
|
42
42
|
throw new Error('Failed to fetch Merkle campaigns');
|
package/esm/aaveV4/merkl.js
CHANGED
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { aprToApy } from '../moneymarket';
|
|
11
|
-
import {
|
|
11
|
+
import { DEFAULT_TIMEOUT } from '../services/utils';
|
|
12
12
|
import { IncentiveKind, OpportunityAction, OpportunityStatus, } from '../types';
|
|
13
13
|
/**
|
|
14
14
|
* Merkl tags Aave V4 reward campaigns by scope via the `type` field:
|
|
@@ -31,8 +31,8 @@ const buildIncentive = (opportunity) => {
|
|
|
31
31
|
export const getAaveV4MerkleCampaigns = (chainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
32
|
const result = { hub: {}, spoke: {} };
|
|
33
33
|
try {
|
|
34
|
-
const res = yield fetch('https://
|
|
35
|
-
signal: AbortSignal.timeout(
|
|
34
|
+
const res = yield fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
35
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
36
36
|
});
|
|
37
37
|
if (!res.ok)
|
|
38
38
|
throw new Error('Failed to fetch Aave V4 Merkle campaigns');
|
package/esm/claiming/aaveV3.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
11
|
import { ClaimType } from '../types/claiming';
|
|
12
12
|
import { AaveIncentiveDataProviderV3ContractViem, AaveRewardsControllerViem, } from '../contracts';
|
|
13
|
-
import { compareAddresses, getEthAmountForDecimals
|
|
13
|
+
import { compareAddresses, getEthAmountForDecimals } from '../services/utils';
|
|
14
14
|
import { getAaveUnderlyingSymbol } from '../helpers/aaveHelpers';
|
|
15
15
|
const mapAaveRewardsToClaimableTokens = (aaveRewards, marketAddress, walletAddress) => aaveRewards.map(reward => ({
|
|
16
16
|
symbol: reward.symbol,
|
|
@@ -92,7 +92,7 @@ export function getMeritUnclaimedRewards(account, network) {
|
|
|
92
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
93
|
let data;
|
|
94
94
|
try {
|
|
95
|
-
const res = yield fetch(`https://
|
|
95
|
+
const res = yield fetch(`https://api-merkl.angle.money/v4/users/${account}/rewards?chainId=${network}`, { signal: AbortSignal.timeout(3000) });
|
|
96
96
|
data = yield res.json();
|
|
97
97
|
}
|
|
98
98
|
catch (error) {
|
|
@@ -100,10 +100,6 @@ export function getMeritUnclaimedRewards(account, network) {
|
|
|
100
100
|
data = [];
|
|
101
101
|
}
|
|
102
102
|
const claimableTokens = [];
|
|
103
|
-
// Merkl (or our proxy, on a non-2xx) can return a non-array error body; `fetch` doesn't throw on
|
|
104
|
-
// HTTP errors, so guard before iterating. Mirrors the app-side getMeritUnclaimedRewards.
|
|
105
|
-
if (!Array.isArray(data))
|
|
106
|
-
return claimableTokens;
|
|
107
103
|
data.forEach((item) => {
|
|
108
104
|
item.rewards.forEach(reward => {
|
|
109
105
|
const { token, amount, claimed, proofs, } = reward;
|
|
@@ -177,21 +177,21 @@ export const getApyAfterValuesEstimationEulerV2 = (actions, provider, network) =
|
|
|
177
177
|
const data = {};
|
|
178
178
|
for (let i = 0; i < numOfActions; i += 1) {
|
|
179
179
|
// @ts-ignore
|
|
180
|
-
const _interestRate = res[numOfActions]
|
|
180
|
+
const _interestRate = res[numOfActions][i].toString();
|
|
181
181
|
// @ts-ignore
|
|
182
|
-
const vaultInfo = res[i]
|
|
183
|
-
const decimals = vaultInfo.decimals;
|
|
182
|
+
const vaultInfo = res[i];
|
|
183
|
+
const decimals = vaultInfo.decimals.toString();
|
|
184
184
|
const borrowRate = getEulerV2BorrowRate(_interestRate);
|
|
185
185
|
const amount = new Dec(actions[i].amount).mul(Math.pow(10, decimals)).toString();
|
|
186
186
|
const action = actions[i].action;
|
|
187
187
|
const isBorrowOperation = borrowOperations.includes(action);
|
|
188
188
|
const { liquidityAdded, liquidityRemoved } = getLiquidityChanges(action, amount, isBorrowOperation);
|
|
189
|
-
const totalBorrows = new Dec(vaultInfo.totalBorrows).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
190
|
-
const totalAssets = new Dec(vaultInfo.totalAssets).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
189
|
+
const totalBorrows = new Dec(vaultInfo.totalBorrows.toString()).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
190
|
+
const totalAssets = new Dec(vaultInfo.totalAssets.toString()).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
191
191
|
const utilizationRate = getUtilizationRate(totalBorrows, totalAssets);
|
|
192
192
|
data[vaultInfo.vaultAddr.toLowerCase()] = {
|
|
193
193
|
borrowRate,
|
|
194
|
-
supplyRate: getEulerV2SupplyRate(borrowRate, utilizationRate, vaultInfo.interestFee),
|
|
194
|
+
supplyRate: getEulerV2SupplyRate(borrowRate, utilizationRate, vaultInfo.interestFee.toString()),
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
return data;
|
package/package.json
CHANGED
package/src/aaveV3/merkl.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aprToApy } from '../moneymarket';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_TIMEOUT, wethToEth } from '../services/utils';
|
|
3
3
|
import {
|
|
4
4
|
MerkleRewardMap, MerklOpportunity, OpportunityAction, OpportunityStatus,
|
|
5
5
|
} from '../types';
|
|
@@ -31,8 +31,8 @@ export const formatAaveAsset = (_symbol: string) => {
|
|
|
31
31
|
|
|
32
32
|
export const getMerkleCampaigns = async (chainId: NetworkNumber): Promise<MerkleRewardMap> => {
|
|
33
33
|
try {
|
|
34
|
-
const res = await fetch('https://
|
|
35
|
-
signal: AbortSignal.timeout(
|
|
34
|
+
const res = await fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
35
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
36
36
|
});
|
|
37
37
|
if (!res.ok) throw new Error('Failed to fetch Merkle campaigns');
|
|
38
38
|
const opportunities = await res.json() as MerklOpportunity[];
|
package/src/aaveV4/merkl.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aprToApy } from '../moneymarket';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_TIMEOUT } from '../services/utils';
|
|
3
3
|
import {
|
|
4
4
|
AaveV4MerklRewardMap,
|
|
5
5
|
AaveV4ReserveAssetData,
|
|
@@ -34,8 +34,8 @@ const buildIncentive = (opportunity: MerklOpportunity): IncentiveData => {
|
|
|
34
34
|
export const getAaveV4MerkleCampaigns = async (chainId: NetworkNumber): Promise<AaveV4MerklRewardMap> => {
|
|
35
35
|
const result: AaveV4MerklRewardMap = { hub: {}, spoke: {} };
|
|
36
36
|
try {
|
|
37
|
-
const res = await fetch('https://
|
|
38
|
-
signal: AbortSignal.timeout(
|
|
37
|
+
const res = await fetch('https://api-merkl.angle.money/v4/opportunities?mainProtocolId=aave', {
|
|
38
|
+
signal: AbortSignal.timeout(DEFAULT_TIMEOUT),
|
|
39
39
|
});
|
|
40
40
|
if (!res.ok) throw new Error('Failed to fetch Aave V4 Merkle campaigns');
|
|
41
41
|
const opportunities = await res.json() as MerklOpportunity[];
|
package/src/claiming/aaveV3.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
AaveIncentiveDataProviderV3ContractViem,
|
|
7
7
|
AaveRewardsControllerViem,
|
|
8
8
|
} from '../contracts';
|
|
9
|
-
import { compareAddresses, getEthAmountForDecimals
|
|
9
|
+
import { compareAddresses, getEthAmountForDecimals } from '../services/utils';
|
|
10
10
|
import { getAaveUnderlyingSymbol } from '../helpers/aaveHelpers';
|
|
11
11
|
|
|
12
12
|
type AaveReward = {
|
|
@@ -106,8 +106,8 @@ export async function getUnclaimedRewardsForAllMarkets(
|
|
|
106
106
|
export async function getMeritUnclaimedRewards(account: EthAddress, network: NetworkNumber): Promise<ClaimableToken[]> {
|
|
107
107
|
let data;
|
|
108
108
|
try {
|
|
109
|
-
const res = await fetch(`https://
|
|
110
|
-
{ signal: AbortSignal.timeout(
|
|
109
|
+
const res = await fetch(`https://api-merkl.angle.money/v4/users/${account}/rewards?chainId=${network}`,
|
|
110
|
+
{ signal: AbortSignal.timeout(3000) });
|
|
111
111
|
data = await res.json();
|
|
112
112
|
} catch (error) {
|
|
113
113
|
console.error('External API Failure: Aave Merit', error);
|
|
@@ -116,10 +116,6 @@ export async function getMeritUnclaimedRewards(account: EthAddress, network: Net
|
|
|
116
116
|
|
|
117
117
|
const claimableTokens: ClaimableToken[] = [];
|
|
118
118
|
|
|
119
|
-
// Merkl (or our proxy, on a non-2xx) can return a non-array error body; `fetch` doesn't throw on
|
|
120
|
-
// HTTP errors, so guard before iterating. Mirrors the app-side getMeritUnclaimedRewards.
|
|
121
|
-
if (!Array.isArray(data)) return claimableTokens;
|
|
122
|
-
|
|
123
119
|
data.forEach((item: { rewards: any[]; }) => {
|
|
124
120
|
item.rewards.forEach(reward => {
|
|
125
121
|
const {
|
|
@@ -173,7 +173,7 @@ export const getApyAfterValuesEstimationEulerV2 = async (actions: { action: stri
|
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
const res = await Promise.all([
|
|
176
|
-
...actions.map(({ vaultAddress }) => eulerV2ViewContract.read.getVaultInfoFull([vaultAddress])),
|
|
176
|
+
...actions.map(({ vaultAddress }) => eulerV2ViewContract.read.getVaultInfoFull([vaultAddress])) as any,
|
|
177
177
|
// @ts-ignore
|
|
178
178
|
eulerV2ViewContract.read.getApyAfterValuesEstimation([apyAfterValuesEstimationParams]),
|
|
179
179
|
]);
|
|
@@ -181,10 +181,10 @@ export const getApyAfterValuesEstimationEulerV2 = async (actions: { action: stri
|
|
|
181
181
|
const data: any = {};
|
|
182
182
|
for (let i = 0; i < numOfActions; i += 1) {
|
|
183
183
|
// @ts-ignore
|
|
184
|
-
const _interestRate = res[numOfActions]
|
|
184
|
+
const _interestRate = res[numOfActions][i].toString();
|
|
185
185
|
// @ts-ignore
|
|
186
|
-
const vaultInfo = res[i]
|
|
187
|
-
const decimals = vaultInfo.decimals;
|
|
186
|
+
const vaultInfo = res[i];
|
|
187
|
+
const decimals = vaultInfo.decimals.toString();
|
|
188
188
|
const borrowRate = getEulerV2BorrowRate(_interestRate);
|
|
189
189
|
|
|
190
190
|
const amount = new Dec(actions[i].amount).mul(10 ** decimals).toString();
|
|
@@ -192,12 +192,12 @@ export const getApyAfterValuesEstimationEulerV2 = async (actions: { action: stri
|
|
|
192
192
|
const isBorrowOperation = borrowOperations.includes(action);
|
|
193
193
|
const { liquidityAdded, liquidityRemoved } = getLiquidityChanges(action, amount, isBorrowOperation);
|
|
194
194
|
|
|
195
|
-
const totalBorrows = new Dec(vaultInfo.totalBorrows).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
196
|
-
const totalAssets = new Dec(vaultInfo.totalAssets).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
195
|
+
const totalBorrows = new Dec(vaultInfo.totalBorrows.toString()).add(isBorrowOperation ? liquidityRemoved : '0').sub(isBorrowOperation ? liquidityAdded : '0').toString();
|
|
196
|
+
const totalAssets = new Dec(vaultInfo.totalAssets.toString()).add(isBorrowOperation ? '0' : liquidityAdded).sub(isBorrowOperation ? '0' : liquidityRemoved).toString();
|
|
197
197
|
const utilizationRate = getUtilizationRate(totalBorrows, totalAssets);
|
|
198
198
|
data[vaultInfo.vaultAddr.toLowerCase()] = {
|
|
199
199
|
borrowRate,
|
|
200
|
-
supplyRate: getEulerV2SupplyRate(borrowRate, utilizationRate, vaultInfo.interestFee),
|
|
200
|
+
supplyRate: getEulerV2SupplyRate(borrowRate, utilizationRate, vaultInfo.interestFee.toString()),
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
return data;
|