@carrot-protocol/boost-http-client 0.2.16-group-refactor1-dev-50c976e → 0.2.16-token22-dev-998073e
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.ts +16 -8
- package/dist/index.js +219 -134
- package/dist/types.d.ts +99 -20
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -9
- package/package.json +2 -2
- package/src/index.ts +327 -155
- package/src/types.ts +115 -21
- package/src/utils.ts +0 -8
package/src/types.ts
CHANGED
|
@@ -1,19 +1,51 @@
|
|
|
1
1
|
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// Send a tx
|
|
4
4
|
export interface SendRequest {
|
|
5
5
|
userRequestId: string;
|
|
6
6
|
txns: string[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Request to deposit collateral
|
|
11
|
+
*/
|
|
12
|
+
export interface DepositRequest {
|
|
13
|
+
owner: web3.PublicKey;
|
|
14
|
+
clendGroup: web3.PublicKey;
|
|
15
|
+
clendAccount: web3.PublicKey | null;
|
|
16
|
+
inputTokenMint: web3.PublicKey;
|
|
17
|
+
depositAmountUi: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DepositResponse {
|
|
21
|
+
userRequestId: string;
|
|
22
|
+
unsignedBase64Tx: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Request to withdraw collateral
|
|
27
|
+
*/
|
|
28
|
+
export interface WithdrawRequest {
|
|
29
|
+
clendAccount: web3.PublicKey;
|
|
30
|
+
outputTokenMint: web3.PublicKey;
|
|
31
|
+
withdrawAmountUi: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface WithdrawResponse {
|
|
35
|
+
userRequestId: string;
|
|
36
|
+
unsignedBase64Tx: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
/**
|
|
10
40
|
* Request to deposit collateral and create a leveraged position
|
|
11
41
|
*/
|
|
12
42
|
export interface DepositLeverageRequest {
|
|
13
43
|
owner: web3.PublicKey;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
44
|
+
clendGroup: web3.PublicKey;
|
|
45
|
+
clendAccount: web3.PublicKey | null;
|
|
46
|
+
inputTokenMint: web3.PublicKey;
|
|
47
|
+
assetTokenMint: web3.PublicKey;
|
|
48
|
+
liabilityTokenMint: web3.PublicKey;
|
|
17
49
|
depositAmountUi: number;
|
|
18
50
|
leverage: number;
|
|
19
51
|
slippageBps: number;
|
|
@@ -31,7 +63,9 @@ export interface DepositLeverageResponse {
|
|
|
31
63
|
* Request to adjust the leverage of an existing position
|
|
32
64
|
*/
|
|
33
65
|
export interface AdjustLeverageRequest {
|
|
34
|
-
|
|
66
|
+
clendAccount: web3.PublicKey;
|
|
67
|
+
assetTokenMint: web3.PublicKey;
|
|
68
|
+
liabilityTokenMint: web3.PublicKey;
|
|
35
69
|
leverage: number;
|
|
36
70
|
slippageBps: number;
|
|
37
71
|
}
|
|
@@ -48,8 +82,10 @@ export interface AdjustLeverageResponse {
|
|
|
48
82
|
* Request to withdraw from a leveraged position
|
|
49
83
|
*/
|
|
50
84
|
export interface WithdrawLeverageRequest {
|
|
51
|
-
|
|
52
|
-
|
|
85
|
+
clendAccount: web3.PublicKey;
|
|
86
|
+
outputTokenMint: web3.PublicKey;
|
|
87
|
+
assetTokenMint: web3.PublicKey;
|
|
88
|
+
liabilityTokenMint: web3.PublicKey;
|
|
53
89
|
withdrawAmountUi: number;
|
|
54
90
|
slippageBps: number;
|
|
55
91
|
withdrawAll: boolean;
|
|
@@ -63,57 +99,99 @@ export interface WithdrawLeverageResponse {
|
|
|
63
99
|
unsignedBase64Tx: string;
|
|
64
100
|
}
|
|
65
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Request to withdraw emissions from a bank
|
|
104
|
+
*/
|
|
105
|
+
export interface WithdrawEmissionsRequest {
|
|
106
|
+
owner: web3.PublicKey;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Response for withdraw emissions operation
|
|
111
|
+
*/
|
|
112
|
+
export interface WithdrawEmissionsResponse {
|
|
113
|
+
userRequestId: string;
|
|
114
|
+
unsignedBase64Tx: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface GetGroupsResponse {
|
|
118
|
+
groups: GroupAndBanks[];
|
|
119
|
+
}
|
|
120
|
+
|
|
66
121
|
export interface GetGroupResponse {
|
|
122
|
+
group: GroupAndBanks;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface GroupAndBanks {
|
|
126
|
+
group: web3.PublicKey;
|
|
127
|
+
groupName: string;
|
|
67
128
|
banks: Bank[];
|
|
68
129
|
}
|
|
69
130
|
|
|
70
131
|
export interface GetUserRequest {
|
|
71
|
-
|
|
72
|
-
|
|
132
|
+
groups: web3.PublicKey[];
|
|
133
|
+
user: web3.PublicKey;
|
|
134
|
+
getClendAccountSummary: boolean;
|
|
73
135
|
}
|
|
74
136
|
|
|
75
137
|
export interface GetUserResponse {
|
|
76
138
|
wallet: UserWallet;
|
|
77
|
-
|
|
78
|
-
|
|
139
|
+
clendAccounts: {
|
|
140
|
+
clendAccount: ClendAccount;
|
|
141
|
+
summary: ClendAccountTxSummary[];
|
|
142
|
+
}[];
|
|
79
143
|
}
|
|
80
144
|
|
|
81
145
|
export interface UserWallet {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
146
|
+
balances: UserBalance[];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface UserBalance {
|
|
150
|
+
mint: web3.PublicKey;
|
|
151
|
+
balance: BN;
|
|
152
|
+
balanceUi: number;
|
|
88
153
|
}
|
|
89
154
|
|
|
90
155
|
export interface ClendAccount {
|
|
91
|
-
|
|
156
|
+
key: web3.PublicKey;
|
|
157
|
+
group: web3.PublicKey;
|
|
158
|
+
balances: ClendAccountBalance[];
|
|
92
159
|
netValue: number;
|
|
93
160
|
netApy: number;
|
|
94
161
|
pnl: number;
|
|
162
|
+
totalEmissionsApy: number;
|
|
95
163
|
totalAssetValue: number;
|
|
96
164
|
totalLiabilityValue: number;
|
|
97
165
|
healthFactorNotional: number;
|
|
98
166
|
healthFactorRiskAdjusted: number;
|
|
99
167
|
notionalLeverage: number;
|
|
100
168
|
riskAdjustedLeverage: number;
|
|
101
|
-
liquidationPrice: number;
|
|
102
|
-
liquidationPriceChangePercentage: number;
|
|
103
169
|
notionalLtv: number;
|
|
104
170
|
riskAdjustedLtv: number;
|
|
105
171
|
}
|
|
106
172
|
|
|
107
|
-
export interface
|
|
173
|
+
export interface ClendAccountBalance {
|
|
108
174
|
mint: web3.PublicKey;
|
|
109
175
|
bank: web3.PublicKey;
|
|
176
|
+
tokenYieldApy: number;
|
|
110
177
|
assetBalance: BN;
|
|
111
178
|
assetBalanceUi: number;
|
|
112
179
|
assetValue: number;
|
|
180
|
+
assetEmissionsApy: number;
|
|
113
181
|
liabilityBalance: BN;
|
|
114
182
|
liabilityBalanceUi: number;
|
|
115
183
|
liabilityValue: number;
|
|
184
|
+
liabilityBorrowCostApy: number;
|
|
185
|
+
liabilityEmissionsApy: number;
|
|
186
|
+
emissionsOutstandingAndUnclaimed: BN;
|
|
187
|
+
emissionsOutstandingAndUnclaimedUi: number;
|
|
116
188
|
price: number;
|
|
189
|
+
liquidation: ClendAccountAssetLiquidation | null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface ClendAccountAssetLiquidation {
|
|
193
|
+
price: number;
|
|
194
|
+
changePercentage: number;
|
|
117
195
|
}
|
|
118
196
|
|
|
119
197
|
export interface GetBankResponse {
|
|
@@ -124,6 +202,7 @@ export interface Bank {
|
|
|
124
202
|
group: web3.PublicKey;
|
|
125
203
|
key: web3.PublicKey;
|
|
126
204
|
mint: web3.PublicKey;
|
|
205
|
+
tokenYieldApy: number;
|
|
127
206
|
supplyApy: number;
|
|
128
207
|
borrowApy: number;
|
|
129
208
|
utilizationRate: number;
|
|
@@ -144,8 +223,23 @@ export interface Bank {
|
|
|
144
223
|
depositLimitUi: number;
|
|
145
224
|
borrowLimit: BN;
|
|
146
225
|
borrowLimitUi: number;
|
|
226
|
+
emissions: BankEmissions | null;
|
|
147
227
|
}
|
|
148
228
|
|
|
229
|
+
export interface BankEmissions {
|
|
230
|
+
emissionsMode: BankEmissionsMode;
|
|
231
|
+
emissionsApy: number;
|
|
232
|
+
emissionsMint: web3.PublicKey;
|
|
233
|
+
emissionsTokenPrice: number;
|
|
234
|
+
emissionsRate: BN;
|
|
235
|
+
emissionsRemainingUi: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export type BankEmissionsMode =
|
|
239
|
+
| "LENDING_ONLY"
|
|
240
|
+
| "BORROW_ONLY"
|
|
241
|
+
| "LENDING_AND_BORROWING";
|
|
242
|
+
|
|
149
243
|
export interface ClendAccountTxSummary {
|
|
150
244
|
txSig: string;
|
|
151
245
|
time: Date;
|
package/src/utils.ts
CHANGED
|
@@ -15,11 +15,3 @@ export function netValueInToken(
|
|
|
15
15
|
|
|
16
16
|
return clendAccount.netValue / clendAccountTokenBalance.price;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
export function getProductionGroups(): web3.PublicKey[] {
|
|
20
|
-
return [new web3.PublicKey("9bCWxAXFdWQ9GcZTSU3G636T6EyGXYMgaWR74yc7QZz8")];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function getStagingGroups(): web3.PublicKey[] {
|
|
24
|
-
return [new web3.PublicKey("HKMDWLBK7yUmorSx9argg2rYcro6KoWf41N57FccKRP5")];
|
|
25
|
-
}
|