@lit-protocol/vincent-ability-morpho 0.0.7-mma

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.
Files changed (33) hide show
  1. package/CONTRIBUTING.md +90 -0
  2. package/README.md +136 -0
  3. package/dist/CONTRIBUTING.md +90 -0
  4. package/dist/README.md +136 -0
  5. package/dist/package.json +34 -0
  6. package/dist/src/generated/lit-action.js +9 -0
  7. package/dist/src/generated/vincent-ability-metadata.json +3 -0
  8. package/dist/src/generated/vincent-bundled-ability.d.ts +98 -0
  9. package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
  10. package/dist/src/generated/vincent-bundled-ability.js +15 -0
  11. package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
  12. package/dist/src/generated/vincent-bundled-ability.ts +13 -0
  13. package/dist/src/index.d.ts +3 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/index.js +8 -0
  16. package/dist/src/index.js.map +1 -0
  17. package/dist/src/lib/helpers/index.d.ts +561 -0
  18. package/dist/src/lib/helpers/index.d.ts.map +1 -0
  19. package/dist/src/lib/helpers/index.js +1123 -0
  20. package/dist/src/lib/helpers/index.js.map +1 -0
  21. package/dist/src/lib/lit-action.d.ts +2 -0
  22. package/dist/src/lib/lit-action.d.ts.map +1 -0
  23. package/dist/src/lib/lit-action.js +16 -0
  24. package/dist/src/lib/lit-action.js.map +1 -0
  25. package/dist/src/lib/schemas.d.ts +125 -0
  26. package/dist/src/lib/schemas.d.ts.map +1 -0
  27. package/dist/src/lib/schemas.js +109 -0
  28. package/dist/src/lib/schemas.js.map +1 -0
  29. package/dist/src/lib/vincent-ability.d.ts +96 -0
  30. package/dist/src/lib/vincent-ability.d.ts.map +1 -0
  31. package/dist/src/lib/vincent-ability.js +378 -0
  32. package/dist/src/lib/vincent-ability.js.map +1 -0
  33. package/package.json +33 -0
@@ -0,0 +1,90 @@
1
+ # Contributing to Vincent Ability Morpho
2
+
3
+ This document provides guidelines for contributing to the Vincent Ability Morpho project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Ability Morpho is a ability to send deposit, withdraw or redeem Morpho vault transactions and supply or withdrawCollateral Morpho market transactions from a Vincent app on behalf of the delegator. It's part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK.
8
+
9
+ ## Setup
10
+
11
+ 1. Follow the global setup instructions in the repository root [CONTRIBUTING.md](../../../CONTRIBUTING.md).
12
+ 2. Install dependencies:
13
+ ```bash
14
+ pnpm install
15
+ ```
16
+
17
+ ## Development Workflow
18
+
19
+ ### Testing
20
+
21
+ Run tests:
22
+
23
+ ```bash
24
+ nx test ability-morpho
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the ability:
30
+
31
+ ```bash
32
+ nx action:build ability-morpho
33
+ ```
34
+
35
+ ### Deploying the Lit Action to IPFS
36
+
37
+ Building will be done automatically. Deploy the ability:
38
+
39
+ ```bash
40
+ nx action:deploy ability-erc20-approval
41
+ ```
42
+
43
+ ## Project Structure
44
+
45
+ - `src/`: Source code
46
+ - `index.ts`: Main entry point
47
+
48
+ ## Ability Development Guidelines
49
+
50
+ 1. Use the Vincent Ability SDK to create abilitys
51
+ 2. Define clear schemas for ability parameters
52
+ 3. Implement the ability lifecycle methods (precheck, execute)
53
+ 4. Handle errors gracefully
54
+ 5. Write comprehensive tests for all functionality
55
+ 6. Document the ability's purpose and usage
56
+
57
+ ## Integration with Policies
58
+
59
+ This ability can be integrated with various Vincent Policies to enforce constraints. When developing or modifying the ability, consider how it will be used with policies such as:
60
+
61
+ - Vincent Policy Spending Limit
62
+
63
+ ## Testing
64
+
65
+ Write unit tests for all functionality:
66
+
67
+ ```bash
68
+ pnpm test
69
+ ```
70
+
71
+ ## Documentation
72
+
73
+ - Document the ability's purpose and usage
74
+ - Update README.md when adding new features
75
+ - Document the ability's parameters and behavior
76
+
77
+ ## Pull Request Process
78
+
79
+ 1. Ensure your code follows the coding standards
80
+ 2. Update documentation if necessary
81
+ 3. Include tests for new functionality
82
+ 4. Link any related issues in your pull request description
83
+ 5. Request a review from a maintainer
84
+
85
+ ## Additional Resources
86
+
87
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
88
+ - [Vincent Ability SDK Documentation](../../libs/ability-sdk/README.md)
89
+ - [ERC20 Standard](https://eips.ethereum.org/EIPS/eip-20)
90
+ - [ERC4626 Standard](https://eips.ethereum.org/EIPS/eip-4626)
package/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # Vincent Ability Morpho
2
+
3
+ An ability to interact with Morpho vaults (deposit, withdraw, redeem) or markets (supply,
4
+ withdrawCollateral) from a Vincent app on behalf of the delegator.
5
+
6
+ ## Overview
7
+
8
+ The Vincent Ability Morpho is part of the Vincent Abilities ecosystem and is built using the Vincent
9
+ Ability SDK. It allows
10
+ Vincent apps to interact with Morpho vaults on behalf of users, enabling seamless integration with
11
+ DeFi yield
12
+ strategies.
13
+
14
+ ## Features
15
+
16
+ - Deposit assets into Morpho vaults
17
+ - Withdraw assets from Morpho vaults
18
+ - Redeem vault shares for underlying assets
19
+ - Support for multiple chains including Ethereum, Base, and Arbitrum
20
+ - Integration with spending limit policies for enhanced security
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @lit-protocol/vincent-ability-morpho
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ This ability can be used in Vincent apps to interact with Morpho vaults:
31
+
32
+ ```typescript
33
+ import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
34
+ import { bundledVincentAbility, MorphoOperation } from '@lit-protocol/vincent-ability-morpho';
35
+
36
+ // One of delegatee signers from your app's Vincent Dashboard
37
+ const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
38
+
39
+ // Initialize the Vincent Ability Client
40
+ const abilityClient = getVincentAbilityClient({
41
+ ethersSigner: delegateeSigner,
42
+ bundledVincentAbility,
43
+ });
44
+ const delegatorPkpEthAddress = '0x09182301238'; // The delegator PKP Eth Address
45
+
46
+ const abilityParams = {
47
+ operation: MorphoOperation.VAULT_DEPOSIT, // The morpho operation, can apply to vault or market
48
+ marketId: '0x1234...', // The market id. Mandatory for market operations
49
+ vaultAddress: '0x1234...', // The Morpho vault or market contract address
50
+ amount: '1.0', // Amount to deposit/withdraw/redeem in the vault or supply/withdrawCollateral in the market
51
+ chain: 'base', // The chain where the contract is deployed
52
+ onBehalfOf: '0xabcd...', // Optional: address to receive vault shares (defaults to delegator)
53
+ };
54
+
55
+ // Run precheck to see if ability should be executed
56
+ const precheckResult = await client.precheck(abilityParams, {
57
+ delegatorPkpEthAddress,
58
+ });
59
+
60
+ if (precheckResult.success === true) {
61
+ // Execute the Vincent Ability
62
+ const executeResult = await client.execute(abilityParams, {
63
+ delegatorPkpEthAddress,
64
+ });
65
+
66
+ // ...ability has executed, you can check `executeResult` for details
67
+ }
68
+ ```
69
+
70
+ ## Prerequisites
71
+
72
+ Before executing vault operations, ensure that:
73
+
74
+ 1. The user has approved the vault to spend their tokens (for deposits)
75
+ 2. The user has sufficient balance of the required tokens
76
+ 3. The user has delegated permission to the Vincent app to execute operations
77
+
78
+ You can use the Vincent Ability ERC20 Approval to handle token approvals
79
+
80
+ ## Vault Operations
81
+
82
+ The ability supports the following operations on Morpho vaults:
83
+
84
+ - **DEPOSIT** - Deposit assets into a Morpho vault to earn yield
85
+ - **WITHDRAW** - Withdraw assets from a Morpho vault
86
+ - **REDEEM** - Redeem vault shares for underlying assets
87
+
88
+ And the following operations on Morpho markets:
89
+
90
+ - **SUPPLY** - Supply collateral to a Morpho market to earn yield
91
+ - **WITHDRAW_COLLATERAL** - Withdraw collateral from a Morpho market
92
+
93
+ ## Parameters
94
+
95
+ | Parameter | Type | Required | Description |
96
+ | -------------- | --------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------ |
97
+ | `operation` | `"vault_deposit" \| "vault_withdraw" \| "vault_redeem" \| "market_supply" \| "market_withdrawCollateral"` | ✅ | The vault or market operation to perform. Can use `MorphoOperation` enum |
98
+ | `marketId` | `string` | ❌ | The market id. Mandatory for market operations |
99
+ | `vaultAddress` | `string` | ✅ | Morpho vault contract address (0x format) |
100
+ | `amount` | `string` | ✅ | Amount as string (assets for deposit, shares for redeem) |
101
+ | `chain` | `string` | ✅ | Chain identifier (e.g., "base") |
102
+ | `onBehalfOf` | `string` | ❌ | Address to receive tokens (defaults to sender) |
103
+ | `rpcUrl` | `string` | ❌ | Custom RPC URL (for precheck validation) |
104
+
105
+ ## Supported Networks
106
+
107
+ The ability supports all chains where Morpho is deployed, including:
108
+
109
+ - Ethereum Mainnet
110
+ - Base
111
+ - Arbitrum
112
+ - Optimism
113
+ - Polygon
114
+
115
+ ## Building
116
+
117
+ Run `nx build ability-morpho` to build the library.
118
+
119
+ ## Testing
120
+
121
+ Run `nx test ability-morpho` to execute the unit tests via [Jest](https://jestjs.io).
122
+
123
+ For end-to-end testing with the Vincent SDK:
124
+
125
+ ```bash
126
+ nx e2e ability-morpho-e2e
127
+ ```
128
+
129
+ ## Contributing
130
+
131
+ Please see [CONTRIBUTING.md](../../../CONTRIBUTING.md) for guidelines on how to contribute to this
132
+ project.
133
+
134
+ ## License
135
+
136
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,90 @@
1
+ # Contributing to Vincent Ability Morpho
2
+
3
+ This document provides guidelines for contributing to the Vincent Ability Morpho project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Ability Morpho is a ability to send deposit, withdraw or redeem Morpho vault transactions and supply or withdrawCollateral Morpho market transactions from a Vincent app on behalf of the delegator. It's part of the Vincent Abilities ecosystem and is built using the Vincent Ability SDK.
8
+
9
+ ## Setup
10
+
11
+ 1. Follow the global setup instructions in the repository root [CONTRIBUTING.md](../../../CONTRIBUTING.md).
12
+ 2. Install dependencies:
13
+ ```bash
14
+ pnpm install
15
+ ```
16
+
17
+ ## Development Workflow
18
+
19
+ ### Testing
20
+
21
+ Run tests:
22
+
23
+ ```bash
24
+ nx test ability-morpho
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the ability:
30
+
31
+ ```bash
32
+ nx action:build ability-morpho
33
+ ```
34
+
35
+ ### Deploying the Lit Action to IPFS
36
+
37
+ Building will be done automatically. Deploy the ability:
38
+
39
+ ```bash
40
+ nx action:deploy ability-erc20-approval
41
+ ```
42
+
43
+ ## Project Structure
44
+
45
+ - `src/`: Source code
46
+ - `index.ts`: Main entry point
47
+
48
+ ## Ability Development Guidelines
49
+
50
+ 1. Use the Vincent Ability SDK to create abilitys
51
+ 2. Define clear schemas for ability parameters
52
+ 3. Implement the ability lifecycle methods (precheck, execute)
53
+ 4. Handle errors gracefully
54
+ 5. Write comprehensive tests for all functionality
55
+ 6. Document the ability's purpose and usage
56
+
57
+ ## Integration with Policies
58
+
59
+ This ability can be integrated with various Vincent Policies to enforce constraints. When developing or modifying the ability, consider how it will be used with policies such as:
60
+
61
+ - Vincent Policy Spending Limit
62
+
63
+ ## Testing
64
+
65
+ Write unit tests for all functionality:
66
+
67
+ ```bash
68
+ pnpm test
69
+ ```
70
+
71
+ ## Documentation
72
+
73
+ - Document the ability's purpose and usage
74
+ - Update README.md when adding new features
75
+ - Document the ability's parameters and behavior
76
+
77
+ ## Pull Request Process
78
+
79
+ 1. Ensure your code follows the coding standards
80
+ 2. Update documentation if necessary
81
+ 3. Include tests for new functionality
82
+ 4. Link any related issues in your pull request description
83
+ 5. Request a review from a maintainer
84
+
85
+ ## Additional Resources
86
+
87
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
88
+ - [Vincent Ability SDK Documentation](../../libs/ability-sdk/README.md)
89
+ - [ERC20 Standard](https://eips.ethereum.org/EIPS/eip-20)
90
+ - [ERC4626 Standard](https://eips.ethereum.org/EIPS/eip-4626)
package/dist/README.md ADDED
@@ -0,0 +1,136 @@
1
+ # Vincent Ability Morpho
2
+
3
+ An ability to interact with Morpho vaults (deposit, withdraw, redeem) or markets (supply,
4
+ withdrawCollateral) from a Vincent app on behalf of the delegator.
5
+
6
+ ## Overview
7
+
8
+ The Vincent Ability Morpho is part of the Vincent Abilities ecosystem and is built using the Vincent
9
+ Ability SDK. It allows
10
+ Vincent apps to interact with Morpho vaults on behalf of users, enabling seamless integration with
11
+ DeFi yield
12
+ strategies.
13
+
14
+ ## Features
15
+
16
+ - Deposit assets into Morpho vaults
17
+ - Withdraw assets from Morpho vaults
18
+ - Redeem vault shares for underlying assets
19
+ - Support for multiple chains including Ethereum, Base, and Arbitrum
20
+ - Integration with spending limit policies for enhanced security
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @lit-protocol/vincent-ability-morpho
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ This ability can be used in Vincent apps to interact with Morpho vaults:
31
+
32
+ ```typescript
33
+ import { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
34
+ import { bundledVincentAbility, MorphoOperation } from '@lit-protocol/vincent-ability-morpho';
35
+
36
+ // One of delegatee signers from your app's Vincent Dashboard
37
+ const delegateeSigner = new ethers.Wallet('YOUR_DELEGATEE_PRIVATE_KEY');
38
+
39
+ // Initialize the Vincent Ability Client
40
+ const abilityClient = getVincentAbilityClient({
41
+ ethersSigner: delegateeSigner,
42
+ bundledVincentAbility,
43
+ });
44
+ const delegatorPkpEthAddress = '0x09182301238'; // The delegator PKP Eth Address
45
+
46
+ const abilityParams = {
47
+ operation: MorphoOperation.VAULT_DEPOSIT, // The morpho operation, can apply to vault or market
48
+ marketId: '0x1234...', // The market id. Mandatory for market operations
49
+ vaultAddress: '0x1234...', // The Morpho vault or market contract address
50
+ amount: '1.0', // Amount to deposit/withdraw/redeem in the vault or supply/withdrawCollateral in the market
51
+ chain: 'base', // The chain where the contract is deployed
52
+ onBehalfOf: '0xabcd...', // Optional: address to receive vault shares (defaults to delegator)
53
+ };
54
+
55
+ // Run precheck to see if ability should be executed
56
+ const precheckResult = await client.precheck(abilityParams, {
57
+ delegatorPkpEthAddress,
58
+ });
59
+
60
+ if (precheckResult.success === true) {
61
+ // Execute the Vincent Ability
62
+ const executeResult = await client.execute(abilityParams, {
63
+ delegatorPkpEthAddress,
64
+ });
65
+
66
+ // ...ability has executed, you can check `executeResult` for details
67
+ }
68
+ ```
69
+
70
+ ## Prerequisites
71
+
72
+ Before executing vault operations, ensure that:
73
+
74
+ 1. The user has approved the vault to spend their tokens (for deposits)
75
+ 2. The user has sufficient balance of the required tokens
76
+ 3. The user has delegated permission to the Vincent app to execute operations
77
+
78
+ You can use the Vincent Ability ERC20 Approval to handle token approvals
79
+
80
+ ## Vault Operations
81
+
82
+ The ability supports the following operations on Morpho vaults:
83
+
84
+ - **DEPOSIT** - Deposit assets into a Morpho vault to earn yield
85
+ - **WITHDRAW** - Withdraw assets from a Morpho vault
86
+ - **REDEEM** - Redeem vault shares for underlying assets
87
+
88
+ And the following operations on Morpho markets:
89
+
90
+ - **SUPPLY** - Supply collateral to a Morpho market to earn yield
91
+ - **WITHDRAW_COLLATERAL** - Withdraw collateral from a Morpho market
92
+
93
+ ## Parameters
94
+
95
+ | Parameter | Type | Required | Description |
96
+ | -------------- | --------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------ |
97
+ | `operation` | `"vault_deposit" \| "vault_withdraw" \| "vault_redeem" \| "market_supply" \| "market_withdrawCollateral"` | ✅ | The vault or market operation to perform. Can use `MorphoOperation` enum |
98
+ | `marketId` | `string` | ❌ | The market id. Mandatory for market operations |
99
+ | `vaultAddress` | `string` | ✅ | Morpho vault contract address (0x format) |
100
+ | `amount` | `string` | ✅ | Amount as string (assets for deposit, shares for redeem) |
101
+ | `chain` | `string` | ✅ | Chain identifier (e.g., "base") |
102
+ | `onBehalfOf` | `string` | ❌ | Address to receive tokens (defaults to sender) |
103
+ | `rpcUrl` | `string` | ❌ | Custom RPC URL (for precheck validation) |
104
+
105
+ ## Supported Networks
106
+
107
+ The ability supports all chains where Morpho is deployed, including:
108
+
109
+ - Ethereum Mainnet
110
+ - Base
111
+ - Arbitrum
112
+ - Optimism
113
+ - Polygon
114
+
115
+ ## Building
116
+
117
+ Run `nx build ability-morpho` to build the library.
118
+
119
+ ## Testing
120
+
121
+ Run `nx test ability-morpho` to execute the unit tests via [Jest](https://jestjs.io).
122
+
123
+ For end-to-end testing with the Vincent SDK:
124
+
125
+ ```bash
126
+ nx e2e ability-morpho-e2e
127
+ ```
128
+
129
+ ## Contributing
130
+
131
+ Please see [CONTRIBUTING.md](../../../CONTRIBUTING.md) for guidelines on how to contribute to this
132
+ project.
133
+
134
+ ## License
135
+
136
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@lit-protocol/vincent-ability-morpho",
3
+ "version": "0.0.6",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "scripts": {
8
+ "vault-search": "tsx examples/vault-search.ts"
9
+ },
10
+ "dependencies": {
11
+ "@lit-protocol/vincent-scaffold-sdk": "^1.1.6",
12
+ "@lit-protocol/vincent-ability-sdk": "workspace:*",
13
+ "ethers": "^5.8.0",
14
+ "tslib": "2.8.1",
15
+ "zod": "^3.25.64"
16
+ },
17
+ "peerDependencies": {
18
+ "@lit-protocol/vincent-app-sdk": "workspace:^"
19
+ },
20
+ "devDependencies": {
21
+ "esbuild": "^0.19.12",
22
+ "esbuild-plugin-polyfill-node": "^0.3.0",
23
+ "ipfs-only-hash": "^4.0.0",
24
+ "tsx": "^4.19.4"
25
+ },
26
+ "main": "./dist/src/index.js",
27
+ "module": "./dist/src/index.js",
28
+ "types": "./dist/src/index.d.ts",
29
+ "files": [
30
+ "dist/**",
31
+ "*.md"
32
+ ],
33
+ "type": "commonjs"
34
+ }