@lit-protocol/vincent-ability-aerodrome-swap 0.1.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/CHANGELOG.md +9 -0
- package/CONTRIBUTING.md +5 -0
- package/README.md +5 -0
- package/dist/CONTRIBUTING.md +5 -0
- package/dist/README.md +5 -0
- package/dist/package.json +30 -0
- package/dist/src/generated/lit-action.js +9 -0
- package/dist/src/generated/vincent-ability-metadata.json +3 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts +136 -0
- package/dist/src/generated/vincent-bundled-ability.d.ts.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.js +15 -0
- package/dist/src/generated/vincent-bundled-ability.js.map +1 -0
- package/dist/src/generated/vincent-bundled-ability.ts +13 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib/ability-checks/check-erc20-allowance.d.ts +10 -0
- package/dist/src/lib/ability-checks/check-erc20-allowance.d.ts.map +1 -0
- package/dist/src/lib/ability-checks/check-erc20-allowance.js +31 -0
- package/dist/src/lib/ability-checks/check-erc20-allowance.js.map +1 -0
- package/dist/src/lib/ability-checks/check-erc20-balance.d.ts +9 -0
- package/dist/src/lib/ability-checks/check-erc20-balance.d.ts.map +1 -0
- package/dist/src/lib/ability-checks/check-erc20-balance.js +25 -0
- package/dist/src/lib/ability-checks/check-erc20-balance.js.map +1 -0
- package/dist/src/lib/ability-checks/check-native-token-balance.d.ts +7 -0
- package/dist/src/lib/ability-checks/check-native-token-balance.d.ts.map +1 -0
- package/dist/src/lib/ability-checks/check-native-token-balance.js +18 -0
- package/dist/src/lib/ability-checks/check-native-token-balance.js.map +1 -0
- package/dist/src/lib/ability-checks/index.d.ts +4 -0
- package/dist/src/lib/ability-checks/index.d.ts.map +1 -0
- package/dist/src/lib/ability-checks/index.js +7 -0
- package/dist/src/lib/ability-checks/index.js.map +1 -0
- package/dist/src/lib/ability-helpers/find-supported-token-on-base.d.ts +18 -0
- package/dist/src/lib/ability-helpers/find-supported-token-on-base.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/find-supported-token-on-base.js +10 -0
- package/dist/src/lib/ability-helpers/find-supported-token-on-base.js.map +1 -0
- package/dist/src/lib/ability-helpers/get-erc20-allowance.d.ts +8 -0
- package/dist/src/lib/ability-helpers/get-erc20-allowance.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/get-erc20-allowance.js +10 -0
- package/dist/src/lib/ability-helpers/get-erc20-allowance.js.map +1 -0
- package/dist/src/lib/ability-helpers/get-erc20-contract.d.ts +4 -0
- package/dist/src/lib/ability-helpers/get-erc20-contract.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/get-erc20-contract.js +20 -0
- package/dist/src/lib/ability-helpers/get-erc20-contract.js.map +1 -0
- package/dist/src/lib/ability-helpers/index.d.ts +6 -0
- package/dist/src/lib/ability-helpers/index.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/index.js +9 -0
- package/dist/src/lib/ability-helpers/index.js.map +1 -0
- package/dist/src/lib/ability-helpers/send-aerodrome-swap-tx.d.ts +15 -0
- package/dist/src/lib/ability-helpers/send-aerodrome-swap-tx.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/send-aerodrome-swap-tx.js +79 -0
- package/dist/src/lib/ability-helpers/send-aerodrome-swap-tx.js.map +1 -0
- package/dist/src/lib/ability-helpers/send-erc20-approval-tx.d.ts +15 -0
- package/dist/src/lib/ability-helpers/send-erc20-approval-tx.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/send-erc20-approval-tx.js +86 -0
- package/dist/src/lib/ability-helpers/send-erc20-approval-tx.js.map +1 -0
- package/dist/src/lib/ability-helpers/sign-tx.d.ts +3 -0
- package/dist/src/lib/ability-helpers/sign-tx.d.ts.map +1 -0
- package/dist/src/lib/ability-helpers/sign-tx.js +28 -0
- package/dist/src/lib/ability-helpers/sign-tx.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 +16 -0
- package/dist/src/lib/lit-action.js.map +1 -0
- package/dist/src/lib/schemas.d.ts +139 -0
- package/dist/src/lib/schemas.d.ts.map +1 -0
- package/dist/src/lib/schemas.js +128 -0
- package/dist/src/lib/schemas.js.map +1 -0
- package/dist/src/lib/types.d.ts +43 -0
- package/dist/src/lib/types.d.ts.map +1 -0
- package/dist/src/lib/types.js +9 -0
- package/dist/src/lib/types.js.map +1 -0
- package/dist/src/lib/vincent-ability.d.ts +134 -0
- package/dist/src/lib/vincent-ability.d.ts.map +1 -0
- package/dist/src/lib/vincent-ability.js +322 -0
- package/dist/src/lib/vincent-ability.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendErc20ApprovalTx = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
|
|
6
|
+
const get_erc20_contract_1 = require("./get-erc20-contract");
|
|
7
|
+
const sign_tx_1 = require("./sign-tx");
|
|
8
|
+
const sendErc20ApprovalTx = async ({ rpcUrl, chainId, pkpPublicKey, pkpEthAddress, erc20TokenAddress, spenderAddress, allowanceAmount, gasBufferPercentage, baseFeePerGasBufferPercentage, alchemyGasSponsor, alchemyGasSponsorApiKey, alchemyGasSponsorPolicyId, }) => {
|
|
9
|
+
if (alchemyGasSponsor) {
|
|
10
|
+
console.log('[sendErc20ApprovalTx] Alchemy gas sponsor is enabled');
|
|
11
|
+
if (!alchemyGasSponsorApiKey || !alchemyGasSponsorPolicyId) {
|
|
12
|
+
throw new Error('[sendErc20ApprovalTx] Alchemy gas sponsor is enabled, but API key or policy ID is not provided.');
|
|
13
|
+
}
|
|
14
|
+
return await (0, vincent_ability_sdk_1.sponsoredGasContractCall)({
|
|
15
|
+
pkpPublicKey,
|
|
16
|
+
abi: get_erc20_contract_1.ERC20_ABI,
|
|
17
|
+
contractAddress: erc20TokenAddress,
|
|
18
|
+
functionName: 'approve',
|
|
19
|
+
args: [spenderAddress, allowanceAmount],
|
|
20
|
+
chainId,
|
|
21
|
+
eip7702AlchemyApiKey: alchemyGasSponsorApiKey,
|
|
22
|
+
eip7702AlchemyPolicyId: alchemyGasSponsorPolicyId,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
console.log('[sendErc20ApprovalTx] Estimating gas for ERC20 Approval transaction');
|
|
26
|
+
const populateTxResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: '[sendErc20ApprovalTx] ERC20 approval tx gas estimation' }, async () => {
|
|
27
|
+
const erc20Interface = new ethers_1.ethers.utils.Interface(get_erc20_contract_1.ERC20_ABI);
|
|
28
|
+
const approveCalldata = erc20Interface.encodeFunctionData('approve', [
|
|
29
|
+
spenderAddress,
|
|
30
|
+
allowanceAmount,
|
|
31
|
+
]);
|
|
32
|
+
try {
|
|
33
|
+
return JSON.stringify({
|
|
34
|
+
status: 'success',
|
|
35
|
+
populatedTransaction: await (0, vincent_ability_sdk_1.populateTransaction)({
|
|
36
|
+
to: erc20TokenAddress,
|
|
37
|
+
from: pkpEthAddress,
|
|
38
|
+
value: '0',
|
|
39
|
+
data: approveCalldata,
|
|
40
|
+
rpcUrl,
|
|
41
|
+
chainId,
|
|
42
|
+
gasBufferPercentage,
|
|
43
|
+
baseFeePerGasBufferPercentage,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
return JSON.stringify({
|
|
49
|
+
status: 'error',
|
|
50
|
+
error: error instanceof Error ? error.message : String(error),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const parsedPopulateTxResponse = JSON.parse(populateTxResponse);
|
|
55
|
+
if (parsedPopulateTxResponse.status === 'error') {
|
|
56
|
+
throw new Error(`[sendErc20ApprovalTx] Error populating transaction for approval: ${parsedPopulateTxResponse.error}`);
|
|
57
|
+
}
|
|
58
|
+
const { populatedTransaction } = parsedPopulateTxResponse;
|
|
59
|
+
const signedApprovalTx = await (0, sign_tx_1.signTx)(pkpPublicKey, populatedTransaction, 'erc20ApprovalSig');
|
|
60
|
+
console.log(`Broadcasting ERC20 approval transaction (sendErc20ApprovalTx)`);
|
|
61
|
+
const swapTxResponse = await Lit.Actions.runOnce({ waitForResponse: true, name: 'erc20ApprovalTxSender' }, async () => {
|
|
62
|
+
try {
|
|
63
|
+
const rpcProvider = new ethers_1.ethers.providers.StaticJsonRpcProvider(rpcUrl);
|
|
64
|
+
const receipt = await rpcProvider.sendTransaction(signedApprovalTx);
|
|
65
|
+
return JSON.stringify({
|
|
66
|
+
status: 'success',
|
|
67
|
+
txHash: receipt.hash,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return JSON.stringify({
|
|
72
|
+
status: 'error',
|
|
73
|
+
error: error instanceof Error ? error.message : String(error),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
const parsedSwapTxResponse = JSON.parse(swapTxResponse);
|
|
78
|
+
if (parsedSwapTxResponse.status === 'error') {
|
|
79
|
+
throw new Error(`[sendErc20ApprovalTx] Error broadcasting ERC20 approval transaction: ${parsedSwapTxResponse.error}`);
|
|
80
|
+
}
|
|
81
|
+
const { txHash } = parsedSwapTxResponse;
|
|
82
|
+
console.log(`[sendErc20ApprovalTx] ERC20 approval transaction broadcasted: ${txHash}`);
|
|
83
|
+
return txHash;
|
|
84
|
+
};
|
|
85
|
+
exports.sendErc20ApprovalTx = sendErc20ApprovalTx;
|
|
86
|
+
//# sourceMappingURL=send-erc20-approval-tx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-erc20-approval-tx.js","sourceRoot":"","sources":["../../../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G,MAAM,WAAW,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;YACpE,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,OAAO,CAAC,IAAI;aACrB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,OAAO;gBACf,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;IAEF,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACxD,IAAI,oBAAoB,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CACb,wEAAwE,oBAAoB,CAAC,KAAK,EAAE,CACrG,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,MAAM,EAAE,GAAG,oBAAoB,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,iEAAiE,MAAM,EAAE,CAAC,CAAC;IAEvF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAzHW,QAAA,mBAAmB,uBAyH9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-tx.d.ts","sourceRoot":"","sources":["../../../../src/lib/ability-helpers/sign-tx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAYhC,eAAO,MAAM,MAAM,GACjB,cAAc,MAAM,EACpB,IAAI,MAAM,CAAC,mBAAmB,EAC9B,SAAS,MAAM,oBA4BhB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.signTx = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const signTx = async (pkpPublicKey, tx, sigName) => {
|
|
6
|
+
// Remove 0x prefix if it exists, Lit expects a hex string without 0x prefix
|
|
7
|
+
const publicKeyForLit = pkpPublicKey.replace(/^0x/, '');
|
|
8
|
+
console.log(`Signing using PKP Public Key: ${publicKeyForLit} (signTx)`);
|
|
9
|
+
const unsignedSerializedTx = ethers_1.ethers.utils.serializeTransaction(tx);
|
|
10
|
+
const txHash = ethers_1.ethers.utils.keccak256(unsignedSerializedTx);
|
|
11
|
+
console.log('Tx hash (signTx)', txHash);
|
|
12
|
+
const signatureResponse = await Lit.Actions.signAndCombineEcdsa({
|
|
13
|
+
toSign: ethers_1.ethers.utils.arrayify(txHash),
|
|
14
|
+
publicKey: publicKeyForLit,
|
|
15
|
+
sigName,
|
|
16
|
+
});
|
|
17
|
+
const { r, s, v } = JSON.parse(signatureResponse);
|
|
18
|
+
const ethersJoinedSignature = ethers_1.ethers.utils.joinSignature({
|
|
19
|
+
r: '0x' + r.substring(2),
|
|
20
|
+
s: '0x' + s,
|
|
21
|
+
v: v,
|
|
22
|
+
});
|
|
23
|
+
const signedSerializedTx = ethers_1.ethers.utils.serializeTransaction(tx, ethersJoinedSignature);
|
|
24
|
+
console.log('Signed serialized tx (signTx)', signedSerializedTx);
|
|
25
|
+
return signedSerializedTx;
|
|
26
|
+
};
|
|
27
|
+
exports.signTx = signTx;
|
|
28
|
+
//# sourceMappingURL=sign-tx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign-tx.js","sourceRoot":"","sources":["../../../../src/lib/ability-helpers/sign-tx.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAYzB,MAAM,MAAM,GAAG,KAAK,EACzB,YAAoB,EACpB,EAA8B,EAC9B,OAAe,EACf,EAAE;IACF,4EAA4E;IAC5E,MAAM,eAAe,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,GAAG,CAAC,iCAAiC,eAAe,WAAW,CAAC,CAAC;IAEzE,MAAM,oBAAoB,GAAG,eAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;IAEnE,MAAM,MAAM,GAAG,eAAM,CAAC,KAAK,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;IAExC,MAAM,iBAAiB,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC;QAC9D,MAAM,EAAE,eAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;QACrC,SAAS,EAAE,eAAe;QAC1B,OAAO;KACR,CAAC,CAAC;IAEH,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAClD,MAAM,qBAAqB,GAAG,eAAM,CAAC,KAAK,CAAC,aAAa,CAAC;QACvD,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QACxB,CAAC,EAAE,IAAI,GAAG,CAAC;QACX,CAAC,EAAE,CAAC;KACL,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,eAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;IACxF,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,kBAAkB,CAAC,CAAC;IAEjE,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AA/BW,QAAA,MAAM,UA+BjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lit-action.d.ts","sourceRoot":"","sources":["../../../src/lib/lit-action.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vincent_ability_sdk_1 = require("@lit-protocol/vincent-ability-sdk");
|
|
4
|
+
// FIXME: This should be generated code
|
|
5
|
+
const vincent_ability_1 = require("./vincent-ability");
|
|
6
|
+
(async () => {
|
|
7
|
+
const func = (0, vincent_ability_sdk_1.vincentAbilityHandler)({
|
|
8
|
+
vincentAbility: vincent_ability_1.vincentAbility,
|
|
9
|
+
context: {
|
|
10
|
+
delegatorPkpEthAddress: context.delegatorPkpEthAddress,
|
|
11
|
+
},
|
|
12
|
+
abilityParams,
|
|
13
|
+
});
|
|
14
|
+
await func();
|
|
15
|
+
})();
|
|
16
|
+
//# 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,2EAA0E;AAG1E,uCAAuC;AAEvC,uDAAmD;AAQnD,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,IAAI,GAAG,IAAA,2CAAqB,EAAC;QACjC,cAAc,EAAE,gCAAc;QAC9B,OAAO,EAAE;YACP,sBAAsB,EAAE,OAAO,CAAC,sBAAsB;SACvD;QACD,aAAa;KACd,CAAC,CAAC;IACH,MAAM,IAAI,EAAE,CAAC;AACf,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DEFAULT_AERODROME_SWAP_SLIPPAGE = 0.005;
|
|
3
|
+
export declare const abilityParamsSchema: z.ZodObject<{
|
|
4
|
+
action: z.ZodEnum<["approve", "swap"]>;
|
|
5
|
+
rpcUrl: z.ZodString;
|
|
6
|
+
tokenInAddress: z.ZodString;
|
|
7
|
+
tokenOutAddress: z.ZodString;
|
|
8
|
+
amountIn: z.ZodString;
|
|
9
|
+
slippage: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
10
|
+
gasBufferPercentage: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
baseFeePerGasBufferPercentage: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
alchemyGasSponsor: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
13
|
+
alchemyGasSponsorApiKey: z.ZodOptional<z.ZodString>;
|
|
14
|
+
alchemyGasSponsorPolicyId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
action: "approve" | "swap";
|
|
17
|
+
rpcUrl: string;
|
|
18
|
+
tokenInAddress: string;
|
|
19
|
+
tokenOutAddress: string;
|
|
20
|
+
amountIn: string;
|
|
21
|
+
alchemyGasSponsor: boolean;
|
|
22
|
+
slippage?: number | undefined;
|
|
23
|
+
gasBufferPercentage?: number | undefined;
|
|
24
|
+
baseFeePerGasBufferPercentage?: number | undefined;
|
|
25
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
26
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
action: "approve" | "swap";
|
|
29
|
+
rpcUrl: string;
|
|
30
|
+
tokenInAddress: string;
|
|
31
|
+
tokenOutAddress: string;
|
|
32
|
+
amountIn: string;
|
|
33
|
+
slippage?: number | undefined;
|
|
34
|
+
gasBufferPercentage?: number | undefined;
|
|
35
|
+
baseFeePerGasBufferPercentage?: number | undefined;
|
|
36
|
+
alchemyGasSponsor?: boolean | undefined;
|
|
37
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
38
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const precheckSuccessSchema: z.ZodObject<{
|
|
41
|
+
nativeTokenBalance: z.ZodOptional<z.ZodString>;
|
|
42
|
+
tokenInAddress: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tokenInBalance: z.ZodOptional<z.ZodString>;
|
|
44
|
+
currentTokenInAllowanceForSpender: z.ZodString;
|
|
45
|
+
spenderAddress: z.ZodString;
|
|
46
|
+
requiredTokenInAllowance: z.ZodOptional<z.ZodString>;
|
|
47
|
+
quote: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
tokenInAmount: z.ZodString;
|
|
49
|
+
tokenOutAmount: z.ZodString;
|
|
50
|
+
priceImpact: z.ZodString;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
tokenInAmount: string;
|
|
53
|
+
tokenOutAmount: string;
|
|
54
|
+
priceImpact: string;
|
|
55
|
+
}, {
|
|
56
|
+
tokenInAmount: string;
|
|
57
|
+
tokenOutAmount: string;
|
|
58
|
+
priceImpact: string;
|
|
59
|
+
}>>;
|
|
60
|
+
}, "strip", z.ZodTypeAny, {
|
|
61
|
+
currentTokenInAllowanceForSpender: string;
|
|
62
|
+
spenderAddress: string;
|
|
63
|
+
tokenInAddress?: string | undefined;
|
|
64
|
+
nativeTokenBalance?: string | undefined;
|
|
65
|
+
tokenInBalance?: string | undefined;
|
|
66
|
+
requiredTokenInAllowance?: string | undefined;
|
|
67
|
+
quote?: {
|
|
68
|
+
tokenInAmount: string;
|
|
69
|
+
tokenOutAmount: string;
|
|
70
|
+
priceImpact: string;
|
|
71
|
+
} | undefined;
|
|
72
|
+
}, {
|
|
73
|
+
currentTokenInAllowanceForSpender: string;
|
|
74
|
+
spenderAddress: string;
|
|
75
|
+
tokenInAddress?: string | undefined;
|
|
76
|
+
nativeTokenBalance?: string | undefined;
|
|
77
|
+
tokenInBalance?: string | undefined;
|
|
78
|
+
requiredTokenInAllowance?: string | undefined;
|
|
79
|
+
quote?: {
|
|
80
|
+
tokenInAmount: string;
|
|
81
|
+
tokenOutAmount: string;
|
|
82
|
+
priceImpact: string;
|
|
83
|
+
} | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
export declare const precheckFailSchema: z.ZodObject<{
|
|
86
|
+
reason: z.ZodString;
|
|
87
|
+
spenderAddress: z.ZodOptional<z.ZodString>;
|
|
88
|
+
tokenAddress: z.ZodOptional<z.ZodString>;
|
|
89
|
+
requiredTokenAmount: z.ZodOptional<z.ZodString>;
|
|
90
|
+
tokenBalance: z.ZodOptional<z.ZodString>;
|
|
91
|
+
currentAllowance: z.ZodOptional<z.ZodString>;
|
|
92
|
+
requiredAllowance: z.ZodOptional<z.ZodString>;
|
|
93
|
+
}, "strip", z.ZodTypeAny, {
|
|
94
|
+
reason: string;
|
|
95
|
+
spenderAddress?: string | undefined;
|
|
96
|
+
tokenAddress?: string | undefined;
|
|
97
|
+
requiredTokenAmount?: string | undefined;
|
|
98
|
+
tokenBalance?: string | undefined;
|
|
99
|
+
currentAllowance?: string | undefined;
|
|
100
|
+
requiredAllowance?: string | undefined;
|
|
101
|
+
}, {
|
|
102
|
+
reason: string;
|
|
103
|
+
spenderAddress?: string | undefined;
|
|
104
|
+
tokenAddress?: string | undefined;
|
|
105
|
+
requiredTokenAmount?: string | undefined;
|
|
106
|
+
tokenBalance?: string | undefined;
|
|
107
|
+
currentAllowance?: string | undefined;
|
|
108
|
+
requiredAllowance?: string | undefined;
|
|
109
|
+
}>;
|
|
110
|
+
export declare const executeFailSchema: z.ZodObject<{
|
|
111
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
reason?: string | undefined;
|
|
114
|
+
}, {
|
|
115
|
+
reason?: string | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
export declare const executeSuccessSchema: z.ZodObject<{
|
|
118
|
+
swapTxHash: z.ZodOptional<z.ZodString>;
|
|
119
|
+
swapTxUserOperationHash: z.ZodOptional<z.ZodString>;
|
|
120
|
+
approvalTxHash: z.ZodOptional<z.ZodString>;
|
|
121
|
+
approvalTxUserOperationHash: z.ZodOptional<z.ZodString>;
|
|
122
|
+
currentAllowance: z.ZodOptional<z.ZodString>;
|
|
123
|
+
requiredAllowance: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
currentAllowance?: string | undefined;
|
|
126
|
+
requiredAllowance?: string | undefined;
|
|
127
|
+
swapTxHash?: string | undefined;
|
|
128
|
+
swapTxUserOperationHash?: string | undefined;
|
|
129
|
+
approvalTxHash?: string | undefined;
|
|
130
|
+
approvalTxUserOperationHash?: string | undefined;
|
|
131
|
+
}, {
|
|
132
|
+
currentAllowance?: string | undefined;
|
|
133
|
+
requiredAllowance?: string | undefined;
|
|
134
|
+
swapTxHash?: string | undefined;
|
|
135
|
+
swapTxUserOperationHash?: string | undefined;
|
|
136
|
+
approvalTxHash?: string | undefined;
|
|
137
|
+
approvalTxUserOperationHash?: string | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,+BAA+B,QAAQ,CAAC;AAErD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4C9B,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsChC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;EA6B7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;EAE5B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EA4B/B,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeSuccessSchema = exports.executeFailSchema = exports.precheckFailSchema = exports.precheckSuccessSchema = exports.abilityParamsSchema = exports.DEFAULT_AERODROME_SWAP_SLIPPAGE = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.DEFAULT_AERODROME_SWAP_SLIPPAGE = 0.005;
|
|
6
|
+
exports.abilityParamsSchema = zod_1.z.object({
|
|
7
|
+
action: zod_1.z
|
|
8
|
+
.enum(['approve', 'swap'])
|
|
9
|
+
.describe('Dictates whether to perform an ERC20 approval or a swap'),
|
|
10
|
+
rpcUrl: zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.describe('An RPC endpoint for Base mainnet, used to check balances, allowances, and to send approval and swap transactions'),
|
|
13
|
+
tokenInAddress: zod_1.z.string().describe('The address of the token to swap from'),
|
|
14
|
+
tokenOutAddress: zod_1.z.string().describe('The address of the token to swap to'),
|
|
15
|
+
amountIn: zod_1.z
|
|
16
|
+
.string()
|
|
17
|
+
.describe('The amount to swap in the smallest unit (Example: 2123456 for 2.123456 USDC (6 decimals), or 10000000000000000 for 0.01 WETH (18 decimals))'),
|
|
18
|
+
slippage: zod_1.z
|
|
19
|
+
.number()
|
|
20
|
+
.min(0)
|
|
21
|
+
.max(1)
|
|
22
|
+
.default(exports.DEFAULT_AERODROME_SWAP_SLIPPAGE)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe('Slippage tolerance as decimal (e.g., 0.005 for 0.5%, default 0.5%)'),
|
|
25
|
+
gasBufferPercentage: zod_1.z
|
|
26
|
+
.number()
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Percent added to estimated gas limit (default 50)'),
|
|
29
|
+
baseFeePerGasBufferPercentage: zod_1.z
|
|
30
|
+
.number()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('Percent added to baseFeePerGas when computing maxFeePerGas (default 0)'),
|
|
33
|
+
alchemyGasSponsor: zod_1.z
|
|
34
|
+
.boolean()
|
|
35
|
+
.optional()
|
|
36
|
+
.default(false)
|
|
37
|
+
.describe('Whether to use Alchemy gas sponsorship for the transaction'),
|
|
38
|
+
alchemyGasSponsorApiKey: zod_1.z
|
|
39
|
+
.string()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('The API key for Alchemy gas sponsorship'),
|
|
42
|
+
alchemyGasSponsorPolicyId: zod_1.z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('The policy ID for Alchemy gas sponsorship'),
|
|
46
|
+
});
|
|
47
|
+
exports.precheckSuccessSchema = zod_1.z.object({
|
|
48
|
+
nativeTokenBalance: zod_1.z
|
|
49
|
+
.string()
|
|
50
|
+
.describe("The balance of the Vincent delegator's native token in the smallest unit used for gas fees if alchemyGasSponsor is not enabled")
|
|
51
|
+
.optional(),
|
|
52
|
+
tokenInAddress: zod_1.z
|
|
53
|
+
.string()
|
|
54
|
+
.describe('The address of the input token used for the swap')
|
|
55
|
+
.optional(),
|
|
56
|
+
tokenInBalance: zod_1.z
|
|
57
|
+
.string()
|
|
58
|
+
.describe("The balance of the Vincent delegator's input token in the smallest unit used for the swap")
|
|
59
|
+
.optional(),
|
|
60
|
+
currentTokenInAllowanceForSpender: zod_1.z
|
|
61
|
+
.string()
|
|
62
|
+
.describe("The current allowance of the Vincent delegator's input token in the smallest unit used for the swap"),
|
|
63
|
+
spenderAddress: zod_1.z
|
|
64
|
+
.string()
|
|
65
|
+
.describe('The Aerodrome Universal Router address that will be used for the swap'),
|
|
66
|
+
requiredTokenInAllowance: zod_1.z
|
|
67
|
+
.string()
|
|
68
|
+
.describe("The required allowance of the Vincent delegator's input token in the smallest unit for the swap for the ERC20 spender (Aerodrome Universal Router address)")
|
|
69
|
+
.optional(),
|
|
70
|
+
quote: zod_1.z
|
|
71
|
+
.object({
|
|
72
|
+
tokenInAmount: zod_1.z.string().describe('The amount of the input token for the swap'),
|
|
73
|
+
tokenOutAmount: zod_1.z.string().describe('The amount of the output token quoted for the swap'),
|
|
74
|
+
priceImpact: zod_1.z.string().describe('The price impact of the swap'),
|
|
75
|
+
})
|
|
76
|
+
.optional(),
|
|
77
|
+
});
|
|
78
|
+
exports.precheckFailSchema = zod_1.z.object({
|
|
79
|
+
reason: zod_1.z.string().describe('The reason the precheck failed'),
|
|
80
|
+
spenderAddress: zod_1.z
|
|
81
|
+
.string()
|
|
82
|
+
.describe('The Aerodrome router address that will be used to spend the ERC20 token')
|
|
83
|
+
.optional(),
|
|
84
|
+
tokenAddress: zod_1.z.string().describe('The address of the input token for the swap').optional(),
|
|
85
|
+
requiredTokenAmount: zod_1.z
|
|
86
|
+
.string()
|
|
87
|
+
.describe('The required amount of the input token in the smallest unit for the swap')
|
|
88
|
+
.optional(),
|
|
89
|
+
tokenBalance: zod_1.z
|
|
90
|
+
.string()
|
|
91
|
+
.describe("The balance of the Vincent delegator's input token in the smallest unit used for the swap")
|
|
92
|
+
.optional(),
|
|
93
|
+
currentAllowance: zod_1.z
|
|
94
|
+
.string()
|
|
95
|
+
.describe("The current allowance of the Vincent delegator's input token in the smallest unit used for the swap for the ERC20 spender (Aerodrome Universal Router address)")
|
|
96
|
+
.optional(),
|
|
97
|
+
requiredAllowance: zod_1.z
|
|
98
|
+
.string()
|
|
99
|
+
.describe("The required allowance of the Vincent delegator's input token in the smallest unit used for the swap for the ERC20 spender (Aerodrome Universal Router address)")
|
|
100
|
+
.optional(),
|
|
101
|
+
});
|
|
102
|
+
exports.executeFailSchema = zod_1.z.object({
|
|
103
|
+
reason: zod_1.z.string().optional().describe('The reason the execution failed'),
|
|
104
|
+
});
|
|
105
|
+
exports.executeSuccessSchema = zod_1.z.object({
|
|
106
|
+
swapTxHash: zod_1.z.string().describe('The hash of the swapping transaction on Aerodrome').optional(),
|
|
107
|
+
swapTxUserOperationHash: zod_1.z
|
|
108
|
+
.string()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe('The hash of the user operation that was executed'),
|
|
111
|
+
approvalTxHash: zod_1.z
|
|
112
|
+
.string()
|
|
113
|
+
.optional()
|
|
114
|
+
.describe('Transaction hash if a new approval was created, undefined if existing approval was used'),
|
|
115
|
+
approvalTxUserOperationHash: zod_1.z
|
|
116
|
+
.string()
|
|
117
|
+
.optional()
|
|
118
|
+
.describe('The hash of the user operation that was executed'),
|
|
119
|
+
currentAllowance: zod_1.z
|
|
120
|
+
.string()
|
|
121
|
+
.describe("The current allowance of the Vincent delegator's input token in the smallest unit used for the swap for the ERC20 spender (Aerodrome Universal Router address)")
|
|
122
|
+
.optional(),
|
|
123
|
+
requiredAllowance: zod_1.z
|
|
124
|
+
.string()
|
|
125
|
+
.describe("The required allowance of the Vincent delegator's input token in the smallest unit used for the swap for the ERC20 spender (Aerodrome Universal Router address)")
|
|
126
|
+
.optional(),
|
|
127
|
+
});
|
|
128
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/lib/schemas.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,+BAA+B,GAAG,KAAK,CAAC;AAExC,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,OAAC;SACN,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;SACzB,QAAQ,CAAC,yDAAyD,CAAC;IACtE,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,QAAQ,CACP,kHAAkH,CACnH;IACH,cAAc,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IAC5E,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;IAC3E,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,QAAQ,CACP,6IAA6I,CAC9I;IACH,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,CAAC,CAAC;SACN,OAAO,CAAC,uCAA+B,CAAC;SACxC,QAAQ,EAAE;SACV,QAAQ,CAAC,oEAAoE,CAAC;IACjF,mBAAmB,EAAE,OAAC;SACnB,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,mDAAmD,CAAC;IAChE,6BAA6B,EAA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E;SACV,QAAQ,CACP,yFAAyF,CAC1F;IACH,2BAA2B,EAAE,OAAC;SAC3B,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,kDAAkD,CAAC;IAC/D,gBAAgB,EAAE,OAAC;SAChB,MAAM,EAAE;SACR,QAAQ,CACP,gKAAgK,CACjK;SACA,QAAQ,EAAE;IACb,iBAAiB,EAAE,OAAC;SACjB,MAAM,EAAE;SACR,QAAQ,CACP,iKAAiK,CAClK;SACA,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ethers } from 'ethers';
|
|
2
|
+
export type CheckNativeTokenBalanceResult = CheckNativeTokenBalanceResultSuccess | CheckNativeTokenBalanceResultFailure;
|
|
3
|
+
export interface CheckNativeTokenBalanceResultSuccess {
|
|
4
|
+
success: true;
|
|
5
|
+
ethBalance: ethers.BigNumber;
|
|
6
|
+
}
|
|
7
|
+
export interface CheckNativeTokenBalanceResultFailure {
|
|
8
|
+
success: false;
|
|
9
|
+
reason: string;
|
|
10
|
+
}
|
|
11
|
+
export type CheckErc20BalanceResult = CheckErc20BalanceResultSuccess | CheckErc20BalanceResultFailure;
|
|
12
|
+
interface CheckErc20BalanceResultBase {
|
|
13
|
+
tokenAddress: string;
|
|
14
|
+
requiredTokenAmount: ethers.BigNumber;
|
|
15
|
+
tokenBalance: ethers.BigNumber;
|
|
16
|
+
}
|
|
17
|
+
export interface CheckErc20BalanceResultSuccess extends CheckErc20BalanceResultBase {
|
|
18
|
+
success: true;
|
|
19
|
+
}
|
|
20
|
+
export interface CheckErc20BalanceResultFailure extends CheckErc20BalanceResultBase {
|
|
21
|
+
success: false;
|
|
22
|
+
reason: string;
|
|
23
|
+
}
|
|
24
|
+
export type CheckErc20AllowanceResult = CheckErc20AllowanceResultSuccess | CheckErc20AllowanceResultFailure;
|
|
25
|
+
interface CheckErc20AllowanceResultBase {
|
|
26
|
+
spenderAddress: string;
|
|
27
|
+
tokenAddress: string;
|
|
28
|
+
requiredAllowance: ethers.BigNumber;
|
|
29
|
+
currentAllowance: ethers.BigNumber;
|
|
30
|
+
}
|
|
31
|
+
export interface CheckErc20AllowanceResultSuccess extends CheckErc20AllowanceResultBase {
|
|
32
|
+
success: true;
|
|
33
|
+
}
|
|
34
|
+
export interface CheckErc20AllowanceResultFailure extends CheckErc20AllowanceResultBase {
|
|
35
|
+
success: false;
|
|
36
|
+
reason: string;
|
|
37
|
+
}
|
|
38
|
+
export declare enum AbilityAction {
|
|
39
|
+
Swap = "swap",
|
|
40
|
+
Approve = "approve"
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,MAAM,6BAA6B,GACrC,oCAAoC,GACpC,oCAAoC,CAAC;AAEzC,MAAM,WAAW,oCAAoC;IACnD,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,oCAAoC;IACnD,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,uBAAuB,GAC/B,8BAA8B,GAC9B,8BAA8B,CAAC;AAEnC,UAAU,2BAA2B;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC,SAAS,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC,SAAS,CAAC;CAChC;AAED,MAAM,WAAW,8BAA+B,SAAQ,2BAA2B;IACjF,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,8BAA+B,SAAQ,2BAA2B;IACjF,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,yBAAyB,GACjC,gCAAgC,GAChC,gCAAgC,CAAC;AAErC,UAAU,6BAA6B;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC,SAAS,CAAC;IACpC,gBAAgB,EAAE,MAAM,CAAC,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,gCAAiC,SAAQ,6BAA6B;IACrF,OAAO,EAAE,IAAI,CAAC;CACf;AAED,MAAM,WAAW,gCAAiC,SAAQ,6BAA6B;IACrF,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,OAAO,YAAY;CACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbilityAction = void 0;
|
|
4
|
+
var AbilityAction;
|
|
5
|
+
(function (AbilityAction) {
|
|
6
|
+
AbilityAction["Swap"] = "swap";
|
|
7
|
+
AbilityAction["Approve"] = "approve";
|
|
8
|
+
})(AbilityAction || (exports.AbilityAction = AbilityAction = {}));
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":";;;AAuDA,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,oCAAmB,CAAA;AACrB,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export declare const bigintReplacer: (key: any, value: any) => any;
|
|
2
|
+
export declare const vincentAbility: import("@lit-protocol/vincent-ability-sdk").VincentAbility<import("zod").ZodObject<{
|
|
3
|
+
action: import("zod").ZodEnum<["approve", "swap"]>;
|
|
4
|
+
rpcUrl: import("zod").ZodString;
|
|
5
|
+
tokenInAddress: import("zod").ZodString;
|
|
6
|
+
tokenOutAddress: import("zod").ZodString;
|
|
7
|
+
amountIn: import("zod").ZodString;
|
|
8
|
+
slippage: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>;
|
|
9
|
+
gasBufferPercentage: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
10
|
+
baseFeePerGasBufferPercentage: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
11
|
+
alchemyGasSponsor: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
|
|
12
|
+
alchemyGasSponsorApiKey: import("zod").ZodOptional<import("zod").ZodString>;
|
|
13
|
+
alchemyGasSponsorPolicyId: import("zod").ZodOptional<import("zod").ZodString>;
|
|
14
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
15
|
+
action: "approve" | "swap";
|
|
16
|
+
rpcUrl: string;
|
|
17
|
+
tokenInAddress: string;
|
|
18
|
+
tokenOutAddress: string;
|
|
19
|
+
amountIn: string;
|
|
20
|
+
alchemyGasSponsor: boolean;
|
|
21
|
+
slippage?: number | undefined;
|
|
22
|
+
gasBufferPercentage?: number | undefined;
|
|
23
|
+
baseFeePerGasBufferPercentage?: number | undefined;
|
|
24
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
25
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
action: "approve" | "swap";
|
|
28
|
+
rpcUrl: string;
|
|
29
|
+
tokenInAddress: string;
|
|
30
|
+
tokenOutAddress: string;
|
|
31
|
+
amountIn: string;
|
|
32
|
+
slippage?: number | undefined;
|
|
33
|
+
gasBufferPercentage?: number | undefined;
|
|
34
|
+
baseFeePerGasBufferPercentage?: number | undefined;
|
|
35
|
+
alchemyGasSponsor?: boolean | undefined;
|
|
36
|
+
alchemyGasSponsorApiKey?: string | undefined;
|
|
37
|
+
alchemyGasSponsorPolicyId?: string | undefined;
|
|
38
|
+
}>, string, import("node_modules/@lit-protocol/vincent-ability-sdk/dist/src/lib/abilityCore/helpers").AbilityPolicyMap<readonly [], never>, {}, import("zod").ZodObject<{
|
|
39
|
+
swapTxHash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
40
|
+
swapTxUserOperationHash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
41
|
+
approvalTxHash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
42
|
+
approvalTxUserOperationHash: import("zod").ZodOptional<import("zod").ZodString>;
|
|
43
|
+
currentAllowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
44
|
+
requiredAllowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
45
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
46
|
+
currentAllowance?: string | undefined;
|
|
47
|
+
requiredAllowance?: string | undefined;
|
|
48
|
+
swapTxHash?: string | undefined;
|
|
49
|
+
swapTxUserOperationHash?: string | undefined;
|
|
50
|
+
approvalTxHash?: string | undefined;
|
|
51
|
+
approvalTxUserOperationHash?: string | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
currentAllowance?: string | undefined;
|
|
54
|
+
requiredAllowance?: string | undefined;
|
|
55
|
+
swapTxHash?: string | undefined;
|
|
56
|
+
swapTxUserOperationHash?: string | undefined;
|
|
57
|
+
approvalTxHash?: string | undefined;
|
|
58
|
+
approvalTxUserOperationHash?: string | undefined;
|
|
59
|
+
}>, import("zod").ZodObject<{
|
|
60
|
+
reason: import("zod").ZodOptional<import("zod").ZodString>;
|
|
61
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
62
|
+
reason?: string | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
reason?: string | undefined;
|
|
65
|
+
}>, import("zod").ZodObject<{
|
|
66
|
+
nativeTokenBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
67
|
+
tokenInAddress: import("zod").ZodOptional<import("zod").ZodString>;
|
|
68
|
+
tokenInBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
69
|
+
currentTokenInAllowanceForSpender: import("zod").ZodString;
|
|
70
|
+
spenderAddress: import("zod").ZodString;
|
|
71
|
+
requiredTokenInAllowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
72
|
+
quote: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
73
|
+
tokenInAmount: import("zod").ZodString;
|
|
74
|
+
tokenOutAmount: import("zod").ZodString;
|
|
75
|
+
priceImpact: import("zod").ZodString;
|
|
76
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
77
|
+
tokenInAmount: string;
|
|
78
|
+
tokenOutAmount: string;
|
|
79
|
+
priceImpact: string;
|
|
80
|
+
}, {
|
|
81
|
+
tokenInAmount: string;
|
|
82
|
+
tokenOutAmount: string;
|
|
83
|
+
priceImpact: string;
|
|
84
|
+
}>>;
|
|
85
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
86
|
+
currentTokenInAllowanceForSpender: string;
|
|
87
|
+
spenderAddress: string;
|
|
88
|
+
tokenInAddress?: string | undefined;
|
|
89
|
+
nativeTokenBalance?: string | undefined;
|
|
90
|
+
tokenInBalance?: string | undefined;
|
|
91
|
+
requiredTokenInAllowance?: string | undefined;
|
|
92
|
+
quote?: {
|
|
93
|
+
tokenInAmount: string;
|
|
94
|
+
tokenOutAmount: string;
|
|
95
|
+
priceImpact: string;
|
|
96
|
+
} | undefined;
|
|
97
|
+
}, {
|
|
98
|
+
currentTokenInAllowanceForSpender: string;
|
|
99
|
+
spenderAddress: string;
|
|
100
|
+
tokenInAddress?: string | undefined;
|
|
101
|
+
nativeTokenBalance?: string | undefined;
|
|
102
|
+
tokenInBalance?: string | undefined;
|
|
103
|
+
requiredTokenInAllowance?: string | undefined;
|
|
104
|
+
quote?: {
|
|
105
|
+
tokenInAmount: string;
|
|
106
|
+
tokenOutAmount: string;
|
|
107
|
+
priceImpact: string;
|
|
108
|
+
} | undefined;
|
|
109
|
+
}>, import("zod").ZodObject<{
|
|
110
|
+
reason: import("zod").ZodString;
|
|
111
|
+
spenderAddress: import("zod").ZodOptional<import("zod").ZodString>;
|
|
112
|
+
tokenAddress: import("zod").ZodOptional<import("zod").ZodString>;
|
|
113
|
+
requiredTokenAmount: import("zod").ZodOptional<import("zod").ZodString>;
|
|
114
|
+
tokenBalance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
115
|
+
currentAllowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
116
|
+
requiredAllowance: import("zod").ZodOptional<import("zod").ZodString>;
|
|
117
|
+
}, "strip", import("zod").ZodTypeAny, {
|
|
118
|
+
reason: string;
|
|
119
|
+
spenderAddress?: string | undefined;
|
|
120
|
+
tokenAddress?: string | undefined;
|
|
121
|
+
requiredTokenAmount?: string | undefined;
|
|
122
|
+
tokenBalance?: string | undefined;
|
|
123
|
+
currentAllowance?: string | undefined;
|
|
124
|
+
requiredAllowance?: string | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
reason: string;
|
|
127
|
+
spenderAddress?: string | undefined;
|
|
128
|
+
tokenAddress?: string | undefined;
|
|
129
|
+
requiredTokenAmount?: string | undefined;
|
|
130
|
+
tokenBalance?: string | undefined;
|
|
131
|
+
currentAllowance?: string | undefined;
|
|
132
|
+
requiredAllowance?: string | undefined;
|
|
133
|
+
}>>;
|
|
134
|
+
//# sourceMappingURL=vincent-ability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vincent-ability.d.ts","sourceRoot":"","sources":["../../../src/lib/vincent-ability.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,EAAE,OAAO,GAAG,QAElD,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+XzB,CAAC"}
|