@mortiseagentvault/sdk 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 +58 -4
- package/dist/THIRD_PARTY_NOTICES.txt +79 -0
- package/dist/abis.d.ts +3438 -0
- package/dist/actions.d.ts +255 -0
- package/dist/addresses.d.ts +21 -0
- package/dist/calls.d.ts +18 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4662 -10
- package/dist/modules.d.ts +14 -1
- package/dist/x402.d.ts +68 -0
- package/package.json +24 -7
- package/dist/abis.js +0 -28
- package/dist/actions.js +0 -159
- package/dist/addresses.js +0 -47
- package/dist/agent.js +0 -115
- package/dist/calls.js +0 -96
- package/dist/errors.js +0 -52
- package/dist/modules.js +0 -15
- package/dist/root.js +0 -104
- package/dist/userop.js +0 -425
- package/dist/vault.js +0 -117
package/README.md
CHANGED
|
@@ -16,7 +16,18 @@ The addresses of the deployed contracts are built in; see [`deployments/4663.jso
|
|
|
16
16
|
npm install @mortiseagentvault/sdk viem
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Requires Node.js 20 or later.
|
|
19
|
+
Requires Node.js 20 or later. The package is a single bundled module with no runtime dependencies: it
|
|
20
|
+
carries the parts of viem it uses, and its types expect the viem clients you create yourself. The
|
|
21
|
+
licenses of the bundled code are in `dist/THIRD_PARTY_NOTICES.txt`.
|
|
22
|
+
|
|
23
|
+
viem itself pins `ws` 8.21.0, which `npm audit` reports
|
|
24
|
+
([GHSA-37g9-w4hg-h9qr](https://github.com/advisories/GHSA-37g9-w4hg-h9qr)); `ws` is only loaded by viem's
|
|
25
|
+
WebSocket transport. The SDK's bundle contains no `ws` code; your project loads `ws` only if you create a
|
|
26
|
+
viem WebSocket client yourself. To move your project to the patched release, add this to its `package.json`:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
"overrides": { "ws": "^8.23.1" }
|
|
30
|
+
```
|
|
20
31
|
|
|
21
32
|
## Owner: create a vault and add an agent
|
|
22
33
|
|
|
@@ -81,9 +92,49 @@ const receipt = await executeActions(client, agentWallet, vault, wrap);
|
|
|
81
92
|
const p = await permissions(client, vault, agent.address, { adapters: [mortise.weth], tokens: [ETH] });
|
|
82
93
|
```
|
|
83
94
|
|
|
84
|
-
`actions.*` encodes the input of each adapter
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
`actions.*` encodes the input of each adapter, in exactly the layout its `plan()` decodes, and `markets.*`
|
|
96
|
+
gives the market id the owner allows for it:
|
|
97
|
+
|
|
98
|
+
| Kind | Adapters |
|
|
99
|
+
|---|---|
|
|
100
|
+
| Swaps | Uniswap v2, v3 and v4, PancakeSwap v3 and Infinity, Aero Slipstream, 1inch, Sushi, Pons, Flap |
|
|
101
|
+
| Liquidity | Uniswap v3 and v4 positions, Aero CL positions, Beefy CLM and vaults |
|
|
102
|
+
| Lending and yield | Morpho Blue (supply, and borrowing under a listed loan-to-value ceiling), Aave v3, Lista Lending, ERC-4626, Pendle PT, the Priors credit pool |
|
|
103
|
+
| Bridges | Across, LayerZero (USDG OFT), Chainlink CCIP |
|
|
104
|
+
| Payments and identity | x402 through `MortiseX402Escrow`, the vault's ERC-8004 identity |
|
|
105
|
+
| Venues and moves | Lighter perps margin, WETH, listed transfers, family transfers |
|
|
106
|
+
|
|
107
|
+
1inch and Sushi take the router calldata from their own swap APIs: the adapters check it (output to the
|
|
108
|
+
vault, the exact amount, a floor on the pair) before the vault signs anything.
|
|
109
|
+
|
|
110
|
+
## x402 payments
|
|
111
|
+
|
|
112
|
+
The vault pays x402 resources through `MortiseX402Escrow`, which stands as the EIP-3009 payer and approves
|
|
113
|
+
exactly one payment per funding (ERC-1271). The owner lists each payee; the agent then pays it:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
import { gate, markets, mortise, payX402 } from "@mortiseagentvault/sdk";
|
|
117
|
+
|
|
118
|
+
// Owner, once per seller: gate.setMarket(mortise.x402, markets.x402Payee(PAYEE), true)
|
|
119
|
+
const paid = await payX402(client, agentWallet, vault, "https://seller.example/resource", { maxValue: 100_000n });
|
|
120
|
+
console.log(paid.status, paid.collected, paid.settlement);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`payX402` reads the 402 answer (v2 header or v1 body), funds one payment in USDG, and asks again with it.
|
|
124
|
+
The seller's facilitator must accept a contract payer, as the official `@x402/evm` facilitator does. A
|
|
125
|
+
payment the seller never collects goes back to the vault after its deadline with `x402Escrow.reclaim(nonce)`,
|
|
126
|
+
which anyone may send. A failure after the payment's terms are fixed throws an `X402PaymentError` whose
|
|
127
|
+
`terms.nonce` is the one to reclaim, so a funded payment is never lost track of.
|
|
128
|
+
|
|
129
|
+
## Circuit breaker and auto-compound
|
|
130
|
+
|
|
131
|
+
`pauseGuard.*` makes `MortisePauseGuard` the vault's pauser (`gate.setPauser(mortise.pauseGuard)`), names
|
|
132
|
+
watchers that may pause at any time, and sets Chainlink price bounds that let anyone pause once a fresh price
|
|
133
|
+
leaves them. Unpausing stays with the root.
|
|
134
|
+
|
|
135
|
+
`moduleState.compound` builds the state of `CompoundModule`, which puts a position's fees back into it in two
|
|
136
|
+
triggers: collect, then deposit what the balances rose by. The deposit is an `increase` action with zero
|
|
137
|
+
amounts; `compoundWords.increase` names the words the module fills.
|
|
87
138
|
|
|
88
139
|
## Errors
|
|
89
140
|
|
|
@@ -98,8 +149,11 @@ refused to install.
|
|
|
98
149
|
The tests run against the live Mortise contracts on a local fork of Robinhood Chain mainnet. Nothing is
|
|
99
150
|
mocked. They need Node.js 22.6 or later and [Foundry](https://book.getfoundry.sh)'s `anvil` on the `PATH`.
|
|
100
151
|
|
|
152
|
+
The tests import the built package, so build it first:
|
|
153
|
+
|
|
101
154
|
```sh
|
|
102
155
|
npm install
|
|
156
|
+
npm run build
|
|
103
157
|
npm test # forks the public RPC
|
|
104
158
|
FORK_RPC=<url> npm test # or a private RPC
|
|
105
159
|
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
This package bundles the following third-party code. Their licenses follow.
|
|
2
|
+
|
|
3
|
+
------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
@noble/hashes@1.8.0 (MIT)
|
|
6
|
+
|
|
7
|
+
The MIT License (MIT)
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2022 Paul Miller (https://paulmillr.com)
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the “Software”), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in
|
|
19
|
+
all copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
27
|
+
THE SOFTWARE.
|
|
28
|
+
|
|
29
|
+
------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
abitype@1.2.3 (MIT)
|
|
32
|
+
|
|
33
|
+
MIT License
|
|
34
|
+
|
|
35
|
+
Copyright (c) 2022-present weth, LLC
|
|
36
|
+
|
|
37
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
38
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
39
|
+
in the Software without restriction, including without limitation the rights
|
|
40
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
41
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
42
|
+
furnished to do so, subject to the following conditions:
|
|
43
|
+
|
|
44
|
+
The above copyright notice and this permission notice shall be included in all
|
|
45
|
+
copies or substantial portions of the Software.
|
|
46
|
+
|
|
47
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
48
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
49
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
50
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
51
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
52
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
53
|
+
SOFTWARE.
|
|
54
|
+
|
|
55
|
+
------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
viem@2.58.8 (MIT)
|
|
58
|
+
|
|
59
|
+
MIT License
|
|
60
|
+
|
|
61
|
+
Copyright (c) 2023-present weth, LLC
|
|
62
|
+
|
|
63
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
64
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
65
|
+
in the Software without restriction, including without limitation the rights
|
|
66
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
67
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
68
|
+
furnished to do so, subject to the following conditions:
|
|
69
|
+
|
|
70
|
+
The above copyright notice and this permission notice shall be included in all
|
|
71
|
+
copies or substantial portions of the Software.
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
75
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
76
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
77
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
78
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
79
|
+
SOFTWARE.
|