@lit-protocol/vincent-policy-send-counter 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.
- package/CONTRIBUTING.md +89 -0
- package/README.md +71 -0
- package/dist/CONTRIBUTING.md +89 -0
- package/dist/README.md +71 -0
- package/dist/package.json +30 -0
- package/dist/src/generated/lit-action.js +9 -0
- package/dist/src/generated/vincent-bundled-policy.d.ts +212 -0
- package/dist/src/generated/vincent-bundled-policy.d.ts.map +1 -0
- package/dist/src/generated/vincent-bundled-policy.js +15 -0
- package/dist/src/generated/vincent-bundled-policy.js.map +1 -0
- package/dist/src/generated/vincent-bundled-policy.ts +13 -0
- package/dist/src/generated/vincent-policy-metadata.json +3 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/lit-action.d.ts +2 -0
- package/dist/src/lib/lit-action.d.ts.map +1 -0
- package/dist/src/lib/lit-action.js +12 -0
- package/dist/src/lib/lit-action.js.map +1 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts +7 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.js +22 -0
- package/dist/src/lib/policy-helpers/calculate-usd-value.js.map +1 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts +16 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.js +29 -0
- package/dist/src/lib/policy-helpers/check-spending-limit.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts +6 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js +22 -0
- package/dist/src/lib/policy-helpers/get-eth-usd-price.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts +10 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js +68 -0
- package/dist/src/lib/policy-helpers/get-token-amount-in-usd.js.map +1 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts +15 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js +114 -0
- package/dist/src/lib/policy-helpers/get-uniswap-quote.js.map +1 -0
- package/dist/src/lib/policy-helpers/index.d.ts +7 -0
- package/dist/src/lib/policy-helpers/index.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/index.js +10 -0
- package/dist/src/lib/policy-helpers/index.js.map +1 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts +9 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.js +144 -0
- package/dist/src/lib/policy-helpers/send-spend-tx.js.map +1 -0
- package/dist/src/lib/policy-helpers/sign-tx.d.ts +3 -0
- package/dist/src/lib/policy-helpers/sign-tx.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/sign-tx.js +28 -0
- package/dist/src/lib/policy-helpers/sign-tx.js.map +1 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts +4 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.d.ts.map +1 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.js +22 -0
- package/dist/src/lib/policy-helpers/spending-limit-contract.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +101 -0
- package/dist/src/lib/schemas.d.ts.map +1 -0
- package/dist/src/lib/schemas.js +60 -0
- package/dist/src/lib/schemas.js.map +1 -0
- package/dist/src/lib/vincent-policy.d.ts +209 -0
- package/dist/src/lib/vincent-policy.d.ts.map +1 -0
- package/dist/src/lib/vincent-policy.js +117 -0
- package/dist/src/lib/vincent-policy.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
|
|
3
|
+
*/
|
|
4
|
+
export declare const bundledVincentPolicy: import("@lit-protocol/vincent-tool-sdk").BundledVincentPolicy<import("node_modules/@lit-protocol/vincent-tool-sdk/dist/src/lib/types").VincentPolicy<"@lit-protocol/vincent-policy-spending-limit", import("zod").ZodObject<{
|
|
5
|
+
ethRpcUrl: import("zod").ZodString;
|
|
6
|
+
rpcUrlForUniswap: import("zod").ZodString;
|
|
7
|
+
chainIdForUniswap: import("zod").ZodNumber;
|
|
8
|
+
tokenAddress: import("zod").ZodString;
|
|
9
|
+
tokenDecimals: import("zod").ZodNumber;
|
|
10
|
+
buyAmount: import("zod").ZodNumber;
|
|
11
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
12
|
+
ethRpcUrl: string;
|
|
13
|
+
rpcUrlForUniswap: string;
|
|
14
|
+
chainIdForUniswap: number;
|
|
15
|
+
tokenAddress: string;
|
|
16
|
+
tokenDecimals: number;
|
|
17
|
+
buyAmount: number;
|
|
18
|
+
}, {
|
|
19
|
+
ethRpcUrl: string;
|
|
20
|
+
rpcUrlForUniswap: string;
|
|
21
|
+
chainIdForUniswap: number;
|
|
22
|
+
tokenAddress: string;
|
|
23
|
+
tokenDecimals: number;
|
|
24
|
+
buyAmount: number;
|
|
25
|
+
}>, import("zod").ZodObject<{
|
|
26
|
+
maxDailySpendingLimitInUsdCents: import("zod").ZodBigInt;
|
|
27
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
28
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
29
|
+
}, {
|
|
30
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
31
|
+
}>, import("zod").ZodObject<{
|
|
32
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
33
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
34
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
35
|
+
maxSpendingLimitInUsd: number;
|
|
36
|
+
buyAmountInUsd: number;
|
|
37
|
+
}, {
|
|
38
|
+
maxSpendingLimitInUsd: number;
|
|
39
|
+
buyAmountInUsd: number;
|
|
40
|
+
}>, import("zod").ZodObject<{
|
|
41
|
+
reason: import("zod").ZodLiteral<"Attempted buy amount exceeds daily limit">;
|
|
42
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
43
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
44
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
45
|
+
maxSpendingLimitInUsd: number;
|
|
46
|
+
reason: "Attempted buy amount exceeds daily limit";
|
|
47
|
+
buyAmountInUsd: number;
|
|
48
|
+
}, {
|
|
49
|
+
maxSpendingLimitInUsd: number;
|
|
50
|
+
reason: "Attempted buy amount exceeds daily limit";
|
|
51
|
+
buyAmountInUsd: number;
|
|
52
|
+
}>, import("zod").ZodObject<{
|
|
53
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
54
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
55
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
56
|
+
maxSpendingLimitInUsd: number;
|
|
57
|
+
buyAmountInUsd: number;
|
|
58
|
+
}, {
|
|
59
|
+
maxSpendingLimitInUsd: number;
|
|
60
|
+
buyAmountInUsd: number;
|
|
61
|
+
}>, import("zod").ZodObject<{
|
|
62
|
+
reason: import("zod").ZodString;
|
|
63
|
+
maxSpendingLimitInUsd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
64
|
+
buyAmountInUsd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
65
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
66
|
+
reason: string;
|
|
67
|
+
maxSpendingLimitInUsd?: number | undefined;
|
|
68
|
+
buyAmountInUsd?: number | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
reason: string;
|
|
71
|
+
maxSpendingLimitInUsd?: number | undefined;
|
|
72
|
+
buyAmountInUsd?: number | undefined;
|
|
73
|
+
}>, import("zod").ZodObject<{
|
|
74
|
+
amountSpentUsd: import("zod").ZodNumber;
|
|
75
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
76
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
77
|
+
amountSpentUsd: number;
|
|
78
|
+
maxSpendingLimitInUsd: number;
|
|
79
|
+
}, {
|
|
80
|
+
amountSpentUsd: number;
|
|
81
|
+
maxSpendingLimitInUsd: number;
|
|
82
|
+
}>, import("zod").ZodObject<{
|
|
83
|
+
spendTxHash: import("zod").ZodString;
|
|
84
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
85
|
+
spendTxHash: string;
|
|
86
|
+
}, {
|
|
87
|
+
spendTxHash: string;
|
|
88
|
+
}>, import("zod").ZodObject<{
|
|
89
|
+
error: import("zod").ZodString;
|
|
90
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
91
|
+
error: string;
|
|
92
|
+
}, {
|
|
93
|
+
error: string;
|
|
94
|
+
}>, import("node_modules/@lit-protocol/vincent-tool-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
|
|
95
|
+
ethRpcUrl: import("zod").ZodString;
|
|
96
|
+
rpcUrlForUniswap: import("zod").ZodString;
|
|
97
|
+
chainIdForUniswap: import("zod").ZodNumber;
|
|
98
|
+
tokenAddress: import("zod").ZodString;
|
|
99
|
+
tokenDecimals: import("zod").ZodNumber;
|
|
100
|
+
buyAmount: import("zod").ZodNumber;
|
|
101
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
102
|
+
ethRpcUrl: string;
|
|
103
|
+
rpcUrlForUniswap: string;
|
|
104
|
+
chainIdForUniswap: number;
|
|
105
|
+
tokenAddress: string;
|
|
106
|
+
tokenDecimals: number;
|
|
107
|
+
buyAmount: number;
|
|
108
|
+
}, {
|
|
109
|
+
ethRpcUrl: string;
|
|
110
|
+
rpcUrlForUniswap: string;
|
|
111
|
+
chainIdForUniswap: number;
|
|
112
|
+
tokenAddress: string;
|
|
113
|
+
tokenDecimals: number;
|
|
114
|
+
buyAmount: number;
|
|
115
|
+
}>, import("zod").ZodObject<{
|
|
116
|
+
maxDailySpendingLimitInUsdCents: import("zod").ZodBigInt;
|
|
117
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
118
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
119
|
+
}, {
|
|
120
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
121
|
+
}>, import("zod").ZodObject<{
|
|
122
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
123
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
124
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
125
|
+
maxSpendingLimitInUsd: number;
|
|
126
|
+
buyAmountInUsd: number;
|
|
127
|
+
}, {
|
|
128
|
+
maxSpendingLimitInUsd: number;
|
|
129
|
+
buyAmountInUsd: number;
|
|
130
|
+
}>, import("zod").ZodObject<{
|
|
131
|
+
reason: import("zod").ZodString;
|
|
132
|
+
maxSpendingLimitInUsd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
133
|
+
buyAmountInUsd: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
134
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
135
|
+
reason: string;
|
|
136
|
+
maxSpendingLimitInUsd?: number | undefined;
|
|
137
|
+
buyAmountInUsd?: number | undefined;
|
|
138
|
+
}, {
|
|
139
|
+
reason: string;
|
|
140
|
+
maxSpendingLimitInUsd?: number | undefined;
|
|
141
|
+
buyAmountInUsd?: number | undefined;
|
|
142
|
+
}>>, import("node_modules/@lit-protocol/vincent-tool-sdk/dist/src/lib/types").PolicyLifecycleFunction<import("zod").ZodObject<{
|
|
143
|
+
ethRpcUrl: import("zod").ZodString;
|
|
144
|
+
rpcUrlForUniswap: import("zod").ZodString;
|
|
145
|
+
chainIdForUniswap: import("zod").ZodNumber;
|
|
146
|
+
tokenAddress: import("zod").ZodString;
|
|
147
|
+
tokenDecimals: import("zod").ZodNumber;
|
|
148
|
+
buyAmount: import("zod").ZodNumber;
|
|
149
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
150
|
+
ethRpcUrl: string;
|
|
151
|
+
rpcUrlForUniswap: string;
|
|
152
|
+
chainIdForUniswap: number;
|
|
153
|
+
tokenAddress: string;
|
|
154
|
+
tokenDecimals: number;
|
|
155
|
+
buyAmount: number;
|
|
156
|
+
}, {
|
|
157
|
+
ethRpcUrl: string;
|
|
158
|
+
rpcUrlForUniswap: string;
|
|
159
|
+
chainIdForUniswap: number;
|
|
160
|
+
tokenAddress: string;
|
|
161
|
+
tokenDecimals: number;
|
|
162
|
+
buyAmount: number;
|
|
163
|
+
}>, import("zod").ZodObject<{
|
|
164
|
+
maxDailySpendingLimitInUsdCents: import("zod").ZodBigInt;
|
|
165
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
166
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
167
|
+
}, {
|
|
168
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
169
|
+
}>, import("zod").ZodObject<{
|
|
170
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
171
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
172
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
173
|
+
maxSpendingLimitInUsd: number;
|
|
174
|
+
buyAmountInUsd: number;
|
|
175
|
+
}, {
|
|
176
|
+
maxSpendingLimitInUsd: number;
|
|
177
|
+
buyAmountInUsd: number;
|
|
178
|
+
}>, import("zod").ZodObject<{
|
|
179
|
+
reason: import("zod").ZodLiteral<"Attempted buy amount exceeds daily limit">;
|
|
180
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
181
|
+
buyAmountInUsd: import("zod").ZodNumber;
|
|
182
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
183
|
+
maxSpendingLimitInUsd: number;
|
|
184
|
+
reason: "Attempted buy amount exceeds daily limit";
|
|
185
|
+
buyAmountInUsd: number;
|
|
186
|
+
}, {
|
|
187
|
+
maxSpendingLimitInUsd: number;
|
|
188
|
+
reason: "Attempted buy amount exceeds daily limit";
|
|
189
|
+
buyAmountInUsd: number;
|
|
190
|
+
}>>, import("node_modules/@lit-protocol/vincent-tool-sdk/dist/src/lib/types").CommitLifecycleFunction<import("zod").ZodObject<{
|
|
191
|
+
amountSpentUsd: import("zod").ZodNumber;
|
|
192
|
+
maxSpendingLimitInUsd: import("zod").ZodNumber;
|
|
193
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
194
|
+
amountSpentUsd: number;
|
|
195
|
+
maxSpendingLimitInUsd: number;
|
|
196
|
+
}, {
|
|
197
|
+
amountSpentUsd: number;
|
|
198
|
+
maxSpendingLimitInUsd: number;
|
|
199
|
+
}>, import("zod").ZodObject<{
|
|
200
|
+
spendTxHash: import("zod").ZodString;
|
|
201
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
202
|
+
spendTxHash: string;
|
|
203
|
+
}, {
|
|
204
|
+
spendTxHash: string;
|
|
205
|
+
}>, import("zod").ZodObject<{
|
|
206
|
+
error: import("zod").ZodString;
|
|
207
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
208
|
+
error: string;
|
|
209
|
+
}, {
|
|
210
|
+
error: string;
|
|
211
|
+
}>>>, string>;
|
|
212
|
+
//# sourceMappingURL=vincent-bundled-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vincent-bundled-policy.d.ts","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-policy.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAA0D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bundledVincentPolicy = void 0;
|
|
7
|
+
const tslib_1 = require("tslib");
|
|
8
|
+
const vincent_tool_sdk_1 = require("@lit-protocol/vincent-tool-sdk");
|
|
9
|
+
const vincent_policy_1 = require("../lib/vincent-policy");
|
|
10
|
+
const vincent_policy_metadata_json_1 = tslib_1.__importDefault(require("./vincent-policy-metadata.json"));
|
|
11
|
+
if (!vincent_policy_metadata_json_1.default.ipfsCid) {
|
|
12
|
+
throw new Error('ipfsCid is not defined in metadata JSON file');
|
|
13
|
+
}
|
|
14
|
+
exports.bundledVincentPolicy = (0, vincent_tool_sdk_1.asBundledVincentPolicy)(vincent_policy_1.vincentPolicy, vincent_policy_metadata_json_1.default.ipfsCid);
|
|
15
|
+
//# sourceMappingURL=vincent-bundled-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vincent-bundled-policy.js","sourceRoot":"","sources":["../../../src/generated/vincent-bundled-policy.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,qEAAwE;AACxE,0DAAsD;AACtD,0GAAsD;AAEtD,IAAG,CAAC,sCAAQ,CAAC,OAAO,EAAE,CAAC;IACrB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC;AAEY,QAAA,oBAAoB,GAAG,IAAA,yCAAsB,EAAC,8BAAa,EAAE,sCAAQ,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { asBundledVincentPolicy } from '@lit-protocol/vincent-tool-sdk';
|
|
6
|
+
import { vincentPolicy } from '../lib/vincent-policy';
|
|
7
|
+
import metadata from './vincent-policy-metadata.json';
|
|
8
|
+
|
|
9
|
+
if(!metadata.ipfsCid) {
|
|
10
|
+
throw new Error('ipfsCid is not defined in metadata JSON file');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const bundledVincentPolicy = asBundledVincentPolicy(vincentPolicy, metadata.ipfsCid);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,qBAAqB,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.vincentPolicyMetadata = exports.bundledVincentPolicy = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
var vincent_bundled_policy_1 = require("./generated/vincent-bundled-policy");
|
|
6
|
+
Object.defineProperty(exports, "bundledVincentPolicy", { enumerable: true, get: function () { return vincent_bundled_policy_1.bundledVincentPolicy; } });
|
|
7
|
+
const vincentPolicyMetadata = tslib_1.__importStar(require("./generated/vincent-policy-metadata.json"));
|
|
8
|
+
exports.vincentPolicyMetadata = vincentPolicyMetadata;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6EAA0E;AAAjE,8HAAA,oBAAoB,OAAA;AAC7B,wGAAkF;AAEzE,sDAAqB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.d.ts","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vincent_tool_sdk_1 = require("@lit-protocol/vincent-tool-sdk");
|
|
4
|
+
const vincent_policy_1 = require("./vincent-policy");
|
|
5
|
+
(async () => {
|
|
6
|
+
return await (0, vincent_tool_sdk_1.vincentPolicyHandler)({
|
|
7
|
+
vincentPolicy: vincent_policy_1.vincentPolicy,
|
|
8
|
+
context,
|
|
9
|
+
toolParams,
|
|
10
|
+
});
|
|
11
|
+
})();
|
|
12
|
+
//# sourceMappingURL=lit-action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.js","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":";;AAAA,qEAAsE;AAEtE,qDAAiD;AAUjD,CAAC,KAAK,IAAI,EAAE;IACV,OAAO,MAAM,IAAA,uCAAoB,EAAC;QAChC,aAAa,EAAE,8BAAa;QAC5B,OAAO;QACP,UAAU;KACX,CAAC,CAAC;AACL,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const calculateUsdValue: ({ ethRpcUrl, chainlinkPriceFeedAddress, amountInWeth, }: {
|
|
3
|
+
ethRpcUrl: string;
|
|
4
|
+
chainlinkPriceFeedAddress: string;
|
|
5
|
+
amountInWeth: ethers.BigNumber;
|
|
6
|
+
}) => Promise<ethers.BigNumber>;
|
|
7
|
+
//# sourceMappingURL=calculate-usd-value.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-usd-value.d.ts","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/calculate-usd-value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,eAAO,MAAM,iBAAiB,GAAU,yDAIrC;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,yBAAyB,EAAE,MAAM,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC;CAChC,KAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAgB3B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateUsdValue = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const get_eth_usd_price_1 = require("./get-eth-usd-price");
|
|
6
|
+
const calculateUsdValue = async ({ ethRpcUrl, chainlinkPriceFeedAddress, amountInWeth, }) => {
|
|
7
|
+
const ethPriceInUsd = await (0, get_eth_usd_price_1.getEthUsdPriceFromChainlink)({ ethRpcUrl, chainlinkPriceFeedAddress });
|
|
8
|
+
// Calculate USD value (8 decimals precision)
|
|
9
|
+
const CHAINLINK_DECIMALS = 8;
|
|
10
|
+
const WETH_DECIMALS = 18; // WETH decimals
|
|
11
|
+
const amountInUsd = amountInWeth
|
|
12
|
+
.mul(ethPriceInUsd)
|
|
13
|
+
.div(ethers_1.ethers.utils.parseUnits('1', WETH_DECIMALS));
|
|
14
|
+
console.log(`Calculate token amount in USDC (calculateUsdValue)`, {
|
|
15
|
+
tokenAmountInWeth: ethers_1.ethers.utils.formatUnits(amountInWeth, WETH_DECIMALS),
|
|
16
|
+
ethPriceInUsd: ethers_1.ethers.utils.formatUnits(ethPriceInUsd, CHAINLINK_DECIMALS),
|
|
17
|
+
tokenAmountInUsd: ethers_1.ethers.utils.formatUnits(amountInUsd, CHAINLINK_DECIMALS),
|
|
18
|
+
});
|
|
19
|
+
return amountInUsd;
|
|
20
|
+
};
|
|
21
|
+
exports.calculateUsdValue = calculateUsdValue;
|
|
22
|
+
//# sourceMappingURL=calculate-usd-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculate-usd-value.js","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/calculate-usd-value.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,2DAAkE;AAE3D,MAAM,iBAAiB,GAAG,KAAK,EAAE,EACtC,SAAS,EACT,yBAAyB,EACzB,YAAY,GAKb,EAA6B,EAAE;IAC9B,MAAM,aAAa,GAAG,MAAM,IAAA,+CAA2B,EAAC,EAAE,SAAS,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAElG,6CAA6C;IAC7C,MAAM,kBAAkB,GAAG,CAAC,CAAC;IAC7B,MAAM,aAAa,GAAG,EAAE,CAAC,CAAC,gBAAgB;IAC1C,MAAM,WAAW,GAAG,YAAY;SAC7B,GAAG,CAAC,aAAa,CAAC;SAClB,GAAG,CAAC,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;IACpD,OAAO,CAAC,GAAG,CAAC,oDAAoD,EAAE;QAChE,iBAAiB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC;QACxE,aAAa,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,kBAAkB,CAAC;QAC1E,gBAAgB,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,EAAE,kBAAkB,CAAC;KAC5E,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAxBW,QAAA,iBAAiB,qBAwB5B"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const checkIfBuyAmountAllowed: ({ ethRpcUrl, rpcUrlForUniswap, chainIdForUniswap, tokenAddress, tokenDecimals, buyAmount, maxDailySpendingLimitInUsdCents, pkpEthAddress, appId, }: {
|
|
2
|
+
ethRpcUrl: string;
|
|
3
|
+
rpcUrlForUniswap: string;
|
|
4
|
+
chainIdForUniswap: number;
|
|
5
|
+
tokenAddress: `0x${string}`;
|
|
6
|
+
tokenDecimals: number;
|
|
7
|
+
buyAmount: number;
|
|
8
|
+
maxDailySpendingLimitInUsdCents: bigint;
|
|
9
|
+
pkpEthAddress: `0x${string}`;
|
|
10
|
+
appId: number;
|
|
11
|
+
}) => Promise<{
|
|
12
|
+
buyAmountAllowed: boolean;
|
|
13
|
+
buyAmountInUsd: bigint;
|
|
14
|
+
adjustedMaxDailySpendingLimit: bigint;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=check-spending-limit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-spending-limit.d.ts","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/check-spending-limit.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,GAAU,oJAU3C;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,KAAK,MAAM,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B,EAAE,MAAM,CAAC;IACxC,aAAa,EAAE,KAAK,MAAM,EAAE,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,OAAO,CAAC;IACV,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,6BAA6B,EAAE,MAAM,CAAC;CACvC,CAoCA,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIfBuyAmountAllowed = void 0;
|
|
4
|
+
const get_token_amount_in_usd_1 = require("./get-token-amount-in-usd");
|
|
5
|
+
const spending_limit_contract_1 = require("./spending-limit-contract");
|
|
6
|
+
const checkIfBuyAmountAllowed = async ({ ethRpcUrl, rpcUrlForUniswap, chainIdForUniswap, tokenAddress, tokenDecimals, buyAmount, maxDailySpendingLimitInUsdCents, pkpEthAddress, appId, }) => {
|
|
7
|
+
const buyAmountInUsd = await (0, get_token_amount_in_usd_1.getTokenAmountInUsd)({
|
|
8
|
+
ethRpcUrl,
|
|
9
|
+
rpcUrlForUniswap,
|
|
10
|
+
chainIdForUniswap,
|
|
11
|
+
tokenAddress,
|
|
12
|
+
tokenDecimals,
|
|
13
|
+
tokenAmount: buyAmount,
|
|
14
|
+
});
|
|
15
|
+
// maxDailySpendingLimitInUsdCents has 2 decimal precision, but tokenAmountInUsd has 8,
|
|
16
|
+
// so we multiply by 10^6 to match the precision
|
|
17
|
+
const adjustedMaxDailySpendingLimit = maxDailySpendingLimitInUsdCents * 1000000n;
|
|
18
|
+
console.log(`Adjusted maxDailySpendingLimitInUsdCents to 8 decimal precision: ${adjustedMaxDailySpendingLimit.toString()} (spendingLimitPolicyPrecheck)`);
|
|
19
|
+
const spendingLimitContract = (0, spending_limit_contract_1.getSpendingLimitContractInstance)();
|
|
20
|
+
const buyAmountAllowed = await spendingLimitContract.checkLimit(pkpEthAddress, BigInt(appId), buyAmountInUsd.toBigInt(), adjustedMaxDailySpendingLimit, 86400n);
|
|
21
|
+
console.log(`Buy amount allowed: ${JSON.stringify(buyAmountAllowed)} (spendingLimitPolicyPrecheck)`);
|
|
22
|
+
return {
|
|
23
|
+
buyAmountAllowed,
|
|
24
|
+
buyAmountInUsd: buyAmountInUsd.toBigInt(),
|
|
25
|
+
adjustedMaxDailySpendingLimit,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.checkIfBuyAmountAllowed = checkIfBuyAmountAllowed;
|
|
29
|
+
//# sourceMappingURL=check-spending-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-spending-limit.js","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/check-spending-limit.ts"],"names":[],"mappings":";;;AAAA,uEAAgE;AAChE,uEAA6E;AAEtE,MAAM,uBAAuB,GAAG,KAAK,EAAE,EAC5C,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,SAAS,EACT,+BAA+B,EAC/B,aAAa,EACb,KAAK,GAWN,EAIE,EAAE;IACH,MAAM,cAAc,GAAG,MAAM,IAAA,6CAAmB,EAAC;QAC/C,SAAS;QACT,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,WAAW,EAAE,SAAS;KACvB,CAAC,CAAC;IAEH,uFAAuF;IACvF,gDAAgD;IAChD,MAAM,6BAA6B,GAAG,+BAA+B,GAAG,QAAU,CAAC;IACnF,OAAO,CAAC,GAAG,CACT,oEAAoE,6BAA6B,CAAC,QAAQ,EAAE,gCAAgC,CAC7I,CAAC;IAEF,MAAM,qBAAqB,GAAG,IAAA,0DAAgC,GAAE,CAAC;IAEjE,MAAM,gBAAgB,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAC7D,aAAa,EACb,MAAM,CAAC,KAAK,CAAC,EACb,cAAc,CAAC,QAAQ,EAAE,EACzB,6BAA6B,EAC7B,MAAM,CACP,CAAC;IAEF,OAAO,CAAC,GAAG,CACT,uBAAuB,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,gCAAgC,CACxF,CAAC;IAEF,OAAO;QACL,gBAAgB;QAChB,cAAc,EAAE,cAAc,CAAC,QAAQ,EAAE;QACzC,6BAA6B;KAC9B,CAAC;AACJ,CAAC,CAAC;AA5DW,QAAA,uBAAuB,2BA4DlC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const getEthUsdPriceFromChainlink: ({ chainlinkPriceFeedAddress, ethRpcUrl, }: {
|
|
3
|
+
chainlinkPriceFeedAddress: string;
|
|
4
|
+
ethRpcUrl: string;
|
|
5
|
+
}) => Promise<ethers.BigNumber>;
|
|
6
|
+
//# sourceMappingURL=get-eth-usd-price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-eth-usd-price.d.ts","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/get-eth-usd-price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,eAAO,MAAM,2BAA2B,GAAU,2CAG/C;IACD,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAiB3B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEthUsdPriceFromChainlink = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const CHAINLINK_AGGREGATOR_ABI = [
|
|
6
|
+
'function latestRoundData() external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)',
|
|
7
|
+
];
|
|
8
|
+
const getEthUsdPriceFromChainlink = async ({ chainlinkPriceFeedAddress, ethRpcUrl, }) => {
|
|
9
|
+
console.log(`Getting ETH price in USD from Chainlink (getEthUsdPriceFromChainlink)`, {
|
|
10
|
+
chainlinkPriceFeedAddress,
|
|
11
|
+
ethRpcUrl,
|
|
12
|
+
});
|
|
13
|
+
const provider = new ethers_1.ethers.providers.StaticJsonRpcProvider(ethRpcUrl);
|
|
14
|
+
const contract = new ethers_1.ethers.Contract(chainlinkPriceFeedAddress, CHAINLINK_AGGREGATOR_ABI, provider);
|
|
15
|
+
const [_, answer] = await contract.latestRoundData();
|
|
16
|
+
console.log(`Got ETH price in USD (getEthUsdPriceFromChainlink)`, {
|
|
17
|
+
ethPriceInUsd: ethers_1.ethers.utils.formatUnits(answer, 8),
|
|
18
|
+
});
|
|
19
|
+
return answer;
|
|
20
|
+
};
|
|
21
|
+
exports.getEthUsdPriceFromChainlink = getEthUsdPriceFromChainlink;
|
|
22
|
+
//# sourceMappingURL=get-eth-usd-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-eth-usd-price.js","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/get-eth-usd-price.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,MAAM,wBAAwB,GAAG;IAC/B,gJAAgJ;CACjJ,CAAC;AAEK,MAAM,2BAA2B,GAAG,KAAK,EAAE,EAChD,yBAAyB,EACzB,SAAS,GAIV,EAA6B,EAAE;IAC9B,OAAO,CAAC,GAAG,CAAC,uEAAuE,EAAE;QACnF,yBAAyB;QACzB,SAAS;KACV,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,QAAQ,CAClC,yBAAyB,EACzB,wBAAwB,EACxB,QAAQ,CACT,CAAC;IACF,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,QAAQ,CAAC,eAAe,EAAE,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,oDAAoD,EAAE;QAChE,aAAa,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;KACnD,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAvBW,QAAA,2BAA2B,+BAuBtC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const getTokenAmountInUsd: ({ ethRpcUrl, rpcUrlForUniswap, chainIdForUniswap, tokenAddress, tokenAmount, tokenDecimals, }: {
|
|
3
|
+
ethRpcUrl: string;
|
|
4
|
+
rpcUrlForUniswap: string;
|
|
5
|
+
chainIdForUniswap: number;
|
|
6
|
+
tokenAddress: string;
|
|
7
|
+
tokenDecimals: number;
|
|
8
|
+
tokenAmount: number;
|
|
9
|
+
}) => Promise<ethers.BigNumber>;
|
|
10
|
+
//# sourceMappingURL=get-token-amount-in-usd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-token-amount-in-usd.d.ts","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/get-token-amount-in-usd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAWhC,eAAO,MAAM,mBAAmB,GAAU,+FAOvC;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB,KAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAiE3B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTokenAmountInUsd = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const calculate_usd_value_1 = require("./calculate-usd-value");
|
|
6
|
+
const get_uniswap_quote_1 = require("./get-uniswap-quote");
|
|
7
|
+
const ETH_MAINNET_WETH_ADDRESS = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
8
|
+
/**
|
|
9
|
+
* Source: https://docs.chain.link/data-feeds/price-feeds/addresses/?network=ethereum&page=1&search=ETH%2FUSD
|
|
10
|
+
*/
|
|
11
|
+
const ETH_MAINNET_ETH_USD_CHAINLINK_FEED = '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419';
|
|
12
|
+
const getTokenAmountInUsd = async ({ ethRpcUrl, rpcUrlForUniswap, chainIdForUniswap, tokenAddress, tokenAmount, tokenDecimals, }) => {
|
|
13
|
+
console.log(`Getting token amount in USD (getTokenAmountInUsd)`, {
|
|
14
|
+
ethRpcUrl,
|
|
15
|
+
rpcUrlForUniswap,
|
|
16
|
+
chainIdForUniswap,
|
|
17
|
+
tokenAddress,
|
|
18
|
+
tokenAmount,
|
|
19
|
+
tokenDecimals,
|
|
20
|
+
ethMainnetWethAddress: ETH_MAINNET_WETH_ADDRESS,
|
|
21
|
+
ethMainnetEthUsdChainlinkFeed: ETH_MAINNET_ETH_USD_CHAINLINK_FEED,
|
|
22
|
+
});
|
|
23
|
+
const provider = new ethers_1.ethers.providers.JsonRpcProvider(rpcUrlForUniswap);
|
|
24
|
+
const tokenInContract = new ethers_1.ethers.Contract(tokenAddress, ['function symbol() view returns (string)'], provider);
|
|
25
|
+
const tokenInSymbol = await tokenInContract.symbol();
|
|
26
|
+
console.log(`tokenInSymbol: ${tokenInSymbol} (getTokenAmountInUsd)`);
|
|
27
|
+
// Special case for WETH - no need to get a quote since it's already in ETH terms
|
|
28
|
+
if (tokenInSymbol.toUpperCase() === 'WETH') {
|
|
29
|
+
console.log(`Token is WETH, using amount directly: ${tokenAmount} (getTokenAmountInUsd)`);
|
|
30
|
+
const amountInWeth = ethers_1.ethers.utils.parseUnits(tokenAmount.toString(), tokenDecimals);
|
|
31
|
+
return (0, calculate_usd_value_1.calculateUsdValue)({
|
|
32
|
+
ethRpcUrl,
|
|
33
|
+
chainlinkPriceFeedAddress: ETH_MAINNET_ETH_USD_CHAINLINK_FEED,
|
|
34
|
+
amountInWeth,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
console.log(`Getting price in WETH from Uniswap (getTokenAmountInUsd)`, {
|
|
38
|
+
tokenInAddress: tokenAddress,
|
|
39
|
+
tokenInDecimals: tokenDecimals,
|
|
40
|
+
tokenInAmount: tokenAmount,
|
|
41
|
+
tokenOutAddress: ETH_MAINNET_WETH_ADDRESS,
|
|
42
|
+
tokenOutDecimals: 18,
|
|
43
|
+
rpcUrl: rpcUrlForUniswap,
|
|
44
|
+
chainId: chainIdForUniswap,
|
|
45
|
+
});
|
|
46
|
+
const amountInWeth = await (0, get_uniswap_quote_1.getUniswapQuote)({
|
|
47
|
+
tokenInAddress: tokenAddress,
|
|
48
|
+
tokenInDecimals: tokenDecimals,
|
|
49
|
+
tokenInAmount: tokenAmount,
|
|
50
|
+
tokenOutAddress: ETH_MAINNET_WETH_ADDRESS,
|
|
51
|
+
tokenOutDecimals: 18,
|
|
52
|
+
rpcUrl: rpcUrlForUniswap,
|
|
53
|
+
chainId: chainIdForUniswap,
|
|
54
|
+
});
|
|
55
|
+
// Convert WETH amount to USD
|
|
56
|
+
const amountInUsdc = await (0, calculate_usd_value_1.calculateUsdValue)({
|
|
57
|
+
ethRpcUrl,
|
|
58
|
+
chainlinkPriceFeedAddress: ETH_MAINNET_ETH_USD_CHAINLINK_FEED,
|
|
59
|
+
amountInWeth: amountInWeth.bestQuote,
|
|
60
|
+
});
|
|
61
|
+
console.log('Calculated token amount in USDC (getTokenAmountInUsd)', {
|
|
62
|
+
amountInWeth: ethers_1.ethers.utils.formatUnits(amountInWeth.bestQuote, 18),
|
|
63
|
+
amountInUsdc: ethers_1.ethers.utils.formatUnits(amountInUsdc, 8),
|
|
64
|
+
});
|
|
65
|
+
return amountInUsdc;
|
|
66
|
+
};
|
|
67
|
+
exports.getTokenAmountInUsd = getTokenAmountInUsd;
|
|
68
|
+
//# sourceMappingURL=get-token-amount-in-usd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-token-amount-in-usd.js","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/get-token-amount-in-usd.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAEhC,+DAA0D;AAC1D,2DAAsD;AAEtD,MAAM,wBAAwB,GAAG,4CAA4C,CAAC;AAC9E;;GAEG;AACH,MAAM,kCAAkC,GAAG,4CAA4C,CAAC;AAEjF,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,aAAa,GAQd,EAA6B,EAAE;IAC9B,OAAO,CAAC,GAAG,CAAC,mDAAmD,EAAE;QAC/D,SAAS;QACT,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,WAAW;QACX,aAAa;QACb,qBAAqB,EAAE,wBAAwB;QAC/C,6BAA6B,EAAE,kCAAkC;KAClE,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;IACxE,MAAM,eAAe,GAAG,IAAI,eAAM,CAAC,QAAQ,CACzC,YAAY,EACZ,CAAC,yCAAyC,CAAC,EAC3C,QAAQ,CACT,CAAC;IACF,MAAM,aAAa,GAAG,MAAM,eAAe,CAAC,MAAM,EAAE,CAAC;IACrD,OAAO,CAAC,GAAG,CAAC,kBAAkB,aAAa,wBAAwB,CAAC,CAAC;IAErE,iFAAiF;IACjF,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,yCAAyC,WAAW,wBAAwB,CAAC,CAAC;QAC1F,MAAM,YAAY,GAAG,eAAM,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,aAAa,CAAC,CAAC;QACpF,OAAO,IAAA,uCAAiB,EAAC;YACvB,SAAS;YACT,yBAAyB,EAAE,kCAAkC;YAC7D,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,0DAA0D,EAAE;QACtE,cAAc,EAAE,YAAY;QAC5B,eAAe,EAAE,aAAa;QAC9B,aAAa,EAAE,WAAW;QAC1B,eAAe,EAAE,wBAAwB;QACzC,gBAAgB,EAAE,EAAE;QACpB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,iBAAiB;KAC3B,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,MAAM,IAAA,mCAAe,EAAC;QACzC,cAAc,EAAE,YAAY;QAC5B,eAAe,EAAE,aAAa;QAC9B,aAAa,EAAE,WAAW;QAC1B,eAAe,EAAE,wBAAwB;QACzC,gBAAgB,EAAE,EAAE;QACpB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,iBAAiB;KAC3B,CAAC,CAAC;IAEH,6BAA6B;IAC7B,MAAM,YAAY,GAAG,MAAM,IAAA,uCAAiB,EAAC;QAC3C,SAAS;QACT,yBAAyB,EAAE,kCAAkC;QAC7D,YAAY,EAAE,YAAY,CAAC,SAAS;KACrC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,uDAAuD,EAAE;QACnE,YAAY,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,EAAE,EAAE,CAAC;QAClE,YAAY,EAAE,eAAM,CAAC,KAAK,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;KACxD,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AA/EW,QAAA,mBAAmB,uBA+E9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
export declare const getUniswapQuote: ({ rpcUrl, chainId, tokenInAddress, tokenInDecimals, tokenInAmount, tokenOutAddress, tokenOutDecimals, }: {
|
|
3
|
+
rpcUrl: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
tokenInAddress: string;
|
|
6
|
+
tokenInDecimals: number;
|
|
7
|
+
tokenInAmount: number;
|
|
8
|
+
tokenOutAddress: string;
|
|
9
|
+
tokenOutDecimals: number;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
bestQuote: ethers.BigNumber;
|
|
12
|
+
bestFee: number;
|
|
13
|
+
amountOutMin: ethers.BigNumber;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=get-uniswap-quote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-uniswap-quote.d.ts","sourceRoot":"","sources":["../../../../src/lib/policy-helpers/get-uniswap-quote.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,eAAO,MAAM,eAAe,GAAU,yGAQnC;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,KAAG,OAAO,CAAC;IACV,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC;CAChC,CA8HA,CAAC"}
|