@merkl/api 0.20.157 → 0.20.158
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/deprecated/erc20SubTypeProcessors/helpers/ownerFinder.js +1 -0
- package/dist/src/engine/implementations/Erc20/subTypes/factories.js +4 -0
- package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/metadata.d.ts +16 -0
- package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/metadata.js +20 -0
- package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/tvl.d.ts +6 -0
- package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/tvl.js +53 -0
- package/dist/src/engine/implementations/Erc20/subTypes/index.d.ts +2 -1
- package/dist/src/engine/implementations/Erc20/subTypes/index.js +1 -0
- package/dist/src/modules/v4/campaign/campaign.test.controller.js +0 -1
- package/dist/src/modules/v4/price/price.service.js +7 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
@@ -4,6 +4,7 @@ const ownerAddresses = {
|
|
4
4
|
"0x42a856dbEBB97AbC1269EAB32f3bb40C15102819": Erc20SubType.satlayer,
|
5
5
|
"0x4C911bf7A008C497719CBEb1a376f1cEc9e2c1d6": Erc20SubType.hanji_liquidity_vault_token,
|
6
6
|
"0x6e9d701fB6478Ed5972a37886C2BA6C82a4cBb4C": Erc20SubType.gamma, // Gamma Bob owner
|
7
|
+
"0x14fB20565a11b15cA2065A06740A0C46F5986eD0": Erc20SubType.lendle_vaults, // Gamma Alice owner
|
7
8
|
};
|
8
9
|
export function getTypeFromOwnerAddress(address) {
|
9
10
|
if (ownerAddresses[address]) {
|
@@ -3,6 +3,8 @@ import { EulerMetadata } from "./implementations/euler/metadata";
|
|
3
3
|
import { EulerTVLBuilder } from "./implementations/euler/tvl";
|
4
4
|
import { GearboxMetadata } from "./implementations/gearbox/metadata";
|
5
5
|
import { GearboxTVLBuilder } from "./implementations/gearbox/tvl";
|
6
|
+
import { LendleMetadata } from "./implementations/lendleVaults/metadata";
|
7
|
+
import { LendleTVLBuilder } from "./implementations/lendleVaults/tvl";
|
6
8
|
import { SuperlendMetadata } from "./implementations/superlend/metadata";
|
7
9
|
import { SuperlendTVLBuilder } from "./implementations/superlend/tvl";
|
8
10
|
/**
|
@@ -17,6 +19,7 @@ const tvlMap = {
|
|
17
19
|
[Erc20SubType.superlend_lending]: new SuperlendTVLBuilder(),
|
18
20
|
[Erc20SubType.euler_borrow]: new EulerTVLBuilder(),
|
19
21
|
[Erc20SubType.euler_lend]: new EulerTVLBuilder(),
|
22
|
+
[Erc20SubType.lendle_vaults]: new LendleTVLBuilder(),
|
20
23
|
};
|
21
24
|
export const erc20SubTypeTVLBuilderFactory = (erc20Subtype) => {
|
22
25
|
if (!tvlMap[erc20Subtype]) {
|
@@ -36,6 +39,7 @@ const metadataMap = {
|
|
36
39
|
[Erc20SubType.superlend_lending]: new SuperlendMetadata(),
|
37
40
|
[Erc20SubType.euler_borrow]: new EulerMetadata(),
|
38
41
|
[Erc20SubType.euler_lend]: new EulerMetadata(),
|
42
|
+
[Erc20SubType.lendle_vaults]: new LendleMetadata(),
|
39
43
|
};
|
40
44
|
export const erc20SubTypeMetadataBuilderFactory = (erc20Subtype) => {
|
41
45
|
if (!metadataMap[erc20Subtype]) {
|
package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/metadata.d.ts
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { MetadataBuilder } from "@/engine/metadata/interface";
|
2
|
+
import type { CampaignWithParams } from "@/modules/v4/campaign/campaign.model";
|
3
|
+
import type { ProtocolId } from "@/modules/v4/protocol/protocol.model";
|
4
|
+
import type { Erc20LikeCampaignEnum } from "../..";
|
5
|
+
export declare class LendleMetadata implements MetadataBuilder<Erc20LikeCampaignEnum> {
|
6
|
+
build(campaign: Omit<CampaignWithParams<Erc20LikeCampaignEnum>, "manualOverrides">): Promise<{
|
7
|
+
action: "LEND";
|
8
|
+
mainProtocol: ProtocolId;
|
9
|
+
name: string;
|
10
|
+
tokens: {
|
11
|
+
chainId: number;
|
12
|
+
address: any;
|
13
|
+
}[];
|
14
|
+
explorerAddress: any;
|
15
|
+
}>;
|
16
|
+
}
|
package/dist/src/engine/implementations/Erc20/subTypes/implementations/lendleVaults/metadata.js
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
import { OpportunityAction } from "@db/api";
|
2
|
+
import { ChainInteractionService, LendleVault__factory, TokenInteractionService } from "@sdk";
|
3
|
+
export class LendleMetadata {
|
4
|
+
async build(campaign) {
|
5
|
+
const { params, computeChainId } = campaign;
|
6
|
+
const { targetToken } = params;
|
7
|
+
const underlyingToken = await LendleVault__factory.connect(targetToken, ChainInteractionService(computeChainId).provider()).want();
|
8
|
+
const underlyingTokenSymbol = await TokenInteractionService(computeChainId).symbol(underlyingToken);
|
9
|
+
return {
|
10
|
+
action: OpportunityAction.LEND,
|
11
|
+
mainProtocol: "lendle",
|
12
|
+
name: `Deposit ${underlyingTokenSymbol} on Lendle vaults`,
|
13
|
+
tokens: [
|
14
|
+
{ chainId: computeChainId, address: targetToken },
|
15
|
+
{ chainId: computeChainId, address: underlyingToken },
|
16
|
+
],
|
17
|
+
explorerAddress: params.targetToken,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { Erc20LikeCampaignEnum } from "@/engine/implementations/Erc20/subTypes";
|
2
|
+
import type { TVLBuilder, TVLData } from "@/engine/tvl/interface";
|
3
|
+
import { type CampaignParameters, type MerklChainId } from "@sdk";
|
4
|
+
export declare class LendleTVLBuilder implements TVLBuilder<Erc20LikeCampaignEnum> {
|
5
|
+
build(computeChainId: MerklChainId, campaigns: CampaignParameters<Erc20LikeCampaignEnum>[]): Promise<TVLData<any>>;
|
6
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { TokenService } from "@/modules/v4/token/token.service";
|
2
|
+
import { TvlType } from "@db/api";
|
3
|
+
import { ChainInteractionService, LendleVaultInterface, bigIntToNumber, } from "@sdk";
|
4
|
+
export class LendleTVLBuilder {
|
5
|
+
async build(computeChainId, campaigns) {
|
6
|
+
const tvls = [];
|
7
|
+
const calls = [];
|
8
|
+
for (const campaign of campaigns) {
|
9
|
+
const { targetToken } = campaign.campaignParameters;
|
10
|
+
calls.push({
|
11
|
+
allowFailure: true,
|
12
|
+
callData: LendleVaultInterface.encodeFunctionData("want"),
|
13
|
+
target: targetToken,
|
14
|
+
}, {
|
15
|
+
allowFailure: true,
|
16
|
+
callData: LendleVaultInterface.encodeFunctionData("getPricePerFullShare"),
|
17
|
+
target: targetToken,
|
18
|
+
}, {
|
19
|
+
allowFailure: true,
|
20
|
+
callData: LendleVaultInterface.encodeFunctionData("totalSupply"),
|
21
|
+
target: targetToken,
|
22
|
+
});
|
23
|
+
}
|
24
|
+
const result = await ChainInteractionService(computeChainId).fetchState(calls);
|
25
|
+
for (const [index, campaign] of campaigns.entries()) {
|
26
|
+
const underlyingTokenAddress = LendleVaultInterface.decodeFunctionResult("want", result[3 * index].returnData)[0];
|
27
|
+
const underlyingPerShare = LendleVaultInterface.decodeFunctionResult("getPricePerFullShare", result[3 * index + 1].returnData)[0];
|
28
|
+
const totalSupply = LendleVaultInterface.decodeFunctionResult("totalSupply", result[3 * index + 2].returnData)[0];
|
29
|
+
const underlyingToken = await TokenService.findUniqueFillOrThrow({
|
30
|
+
chainId: computeChainId,
|
31
|
+
address: underlyingTokenAddress,
|
32
|
+
});
|
33
|
+
if (!underlyingToken.decimals || !underlyingToken.price) {
|
34
|
+
throw new Error(`Missing decimals or price for token ${underlyingToken.address}`);
|
35
|
+
}
|
36
|
+
const totalAssets = bigIntToNumber(underlyingPerShare, 18) *
|
37
|
+
bigIntToNumber(totalSupply, campaign.campaignParameters.decimalsTargetToken);
|
38
|
+
const tvl = totalAssets * underlyingToken.price;
|
39
|
+
tvls.push({
|
40
|
+
campaign,
|
41
|
+
tvl,
|
42
|
+
tvlBreakdown: [
|
43
|
+
{
|
44
|
+
identifier: underlyingToken.id,
|
45
|
+
type: TvlType.TOKEN,
|
46
|
+
value: totalAssets,
|
47
|
+
},
|
48
|
+
],
|
49
|
+
});
|
50
|
+
}
|
51
|
+
return tvls;
|
52
|
+
}
|
53
|
+
}
|
@@ -32,7 +32,6 @@ export const CampaignTestController = new Elysia({
|
|
32
32
|
.get("/tvls/:opportunityId", async ({ params }) => {
|
33
33
|
const campaigns = (await CampaignService.findMany({
|
34
34
|
opportunityId: params.opportunityId,
|
35
|
-
status: "LIVE",
|
36
35
|
test: true,
|
37
36
|
withOpportunity: true,
|
38
37
|
items: 10_000,
|
@@ -2,6 +2,7 @@ import { UnableToFindPrice } from "@/errors";
|
|
2
2
|
import { Pricer } from "@/utils/pricer";
|
3
3
|
import PriceFetcherFactory from "@/utils/prices/priceFetcherFactory";
|
4
4
|
import { PriceSourceMethod } from "@db/api";
|
5
|
+
import { TokenService } from "../token/token.service";
|
5
6
|
import { PriceRepository } from "./price.repository";
|
6
7
|
export class PriceService {
|
7
8
|
// ─── Prices ──────────────────────────────────────────────────────────
|
@@ -39,6 +40,12 @@ export class PriceService {
|
|
39
40
|
if (price === undefined || price === null) {
|
40
41
|
throw new Error();
|
41
42
|
}
|
43
|
+
if (priceSource.symbol.startsWith("0x")) {
|
44
|
+
await TokenService.updateAddressPrices(priceSource.symbol, price);
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
await TokenService.updateSymbolPrices(priceSource.symbol, price, []);
|
48
|
+
}
|
42
49
|
return price;
|
43
50
|
}
|
44
51
|
catch {
|