@coinbase/agentkit 0.2.3-nightly.20250314.36 → 0.2.3-nightly.20250316.38
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.
|
@@ -13,11 +13,12 @@ exports.morphoActionProvider = exports.MorphoActionProvider = exports.SUPPORTED_
|
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
14
|
const decimal_js_1 = require("decimal.js");
|
|
15
15
|
const viem_1 = require("viem");
|
|
16
|
+
const constants_1 = require("../erc20/constants");
|
|
16
17
|
const actionProvider_1 = require("../actionProvider");
|
|
17
18
|
const wallet_providers_1 = require("../../wallet-providers");
|
|
18
19
|
const actionDecorator_1 = require("../actionDecorator");
|
|
19
20
|
const utils_1 = require("../../utils");
|
|
20
|
-
const
|
|
21
|
+
const constants_2 = require("./constants");
|
|
21
22
|
const schemas_1 = require("./schemas");
|
|
22
23
|
exports.SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
|
|
23
24
|
/**
|
|
@@ -50,13 +51,19 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
|
|
|
50
51
|
return "Error: Assets amount must be greater than 0";
|
|
51
52
|
}
|
|
52
53
|
try {
|
|
53
|
-
const
|
|
54
|
+
const decimals = await wallet.readContract({
|
|
55
|
+
address: args.tokenAddress,
|
|
56
|
+
abi: constants_1.abi,
|
|
57
|
+
functionName: "decimals",
|
|
58
|
+
args: [],
|
|
59
|
+
});
|
|
60
|
+
const atomicAssets = (0, viem_1.parseUnits)(args.assets, decimals);
|
|
54
61
|
const approvalResult = await (0, utils_1.approve)(wallet, args.tokenAddress, args.vaultAddress, atomicAssets);
|
|
55
62
|
if (approvalResult.startsWith("Error")) {
|
|
56
63
|
return `Error approving Morpho Vault as spender: ${approvalResult}`;
|
|
57
64
|
}
|
|
58
65
|
const data = (0, viem_1.encodeFunctionData)({
|
|
59
|
-
abi:
|
|
66
|
+
abi: constants_2.METAMORPHO_ABI,
|
|
60
67
|
functionName: "deposit",
|
|
61
68
|
args: [atomicAssets, args.receiver],
|
|
62
69
|
});
|
|
@@ -84,7 +91,7 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
|
|
|
84
91
|
}
|
|
85
92
|
try {
|
|
86
93
|
const data = (0, viem_1.encodeFunctionData)({
|
|
87
|
-
abi:
|
|
94
|
+
abi: constants_2.METAMORPHO_ABI,
|
|
88
95
|
functionName: "withdraw",
|
|
89
96
|
args: [BigInt(args.assets), args.receiver, args.receiver],
|
|
90
97
|
});
|
|
@@ -11,6 +11,7 @@ const MOCK_RECEIVER_ID = "0x9876543210987654321098765432109876543210";
|
|
|
11
11
|
const MOCK_TOKEN_ADDRESS = "0x4200000000000000000000000000000000000006";
|
|
12
12
|
const MOCK_TX_HASH = "0xabcdef1234567890";
|
|
13
13
|
const MOCK_RECEIPT = { status: 1, blockNumber: 1234567 };
|
|
14
|
+
const MOCK_DECIMALS = 18;
|
|
14
15
|
jest.mock("../../utils");
|
|
15
16
|
const mockApprove = utils_1.approve;
|
|
16
17
|
describe("Morpho Action Provider", () => {
|
|
@@ -22,6 +23,7 @@ describe("Morpho Action Provider", () => {
|
|
|
22
23
|
getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm", networkId: "1" }),
|
|
23
24
|
sendTransaction: jest.fn().mockResolvedValue(MOCK_TX_HASH),
|
|
24
25
|
waitForTransactionReceipt: jest.fn().mockResolvedValue(MOCK_RECEIPT),
|
|
26
|
+
readContract: jest.fn().mockResolvedValue(MOCK_DECIMALS),
|
|
25
27
|
};
|
|
26
28
|
mockApprove.mockResolvedValue("Approval successful");
|
|
27
29
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@coinbase/agentkit",
|
|
3
3
|
"description": "Coinbase AgentKit core primitives",
|
|
4
4
|
"repository": "https://github.com/coinbase/agentkit",
|
|
5
|
-
"version": "0.2.3-nightly.
|
|
5
|
+
"version": "0.2.3-nightly.20250316.38",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|