@merkl/api 0.10.346 → 0.10.348
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/cache/declaration.d.ts +5 -0
- package/dist/src/cache/declaration.js +5 -0
- package/dist/src/eden/index.d.ts +136 -1
- package/dist/src/index.d.ts +50 -0
- package/dist/src/libs/campaigns/utils/getUniswapV4Pools.d.ts +7 -0
- package/dist/src/libs/campaigns/utils/getUniswapV4Pools.js +109 -0
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +32 -0
- package/dist/src/modules/v4/campaign/campaign.controller.js +7 -1
- package/dist/src/modules/v4/campaign/campaign.model.d.ts +8 -0
- package/dist/src/modules/v4/campaign/campaign.model.js +5 -0
- package/dist/src/modules/v4/campaign/campaign.repository.d.ts +16 -1
- package/dist/src/modules/v4/campaign/campaign.repository.js +7 -1
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +16 -1
- package/dist/src/modules/v4/campaign/campaign.service.js +14 -1
- package/dist/src/modules/v4/programPayload/programPayload.repository.d.ts +19 -2
- package/dist/src/modules/v4/programPayload/programPayload.repository.js +272 -6
- package/dist/src/modules/v4/router.d.ts +32 -0
- package/dist/src/routes/v3/router.d.ts +18 -0
- package/dist/src/routes/v3/router.js +3 -1
- package/dist/src/routes/v3/uniswapv4.d.ts +45 -0
- package/dist/src/routes/v3/uniswapv4.js +9 -0
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/eden/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Campaign as CampaignResource } from "../modules/v4";
|
1
|
+
import type { Campaign as CampaignResource, CampaignWithParams } from "../modules/v4";
|
2
2
|
import type { CampaignType } from "../../database/api/.generated";
|
3
3
|
declare const eden: {
|
4
4
|
index: {
|
@@ -724,6 +724,35 @@ declare const eden: {
|
|
724
724
|
200: string;
|
725
725
|
}>>;
|
726
726
|
};
|
727
|
+
metadata: {
|
728
|
+
patch: (body: {
|
729
|
+
url: string;
|
730
|
+
campaignId: string;
|
731
|
+
distributionChain: number;
|
732
|
+
}, options: {
|
733
|
+
headers: {
|
734
|
+
authorization: string;
|
735
|
+
};
|
736
|
+
query?: Record<string, unknown> | undefined;
|
737
|
+
fetch?: RequestInit | undefined;
|
738
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
739
|
+
200: {
|
740
|
+
type: import("../../database/api/.generated").$Enums.CampaignType;
|
741
|
+
id: string;
|
742
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
743
|
+
subType: number | null;
|
744
|
+
startTimestamp: bigint;
|
745
|
+
endTimestamp: bigint;
|
746
|
+
computeChainId: number;
|
747
|
+
distributionChainId: number;
|
748
|
+
campaignId: string;
|
749
|
+
rewardTokenId: string;
|
750
|
+
amount: string;
|
751
|
+
opportunityId: string;
|
752
|
+
creatorAddress: string;
|
753
|
+
};
|
754
|
+
}>>;
|
755
|
+
};
|
727
756
|
index: {
|
728
757
|
get: (options: {
|
729
758
|
headers?: Record<string, unknown> | undefined;
|
@@ -3130,6 +3159,19 @@ declare const eden: {
|
|
3130
3159
|
};
|
3131
3160
|
}>>;
|
3132
3161
|
};
|
3162
|
+
uniswapv4: {
|
3163
|
+
get: (options: {
|
3164
|
+
headers?: Record<string, unknown> | undefined;
|
3165
|
+
query: {};
|
3166
|
+
fetch?: RequestInit | undefined;
|
3167
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
3168
|
+
200: {
|
3169
|
+
[x: string]: {
|
3170
|
+
[poolId: string]: UniswapV4PoolType;
|
3171
|
+
} | undefined;
|
3172
|
+
};
|
3173
|
+
}>>;
|
3174
|
+
};
|
3133
3175
|
};
|
3134
3176
|
};
|
3135
3177
|
type Api = typeof eden;
|
@@ -3993,6 +4035,38 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
3993
4035
|
};
|
3994
4036
|
};
|
3995
4037
|
};
|
4038
|
+
} & {
|
4039
|
+
metadata: {
|
4040
|
+
patch: {
|
4041
|
+
body: {
|
4042
|
+
url: string;
|
4043
|
+
campaignId: string;
|
4044
|
+
distributionChain: number;
|
4045
|
+
};
|
4046
|
+
params: {};
|
4047
|
+
query: unknown;
|
4048
|
+
headers: {
|
4049
|
+
authorization: string;
|
4050
|
+
};
|
4051
|
+
response: {
|
4052
|
+
200: {
|
4053
|
+
type: import("../../database/api/.generated").$Enums.CampaignType;
|
4054
|
+
id: string;
|
4055
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
4056
|
+
subType: number | null;
|
4057
|
+
startTimestamp: bigint;
|
4058
|
+
endTimestamp: bigint;
|
4059
|
+
computeChainId: number;
|
4060
|
+
distributionChainId: number;
|
4061
|
+
campaignId: string;
|
4062
|
+
rewardTokenId: string;
|
4063
|
+
amount: string;
|
4064
|
+
opportunityId: string;
|
4065
|
+
creatorAddress: string;
|
4066
|
+
};
|
4067
|
+
};
|
4068
|
+
};
|
4069
|
+
};
|
3996
4070
|
} & {
|
3997
4071
|
index: {
|
3998
4072
|
get: {
|
@@ -7068,6 +7142,24 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
7068
7142
|
};
|
7069
7143
|
};
|
7070
7144
|
};
|
7145
|
+
} & {
|
7146
|
+
v3: {
|
7147
|
+
uniswapv4: {
|
7148
|
+
get: {
|
7149
|
+
body: unknown;
|
7150
|
+
params: {};
|
7151
|
+
query: {};
|
7152
|
+
headers: unknown;
|
7153
|
+
response: {
|
7154
|
+
200: {
|
7155
|
+
[x: string]: {
|
7156
|
+
[poolId: string]: UniswapV4PoolType;
|
7157
|
+
} | undefined;
|
7158
|
+
};
|
7159
|
+
};
|
7160
|
+
};
|
7161
|
+
};
|
7162
|
+
};
|
7071
7163
|
}, {
|
7072
7164
|
derive: {};
|
7073
7165
|
resolve: {};
|
@@ -7800,6 +7892,35 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
7800
7892
|
200: string;
|
7801
7893
|
}>>;
|
7802
7894
|
};
|
7895
|
+
metadata: {
|
7896
|
+
patch: (body: {
|
7897
|
+
url: string;
|
7898
|
+
campaignId: string;
|
7899
|
+
distributionChain: number;
|
7900
|
+
}, options: {
|
7901
|
+
headers: {
|
7902
|
+
authorization: string;
|
7903
|
+
};
|
7904
|
+
query?: Record<string, unknown> | undefined;
|
7905
|
+
fetch?: RequestInit | undefined;
|
7906
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
7907
|
+
200: {
|
7908
|
+
type: import("../../database/api/.generated").$Enums.CampaignType;
|
7909
|
+
id: string;
|
7910
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
7911
|
+
subType: number | null;
|
7912
|
+
startTimestamp: bigint;
|
7913
|
+
endTimestamp: bigint;
|
7914
|
+
computeChainId: number;
|
7915
|
+
distributionChainId: number;
|
7916
|
+
campaignId: string;
|
7917
|
+
rewardTokenId: string;
|
7918
|
+
amount: string;
|
7919
|
+
opportunityId: string;
|
7920
|
+
creatorAddress: string;
|
7921
|
+
};
|
7922
|
+
}>>;
|
7923
|
+
};
|
7803
7924
|
index: {
|
7804
7925
|
get: (options: {
|
7805
7926
|
headers?: Record<string, unknown> | undefined;
|
@@ -10206,11 +10327,25 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
|
|
10206
10327
|
};
|
10207
10328
|
}>>;
|
10208
10329
|
};
|
10330
|
+
uniswapv4: {
|
10331
|
+
get: (options: {
|
10332
|
+
headers?: Record<string, unknown> | undefined;
|
10333
|
+
query: {};
|
10334
|
+
fetch?: RequestInit | undefined;
|
10335
|
+
}) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
|
10336
|
+
200: {
|
10337
|
+
[x: string]: {
|
10338
|
+
[poolId: string]: UniswapV4PoolType;
|
10339
|
+
} | undefined;
|
10340
|
+
};
|
10341
|
+
}>>;
|
10342
|
+
};
|
10209
10343
|
};
|
10210
10344
|
};
|
10211
10345
|
export type Opportunity = FromPromise<Api["v4"]["opportunities"]["index"]["get"]>;
|
10212
10346
|
export type Protocol = FromPromise<Api["v4"]["protocols"]["index"]["get"]>;
|
10213
10347
|
export type Campaign<C extends CampaignType = CampaignType> = CampaignResource<C>["model"];
|
10348
|
+
export type CampaignParams<C extends CampaignType = CampaignType> = CampaignWithParams<C>["model"]["params"];
|
10214
10349
|
export type Chain = FromPromise<Api["v4"]["chains"]["index"]["get"]>;
|
10215
10350
|
export type Explorer = FromPromise<Api["v4"]["chains"]["index"]["get"]>["explorers"][number];
|
10216
10351
|
export type Token = FromPromise<Api["v4"]["tokens"]["index"]["get"]>;
|
package/dist/src/index.d.ts
CHANGED
@@ -852,6 +852,38 @@ declare const app: Elysia<"", false, {
|
|
852
852
|
};
|
853
853
|
};
|
854
854
|
};
|
855
|
+
} & {
|
856
|
+
metadata: {
|
857
|
+
patch: {
|
858
|
+
body: {
|
859
|
+
url: string;
|
860
|
+
campaignId: string;
|
861
|
+
distributionChain: number;
|
862
|
+
};
|
863
|
+
params: {};
|
864
|
+
query: unknown;
|
865
|
+
headers: {
|
866
|
+
authorization: string;
|
867
|
+
};
|
868
|
+
response: {
|
869
|
+
200: {
|
870
|
+
type: import("../database/api/.generated").$Enums.CampaignType;
|
871
|
+
id: string;
|
872
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
873
|
+
subType: number | null;
|
874
|
+
startTimestamp: bigint;
|
875
|
+
endTimestamp: bigint;
|
876
|
+
computeChainId: number;
|
877
|
+
distributionChainId: number;
|
878
|
+
campaignId: string;
|
879
|
+
rewardTokenId: string;
|
880
|
+
amount: string;
|
881
|
+
opportunityId: string;
|
882
|
+
creatorAddress: string;
|
883
|
+
};
|
884
|
+
};
|
885
|
+
};
|
886
|
+
};
|
855
887
|
} & {
|
856
888
|
index: {
|
857
889
|
get: {
|
@@ -3927,6 +3959,24 @@ declare const app: Elysia<"", false, {
|
|
3927
3959
|
};
|
3928
3960
|
};
|
3929
3961
|
};
|
3962
|
+
} & {
|
3963
|
+
v3: {
|
3964
|
+
uniswapv4: {
|
3965
|
+
get: {
|
3966
|
+
body: unknown;
|
3967
|
+
params: {};
|
3968
|
+
query: {};
|
3969
|
+
headers: unknown;
|
3970
|
+
response: {
|
3971
|
+
200: {
|
3972
|
+
[x: string]: {
|
3973
|
+
[poolId: string]: UniswapV4PoolType;
|
3974
|
+
} | undefined;
|
3975
|
+
};
|
3976
|
+
};
|
3977
|
+
};
|
3978
|
+
};
|
3979
|
+
};
|
3930
3980
|
}, {
|
3931
3981
|
derive: {};
|
3932
3982
|
resolve: {};
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import { type MerklChainId, type UniswapV4PoolType } from "@sdk";
|
2
|
+
export type UniswapV4PoolsReturnType = {
|
3
|
+
[chainId in MerklChainId]?: {
|
4
|
+
[poolId: string]: UniswapV4PoolType;
|
5
|
+
};
|
6
|
+
};
|
7
|
+
export declare const getUniswapV4PoolsWithCache: () => Promise<UniswapV4PoolsReturnType>;
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { Redis } from "../../../cache";
|
2
|
+
import { log } from "../../../utils/logger";
|
3
|
+
import { providers } from "../../../utils/providers";
|
4
|
+
import { ChainInteractionService, ERC20Interface, NETWORK_LABELS, NULL_ADDRESS, PoolManagerInterface, UniswapV4Addresses, getContractCreationBlock, } from "@sdk";
|
5
|
+
import { safeFetchLogs } from "./fetchLogs";
|
6
|
+
const UNIV4_CHAINIDS = Object.keys(UniswapV4Addresses).map((x) => Number(x));
|
7
|
+
async function getUniswapV4Pools() {
|
8
|
+
const res = {};
|
9
|
+
for (let chainId of UNIV4_CHAINIDS) {
|
10
|
+
chainId = chainId;
|
11
|
+
res[chainId] = {};
|
12
|
+
const poolManagerAddress = UniswapV4Addresses[chainId]?.PoolManager ?? NULL_ADDRESS;
|
13
|
+
const jsonRPCprovider = providers[chainId];
|
14
|
+
try {
|
15
|
+
const fromBlock = await getContractCreationBlock(poolManagerAddress, jsonRPCprovider);
|
16
|
+
const toBlock = await jsonRPCprovider.getBlockNumber();
|
17
|
+
const logs = await safeFetchLogs(chainId, // TODO: rm type enforcing
|
18
|
+
[PoolManagerInterface.getEventTopic("Initialize")], [poolManagerAddress], fromBlock, toBlock);
|
19
|
+
const decodedPools = await Promise.all(logs.map(async (log) => {
|
20
|
+
const [id, currency0, currency1, fee, tickSpacing, hooks] = PoolManagerInterface.decodeEventLog("Initialize", log.data, log.topics);
|
21
|
+
// Respect typing
|
22
|
+
return {
|
23
|
+
poolId: id,
|
24
|
+
chainId: chainId,
|
25
|
+
currency0: currency0,
|
26
|
+
currency1: currency1,
|
27
|
+
tickSpacing: tickSpacing,
|
28
|
+
lpFee: fee,
|
29
|
+
hooks: hooks,
|
30
|
+
initializeBlock: Number(log.blockNumber),
|
31
|
+
};
|
32
|
+
}));
|
33
|
+
log.local(`fetched ${decodedPools.length} pool(s) on ${NETWORK_LABELS[chainId] ?? "Sepolia"} between blocks ${fromBlock} and ${toBlock}`);
|
34
|
+
/** Extra calls batch to get the collateral addresses */
|
35
|
+
const resCurrencies = await ChainInteractionService(chainId).fetchState(decodedPools.flatMap(pool => {
|
36
|
+
return [
|
37
|
+
{
|
38
|
+
allowFailure: true,
|
39
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
40
|
+
target: pool.currency0,
|
41
|
+
},
|
42
|
+
{
|
43
|
+
allowFailure: true,
|
44
|
+
callData: ERC20Interface.encodeFunctionData("decimals"),
|
45
|
+
target: pool.currency0,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
allowFailure: true,
|
49
|
+
callData: ERC20Interface.encodeFunctionData("symbol"),
|
50
|
+
target: pool.currency1,
|
51
|
+
},
|
52
|
+
{
|
53
|
+
allowFailure: true,
|
54
|
+
callData: ERC20Interface.encodeFunctionData("decimals"),
|
55
|
+
target: pool.currency1,
|
56
|
+
},
|
57
|
+
].filter(x => x.target !== NULL_ADDRESS);
|
58
|
+
}));
|
59
|
+
let index = 0;
|
60
|
+
for (const pool of decodedPools) {
|
61
|
+
let symbolCurrency0;
|
62
|
+
let decimalsCurrency0;
|
63
|
+
if (pool.currency0 !== NULL_ADDRESS) {
|
64
|
+
symbolCurrency0 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index].returnData)[0];
|
65
|
+
decimalsCurrency0 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 1].returnData)[0];
|
66
|
+
}
|
67
|
+
else {
|
68
|
+
symbolCurrency0 = "ETH";
|
69
|
+
decimalsCurrency0 = 18;
|
70
|
+
index -= 2;
|
71
|
+
}
|
72
|
+
let symbolCurrency1;
|
73
|
+
let decimalsCurrency1;
|
74
|
+
if (pool.currency1 !== NULL_ADDRESS) {
|
75
|
+
symbolCurrency1 = ERC20Interface.decodeFunctionResult("symbol", resCurrencies[index + 2].returnData)[0];
|
76
|
+
decimalsCurrency1 = ERC20Interface.decodeFunctionResult("decimals", resCurrencies[index + 3].returnData)[0];
|
77
|
+
}
|
78
|
+
else {
|
79
|
+
symbolCurrency1 = "ETH";
|
80
|
+
decimalsCurrency1 = 18;
|
81
|
+
index -= 2;
|
82
|
+
}
|
83
|
+
const id = pool.poolId;
|
84
|
+
res[chainId][id ?? "unknownKey"] = {
|
85
|
+
chainId: pool.chainId,
|
86
|
+
currency0: pool.currency0,
|
87
|
+
currency1: pool.currency1,
|
88
|
+
decimalsCurrency0,
|
89
|
+
decimalsCurrency1,
|
90
|
+
hooks: pool.hooks,
|
91
|
+
initializeBlock: pool.initializeBlock,
|
92
|
+
lpFee: pool.lpFee,
|
93
|
+
poolId: id,
|
94
|
+
poolKey: pool.poolKey,
|
95
|
+
symbolCurrency0,
|
96
|
+
symbolCurrency1,
|
97
|
+
tickSpacing: pool.tickSpacing,
|
98
|
+
};
|
99
|
+
index += 4;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
catch (e) {
|
103
|
+
log.error(`issue when fetching UniswapV4 pools on ${chainId}`, e);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
log.info("✅ successfully fetched pools on UniswapV4");
|
107
|
+
return res;
|
108
|
+
}
|
109
|
+
export const getUniswapV4PoolsWithCache = async () => await Redis.getOrSet("UniswapV4Pools", getUniswapV4Pools);
|
@@ -74,6 +74,38 @@ export declare const CampaignController: Elysia<"/campaigns", false, {
|
|
74
74
|
};
|
75
75
|
};
|
76
76
|
};
|
77
|
+
} & {
|
78
|
+
metadata: {
|
79
|
+
patch: {
|
80
|
+
body: {
|
81
|
+
url: string;
|
82
|
+
campaignId: string;
|
83
|
+
distributionChain: number;
|
84
|
+
};
|
85
|
+
params: {};
|
86
|
+
query: unknown;
|
87
|
+
headers: {
|
88
|
+
authorization: string;
|
89
|
+
};
|
90
|
+
response: {
|
91
|
+
200: {
|
92
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
93
|
+
id: string;
|
94
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
95
|
+
subType: number | null;
|
96
|
+
startTimestamp: bigint;
|
97
|
+
endTimestamp: bigint;
|
98
|
+
computeChainId: number;
|
99
|
+
distributionChainId: number;
|
100
|
+
campaignId: string;
|
101
|
+
rewardTokenId: string;
|
102
|
+
amount: string;
|
103
|
+
opportunityId: string;
|
104
|
+
creatorAddress: string;
|
105
|
+
};
|
106
|
+
};
|
107
|
+
};
|
108
|
+
};
|
77
109
|
} & {
|
78
110
|
index: {
|
79
111
|
get: {
|
@@ -3,7 +3,7 @@ import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.gua
|
|
3
3
|
import Elysia, { t } from "elysia";
|
4
4
|
import { throwOnUnsupportedChainId } from "src/utils/throw";
|
5
5
|
import { ChainUniqueDto } from "../chain";
|
6
|
-
import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, UpdateCampaignDto } from "./campaign.model";
|
6
|
+
import { CampaignResourceDto, CreateCampaignDto, GetCampaignQueryDto, UpdateCampaignDto, UpdateMetaDataCampaignDto, } from "./campaign.model";
|
7
7
|
import { CampaignService } from "./campaign.service";
|
8
8
|
// ─── Campaigns Controller ────────────────────────────────────────────────────
|
9
9
|
export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { tags: ["Campaigns"] } })
|
@@ -19,6 +19,12 @@ export const CampaignController = new Elysia({ prefix: "/campaigns", detail: { t
|
|
19
19
|
headers: AuthorizationHeadersDto,
|
20
20
|
body: UpdateCampaignDto,
|
21
21
|
detail: { hide: true },
|
22
|
+
})
|
23
|
+
.patch("/metadata", async ({ body }) => await CampaignService.updateMetaData(body), {
|
24
|
+
beforeHandle: BackOfficeGuard,
|
25
|
+
headers: AuthorizationHeadersDto,
|
26
|
+
body: UpdateMetaDataCampaignDto,
|
27
|
+
detail: { hide: true },
|
22
28
|
})
|
23
29
|
// ─── Get Many Campaigns ──────────────────────────────────────────────
|
24
30
|
.get("/", async ({ query }) => await CampaignService.findMany(query), {
|
@@ -112,6 +112,11 @@ export declare const UpdateCampaignDto: import("@sinclair/typebox").TObject<{
|
|
112
112
|
opportunityIdentifier: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
113
113
|
tags: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
|
114
114
|
}>;
|
115
|
+
export declare const UpdateMetaDataCampaignDto: import("@sinclair/typebox").TObject<{
|
116
|
+
distributionChain: import("@sinclair/typebox").TNumber;
|
117
|
+
campaignId: import("@sinclair/typebox").TString;
|
118
|
+
url: import("@sinclair/typebox").TString;
|
119
|
+
}>;
|
115
120
|
export declare const GetCampaignQueryDto: import("@sinclair/typebox").TObject<{
|
116
121
|
creatorTag: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
|
117
122
|
chainId: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
|
@@ -156,6 +161,9 @@ export type CreateCampaignModel = typeof CreateCampaignDto.static & {
|
|
156
161
|
export type UpdateCampaignModel = typeof UpdateCampaignDto.static & {
|
157
162
|
id: string;
|
158
163
|
};
|
164
|
+
export type UpdateMetaDataCampaignModel = typeof UpdateMetaDataCampaignDto.static & {
|
165
|
+
url: string;
|
166
|
+
};
|
159
167
|
export type extendedUpdateCampaignModel = UpdateCampaignModel & {
|
160
168
|
opportunityId: string;
|
161
169
|
};
|
@@ -73,6 +73,11 @@ export const UpdateCampaignDto = t.Object({
|
|
73
73
|
opportunityIdentifier: t.Optional(t.String()),
|
74
74
|
tags: t.Optional(t.Array(t.String())),
|
75
75
|
});
|
76
|
+
export const UpdateMetaDataCampaignDto = t.Object({
|
77
|
+
distributionChain: t.Numeric(),
|
78
|
+
campaignId: t.String(),
|
79
|
+
url: t.String(),
|
80
|
+
});
|
76
81
|
export const GetCampaignQueryDto = t.Object({
|
77
82
|
creatorTag: t.Optional(t.String({ description: "Filter campaigns created by a user who has a specific tag" })),
|
78
83
|
chainId: t.Optional(t.Numeric({
|
@@ -135,7 +135,22 @@ export declare abstract class CampaignRepository {
|
|
135
135
|
campaignId: string;
|
136
136
|
}[]>;
|
137
137
|
static findChains(): Promise<Record<string, ChainId>>;
|
138
|
-
static
|
138
|
+
static updateOpportunity(id: string, data: extendedUpdateCampaignModel): Promise<{
|
139
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
140
|
+
id: string;
|
141
|
+
params: Prisma.JsonValue;
|
142
|
+
subType: number | null;
|
143
|
+
startTimestamp: bigint;
|
144
|
+
endTimestamp: bigint;
|
145
|
+
computeChainId: number;
|
146
|
+
distributionChainId: number;
|
147
|
+
campaignId: string;
|
148
|
+
rewardTokenId: string;
|
149
|
+
amount: string;
|
150
|
+
opportunityId: string;
|
151
|
+
creatorAddress: string;
|
152
|
+
}>;
|
153
|
+
static updateMetaData(id: string, params: string): Promise<{
|
139
154
|
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
140
155
|
id: string;
|
141
156
|
params: Prisma.JsonValue;
|
@@ -313,7 +313,7 @@ export class CampaignRepository {
|
|
313
313
|
return acc;
|
314
314
|
}, {});
|
315
315
|
}
|
316
|
-
static async
|
316
|
+
static async updateOpportunity(id, data) {
|
317
317
|
const updateData = {
|
318
318
|
Opportunity: {
|
319
319
|
connect: { id: data.opportunityId },
|
@@ -321,4 +321,10 @@ export class CampaignRepository {
|
|
321
321
|
};
|
322
322
|
return await apiDbClient.campaign.update({ where: { id }, data: updateData });
|
323
323
|
}
|
324
|
+
static async updateMetaData(id, params) {
|
325
|
+
const updateData = {
|
326
|
+
params: JSON.parse(params),
|
327
|
+
};
|
328
|
+
return await apiDbClient.campaign.update({ where: { id }, data: updateData });
|
329
|
+
}
|
324
330
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type CampaignUnique, type CampaignWithParams, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel, type UpdateCampaignModel } from "./";
|
1
|
+
import { type CampaignUnique, type CampaignWithParams, type ConvertedCampaignType, type CreateCampaignModel, type GetCampaignQueryModel, type UpdateCampaignModel, type UpdateMetaDataCampaignModel } from "./";
|
2
2
|
import { CampaignRepository } from "./campaign.repository";
|
3
3
|
import type { CampaignType } from "../../../../database/api/.generated";
|
4
4
|
import { type CampaignParameters, type Campaign as CampaignTypeV3, type ChainId } from "@sdk";
|
@@ -19,6 +19,21 @@ export declare abstract class CampaignService {
|
|
19
19
|
opportunityId: string;
|
20
20
|
creatorAddress: string;
|
21
21
|
} | undefined>;
|
22
|
+
static updateMetaData(campaign: Omit<UpdateMetaDataCampaignModel, "id">): Promise<{
|
23
|
+
type: import("../../../../database/api/.generated").$Enums.CampaignType;
|
24
|
+
id: string;
|
25
|
+
params: import("database/api/.generated/runtime/library").JsonValue;
|
26
|
+
subType: number | null;
|
27
|
+
startTimestamp: bigint;
|
28
|
+
endTimestamp: bigint;
|
29
|
+
computeChainId: number;
|
30
|
+
distributionChainId: number;
|
31
|
+
campaignId: string;
|
32
|
+
rewardTokenId: string;
|
33
|
+
amount: string;
|
34
|
+
opportunityId: string;
|
35
|
+
creatorAddress: string;
|
36
|
+
}>;
|
22
37
|
static moveToOpportunity(campaign: Omit<UpdateCampaignModel, "id">, upsert?: boolean): Promise<string>;
|
23
38
|
static createMany(campaigns: Omit<CreateCampaignModel, "id">[], upsert?: boolean): Promise<{
|
24
39
|
success: number;
|
@@ -20,6 +20,19 @@ export class CampaignService {
|
|
20
20
|
await OpportunityService.createFromCampaign(campaign);
|
21
21
|
return await CampaignRepository.upsert({ id, ...campaign });
|
22
22
|
}
|
23
|
+
static async updateMetaData(campaign) {
|
24
|
+
const id = CampaignService.hashId({
|
25
|
+
distributionChain: campaign.distributionChain,
|
26
|
+
campaignId: campaign.campaignId,
|
27
|
+
});
|
28
|
+
const existingCampaign = await CampaignService.findUniqueOrThrow(campaign);
|
29
|
+
const params = existingCampaign.params;
|
30
|
+
if ("url" in params) {
|
31
|
+
params.url = campaign.url;
|
32
|
+
}
|
33
|
+
const updatedParams = JSON.stringify(params);
|
34
|
+
return await CampaignRepository.updateMetaData(id, updatedParams);
|
35
|
+
}
|
23
36
|
static async moveToOpportunity(campaign, upsert = false) {
|
24
37
|
const id = CampaignService.hashId({
|
25
38
|
distributionChain: campaign.distributionChain,
|
@@ -61,7 +74,7 @@ export class CampaignService {
|
|
61
74
|
// Create new opportunity
|
62
75
|
await OpportunityService.createFromCampaign(updatedCampaign, upsert);
|
63
76
|
// Move campaign to new opportunity
|
64
|
-
await CampaignRepository.
|
77
|
+
await CampaignRepository.updateOpportunity(id, { id, ...updatedCampaignData });
|
65
78
|
// Update new opportunity with campaign
|
66
79
|
// await OpportunityService.recreate(opportunityId);
|
67
80
|
// Remov (update) campaign from old opportunity
|
@@ -34,7 +34,8 @@ export declare enum pufferCampaigns {
|
|
34
34
|
uniswapv3_vt_weth = "0xa56600e670724b42F38d3A6e4B25e8D786B4F5f9",
|
35
35
|
venus_pufeth = "0xE0ee5dDeBFe0abe0a4Af50299D68b74Cec31668e",
|
36
36
|
unifiBTC = "0x170D847A8320F3B6A77eE15B0CAE430e3eC933a0",
|
37
|
-
unifiUSD = "0x82c40e07277eBb92935f79cE92268F80dDc7caB4"
|
37
|
+
unifiUSD = "0x82c40e07277eBb92935f79cE92268F80dDc7caB4",
|
38
|
+
CARROT_USDC = "0xf00032d0f95e8f43e750c51d0188dca33cc5a8ea"
|
38
39
|
}
|
39
40
|
export declare enum zkSyncCampaigns {
|
40
41
|
Izumi_Finance_Zk_Weth = "Izumi Finance ZK/WETH 0xd62bc9f19bd94fde9c41df4b6eb6419ea6b8e25c",
|
@@ -165,7 +166,23 @@ export declare enum modeCampaigns {
|
|
165
166
|
Meson_Izumi_WETH_mBTC_Mode = "Meson Izumi WETH/m-BTC 0xD40B3D30aEe24e7B8d3aE6501024203e6c4e9EB6",
|
166
167
|
Ionic_Supply_ionoBTC_Mode = "Ionic supply oBTC 0x48c234ab217f077df3c7f541b67d90436cf59b27",
|
167
168
|
Ionic_Supply_ionuniBTC_Mode = "Ionic supply uniBTC 0xa48750877a83f7dec11f722178c317b54a44d142",
|
168
|
-
Lisa_Labs_Kim_vLISTX_USDC_Mode = "Lisa Labs Kim vLISTX/USDC 0xd54aba804a676c8f265e2e6742d7b86d383d093b"
|
169
|
+
Lisa_Labs_Kim_vLISTX_USDC_Mode = "Lisa Labs Kim vLISTX/USDC 0xd54aba804a676c8f265e2e6742d7b86d383d093b",
|
170
|
+
BMX_Hold_sbfBMX_Mode = "BMX Hold sbfBMX 0x548f93779fBC992010C07467cBaf329DD5F059B7",
|
171
|
+
Etherfi_Add_liquidity_wMLT_vault_Mode = "Add Liquidity to wMLT vault 0x8b2EeA0999876AAB1E7955fe01A5D261b570452C",
|
172
|
+
Etherfi_Kim_weETH_WETH_Mode = "Ether.fi Kim weETH/WETH 0xE24C8feB38ca2B18b542994BFBA7E70880171035",
|
173
|
+
Kim_Steer_FLS_WETH_USDC_Mode = "Kim Steer FLS WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
174
|
+
Kim_Steer_EES_v2_WETH_USDC_Mode = "Kim Steer EES V2 WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
175
|
+
Kim_Steer_CRS_v2_WETH_USDC_Mode = "Kim Steer CRS V2 WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
176
|
+
Kim_Gamma_WETH_USDC_Mode = "Kim Gamma Long-Short WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
177
|
+
Kim_v4_WETH_USDC_Mode = "Kim v4 WETH/USDC 0x468cc91df6f669cae6cdce766995bd7874052fbc",
|
178
|
+
Kim_Ichi_SSD_WETH_KIM_Mode = "Kim Ichi SSD WETH/KIM 0x3C3a173984e3152FEd868345904eC0C9325FA516",
|
179
|
+
Kim_Steer_CRS_V2_WETH_KIM_Mode = "Kim Steer CRS V2 WETH/KIM 0x3C3a173984e3152FEd868345904eC0C9325FA516",
|
180
|
+
Kim_Gamma_WETH_KIM_Mode = "Kim Gamma Long-Short WETH/KIM 0x3C3a173984e3152FEd868345904eC0C9325FA516",
|
181
|
+
Kim_v4_WETH_KIM_Mode = "Kim v4 WETH/Kim 0x3C3a173984e3152FEd868345904eC0C9325FA516",
|
182
|
+
Kim_Ichi_SSD_WETH_MODE_Mode = "Kim Ichi SSD WETH/Mode 0x8cfE2A02dfBAbC56aE7e573170E35f88A38BeA55",
|
183
|
+
Kim_Steer_CRS_V2_WETH_MODE_Mode = "Kim Steer CRS V2 WETH/Mode 0x8cfE2A02dfBAbC56aE7e573170E35f88A38BeA55",
|
184
|
+
Kim_Gamma_WETH_MODE_Mode = "Kim Gamma Narrow WETH/Mode 0x8cfE2A02dfBAbC56aE7e573170E35f88A38BeA55",
|
185
|
+
Kim_V4_WETH_MODE_Mode = "Kim V4 WETH/Mode 0x8cfE2A02dfBAbC56aE7e573170E35f88A38BeA55"
|
169
186
|
}
|
170
187
|
declare const ModeInterfaceCampaigns: {
|
171
188
|
[key in modeCampaigns]: partialConfig;
|