@lit-protocol/vincent-policy-spending-limit 0.0.4-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 (67) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/CONTRIBUTING.md +89 -0
  3. package/README.md +64 -0
  4. package/dist/CHANGELOG.md +14 -0
  5. package/dist/CONTRIBUTING.md +89 -0
  6. package/dist/README.md +64 -0
  7. package/dist/package.json +30 -0
  8. package/dist/src/generated/lit-action.js +9 -0
  9. package/dist/src/generated/vincent-bundled-policy.d.ts +212 -0
  10. package/dist/src/generated/vincent-bundled-policy.d.ts.map +1 -0
  11. package/dist/src/generated/vincent-bundled-policy.js +15 -0
  12. package/dist/src/generated/vincent-bundled-policy.js.map +1 -0
  13. package/dist/src/generated/vincent-bundled-policy.ts +13 -0
  14. package/dist/src/generated/vincent-policy-metadata.json +3 -0
  15. package/dist/src/index.d.ts +4 -0
  16. package/dist/src/index.d.ts.map +1 -0
  17. package/dist/src/index.js +9 -0
  18. package/dist/src/index.js.map +1 -0
  19. package/dist/src/lib/lit-action.d.ts +2 -0
  20. package/dist/src/lib/lit-action.d.ts.map +1 -0
  21. package/dist/src/lib/lit-action.js +12 -0
  22. package/dist/src/lib/lit-action.js.map +1 -0
  23. package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts +7 -0
  24. package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts.map +1 -0
  25. package/dist/src/lib/policy-helpers/calculate-usd-value.js +22 -0
  26. package/dist/src/lib/policy-helpers/calculate-usd-value.js.map +1 -0
  27. package/dist/src/lib/policy-helpers/check-spending-limit.d.ts +16 -0
  28. package/dist/src/lib/policy-helpers/check-spending-limit.d.ts.map +1 -0
  29. package/dist/src/lib/policy-helpers/check-spending-limit.js +29 -0
  30. package/dist/src/lib/policy-helpers/check-spending-limit.js.map +1 -0
  31. package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts +6 -0
  32. package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts.map +1 -0
  33. package/dist/src/lib/policy-helpers/get-eth-usd-price.js +22 -0
  34. package/dist/src/lib/policy-helpers/get-eth-usd-price.js.map +1 -0
  35. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts +10 -0
  36. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts.map +1 -0
  37. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js +68 -0
  38. package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js.map +1 -0
  39. package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts +15 -0
  40. package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts.map +1 -0
  41. package/dist/src/lib/policy-helpers/get-uniswap-quote.js +114 -0
  42. package/dist/src/lib/policy-helpers/get-uniswap-quote.js.map +1 -0
  43. package/dist/src/lib/policy-helpers/index.d.ts +7 -0
  44. package/dist/src/lib/policy-helpers/index.d.ts.map +1 -0
  45. package/dist/src/lib/policy-helpers/index.js +10 -0
  46. package/dist/src/lib/policy-helpers/index.js.map +1 -0
  47. package/dist/src/lib/policy-helpers/send-spend-tx.d.ts +9 -0
  48. package/dist/src/lib/policy-helpers/send-spend-tx.d.ts.map +1 -0
  49. package/dist/src/lib/policy-helpers/send-spend-tx.js +144 -0
  50. package/dist/src/lib/policy-helpers/send-spend-tx.js.map +1 -0
  51. package/dist/src/lib/policy-helpers/sign-tx.d.ts +3 -0
  52. package/dist/src/lib/policy-helpers/sign-tx.d.ts.map +1 -0
  53. package/dist/src/lib/policy-helpers/sign-tx.js +28 -0
  54. package/dist/src/lib/policy-helpers/sign-tx.js.map +1 -0
  55. package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts +4 -0
  56. package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts.map +1 -0
  57. package/dist/src/lib/policy-helpers/spending-limit-contract.js +22 -0
  58. package/dist/src/lib/policy-helpers/spending-limit-contract.js.map +1 -0
  59. package/dist/src/lib/schemas.d.ts +101 -0
  60. package/dist/src/lib/schemas.d.ts.map +1 -0
  61. package/dist/src/lib/schemas.js +60 -0
  62. package/dist/src/lib/schemas.js.map +1 -0
  63. package/dist/src/lib/vincent-policy.d.ts +209 -0
  64. package/dist/src/lib/vincent-policy.d.ts.map +1 -0
  65. package/dist/src/lib/vincent-policy.js +117 -0
  66. package/dist/src/lib/vincent-policy.js.map +1 -0
  67. package/package.json +29 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## 1.0.2 (2025-07-08)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - - Fixed a case where a deny response from a policy could be returned without being parsed by its deny result schema ([27a35240](https://github.com/LIT-Protocol/Vincent/commit/27a35240))
6
+
7
+ ### 🧱 Updated Dependencies
8
+
9
+ - Updated tool-sdk to 1.0.2
10
+ - Updated app-sdk to 1.0.2
11
+
12
+ ### ❤️ Thank You
13
+
14
+ - Daryl Collins
@@ -0,0 +1,89 @@
1
+ # Contributing to Vincent Policy Spending Limit
2
+
3
+ This document provides guidelines for contributing to the Vincent Policy Spending Limit project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Spending Limit is a policy that can be attached to tools to avoid them spending more than a user-defined limit in a specific period of time. It's part of the Vincent Tools ecosystem and is built using the Vincent Tool 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 policy-spending-limit
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the policy:
30
+
31
+ ```bash
32
+ nx action:build policy-spending-limit
33
+ ```
34
+
35
+ ### Deploying the Lit Action to IPFS
36
+
37
+ Building will be done automatically. Deploy the policy:
38
+
39
+ ```bash
40
+ nx action:deploy policy-spending-limit
41
+ ```
42
+
43
+ ## Project Structure
44
+
45
+ - `src/`: Source code
46
+ - `index.ts`: Main entry point
47
+
48
+ ## Policy Development Guidelines
49
+
50
+ 1. Use the Vincent Tool SDK to create policies
51
+ 2. Define clear schemas for tool parameters and user parameters
52
+ 3. Implement the policy lifecycle methods (evaluate, commit)
53
+ 4. Handle errors gracefully
54
+ 5. Write comprehensive tests for all functionality
55
+ 6. Document the policy's purpose and usage
56
+
57
+ ## Integration with Tools
58
+
59
+ This policy can be integrated with various Vincent Tools to enforce spending limits. When developing or modifying the policy, consider how it will be used by tools such as:
60
+
61
+ - Vincent Tool ERC20 Approval
62
+ - Vincent Tool Uniswap Swap
63
+
64
+ ## Testing
65
+
66
+ Write unit tests for all functionality:
67
+
68
+ ```bash
69
+ pnpm test
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ - Document the policy's purpose and usage
75
+ - Update README.md when adding new features
76
+ - Document the policy's parameters and behavior
77
+
78
+ ## Pull Request Process
79
+
80
+ 1. Ensure your code follows the coding standards
81
+ 2. Update documentation if necessary
82
+ 3. Include tests for new functionality
83
+ 4. Link any related issues in your pull request description
84
+ 5. Request a review from a maintainer
85
+
86
+ ## Additional Resources
87
+
88
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
89
+ - [Vincent Tool SDK Documentation](../../libs/tool-sdk/README.md)
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Vincent Policy Spending Limit
2
+
3
+ A policy that can be attached to Vincent tools to avoid them spending more than a user-defined limit in a specific period of time.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Spending Limit is part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK. It allows users to set spending limits for tools that interact with their funds, providing an additional layer of security and control.
8
+
9
+ ## Features
10
+
11
+ - Set maximum spending limits per period
12
+ - Track spending across multiple tools
13
+ - Configurable by users through the Vincent Dashboard
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lit-protocol/vincent-policy-spending-limit
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This policy can be integrated with Vincent Tools to enforce spending limits:
24
+
25
+ ```typescript
26
+ import {
27
+ createVincentToolPolicy,
28
+ createVincentTool,
29
+ supportedPoliciesForTool,
30
+ } from '@lit-protocol/vincent-tool-sdk';
31
+ import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-spending-limit';
32
+
33
+ const toolParamsSchema = z.object({
34
+ buy: z.boolean(),
35
+ });
36
+
37
+ const spendingLimitPolicy = createVincentToolPolicy({
38
+ toolParamsSchema,
39
+ bundledVincentPolicy,
40
+ toolParameterMappings: { buy: 'buyAmount' },
41
+ });
42
+
43
+ export const myTokenSwapTool = createVincentTool({
44
+ toolParamsSchema,
45
+ supportedPolicies: supportedPoliciesForTool([spendingLimitPolicy]),
46
+ // ... rest of tool implementation
47
+ });
48
+ ```
49
+
50
+ ## Building
51
+
52
+ Run `nx build policy-spending-limit` to build the library.
53
+
54
+ ## Running unit tests
55
+
56
+ Run `nx test policy-spending-limit` to execute the unit tests via [Jest](https://jestjs.io).
57
+
58
+ ## Contributing
59
+
60
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
61
+
62
+ ## License
63
+
64
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,14 @@
1
+ ## 1.0.2 (2025-07-08)
2
+
3
+ ### 🩹 Fixes
4
+
5
+ - - Fixed a case where a deny response from a policy could be returned without being parsed by its deny result schema ([27a35240](https://github.com/LIT-Protocol/Vincent/commit/27a35240))
6
+
7
+ ### 🧱 Updated Dependencies
8
+
9
+ - Updated tool-sdk to 1.0.2
10
+ - Updated app-sdk to 1.0.2
11
+
12
+ ### ❤️ Thank You
13
+
14
+ - Daryl Collins
@@ -0,0 +1,89 @@
1
+ # Contributing to Vincent Policy Spending Limit
2
+
3
+ This document provides guidelines for contributing to the Vincent Policy Spending Limit project.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Spending Limit is a policy that can be attached to tools to avoid them spending more than a user-defined limit in a specific period of time. It's part of the Vincent Tools ecosystem and is built using the Vincent Tool 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 policy-spending-limit
25
+ ```
26
+
27
+ ### Building the Lit Action
28
+
29
+ Build the policy:
30
+
31
+ ```bash
32
+ nx action:build policy-spending-limit
33
+ ```
34
+
35
+ ### Deploying the Lit Action to IPFS
36
+
37
+ Building will be done automatically. Deploy the policy:
38
+
39
+ ```bash
40
+ nx action:deploy policy-spending-limit
41
+ ```
42
+
43
+ ## Project Structure
44
+
45
+ - `src/`: Source code
46
+ - `index.ts`: Main entry point
47
+
48
+ ## Policy Development Guidelines
49
+
50
+ 1. Use the Vincent Tool SDK to create policies
51
+ 2. Define clear schemas for tool parameters and user parameters
52
+ 3. Implement the policy lifecycle methods (evaluate, commit)
53
+ 4. Handle errors gracefully
54
+ 5. Write comprehensive tests for all functionality
55
+ 6. Document the policy's purpose and usage
56
+
57
+ ## Integration with Tools
58
+
59
+ This policy can be integrated with various Vincent Tools to enforce spending limits. When developing or modifying the policy, consider how it will be used by tools such as:
60
+
61
+ - Vincent Tool ERC20 Approval
62
+ - Vincent Tool Uniswap Swap
63
+
64
+ ## Testing
65
+
66
+ Write unit tests for all functionality:
67
+
68
+ ```bash
69
+ pnpm test
70
+ ```
71
+
72
+ ## Documentation
73
+
74
+ - Document the policy's purpose and usage
75
+ - Update README.md when adding new features
76
+ - Document the policy's parameters and behavior
77
+
78
+ ## Pull Request Process
79
+
80
+ 1. Ensure your code follows the coding standards
81
+ 2. Update documentation if necessary
82
+ 3. Include tests for new functionality
83
+ 4. Link any related issues in your pull request description
84
+ 5. Request a review from a maintainer
85
+
86
+ ## Additional Resources
87
+
88
+ - [Vincent Documentation](https://docs.heyvincent.ai/)
89
+ - [Vincent Tool SDK Documentation](../../libs/tool-sdk/README.md)
package/dist/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # Vincent Policy Spending Limit
2
+
3
+ A policy that can be attached to Vincent tools to avoid them spending more than a user-defined limit in a specific period of time.
4
+
5
+ ## Overview
6
+
7
+ The Vincent Policy Spending Limit is part of the Vincent Tools ecosystem and is built using the Vincent Tool SDK. It allows users to set spending limits for tools that interact with their funds, providing an additional layer of security and control.
8
+
9
+ ## Features
10
+
11
+ - Set maximum spending limits per period
12
+ - Track spending across multiple tools
13
+ - Configurable by users through the Vincent Dashboard
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @lit-protocol/vincent-policy-spending-limit
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ This policy can be integrated with Vincent Tools to enforce spending limits:
24
+
25
+ ```typescript
26
+ import {
27
+ createVincentToolPolicy,
28
+ createVincentTool,
29
+ supportedPoliciesForTool,
30
+ } from '@lit-protocol/vincent-tool-sdk';
31
+ import { bundledVincentPolicy } from '@lit-protocol/vincent-policy-spending-limit';
32
+
33
+ const toolParamsSchema = z.object({
34
+ buy: z.boolean(),
35
+ });
36
+
37
+ const spendingLimitPolicy = createVincentToolPolicy({
38
+ toolParamsSchema,
39
+ bundledVincentPolicy,
40
+ toolParameterMappings: { buy: 'buyAmount' },
41
+ });
42
+
43
+ export const myTokenSwapTool = createVincentTool({
44
+ toolParamsSchema,
45
+ supportedPolicies: supportedPoliciesForTool([spendingLimitPolicy]),
46
+ // ... rest of tool implementation
47
+ });
48
+ ```
49
+
50
+ ## Building
51
+
52
+ Run `nx build policy-spending-limit` to build the library.
53
+
54
+ ## Running unit tests
55
+
56
+ Run `nx test policy-spending-limit` to execute the unit tests via [Jest](https://jestjs.io).
57
+
58
+ ## Contributing
59
+
60
+ Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to contribute to this project.
61
+
62
+ ## License
63
+
64
+ This project is licensed under the MIT License - see the LICENSE file for details.
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@lit-protocol/vincent-policy-spending-limit",
3
+ "version": "1.0.2",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "dependencies": {
8
+ "@lit-protocol/vincent-tool-sdk": "workspace:*",
9
+ "@uniswap/sdk-core": "^7.7.2",
10
+ "ethers": "^5.8.0",
11
+ "tslib": "2.8.1",
12
+ "zod": "^3.25.64"
13
+ },
14
+ "peerDependencies": {
15
+ "@lit-protocol/vincent-app-sdk": "workspace:^"
16
+ },
17
+ "devDependencies": {
18
+ "esbuild": "^0.19.12",
19
+ "esbuild-plugin-polyfill-node": "^0.3.0",
20
+ "ipfs-only-hash": "^4.0.0"
21
+ },
22
+ "main": "./dist/src/index.js",
23
+ "module": "./dist/src/index.js",
24
+ "types": "./dist/src/index.d.ts",
25
+ "files": [
26
+ "dist/**",
27
+ "*.md"
28
+ ],
29
+ "type": "commonjs"
30
+ }