@merkl/api 0.20.35 → 0.20.37
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/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.d.ts +3 -2
- package/dist/src/engine/erc20SubTypeProcessors/implementations/xU308Processor.js +5 -13
- package/dist/src/engine/opportunityMetadata/implementations/Radiant.d.ts +1 -1
- package/dist/src/engine/opportunityMetadata/implementations/Radiant.js +18 -1
- package/dist/src/modules/v4/token/token.service.js +9 -13
- package/dist/src/utils/decodeCalls.js +3 -1
- package/dist/src/utils/encodeCalls.js +3 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Pricer } from "@/utils/pricer";
|
2
|
-
import {
|
2
|
+
import type { Campaign, CampaignParameters } from "@sdk";
|
3
3
|
import { GenericProcessor, type dataType, type mandatoryCallKeys } from "../GenericProcessor";
|
4
4
|
import type { tokenType } from "../helpers/tokenType";
|
5
5
|
type callType = {
|
@@ -10,6 +10,7 @@ type callType = {
|
|
10
10
|
};
|
11
11
|
type callKeysxU308 = mandatoryCallKeys & {
|
12
12
|
pool: string;
|
13
|
+
sqrtPriceX96: string;
|
13
14
|
_token0: string;
|
14
15
|
_token1: string;
|
15
16
|
symbolToken0: string;
|
@@ -32,6 +33,6 @@ export declare class xU308Processor extends GenericProcessor<callKeysxU308, data
|
|
32
33
|
round4: callType[];
|
33
34
|
};
|
34
35
|
processingRound2(typeInfo: dataRawxU308): void;
|
35
|
-
processingRound5(_index: number, type: tokenType, typeInfo: dataRawxU308, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>,
|
36
|
+
processingRound5(_index: number, type: tokenType, typeInfo: dataRawxU308, _calls: string[], campaign: CampaignParameters<Campaign.ERC20> | CampaignParameters<Campaign.EULER>, _pricer: Pricer): Promise<dataTypexU308>;
|
36
37
|
}
|
37
38
|
export {};
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import { generateCardName } from "@/utils/generateCardName";
|
2
|
-
import { BN2Number } from "@sdk";
|
3
2
|
import { GenericProcessor } from "../GenericProcessor";
|
4
3
|
export class xU308Processor extends GenericProcessor {
|
5
4
|
rounds = {
|
@@ -7,6 +6,7 @@ export class xU308Processor extends GenericProcessor {
|
|
7
6
|
round2: [
|
8
7
|
{ key: "_token0", call: "token0", target: "pool" },
|
9
8
|
{ key: "_token1", call: "token1", target: "pool" },
|
9
|
+
{ key: "sqrtPriceX96", call: "sqrtPriceX96", target: "pool" },
|
10
10
|
],
|
11
11
|
round3: [
|
12
12
|
{ key: "symbolToken0", call: "symbol", target: "_token0" },
|
@@ -22,19 +22,11 @@ export class xU308Processor extends GenericProcessor {
|
|
22
22
|
processingRound2(typeInfo) {
|
23
23
|
typeInfo.pool = "0xB387D0A73619791420De4a1e5e710023Cb0f49c0";
|
24
24
|
}
|
25
|
-
async processingRound5(_index, type, typeInfo, _calls, campaign,
|
25
|
+
async processingRound5(_index, type, typeInfo, _calls, campaign, _pricer) {
|
26
26
|
const { whitelistedSupplyTargetToken, totalSupply, blacklistedSupply } = this.handleWhiteListBlacklistRound5(typeInfo, campaign);
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
priceTargetToken =
|
31
|
-
(priceToken0 * BN2Number(typeInfo.balanceToken0, Number(typeInfo.decimalsToken0))) /
|
32
|
-
BN2Number(typeInfo.balanceToken1, Number(typeInfo.decimalsToken1));
|
33
|
-
}
|
34
|
-
const priceToken1 = (await pricer.get({ symbol: typeInfo.symbolToken1 })) ?? 0;
|
35
|
-
priceTargetToken =
|
36
|
-
(priceToken1 * BN2Number(typeInfo.balanceToken1, Number(typeInfo.decimalsToken1))) /
|
37
|
-
BN2Number(typeInfo.balanceToken0, Number(typeInfo.decimalsToken0));
|
27
|
+
const srtPrice = BigInt(typeInfo.sqrtPriceX96);
|
28
|
+
const price = Number(srtPrice) ** 2 / 2 ** 192;
|
29
|
+
const priceTargetToken = price * 10 ** 12;
|
38
30
|
const tvl = priceTargetToken * totalSupply;
|
39
31
|
return {
|
40
32
|
...typeInfo,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
|
2
|
-
import type
|
2
|
+
import { type Campaign as CampaignEnum, type CampaignParameters, type ChainId } from "@sdk";
|
3
3
|
import type { MetadataBuilder } from "../interface";
|
4
4
|
type campaignType = CampaignEnum.RADIANT;
|
5
5
|
export declare class RadiantMetadata implements MetadataBuilder<campaignType> {
|
@@ -1,11 +1,28 @@
|
|
1
|
+
import { log } from "@/utils/logger";
|
1
2
|
import { OpportunityAction } from "@db/api";
|
3
|
+
import { ChainInteractionService, NETWORK_LABELS, RadiantInterface, } from "@sdk";
|
2
4
|
import { getAddress } from "viem";
|
3
5
|
export class RadiantMetadata {
|
4
6
|
async build(computeChainId, params, subType) {
|
7
|
+
const tokens = [{ chainId: computeChainId, address: params.targetToken }];
|
8
|
+
try {
|
9
|
+
const result = await ChainInteractionService(computeChainId).fetchState([
|
10
|
+
{
|
11
|
+
target: params.targetToken,
|
12
|
+
allowFailure: true,
|
13
|
+
callData: RadiantInterface.encodeFunctionData("UNDERLYING_ASSET_ADDRESS"),
|
14
|
+
},
|
15
|
+
]);
|
16
|
+
const underlyingAddress = getAddress(RadiantInterface.decodeFunctionResult("UNDERLYING_ASSET_ADDRESS", result[0].returnData)[0]);
|
17
|
+
tokens.push({ chainId: computeChainId, address: underlyingAddress });
|
18
|
+
}
|
19
|
+
catch {
|
20
|
+
log.warn(`failed to fetch underlying asset address on ${NETWORK_LABELS[computeChainId]} for radiant token ${params.targetToken}`);
|
21
|
+
}
|
5
22
|
return {
|
6
23
|
action: subType <= 1 ? OpportunityAction.LEND : OpportunityAction.BORROW,
|
7
24
|
name: [subType <= 1 ? "Lend" : "Borrow", params.symbolTargetToken].join(" "),
|
8
|
-
tokens
|
25
|
+
tokens,
|
9
26
|
mainProtocol: "radiant",
|
10
27
|
explorerAddress: getAddress(params.targetToken),
|
11
28
|
};
|
@@ -8,8 +8,6 @@ import { Prisma } from "@db/api";
|
|
8
8
|
import { ChainInteractionService, DistributionCreatorService, NETWORK_LABELS, bigIntToNumber, } from "@sdk";
|
9
9
|
import { getAddress, parseUnits } from "viem";
|
10
10
|
import { BucketService } from "../bucket/bucket.service";
|
11
|
-
import { CacheService } from "../cache";
|
12
|
-
import { TTLPresets } from "../cache/cache.model";
|
13
11
|
import { IconService } from "../icon/icon.service";
|
14
12
|
import { PriceService } from "../price";
|
15
13
|
import { TokenRepository } from "./token.repository";
|
@@ -272,17 +270,15 @@ export class TokenService {
|
|
272
270
|
}));
|
273
271
|
}
|
274
272
|
static async getValidRewardTokens(chainId) {
|
275
|
-
|
276
|
-
|
277
|
-
return
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
});
|
285
|
-
}, chainId);
|
273
|
+
const validRewardTokens = await DistributionCreatorService(chainId).validRewardTokens();
|
274
|
+
return (await TokenRepository.findList(chainId, validRewardTokens.map(t => getAddress(t.token)))).map(x => {
|
275
|
+
return {
|
276
|
+
...x,
|
277
|
+
minimumAmountPerHour: validRewardTokens
|
278
|
+
.find(t => getAddress(t.token) === x.address)
|
279
|
+
?.minimumAmountPerEpoch.toString(),
|
280
|
+
};
|
281
|
+
});
|
286
282
|
}
|
287
283
|
static async update(id, data) {
|
288
284
|
return await TokenRepository.update(id, data);
|
@@ -1,11 +1,13 @@
|
|
1
1
|
import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
|
2
|
-
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankERC20Interface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
|
2
|
+
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankERC20Interface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, UniswapV3PoolInterface, VePufferInterface, ZFStableLPINterface, ZFStableSwapThreePoolInterface, } from "@sdk";
|
3
3
|
export function decodeCall(calls, index, key, type) {
|
4
4
|
const returnData = calls[index];
|
5
5
|
return decodeReturnValue(returnData, key, type);
|
6
6
|
}
|
7
7
|
export function decodeReturnValue(returnData, key, type) {
|
8
8
|
switch (key) {
|
9
|
+
case "sqrtPriceX96":
|
10
|
+
return UniswapV3PoolInterface.decodeFunctionResult("slot0", returnData)[0];
|
9
11
|
case "tokens":
|
10
12
|
return LPManagerInterface.decodeFunctionResult("tokens", returnData)[0];
|
11
13
|
case "getTokensCount":
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import { tokenType } from "@/engine/erc20SubTypeProcessors/helpers/tokenType";
|
2
|
-
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxDatastoreInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, VePufferInterface, ZFStableLPINterface, } from "@sdk";
|
2
|
+
import { AaveInterface, AccountantWithRateProvidersInterface, AuraInterface, AuraOperatorInterface, BalancerGaugeInterface, BalancerPoolInterface, BalancerV3StablePoolInterface, BalancerVaultInterface, BeefyInterface, BunniV2HubInterface, BunniV2TokenInterface, CPMMGammaPoolMainInterface, CompoundInterface, CurveInterface, CurveLPTokenInterface, CurveStableSwapNGInterface, DefutureVaultInterface, ERC20Interface, ERC4626Interface, EnzymeInterface, EulerInterface, FactoryInterface, FluidInterface, FraxlendInterface, GearboxVaultInterface, HourglassERC20TBTInterface, HourglassVedaLockDepositorV2Interface, IonicInterface, LPManagerHelperInterface, LPManagerInterface, LayerBankInterface, LendleInterface, MaverickBPLensInterface, MetamorphoInterface, MoonwellInterface, OneInchStakingInterface, PendleInterface, PendleYTInterface, RadiantInterface, RfxDatastoreInterface, RswEthStrategyInterface, SpectraYTInterface, SturdyInterface, SymetricAmbientStrategyInterface, SyncSwapClassicPoolInterface, TorosInterface, UniswapV2PoolInterface, UniswapV3PoolInterface, VePufferInterface, ZFStableLPINterface, } from "@sdk";
|
3
3
|
export function createCall(target, key, type, metaData) {
|
4
4
|
switch (key) {
|
5
|
+
case "sqrtPriceX96":
|
6
|
+
return { allowFailure: true, callData: UniswapV3PoolInterface.encodeFunctionData("slot0"), target };
|
5
7
|
case "tokens":
|
6
8
|
return { allowFailure: true, callData: LPManagerInterface.encodeFunctionData("tokens", [metaData]), target };
|
7
9
|
case "getTokensCount":
|