@waiaas/actions 2.6.0-rc.9 → 2.6.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 +51 -3
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/jito-staking/config.d.ts +41 -0
- package/dist/providers/jito-staking/config.d.ts.map +1 -0
- package/dist/providers/jito-staking/config.js +50 -0
- package/dist/providers/jito-staking/config.js.map +1 -0
- package/dist/providers/jito-staking/epoch-tracker.d.ts +22 -0
- package/dist/providers/jito-staking/epoch-tracker.d.ts.map +1 -0
- package/dist/providers/jito-staking/epoch-tracker.js +48 -0
- package/dist/providers/jito-staking/epoch-tracker.js.map +1 -0
- package/dist/providers/jito-staking/index.d.ts +12 -0
- package/dist/providers/jito-staking/index.d.ts.map +1 -0
- package/dist/providers/jito-staking/index.js +89 -0
- package/dist/providers/jito-staking/index.js.map +1 -0
- package/dist/providers/jito-staking/jito-stake-pool.d.ts +100 -0
- package/dist/providers/jito-staking/jito-stake-pool.d.ts.map +1 -0
- package/dist/providers/jito-staking/jito-stake-pool.js +355 -0
- package/dist/providers/jito-staking/jito-stake-pool.js.map +1 -0
- package/dist/providers/lido-staking/config.d.ts +29 -0
- package/dist/providers/lido-staking/config.d.ts.map +1 -0
- package/dist/providers/lido-staking/config.js +40 -0
- package/dist/providers/lido-staking/config.js.map +1 -0
- package/dist/providers/lido-staking/index.d.ts +12 -0
- package/dist/providers/lido-staking/index.d.ts.map +1 -0
- package/dist/providers/lido-staking/index.js +129 -0
- package/dist/providers/lido-staking/index.js.map +1 -0
- package/dist/providers/lido-staking/lido-contract.d.ts +43 -0
- package/dist/providers/lido-staking/lido-contract.d.ts.map +1 -0
- package/dist/providers/lido-staking/lido-contract.js +83 -0
- package/dist/providers/lido-staking/lido-contract.js.map +1 -0
- package/dist/providers/lido-staking/withdrawal-tracker.d.ts +21 -0
- package/dist/providers/lido-staking/withdrawal-tracker.d.ts.map +1 -0
- package/dist/providers/lido-staking/withdrawal-tracker.js +46 -0
- package/dist/providers/lido-staking/withdrawal-tracker.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lido contract ABI encoding helpers.
|
|
3
|
+
*
|
|
4
|
+
* Manual ABI encoding (no viem dependency) for:
|
|
5
|
+
* - stETH submit(address _referral)
|
|
6
|
+
* - WithdrawalQueue requestWithdrawals(uint256[] _amounts, address _owner)
|
|
7
|
+
* - ERC-20 approve(address spender, uint256 amount)
|
|
8
|
+
*
|
|
9
|
+
* Function selectors are hardcoded hex constants derived from keccak256 of function signatures.
|
|
10
|
+
*/
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// Utility: pad a hex value to 32 bytes (64 hex chars)
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
function padHex(value, length = 64) {
|
|
15
|
+
return value.padStart(length, '0');
|
|
16
|
+
}
|
|
17
|
+
function addressToHex(address) {
|
|
18
|
+
return padHex(address.slice(2).toLowerCase());
|
|
19
|
+
}
|
|
20
|
+
function uint256ToHex(value) {
|
|
21
|
+
if (value < 0n)
|
|
22
|
+
throw new Error('uint256 cannot be negative');
|
|
23
|
+
return padHex(value.toString(16));
|
|
24
|
+
}
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
// submit(address _referral) -- function selector 0xa1903eab
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
/**
|
|
29
|
+
* Encode Lido stETH submit(address _referral) calldata.
|
|
30
|
+
* ETH value is sent as transaction value, not encoded in calldata.
|
|
31
|
+
*
|
|
32
|
+
* @param referral - Referral address (defaults to zero address)
|
|
33
|
+
* @returns ABI-encoded calldata with 0x prefix
|
|
34
|
+
*/
|
|
35
|
+
export function encodeSubmitCalldata(referral = '0x0000000000000000000000000000000000000000') {
|
|
36
|
+
const selector = '0xa1903eab';
|
|
37
|
+
const paddedReferral = addressToHex(referral);
|
|
38
|
+
return `${selector}${paddedReferral}`;
|
|
39
|
+
}
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
// requestWithdrawals(uint256[] _amounts, address _owner) -- 0xd669a4e2
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
/**
|
|
44
|
+
* Encode Lido WithdrawalQueue requestWithdrawals(uint256[], address) calldata.
|
|
45
|
+
*
|
|
46
|
+
* ABI layout:
|
|
47
|
+
* selector (4 bytes)
|
|
48
|
+
* offset to amounts array (32 bytes) = 0x40 (64 decimal)
|
|
49
|
+
* owner address (32 bytes)
|
|
50
|
+
* array length (32 bytes)
|
|
51
|
+
* array element 0 (32 bytes)
|
|
52
|
+
* ... array element N (32 bytes)
|
|
53
|
+
*
|
|
54
|
+
* @param amounts - Array of stETH withdrawal amounts in wei
|
|
55
|
+
* @param owner - Address to receive the withdrawal NFT
|
|
56
|
+
* @returns ABI-encoded calldata with 0x prefix
|
|
57
|
+
*/
|
|
58
|
+
export function encodeRequestWithdrawalsCalldata(amounts, owner) {
|
|
59
|
+
const selector = '0xd669a4e2';
|
|
60
|
+
// offset to dynamic array = 0x40 (2 * 32 bytes: offset slot + owner slot)
|
|
61
|
+
const offsetHex = uint256ToHex(64n);
|
|
62
|
+
const ownerHex = addressToHex(owner);
|
|
63
|
+
const lengthHex = uint256ToHex(BigInt(amounts.length));
|
|
64
|
+
const elementsHex = amounts.map((a) => uint256ToHex(a)).join('');
|
|
65
|
+
return `${selector}${offsetHex}${ownerHex}${lengthHex}${elementsHex}`;
|
|
66
|
+
}
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
// approve(address spender, uint256 amount) -- 0x095ea7b3
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
/**
|
|
71
|
+
* Encode ERC-20 approve(address spender, uint256 amount) calldata.
|
|
72
|
+
*
|
|
73
|
+
* @param spender - Spender address to approve
|
|
74
|
+
* @param amount - Amount to approve in wei
|
|
75
|
+
* @returns ABI-encoded calldata with 0x prefix
|
|
76
|
+
*/
|
|
77
|
+
export function encodeApproveCalldata(spender, amount) {
|
|
78
|
+
const selector = '0x095ea7b3';
|
|
79
|
+
const paddedSpender = addressToHex(spender);
|
|
80
|
+
const paddedAmount = uint256ToHex(amount);
|
|
81
|
+
return `${selector}${paddedSpender}${paddedAmount}`;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=lido-contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lido-contract.js","sourceRoot":"","sources":["../../../src/providers/lido-staking/lido-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,sDAAsD;AACtD,8EAA8E;AAE9E,SAAS,MAAM,CAAC,KAAa,EAAE,SAAiB,EAAE;IAChD,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,OAAe;IACnC,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,IAAI,KAAK,GAAG,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,CAAC;AAED,8EAA8E;AAC9E,4DAA4D;AAC5D,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,WAAmB,4CAA4C;IAE/D,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC9B,MAAM,cAAc,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9C,OAAO,GAAG,QAAQ,GAAG,cAAc,EAAE,CAAC;AACxC,CAAC;AAED,8EAA8E;AAC9E,uEAAuE;AACvE,8EAA8E;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gCAAgC,CAC9C,OAAiB,EACjB,KAAa;IAEb,MAAM,QAAQ,GAAG,YAAY,CAAC;IAE9B,0EAA0E;IAC1E,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEjE,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,EAAE,CAAC;AACxE,CAAC;AAED,8EAA8E;AAC9E,yDAAyD;AACzD,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAe,EAAE,MAAc;IACnE,MAAM,QAAQ,GAAG,YAAY,CAAC;IAC9B,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LidoWithdrawalTracker - IAsyncStatusTracker for Lido withdrawal queue.
|
|
3
|
+
*
|
|
4
|
+
* Tracks Lido unstake requests via metadata-based polling (v1 implementation).
|
|
5
|
+
* Active polling: 30s x 480 = 4 hours, then TIMEOUT (terminal).
|
|
6
|
+
*
|
|
7
|
+
* Lido withdrawals typically take 1-5 days. This tracker monitors metadata
|
|
8
|
+
* state (set by external claim detection or manual status update) and emits
|
|
9
|
+
* STAKING_UNSTAKE_COMPLETED or STAKING_UNSTAKE_TIMEOUT notifications.
|
|
10
|
+
*
|
|
11
|
+
* @see packages/actions/src/common/async-status-tracker.ts
|
|
12
|
+
*/
|
|
13
|
+
import type { IAsyncStatusTracker, AsyncTrackingResult } from '../../common/async-status-tracker.js';
|
|
14
|
+
export declare class LidoWithdrawalTracker implements IAsyncStatusTracker {
|
|
15
|
+
readonly name = "lido-withdrawal";
|
|
16
|
+
readonly maxAttempts = 480;
|
|
17
|
+
readonly pollIntervalMs = 30000;
|
|
18
|
+
readonly timeoutTransition: "TIMEOUT";
|
|
19
|
+
checkStatus(_txId: string, metadata: Record<string, unknown>): Promise<AsyncTrackingResult>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=withdrawal-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawal-tracker.d.ts","sourceRoot":"","sources":["../../../src/providers/lido-staking/withdrawal-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAKrG,qBAAa,qBAAsB,YAAW,mBAAmB;IAC/D,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,WAAW,OAAO;IAC3B,QAAQ,CAAC,cAAc,SAAU;IACjC,QAAQ,CAAC,iBAAiB,EAAG,SAAS,CAAU;IAE1C,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;CA2BlG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LidoWithdrawalTracker - IAsyncStatusTracker for Lido withdrawal queue.
|
|
3
|
+
*
|
|
4
|
+
* Tracks Lido unstake requests via metadata-based polling (v1 implementation).
|
|
5
|
+
* Active polling: 30s x 480 = 4 hours, then TIMEOUT (terminal).
|
|
6
|
+
*
|
|
7
|
+
* Lido withdrawals typically take 1-5 days. This tracker monitors metadata
|
|
8
|
+
* state (set by external claim detection or manual status update) and emits
|
|
9
|
+
* STAKING_UNSTAKE_COMPLETED or STAKING_UNSTAKE_TIMEOUT notifications.
|
|
10
|
+
*
|
|
11
|
+
* @see packages/actions/src/common/async-status-tracker.ts
|
|
12
|
+
*/
|
|
13
|
+
/** Days after which a Lido withdrawal is considered overdue for timeout hint. */
|
|
14
|
+
const LIDO_EXPECTED_DAYS = 5;
|
|
15
|
+
export class LidoWithdrawalTracker {
|
|
16
|
+
name = 'lido-withdrawal';
|
|
17
|
+
maxAttempts = 480; // 480 x 30s = 4 hours active polling
|
|
18
|
+
pollIntervalMs = 30_000; // 30 seconds
|
|
19
|
+
timeoutTransition = 'TIMEOUT';
|
|
20
|
+
async checkStatus(_txId, metadata) {
|
|
21
|
+
// If metadata.status is already 'claimable', withdrawal is complete
|
|
22
|
+
if (metadata.status === 'claimable') {
|
|
23
|
+
return {
|
|
24
|
+
state: 'COMPLETED',
|
|
25
|
+
details: {
|
|
26
|
+
completedAt: Date.now(),
|
|
27
|
+
protocol: 'lido',
|
|
28
|
+
notificationEvent: 'STAKING_UNSTAKE_COMPLETED',
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
// Calculate estimated days remaining based on withdrawal request time
|
|
33
|
+
const requestedAt = metadata.withdrawalRequestedAt;
|
|
34
|
+
const estimatedDaysRemaining = requestedAt
|
|
35
|
+
? Math.max(0, LIDO_EXPECTED_DAYS - (Date.now() - requestedAt) / (1000 * 60 * 60 * 24))
|
|
36
|
+
: LIDO_EXPECTED_DAYS;
|
|
37
|
+
return {
|
|
38
|
+
state: 'PENDING',
|
|
39
|
+
details: {
|
|
40
|
+
estimatedDaysRemaining: Math.round(estimatedDaysRemaining * 10) / 10,
|
|
41
|
+
protocol: 'lido',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=withdrawal-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"withdrawal-tracker.js","sourceRoot":"","sources":["../../../src/providers/lido-staking/withdrawal-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,iFAAiF;AACjF,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B,MAAM,OAAO,qBAAqB;IACvB,IAAI,GAAG,iBAAiB,CAAC;IACzB,WAAW,GAAG,GAAG,CAAC,CAAU,qCAAqC;IACjE,cAAc,GAAG,MAAM,CAAC,CAAI,aAAa;IACzC,iBAAiB,GAAG,SAAkB,CAAC;IAEhD,KAAK,CAAC,WAAW,CAAC,KAAa,EAAE,QAAiC;QAChE,oEAAoE;QACpE,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;YACpC,OAAO;gBACL,KAAK,EAAE,WAAW;gBAClB,OAAO,EAAE;oBACP,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;oBACvB,QAAQ,EAAE,MAAM;oBAChB,iBAAiB,EAAE,2BAA2B;iBAC/C;aACF,CAAC;QACJ,CAAC;QAED,sEAAsE;QACtE,MAAM,WAAW,GAAG,QAAQ,CAAC,qBAA2C,CAAC;QACzE,MAAM,sBAAsB,GAAG,WAAW;YACxC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,kBAAkB,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;YACtF,CAAC,CAAC,kBAAkB,CAAC;QAEvB,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE;gBACP,sBAAsB,EAAE,IAAI,CAAC,KAAK,CAAC,sBAAsB,GAAG,EAAE,CAAC,GAAG,EAAE;gBACpE,QAAQ,EAAE,MAAM;aACjB;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waiaas/actions",
|
|
3
|
-
"version": "2.6.0
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "WAIaaS built-in DeFi Action Provider implementations",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"zod": "^3.24.0",
|
|
32
|
-
"@waiaas/core": "2.6.0
|
|
32
|
+
"@waiaas/core": "2.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^25.2.3",
|