@jup-ag/lend 0.0.46 → 0.0.47

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.
@@ -1,3 +1,5 @@
1
+ import { AxiosInstance } from 'axios';
2
+
1
3
  type Token = {
2
4
  address: string;
3
5
  chainId: string;
@@ -10,38 +12,6 @@ type Token = {
10
12
  stakingApr?: number;
11
13
  };
12
14
 
13
- type LendingToken = {
14
- id: number;
15
- address: string;
16
- name: string;
17
- symbol: string;
18
- decimals: number;
19
- assetAddress: string;
20
- asset: Token;
21
- totalAssets: string;
22
- totalSupply: string;
23
- convertToShares: string;
24
- convertToAssets: string;
25
- rewardsRate: string;
26
- supplyRate: string;
27
- totalRate: string;
28
- rebalanceDifference: string;
29
- liquiditySupplyData: {
30
- modeWithInterest: boolean;
31
- supply: string;
32
- withdrawalLimit: string;
33
- lastUpdateTimestamp: string;
34
- expandPercent: string;
35
- expandDuration: string;
36
- baseWithdrawalLimit: string;
37
- withdrawableUntilLimit: string;
38
- withdrawable: string;
39
- };
40
- };
41
- declare const getLendingTokens: ({ apiKey, }: {
42
- apiKey?: string;
43
- }) => Promise<LendingToken[]>;
44
-
45
15
  type Vault = {
46
16
  id: number;
47
17
  address: string;
@@ -111,9 +81,61 @@ type Vault = {
111
81
  borrowable: string;
112
82
  };
113
83
  };
114
- declare const getVaults: ({ apiKey, }: {
115
- apiKey?: string;
116
- }) => Promise<Vault[]>;
84
+ declare class BorrowClient {
85
+ http: HttpClient;
86
+ constructor({ http }: {
87
+ http: HttpClient;
88
+ });
89
+ getVaults(): Promise<Vault[]>;
90
+ }
91
+
92
+ type LendingToken = {
93
+ id: number;
94
+ address: string;
95
+ name: string;
96
+ symbol: string;
97
+ decimals: number;
98
+ assetAddress: string;
99
+ asset: Token;
100
+ totalAssets: string;
101
+ totalSupply: string;
102
+ convertToShares: string;
103
+ convertToAssets: string;
104
+ rewardsRate: string;
105
+ supplyRate: string;
106
+ totalRate: string;
107
+ rebalanceDifference: string;
108
+ liquiditySupplyData: {
109
+ modeWithInterest: boolean;
110
+ supply: string;
111
+ withdrawalLimit: string;
112
+ lastUpdateTimestamp: string;
113
+ expandPercent: string;
114
+ expandDuration: string;
115
+ baseWithdrawalLimit: string;
116
+ withdrawableUntilLimit: string;
117
+ withdrawable: string;
118
+ };
119
+ };
120
+ declare class EarnClient {
121
+ http: HttpClient;
122
+ constructor({ http }: {
123
+ http: HttpClient;
124
+ });
125
+ getTokens(): Promise<LendingToken[]>;
126
+ }
127
+
128
+ type HttpClient = AxiosInstance;
129
+ declare class Client {
130
+ borrowClient: BorrowClient;
131
+ earnClient: EarnClient;
132
+ http: HttpClient;
133
+ constructor({ apiKey }: {
134
+ apiKey?: string;
135
+ });
136
+ get borrow(): BorrowClient;
137
+ get earn(): EarnClient;
138
+ }
117
139
 
118
- export { getLendingTokens, getVaults };
119
- export type { LendingToken, Token, Vault };
140
+ export { Client };
141
+ export type { HttpClient, Token };
@@ -1,3 +1,5 @@
1
+ import { AxiosInstance } from 'axios';
2
+
1
3
  type Token = {
2
4
  address: string;
3
5
  chainId: string;
@@ -10,38 +12,6 @@ type Token = {
10
12
  stakingApr?: number;
11
13
  };
12
14
 
13
- type LendingToken = {
14
- id: number;
15
- address: string;
16
- name: string;
17
- symbol: string;
18
- decimals: number;
19
- assetAddress: string;
20
- asset: Token;
21
- totalAssets: string;
22
- totalSupply: string;
23
- convertToShares: string;
24
- convertToAssets: string;
25
- rewardsRate: string;
26
- supplyRate: string;
27
- totalRate: string;
28
- rebalanceDifference: string;
29
- liquiditySupplyData: {
30
- modeWithInterest: boolean;
31
- supply: string;
32
- withdrawalLimit: string;
33
- lastUpdateTimestamp: string;
34
- expandPercent: string;
35
- expandDuration: string;
36
- baseWithdrawalLimit: string;
37
- withdrawableUntilLimit: string;
38
- withdrawable: string;
39
- };
40
- };
41
- declare const getLendingTokens: ({ apiKey, }: {
42
- apiKey?: string;
43
- }) => Promise<LendingToken[]>;
44
-
45
15
  type Vault = {
46
16
  id: number;
47
17
  address: string;
@@ -111,9 +81,61 @@ type Vault = {
111
81
  borrowable: string;
112
82
  };
113
83
  };
114
- declare const getVaults: ({ apiKey, }: {
115
- apiKey?: string;
116
- }) => Promise<Vault[]>;
84
+ declare class BorrowClient {
85
+ http: HttpClient;
86
+ constructor({ http }: {
87
+ http: HttpClient;
88
+ });
89
+ getVaults(): Promise<Vault[]>;
90
+ }
91
+
92
+ type LendingToken = {
93
+ id: number;
94
+ address: string;
95
+ name: string;
96
+ symbol: string;
97
+ decimals: number;
98
+ assetAddress: string;
99
+ asset: Token;
100
+ totalAssets: string;
101
+ totalSupply: string;
102
+ convertToShares: string;
103
+ convertToAssets: string;
104
+ rewardsRate: string;
105
+ supplyRate: string;
106
+ totalRate: string;
107
+ rebalanceDifference: string;
108
+ liquiditySupplyData: {
109
+ modeWithInterest: boolean;
110
+ supply: string;
111
+ withdrawalLimit: string;
112
+ lastUpdateTimestamp: string;
113
+ expandPercent: string;
114
+ expandDuration: string;
115
+ baseWithdrawalLimit: string;
116
+ withdrawableUntilLimit: string;
117
+ withdrawable: string;
118
+ };
119
+ };
120
+ declare class EarnClient {
121
+ http: HttpClient;
122
+ constructor({ http }: {
123
+ http: HttpClient;
124
+ });
125
+ getTokens(): Promise<LendingToken[]>;
126
+ }
127
+
128
+ type HttpClient = AxiosInstance;
129
+ declare class Client {
130
+ borrowClient: BorrowClient;
131
+ earnClient: EarnClient;
132
+ http: HttpClient;
133
+ constructor({ apiKey }: {
134
+ apiKey?: string;
135
+ });
136
+ get borrow(): BorrowClient;
137
+ get earn(): EarnClient;
138
+ }
117
139
 
118
- export { getLendingTokens, getVaults };
119
- export type { LendingToken, Token, Vault };
140
+ export { Client };
141
+ export type { HttpClient, Token };
@@ -1,29 +1,47 @@
1
- const getLendingTokens = async ({
2
- apiKey
3
- }) => {
4
- const response = await fetch(
5
- apiKey ? `https://api.jup.ag/lend/v1/earn/tokens` : "https://lite-api.jup.ag/lend/v1/earn/tokens",
6
- {
7
- headers: {
8
- "x-api-key": apiKey || ""
9
- }
10
- }
11
- );
12
- return await response.json();
13
- };
1
+ import axios from 'axios';
2
+
3
+ class BorrowClient {
4
+ http;
5
+ constructor({ http }) {
6
+ this.http = http;
7
+ }
8
+ async getVaults() {
9
+ const { data } = await this.http.get("/v1/borrow/vaults");
10
+ return data;
11
+ }
12
+ }
13
+
14
+ class EarnClient {
15
+ http;
16
+ constructor({ http }) {
17
+ this.http = http;
18
+ }
19
+ async getTokens() {
20
+ const { data } = await this.http.get("/v1/earn/tokens");
21
+ return data;
22
+ }
23
+ }
14
24
 
15
- const getVaults = async ({
16
- apiKey
17
- }) => {
18
- const response = await fetch(
19
- apiKey ? `https://api.jup.ag/lend/v1/borrow/vaults` : "https://lite-api.jup.ag/lend/v1/borrow/vaults",
20
- {
25
+ class Client {
26
+ borrowClient;
27
+ earnClient;
28
+ http;
29
+ constructor({ apiKey }) {
30
+ this.http = axios.create({
31
+ baseURL: apiKey ? `https://api.jup.ag/lend` : "https://lite-api.jup.ag/lend",
21
32
  headers: {
22
33
  "x-api-key": apiKey || ""
23
34
  }
24
- }
25
- );
26
- return await response.json();
27
- };
35
+ });
36
+ this.borrowClient = new BorrowClient({ http: this.http });
37
+ this.earnClient = new EarnClient({ http: this.http });
38
+ }
39
+ get borrow() {
40
+ return this.borrowClient;
41
+ }
42
+ get earn() {
43
+ return this.earnClient;
44
+ }
45
+ }
28
46
 
29
- export { getLendingTokens, getVaults };
47
+ export { Client };
package/dist/index.mjs CHANGED
@@ -5,6 +5,6 @@ import '@solana/web3.js';
5
5
  import '@solana/spl-token';
6
6
  import 'bn.js';
7
7
 
8
- const version = "0.0.46";
8
+ const version = "0.0.47";
9
9
 
10
10
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jup-ag/lend",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -43,6 +43,7 @@
43
43
  "@coral-xyz/anchor": "^0.31.1",
44
44
  "@solana/spl-token": "^0.4.13",
45
45
  "@solana/web3.js": "^1.98.2",
46
+ "axios": "^1.11.0",
46
47
  "bn.js": "^5.2.2"
47
48
  },
48
49
  "scripts": {