@candledottv/agent-sdk 0.4.10 → 0.5.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 +164 -8
- package/dist/client.d.ts +297 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +98 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +171 -34
- package/dist/staking.d.ts +136 -0
- package/dist/staking.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -161,6 +161,51 @@ class JsonRpcError extends Error {
|
|
|
161
161
|
this.data = args.data;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
+
function operationErrorMessage(cause, ids, flow) {
|
|
165
|
+
const original = cause instanceof Error ? cause.message : String(cause);
|
|
166
|
+
const isTrade = ids.clientTradeId !== undefined;
|
|
167
|
+
const idName = isTrade ? "clientTradeId" : "clientLaunchId";
|
|
168
|
+
const noun = isTrade ? "trade" : "launch";
|
|
169
|
+
const read = isTrade ? "getTradeJob()" : "getLaunchJob()";
|
|
170
|
+
const bundle = ids.bundleId !== undefined ? ` (bundleId ${ids.bundleId}, single-use: for logs only, never resubmitted)` : "";
|
|
171
|
+
const head = `${original} -- ${idName} ${ids.clientTradeId ?? ids.clientLaunchId}${bundle}: ` + "the request may or may not have reached Candle.";
|
|
172
|
+
const tail = `A call with a new id, or with none, is a second, independent ${noun}.`;
|
|
173
|
+
if (flow === "server-executed") {
|
|
174
|
+
return `${head} Read the job for this id (${read}), or retry the call with this same ${idName} and the same request. ${tail}`;
|
|
175
|
+
}
|
|
176
|
+
return `${head} This id identifies the job: read the job for this id (${read}), and check the wallet's recent ` + `transactions before sending again, because a call under the same id can sign and broadcast a second ` + `transaction. ${tail}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
class CandleOperationError extends Error {
|
|
180
|
+
constructor(args) {
|
|
181
|
+
super(operationErrorMessage(args.cause, args.ids, args.flow), { cause: args.cause });
|
|
182
|
+
this.name = "CandleOperationError";
|
|
183
|
+
Object.assign(this, definedIds(args.ids));
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function definedIds(ids) {
|
|
187
|
+
return {
|
|
188
|
+
...typeof ids.clientTradeId === "string" ? { clientTradeId: ids.clientTradeId } : {},
|
|
189
|
+
...typeof ids.clientLaunchId === "string" ? { clientLaunchId: ids.clientLaunchId } : {},
|
|
190
|
+
...typeof ids.bundleId === "string" ? { bundleId: ids.bundleId } : {}
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
function operationIds(error) {
|
|
194
|
+
if (error instanceof CandleApiError || error instanceof JsonRpcError || error instanceof TradeLandedFeeLegError || error instanceof CandleOperationError) {
|
|
195
|
+
return definedIds(error);
|
|
196
|
+
}
|
|
197
|
+
return {};
|
|
198
|
+
}
|
|
199
|
+
function withOperationIds(error, ids, flow) {
|
|
200
|
+
if (error instanceof CandleApiError || error instanceof JsonRpcError)
|
|
201
|
+
return Object.assign(error, definedIds(ids));
|
|
202
|
+
if (error instanceof TradeLandedFeeLegError)
|
|
203
|
+
return error;
|
|
204
|
+
if (error instanceof CandleOperationError) {
|
|
205
|
+
return new CandleOperationError({ cause: error.cause, ids: { ...operationIds(error), ...definedIds(ids) }, flow });
|
|
206
|
+
}
|
|
207
|
+
return new CandleOperationError({ cause: error, ids, flow });
|
|
208
|
+
}
|
|
164
209
|
function envelopeError(body) {
|
|
165
210
|
if (typeof body !== "object" || body === null)
|
|
166
211
|
return null;
|
|
@@ -991,6 +1036,25 @@ class CandleClient {
|
|
|
991
1036
|
});
|
|
992
1037
|
}
|
|
993
1038
|
};
|
|
1039
|
+
staking = {
|
|
1040
|
+
positions: async () => {
|
|
1041
|
+
this.requireKey("staking.positions()");
|
|
1042
|
+
return this.requestJson("GET", "/api/v1/agent/staking");
|
|
1043
|
+
},
|
|
1044
|
+
stake: async (request) => this.stakingBuild("stake", { ...request, payer: request.payer ?? "main" }),
|
|
1045
|
+
unstake: async (request) => this.stakingBuild("unstake", { ...request, payer: request.payer ?? "main" }),
|
|
1046
|
+
finish: async (request) => this.stakingBuild("finish", { ...request, payer: request.payer ?? "main" }),
|
|
1047
|
+
claimReward: async (rewardId) => {
|
|
1048
|
+
this.requireKey("staking.claimReward()");
|
|
1049
|
+
return this.requestJson("POST", `/api/v1/agent/staking/rewards/${encodeURIComponent(rewardId)}/claim`, {});
|
|
1050
|
+
},
|
|
1051
|
+
submit: async (request) => this.stakingBuild("submit", request),
|
|
1052
|
+
confirm: async (request) => this.stakingBuild("confirm", request)
|
|
1053
|
+
};
|
|
1054
|
+
async stakingBuild(action, request) {
|
|
1055
|
+
this.requireKey(`staking.${action}()`);
|
|
1056
|
+
return this.requestJson("POST", `/api/v1/agent/staking/${action === "submit" || action === "confirm" ? action : `${action}/build`}`, request);
|
|
1057
|
+
}
|
|
994
1058
|
constructor(opts) {
|
|
995
1059
|
assertTransportSecurity(opts.apiUrl, opts.allowInsecureHttp === true);
|
|
996
1060
|
this.apiUrl = opts.apiUrl.replace(/\/+$/, "");
|
|
@@ -1059,6 +1123,21 @@ class CandleClient {
|
|
|
1059
1123
|
const body = await this.requestJson("GET", `/api/v1/users/${encodeURIComponent(idOrWallet)}/agent`);
|
|
1060
1124
|
return body.agent;
|
|
1061
1125
|
}
|
|
1126
|
+
async listAgents(options = {}) {
|
|
1127
|
+
const params = new URLSearchParams;
|
|
1128
|
+
if (options.sort !== undefined)
|
|
1129
|
+
params.set("sort", options.sort);
|
|
1130
|
+
if (options.strategy !== undefined)
|
|
1131
|
+
params.set("strategy", options.strategy);
|
|
1132
|
+
if (options.query !== undefined && options.query.trim() !== "")
|
|
1133
|
+
params.set("q", options.query);
|
|
1134
|
+
if (options.limit !== undefined)
|
|
1135
|
+
params.set("limit", String(options.limit));
|
|
1136
|
+
if (options.cursor !== undefined)
|
|
1137
|
+
params.set("cursor", options.cursor);
|
|
1138
|
+
const body = await this.requestJson("GET", `/api/v1/agent/directory${params.size ? `?${params}` : ""}`);
|
|
1139
|
+
return body.directory;
|
|
1140
|
+
}
|
|
1062
1141
|
async getAgentTier() {
|
|
1063
1142
|
return this.requestJson("GET", "/api/v1/agent/tier");
|
|
1064
1143
|
}
|
|
@@ -1071,25 +1150,33 @@ class CandleClient {
|
|
|
1071
1150
|
}
|
|
1072
1151
|
async launch(req) {
|
|
1073
1152
|
this.requireKey("launch()");
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1153
|
+
const clientLaunchId = req.clientLaunchId ?? generateClientLaunchId();
|
|
1154
|
+
const body = { ...req, clientLaunchId };
|
|
1155
|
+
return this.runOperation({ clientLaunchId }, "server-executed", async (op) => {
|
|
1156
|
+
let lastError;
|
|
1157
|
+
for (let attempt = 0;attempt <= this.maxRetries; attempt++) {
|
|
1158
|
+
if (attempt > 0)
|
|
1159
|
+
await sleep2(retryDelayMs(attempt - 1));
|
|
1160
|
+
try {
|
|
1161
|
+
const result = await this.requestJson("POST", "/api/v1/launch/headless", body, op);
|
|
1162
|
+
return { ...result, clientLaunchId };
|
|
1163
|
+
} catch (error) {
|
|
1164
|
+
if (!isRetryableLaunchFailure(error))
|
|
1165
|
+
throw error;
|
|
1166
|
+
lastError = error;
|
|
1167
|
+
}
|
|
1085
1168
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1169
|
+
throw lastError;
|
|
1170
|
+
});
|
|
1088
1171
|
}
|
|
1089
1172
|
async launchAsync(req) {
|
|
1090
1173
|
this.requireKey("launchAsync()");
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1174
|
+
const clientLaunchId = req.clientLaunchId ?? generateClientLaunchId();
|
|
1175
|
+
const body = { ...req, clientLaunchId, async: true };
|
|
1176
|
+
return this.runOperation({ clientLaunchId }, "server-executed", async (op) => {
|
|
1177
|
+
const accepted = await this.requestJson("POST", "/api/v1/launch/headless", body, op);
|
|
1178
|
+
return { ...accepted, clientLaunchId: accepted.clientLaunchId ?? clientLaunchId };
|
|
1179
|
+
});
|
|
1093
1180
|
}
|
|
1094
1181
|
async getLaunchJob(clientLaunchId) {
|
|
1095
1182
|
this.requireKey("getLaunchJob()");
|
|
@@ -1207,16 +1294,28 @@ class CandleClient {
|
|
|
1207
1294
|
return this.requestJson("POST", "/api/v1/launch/self/dry-run", req);
|
|
1208
1295
|
}
|
|
1209
1296
|
async buildSelfLaunch(req) {
|
|
1297
|
+
return this.postSelfLaunchBuild(req);
|
|
1298
|
+
}
|
|
1299
|
+
async postSelfLaunchBuild(req, op) {
|
|
1210
1300
|
this.requireKey("buildSelfLaunch()");
|
|
1211
|
-
return this.requestJson("POST", "/api/v1/launch/self/build", req);
|
|
1301
|
+
return this.requestJson("POST", "/api/v1/launch/self/build", req, op);
|
|
1212
1302
|
}
|
|
1213
1303
|
async confirmSelfLaunch(req) {
|
|
1214
1304
|
this.requireKey("confirmSelfLaunch()");
|
|
1215
|
-
|
|
1305
|
+
const result = await this.requestJson("POST", "/api/v1/launch/self/confirm", req);
|
|
1306
|
+
return { ...result, clientLaunchId: req.clientLaunchId };
|
|
1216
1307
|
}
|
|
1217
1308
|
async buildTrade(req) {
|
|
1309
|
+
return this.postTradeBuild(req);
|
|
1310
|
+
}
|
|
1311
|
+
async postTradeBuild(req, op) {
|
|
1218
1312
|
this.requireKey("buildTrade()");
|
|
1219
|
-
return this.requestJson("POST", "/api/v1/trade/agent/build", req);
|
|
1313
|
+
return this.requestJson("POST", "/api/v1/trade/agent/build", req, op);
|
|
1314
|
+
}
|
|
1315
|
+
async getTradeJob(clientTradeId) {
|
|
1316
|
+
this.requireKey("getTradeJob()");
|
|
1317
|
+
const body = await this.requestJson("GET", `/api/v1/trade/agent/jobs/${encodeURIComponent(clientTradeId)}`);
|
|
1318
|
+
return body.job;
|
|
1220
1319
|
}
|
|
1221
1320
|
async confirmTrade(req) {
|
|
1222
1321
|
this.requireKey("confirmTrade()");
|
|
@@ -1305,15 +1404,22 @@ class CandleClient {
|
|
|
1305
1404
|
...req.maxSlippageBps !== undefined ? { maxSlippageBps: req.maxSlippageBps } : {},
|
|
1306
1405
|
...req.quoteAsset !== undefined ? { quoteAsset: req.quoteAsset } : {}
|
|
1307
1406
|
};
|
|
1407
|
+
const flow = req.from === "main" ? "server-executed" : "caller-broadcast";
|
|
1408
|
+
return this.runOperation({ clientTradeId }, flow, async (op) => {
|
|
1409
|
+
const result = await this.tradeSteps(req, buildReq, op);
|
|
1410
|
+
return typeof result.clientTradeId === "string" ? result : { ...result, clientTradeId };
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
async tradeSteps(req, buildReq, op) {
|
|
1308
1414
|
if (req.from === "main") {
|
|
1309
|
-
const result = await this.
|
|
1415
|
+
const result = await this.postTradeBuild(buildReq, op);
|
|
1310
1416
|
if (result.status !== "executed") {
|
|
1311
1417
|
throw new Error(`trade({ from: "main" }) expected an executed result but got status "${result.status}"`);
|
|
1312
1418
|
}
|
|
1313
1419
|
return result;
|
|
1314
1420
|
}
|
|
1315
1421
|
const { linkedWalletId, privyWalletId } = req.from;
|
|
1316
|
-
const built = await this.
|
|
1422
|
+
const built = await this.postTradeBuild(buildReq, op);
|
|
1317
1423
|
if (built.status !== "built") {
|
|
1318
1424
|
return built;
|
|
1319
1425
|
}
|
|
@@ -1392,11 +1498,12 @@ class CandleClient {
|
|
|
1392
1498
|
}
|
|
1393
1499
|
async selfLaunch(req) {
|
|
1394
1500
|
const { privyWalletId, ...launchReq } = req;
|
|
1395
|
-
const
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1501
|
+
const clientLaunchId = launchReq.clientLaunchId ?? generateClientLaunchId();
|
|
1502
|
+
const body = { ...launchReq, clientLaunchId };
|
|
1503
|
+
return this.runOperation({ clientLaunchId }, "caller-broadcast", (op) => this.selfLaunchSteps(body, privyWalletId, op));
|
|
1504
|
+
}
|
|
1505
|
+
async selfLaunchSteps(body, privyWalletId, op) {
|
|
1506
|
+
const built = await this.postSelfLaunchBuild(body, op);
|
|
1400
1507
|
if (typeof built.transaction === "string") {
|
|
1401
1508
|
let unsignedTransactionBase64 = built.transaction;
|
|
1402
1509
|
let clientLaunchId = built.clientLaunchId;
|
|
@@ -1415,7 +1522,7 @@ class CandleClient {
|
|
|
1415
1522
|
throw error;
|
|
1416
1523
|
if (attempt === MAX_BLOCKHASH_REBUILDS)
|
|
1417
1524
|
throw withRpcLagHint(error);
|
|
1418
|
-
const rebuilt = await this.
|
|
1525
|
+
const rebuilt = await this.postSelfLaunchBuild(body, op);
|
|
1419
1526
|
if (typeof rebuilt.transaction !== "string")
|
|
1420
1527
|
throw error;
|
|
1421
1528
|
unsignedTransactionBase64 = rebuilt.transaction;
|
|
@@ -1468,8 +1575,13 @@ class CandleClient {
|
|
|
1468
1575
|
}
|
|
1469
1576
|
async buildAtomicLaunch(req) {
|
|
1470
1577
|
this.requireKey("buildAtomicLaunch()");
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1578
|
+
const clientLaunchId = req.clientLaunchId ?? generateClientLaunchId();
|
|
1579
|
+
const body = { ...req, clientLaunchId };
|
|
1580
|
+
return this.runOperation({ clientLaunchId }, "server-executed", (op) => this.postAtomicBuild(body, clientLaunchId, op));
|
|
1581
|
+
}
|
|
1582
|
+
async postAtomicBuild(body, clientLaunchId, op) {
|
|
1583
|
+
const built = await this.requestJson("POST", "/api/v1/launch/atomic/build", body, op);
|
|
1584
|
+
return { ...built, clientLaunchId };
|
|
1473
1585
|
}
|
|
1474
1586
|
async submitAtomicLaunch(req) {
|
|
1475
1587
|
this.requireKey("submitAtomicLaunch()");
|
|
@@ -1492,14 +1604,24 @@ class CandleClient {
|
|
|
1492
1604
|
throw new Error(`submitAtomicLaunch(): unexpected 200 response shape: ${text}`);
|
|
1493
1605
|
}
|
|
1494
1606
|
async launchAtomic(req) {
|
|
1607
|
+
this.requireKey("buildAtomicLaunch()");
|
|
1495
1608
|
const { payer, firstBuys, ...launchFields } = req;
|
|
1609
|
+
const clientLaunchId = launchFields.clientLaunchId ?? generateClientLaunchId();
|
|
1496
1610
|
const buildReq = {
|
|
1497
1611
|
...launchFields,
|
|
1498
|
-
clientLaunchId
|
|
1612
|
+
clientLaunchId,
|
|
1499
1613
|
payer: toAtomicWirePayer(payer),
|
|
1500
1614
|
firstBuys: firstBuys.map((leg) => ({ payer: toAtomicWirePayer(leg.payer), amountRaw: leg.amountRaw }))
|
|
1501
1615
|
};
|
|
1502
|
-
|
|
1616
|
+
return this.runOperation({ clientLaunchId }, "server-executed", async (op) => {
|
|
1617
|
+
const outcome = await this.launchAtomicSteps(req, buildReq, clientLaunchId, op);
|
|
1618
|
+
return { ...outcome, clientLaunchId };
|
|
1619
|
+
});
|
|
1620
|
+
}
|
|
1621
|
+
async launchAtomicSteps(req, buildReq, clientLaunchId, op) {
|
|
1622
|
+
const { payer, firstBuys } = req;
|
|
1623
|
+
const built = await this.postAtomicBuild(buildReq, clientLaunchId, op);
|
|
1624
|
+
op.ids.bundleId = built.bundleId;
|
|
1503
1625
|
const signedTxsBase64 = [];
|
|
1504
1626
|
for (const leg of built.legs) {
|
|
1505
1627
|
if (leg.signer !== "client")
|
|
@@ -1835,12 +1957,25 @@ class CandleClient {
|
|
|
1835
1957
|
headers["x-api-key"] = this.apiKey;
|
|
1836
1958
|
return headers;
|
|
1837
1959
|
}
|
|
1838
|
-
async
|
|
1839
|
-
const
|
|
1960
|
+
async runOperation(ids, flow, steps) {
|
|
1961
|
+
const op = { sent: false, ids: { ...ids } };
|
|
1962
|
+
try {
|
|
1963
|
+
return await steps(op);
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
if (!op.sent)
|
|
1966
|
+
throw error;
|
|
1967
|
+
throw withOperationIds(error, op.ids, flow);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
async requestJson(method, path, body, op) {
|
|
1971
|
+
const init = {
|
|
1840
1972
|
method,
|
|
1841
1973
|
headers: this.headers({ json: body !== undefined }),
|
|
1842
1974
|
...body !== undefined ? { body: JSON.stringify(body) } : {}
|
|
1843
|
-
}
|
|
1975
|
+
};
|
|
1976
|
+
if (op)
|
|
1977
|
+
op.sent = true;
|
|
1978
|
+
const res = await this.fetchImpl(`${this.apiUrl}${path}`, init);
|
|
1844
1979
|
return this.parseResponse(res);
|
|
1845
1980
|
}
|
|
1846
1981
|
async parseResponse(res) {
|
|
@@ -1963,7 +2098,7 @@ function generateClientLaunchId() {
|
|
|
1963
2098
|
function generateClientTradeId() {
|
|
1964
2099
|
return generateSdkId();
|
|
1965
2100
|
}
|
|
1966
|
-
var SDK_VERSION = "0.
|
|
2101
|
+
var SDK_VERSION = "0.5.0";
|
|
1967
2102
|
var sdkUpdateWarned = false;
|
|
1968
2103
|
function noteLatestSdkVersion(value) {
|
|
1969
2104
|
if (sdkUpdateWarned || !value || !/^\d+\.\d+\.\d+$/.test(value))
|
|
@@ -2327,6 +2462,7 @@ export {
|
|
|
2327
2462
|
planPromotionLine,
|
|
2328
2463
|
planLabel,
|
|
2329
2464
|
perpsDepositProblem,
|
|
2465
|
+
operationIds,
|
|
2330
2466
|
isSolanaRpcErrorData,
|
|
2331
2467
|
hyperliquidActionHash,
|
|
2332
2468
|
generateSignerKeypair,
|
|
@@ -2341,6 +2477,7 @@ export {
|
|
|
2341
2477
|
HYPERLIQUID_EXCHANGE_URLS,
|
|
2342
2478
|
HYPERLIQUID_ALLOWED_ACTION_TYPES,
|
|
2343
2479
|
EncryptedFileSecretStore,
|
|
2480
|
+
CandleOperationError,
|
|
2344
2481
|
CandleClient,
|
|
2345
2482
|
CandleApiError,
|
|
2346
2483
|
CANDLE_HYPERLIQUID_BUILDER_ADDRESS,
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Agent staking is Solana-only. Builds for linked wallets return bytes for external signing. */
|
|
2
|
+
export type StakingPayer = {
|
|
3
|
+
payer?: "main";
|
|
4
|
+
linkedWalletId?: never;
|
|
5
|
+
} | {
|
|
6
|
+
payer: "linked";
|
|
7
|
+
linkedWalletId: string;
|
|
8
|
+
};
|
|
9
|
+
export type StakeRequest = StakingPayer & {
|
|
10
|
+
amountRaw: string;
|
|
11
|
+
clientStakeId: string;
|
|
12
|
+
dryRun?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type FinishUnstakeRequest = StakingPayer & {
|
|
15
|
+
withdrawal: string;
|
|
16
|
+
clientStakeId: string;
|
|
17
|
+
dryRun?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface StakingWithdrawal {
|
|
20
|
+
withdrawal: string;
|
|
21
|
+
amountRaw: string;
|
|
22
|
+
startTime: string;
|
|
23
|
+
endTime: string;
|
|
24
|
+
claimTime?: string;
|
|
25
|
+
claimable: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface StakingWalletPosition {
|
|
28
|
+
payer: "main" | "linked";
|
|
29
|
+
address: string;
|
|
30
|
+
linkedWalletId?: string;
|
|
31
|
+
tee?: boolean;
|
|
32
|
+
label?: string | null;
|
|
33
|
+
delegated?: boolean;
|
|
34
|
+
cndl: {
|
|
35
|
+
mint: string;
|
|
36
|
+
decimals: number;
|
|
37
|
+
amountRaw: string;
|
|
38
|
+
};
|
|
39
|
+
staked: {
|
|
40
|
+
mint: string;
|
|
41
|
+
decimals: number;
|
|
42
|
+
amountRaw: string;
|
|
43
|
+
cndlValueRaw: string;
|
|
44
|
+
};
|
|
45
|
+
pendingWithdrawalRaw: string;
|
|
46
|
+
withdrawals: {
|
|
47
|
+
active: StakingWithdrawal[];
|
|
48
|
+
finished: StakingWithdrawal[];
|
|
49
|
+
};
|
|
50
|
+
unclaimedRewards: Array<{
|
|
51
|
+
rewardId: string;
|
|
52
|
+
mint: string;
|
|
53
|
+
symbol: string | null;
|
|
54
|
+
name: string | null;
|
|
55
|
+
amountRaw: string;
|
|
56
|
+
distributedAt: number | null;
|
|
57
|
+
claiming: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export interface StakingPositions {
|
|
61
|
+
success: true;
|
|
62
|
+
pool: {
|
|
63
|
+
withdrawalTimelockSeconds: number;
|
|
64
|
+
paused: boolean;
|
|
65
|
+
maxActiveWithdrawals: number;
|
|
66
|
+
} | null;
|
|
67
|
+
wallets: StakingWalletPosition[];
|
|
68
|
+
notes: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface StakingFigures {
|
|
71
|
+
networkFeeLamports: string;
|
|
72
|
+
priorityFeeLamports: string;
|
|
73
|
+
rentLamports: string;
|
|
74
|
+
reserveLamports: string;
|
|
75
|
+
requiredLamports: string;
|
|
76
|
+
balanceLamports: string;
|
|
77
|
+
creates: string[];
|
|
78
|
+
}
|
|
79
|
+
interface StakingOperation {
|
|
80
|
+
success: true;
|
|
81
|
+
action: "stake" | "unstake" | "finish";
|
|
82
|
+
payer: "main" | "linked";
|
|
83
|
+
linkedWalletId?: string;
|
|
84
|
+
wallet: string;
|
|
85
|
+
clientStakeId: string;
|
|
86
|
+
amountRaw?: string;
|
|
87
|
+
withdrawal?: string;
|
|
88
|
+
figures?: StakingFigures;
|
|
89
|
+
}
|
|
90
|
+
export type StakingResult = StakingOperation & ({
|
|
91
|
+
dryRun: true;
|
|
92
|
+
} | {
|
|
93
|
+
dryRun: false;
|
|
94
|
+
replay: boolean;
|
|
95
|
+
status: "built";
|
|
96
|
+
transaction: string;
|
|
97
|
+
recentBlockhash: string;
|
|
98
|
+
builtAt: number;
|
|
99
|
+
lastValidBlockHeight: number;
|
|
100
|
+
warnings: string[];
|
|
101
|
+
} | {
|
|
102
|
+
dryRun: false;
|
|
103
|
+
replay: boolean;
|
|
104
|
+
status: "confirmed";
|
|
105
|
+
signature: string;
|
|
106
|
+
builtAt: number;
|
|
107
|
+
lastValidBlockHeight: number;
|
|
108
|
+
warnings: string[];
|
|
109
|
+
});
|
|
110
|
+
export interface StakingRewardClaim {
|
|
111
|
+
success: true;
|
|
112
|
+
rewardId: string;
|
|
113
|
+
owner: string;
|
|
114
|
+
mint: string;
|
|
115
|
+
amountRaw: string;
|
|
116
|
+
signature: string;
|
|
117
|
+
}
|
|
118
|
+
export interface CandleStaking {
|
|
119
|
+
positions(): Promise<StakingPositions>;
|
|
120
|
+
/** MOVES REAL FUNDS for the embedded payer; linked/TEE payers return a build to sign. Reuse the id on retry. */
|
|
121
|
+
stake(request: StakeRequest): Promise<StakingResult>;
|
|
122
|
+
/** Start the pool's wait. No instant unstake. Input is raw sCNDL, not CNDL value. */
|
|
123
|
+
unstake(request: StakeRequest): Promise<StakingResult>;
|
|
124
|
+
finish(request: FinishUnstakeRequest): Promise<StakingResult>;
|
|
125
|
+
claimReward(rewardId: string): Promise<StakingRewardClaim>;
|
|
126
|
+
submit(request: {
|
|
127
|
+
clientStakeId: string;
|
|
128
|
+
signedTransaction: string;
|
|
129
|
+
}): Promise<StakingResult>;
|
|
130
|
+
confirm(request: {
|
|
131
|
+
clientStakeId: string;
|
|
132
|
+
signature: string;
|
|
133
|
+
}): Promise<StakingResult>;
|
|
134
|
+
}
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=staking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,MAAM,MAAM,YAAY,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAA;AACnH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAA;AACxG,MAAM,MAAM,oBAAoB,GAAG,Y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