@odisea-labs/pan 0.1.0 → 1.2.2

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/dist/index.d.mts CHANGED
@@ -1,11 +1,16 @@
1
+ import { PanConfig as PanConfig$1, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
2
+
3
+ type ChainType = "ethereum" | "tron";
1
4
  interface Wallet {
2
5
  id: string;
3
6
  address: string;
7
+ chainType: ChainType;
4
8
  chains: string[];
5
9
  createdAt: string;
6
10
  }
7
11
  interface CreateWalletParams {
8
12
  userId: string;
13
+ chainType?: ChainType;
9
14
  email?: string;
10
15
  metadata?: Record<string, unknown>;
11
16
  }
@@ -89,7 +94,7 @@ interface Intent {
89
94
  }
90
95
  interface CreateIntentParams {
91
96
  walletId: string;
92
- action: "lend" | "swap" | "bridge";
97
+ action: "lend" | "swap" | "bridge" | "transfer";
93
98
  amount: number;
94
99
  }
95
100
  interface CreateIntentResponse {
@@ -97,6 +102,10 @@ interface CreateIntentResponse {
97
102
  status: string;
98
103
  executionPlan: ExecutionPlan;
99
104
  estimatedGas?: number;
105
+ txHash?: string;
106
+ gasUsed?: number;
107
+ gasCostUsd?: number;
108
+ error?: string;
100
109
  }
101
110
  interface LendIntentParams {
102
111
  walletId: string;
@@ -119,6 +128,24 @@ interface WalletBalances {
119
128
  chains: ChainBalance[];
120
129
  totalValueUsd?: number;
121
130
  }
131
+ interface YieldOption {
132
+ chain: string;
133
+ asset: string;
134
+ apy: number;
135
+ }
136
+ interface RecommendedYield {
137
+ chain: string;
138
+ asset: string;
139
+ apy: number;
140
+ reasoning: string;
141
+ }
142
+ interface AllYieldsResponse {
143
+ chains: string[];
144
+ assets: string[];
145
+ rates: YieldOption[];
146
+ best: RecommendedYield;
147
+ updatedAt: string;
148
+ }
122
149
 
123
150
  declare class PanClient {
124
151
  private apiKey;
@@ -134,13 +161,6 @@ declare class PanError extends Error {
134
161
  constructor(errorData: any, statusCode?: number);
135
162
  }
136
163
 
137
- declare class IntentManager {
138
- private client;
139
- constructor(client: PanClient);
140
- lend(params: LendIntentParams): Promise<CreateIntentResponse>;
141
- getIntent(intentId: string): Promise<Intent>;
142
- }
143
-
144
164
  declare class WalletManager {
145
165
  private client;
146
166
  constructor(client: PanClient);
@@ -149,11 +169,22 @@ declare class WalletManager {
149
169
  getBalances(walletId: string): Promise<WalletBalances>;
150
170
  }
151
171
 
172
+ declare class YieldManager {
173
+ private client;
174
+ constructor(client: PanClient);
175
+ getAll(): Promise<AllYieldsResponse>;
176
+ }
177
+
152
178
  declare class Pan {
153
179
  private client;
154
180
  wallet: WalletManager;
155
- intent: IntentManager;
156
- constructor(config: PanConfig);
181
+ yields: YieldManager;
182
+ constructor(config: PanConfig$1);
183
+ lend(params: LendIntentParams$1): Promise<CreateIntentResponse$1>;
184
+ transfer(params: TransferIntentParams): Promise<CreateIntentResponse$1>;
185
+ withdraw(params: WithdrawIntentParams): Promise<CreateIntentResponse$1>;
186
+ bridge(params: BridgeIntentParams): Promise<CreateIntentResponse$1>;
187
+ getIntent(intentId: string): Promise<Intent$1>;
157
188
  }
158
189
 
159
- export { type AnyExecutionStep, type BridgeStep, type ChainBalance, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, IntentManager, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager };
190
+ export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,16 @@
1
+ import { PanConfig as PanConfig$1, LendIntentParams as LendIntentParams$1, CreateIntentResponse as CreateIntentResponse$1, TransferIntentParams, WithdrawIntentParams, BridgeIntentParams, Intent as Intent$1 } from '@pan/types';
2
+
3
+ type ChainType = "ethereum" | "tron";
1
4
  interface Wallet {
2
5
  id: string;
3
6
  address: string;
7
+ chainType: ChainType;
4
8
  chains: string[];
5
9
  createdAt: string;
6
10
  }
7
11
  interface CreateWalletParams {
8
12
  userId: string;
13
+ chainType?: ChainType;
9
14
  email?: string;
10
15
  metadata?: Record<string, unknown>;
11
16
  }
@@ -89,7 +94,7 @@ interface Intent {
89
94
  }
90
95
  interface CreateIntentParams {
91
96
  walletId: string;
92
- action: "lend" | "swap" | "bridge";
97
+ action: "lend" | "swap" | "bridge" | "transfer";
93
98
  amount: number;
94
99
  }
95
100
  interface CreateIntentResponse {
@@ -97,6 +102,10 @@ interface CreateIntentResponse {
97
102
  status: string;
98
103
  executionPlan: ExecutionPlan;
99
104
  estimatedGas?: number;
105
+ txHash?: string;
106
+ gasUsed?: number;
107
+ gasCostUsd?: number;
108
+ error?: string;
100
109
  }
101
110
  interface LendIntentParams {
102
111
  walletId: string;
@@ -119,6 +128,24 @@ interface WalletBalances {
119
128
  chains: ChainBalance[];
120
129
  totalValueUsd?: number;
121
130
  }
131
+ interface YieldOption {
132
+ chain: string;
133
+ asset: string;
134
+ apy: number;
135
+ }
136
+ interface RecommendedYield {
137
+ chain: string;
138
+ asset: string;
139
+ apy: number;
140
+ reasoning: string;
141
+ }
142
+ interface AllYieldsResponse {
143
+ chains: string[];
144
+ assets: string[];
145
+ rates: YieldOption[];
146
+ best: RecommendedYield;
147
+ updatedAt: string;
148
+ }
122
149
 
123
150
  declare class PanClient {
124
151
  private apiKey;
@@ -134,13 +161,6 @@ declare class PanError extends Error {
134
161
  constructor(errorData: any, statusCode?: number);
135
162
  }
136
163
 
137
- declare class IntentManager {
138
- private client;
139
- constructor(client: PanClient);
140
- lend(params: LendIntentParams): Promise<CreateIntentResponse>;
141
- getIntent(intentId: string): Promise<Intent>;
142
- }
143
-
144
164
  declare class WalletManager {
145
165
  private client;
146
166
  constructor(client: PanClient);
@@ -149,11 +169,22 @@ declare class WalletManager {
149
169
  getBalances(walletId: string): Promise<WalletBalances>;
150
170
  }
151
171
 
172
+ declare class YieldManager {
173
+ private client;
174
+ constructor(client: PanClient);
175
+ getAll(): Promise<AllYieldsResponse>;
176
+ }
177
+
152
178
  declare class Pan {
153
179
  private client;
154
180
  wallet: WalletManager;
155
- intent: IntentManager;
156
- constructor(config: PanConfig);
181
+ yields: YieldManager;
182
+ constructor(config: PanConfig$1);
183
+ lend(params: LendIntentParams$1): Promise<CreateIntentResponse$1>;
184
+ transfer(params: TransferIntentParams): Promise<CreateIntentResponse$1>;
185
+ withdraw(params: WithdrawIntentParams): Promise<CreateIntentResponse$1>;
186
+ bridge(params: BridgeIntentParams): Promise<CreateIntentResponse$1>;
187
+ getIntent(intentId: string): Promise<Intent$1>;
157
188
  }
158
189
 
159
- export { type AnyExecutionStep, type BridgeStep, type ChainBalance, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, IntentManager, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager };
190
+ export { type AllYieldsResponse, type AnyExecutionStep, type BridgeStep, type ChainBalance, type ChainType, type ConsolidateStep, type CreateIntentParams, type CreateIntentResponse, type CreateWalletParams, type DepositStep, type ExecutionPlan, type ExecutionResult, type ExecutionStep, type ExecutionStepType, type Intent, type LendIntentParams, Pan, PanClient, type PanConfig, PanError, type RateLimitError, type RecommendedYield, type SwapStep, type TokenBalance, type Wallet, type WalletBalances, WalletManager, YieldManager, type YieldOption };
package/dist/index.js CHANGED
@@ -20,11 +20,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
- IntentManager: () => IntentManager,
24
23
  Pan: () => Pan,
25
24
  PanClient: () => PanClient,
26
25
  PanError: () => PanError,
27
- WalletManager: () => WalletManager
26
+ WalletManager: () => WalletManager,
27
+ YieldManager: () => YieldManager
28
28
  });
29
29
  module.exports = __toCommonJS(index_exports);
30
30
 
@@ -86,28 +86,6 @@ var PanError = class extends Error {
86
86
  }
87
87
  };
88
88
 
89
- // src/intent.ts
90
- var IntentManager = class {
91
- constructor(client) {
92
- this.client = client;
93
- }
94
- async lend(params) {
95
- return this.client.request("/api/v1/intents", {
96
- method: "POST",
97
- body: JSON.stringify({
98
- walletId: params.walletId,
99
- action: "lend",
100
- amount: params.amount
101
- })
102
- });
103
- }
104
- async getIntent(intentId) {
105
- return this.client.request(`/api/v1/intents/${intentId}`, {
106
- method: "GET"
107
- });
108
- }
109
- };
110
-
111
89
  // src/wallet.ts
112
90
  var WalletManager = class {
113
91
  constructor(client) {
@@ -131,19 +109,84 @@ var WalletManager = class {
131
109
  }
132
110
  };
133
111
 
112
+ // src/yields.ts
113
+ var YieldManager = class {
114
+ constructor(client) {
115
+ this.client = client;
116
+ }
117
+ async getAll() {
118
+ return this.client.request("/api/v1/yields", {
119
+ method: "GET"
120
+ });
121
+ }
122
+ };
123
+
134
124
  // src/index.ts
135
125
  var Pan = class {
136
126
  constructor(config) {
137
127
  this.client = new PanClient(config);
138
128
  this.wallet = new WalletManager(this.client);
139
- this.intent = new IntentManager(this.client);
129
+ this.yields = new YieldManager(this.client);
130
+ }
131
+ async lend(params) {
132
+ return this.client.request("/api/v1/intents", {
133
+ method: "POST",
134
+ body: JSON.stringify({
135
+ walletId: params.walletId,
136
+ action: "lend",
137
+ amount: params.amount
138
+ })
139
+ });
140
+ }
141
+ async transfer(params) {
142
+ return this.client.request("/api/v1/intents", {
143
+ method: "POST",
144
+ body: JSON.stringify({
145
+ walletId: params.walletId,
146
+ action: "transfer",
147
+ to: params.to,
148
+ amount: params.amount,
149
+ asset: params.asset,
150
+ chain: params.chain
151
+ })
152
+ });
153
+ }
154
+ async withdraw(params) {
155
+ return this.client.request("/api/v1/intents", {
156
+ method: "POST",
157
+ body: JSON.stringify({
158
+ walletId: params.walletId,
159
+ action: "withdraw",
160
+ amount: params.amount,
161
+ asset: params.asset || "USDC",
162
+ chain: params.chain
163
+ })
164
+ });
165
+ }
166
+ async bridge(params) {
167
+ return this.client.request("/api/v1/intents", {
168
+ method: "POST",
169
+ body: JSON.stringify({
170
+ walletId: params.walletId,
171
+ action: "bridge",
172
+ amount: params.amount,
173
+ asset: params.asset || "USDC",
174
+ fromChain: params.fromChain,
175
+ toChain: params.toChain
176
+ })
177
+ });
178
+ }
179
+ async getIntent(intentId) {
180
+ return this.client.request(`/api/v1/intents/${intentId}`, {
181
+ method: "GET"
182
+ });
140
183
  }
141
184
  };
142
185
  // Annotate the CommonJS export names for ESM import in node:
143
186
  0 && (module.exports = {
144
- IntentManager,
145
187
  Pan,
146
188
  PanClient,
147
189
  PanError,
148
- WalletManager
190
+ WalletManager,
191
+ YieldManager
149
192
  });
package/dist/index.mjs CHANGED
@@ -56,28 +56,6 @@ var PanError = class extends Error {
56
56
  }
57
57
  };
58
58
 
59
- // src/intent.ts
60
- var IntentManager = class {
61
- constructor(client) {
62
- this.client = client;
63
- }
64
- async lend(params) {
65
- return this.client.request("/api/v1/intents", {
66
- method: "POST",
67
- body: JSON.stringify({
68
- walletId: params.walletId,
69
- action: "lend",
70
- amount: params.amount
71
- })
72
- });
73
- }
74
- async getIntent(intentId) {
75
- return this.client.request(`/api/v1/intents/${intentId}`, {
76
- method: "GET"
77
- });
78
- }
79
- };
80
-
81
59
  // src/wallet.ts
82
60
  var WalletManager = class {
83
61
  constructor(client) {
@@ -101,18 +79,83 @@ var WalletManager = class {
101
79
  }
102
80
  };
103
81
 
82
+ // src/yields.ts
83
+ var YieldManager = class {
84
+ constructor(client) {
85
+ this.client = client;
86
+ }
87
+ async getAll() {
88
+ return this.client.request("/api/v1/yields", {
89
+ method: "GET"
90
+ });
91
+ }
92
+ };
93
+
104
94
  // src/index.ts
105
95
  var Pan = class {
106
96
  constructor(config) {
107
97
  this.client = new PanClient(config);
108
98
  this.wallet = new WalletManager(this.client);
109
- this.intent = new IntentManager(this.client);
99
+ this.yields = new YieldManager(this.client);
100
+ }
101
+ async lend(params) {
102
+ return this.client.request("/api/v1/intents", {
103
+ method: "POST",
104
+ body: JSON.stringify({
105
+ walletId: params.walletId,
106
+ action: "lend",
107
+ amount: params.amount
108
+ })
109
+ });
110
+ }
111
+ async transfer(params) {
112
+ return this.client.request("/api/v1/intents", {
113
+ method: "POST",
114
+ body: JSON.stringify({
115
+ walletId: params.walletId,
116
+ action: "transfer",
117
+ to: params.to,
118
+ amount: params.amount,
119
+ asset: params.asset,
120
+ chain: params.chain
121
+ })
122
+ });
123
+ }
124
+ async withdraw(params) {
125
+ return this.client.request("/api/v1/intents", {
126
+ method: "POST",
127
+ body: JSON.stringify({
128
+ walletId: params.walletId,
129
+ action: "withdraw",
130
+ amount: params.amount,
131
+ asset: params.asset || "USDC",
132
+ chain: params.chain
133
+ })
134
+ });
135
+ }
136
+ async bridge(params) {
137
+ return this.client.request("/api/v1/intents", {
138
+ method: "POST",
139
+ body: JSON.stringify({
140
+ walletId: params.walletId,
141
+ action: "bridge",
142
+ amount: params.amount,
143
+ asset: params.asset || "USDC",
144
+ fromChain: params.fromChain,
145
+ toChain: params.toChain
146
+ })
147
+ });
148
+ }
149
+ async getIntent(intentId) {
150
+ return this.client.request(`/api/v1/intents/${intentId}`, {
151
+ method: "GET"
152
+ });
110
153
  }
111
154
  };
112
155
  export {
113
- IntentManager,
114
156
  Pan,
115
157
  PanClient,
116
158
  PanError,
117
- WalletManager
159
+ WalletManager,
160
+ YieldManager
118
161
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@odisea-labs/pan",
3
- "version": "0.1.0",
3
+ "version": "1.2.2",
4
4
  "description": "Intent-based DeFi API SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -39,6 +39,9 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
+ "dependencies": {
43
+ "@pan/types": "0.1.0"
44
+ },
42
45
  "devDependencies": {
43
46
  "tsup": "^8.3.5"
44
47
  }