@coinbase/agentkit 0.0.0-nightly-20250807210405 → 0.0.0-nightly-20250815210416
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/README.md +106 -54
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +43 -0
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +151 -0
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +242 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +42 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +132 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +199 -0
- package/dist/action-providers/cdp/index.d.ts +3 -0
- package/dist/action-providers/cdp/index.js +3 -0
- package/dist/action-providers/cdp/schemas.d.ts +29 -0
- package/dist/action-providers/cdp/schemas.js +32 -1
- package/dist/action-providers/cdp/spendPermissionUtils.d.ts +24 -0
- package/dist/action-providers/cdp/spendPermissionUtils.js +66 -0
- package/dist/action-providers/flaunch/flaunchActionProvider.js +3 -11
- package/dist/action-providers/flaunch/flaunchActionProvider.test.js +5 -0
- package/dist/action-providers/index.d.ts +1 -0
- package/dist/action-providers/index.js +1 -0
- package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
- package/dist/action-providers/truemarkets/truemarketsActionProvider.js +10 -31
- package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
- package/dist/action-providers/zerion/constants.d.ts +1 -0
- package/dist/action-providers/zerion/constants.js +4 -0
- package/dist/action-providers/zerion/index.d.ts +2 -0
- package/dist/action-providers/zerion/index.js +18 -0
- package/dist/action-providers/zerion/schemas.d.ts +11 -0
- package/dist/action-providers/zerion/schemas.js +15 -0
- package/dist/action-providers/zerion/types.d.ts +125 -0
- package/dist/action-providers/zerion/types.js +16 -0
- package/dist/action-providers/zerion/utils.d.ts +3 -0
- package/dist/action-providers/zerion/utils.js +45 -0
- package/dist/action-providers/zerion/zerionActionProvider.d.ts +57 -0
- package/dist/action-providers/zerion/zerionActionProvider.js +159 -0
- package/dist/action-providers/zerion/zerionActionProvider.test.d.ts +1 -0
- package/dist/action-providers/zerion/zerionActionProvider.test.js +213 -0
- package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +7 -1
- package/dist/wallet-providers/cdpEvmWalletProvider.js +10 -1
- package/dist/wallet-providers/cdpShared.d.ts +5 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +9 -2
- package/dist/wallet-providers/cdpSmartWalletProvider.js +20 -12
- package/dist/wallet-providers/evmWalletProvider.d.ts +5 -1
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +8 -1
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +11 -1
- package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +11 -1
- package/dist/wallet-providers/legacyCdpWalletProvider.js +10 -1
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +9 -1
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +10 -1
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
- package/dist/wallet-providers/viemWalletProvider.d.ts +7 -1
- package/dist/wallet-providers/viemWalletProvider.js +8 -0
- package/dist/wallet-providers/zeroDevWalletProvider.d.ts +9 -1
- package/dist/wallet-providers/zeroDevWalletProvider.js +10 -1
- package/package.json +2 -2
|
@@ -4,25 +4,13 @@ import { Network } from "../../network";
|
|
|
4
4
|
import { GetTruthMarketsSchema, GetTruthMarketDetailsSchema } from "./schemas";
|
|
5
5
|
import { EvmWalletProvider } from "../../wallet-providers";
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
*/
|
|
9
|
-
export interface TrueMarketsActionProviderConfig {
|
|
10
|
-
/**
|
|
11
|
-
* RPC URL for creating the Viem public client
|
|
12
|
-
*/
|
|
13
|
-
RPC_URL?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* TrueMarketsActionProvider provides actions to interact with TrueMarkets contracts.
|
|
7
|
+
* Action provider for TrueMarkets interactions.
|
|
17
8
|
*/
|
|
18
9
|
export declare class TrueMarketsActionProvider extends ActionProvider<EvmWalletProvider> {
|
|
19
|
-
#private;
|
|
20
10
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @param config - The configuration options for the TrueMarketsActionProvider.
|
|
11
|
+
* Creates a new TrueMarkets action provider.
|
|
24
12
|
*/
|
|
25
|
-
constructor(
|
|
13
|
+
constructor();
|
|
26
14
|
/**
|
|
27
15
|
* Gets active markets from the TruthMarketManager contract.
|
|
28
16
|
*
|
|
@@ -48,4 +36,4 @@ export declare class TrueMarketsActionProvider extends ActionProvider<EvmWalletP
|
|
|
48
36
|
*/
|
|
49
37
|
supportsNetwork: (network: Network) => boolean;
|
|
50
38
|
}
|
|
51
|
-
export declare const truemarketsActionProvider: (
|
|
39
|
+
export declare const truemarketsActionProvider: () => TrueMarketsActionProvider;
|
|
@@ -8,18 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
15
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
16
|
-
};
|
|
17
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
18
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
19
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
20
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
21
|
-
};
|
|
22
|
-
var _TrueMarketsActionProvider_publicClient;
|
|
23
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
12
|
exports.truemarketsActionProvider = exports.TrueMarketsActionProvider = void 0;
|
|
25
13
|
const zod_1 = require("zod");
|
|
@@ -30,19 +18,15 @@ const constants_1 = require("./constants");
|
|
|
30
18
|
const constants_2 = require("../erc20/constants");
|
|
31
19
|
const wallet_providers_1 = require("../../wallet-providers");
|
|
32
20
|
const viem_1 = require("viem");
|
|
33
|
-
const chains_1 = require("viem/chains");
|
|
34
21
|
/**
|
|
35
|
-
*
|
|
22
|
+
* Action provider for TrueMarkets interactions.
|
|
36
23
|
*/
|
|
37
24
|
class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
38
25
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* @param config - The configuration options for the TrueMarketsActionProvider.
|
|
26
|
+
* Creates a new TrueMarkets action provider.
|
|
42
27
|
*/
|
|
43
|
-
constructor(
|
|
28
|
+
constructor() {
|
|
44
29
|
super("truemarkets", []);
|
|
45
|
-
_TrueMarketsActionProvider_publicClient.set(this, void 0);
|
|
46
30
|
/**
|
|
47
31
|
* Checks if the TrueMarkets action provider supports the given network.
|
|
48
32
|
* Currently only supports Base mainnet.
|
|
@@ -51,10 +35,6 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
51
35
|
* @returns True if the TrueMarkets action provider supports the network, false otherwise.
|
|
52
36
|
*/
|
|
53
37
|
this.supportsNetwork = (network) => network.networkId === "base-mainnet";
|
|
54
|
-
__classPrivateFieldSet(this, _TrueMarketsActionProvider_publicClient, (0, viem_1.createPublicClient)({
|
|
55
|
-
chain: chains_1.base,
|
|
56
|
-
transport: config?.RPC_URL ? (0, viem_1.http)(config.RPC_URL) : (0, viem_1.http)(),
|
|
57
|
-
}), "f");
|
|
58
38
|
}
|
|
59
39
|
/**
|
|
60
40
|
* Gets active markets from the TruthMarketManager contract.
|
|
@@ -105,7 +85,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
105
85
|
functionName: "getActiveMarketAddress",
|
|
106
86
|
args: [BigInt(index)],
|
|
107
87
|
}));
|
|
108
|
-
const marketAddresses = await
|
|
88
|
+
const marketAddresses = await walletProvider.getPublicClient().multicall({
|
|
109
89
|
contracts: addressCalls,
|
|
110
90
|
});
|
|
111
91
|
// Filter out errors and extract results
|
|
@@ -124,7 +104,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
124
104
|
abi: constants_1.TruthMarketABI,
|
|
125
105
|
functionName: "marketQuestion",
|
|
126
106
|
}));
|
|
127
|
-
const marketQuestionsResult = await
|
|
107
|
+
const marketQuestionsResult = await walletProvider.getPublicClient().multicall({
|
|
128
108
|
contracts: questionCalls,
|
|
129
109
|
});
|
|
130
110
|
// Create market objects mapping indices to addresses and questions
|
|
@@ -175,7 +155,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
175
155
|
});
|
|
176
156
|
}
|
|
177
157
|
try {
|
|
178
|
-
marketAddress = (await
|
|
158
|
+
marketAddress = (await walletProvider.getPublicClient().readContract({
|
|
179
159
|
address: constants_1.TruthMarketManager_ADDRESS,
|
|
180
160
|
abi: constants_1.TruthMarketManagerABI,
|
|
181
161
|
functionName: "getActiveMarketAddress",
|
|
@@ -227,7 +207,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
227
207
|
functionName: "winningPosition",
|
|
228
208
|
},
|
|
229
209
|
];
|
|
230
|
-
const basicInfoResults = await
|
|
210
|
+
const basicInfoResults = await walletProvider.getPublicClient().multicall({
|
|
231
211
|
contracts: basicInfoCalls,
|
|
232
212
|
});
|
|
233
213
|
// Extract results, handling potential errors
|
|
@@ -279,7 +259,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
279
259
|
functionName: "slot0",
|
|
280
260
|
},
|
|
281
261
|
];
|
|
282
|
-
const poolInfoResults = await
|
|
262
|
+
const poolInfoResults = await walletProvider.getPublicClient().multicall({
|
|
283
263
|
contracts: poolInfoCalls,
|
|
284
264
|
});
|
|
285
265
|
if (poolInfoResults.some(result => result.status === "failure")) {
|
|
@@ -331,7 +311,7 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
331
311
|
args: [noPool],
|
|
332
312
|
},
|
|
333
313
|
];
|
|
334
|
-
const balanceResults = await
|
|
314
|
+
const balanceResults = await walletProvider.getPublicClient().multicall({
|
|
335
315
|
contracts: balanceCalls,
|
|
336
316
|
});
|
|
337
317
|
if (balanceResults.some(result => result.status === "failure")) {
|
|
@@ -430,7 +410,6 @@ class TrueMarketsActionProvider extends actionProvider_1.ActionProvider {
|
|
|
430
410
|
}
|
|
431
411
|
}
|
|
432
412
|
exports.TrueMarketsActionProvider = TrueMarketsActionProvider;
|
|
433
|
-
_TrueMarketsActionProvider_publicClient = new WeakMap();
|
|
434
413
|
__decorate([
|
|
435
414
|
(0, actionDecorator_1.CreateAction)({
|
|
436
415
|
name: "get_prediction_markets",
|
|
@@ -465,5 +444,5 @@ __decorate([
|
|
|
465
444
|
__metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
|
|
466
445
|
__metadata("design:returntype", Promise)
|
|
467
446
|
], TrueMarketsActionProvider.prototype, "getPredictionMarketDetails", null);
|
|
468
|
-
const truemarketsActionProvider = (
|
|
447
|
+
const truemarketsActionProvider = () => new TrueMarketsActionProvider();
|
|
469
448
|
exports.truemarketsActionProvider = truemarketsActionProvider;
|
|
@@ -2,29 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const truemarketsActionProvider_1 = require("./truemarketsActionProvider");
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
|
-
const viem_1 = require("viem");
|
|
6
|
-
// Mock viem's createPublicClient
|
|
7
|
-
jest.mock("viem", () => {
|
|
8
|
-
const originalModule = jest.requireActual("viem");
|
|
9
|
-
return {
|
|
10
|
-
...originalModule,
|
|
11
|
-
createPublicClient: jest.fn().mockImplementation(() => ({
|
|
12
|
-
// Mock public client methods as needed
|
|
13
|
-
multicall: jest.fn().mockImplementation(({ contracts }) => {
|
|
14
|
-
// Create mock responses with success status
|
|
15
|
-
return contracts.map(() => ({
|
|
16
|
-
status: "success",
|
|
17
|
-
result: "mock result",
|
|
18
|
-
}));
|
|
19
|
-
}),
|
|
20
|
-
readContract: jest.fn(),
|
|
21
|
-
})),
|
|
22
|
-
http: jest.fn().mockImplementation(url => ({ url })),
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
5
|
describe("TrueMarketsActionProvider", () => {
|
|
26
6
|
let provider;
|
|
27
7
|
let mockWallet;
|
|
8
|
+
let publicClientMock;
|
|
28
9
|
// Mock addresses and data for tests
|
|
29
10
|
const MOCK_MARKET_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
30
11
|
const MOCK_YES_POOL_ADDRESS = "0x2345678901234567890123456789012345678901";
|
|
@@ -36,26 +17,22 @@ describe("TrueMarketsActionProvider", () => {
|
|
|
36
17
|
const MOCK_MARKET_SOURCE = "Test source";
|
|
37
18
|
const MOCK_STATUS_NUM = 0n; // Created status
|
|
38
19
|
const MOCK_END_OF_TRADING = 1717171717n; // Unix timestamp
|
|
39
|
-
describe("constructor", () => {
|
|
40
|
-
it("should use the provided RPC_URL for the public client", () => {
|
|
41
|
-
const customRpcUrl = "https://custom-rpc.example.com";
|
|
42
|
-
(0, truemarketsActionProvider_1.truemarketsActionProvider)({ RPC_URL: customRpcUrl });
|
|
43
|
-
// Verify createPublicClient was called with the correct URL
|
|
44
|
-
expect(viem_1.createPublicClient).toHaveBeenCalledWith(expect.objectContaining({
|
|
45
|
-
chain: expect.anything(),
|
|
46
|
-
transport: expect.objectContaining({ url: customRpcUrl }),
|
|
47
|
-
}));
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
20
|
beforeEach(() => {
|
|
51
21
|
jest.clearAllMocks();
|
|
52
22
|
provider = (0, truemarketsActionProvider_1.truemarketsActionProvider)();
|
|
23
|
+
publicClientMock = {
|
|
24
|
+
multicall: jest
|
|
25
|
+
.fn()
|
|
26
|
+
.mockImplementation(({ contracts }) => contracts.map(() => ({ status: "success", result: "mock result" }))),
|
|
27
|
+
readContract: jest.fn(),
|
|
28
|
+
};
|
|
53
29
|
mockWallet = {
|
|
54
30
|
readContract: jest.fn(),
|
|
55
31
|
getName: jest.fn().mockReturnValue("evm_wallet_provider"),
|
|
56
32
|
getNetwork: jest.fn().mockReturnValue({
|
|
57
33
|
networkId: "base-mainnet",
|
|
58
34
|
}),
|
|
35
|
+
getPublicClient: jest.fn().mockReturnValue(publicClientMock),
|
|
59
36
|
};
|
|
60
37
|
});
|
|
61
38
|
afterEach(() => {
|
|
@@ -134,8 +111,9 @@ describe("TrueMarketsActionProvider", () => {
|
|
|
134
111
|
describe("getPredictionMarketDetails", () => {
|
|
135
112
|
let mockPublicClient;
|
|
136
113
|
beforeEach(() => {
|
|
137
|
-
//
|
|
138
|
-
mockPublicClient =
|
|
114
|
+
// Use the shared mocked public client
|
|
115
|
+
mockPublicClient = publicClientMock;
|
|
116
|
+
mockPublicClient.multicall.mockReset();
|
|
139
117
|
// Setup multicall mock responses
|
|
140
118
|
mockPublicClient.multicall
|
|
141
119
|
// Basic info calls
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ZERION_V1_BASE_URL = "https://api.zerion.io/v1";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./zerionActionProvider"), exports);
|
|
18
|
+
__exportStar(require("./schemas"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Input schema for getting wallet portfolio.
|
|
4
|
+
*/
|
|
5
|
+
export declare const GetWalletPortfolioSchema: z.ZodObject<{
|
|
6
|
+
walletAddress: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
walletAddress: string;
|
|
9
|
+
}, {
|
|
10
|
+
walletAddress: string;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetWalletPortfolioSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Input schema for getting wallet portfolio.
|
|
7
|
+
*/
|
|
8
|
+
exports.GetWalletPortfolioSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
walletAddress: zod_1.z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("The wallet address to fetch portfolio for. Defaults is empty string, which will raise an error later if not provided."),
|
|
13
|
+
})
|
|
14
|
+
.strip()
|
|
15
|
+
.describe("Input schema for fetching wallet portfolio");
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export interface ZerionFungiblePositionsResponse {
|
|
2
|
+
links: {
|
|
3
|
+
self: string;
|
|
4
|
+
};
|
|
5
|
+
data: ZerionFungiblePosition[];
|
|
6
|
+
}
|
|
7
|
+
export interface ZerionPortfolioResponse {
|
|
8
|
+
links: {
|
|
9
|
+
self: string;
|
|
10
|
+
};
|
|
11
|
+
data: ZerionPortfolio;
|
|
12
|
+
}
|
|
13
|
+
export interface ZerionPortfolio {
|
|
14
|
+
type: string;
|
|
15
|
+
id: string;
|
|
16
|
+
attributes: PortfolioAttributes;
|
|
17
|
+
}
|
|
18
|
+
export interface PortfolioAttributes {
|
|
19
|
+
positions_distribution_by_type: {
|
|
20
|
+
wallet: number;
|
|
21
|
+
deposited: number;
|
|
22
|
+
borrowed: number;
|
|
23
|
+
locked: number;
|
|
24
|
+
staked: number;
|
|
25
|
+
};
|
|
26
|
+
positions_distribution_by_chain: {
|
|
27
|
+
[key: string]: number;
|
|
28
|
+
};
|
|
29
|
+
total: {
|
|
30
|
+
positions: number;
|
|
31
|
+
};
|
|
32
|
+
changes: {
|
|
33
|
+
absolute_1d: number;
|
|
34
|
+
percent_1d: number;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface ZerionFungiblePosition {
|
|
38
|
+
type: string;
|
|
39
|
+
id: string;
|
|
40
|
+
attributes: FungibleAttributes;
|
|
41
|
+
relationships: Relationships;
|
|
42
|
+
}
|
|
43
|
+
export interface FungibleAttributes {
|
|
44
|
+
parent: null | string;
|
|
45
|
+
protocol: null | string;
|
|
46
|
+
pool_address?: string;
|
|
47
|
+
group_id?: string;
|
|
48
|
+
name: string;
|
|
49
|
+
position_type: PositionType;
|
|
50
|
+
quantity: Quantity;
|
|
51
|
+
value: number | null;
|
|
52
|
+
price: number;
|
|
53
|
+
changes: Changes | null;
|
|
54
|
+
fungible_info: FungibleInfo;
|
|
55
|
+
flags: AttributesFlags;
|
|
56
|
+
updated_at: Date;
|
|
57
|
+
updated_at_block: number | null;
|
|
58
|
+
application_metadata?: ApplicationMetadata;
|
|
59
|
+
}
|
|
60
|
+
export interface ApplicationMetadata {
|
|
61
|
+
name: string;
|
|
62
|
+
icon: Icon;
|
|
63
|
+
url: string;
|
|
64
|
+
}
|
|
65
|
+
export interface Icon {
|
|
66
|
+
url: string;
|
|
67
|
+
}
|
|
68
|
+
export interface Changes {
|
|
69
|
+
absolute_1d: number;
|
|
70
|
+
percent_1d: number;
|
|
71
|
+
}
|
|
72
|
+
export interface AttributesFlags {
|
|
73
|
+
displayable: boolean;
|
|
74
|
+
is_trash: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface FungibleInfo {
|
|
77
|
+
name: string;
|
|
78
|
+
symbol: string;
|
|
79
|
+
icon: Icon | null;
|
|
80
|
+
flags: FungibleInfoFlags;
|
|
81
|
+
implementations: Implementation[];
|
|
82
|
+
}
|
|
83
|
+
export interface FungibleInfoFlags {
|
|
84
|
+
verified: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface Implementation {
|
|
87
|
+
chain_id: string;
|
|
88
|
+
address: null | string;
|
|
89
|
+
decimals: number;
|
|
90
|
+
}
|
|
91
|
+
export declare enum PositionType {
|
|
92
|
+
Deposit = "deposit",
|
|
93
|
+
Reward = "reward",
|
|
94
|
+
Staked = "staked",
|
|
95
|
+
Wallet = "wallet"
|
|
96
|
+
}
|
|
97
|
+
export interface Quantity {
|
|
98
|
+
int: string;
|
|
99
|
+
decimals: number;
|
|
100
|
+
float: number;
|
|
101
|
+
numeric: string;
|
|
102
|
+
}
|
|
103
|
+
export interface Relationships {
|
|
104
|
+
chain: Chain;
|
|
105
|
+
dapp?: Dapp;
|
|
106
|
+
fungible: Chain;
|
|
107
|
+
}
|
|
108
|
+
export interface Dapp {
|
|
109
|
+
data: Data;
|
|
110
|
+
}
|
|
111
|
+
export interface Chain {
|
|
112
|
+
links: {
|
|
113
|
+
related: string;
|
|
114
|
+
};
|
|
115
|
+
data: Data;
|
|
116
|
+
}
|
|
117
|
+
export interface Data {
|
|
118
|
+
type: DataType;
|
|
119
|
+
id: string;
|
|
120
|
+
}
|
|
121
|
+
export declare enum DataType {
|
|
122
|
+
Chains = "chains",
|
|
123
|
+
Dapps = "dapps",
|
|
124
|
+
Fungibles = "fungibles"
|
|
125
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataType = exports.PositionType = void 0;
|
|
4
|
+
var PositionType;
|
|
5
|
+
(function (PositionType) {
|
|
6
|
+
PositionType["Deposit"] = "deposit";
|
|
7
|
+
PositionType["Reward"] = "reward";
|
|
8
|
+
PositionType["Staked"] = "staked";
|
|
9
|
+
PositionType["Wallet"] = "wallet";
|
|
10
|
+
})(PositionType || (exports.PositionType = PositionType = {}));
|
|
11
|
+
var DataType;
|
|
12
|
+
(function (DataType) {
|
|
13
|
+
DataType["Chains"] = "chains";
|
|
14
|
+
DataType["Dapps"] = "dapps";
|
|
15
|
+
DataType["Fungibles"] = "fungibles";
|
|
16
|
+
})(DataType || (exports.DataType = DataType = {}));
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPositionsData = exports.formatPortfolioData = void 0;
|
|
4
|
+
const formatPortfolioData = (data) => {
|
|
5
|
+
// Total value
|
|
6
|
+
const totalValue = data.attributes.total.positions;
|
|
7
|
+
const totalValueStr = `$${totalValue.toFixed(2)}`;
|
|
8
|
+
// 24h change
|
|
9
|
+
const changePercent = data.attributes.changes.percent_1d;
|
|
10
|
+
const changeStr = `${changePercent.toFixed(2)}%`;
|
|
11
|
+
// Positions by type (filter out 0)
|
|
12
|
+
const types = Object.entries(data.attributes.positions_distribution_by_type)
|
|
13
|
+
.filter(([_, v]) => v > 0)
|
|
14
|
+
.map(([type, value]) => `${type}: $${value.toFixed(2)}`)
|
|
15
|
+
.join(", ");
|
|
16
|
+
// Positions by chain (top 5 by value)
|
|
17
|
+
const topChains = Object.entries(data.attributes.positions_distribution_by_chain)
|
|
18
|
+
.sort(([, a], [, b]) => b - a)
|
|
19
|
+
.slice(0, 5)
|
|
20
|
+
.map(([chain, value]) => `${chain}: $${value.toFixed(2)}`)
|
|
21
|
+
.join(", ");
|
|
22
|
+
// Final summary string
|
|
23
|
+
return `Wallet Portfolio Overview:
|
|
24
|
+
- Total Value: ${totalValueStr}
|
|
25
|
+
- 24h Change: ${changeStr}
|
|
26
|
+
- Position Types: ${types}
|
|
27
|
+
- Top Chains: ${topChains}`;
|
|
28
|
+
};
|
|
29
|
+
exports.formatPortfolioData = formatPortfolioData;
|
|
30
|
+
const formatPositionsData = (data) => {
|
|
31
|
+
const filtered = data.filter(pos => pos.attributes.value !== null);
|
|
32
|
+
// Sort by value (descending)
|
|
33
|
+
const sorted = filtered.sort((a, b) => b.attributes.value - a.attributes.value);
|
|
34
|
+
const lines = [];
|
|
35
|
+
let totalValue = 0;
|
|
36
|
+
for (const pos of sorted) {
|
|
37
|
+
const { value, position_type, fungible_info, application_metadata } = pos.attributes;
|
|
38
|
+
const chain = pos.relationships.chain.data.id;
|
|
39
|
+
const protocolLine = application_metadata?.name ? `via ${application_metadata.name}` : "";
|
|
40
|
+
lines.push(`- ${fungible_info.symbol} (${fungible_info.name}) on ${chain} — $${value.toFixed(2)} [${position_type}${protocolLine ? " " + protocolLine : ""}]`);
|
|
41
|
+
totalValue += value;
|
|
42
|
+
}
|
|
43
|
+
return `Total Value: $${totalValue.toFixed(2)}\n\nToken Positions (>$1):\n${lines.join("\n")}`;
|
|
44
|
+
};
|
|
45
|
+
exports.formatPositionsData = formatPositionsData;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Network } from "../../network";
|
|
3
|
+
import { ActionProvider } from "../actionProvider";
|
|
4
|
+
import { GetWalletPortfolioSchema } from "./schemas";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the ZerionActionProvider.
|
|
7
|
+
*/
|
|
8
|
+
export interface ZerionActionProviderConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Zerion API Key. Request new at https://zerion.io/api
|
|
11
|
+
*/
|
|
12
|
+
apiKey?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* ZerionActionProvider provides actions for zerion operations.
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* This provider is designed to provide EVM-based operations.
|
|
19
|
+
* It supports all EVM-based networks.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ZerionActionProvider extends ActionProvider {
|
|
22
|
+
private readonly apiKey;
|
|
23
|
+
/**
|
|
24
|
+
* Constructor for the ZerionActionProvider.
|
|
25
|
+
*
|
|
26
|
+
* @param config - The configuration options for the ZerionActionProvider.
|
|
27
|
+
*/
|
|
28
|
+
constructor(config?: ZerionActionProviderConfig);
|
|
29
|
+
/**
|
|
30
|
+
* Fetches and summarizes a crypto wallet's portfolio in USD.
|
|
31
|
+
*
|
|
32
|
+
* @param args - Arguments defined by GetWalletPortfolioSchema
|
|
33
|
+
* @returns A promise that resolves to a string describing the action result
|
|
34
|
+
*/
|
|
35
|
+
getPortfolioOverview(args: z.infer<typeof GetWalletPortfolioSchema>): Promise<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves and summarizes a wallet's fungible token holdings.
|
|
38
|
+
*
|
|
39
|
+
* @param args - Arguments defined by GetWalletPortfolioSchema
|
|
40
|
+
* @returns A promise that resolves to a string describing the action result
|
|
41
|
+
*/
|
|
42
|
+
getFungiblePositions(args: z.infer<typeof GetWalletPortfolioSchema>): Promise<string>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if this provider supports the given network.
|
|
45
|
+
*
|
|
46
|
+
* @param network - The network to check support for
|
|
47
|
+
* @returns True if the network is supported
|
|
48
|
+
*/
|
|
49
|
+
supportsNetwork(network: Network): boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Factory function to create a new ZerionActionProvider instance.
|
|
53
|
+
*
|
|
54
|
+
* @param config - The configuration options for the ZerionActionProvider.
|
|
55
|
+
* @returns A new ZerionActionProvider instance
|
|
56
|
+
*/
|
|
57
|
+
export declare const zerionActionProvider: (config?: ZerionActionProviderConfig) => ZerionActionProvider;
|