@kamino-finance/klend-sdk 5.13.1 → 5.13.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/classes/action.d.ts +32 -31
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +126 -95
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +3 -2
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +3 -2
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/manager.d.ts +7 -7
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +46 -46
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligationOrder.d.ts +1 -1
- package/dist/classes/obligationOrder.d.ts.map +1 -1
- package/dist/classes/reserve.d.ts +2 -2
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +70 -70
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +13 -0
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/utils.d.ts +1 -9
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +4 -51
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +5 -3
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +50 -41
- package/dist/classes/vault.js.map +1 -1
- package/dist/classes/{types.d.ts → vault_types.d.ts} +2 -15
- package/dist/classes/vault_types.d.ts.map +1 -0
- package/dist/classes/{types.js → vault_types.js} +1 -1
- package/dist/classes/vault_types.js.map +1 -0
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +25 -26
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +6 -6
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +6 -6
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +61 -61
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/calcs.d.ts +0 -1
- package/dist/leverage/calcs.d.ts.map +1 -1
- package/dist/leverage/calcs.js +5 -8
- package/dist/leverage/calcs.js.map +1 -1
- package/dist/leverage/operations.d.ts +5 -5
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +73 -73
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +1 -1
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/leverage/utils.d.ts +2 -2
- package/dist/leverage/utils.d.ts.map +1 -1
- package/dist/leverage/utils.js +5 -5
- package/dist/leverage/utils.js.map +1 -1
- package/dist/referrals/instructions.d.ts +3 -3
- package/dist/referrals/instructions.d.ts.map +1 -1
- package/dist/referrals/instructions.js +10 -10
- package/dist/referrals/instructions.js.map +1 -1
- package/dist/referrals/operations.js +6 -6
- package/dist/referrals/operations.js.map +1 -1
- package/dist/utils/ata.d.ts +3 -3
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +22 -22
- package/dist/utils/ata.js.map +1 -1
- package/dist/utils/instruction.d.ts +2 -2
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js +12 -12
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/lookupTable.js +6 -6
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/userMetadata.d.ts +1 -1
- package/dist/utils/userMetadata.d.ts.map +1 -1
- package/dist/utils/userMetadata.js +3 -3
- package/dist/utils/userMetadata.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/action.ts +143 -102
- package/src/classes/index.ts +5 -2
- package/src/classes/manager.ts +54 -51
- package/src/classes/obligationOrder.ts +1 -1
- package/src/classes/reserve.ts +126 -132
- package/src/classes/shared.ts +15 -0
- package/src/classes/utils.ts +3 -52
- package/src/classes/vault.ts +53 -42
- package/src/classes/{types.ts → vault_types.ts} +1 -16
- package/src/client.ts +16 -16
- package/src/client_kamino_manager.ts +25 -25
- package/src/lending_operations/repay_with_collateral_operations.ts +13 -13
- package/src/lending_operations/swap_collateral_operations.ts +85 -85
- package/src/leverage/calcs.ts +2 -6
- package/src/leverage/operations.ts +84 -84
- package/src/leverage/types.ts +1 -1
- package/src/leverage/utils.ts +5 -5
- package/src/referrals/instructions.ts +6 -6
- package/src/referrals/operations.ts +9 -9
- package/src/utils/ata.ts +18 -18
- package/src/utils/instruction.ts +10 -10
- package/src/utils/lookupTable.ts +6 -6
- package/src/utils/userMetadata.ts +1 -1
- package/dist/classes/types.d.ts.map +0 -1
- package/dist/classes/types.js.map +0 -1
- package/dist/classes/types_utils.d.ts +0 -14
- package/dist/classes/types_utils.d.ts.map +0 -1
- package/dist/classes/types_utils.js +0 -50
- package/dist/classes/types_utils.js.map +0 -1
- package/src/classes/types_utils.ts +0 -49
package/src/utils/ata.ts
CHANGED
|
@@ -67,7 +67,7 @@ export function getAssociatedTokenAddress(
|
|
|
67
67
|
return address;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
export const
|
|
70
|
+
export const getAtasWithCreateIxsIfMissing = async (
|
|
71
71
|
connection: Connection,
|
|
72
72
|
user: PublicKey,
|
|
73
73
|
mints: Array<{ mint: PublicKey; tokenProgram: PublicKey }>
|
|
@@ -109,10 +109,10 @@ export function createAtasIdempotent(
|
|
|
109
109
|
return res;
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
export function
|
|
113
|
-
const
|
|
112
|
+
export function getTransferWsolIxs(owner: PublicKey, ata: PublicKey, amountLamports: Decimal) {
|
|
113
|
+
const ixs: TransactionInstruction[] = [];
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
ixs.push(
|
|
116
116
|
SystemProgram.transfer({
|
|
117
117
|
fromPubkey: owner,
|
|
118
118
|
toPubkey: ata,
|
|
@@ -120,7 +120,7 @@ export function getTransferWsolIxns(owner: PublicKey, ata: PublicKey, amountLamp
|
|
|
120
120
|
})
|
|
121
121
|
);
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
ixs.push(
|
|
124
124
|
new TransactionInstruction({
|
|
125
125
|
keys: [
|
|
126
126
|
{
|
|
@@ -134,12 +134,12 @@ export function getTransferWsolIxns(owner: PublicKey, ata: PublicKey, amountLamp
|
|
|
134
134
|
})
|
|
135
135
|
);
|
|
136
136
|
|
|
137
|
-
return
|
|
137
|
+
return ixs;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
export function
|
|
141
|
-
return
|
|
142
|
-
const { programId, keys } =
|
|
140
|
+
export function removeBudgetAndAtaIxs(ixs: TransactionInstruction[], mints: string[]): TransactionInstruction[] {
|
|
141
|
+
return ixs.filter((ix) => {
|
|
142
|
+
const { programId, keys } = ix;
|
|
143
143
|
|
|
144
144
|
if (programId.equals(ComputeBudgetProgram.programId)) {
|
|
145
145
|
return false;
|
|
@@ -195,8 +195,8 @@ export const createWsolAtaIfMissing = async (
|
|
|
195
195
|
amount: Decimal,
|
|
196
196
|
owner: PublicKey
|
|
197
197
|
): Promise<CreateWsolAtaIxs> => {
|
|
198
|
-
const
|
|
199
|
-
const
|
|
198
|
+
const createIxs: TransactionInstruction[] = [];
|
|
199
|
+
const closeIxs: TransactionInstruction[] = [];
|
|
200
200
|
|
|
201
201
|
const wsolAta: PublicKey = getAssociatedTokenAddressSync(NATIVE_MINT, owner, true, TOKEN_PROGRAM_ID);
|
|
202
202
|
|
|
@@ -205,7 +205,7 @@ export const createWsolAtaIfMissing = async (
|
|
|
205
205
|
|
|
206
206
|
// This checks if we need to create it
|
|
207
207
|
if (isWsolInfoInvalid(wsolAtaAccountInfo)) {
|
|
208
|
-
|
|
208
|
+
createIxs.push(createAssociatedTokenAccountInstruction(owner, wsolAta, owner, NATIVE_MINT, TOKEN_PROGRAM_ID));
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
let wsolExistingBalanceLamports = new Decimal(0);
|
|
@@ -219,7 +219,7 @@ export const createWsolAtaIfMissing = async (
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
if (solDeposit !== null && solDeposit.gt(wsolExistingBalanceLamports)) {
|
|
222
|
-
|
|
222
|
+
createIxs.push(
|
|
223
223
|
SystemProgram.transfer({
|
|
224
224
|
fromPubkey: owner,
|
|
225
225
|
toPubkey: wsolAta,
|
|
@@ -228,9 +228,9 @@ export const createWsolAtaIfMissing = async (
|
|
|
228
228
|
);
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
if (
|
|
231
|
+
if (createIxs.length > 0) {
|
|
232
232
|
// Primitive way of wrapping SOL
|
|
233
|
-
|
|
233
|
+
createIxs.push(
|
|
234
234
|
new TransactionInstruction({
|
|
235
235
|
keys: [
|
|
236
236
|
{
|
|
@@ -245,12 +245,12 @@ export const createWsolAtaIfMissing = async (
|
|
|
245
245
|
);
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
closeIxs.push(createCloseAccountInstruction(wsolAta, owner, owner, [], TOKEN_PROGRAM_ID));
|
|
249
249
|
|
|
250
250
|
return {
|
|
251
251
|
wsolAta,
|
|
252
|
-
createAtaIxs:
|
|
253
|
-
closeAtaIxs:
|
|
252
|
+
createAtaIxs: createIxs,
|
|
253
|
+
closeAtaIxs: closeIxs,
|
|
254
254
|
};
|
|
255
255
|
};
|
|
256
256
|
|
package/src/utils/instruction.ts
CHANGED
|
@@ -66,12 +66,12 @@ export async function buildAndSendTxnWithLogs(
|
|
|
66
66
|
export async function buildAndSendTxn(
|
|
67
67
|
c: Connection,
|
|
68
68
|
owner: Keypair,
|
|
69
|
-
|
|
69
|
+
ixs: TransactionInstruction[],
|
|
70
70
|
signers: Signer[],
|
|
71
71
|
lutAddresses: PublicKey[] = [],
|
|
72
72
|
description: string = ''
|
|
73
73
|
): Promise<TransactionSignature> {
|
|
74
|
-
const tx = await buildVersionedTransaction(c, owner.publicKey,
|
|
74
|
+
const tx = await buildVersionedTransaction(c, owner.publicKey, ixs, lutAddresses);
|
|
75
75
|
|
|
76
76
|
return await buildAndSendTxnWithLogs(c, tx, owner, signers, true, description);
|
|
77
77
|
}
|
|
@@ -234,19 +234,19 @@ export async function getLookupTableAccounts(
|
|
|
234
234
|
return lookupTableAccounts;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
export const
|
|
237
|
+
export const getComputeBudgetAndPriorityFeeIxs = (
|
|
238
238
|
units: number,
|
|
239
239
|
priorityFeeLamports?: Decimal
|
|
240
240
|
): TransactionInstruction[] => {
|
|
241
|
-
const
|
|
242
|
-
|
|
241
|
+
const ixs: TransactionInstruction[] = [];
|
|
242
|
+
ixs.push(ComputeBudgetProgram.setComputeUnitLimit({ units }));
|
|
243
243
|
|
|
244
244
|
if (priorityFeeLamports && priorityFeeLamports.gt(0)) {
|
|
245
245
|
const unitPrice = priorityFeeLamports.mul(10 ** 6).div(units);
|
|
246
|
-
|
|
246
|
+
ixs.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: BigInt(unitPrice.floor().toString()) }));
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
return
|
|
249
|
+
return ixs;
|
|
250
250
|
};
|
|
251
251
|
|
|
252
252
|
// filters null values from array and make typescript happy
|
|
@@ -272,9 +272,9 @@ export function uniqueAccountsWithProgramIds(
|
|
|
272
272
|
}
|
|
273
273
|
|
|
274
274
|
const uniqueAccounts = new PublicKeySet<PublicKey>(luts);
|
|
275
|
-
ixs.forEach((
|
|
276
|
-
uniqueAccounts.add(
|
|
277
|
-
|
|
275
|
+
ixs.forEach((ix) => {
|
|
276
|
+
uniqueAccounts.add(ix.programId);
|
|
277
|
+
ix.keys.forEach((key) => {
|
|
278
278
|
uniqueAccounts.add(key.pubkey);
|
|
279
279
|
});
|
|
280
280
|
});
|
package/src/utils/lookupTable.ts
CHANGED
|
@@ -61,13 +61,13 @@ export const extendLookupTableIxs = (
|
|
|
61
61
|
* @returns - the instruction to create the lookup table and its address
|
|
62
62
|
*/
|
|
63
63
|
export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey] {
|
|
64
|
-
const [
|
|
64
|
+
const [ix, address] = AddressLookupTableProgram.createLookupTable({
|
|
65
65
|
authority: payer,
|
|
66
66
|
payer,
|
|
67
67
|
recentSlot: slot,
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
return [
|
|
70
|
+
return [ix, address];
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -77,12 +77,12 @@ export function initLookupTableIx(payer: PublicKey, slot: number): [TransactionI
|
|
|
77
77
|
* @returns - the instruction to deactivate the lookup table
|
|
78
78
|
*/
|
|
79
79
|
export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
80
|
-
const
|
|
80
|
+
const ix = AddressLookupTableProgram.deactivateLookupTable({
|
|
81
81
|
authority: payer,
|
|
82
82
|
lookupTable: lookupTable,
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
return
|
|
85
|
+
return ix;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -93,13 +93,13 @@ export function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey
|
|
|
93
93
|
*/
|
|
94
94
|
/// this require the LUT to be deactivated at least 500 blocks before
|
|
95
95
|
export function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction {
|
|
96
|
-
const
|
|
96
|
+
const ix = AddressLookupTableProgram.closeLookupTable({
|
|
97
97
|
authority: payer,
|
|
98
98
|
recipient: payer,
|
|
99
99
|
lookupTable: lookupTable,
|
|
100
100
|
});
|
|
101
101
|
|
|
102
|
-
return
|
|
102
|
+
return ix;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
/**
|
|
@@ -28,7 +28,7 @@ export type KaminoUserMetadata = {
|
|
|
28
28
|
state: UserMetadata;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const getUserLutAddressAndSetupIxs = async (
|
|
32
32
|
kaminoMarket: KaminoMarket,
|
|
33
33
|
user: PublicKey,
|
|
34
34
|
referrer: PublicKey = PublicKey.default,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/classes/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,OAAO,MAAM,oBAAoB,CAAC;AAEzC,qIAAqI;AACrI,MAAM,MAAM,YAAY,GAAG;IACzB,oBAAoB,EAAE,sBAAsB,EAAE,CAAC;IAC/C,YAAY,EAAE,sBAAsB,EAAE,CAAC;IACvC,WAAW,EAAE,sBAAsB,CAAC;IACpC,cAAc,EAAE,sBAAsB,EAAE,CAAC;IACzC,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,YAAY,EAAE,sBAAsB,CAAC;IACrC,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,yBAAyB,EAAE,sBAAsB,CAAC;IAClD,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,mBAAmB,EAAE,sBAAsB,CAAC;IAC5C,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,+IAA+I;AAC/I,MAAM,MAAM,eAAe,GAAG;IAC5B,mBAAmB,EAAE,sBAAsB,EAAE,CAAC;IAC9C,UAAU,EAAE,sBAAsB,EAAE,CAAC;CACtC,CAAC;AAEF,0JAA0J;AAC1J,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,sBAAsB,EAAE,CAAC;IACrC,sBAAsB,EAAE,sBAAsB,EAAE,CAAC;CAClD,CAAC;AAEF,qJAAqJ;AACrJ,MAAM,MAAM,WAAW,GAAG;IACxB,0BAA0B,EAAE,sBAAsB,EAAE,CAAC;IACrD,WAAW,EAAE,sBAAsB,EAAE,CAAC;CACvC,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,OAAO,CAAC;IACtB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/classes/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { VaultHoldings, VaultHoldingsWithUSDValue, VaultOverview } from './vault';
|
|
2
|
-
export declare function holdingsToJson(holdings: VaultHoldings): {
|
|
3
|
-
available: string;
|
|
4
|
-
invested: string;
|
|
5
|
-
totalAUMIncludingFees: string;
|
|
6
|
-
investedInReserves: {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
};
|
|
9
|
-
pendingFees: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function printHoldings(holdings: VaultHoldings): void;
|
|
12
|
-
export declare function printHoldingsWithUSDValue(holdings: VaultHoldingsWithUSDValue): void;
|
|
13
|
-
export declare function printVaultOverview(vaultOverview: VaultOverview): void;
|
|
14
|
-
//# sourceMappingURL=types_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types_utils.d.ts","sourceRoot":"","sources":["../../src/classes/types_utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAElF,wBAAgB,cAAc,CAAC,QAAQ,EAAE,aAAa;;;;;;;;EAQrD;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,aAAa,QAOpD;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,yBAAyB,QAO5E;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,aAAa,QAiB9D"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.holdingsToJson = holdingsToJson;
|
|
4
|
-
exports.printHoldings = printHoldings;
|
|
5
|
-
exports.printHoldingsWithUSDValue = printHoldingsWithUSDValue;
|
|
6
|
-
exports.printVaultOverview = printVaultOverview;
|
|
7
|
-
const utils_1 = require("./utils");
|
|
8
|
-
function holdingsToJson(holdings) {
|
|
9
|
-
return {
|
|
10
|
-
available: holdings.available.toString(),
|
|
11
|
-
invested: holdings.invested.toString(),
|
|
12
|
-
totalAUMIncludingFees: holdings.totalAUMIncludingFees.toString(),
|
|
13
|
-
investedInReserves: (0, utils_1.pubkeyHashMapToJson)(holdings.investedInReserves),
|
|
14
|
-
pendingFees: holdings.pendingFees.toString(),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function printHoldings(holdings) {
|
|
18
|
-
console.log('Holdings:');
|
|
19
|
-
console.log(' Available:', holdings.available.toString());
|
|
20
|
-
console.log(' Invested:', holdings.invested.toString());
|
|
21
|
-
console.log(' Total AUM including fees:', holdings.totalAUMIncludingFees.toString());
|
|
22
|
-
console.log(' Pending fees:', holdings.pendingFees.toString());
|
|
23
|
-
console.log(' Invested in reserves:', (0, utils_1.pubkeyHashMapToJson)(holdings.investedInReserves));
|
|
24
|
-
}
|
|
25
|
-
function printHoldingsWithUSDValue(holdings) {
|
|
26
|
-
console.log('Holdings with USD value:');
|
|
27
|
-
console.log(' Available:', holdings.availableUSD.toString());
|
|
28
|
-
console.log(' Invested:', holdings.investedUSD.toString());
|
|
29
|
-
console.log(' Total including pending fees:', holdings.totalUSDIncludingFees.toString());
|
|
30
|
-
console.log(' Pending fees:', holdings.pendingFeesUSD.toString());
|
|
31
|
-
console.log(' Invested in reserves:', (0, utils_1.pubkeyHashMapToJson)(holdings.investedInReservesUSD));
|
|
32
|
-
}
|
|
33
|
-
function printVaultOverview(vaultOverview) {
|
|
34
|
-
console.log('Vault overview:');
|
|
35
|
-
printHoldingsWithUSDValue(vaultOverview.holdingsUSD);
|
|
36
|
-
console.log(' Theoretical Supply APY:', vaultOverview.theoreticalSupplyAPY.toString());
|
|
37
|
-
console.log(' Utilization ratio:', vaultOverview.utilizationRatio.toString());
|
|
38
|
-
console.log(' Total supplied:', vaultOverview.totalSupplied.toString());
|
|
39
|
-
console.log(' Borrowed amount:', vaultOverview.totalBorrowed.toString());
|
|
40
|
-
vaultOverview.reservesOverview.forEach((reserveOverview, pubkey) => {
|
|
41
|
-
console.log(' Reserve:', pubkey.toString());
|
|
42
|
-
console.log(' Total borrowed from reserve:', reserveOverview.totalBorrowedAmount.toString());
|
|
43
|
-
console.log(' Supplied:', reserveOverview.suppliedAmount.toString());
|
|
44
|
-
console.log(' Utilization ratio:', reserveOverview.utilizationRatio.toString());
|
|
45
|
-
console.log(' Liquidation Threshold Pct:', reserveOverview.liquidationThresholdPct.toString());
|
|
46
|
-
console.log(' Supply APY:', reserveOverview.supplyAPY.toString());
|
|
47
|
-
console.log(' Lending market:', reserveOverview.market.toString());
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=types_utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types_utils.js","sourceRoot":"","sources":["../../src/classes/types_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C,QAAQ,EAAE,CAAC,CAAC;QACxE,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,eAAe,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,eAAe,CAAC,uBAAuB,CAAC,QAAQ,EAAE,CAAC,CAAC;QAClG,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,eAAe,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { pubkeyHashMapToJson } from './utils';
|
|
2
|
-
import { VaultHoldings, VaultHoldingsWithUSDValue, VaultOverview } from './vault';
|
|
3
|
-
|
|
4
|
-
export function holdingsToJson(holdings: VaultHoldings) {
|
|
5
|
-
return {
|
|
6
|
-
available: holdings.available.toString(),
|
|
7
|
-
invested: holdings.invested.toString(),
|
|
8
|
-
totalAUMIncludingFees: holdings.totalAUMIncludingFees.toString(),
|
|
9
|
-
investedInReserves: pubkeyHashMapToJson(holdings.investedInReserves),
|
|
10
|
-
pendingFees: holdings.pendingFees.toString(),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function printHoldings(holdings: VaultHoldings) {
|
|
15
|
-
console.log('Holdings:');
|
|
16
|
-
console.log(' Available:', holdings.available.toString());
|
|
17
|
-
console.log(' Invested:', holdings.invested.toString());
|
|
18
|
-
console.log(' Total AUM including fees:', holdings.totalAUMIncludingFees.toString());
|
|
19
|
-
console.log(' Pending fees:', holdings.pendingFees.toString());
|
|
20
|
-
console.log(' Invested in reserves:', pubkeyHashMapToJson(holdings.investedInReserves));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function printHoldingsWithUSDValue(holdings: VaultHoldingsWithUSDValue) {
|
|
24
|
-
console.log('Holdings with USD value:');
|
|
25
|
-
console.log(' Available:', holdings.availableUSD.toString());
|
|
26
|
-
console.log(' Invested:', holdings.investedUSD.toString());
|
|
27
|
-
console.log(' Total including pending fees:', holdings.totalUSDIncludingFees.toString());
|
|
28
|
-
console.log(' Pending fees:', holdings.pendingFeesUSD.toString());
|
|
29
|
-
console.log(' Invested in reserves:', pubkeyHashMapToJson(holdings.investedInReservesUSD));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function printVaultOverview(vaultOverview: VaultOverview) {
|
|
33
|
-
console.log('Vault overview:');
|
|
34
|
-
printHoldingsWithUSDValue(vaultOverview.holdingsUSD);
|
|
35
|
-
console.log(' Theoretical Supply APY:', vaultOverview.theoreticalSupplyAPY.toString());
|
|
36
|
-
console.log(' Utilization ratio:', vaultOverview.utilizationRatio.toString());
|
|
37
|
-
console.log(' Total supplied:', vaultOverview.totalSupplied.toString());
|
|
38
|
-
console.log(' Borrowed amount:', vaultOverview.totalBorrowed.toString());
|
|
39
|
-
|
|
40
|
-
vaultOverview.reservesOverview.forEach((reserveOverview, pubkey) => {
|
|
41
|
-
console.log(' Reserve:', pubkey.toString());
|
|
42
|
-
console.log(' Total borrowed from reserve:', reserveOverview.totalBorrowedAmount.toString());
|
|
43
|
-
console.log(' Supplied:', reserveOverview.suppliedAmount.toString());
|
|
44
|
-
console.log(' Utilization ratio:', reserveOverview.utilizationRatio.toString());
|
|
45
|
-
console.log(' Liquidation Threshold Pct:', reserveOverview.liquidationThresholdPct.toString());
|
|
46
|
-
console.log(' Supply APY:', reserveOverview.supplyAPY.toString());
|
|
47
|
-
console.log(' Lending market:', reserveOverview.market.toString());
|
|
48
|
-
});
|
|
49
|
-
}
|