@merkl/api 0.16.13 → 0.16.15
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/backgroundJobs/jobs/priceUpdater.js +1 -1
- package/dist/src/eden/index.d.ts +363 -413
- package/dist/src/entities/opportunity.js +17 -0
- package/dist/src/index.d.ts +84 -82
- package/dist/src/libs/campaigns/campaignTypes/EncompassingDynamicData.d.ts +5 -0
- package/dist/src/libs/campaigns/campaignTypes/EncompassingDynamicData.js +34 -0
- package/dist/src/libs/campaigns/campaignsDynamicData.js +4 -0
- package/dist/src/libs/merklChainData.js +1 -1
- package/dist/src/libs/tokens/balances.js +1 -1
- package/dist/src/modules/v4/accounting/accounting.service.js +1 -1
- package/dist/src/modules/v4/campaign/campaign.controller.d.ts +1 -13
- package/dist/src/modules/v4/campaign/campaign.repository.js +2 -2
- package/dist/src/modules/v4/campaign/campaign.service.d.ts +2 -26
- package/dist/src/modules/v4/campaign/campaign.service.js +3 -3
- package/dist/src/modules/v4/claims/claims.controller.d.ts +1 -1
- package/dist/src/modules/v4/enso/enso.model.d.ts +1 -1
- package/dist/src/modules/v4/enso/enso.model.js +1 -1
- package/dist/src/modules/v4/enso/enso.service.d.ts +2 -2
- package/dist/src/modules/v4/enso/enso.service.js +2 -2
- package/dist/src/modules/v4/interaction/interaction.model.d.ts +1 -1
- package/dist/src/modules/v4/kyberzap/kyberzap.service.d.ts +1 -1
- package/dist/src/modules/v4/kyberzap/kyberzap.service.js +1 -1
- package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +4 -40
- package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +12 -108
- package/dist/src/modules/v4/opportunity/opportunity.service.js +8 -5
- package/dist/src/modules/v4/opportunity/subservices/getAjnaMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getBadgerMetadata.service.js +1 -1
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.d.ts +3 -0
- package/dist/src/modules/v4/opportunity/subservices/getEncompassingMetadata.service.js +35 -0
- package/dist/src/modules/v4/protocol/protocol.model.d.ts +1 -1
- package/dist/src/modules/v4/protocol/protocol.model.js +4 -0
- package/dist/src/modules/v4/protocol/protocol.service.js +6 -2
- package/dist/src/modules/v4/referral/referral.controller.d.ts +82 -0
- package/dist/src/modules/v4/referral/referral.controller.js +25 -0
- package/dist/src/modules/v4/referral/referral.model.d.ts +10 -0
- package/dist/src/modules/v4/referral/referral.model.js +12 -0
- package/dist/src/modules/v4/referral/referral.service.d.ts +216 -0
- package/dist/src/modules/v4/referral/referral.service.js +170 -0
- package/dist/src/modules/v4/reward/reward.controller.js +3 -3
- package/dist/src/modules/v4/reward/reward.repository.js +2 -2
- package/dist/src/modules/v4/reward/reward.service.js +1 -1
- package/dist/src/modules/v4/router.d.ts +84 -82
- package/dist/src/modules/v4/router.js +3 -1
- package/dist/src/modules/v4/token/token.controller.d.ts +16 -28
- package/dist/src/modules/v4/token/token.controller.js +2 -1
- package/dist/src/modules/v4/token/token.service.d.ts +5 -69
- package/dist/src/routes/v3/lostyield.js +1 -1
- package/dist/tsconfig.package.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/modules/v4/token/index.d.ts +0 -3
- package/dist/src/modules/v4/token/index.js +0 -3
@@ -0,0 +1,216 @@
|
|
1
|
+
export declare abstract class ReferralService {
|
2
|
+
#private;
|
3
|
+
static abi: readonly [{
|
4
|
+
readonly name: "getReferralKeys";
|
5
|
+
readonly type: "function";
|
6
|
+
readonly stateMutability: "view";
|
7
|
+
readonly inputs: readonly [];
|
8
|
+
readonly outputs: readonly [{
|
9
|
+
readonly type: "string[]";
|
10
|
+
}];
|
11
|
+
}, {
|
12
|
+
readonly name: "getReferrerStatus";
|
13
|
+
readonly type: "function";
|
14
|
+
readonly stateMutability: "view";
|
15
|
+
readonly inputs: readonly [{
|
16
|
+
readonly type: "string";
|
17
|
+
readonly name: "key";
|
18
|
+
}, {
|
19
|
+
readonly type: "address";
|
20
|
+
readonly name: "user";
|
21
|
+
}];
|
22
|
+
readonly outputs: readonly [{
|
23
|
+
readonly type: "bytes32";
|
24
|
+
}];
|
25
|
+
}, {
|
26
|
+
readonly name: "referrerCodeMapping";
|
27
|
+
readonly type: "function";
|
28
|
+
readonly stateMutability: "view";
|
29
|
+
readonly inputs: readonly [{
|
30
|
+
readonly type: "string";
|
31
|
+
readonly name: "key";
|
32
|
+
}, {
|
33
|
+
readonly type: "address";
|
34
|
+
readonly name: "user";
|
35
|
+
}];
|
36
|
+
readonly outputs: readonly [{
|
37
|
+
readonly type: "string";
|
38
|
+
}];
|
39
|
+
}, {
|
40
|
+
readonly name: "codeToReferrer";
|
41
|
+
readonly type: "function";
|
42
|
+
readonly stateMutability: "view";
|
43
|
+
readonly inputs: readonly [{
|
44
|
+
readonly type: "string";
|
45
|
+
readonly name: "key";
|
46
|
+
}, {
|
47
|
+
readonly type: "string";
|
48
|
+
readonly name: "user";
|
49
|
+
}];
|
50
|
+
readonly outputs: readonly [{
|
51
|
+
readonly type: "address";
|
52
|
+
}];
|
53
|
+
}, {
|
54
|
+
readonly name: "getReferrer";
|
55
|
+
readonly type: "function";
|
56
|
+
readonly stateMutability: "view";
|
57
|
+
readonly inputs: readonly [{
|
58
|
+
readonly type: "string";
|
59
|
+
readonly name: "key";
|
60
|
+
}, {
|
61
|
+
readonly type: "address";
|
62
|
+
readonly name: "user";
|
63
|
+
}];
|
64
|
+
readonly outputs: readonly [{
|
65
|
+
readonly type: "address";
|
66
|
+
}];
|
67
|
+
}, {
|
68
|
+
readonly name: "getReferredUsers";
|
69
|
+
readonly type: "function";
|
70
|
+
readonly stateMutability: "view";
|
71
|
+
readonly inputs: readonly [{
|
72
|
+
readonly type: "string";
|
73
|
+
readonly name: "key";
|
74
|
+
}, {
|
75
|
+
readonly type: "address";
|
76
|
+
readonly name: "user";
|
77
|
+
}];
|
78
|
+
readonly outputs: readonly [{
|
79
|
+
readonly type: "address[]";
|
80
|
+
}];
|
81
|
+
}, {
|
82
|
+
readonly name: "acknowledgeReferrerByKey";
|
83
|
+
readonly type: "function";
|
84
|
+
readonly stateMutability: "nonpayable";
|
85
|
+
readonly inputs: readonly [{
|
86
|
+
readonly type: "string";
|
87
|
+
readonly name: "key";
|
88
|
+
}, {
|
89
|
+
readonly type: "string";
|
90
|
+
readonly name: "referrerCode";
|
91
|
+
}];
|
92
|
+
readonly outputs: readonly [];
|
93
|
+
}, {
|
94
|
+
readonly name: "getCostOfReferral";
|
95
|
+
readonly type: "function";
|
96
|
+
readonly stateMutability: "view";
|
97
|
+
readonly inputs: readonly [{
|
98
|
+
readonly type: "string";
|
99
|
+
readonly name: "key";
|
100
|
+
}];
|
101
|
+
readonly outputs: readonly [{
|
102
|
+
readonly type: "uint256";
|
103
|
+
}];
|
104
|
+
}, {
|
105
|
+
readonly name: "getPaymentToken";
|
106
|
+
readonly type: "function";
|
107
|
+
readonly stateMutability: "view";
|
108
|
+
readonly inputs: readonly [{
|
109
|
+
readonly type: "string";
|
110
|
+
readonly name: "key";
|
111
|
+
}];
|
112
|
+
readonly outputs: readonly [{
|
113
|
+
readonly type: "address";
|
114
|
+
}];
|
115
|
+
}, {
|
116
|
+
readonly name: "getReferrerStatusByKey";
|
117
|
+
readonly type: "function";
|
118
|
+
readonly stateMutability: "view";
|
119
|
+
readonly inputs: readonly [{
|
120
|
+
readonly type: "string";
|
121
|
+
readonly name: "key";
|
122
|
+
}, {
|
123
|
+
readonly type: "address";
|
124
|
+
readonly name: "referrer";
|
125
|
+
}];
|
126
|
+
readonly outputs: readonly [{
|
127
|
+
readonly type: "uint8";
|
128
|
+
}];
|
129
|
+
}, {
|
130
|
+
readonly name: "requiresAuthorization";
|
131
|
+
readonly type: "function";
|
132
|
+
readonly stateMutability: "view";
|
133
|
+
readonly inputs: readonly [{
|
134
|
+
readonly type: "string";
|
135
|
+
readonly name: "key";
|
136
|
+
}];
|
137
|
+
readonly outputs: readonly [{
|
138
|
+
readonly type: "bool";
|
139
|
+
}];
|
140
|
+
}, {
|
141
|
+
readonly name: "requiresRefererToBeSet";
|
142
|
+
readonly type: "function";
|
143
|
+
readonly stateMutability: "view";
|
144
|
+
readonly inputs: readonly [{
|
145
|
+
readonly type: "string";
|
146
|
+
readonly name: "key";
|
147
|
+
}];
|
148
|
+
readonly outputs: readonly [{
|
149
|
+
readonly type: "bool";
|
150
|
+
}];
|
151
|
+
}, {
|
152
|
+
readonly name: "becomeReferrer";
|
153
|
+
readonly type: "function";
|
154
|
+
readonly stateMutability: "payable";
|
155
|
+
readonly inputs: readonly [{
|
156
|
+
readonly type: "string";
|
157
|
+
readonly name: "key";
|
158
|
+
}, {
|
159
|
+
readonly type: "string";
|
160
|
+
readonly name: "referrerCode";
|
161
|
+
}];
|
162
|
+
readonly outputs: readonly [];
|
163
|
+
}];
|
164
|
+
static getReferralContract(chainId: number): "0xF39CC381B91f36238c77f42B9fF4D45376F80E5b" | undefined;
|
165
|
+
static isKeyAvailable(key: string, chainId: number): Promise<any>;
|
166
|
+
static getReferredUsers(chainId: number, key: string, address: string): Promise<any>;
|
167
|
+
static getReferralStatus(chainId: number, key: string, address: string): Promise<boolean>;
|
168
|
+
static generateCode(chainId: number, key: string, address: string): string;
|
169
|
+
static getCode(chainId: number, key: string, address: string): Promise<any>;
|
170
|
+
/**
|
171
|
+
* Get state & transaction for creating a referral code
|
172
|
+
* @param chainId of the referral contract
|
173
|
+
* @param key of referral
|
174
|
+
* @param address of the creator
|
175
|
+
*/
|
176
|
+
static getCodeOrTransaction(chainId: number, key: string, address: string): Promise<{
|
177
|
+
code: string;
|
178
|
+
referrer: boolean;
|
179
|
+
referredUsers: never[];
|
180
|
+
transaction: {
|
181
|
+
to: string;
|
182
|
+
data: `0x${string}`;
|
183
|
+
};
|
184
|
+
} | {
|
185
|
+
code: any;
|
186
|
+
referrer: boolean;
|
187
|
+
referredUsers: any;
|
188
|
+
transaction?: undefined;
|
189
|
+
}>;
|
190
|
+
/**
|
191
|
+
* Checks if code exists in the contracts
|
192
|
+
* @param chainId of the referral contract
|
193
|
+
* @param key of referral
|
194
|
+
* @param code user referral code
|
195
|
+
* @returns referrerAddress if code exitst
|
196
|
+
*/
|
197
|
+
static isCodeRegistered(chainId: number, key: string, code: string): Promise<any>;
|
198
|
+
/**
|
199
|
+
* Get state & transaction for redeeming a referral code
|
200
|
+
* @param chainId of the referral contract
|
201
|
+
* @param key of referral
|
202
|
+
* @param code user referral code
|
203
|
+
*/
|
204
|
+
static getReferralTransaction(chainId: number, key: string, code: string): Promise<{
|
205
|
+
code: string;
|
206
|
+
referrer: any;
|
207
|
+
transaction?: undefined;
|
208
|
+
} | {
|
209
|
+
code: string;
|
210
|
+
referrer: any;
|
211
|
+
transaction: {
|
212
|
+
to: string;
|
213
|
+
data: `0x${string}`;
|
214
|
+
};
|
215
|
+
}>;
|
216
|
+
}
|
@@ -0,0 +1,170 @@
|
|
1
|
+
import { ChainId, ChainInteractionService } from "@sdk";
|
2
|
+
import { decodeFunctionResult, encodeFunctionData, parseAbi, } from "viem";
|
3
|
+
export class ReferralService {
|
4
|
+
static abi = parseAbi([
|
5
|
+
"function getReferralKeys() external view returns (string[] memory)",
|
6
|
+
"function getReferrerStatus(string calldata key, address user) external view returns (bytes32)",
|
7
|
+
"function referrerCodeMapping(string key, address user) external view returns (string)",
|
8
|
+
"function codeToReferrer(string key, string user) external view returns (address)",
|
9
|
+
"function getReferrer(string calldata key, address user) external view returns (address)",
|
10
|
+
"function getReferredUsers(string calldata key, address user) external view returns (address[] memory)",
|
11
|
+
"function acknowledgeReferrerByKey(string calldata key, string calldata referrerCode) external",
|
12
|
+
"function getCostOfReferral(string calldata key) external view returns (uint256)",
|
13
|
+
"function getPaymentToken(string calldata key) external view returns (address)",
|
14
|
+
"function getReferrerStatusByKey(string calldata key, address referrer) external view returns (uint8)",
|
15
|
+
"function requiresAuthorization(string calldata key) external view returns (bool)",
|
16
|
+
"function requiresRefererToBeSet(string calldata key) external view returns (bool)",
|
17
|
+
"function becomeReferrer(string calldata key, string calldata referrerCode) external payable",
|
18
|
+
]);
|
19
|
+
static getReferralContract(chainId) {
|
20
|
+
if (chainId === ChainId.ETHERLINK)
|
21
|
+
return "0xF39CC381B91f36238c77f42B9fF4D45376F80E5b";
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* Makes an on-chain call to the referral contract
|
26
|
+
* @param chainId
|
27
|
+
* @param functionName
|
28
|
+
* @param args
|
29
|
+
* @returns
|
30
|
+
*/
|
31
|
+
static async #call(chainId, functionName, args) {
|
32
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
33
|
+
if (!referralContractAddress)
|
34
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
35
|
+
return await ChainInteractionService(chainId).fetchAndDecode({
|
36
|
+
target: referralContractAddress,
|
37
|
+
allowFailure: true,
|
38
|
+
callData: encodeFunctionData({
|
39
|
+
abi: ReferralService.abi,
|
40
|
+
functionName,
|
41
|
+
args,
|
42
|
+
}),
|
43
|
+
}, (r) => decodeFunctionResult({
|
44
|
+
abi: ReferralService.abi,
|
45
|
+
functionName,
|
46
|
+
data: r?.returnData,
|
47
|
+
}));
|
48
|
+
}
|
49
|
+
static async isKeyAvailable(key, chainId) {
|
50
|
+
const referralKeys = await ReferralService.#call(chainId, "getReferralKeys", []);
|
51
|
+
return referralKeys.includes(key);
|
52
|
+
}
|
53
|
+
static async getReferredUsers(chainId, key, address) {
|
54
|
+
const isReferralKeyAvailable = ReferralService.isKeyAvailable(key, chainId);
|
55
|
+
if (!isReferralKeyAvailable)
|
56
|
+
throw new Error(`Referral key ${key} not available on ${chainId}`);
|
57
|
+
return await ReferralService.#call(chainId, "getReferredUsers", [key, address]);
|
58
|
+
}
|
59
|
+
static async getReferralStatus(chainId, key, address) {
|
60
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
61
|
+
const isReferralKeyAvailable = ReferralService.isKeyAvailable(key, chainId);
|
62
|
+
if (!referralContractAddress)
|
63
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
64
|
+
if (!isReferralKeyAvailable)
|
65
|
+
throw new Error(`Referral key ${key} not available on ${chainId}`);
|
66
|
+
const shouldCheckStatus = await ReferralService.#call(chainId, "requiresAuthorization", [key]);
|
67
|
+
if (!shouldCheckStatus)
|
68
|
+
return true;
|
69
|
+
const referralStatus = await ReferralService.#call(chainId, "getReferrerStatusByKey", [
|
70
|
+
key,
|
71
|
+
address,
|
72
|
+
]);
|
73
|
+
return referralStatus === 1;
|
74
|
+
}
|
75
|
+
static generateCode(chainId, key, address) {
|
76
|
+
return Bun.hash([chainId, key, address].join("-")).toString().slice(0, 12);
|
77
|
+
}
|
78
|
+
static async getCode(chainId, key, address) {
|
79
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
80
|
+
if (!referralContractAddress)
|
81
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
82
|
+
const code = await ReferralService.#call(chainId, "referrerCodeMapping", [key, address]);
|
83
|
+
return code === "" ? undefined : code;
|
84
|
+
}
|
85
|
+
/**
|
86
|
+
* Get state & transaction for creating a referral code
|
87
|
+
* @param chainId of the referral contract
|
88
|
+
* @param key of referral
|
89
|
+
* @param address of the creator
|
90
|
+
*/
|
91
|
+
static async getCodeOrTransaction(chainId, key, address) {
|
92
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
93
|
+
const isReferralKeyAvailable = ReferralService.isKeyAvailable(key, chainId);
|
94
|
+
if (!referralContractAddress)
|
95
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
96
|
+
if (!isReferralKeyAvailable)
|
97
|
+
throw new Error(`Referral key ${key} not available on ${chainId}`);
|
98
|
+
const contractCode = await ReferralService.getCode(chainId, key, address);
|
99
|
+
if (!contractCode) {
|
100
|
+
const code = ReferralService.generateCode(chainId, key, address);
|
101
|
+
return {
|
102
|
+
code,
|
103
|
+
referrer: false,
|
104
|
+
referredUsers: [],
|
105
|
+
transaction: {
|
106
|
+
to: referralContractAddress,
|
107
|
+
data: encodeFunctionData({
|
108
|
+
abi: ReferralService.abi,
|
109
|
+
functionName: "becomeReferrer",
|
110
|
+
args: [key, code],
|
111
|
+
}),
|
112
|
+
},
|
113
|
+
};
|
114
|
+
}
|
115
|
+
const code = await ReferralService.getCode(chainId, key, address);
|
116
|
+
const referredUsers = await ReferralService.getReferredUsers(chainId, key, address);
|
117
|
+
return {
|
118
|
+
code,
|
119
|
+
referrer: true,
|
120
|
+
referredUsers,
|
121
|
+
};
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* Checks if code exists in the contracts
|
125
|
+
* @param chainId of the referral contract
|
126
|
+
* @param key of referral
|
127
|
+
* @param code user referral code
|
128
|
+
* @returns referrerAddress if code exitst
|
129
|
+
*/
|
130
|
+
static async isCodeRegistered(chainId, key, code) {
|
131
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
132
|
+
if (!referralContractAddress)
|
133
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
134
|
+
const referrerAddress = await ReferralService.#call(chainId, "codeToReferrer", [key, code]);
|
135
|
+
return referrerAddress === "" ? undefined : referrerAddress;
|
136
|
+
}
|
137
|
+
/**
|
138
|
+
* Get state & transaction for redeeming a referral code
|
139
|
+
* @param chainId of the referral contract
|
140
|
+
* @param key of referral
|
141
|
+
* @param code user referral code
|
142
|
+
*/
|
143
|
+
static async getReferralTransaction(chainId, key, code) {
|
144
|
+
const referralContractAddress = ReferralService.getReferralContract(chainId);
|
145
|
+
const isReferralKeyAvailable = ReferralService.isKeyAvailable(key, chainId);
|
146
|
+
if (!referralContractAddress)
|
147
|
+
throw new Error(`Referral contract not deployed on chain ${chainId}`);
|
148
|
+
if (!isReferralKeyAvailable)
|
149
|
+
throw new Error(`Referral key ${key} not available on ${chainId}`);
|
150
|
+
const referrerAddress = await ReferralService.isCodeRegistered(chainId, key, code);
|
151
|
+
if (!referrerAddress) {
|
152
|
+
return {
|
153
|
+
code,
|
154
|
+
referrer: referrerAddress,
|
155
|
+
};
|
156
|
+
}
|
157
|
+
return {
|
158
|
+
code,
|
159
|
+
referrer: referrerAddress,
|
160
|
+
transaction: {
|
161
|
+
to: referralContractAddress,
|
162
|
+
data: encodeFunctionData({
|
163
|
+
abi: ReferralService.abi,
|
164
|
+
functionName: "acknowledgeReferrerByKey",
|
165
|
+
args: [key, code],
|
166
|
+
}),
|
167
|
+
},
|
168
|
+
};
|
169
|
+
}
|
170
|
+
}
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { BackOfficeGuard } from "../../../guards/BackOffice.guard";
|
2
2
|
import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
|
3
|
+
import { ChainDto } from "../accounting/accounting.model";
|
4
|
+
import { CampaignService } from "../campaign/campaign.service";
|
5
|
+
import { TokenService } from "../token/token.service";
|
3
6
|
import { throwOnInvalidRequiredAddress, throwOnUnsupportedChainId } from "../../../utils/throw";
|
4
7
|
import Elysia from "elysia";
|
5
|
-
import { ChainDto } from "../accounting";
|
6
|
-
import { CampaignService } from "../campaign";
|
7
|
-
import { TokenService } from "../token";
|
8
8
|
import { CampaignIdDto, CampaignIdWithoutPageDto, CampaignRewardsDto, CreateManyBreakdownDto, CreateManyRewardDto, RegisterClaimsDto, TokenIdDto, } from "./reward.model";
|
9
9
|
import { RewardService } from "./reward.service";
|
10
10
|
// ─── Rewards Controller ──────────────────────────────────────────────────────
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Campaign, Reward, RewardBreakdown } from "../../../../database/api/.generated/drizzle/schema.ts";
|
2
|
+
import { TokenService } from "../token/token.service";
|
3
|
+
import { UserService } from "../user/user.service";
|
2
4
|
import { apiDbClient } from "../../../utils/prisma";
|
3
5
|
import { and, eq, exists, inArray, sql } from "drizzle-orm";
|
4
6
|
import { CampaignService } from "../campaign";
|
5
|
-
import { TokenService } from "../token";
|
6
|
-
import { UserService } from "../user";
|
7
7
|
import { RewardService } from "./reward.service";
|
8
8
|
export class RewardRepository {
|
9
9
|
static async createManyReward(rewards) {
|
@@ -8,7 +8,7 @@ import { CampaignService } from "../campaign";
|
|
8
8
|
import { ChainService } from "../chain";
|
9
9
|
import { MerklRootService } from "../merklRoot";
|
10
10
|
import { OpportunityService } from "../opportunity";
|
11
|
-
import { TokenService } from "../token";
|
11
|
+
import { TokenService } from "../token/token.service";
|
12
12
|
import { RewardRepository } from "./reward.repository";
|
13
13
|
export class RewardService {
|
14
14
|
static hashId(root, recipient, rewardTokenId) {
|
@@ -93,20 +93,8 @@ export declare const v4: Elysia<"/v4", false, {
|
|
93
93
|
name: string;
|
94
94
|
status: "PAST" | "LIVE" | "SOON";
|
95
95
|
action: import("../../../database/api/.generated").$Enums.OpportunityAction;
|
96
|
-
tokens:
|
97
|
-
|
98
|
-
name: string | null;
|
99
|
-
id: string;
|
100
|
-
icon: string;
|
101
|
-
chainId: number;
|
102
|
-
address: string;
|
103
|
-
decimals: number;
|
104
|
-
verified: boolean;
|
105
|
-
isTest: boolean;
|
106
|
-
} & {
|
107
|
-
price?: number | null | undefined;
|
108
|
-
})[];
|
109
|
-
mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | undefined;
|
96
|
+
tokens: any[];
|
97
|
+
mainProtocol: "morpho" | "euler" | "ambient" | "arthswap" | "baseswap" | "camelot" | "crust" | "fenix" | "horiza" | "izumi" | "kim" | "pancakeswap-v3" | "quickswap-algebra" | "quickswap-uni" | "ramses" | "retro" | "stryke" | "stryke-pcs" | "stryke-sushi" | "sushiswap-v3" | "swapr" | "thruster" | "uniswap-v3" | "voltage" | "zero" | "koi" | "supswap-v3" | "zkswap" | "thirdtrade" | "uniswapv4" | "uniswap-v2" | "velodrome" | "aerodrome" | "balancer" | "curve" | "cross_curve" | "curveNPool" | "aura" | "akron" | "beefy" | "dragonswap" | "poolside" | "syncswap-v3" | "neptune" | "zkSwapThreePool" | "syncswap" | "rfx" | "radiant" | "aave" | "gearbox" | "compound" | "sturdy" | "frax" | "ionic" | "moonwell" | "fluid" | "silo" | "coumpound" | "dolomite" | "badger" | "ajna" | "layerbank" | "ion" | "venus" | "woofi" | "reactor_fusion" | "eigenlayer" | "vest" | "zerolend" | "hyperdrive" | "gamma" | "oku" | "hourglass" | "veda" | "kyo" | "sonex" | undefined;
|
110
98
|
depositUrl: any;
|
111
99
|
tags: string[];
|
112
100
|
};
|
@@ -191,19 +179,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
191
179
|
};
|
192
180
|
id: string;
|
193
181
|
depositUrl: string | undefined;
|
194
|
-
tokens:
|
195
|
-
symbol: string;
|
196
|
-
name: string | null;
|
197
|
-
id: string;
|
198
|
-
icon: string;
|
199
|
-
chainId: number;
|
200
|
-
address: string;
|
201
|
-
decimals: number;
|
202
|
-
verified: boolean;
|
203
|
-
isTest: boolean;
|
204
|
-
} & {
|
205
|
-
price?: number | null | undefined;
|
206
|
-
})[];
|
182
|
+
tokens: Token[];
|
207
183
|
chain: {
|
208
184
|
name: string;
|
209
185
|
id: number;
|
@@ -490,19 +466,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
490
466
|
id: number;
|
491
467
|
icon: string;
|
492
468
|
};
|
493
|
-
rewardToken:
|
494
|
-
symbol: string;
|
495
|
-
name: string | null;
|
496
|
-
id: string;
|
497
|
-
icon: string;
|
498
|
-
chainId: number;
|
499
|
-
address: string;
|
500
|
-
decimals: number;
|
501
|
-
verified: boolean;
|
502
|
-
isTest: boolean;
|
503
|
-
} & {
|
504
|
-
price?: number | null | undefined;
|
505
|
-
};
|
469
|
+
rewardToken: Token;
|
506
470
|
distributionChain: {
|
507
471
|
name: string;
|
508
472
|
id: number;
|
@@ -982,19 +946,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
982
946
|
id: number;
|
983
947
|
icon: string;
|
984
948
|
};
|
985
|
-
rewardToken:
|
986
|
-
symbol: string;
|
987
|
-
name: string | null;
|
988
|
-
id: string;
|
989
|
-
icon: string;
|
990
|
-
chainId: number;
|
991
|
-
address: string;
|
992
|
-
decimals: number;
|
993
|
-
verified: boolean;
|
994
|
-
isTest: boolean;
|
995
|
-
} & {
|
996
|
-
price?: number | null | undefined;
|
997
|
-
};
|
949
|
+
rewardToken: Token;
|
998
950
|
distributionChain: {
|
999
951
|
name: string;
|
1000
952
|
id: number;
|
@@ -1406,21 +1358,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1406
1358
|
};
|
1407
1359
|
headers: unknown;
|
1408
1360
|
response: {
|
1409
|
-
200:
|
1410
|
-
symbol: string;
|
1411
|
-
name: string | null;
|
1412
|
-
id: string;
|
1413
|
-
icon: string;
|
1414
|
-
chainId: number;
|
1415
|
-
address: string;
|
1416
|
-
decimals: number;
|
1417
|
-
verified: boolean;
|
1418
|
-
isTest: boolean;
|
1419
|
-
} & {
|
1420
|
-
price?: number | null | undefined;
|
1421
|
-
} & {
|
1422
|
-
balance: bigint;
|
1423
|
-
})[];
|
1361
|
+
200: any[];
|
1424
1362
|
};
|
1425
1363
|
};
|
1426
1364
|
};
|
@@ -1442,19 +1380,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1442
1380
|
};
|
1443
1381
|
headers: unknown;
|
1444
1382
|
response: {
|
1445
|
-
200:
|
1446
|
-
symbol: string;
|
1447
|
-
name: string | null;
|
1448
|
-
id: string;
|
1449
|
-
icon: string;
|
1450
|
-
chainId: number;
|
1451
|
-
address: string;
|
1452
|
-
decimals: number;
|
1453
|
-
verified: boolean;
|
1454
|
-
isTest: boolean;
|
1455
|
-
} & {
|
1456
|
-
price?: number | null | undefined;
|
1457
|
-
})[];
|
1383
|
+
200: Token[];
|
1458
1384
|
};
|
1459
1385
|
};
|
1460
1386
|
};
|
@@ -1548,6 +1474,20 @@ export declare const v4: Elysia<"/v4", false, {
|
|
1548
1474
|
};
|
1549
1475
|
};
|
1550
1476
|
};
|
1477
|
+
} & {
|
1478
|
+
tokens: {
|
1479
|
+
sync: {
|
1480
|
+
get: {
|
1481
|
+
body: unknown;
|
1482
|
+
params: {};
|
1483
|
+
query: unknown;
|
1484
|
+
headers: unknown;
|
1485
|
+
response: {
|
1486
|
+
200: void;
|
1487
|
+
};
|
1488
|
+
};
|
1489
|
+
};
|
1490
|
+
};
|
1551
1491
|
};
|
1552
1492
|
} & {
|
1553
1493
|
v4: {
|
@@ -3297,7 +3237,7 @@ export declare const v4: Elysia<"/v4", false, {
|
|
3297
3237
|
headers: unknown;
|
3298
3238
|
response: {
|
3299
3239
|
200: (import("./claims").ClaimModel & {
|
3300
|
-
token?:
|
3240
|
+
token?: Token;
|
3301
3241
|
})[];
|
3302
3242
|
};
|
3303
3243
|
};
|
@@ -3849,6 +3789,68 @@ export declare const v4: Elysia<"/v4", false, {
|
|
3849
3789
|
};
|
3850
3790
|
};
|
3851
3791
|
};
|
3792
|
+
} & {
|
3793
|
+
v4: {
|
3794
|
+
referral: {
|
3795
|
+
code: {
|
3796
|
+
get: {
|
3797
|
+
body: unknown;
|
3798
|
+
params: {};
|
3799
|
+
query: {
|
3800
|
+
chainId: number;
|
3801
|
+
address: string;
|
3802
|
+
referralKey: string;
|
3803
|
+
};
|
3804
|
+
headers: unknown;
|
3805
|
+
response: {
|
3806
|
+
200: {
|
3807
|
+
code: string;
|
3808
|
+
referrer: boolean;
|
3809
|
+
referredUsers: never[];
|
3810
|
+
transaction: {
|
3811
|
+
to: string;
|
3812
|
+
data: `0x${string}`;
|
3813
|
+
};
|
3814
|
+
} | {
|
3815
|
+
code: any;
|
3816
|
+
referrer: boolean;
|
3817
|
+
referredUsers: any;
|
3818
|
+
transaction?: undefined;
|
3819
|
+
};
|
3820
|
+
};
|
3821
|
+
};
|
3822
|
+
};
|
3823
|
+
};
|
3824
|
+
} & {
|
3825
|
+
referral: {
|
3826
|
+
redeem: {
|
3827
|
+
get: {
|
3828
|
+
body: unknown;
|
3829
|
+
params: {};
|
3830
|
+
query: {
|
3831
|
+
code: string;
|
3832
|
+
chainId: number;
|
3833
|
+
referralKey: string;
|
3834
|
+
};
|
3835
|
+
headers: unknown;
|
3836
|
+
response: {
|
3837
|
+
200: {
|
3838
|
+
code: string;
|
3839
|
+
referrer: any;
|
3840
|
+
transaction?: undefined;
|
3841
|
+
} | {
|
3842
|
+
code: string;
|
3843
|
+
referrer: any;
|
3844
|
+
transaction: {
|
3845
|
+
to: string;
|
3846
|
+
data: `0x${string}`;
|
3847
|
+
};
|
3848
|
+
};
|
3849
|
+
};
|
3850
|
+
};
|
3851
|
+
};
|
3852
|
+
};
|
3853
|
+
};
|
3852
3854
|
}, {
|
3853
3855
|
derive: {};
|
3854
3856
|
resolve: {};
|
@@ -27,6 +27,7 @@ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
27
27
|
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-node";
|
28
28
|
import { PrismaInstrumentation } from "@prisma/instrumentation";
|
29
29
|
import Elysia from "elysia";
|
30
|
+
import { ReferralController } from "./referral/referral.controller";
|
30
31
|
// ─── V4 Router ───────────────────────────────────────────────────────────────
|
31
32
|
export const v4 = new Elysia({ tags: ["v4"], prefix: "/v4" })
|
32
33
|
// ─── OpenTelemetry ───────────────────────────────────────────────────
|
@@ -71,4 +72,5 @@ export const v4 = new Elysia({ tags: ["v4"], prefix: "/v4" })
|
|
71
72
|
.use(ProgramPayloadController)
|
72
73
|
.use(BoostController)
|
73
74
|
.use(ComputedValueController)
|
74
|
-
.use(CreatorController)
|
75
|
+
.use(CreatorController)
|
76
|
+
.use(ReferralController);
|