@wzrd_sol/goat-plugin 0.1.0 → 0.2.0
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/README.md +67 -0
- package/dist/index.d.mts +122 -61
- package/dist/index.d.ts +122 -61
- package/dist/index.js +361 -436
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +356 -420
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -9
package/dist/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
7
|
var __export = (target, all) => {
|
|
@@ -18,25 +16,17 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
16
|
}
|
|
19
17
|
return to;
|
|
20
18
|
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
20
|
|
|
31
21
|
// src/index.ts
|
|
32
22
|
var index_exports = {};
|
|
33
23
|
__export(index_exports, {
|
|
34
24
|
ClaimParameters: () => ClaimParameters,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
EarnParameters: () => EarnParameters,
|
|
26
|
+
InferParameters: () => InferParameters,
|
|
27
|
+
ReportParameters: () => ReportParameters,
|
|
28
|
+
RewardsParameters: () => RewardsParameters,
|
|
29
|
+
WzrdClient: () => WzrdClient,
|
|
40
30
|
WzrdPlugin: () => WzrdPlugin,
|
|
41
31
|
wzrd: () => wzrd
|
|
42
32
|
});
|
|
@@ -45,29 +35,55 @@ module.exports = __toCommonJS(index_exports);
|
|
|
45
35
|
// src/wzrd.plugin.ts
|
|
46
36
|
var import_core7 = require("@goat-sdk/core");
|
|
47
37
|
|
|
48
|
-
// src/
|
|
49
|
-
var
|
|
50
|
-
var TOKEN_REFRESH_MARGIN_MS =
|
|
51
|
-
var
|
|
38
|
+
// src/client.ts
|
|
39
|
+
var DEFAULT_API = "https://api.twzrd.xyz";
|
|
40
|
+
var TOKEN_REFRESH_MARGIN_MS = 60 * 60 * 1e3;
|
|
41
|
+
var B58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
42
|
+
function toBase58(bytes) {
|
|
43
|
+
const digits = [
|
|
44
|
+
0
|
|
45
|
+
];
|
|
46
|
+
for (const byte of bytes) {
|
|
47
|
+
let carry = byte;
|
|
48
|
+
for (let j = 0; j < digits.length; j++) {
|
|
49
|
+
carry += digits[j] << 8;
|
|
50
|
+
digits[j] = carry % 58;
|
|
51
|
+
carry = carry / 58 | 0;
|
|
52
|
+
}
|
|
53
|
+
while (carry > 0) {
|
|
54
|
+
digits.push(carry % 58);
|
|
55
|
+
carry = carry / 58 | 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
let out = "";
|
|
59
|
+
for (const b of bytes) {
|
|
60
|
+
if (b !== 0) break;
|
|
61
|
+
out += "1";
|
|
62
|
+
}
|
|
63
|
+
for (let i = digits.length - 1; i >= 0; i--) out += B58[digits[i]];
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
__name(toBase58, "toBase58");
|
|
67
|
+
function hexToBytes(hex) {
|
|
68
|
+
const clean = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
69
|
+
const bytes = new Uint8Array(clean.length / 2);
|
|
70
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
71
|
+
bytes[i] = parseInt(clean.substring(i * 2, i * 2 + 2), 16);
|
|
72
|
+
}
|
|
73
|
+
return bytes;
|
|
74
|
+
}
|
|
75
|
+
__name(hexToBytes, "hexToBytes");
|
|
76
|
+
var WzrdClient = class {
|
|
52
77
|
static {
|
|
53
|
-
__name(this, "
|
|
78
|
+
__name(this, "WzrdClient");
|
|
54
79
|
}
|
|
55
80
|
apiUrl;
|
|
56
|
-
// Cache auth tokens per wallet address
|
|
81
|
+
// Cache auth tokens per wallet address
|
|
57
82
|
tokenCache = /* @__PURE__ */ new Map();
|
|
58
83
|
constructor(options) {
|
|
59
|
-
this.apiUrl = options?.apiUrl?.trim() || process.env.WZRD_API_URL?.trim() ||
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Authenticate with the WZRD API using the GOAT wallet client.
|
|
63
|
-
*
|
|
64
|
-
* Flow:
|
|
65
|
-
* 1. GET /v1/agent/challenge — receive nonce
|
|
66
|
-
* 2. Sign canonical message with wallet's signMessage()
|
|
67
|
-
* 3. POST /v1/agent/verify — receive bearer token (24h TTL)
|
|
68
|
-
*
|
|
69
|
-
* Returns a cached bearer token if still valid.
|
|
70
|
-
*/
|
|
84
|
+
this.apiUrl = options?.apiUrl?.trim() || process.env.WZRD_API_URL?.trim() || DEFAULT_API;
|
|
85
|
+
}
|
|
86
|
+
/** Ed25519 challenge → sign → verify → Bearer token */
|
|
71
87
|
async authenticate(walletClient) {
|
|
72
88
|
const address = walletClient.getAddress();
|
|
73
89
|
const cached = this.tokenCache.get(address);
|
|
@@ -100,99 +116,171 @@ var WzrdApiClient = class {
|
|
|
100
116
|
const { token, expires_at } = await verifyRes.json();
|
|
101
117
|
this.tokenCache.set(address, {
|
|
102
118
|
token,
|
|
103
|
-
expiresAt: new Date(expires_at).getTime()
|
|
119
|
+
expiresAt: expires_at ? new Date(expires_at).getTime() : Date.now() + 23 * 60 * 60 * 1e3
|
|
104
120
|
});
|
|
105
121
|
return token;
|
|
106
122
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
123
|
+
/** Authenticated fetch helper */
|
|
124
|
+
async authedFetch(walletClient, path, init) {
|
|
125
|
+
const token = await this.authenticate(walletClient);
|
|
126
|
+
const headers = new Headers(init?.headers);
|
|
127
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
128
|
+
headers.set("Content-Type", "application/json");
|
|
129
|
+
return fetch(`${this.apiUrl}${path}`, {
|
|
130
|
+
...init,
|
|
131
|
+
headers
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/** Pick a model from the momentum signal — returns top model name */
|
|
135
|
+
async pickModel(taskType) {
|
|
136
|
+
const res = await fetch(`${this.apiUrl}/v1/signals/momentum?limit=10&trending=true`);
|
|
137
|
+
if (!res.ok) throw new Error(`Momentum fetch failed: ${res.status}`);
|
|
138
|
+
const data = await res.json();
|
|
139
|
+
if (!data.models?.length) throw new Error("No models available in momentum feed");
|
|
140
|
+
return data.models[0].model;
|
|
141
|
+
}
|
|
142
|
+
/** Server-witnessed inference — WZRD calls the provider, grades quality */
|
|
143
|
+
async infer(walletClient, prompt, model, taskType) {
|
|
144
|
+
const resolvedModel = model || await this.pickModel(taskType);
|
|
145
|
+
const res = await this.authedFetch(walletClient, "/v1/agent/infer", {
|
|
146
|
+
method: "POST",
|
|
147
|
+
body: JSON.stringify({
|
|
148
|
+
model: resolvedModel,
|
|
149
|
+
prompt,
|
|
150
|
+
task_type: taskType || "chat"
|
|
151
|
+
})
|
|
152
|
+
});
|
|
153
|
+
if (!res.ok) {
|
|
154
|
+
const body = await res.text().catch(() => "");
|
|
155
|
+
throw new Error(`Infer failed (${res.status}): ${body}`);
|
|
119
156
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
157
|
+
return res.json();
|
|
158
|
+
}
|
|
159
|
+
/** Report model pick with execution_id for verified rewards */
|
|
160
|
+
async report(walletClient, params) {
|
|
161
|
+
const res = await this.authedFetch(walletClient, "/v1/agent/report", {
|
|
162
|
+
method: "POST",
|
|
163
|
+
body: JSON.stringify(params)
|
|
164
|
+
});
|
|
165
|
+
if (!res.ok) {
|
|
166
|
+
const body = await res.text().catch(() => "");
|
|
167
|
+
throw new Error(`Report failed (${res.status}): ${body}`);
|
|
123
168
|
}
|
|
169
|
+
return res.json();
|
|
124
170
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
171
|
+
/** Check pending + total rewards */
|
|
172
|
+
async getRewards(walletClient) {
|
|
173
|
+
const res = await this.authedFetch(walletClient, "/v1/agent/earned");
|
|
174
|
+
if (!res.ok) throw new Error(`Rewards check failed: ${res.status}`);
|
|
175
|
+
const data = await res.json();
|
|
176
|
+
const economy = data.economy;
|
|
177
|
+
const routing = data.routing;
|
|
178
|
+
return {
|
|
179
|
+
pending_ccm: Number(economy?.pending_ccm ?? 0),
|
|
180
|
+
total_rewarded_ccm: Number(economy?.earned_ccm ?? 0),
|
|
181
|
+
rank: null,
|
|
182
|
+
contribution_count: Number(routing?.lifetime_contributions ?? 0)
|
|
183
|
+
};
|
|
129
184
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
185
|
+
/** Gasless CCM claim via server relay */
|
|
186
|
+
async claimRelay(walletClient) {
|
|
187
|
+
const pubkey = walletClient.getAddress();
|
|
188
|
+
const res = await this.authedFetch(walletClient, `/v1/claims/${pubkey}/relay`, {
|
|
189
|
+
method: "POST"
|
|
190
|
+
});
|
|
191
|
+
if (!res.ok) {
|
|
192
|
+
const body = await res.text().catch(() => "");
|
|
193
|
+
throw new Error(`Claim relay failed (${res.status}): ${body}`);
|
|
194
|
+
}
|
|
195
|
+
return res.json();
|
|
139
196
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
197
|
+
/** Check claims status */
|
|
198
|
+
async getClaimStatus(walletClient) {
|
|
199
|
+
const pubkey = walletClient.getAddress();
|
|
200
|
+
const res = await this.authedFetch(walletClient, `/v1/claims/${pubkey}`);
|
|
201
|
+
if (!res.ok) {
|
|
202
|
+
if (res.status === 404) {
|
|
203
|
+
return {
|
|
204
|
+
cumulative_total: 0,
|
|
205
|
+
claimed_total: 0,
|
|
206
|
+
claimable: 0
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
throw new Error(`Claim status failed: ${res.status}`);
|
|
210
|
+
}
|
|
211
|
+
const data = await res.json();
|
|
212
|
+
return {
|
|
213
|
+
...data,
|
|
214
|
+
claimable: data.cumulative_total - data.claimed_total
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/** Public: fetch leaderboard (no auth) */
|
|
218
|
+
async getLeaderboard(limit = 20) {
|
|
219
|
+
const res = await fetch(`${this.apiUrl}/v1/leaderboard?limit=${limit}`);
|
|
220
|
+
if (!res.ok) throw new Error(`Leaderboard failed: ${res.status}`);
|
|
221
|
+
return res.json();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
143
224
|
|
|
144
|
-
// src/tools/
|
|
225
|
+
// src/tools/infer.ts
|
|
145
226
|
var import_core2 = require("@goat-sdk/core");
|
|
227
|
+
var import_wallet_solana = require("@goat-sdk/wallet-solana");
|
|
146
228
|
|
|
147
229
|
// src/parameters.ts
|
|
148
230
|
var import_core = require("@goat-sdk/core");
|
|
149
231
|
var import_zod = require("zod");
|
|
150
|
-
var
|
|
151
|
-
|
|
152
|
-
|
|
232
|
+
var InferParameters = class extends (0, import_core.createToolParameters)(import_zod.z.object({
|
|
233
|
+
prompt: import_zod.z.string().describe("The prompt to send for inference"),
|
|
234
|
+
model: import_zod.z.string().optional().describe("Specific model to use (e.g. 'gemini-2.5-flash'). If omitted, picks the top model from the leaderboard."),
|
|
235
|
+
task_type: import_zod.z.enum([
|
|
236
|
+
"code",
|
|
237
|
+
"chat",
|
|
238
|
+
"reasoning"
|
|
239
|
+
]).optional().describe("Task type for prompt classification: 'code', 'chat', or 'reasoning'. Default: 'chat'.")
|
|
153
240
|
})) {
|
|
154
241
|
static {
|
|
155
|
-
__name(this, "
|
|
242
|
+
__name(this, "InferParameters");
|
|
156
243
|
}
|
|
157
244
|
};
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
245
|
+
var ReportParameters = class extends (0, import_core.createToolParameters)(import_zod.z.object({
|
|
246
|
+
model_id: import_zod.z.string().describe("Model ID from the infer result (e.g. 'gemini-2.5-flash')"),
|
|
247
|
+
execution_id: import_zod.z.string().describe("Execution receipt from WZRD_INFER \u2014 required for verified rewards"),
|
|
248
|
+
task_type: import_zod.z.enum([
|
|
249
|
+
"code",
|
|
250
|
+
"chat",
|
|
251
|
+
"reasoning"
|
|
252
|
+
]).optional().describe("Task type matching the inference request"),
|
|
253
|
+
quality_score: import_zod.z.number().min(0).max(1).optional().describe("Quality score from the infer result (0-1)"),
|
|
254
|
+
latency_ms: import_zod.z.number().int().positive().optional().describe("Latency in ms from the infer result")
|
|
168
255
|
})) {
|
|
169
256
|
static {
|
|
170
|
-
__name(this, "
|
|
257
|
+
__name(this, "ReportParameters");
|
|
171
258
|
}
|
|
172
259
|
};
|
|
173
|
-
var
|
|
260
|
+
var EarnParameters = class extends (0, import_core.createToolParameters)(import_zod.z.object({
|
|
261
|
+
task_type: import_zod.z.enum([
|
|
262
|
+
"code",
|
|
263
|
+
"chat",
|
|
264
|
+
"reasoning"
|
|
265
|
+
]).optional().describe("Task type for the eval prompt: 'code', 'chat', or 'reasoning'. Default: 'code'."),
|
|
266
|
+
prompt: import_zod.z.string().optional().describe("Custom prompt to use for inference. If omitted, a random eval prompt is selected.")
|
|
267
|
+
})) {
|
|
174
268
|
static {
|
|
175
|
-
__name(this, "
|
|
269
|
+
__name(this, "EarnParameters");
|
|
176
270
|
}
|
|
177
271
|
};
|
|
178
|
-
var
|
|
179
|
-
market_id: import_zod.z.number().int().min(1).describe("Market ID to deposit into (get from wzrd_get_leaderboard)"),
|
|
180
|
-
amount_usdc: import_zod.z.number().positive().max(100).describe("Amount of USDC to deposit (e.g. 0.01). Max 100 per deposit."),
|
|
181
|
-
priority_fee: import_zod.z.number().int().positive().optional().describe("Priority fee in micro-lamports (default 50000). Higher = faster inclusion.")
|
|
182
|
-
})) {
|
|
272
|
+
var ClaimParameters = class extends (0, import_core.createToolParameters)(import_zod.z.object({})) {
|
|
183
273
|
static {
|
|
184
|
-
__name(this, "
|
|
274
|
+
__name(this, "ClaimParameters");
|
|
185
275
|
}
|
|
186
276
|
};
|
|
187
|
-
var
|
|
188
|
-
execute: import_zod.z.boolean().optional().describe("If false, only check claimable amount without executing. Default true.")
|
|
189
|
-
})) {
|
|
277
|
+
var RewardsParameters = class extends (0, import_core.createToolParameters)(import_zod.z.object({})) {
|
|
190
278
|
static {
|
|
191
|
-
__name(this, "
|
|
279
|
+
__name(this, "RewardsParameters");
|
|
192
280
|
}
|
|
193
281
|
};
|
|
194
282
|
|
|
195
|
-
// src/tools/
|
|
283
|
+
// src/tools/infer.ts
|
|
196
284
|
function _ts_decorate(decorators, target, key, desc) {
|
|
197
285
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
198
286
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -204,56 +292,44 @@ function _ts_metadata(k, v) {
|
|
|
204
292
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
205
293
|
}
|
|
206
294
|
__name(_ts_metadata, "_ts_metadata");
|
|
207
|
-
var
|
|
295
|
+
var InferTools = class {
|
|
208
296
|
static {
|
|
209
|
-
__name(this, "
|
|
297
|
+
__name(this, "InferTools");
|
|
210
298
|
}
|
|
211
|
-
|
|
212
|
-
constructor(
|
|
213
|
-
this.
|
|
299
|
+
client;
|
|
300
|
+
constructor(client) {
|
|
301
|
+
this.client = client;
|
|
214
302
|
}
|
|
215
|
-
async
|
|
216
|
-
const
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
});
|
|
220
|
-
if (parameters.platform) params.set("platform", parameters.platform);
|
|
221
|
-
const res = await fetch(`${this.api.apiUrl}/v1/leaderboard?${params}`);
|
|
222
|
-
if (!res.ok) {
|
|
223
|
-
throw new Error(`Leaderboard request failed: ${res.status}`);
|
|
224
|
-
}
|
|
225
|
-
const data = await res.json();
|
|
226
|
-
const markets = data.markets ?? [];
|
|
227
|
-
const summary = markets.map((m, i) => `${i + 1}. ${m.metric} \u2014 ${formatVelocity(m.velocity_ema)} velocity (${m.platform}) | ${m.multiplier_bps / 1e4}x multiplier | ${m.position_count} positions | market_id=${m.market_id}`).join("\n");
|
|
303
|
+
async wzrd_infer(walletClient, parameters) {
|
|
304
|
+
const { prompt, model, task_type } = parameters;
|
|
305
|
+
const taskType = task_type || "chat";
|
|
306
|
+
const result = await this.client.infer(walletClient, prompt, model, taskType);
|
|
228
307
|
return {
|
|
229
|
-
summary: `
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
308
|
+
summary: `Inference complete. Model: ${result.model} (${result.provider}), quality: ${result.quality_score.toFixed(2)}, ${result.latency_ms}ms. execution_id: ${result.execution_id}`,
|
|
309
|
+
execution_id: result.execution_id,
|
|
310
|
+
model: result.model,
|
|
311
|
+
provider: result.provider,
|
|
312
|
+
quality_score: result.quality_score,
|
|
313
|
+
latency_ms: result.latency_ms,
|
|
314
|
+
response_preview: result.response.slice(0, 300)
|
|
235
315
|
};
|
|
236
316
|
}
|
|
237
317
|
};
|
|
238
318
|
_ts_decorate([
|
|
239
319
|
(0, import_core2.Tool)({
|
|
240
|
-
description: "
|
|
320
|
+
description: "Run server-witnessed inference through WZRD. The server calls the AI provider, grades quality, and returns an execution receipt (execution_id). Use the execution_id with wzrd_report to earn verified CCM rewards. If no model is specified, picks the top model from the leaderboard."
|
|
241
321
|
}),
|
|
242
322
|
_ts_metadata("design:type", Function),
|
|
243
323
|
_ts_metadata("design:paramtypes", [
|
|
244
|
-
typeof
|
|
324
|
+
typeof import_wallet_solana.SolanaWalletClient === "undefined" ? Object : import_wallet_solana.SolanaWalletClient,
|
|
325
|
+
typeof InferParameters === "undefined" ? Object : InferParameters
|
|
245
326
|
]),
|
|
246
327
|
_ts_metadata("design:returntype", Promise)
|
|
247
|
-
],
|
|
248
|
-
function formatVelocity(v) {
|
|
249
|
-
if (v >= 1e6) return `${(v / 1e6).toFixed(1)}M`;
|
|
250
|
-
if (v >= 1e3) return `${(v / 1e3).toFixed(0)}K`;
|
|
251
|
-
return v.toFixed(0);
|
|
252
|
-
}
|
|
253
|
-
__name(formatVelocity, "formatVelocity");
|
|
328
|
+
], InferTools.prototype, "wzrd_infer", null);
|
|
254
329
|
|
|
255
|
-
// src/tools/
|
|
330
|
+
// src/tools/report.ts
|
|
256
331
|
var import_core3 = require("@goat-sdk/core");
|
|
332
|
+
var import_wallet_solana2 = require("@goat-sdk/wallet-solana");
|
|
257
333
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
258
334
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
259
335
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -265,110 +341,46 @@ function _ts_metadata2(k, v) {
|
|
|
265
341
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
266
342
|
}
|
|
267
343
|
__name(_ts_metadata2, "_ts_metadata");
|
|
268
|
-
var
|
|
344
|
+
var ReportTools = class {
|
|
269
345
|
static {
|
|
270
|
-
__name(this, "
|
|
346
|
+
__name(this, "ReportTools");
|
|
271
347
|
}
|
|
272
|
-
|
|
273
|
-
constructor(
|
|
274
|
-
this.
|
|
348
|
+
client;
|
|
349
|
+
constructor(client) {
|
|
350
|
+
this.client = client;
|
|
275
351
|
}
|
|
276
|
-
async
|
|
277
|
-
const
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
throw new Error(`Leaderboard request failed: ${res.status}`);
|
|
284
|
-
}
|
|
285
|
-
const data = await res.json();
|
|
286
|
-
const markets = data.markets ?? [];
|
|
287
|
-
if (markets.length === 0) {
|
|
288
|
-
return {
|
|
289
|
-
summary: "No markets found.",
|
|
290
|
-
signals: []
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
const sorted = [
|
|
294
|
-
...markets
|
|
295
|
-
].sort((a, b) => a.velocity_ema - b.velocity_ema);
|
|
296
|
-
const signals = markets.map((m) => {
|
|
297
|
-
const rank = sorted.findIndex((s) => s.market_id === m.market_id);
|
|
298
|
-
const percentile = (rank + 1) / sorted.length * 100;
|
|
299
|
-
return {
|
|
300
|
-
market_id: m.market_id,
|
|
301
|
-
metric: m.metric,
|
|
302
|
-
platform: m.platform,
|
|
303
|
-
velocity_ema: m.velocity_ema,
|
|
304
|
-
signal: classify(m, percentile),
|
|
305
|
-
percentile: Math.round(percentile)
|
|
306
|
-
};
|
|
352
|
+
async wzrd_report(walletClient, parameters) {
|
|
353
|
+
const result = await this.client.report(walletClient, {
|
|
354
|
+
model_id: parameters.model_id,
|
|
355
|
+
execution_id: parameters.execution_id,
|
|
356
|
+
task_type: parameters.task_type,
|
|
357
|
+
quality_score: parameters.quality_score,
|
|
358
|
+
latency_ms: parameters.latency_ms
|
|
307
359
|
});
|
|
308
|
-
const tierOrder = [
|
|
309
|
-
"BREAKOUT",
|
|
310
|
-
"MOMENTUM",
|
|
311
|
-
"EMERGING",
|
|
312
|
-
"STABLE",
|
|
313
|
-
"COOLING",
|
|
314
|
-
"WEAK"
|
|
315
|
-
];
|
|
316
|
-
const minIdx = parameters.min_signal ? tierOrder.indexOf(parameters.min_signal) : tierOrder.length;
|
|
317
|
-
const filtered = minIdx < tierOrder.length ? signals.filter((s) => tierOrder.indexOf(s.signal) <= minIdx) : signals;
|
|
318
|
-
const grouped = /* @__PURE__ */ new Map();
|
|
319
|
-
for (const s of filtered) {
|
|
320
|
-
const arr = grouped.get(s.signal) ?? [];
|
|
321
|
-
arr.push(s);
|
|
322
|
-
grouped.set(s.signal, arr);
|
|
323
|
-
}
|
|
324
|
-
const lines = [];
|
|
325
|
-
for (const tier of tierOrder) {
|
|
326
|
-
const group = grouped.get(tier);
|
|
327
|
-
if (!group?.length) continue;
|
|
328
|
-
lines.push(`${tier}:`);
|
|
329
|
-
for (const s of group) {
|
|
330
|
-
lines.push(` ${s.metric} (${formatVelocity2(s.velocity_ema)} velocity, p${s.percentile}) [${s.platform}]`);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
const medianIdx = Math.floor(sorted.length / 2);
|
|
334
|
-
const medianVelocity = sorted[medianIdx]?.velocity_ema ?? 0;
|
|
335
360
|
return {
|
|
336
|
-
summary: `
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
361
|
+
summary: `Reported to WZRD. Verification: ${result.verification_state}, contribution #${result.contribution_id}, model: ${result.model_id}` + (result.quality_score != null ? `, quality: ${result.quality_score.toFixed(2)}` : ""),
|
|
362
|
+
contribution_id: result.contribution_id,
|
|
363
|
+
verification_state: result.verification_state,
|
|
364
|
+
quality_score: result.quality_score,
|
|
365
|
+
model_id: result.model_id
|
|
340
366
|
};
|
|
341
367
|
}
|
|
342
368
|
};
|
|
343
369
|
_ts_decorate2([
|
|
344
370
|
(0, import_core3.Tool)({
|
|
345
|
-
description: "
|
|
371
|
+
description: "Report a model pick to WZRD with an execution_id from wzrd_infer. Verified reports earn CCM rewards with a quality multiplier. Requires: model_id and execution_id (both from wzrd_infer result)."
|
|
346
372
|
}),
|
|
347
373
|
_ts_metadata2("design:type", Function),
|
|
348
374
|
_ts_metadata2("design:paramtypes", [
|
|
349
|
-
typeof
|
|
375
|
+
typeof import_wallet_solana2.SolanaWalletClient === "undefined" ? Object : import_wallet_solana2.SolanaWalletClient,
|
|
376
|
+
typeof ReportParameters === "undefined" ? Object : ReportParameters
|
|
350
377
|
]),
|
|
351
378
|
_ts_metadata2("design:returntype", Promise)
|
|
352
|
-
],
|
|
353
|
-
function classify(m, percentile) {
|
|
354
|
-
if (percentile >= 90) return "BREAKOUT";
|
|
355
|
-
if (percentile >= 70) return "MOMENTUM";
|
|
356
|
-
if (m.snapshot_count < 300 && percentile >= 50) return "EMERGING";
|
|
357
|
-
if (percentile >= 40) return "STABLE";
|
|
358
|
-
if (percentile >= 20) return "COOLING";
|
|
359
|
-
return "WEAK";
|
|
360
|
-
}
|
|
361
|
-
__name(classify, "classify");
|
|
362
|
-
function formatVelocity2(v) {
|
|
363
|
-
if (v >= 1e6) return `${(v / 1e6).toFixed(1)}M`;
|
|
364
|
-
if (v >= 1e3) return `${(v / 1e3).toFixed(0)}K`;
|
|
365
|
-
return v.toFixed(0);
|
|
366
|
-
}
|
|
367
|
-
__name(formatVelocity2, "formatVelocity");
|
|
379
|
+
], ReportTools.prototype, "wzrd_report", null);
|
|
368
380
|
|
|
369
|
-
// src/tools/
|
|
381
|
+
// src/tools/earn.ts
|
|
370
382
|
var import_core4 = require("@goat-sdk/core");
|
|
371
|
-
var
|
|
383
|
+
var import_wallet_solana3 = require("@goat-sdk/wallet-solana");
|
|
372
384
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
373
385
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
374
386
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -380,63 +392,94 @@ function _ts_metadata3(k, v) {
|
|
|
380
392
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
381
393
|
}
|
|
382
394
|
__name(_ts_metadata3, "_ts_metadata");
|
|
383
|
-
var
|
|
395
|
+
var EVAL_PROMPTS = {
|
|
396
|
+
code: [
|
|
397
|
+
"Write a Python function that checks if a binary tree is balanced. Include time complexity analysis.",
|
|
398
|
+
"Implement a thread-safe LRU cache in Rust with O(1) get and put operations.",
|
|
399
|
+
"Write a TypeScript generic function that deep-merges two objects, handling arrays and nested objects."
|
|
400
|
+
],
|
|
401
|
+
chat: [
|
|
402
|
+
"Explain the difference between TCP and UDP to someone who has never programmed before.",
|
|
403
|
+
"What are the tradeoffs between microservices and monolithic architecture?",
|
|
404
|
+
"Describe how consensus works in proof-of-stake blockchains."
|
|
405
|
+
],
|
|
406
|
+
reasoning: [
|
|
407
|
+
"A farmer has a fox, a chicken, and a bag of grain. He must cross a river in a boat that can only carry him and one item. How does he do it?",
|
|
408
|
+
"If it takes 5 machines 5 minutes to make 5 widgets, how long does it take 100 machines to make 100 widgets?",
|
|
409
|
+
"Three people check into a hotel room that costs $30. They each pay $10. The manager realizes the room should cost $25 and gives $5 to the bellboy to return. The bellboy keeps $2 and gives $1 back to each person. So each person paid $9 (total $27) plus the bellboy kept $2 (total $29). Where is the missing dollar?"
|
|
410
|
+
]
|
|
411
|
+
};
|
|
412
|
+
function pickPrompt(taskType) {
|
|
413
|
+
const prompts = EVAL_PROMPTS[taskType] || EVAL_PROMPTS.chat;
|
|
414
|
+
return prompts[Math.floor(Math.random() * prompts.length)];
|
|
415
|
+
}
|
|
416
|
+
__name(pickPrompt, "pickPrompt");
|
|
417
|
+
var EarnTools = class {
|
|
384
418
|
static {
|
|
385
|
-
__name(this, "
|
|
419
|
+
__name(this, "EarnTools");
|
|
386
420
|
}
|
|
387
|
-
|
|
388
|
-
constructor(
|
|
389
|
-
this.
|
|
421
|
+
client;
|
|
422
|
+
constructor(client) {
|
|
423
|
+
this.client = client;
|
|
390
424
|
}
|
|
391
|
-
async
|
|
392
|
-
const
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
425
|
+
async wzrd_earn(walletClient, parameters) {
|
|
426
|
+
const taskType = parameters.task_type || "code";
|
|
427
|
+
const prompt = parameters.prompt || pickPrompt(taskType);
|
|
428
|
+
const steps = [];
|
|
429
|
+
steps.push("-> Picking model from leaderboard...");
|
|
430
|
+
const model = await this.client.pickModel(taskType);
|
|
431
|
+
steps.push(`-> Running inference: ${model} (${taskType})...`);
|
|
432
|
+
const infer = await this.client.infer(walletClient, prompt, model, taskType);
|
|
433
|
+
steps.push(`OK Inference: ${infer.model} (${infer.provider}), quality ${infer.quality_score.toFixed(2)}, ${infer.latency_ms}ms`);
|
|
434
|
+
steps.push("-> Reporting outcome...");
|
|
435
|
+
const report = await this.client.report(walletClient, {
|
|
436
|
+
model_id: infer.model,
|
|
437
|
+
execution_id: infer.execution_id,
|
|
438
|
+
task_type: taskType,
|
|
439
|
+
quality_score: infer.quality_score,
|
|
440
|
+
latency_ms: infer.latency_ms
|
|
397
441
|
});
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
const positions = portfolio.positions ?? [];
|
|
403
|
-
const lines = positions.map((p) => `Market #${p.market_id} (${p.metric}): ${formatUsdc(p.usdc_deposited)} USDC, ${formatUsdc(p.vlofi_minted)} vLOFI, ${p.multiplier_bps / 1e4}x multiplier` + (p.is_settled ? " [SETTLED]" : ""));
|
|
442
|
+
steps.push(`OK Reported: ${report.verification_state}, contribution #${report.contribution_id}`);
|
|
443
|
+
steps.push("-> Checking rewards...");
|
|
444
|
+
const rewards = await this.client.getRewards(walletClient);
|
|
445
|
+
steps.push(`OK Rewards: ${(rewards.pending_ccm / 1e9).toFixed(2)} CCM pending, ${(rewards.total_rewarded_ccm / 1e9).toFixed(2)} CCM lifetime`);
|
|
404
446
|
return {
|
|
405
|
-
summary: `
|
|
406
|
-
${
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
447
|
+
summary: `Earn cycle complete:
|
|
448
|
+
${steps.join("\n")}`,
|
|
449
|
+
infer: {
|
|
450
|
+
execution_id: infer.execution_id,
|
|
451
|
+
model: infer.model,
|
|
452
|
+
provider: infer.provider,
|
|
453
|
+
quality_score: infer.quality_score,
|
|
454
|
+
latency_ms: infer.latency_ms
|
|
455
|
+
},
|
|
456
|
+
report: {
|
|
457
|
+
contribution_id: report.contribution_id,
|
|
458
|
+
verification_state: report.verification_state
|
|
459
|
+
},
|
|
460
|
+
rewards: {
|
|
461
|
+
pending_ccm: rewards.pending_ccm,
|
|
462
|
+
total_rewarded_ccm: rewards.total_rewarded_ccm,
|
|
463
|
+
contribution_count: rewards.contribution_count
|
|
464
|
+
}
|
|
412
465
|
};
|
|
413
466
|
}
|
|
414
467
|
};
|
|
415
468
|
_ts_decorate3([
|
|
416
469
|
(0, import_core4.Tool)({
|
|
417
|
-
description: "
|
|
470
|
+
description: "Run the full WZRD earn cycle: pick a prompt, run server-witnessed inference, report the outcome, and check pending rewards. One tool call, complete loop. Earns verified CCM rewards on Solana. Use task_type to control prompt category (code/chat/reasoning) or provide a custom prompt."
|
|
418
471
|
}),
|
|
419
472
|
_ts_metadata3("design:type", Function),
|
|
420
473
|
_ts_metadata3("design:paramtypes", [
|
|
421
|
-
typeof
|
|
422
|
-
typeof
|
|
474
|
+
typeof import_wallet_solana3.SolanaWalletClient === "undefined" ? Object : import_wallet_solana3.SolanaWalletClient,
|
|
475
|
+
typeof EarnParameters === "undefined" ? Object : EarnParameters
|
|
423
476
|
]),
|
|
424
477
|
_ts_metadata3("design:returntype", Promise)
|
|
425
|
-
],
|
|
426
|
-
function formatUsdc(nativeAmount) {
|
|
427
|
-
return (Number(nativeAmount) / 1e6).toFixed(4);
|
|
428
|
-
}
|
|
429
|
-
__name(formatUsdc, "formatUsdc");
|
|
430
|
-
function formatCcm(nativeAmount) {
|
|
431
|
-
return (Number(nativeAmount) / 1e6).toFixed(4);
|
|
432
|
-
}
|
|
433
|
-
__name(formatCcm, "formatCcm");
|
|
478
|
+
], EarnTools.prototype, "wzrd_earn", null);
|
|
434
479
|
|
|
435
|
-
// src/tools/
|
|
480
|
+
// src/tools/claim.ts
|
|
436
481
|
var import_core5 = require("@goat-sdk/core");
|
|
437
|
-
var
|
|
438
|
-
var import_web3 = require("@solana/web3.js");
|
|
439
|
-
var import_meta = {};
|
|
482
|
+
var import_wallet_solana4 = require("@goat-sdk/wallet-solana");
|
|
440
483
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
441
484
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
442
485
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -448,127 +491,64 @@ function _ts_metadata4(k, v) {
|
|
|
448
491
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
449
492
|
}
|
|
450
493
|
__name(_ts_metadata4, "_ts_metadata");
|
|
451
|
-
var
|
|
494
|
+
var ClaimTools = class {
|
|
452
495
|
static {
|
|
453
|
-
__name(this, "
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
constructor(
|
|
457
|
-
this.
|
|
458
|
-
}
|
|
459
|
-
async
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
const payer = new import_web3.PublicKey(walletClient.getAddress());
|
|
463
|
-
const amountNative = BigInt(Math.round(amount_usdc * 1e6));
|
|
464
|
-
const t0 = Date.now();
|
|
465
|
-
const sdk = await loadSdk();
|
|
466
|
-
const { createDepositMarketIx, fetchMarketVault, fetchOnChainPosition, fetchTokenBalance, getAta, TOKEN_PROGRAM_ID } = sdk;
|
|
467
|
-
const vault = await fetchMarketVault(connection, market_id);
|
|
468
|
-
if (!vault) {
|
|
469
|
-
return {
|
|
470
|
-
success: false,
|
|
471
|
-
error: `Market ${market_id} is listed but does not have an on-chain vault yet. Pick a market with an initialized vault before depositing.`,
|
|
472
|
-
market_id,
|
|
473
|
-
reason: "missing_vault"
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
const existing = await fetchOnChainPosition(connection, payer, market_id);
|
|
477
|
-
if (existing && existing.depositedAmount > 0n && !existing.settled) {
|
|
478
|
-
return {
|
|
479
|
-
success: false,
|
|
480
|
-
error: `Position already exists in market ${market_id}. Cannot double-deposit.`,
|
|
481
|
-
market_id,
|
|
482
|
-
deposited_amount: existing.depositedAmount.toString()
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
const usdcAta = getAta(payer, vault.depositMint, TOKEN_PROGRAM_ID);
|
|
486
|
-
const usdcBalance = await fetchTokenBalance(connection, usdcAta);
|
|
487
|
-
if (usdcBalance < amountNative) {
|
|
496
|
+
__name(this, "ClaimTools");
|
|
497
|
+
}
|
|
498
|
+
client;
|
|
499
|
+
constructor(client) {
|
|
500
|
+
this.client = client;
|
|
501
|
+
}
|
|
502
|
+
async wzrd_claim(walletClient, _parameters) {
|
|
503
|
+
const status = await this.client.getClaimStatus(walletClient);
|
|
504
|
+
if (status.claimable <= 0) {
|
|
488
505
|
return {
|
|
489
|
-
success:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
506
|
+
success: true,
|
|
507
|
+
summary: `No CCM to claim right now. Cumulative: ${formatCcm(status.cumulative_total)} CCM, already claimed: ${formatCcm(status.claimed_total)} CCM. Run wzrd_earn first to accrue rewards.`,
|
|
508
|
+
claimable: 0,
|
|
509
|
+
cumulative_total: status.cumulative_total,
|
|
510
|
+
claimed_total: status.claimed_total
|
|
494
511
|
};
|
|
495
512
|
}
|
|
496
|
-
const
|
|
497
|
-
if (
|
|
513
|
+
const result = await this.client.claimRelay(walletClient);
|
|
514
|
+
if (result.status === "already_claimed") {
|
|
498
515
|
return {
|
|
499
|
-
success:
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
516
|
+
success: true,
|
|
517
|
+
summary: `Already claimed through root ${result.root_seq}.`,
|
|
518
|
+
already_claimed: true,
|
|
519
|
+
root_seq: result.root_seq
|
|
503
520
|
};
|
|
504
521
|
}
|
|
505
|
-
let ixs;
|
|
506
|
-
try {
|
|
507
|
-
ixs = await createDepositMarketIx(connection, payer, market_id, amountNative);
|
|
508
|
-
} catch (error) {
|
|
509
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
510
|
-
if (message.includes("MarketVault not found")) {
|
|
511
|
-
return {
|
|
512
|
-
success: false,
|
|
513
|
-
error: `Market ${market_id} vault not found on-chain.`,
|
|
514
|
-
market_id,
|
|
515
|
-
reason: "missing_vault"
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
throw error;
|
|
519
|
-
}
|
|
520
|
-
ixs.unshift(import_web3.ComputeBudgetProgram.setComputeUnitLimit({
|
|
521
|
-
units: 3e5
|
|
522
|
-
}), import_web3.ComputeBudgetProgram.setComputeUnitPrice({
|
|
523
|
-
microLamports: priority_fee
|
|
524
|
-
}));
|
|
525
|
-
const { hash } = await walletClient.sendTransaction({
|
|
526
|
-
instructions: ixs
|
|
527
|
-
});
|
|
528
|
-
const elapsed = Date.now() - t0;
|
|
529
522
|
return {
|
|
530
523
|
success: true,
|
|
531
|
-
summary: `
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
explorer: `https://
|
|
524
|
+
summary: `Claimed CCM via gasless relay. Cumulative: ${formatCcm(result.cumulative_total)} CCM. Root seq: ${result.root_seq}. Tx: ${result.tx_sig?.slice(0, 16)}...`,
|
|
525
|
+
cumulative_total: result.cumulative_total,
|
|
526
|
+
root_seq: result.root_seq,
|
|
527
|
+
tx_sig: result.tx_sig,
|
|
528
|
+
claimable_before: status.claimable,
|
|
529
|
+
explorer: result.tx_sig ? `https://orbmarkets.io/tx/${result.tx_sig}` : null
|
|
537
530
|
};
|
|
538
531
|
}
|
|
539
532
|
};
|
|
540
533
|
_ts_decorate4([
|
|
541
534
|
(0, import_core5.Tool)({
|
|
542
|
-
description: "
|
|
535
|
+
description: "Claim accrued CCM tokens via gasless relay. The server pays transaction fees \u2014 no SOL needed. CCM accrues from verified inference reports (wzrd_earn/wzrd_report). Call this periodically to harvest earned CCM to your wallet."
|
|
543
536
|
}),
|
|
544
537
|
_ts_metadata4("design:type", Function),
|
|
545
538
|
_ts_metadata4("design:paramtypes", [
|
|
546
|
-
typeof
|
|
547
|
-
typeof
|
|
539
|
+
typeof import_wallet_solana4.SolanaWalletClient === "undefined" ? Object : import_wallet_solana4.SolanaWalletClient,
|
|
540
|
+
typeof ClaimParameters === "undefined" ? Object : ClaimParameters
|
|
548
541
|
]),
|
|
549
542
|
_ts_metadata4("design:returntype", Promise)
|
|
550
|
-
],
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return await import("@wzrd_sol/sdk");
|
|
554
|
-
} catch (error) {
|
|
555
|
-
const fallbackUrl = new URL("../../../../../sdk/dist/index.js", import_meta.url);
|
|
556
|
-
try {
|
|
557
|
-
return await import(fallbackUrl.href);
|
|
558
|
-
} catch {
|
|
559
|
-
throw error;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
__name(loadSdk, "loadSdk");
|
|
564
|
-
function formatUsdc2(nativeAmount) {
|
|
565
|
-
return (Number(nativeAmount) / 1e6).toFixed(4);
|
|
543
|
+
], ClaimTools.prototype, "wzrd_claim", null);
|
|
544
|
+
function formatCcm(nativeAmount) {
|
|
545
|
+
return (Number(nativeAmount) / 1e9).toFixed(2);
|
|
566
546
|
}
|
|
567
|
-
__name(
|
|
547
|
+
__name(formatCcm, "formatCcm");
|
|
568
548
|
|
|
569
|
-
// src/tools/
|
|
549
|
+
// src/tools/rewards.ts
|
|
570
550
|
var import_core6 = require("@goat-sdk/core");
|
|
571
|
-
var
|
|
551
|
+
var import_wallet_solana5 = require("@goat-sdk/wallet-solana");
|
|
572
552
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
573
553
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
574
554
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -580,91 +560,36 @@ function _ts_metadata5(k, v) {
|
|
|
580
560
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
581
561
|
}
|
|
582
562
|
__name(_ts_metadata5, "_ts_metadata");
|
|
583
|
-
var
|
|
563
|
+
var RewardsTools = class {
|
|
584
564
|
static {
|
|
585
|
-
__name(this, "
|
|
565
|
+
__name(this, "RewardsTools");
|
|
586
566
|
}
|
|
587
|
-
|
|
588
|
-
constructor(
|
|
589
|
-
this.
|
|
567
|
+
client;
|
|
568
|
+
constructor(client) {
|
|
569
|
+
this.client = client;
|
|
590
570
|
}
|
|
591
|
-
async
|
|
592
|
-
const
|
|
593
|
-
const token = await this.api.authenticate(walletClient);
|
|
594
|
-
const claimsRes = await fetch(`${this.api.apiUrl}/v1/claims/${pubkey}`, {
|
|
595
|
-
headers: {
|
|
596
|
-
Authorization: `Bearer ${token}`
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
if (!claimsRes.ok) {
|
|
600
|
-
throw new Error(`Claims check failed: ${claimsRes.status}`);
|
|
601
|
-
}
|
|
602
|
-
const claims = await claimsRes.json();
|
|
603
|
-
const claimable = claims.cumulative_total - claims.claimed_total;
|
|
604
|
-
if (claimable <= 0) {
|
|
605
|
-
return {
|
|
606
|
-
success: true,
|
|
607
|
-
summary: `No CCM to claim. Cumulative: ${formatCcm2(claims.cumulative_total)}, already claimed: ${formatCcm2(claims.claimed_total)}.`,
|
|
608
|
-
claimable: 0,
|
|
609
|
-
cumulative_total: claims.cumulative_total,
|
|
610
|
-
claimed_total: claims.claimed_total
|
|
611
|
-
};
|
|
612
|
-
}
|
|
613
|
-
if (parameters.execute === false) {
|
|
614
|
-
return {
|
|
615
|
-
success: true,
|
|
616
|
-
summary: `${formatCcm2(claimable)} CCM claimable (${formatCcm2(claims.cumulative_total)} cumulative, ${formatCcm2(claims.claimed_total)} claimed). Root seq: ${claims.root_seq}. Set execute=true to claim.`,
|
|
617
|
-
claimable,
|
|
618
|
-
cumulative_total: claims.cumulative_total,
|
|
619
|
-
claimed_total: claims.claimed_total,
|
|
620
|
-
root_seq: claims.root_seq
|
|
621
|
-
};
|
|
622
|
-
}
|
|
623
|
-
const relayRes = await fetch(`${this.api.apiUrl}/v1/claims/${pubkey}/relay`, {
|
|
624
|
-
method: "POST",
|
|
625
|
-
headers: {
|
|
626
|
-
Authorization: `Bearer ${token}`,
|
|
627
|
-
"Content-Type": "application/json"
|
|
628
|
-
}
|
|
629
|
-
});
|
|
630
|
-
if (!relayRes.ok) {
|
|
631
|
-
throw new Error(`Relay claim failed: ${relayRes.status} ${await relayRes.text()}`);
|
|
632
|
-
}
|
|
633
|
-
const result = await relayRes.json();
|
|
634
|
-
if (result.status === "already_claimed") {
|
|
635
|
-
return {
|
|
636
|
-
success: true,
|
|
637
|
-
summary: `Already claimed through root ${result.root_seq}. Claimed total: ${formatCcm2(result.claimed_total ?? claims.claimed_total)} CCM.`,
|
|
638
|
-
already_claimed: true,
|
|
639
|
-
root_seq: result.root_seq
|
|
640
|
-
};
|
|
641
|
-
}
|
|
571
|
+
async wzrd_rewards(walletClient, _parameters) {
|
|
572
|
+
const rewards = await this.client.getRewards(walletClient);
|
|
642
573
|
return {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
claimable_before: claimable,
|
|
649
|
-
explorer: result.tx_sig ? `https://solscan.io/tx/${result.tx_sig}` : null
|
|
574
|
+
summary: `WZRD Rewards: ${(rewards.pending_ccm / 1e9).toFixed(2)} CCM pending, ${(rewards.total_rewarded_ccm / 1e9).toFixed(2)} CCM lifetime, ${rewards.contribution_count} contributions` + (rewards.rank ? `, rank #${rewards.rank}` : ""),
|
|
575
|
+
pending_ccm: rewards.pending_ccm,
|
|
576
|
+
total_rewarded_ccm: rewards.total_rewarded_ccm,
|
|
577
|
+
contribution_count: rewards.contribution_count,
|
|
578
|
+
rank: rewards.rank
|
|
650
579
|
};
|
|
651
580
|
}
|
|
652
581
|
};
|
|
653
582
|
_ts_decorate5([
|
|
654
583
|
(0, import_core6.Tool)({
|
|
655
|
-
description: "
|
|
584
|
+
description: "Check your pending CCM rewards, lifetime total, and contribution count. Use this to see how much you've earned from WZRD inference before claiming."
|
|
656
585
|
}),
|
|
657
586
|
_ts_metadata5("design:type", Function),
|
|
658
587
|
_ts_metadata5("design:paramtypes", [
|
|
659
|
-
typeof
|
|
660
|
-
typeof
|
|
588
|
+
typeof import_wallet_solana5.SolanaWalletClient === "undefined" ? Object : import_wallet_solana5.SolanaWalletClient,
|
|
589
|
+
typeof RewardsParameters === "undefined" ? Object : RewardsParameters
|
|
661
590
|
]),
|
|
662
591
|
_ts_metadata5("design:returntype", Promise)
|
|
663
|
-
],
|
|
664
|
-
function formatCcm2(nativeAmount) {
|
|
665
|
-
return (Number(nativeAmount) / 1e6).toFixed(4);
|
|
666
|
-
}
|
|
667
|
-
__name(formatCcm2, "formatCcm");
|
|
592
|
+
], RewardsTools.prototype, "wzrd_rewards", null);
|
|
668
593
|
|
|
669
594
|
// src/wzrd.plugin.ts
|
|
670
595
|
var WzrdPlugin = class extends import_core7.PluginBase {
|
|
@@ -672,13 +597,13 @@ var WzrdPlugin = class extends import_core7.PluginBase {
|
|
|
672
597
|
__name(this, "WzrdPlugin");
|
|
673
598
|
}
|
|
674
599
|
constructor(options) {
|
|
675
|
-
const
|
|
600
|
+
const client = new WzrdClient(options);
|
|
676
601
|
super("wzrd", [
|
|
677
|
-
new
|
|
678
|
-
new
|
|
679
|
-
new
|
|
680
|
-
new
|
|
681
|
-
new
|
|
602
|
+
new EarnTools(client),
|
|
603
|
+
new InferTools(client),
|
|
604
|
+
new ReportTools(client),
|
|
605
|
+
new ClaimTools(client),
|
|
606
|
+
new RewardsTools(client)
|
|
682
607
|
]);
|
|
683
608
|
}
|
|
684
609
|
supportsChain = /* @__PURE__ */ __name((chain) => chain.type === "solana", "supportsChain");
|
|
@@ -687,11 +612,11 @@ var wzrd = /* @__PURE__ */ __name((options) => new WzrdPlugin(options), "wzrd");
|
|
|
687
612
|
// Annotate the CommonJS export names for ESM import in node:
|
|
688
613
|
0 && (module.exports = {
|
|
689
614
|
ClaimParameters,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
615
|
+
EarnParameters,
|
|
616
|
+
InferParameters,
|
|
617
|
+
ReportParameters,
|
|
618
|
+
RewardsParameters,
|
|
619
|
+
WzrdClient,
|
|
695
620
|
WzrdPlugin,
|
|
696
621
|
wzrd
|
|
697
622
|
});
|