@kamino-finance/klend-sdk 5.11.6-beta.0 → 5.11.7
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 +27 -35
- package/dist/classes/action.d.ts.map +1 -1
- package/dist/classes/action.js +198 -344
- package/dist/classes/action.js.map +1 -1
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.d.ts.map +1 -1
- package/dist/classes/index.js +1 -0
- package/dist/classes/index.js.map +1 -1
- package/dist/classes/manager.d.ts +6 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +16 -1
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts +3 -3
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js +30 -16
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/obligation.d.ts +2 -0
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +5 -0
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/vault.d.ts +1 -0
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +26 -20
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +11 -0
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts +6 -3
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js +13 -7
- package/dist/idl_codegen_kamino_vault/accounts/VaultState.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts +25 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js +43 -1
- package/dist/idl_codegen_kamino_vault/errors/custom.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/giveUpPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js +1 -0
- package/dist/idl_codegen_kamino_vault/instructions/initVault.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateReserveAllocation.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateSharesMetadata.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/updateVaultConfig.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js +1 -1
- package/dist/idl_codegen_kamino_vault/instructions/withdrawPendingFees.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts +13 -0
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js +25 -1
- package/dist/idl_codegen_kamino_vault/types/VaultConfigField.js.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.d.ts +2 -2
- package/dist/idl_codegen_kamino_vault/types/index.d.ts.map +1 -1
- package/dist/idl_codegen_kamino_vault/types/index.js.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.d.ts +4 -4
- package/dist/lending_operations/repay_with_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/repay_with_collateral_operations.js +10 -8
- package/dist/lending_operations/repay_with_collateral_operations.js.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.d.ts +2 -2
- package/dist/lending_operations/swap_collateral_operations.d.ts.map +1 -1
- package/dist/lending_operations/swap_collateral_operations.js +11 -6
- package/dist/lending_operations/swap_collateral_operations.js.map +1 -1
- package/dist/leverage/operations.d.ts +9 -7
- package/dist/leverage/operations.d.ts.map +1 -1
- package/dist/leverage/operations.js +78 -66
- package/dist/leverage/operations.js.map +1 -1
- package/dist/leverage/types.d.ts +4 -4
- package/dist/leverage/types.d.ts.map +1 -1
- package/dist/utils/ObligationType.d.ts +1 -1
- package/dist/utils/ObligationType.d.ts.map +1 -1
- package/dist/utils/accountListing.d.ts +4 -4
- package/dist/utils/accountListing.d.ts.map +1 -1
- package/dist/utils/accountListing.js +3 -3
- package/dist/utils/accountListing.js.map +1 -1
- package/dist/utils/constants.d.ts +6 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +7 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +7 -52
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/oracle.d.ts +3 -3
- package/dist/utils/oracle.d.ts.map +1 -1
- package/dist/utils/oracle.js +4 -3
- package/dist/utils/oracle.js.map +1 -1
- package/package.json +2 -2
- package/src/classes/action.ts +225 -400
- package/src/classes/index.ts +1 -0
- package/src/classes/manager.ts +27 -1
- package/src/classes/market.ts +34 -25
- package/src/classes/obligation.ts +6 -0
- package/src/classes/types.ts +1 -1
- package/src/classes/vault.ts +28 -24
- package/src/client.ts +40 -9
- package/src/client_kamino_manager.ts +15 -0
- package/src/idl_codegen_kamino_vault/accounts/VaultState.ts +17 -9
- package/src/idl_codegen_kamino_vault/errors/custom.ts +42 -0
- package/src/idl_codegen_kamino_vault/instructions/giveUpPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/initVault.ts +2 -0
- package/src/idl_codegen_kamino_vault/instructions/initializeSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateReserveAllocation.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateSharesMetadata.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/updateVaultConfig.ts +2 -2
- package/src/idl_codegen_kamino_vault/instructions/withdrawPendingFees.ts +2 -2
- package/src/idl_codegen_kamino_vault/types/VaultConfigField.ts +30 -0
- package/src/idl_codegen_kamino_vault/types/index.ts +2 -0
- package/src/idl_kamino_vault.json +35 -8
- package/src/lending_operations/repay_with_collateral_operations.ts +15 -11
- package/src/lending_operations/swap_collateral_operations.ts +19 -7
- package/src/leverage/operations.ts +114 -66
- package/src/leverage/types.ts +4 -4
- package/src/utils/ObligationType.ts +1 -1
- package/src/utils/accountListing.ts +11 -7
- package/src/utils/constants.ts +7 -0
- package/src/utils/managerTypes.ts +10 -52
- package/src/utils/oracle.ts +7 -6
package/src/classes/index.ts
CHANGED
package/src/classes/manager.ts
CHANGED
|
@@ -575,6 +575,32 @@ export class KaminoManager {
|
|
|
575
575
|
return this._vaultClient.getAllVaults();
|
|
576
576
|
}
|
|
577
577
|
|
|
578
|
+
/**
|
|
579
|
+
* Get all lending markets
|
|
580
|
+
* @returns an array of all lending markets
|
|
581
|
+
*/
|
|
582
|
+
async getAllMarkets(): Promise<KaminoMarket[]> {
|
|
583
|
+
const lendingMarketsAccounts = await getProgramAccounts(
|
|
584
|
+
this.getConnection(),
|
|
585
|
+
this._kaminoLendProgramId,
|
|
586
|
+
LendingMarket.layout.span + 8,
|
|
587
|
+
{
|
|
588
|
+
commitment: this.getConnection().commitment ?? 'processed',
|
|
589
|
+
filters: [
|
|
590
|
+
{ dataSize: LendingMarket.layout.span + 8 },
|
|
591
|
+
{ memcmp: { offset: 0, bytes: bs58.encode(LendingMarket.discriminator) } },
|
|
592
|
+
],
|
|
593
|
+
}
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
const markets = await Promise.all(
|
|
597
|
+
lendingMarketsAccounts.map((account) =>
|
|
598
|
+
KaminoMarket.load(this._connection, account.pubkey, this.recentSlotDurationMs, this._kaminoLendProgramId)
|
|
599
|
+
)
|
|
600
|
+
);
|
|
601
|
+
return markets.filter((market): market is KaminoMarket => market !== null);
|
|
602
|
+
}
|
|
603
|
+
|
|
578
604
|
/**
|
|
579
605
|
* Get all vaults for owner
|
|
580
606
|
* @param owner the pubkey of the vaults owner
|
|
@@ -949,7 +975,7 @@ export class KaminoManager {
|
|
|
949
975
|
}
|
|
950
976
|
|
|
951
977
|
/**
|
|
952
|
-
* This
|
|
978
|
+
* This returns an array of scope oracle configs to be used to set the scope price and twap oracles for a reserve
|
|
953
979
|
* @param feed - scope feed to fetch prices from
|
|
954
980
|
* @param cluster - cluster to fetch from, this should be left unchanged unless working on devnet or locally
|
|
955
981
|
* @returns - an array of scope oracle configs
|
package/src/classes/market.ts
CHANGED
|
@@ -29,7 +29,7 @@ import Decimal from 'decimal.js';
|
|
|
29
29
|
import { FarmState } from '@kamino-finance/farms-sdk';
|
|
30
30
|
import { PROGRAM_ID } from '../idl_codegen/programId';
|
|
31
31
|
import bs58 from 'bs58';
|
|
32
|
-
import { OraclePrices, Scope } from '@kamino-finance/scope-sdk';
|
|
32
|
+
import { OraclePrices, Scope, U16_MAX } from '@kamino-finance/scope-sdk';
|
|
33
33
|
import { Fraction } from './fraction';
|
|
34
34
|
import { chunks, KaminoPrices, MintToPriceMap } from '@kamino-finance/kliquidity-sdk';
|
|
35
35
|
import { parseTokenSymbol, parseZeroPaddedUtf8 } from './utils';
|
|
@@ -59,8 +59,6 @@ export class KaminoMarket {
|
|
|
59
59
|
|
|
60
60
|
readonly programId: PublicKey;
|
|
61
61
|
|
|
62
|
-
scope: Scope;
|
|
63
|
-
|
|
64
62
|
private readonly recentSlotDurationMs: number;
|
|
65
63
|
|
|
66
64
|
private constructor(
|
|
@@ -68,7 +66,6 @@ export class KaminoMarket {
|
|
|
68
66
|
state: LendingMarket,
|
|
69
67
|
marketAddress: string,
|
|
70
68
|
reserves: Map<PublicKey, KaminoReserve>,
|
|
71
|
-
scope: Scope,
|
|
72
69
|
recentSlotDurationMs: number,
|
|
73
70
|
programId: PublicKey = PROGRAM_ID
|
|
74
71
|
) {
|
|
@@ -78,7 +75,6 @@ export class KaminoMarket {
|
|
|
78
75
|
this.reserves = reserves;
|
|
79
76
|
this.reservesActive = getReservesActive(this.reserves);
|
|
80
77
|
this.programId = programId;
|
|
81
|
-
this.scope = scope;
|
|
82
78
|
this.recentSlotDurationMs = recentSlotDurationMs;
|
|
83
79
|
}
|
|
84
80
|
|
|
@@ -97,7 +93,6 @@ export class KaminoMarket {
|
|
|
97
93
|
marketAddress: PublicKey,
|
|
98
94
|
recentSlotDurationMs: number,
|
|
99
95
|
programId: PublicKey = PROGRAM_ID,
|
|
100
|
-
setupLocalTest: boolean = false,
|
|
101
96
|
withReserves: boolean = true
|
|
102
97
|
) {
|
|
103
98
|
const market = await LendingMarket.fetch(connection, marketAddress, programId);
|
|
@@ -105,26 +100,12 @@ export class KaminoMarket {
|
|
|
105
100
|
if (market === null) {
|
|
106
101
|
return null;
|
|
107
102
|
}
|
|
108
|
-
let scope: Scope;
|
|
109
|
-
if (!setupLocalTest) {
|
|
110
|
-
scope = new Scope('mainnet-beta', connection);
|
|
111
|
-
} else {
|
|
112
|
-
scope = new Scope('localnet', connection);
|
|
113
|
-
}
|
|
114
103
|
|
|
115
104
|
const reserves = withReserves
|
|
116
105
|
? await getReservesForMarket(marketAddress, connection, programId, recentSlotDurationMs)
|
|
117
106
|
: new Map<PublicKey, KaminoReserve>();
|
|
118
107
|
|
|
119
|
-
return new KaminoMarket(
|
|
120
|
-
connection,
|
|
121
|
-
market,
|
|
122
|
-
marketAddress.toString(),
|
|
123
|
-
reserves,
|
|
124
|
-
scope,
|
|
125
|
-
recentSlotDurationMs,
|
|
126
|
-
programId
|
|
127
|
-
);
|
|
108
|
+
return new KaminoMarket(connection, market, marketAddress.toString(), reserves, recentSlotDurationMs, programId);
|
|
128
109
|
}
|
|
129
110
|
|
|
130
111
|
async reload(): Promise<void> {
|
|
@@ -1186,9 +1167,9 @@ export class KaminoMarket {
|
|
|
1186
1167
|
/**
|
|
1187
1168
|
* Get all Scope prices used by all the market reserves
|
|
1188
1169
|
*/
|
|
1189
|
-
async getAllScopePrices(oraclePrices?: OraclePrices): Promise<KaminoPrices> {
|
|
1170
|
+
async getAllScopePrices(scope: Scope, oraclePrices?: OraclePrices): Promise<KaminoPrices> {
|
|
1190
1171
|
if (!oraclePrices) {
|
|
1191
|
-
oraclePrices = await
|
|
1172
|
+
oraclePrices = await scope.getOraclePrices();
|
|
1192
1173
|
}
|
|
1193
1174
|
const spot: MintToPriceMap = {};
|
|
1194
1175
|
const twaps: MintToPriceMap = {};
|
|
@@ -1199,11 +1180,11 @@ export class KaminoMarket {
|
|
|
1199
1180
|
const chain = reserve.state.config.tokenInfo.scopeConfiguration.priceChain;
|
|
1200
1181
|
const twapChain = reserve.state.config.tokenInfo.scopeConfiguration.twapChain.filter((x) => x > 0);
|
|
1201
1182
|
if (oracle && isNotNullPubkey(oracle) && chain && Scope.isScopeChainValid(chain)) {
|
|
1202
|
-
const spotPrice = await
|
|
1183
|
+
const spotPrice = await scope.getPriceFromChain(chain, oraclePrices);
|
|
1203
1184
|
spot[tokenMint] = { price: spotPrice.price, name: tokenName };
|
|
1204
1185
|
}
|
|
1205
1186
|
if (oracle && isNotNullPubkey(oracle) && twapChain && Scope.isScopeChainValid(twapChain)) {
|
|
1206
|
-
const twap = await
|
|
1187
|
+
const twap = await scope.getPriceFromChain(twapChain, oraclePrices);
|
|
1207
1188
|
twaps[tokenMint] = { price: twap.price, name: tokenName };
|
|
1208
1189
|
}
|
|
1209
1190
|
}
|
|
@@ -1527,6 +1508,34 @@ export function getReservesActive(reserves: Map<PublicKey, KaminoReserve>): Map<
|
|
|
1527
1508
|
return reservesActive;
|
|
1528
1509
|
}
|
|
1529
1510
|
|
|
1511
|
+
export function getTokenIdsForScopeRefresh(kaminoMarket: KaminoMarket, reserves: PublicKey[]): number[] {
|
|
1512
|
+
const tokenIds: number[] = [];
|
|
1513
|
+
|
|
1514
|
+
for (const reserveAddress of reserves) {
|
|
1515
|
+
const reserve = kaminoMarket.getReserveByAddress(reserveAddress);
|
|
1516
|
+
if (!reserve) {
|
|
1517
|
+
throw new Error(`Reserve not found for reserve ${reserveAddress.toBase58()}`);
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
if (!reserve.state.config.tokenInfo.scopeConfiguration.priceFeed.equals(PublicKey.default)) {
|
|
1521
|
+
let x = 0;
|
|
1522
|
+
|
|
1523
|
+
while (reserve.state.config.tokenInfo.scopeConfiguration.priceChain[x] !== U16_MAX) {
|
|
1524
|
+
tokenIds.push(reserve.state.config.tokenInfo.scopeConfiguration.priceChain[x]);
|
|
1525
|
+
x++;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
x = 0;
|
|
1529
|
+
while (reserve.state.config.tokenInfo.scopeConfiguration.twapChain[x] !== U16_MAX) {
|
|
1530
|
+
tokenIds.push(reserve.state.config.tokenInfo.scopeConfiguration.twapChain[x]);
|
|
1531
|
+
x++;
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
return tokenIds;
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1530
1539
|
export async function getReserveFromMintAndMarket(
|
|
1531
1540
|
connection: Connection,
|
|
1532
1541
|
market: KaminoMarket,
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
getObligationPdaWithArgs,
|
|
18
18
|
getObligationType,
|
|
19
19
|
isNotNullPubkey,
|
|
20
|
+
ObligationType,
|
|
20
21
|
PubkeyHashMap,
|
|
21
22
|
TOTAL_NUMBER_OF_IDS_TO_CHECK,
|
|
22
23
|
U64_MAX,
|
|
@@ -1593,3 +1594,8 @@ export class KaminoObligation {
|
|
|
1593
1594
|
}
|
|
1594
1595
|
}
|
|
1595
1596
|
}
|
|
1597
|
+
|
|
1598
|
+
// Create a function that checks if an obligation is of type obligation or obligationType
|
|
1599
|
+
export function isKaminoObligation(obligation: KaminoObligation | ObligationType): obligation is KaminoObligation {
|
|
1600
|
+
return 'obligationAddress' in obligation;
|
|
1601
|
+
}
|
package/src/classes/types.ts
CHANGED
package/src/classes/vault.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
SYSVAR_RENT_PUBKEY,
|
|
12
12
|
TransactionInstruction,
|
|
13
13
|
} from '@solana/web3.js';
|
|
14
|
-
import { NATIVE_MINT, TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
|
|
14
|
+
import { getAssociatedTokenAddressSync, NATIVE_MINT, TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
|
|
15
15
|
import {
|
|
16
16
|
getAssociatedTokenAddress,
|
|
17
17
|
getTransferWsolIxns,
|
|
@@ -100,6 +100,8 @@ const CTOKEN_VAULT_SEED = 'ctoken_vault';
|
|
|
100
100
|
const BASE_VAULT_AUTHORITY_SEED = 'authority';
|
|
101
101
|
const SHARES_SEED = 'shares';
|
|
102
102
|
|
|
103
|
+
export const INITIAL_DEPOSIT_LAMPORTS = 1000;
|
|
104
|
+
|
|
103
105
|
/**
|
|
104
106
|
* KaminoVaultClient is a class that provides a high-level interface to interact with the Kamino Vault program.
|
|
105
107
|
*/
|
|
@@ -195,6 +197,8 @@ export class KaminoVaultClient {
|
|
|
195
197
|
this._kaminoVaultProgramId
|
|
196
198
|
)[0];
|
|
197
199
|
|
|
200
|
+
const adminTokenAccount = getAssociatedTokenAddressSync(vaultConfig.tokenMint, vaultConfig.admin, false);
|
|
201
|
+
|
|
198
202
|
const initVaultAccounts: InitVaultAccounts = {
|
|
199
203
|
adminAuthority: vaultConfig.admin,
|
|
200
204
|
vaultState: vaultState.publicKey,
|
|
@@ -206,6 +210,7 @@ export class KaminoVaultClient {
|
|
|
206
210
|
rent: SYSVAR_RENT_PUBKEY,
|
|
207
211
|
tokenProgram: vaultConfig.tokenMintProgramId,
|
|
208
212
|
sharesTokenProgram: TOKEN_PROGRAM_ID,
|
|
213
|
+
adminTokenAccount,
|
|
209
214
|
};
|
|
210
215
|
const initVaultIx = initVault(initVaultAccounts, this._kaminoVaultProgramId);
|
|
211
216
|
|
|
@@ -288,7 +293,7 @@ export class KaminoVaultClient {
|
|
|
288
293
|
);
|
|
289
294
|
|
|
290
295
|
const updateReserveAllocationAccounts: UpdateReserveAllocationAccounts = {
|
|
291
|
-
|
|
296
|
+
signer: vaultState.vaultAdminAuthority,
|
|
292
297
|
vaultState: vault.address,
|
|
293
298
|
baseVaultAuthority: vaultState.baseVaultAuthority,
|
|
294
299
|
reserveCollateralMint: reserveState.collateral.mintPubkey,
|
|
@@ -296,7 +301,7 @@ export class KaminoVaultClient {
|
|
|
296
301
|
ctokenVault: cTokenVault,
|
|
297
302
|
systemProgram: SystemProgram.programId,
|
|
298
303
|
rent: SYSVAR_RENT_PUBKEY,
|
|
299
|
-
reserveCollateralTokenProgram:
|
|
304
|
+
reserveCollateralTokenProgram: TOKEN_PROGRAM_ID,
|
|
300
305
|
};
|
|
301
306
|
|
|
302
307
|
const updateReserveAllocationArgs: UpdateReserveAllocationArgs = {
|
|
@@ -320,7 +325,7 @@ export class KaminoVaultClient {
|
|
|
320
325
|
accountsToAddToLUT.push(lendingMarketAuth);
|
|
321
326
|
|
|
322
327
|
const insertIntoLUTIxs = await this.insertIntoLookupTableIxs(
|
|
323
|
-
vaultState.
|
|
328
|
+
vaultState.vaultAdminAuthority,
|
|
324
329
|
vaultState.vaultLookupTable,
|
|
325
330
|
accountsToAddToLUT
|
|
326
331
|
);
|
|
@@ -350,12 +355,12 @@ export class KaminoVaultClient {
|
|
|
350
355
|
const vaultState: VaultState = await vault.getState(this.getConnection());
|
|
351
356
|
|
|
352
357
|
const updateVaultConfigAccs: UpdateVaultConfigAccounts = {
|
|
353
|
-
|
|
358
|
+
vaultAdminAuthority: vaultState.vaultAdminAuthority,
|
|
354
359
|
vaultState: vault.address,
|
|
355
360
|
klendProgram: this._kaminoLendProgramId,
|
|
356
361
|
};
|
|
357
362
|
if (signer) {
|
|
358
|
-
updateVaultConfigAccs.
|
|
363
|
+
updateVaultConfigAccs.vaultAdminAuthority = signer;
|
|
359
364
|
}
|
|
360
365
|
|
|
361
366
|
const updateVaultConfigArgs: UpdateVaultConfigArgs = {
|
|
@@ -409,7 +414,7 @@ export class KaminoVaultClient {
|
|
|
409
414
|
if (mode.kind === new VaultConfigField.PendingVaultAdmin().kind) {
|
|
410
415
|
const newPubkey = new PublicKey(value);
|
|
411
416
|
const insertIntoLutIxs = await this.insertIntoLookupTableIxs(
|
|
412
|
-
vaultState.
|
|
417
|
+
vaultState.vaultAdminAuthority,
|
|
413
418
|
vaultState.vaultLookupTable,
|
|
414
419
|
[newPubkey]
|
|
415
420
|
);
|
|
@@ -427,7 +432,7 @@ export class KaminoVaultClient {
|
|
|
427
432
|
farmState!.globalConfig
|
|
428
433
|
);
|
|
429
434
|
const insertIntoLutIxs = await this.insertIntoLookupTableIxs(
|
|
430
|
-
vaultState.
|
|
435
|
+
vaultState.vaultAdminAuthority,
|
|
431
436
|
vaultState.vaultLookupTable,
|
|
432
437
|
keysToAddToLUT
|
|
433
438
|
);
|
|
@@ -476,7 +481,7 @@ export class KaminoVaultClient {
|
|
|
476
481
|
value: string
|
|
477
482
|
): TransactionInstruction {
|
|
478
483
|
const updateVaultConfigAccs: UpdateVaultConfigAccounts = {
|
|
479
|
-
|
|
484
|
+
vaultAdminAuthority: admin,
|
|
480
485
|
vaultState: vault,
|
|
481
486
|
klendProgram: this._kaminoLendProgramId,
|
|
482
487
|
};
|
|
@@ -526,7 +531,7 @@ export class KaminoVaultClient {
|
|
|
526
531
|
|
|
527
532
|
// read the current LUT and create a new one for the new admin and backfill it
|
|
528
533
|
const accountsInExistentLUT = (await getAccountsInLUT(this.getConnection(), vaultState.vaultLookupTable)).filter(
|
|
529
|
-
(account) => !account.equals(vaultState.
|
|
534
|
+
(account) => !account.equals(vaultState.vaultAdminAuthority)
|
|
530
535
|
);
|
|
531
536
|
|
|
532
537
|
const LUTIxs: TransactionInstruction[] = [];
|
|
@@ -569,7 +574,7 @@ export class KaminoVaultClient {
|
|
|
569
574
|
const vaultState: VaultState = await vault.getState(this.getConnection());
|
|
570
575
|
|
|
571
576
|
const giveUpPendingFeesAccounts: GiveUpPendingFeesAccounts = {
|
|
572
|
-
|
|
577
|
+
vaultAdminAuthority: vaultState.vaultAdminAuthority,
|
|
573
578
|
vaultState: vault.address,
|
|
574
579
|
klendProgram: this._kaminoLendProgramId,
|
|
575
580
|
};
|
|
@@ -599,7 +604,7 @@ export class KaminoVaultClient {
|
|
|
599
604
|
): Promise<TransactionInstruction[]> {
|
|
600
605
|
const vaultState: VaultState = await vault.getState(this.getConnection());
|
|
601
606
|
const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
|
|
602
|
-
const [{ ata: adminTokenAta, createAtaIx }] = createAtasIdempotent(vaultState.
|
|
607
|
+
const [{ ata: adminTokenAta, createAtaIx }] = createAtasIdempotent(vaultState.vaultAdminAuthority, [
|
|
603
608
|
{
|
|
604
609
|
mint: vaultState.tokenMint,
|
|
605
610
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
@@ -1010,20 +1015,16 @@ export class KaminoVaultClient {
|
|
|
1010
1015
|
if (allReserves.length === 0) {
|
|
1011
1016
|
throw new Error('No reserves found for the vault, please select at least one reserve for the vault');
|
|
1012
1017
|
}
|
|
1013
|
-
|
|
1014
1018
|
const [allReservesStateMap, computedReservesAllocation] = await Promise.all([
|
|
1015
1019
|
this.loadVaultReserves(vaultState),
|
|
1016
1020
|
this.getVaultComputedReservesAllocation(vaultState),
|
|
1017
1021
|
]);
|
|
1018
|
-
|
|
1019
1022
|
const tokenProgram = await getAccountOwner(this.getConnection(), vaultState.tokenMint);
|
|
1020
1023
|
const [{ ata: _payerTokenAta, createAtaIx }] = createAtasIdempotent(payer, [
|
|
1021
1024
|
{ mint: vaultState.tokenMint, tokenProgram },
|
|
1022
1025
|
]);
|
|
1023
|
-
|
|
1024
1026
|
// compute total vault holdings and expected distribution based on weights
|
|
1025
1027
|
const curentVaultAllocations = this.getVaultAllocations(vaultState);
|
|
1026
|
-
|
|
1027
1028
|
const reservesToDisinvestFrom: PublicKey[] = [];
|
|
1028
1029
|
const reservesToInvestInto: PublicKey[] = [];
|
|
1029
1030
|
|
|
@@ -1294,7 +1295,7 @@ export class KaminoVaultClient {
|
|
|
1294
1295
|
const lendingMarketAuth = lendingMarketAuthPda(marketAddress, this._kaminoLendProgramId)[0];
|
|
1295
1296
|
|
|
1296
1297
|
const withdrawPendingFeesAccounts: WithdrawPendingFeesAccounts = {
|
|
1297
|
-
|
|
1298
|
+
vaultAdminAuthority: vaultState.vaultAdminAuthority,
|
|
1298
1299
|
vaultState: vault.address,
|
|
1299
1300
|
reserve: reserve.address,
|
|
1300
1301
|
tokenVault: vaultState.tokenVault,
|
|
@@ -1354,7 +1355,7 @@ export class KaminoVaultClient {
|
|
|
1354
1355
|
const vaultState = await vault.getState(this.getConnection());
|
|
1355
1356
|
const allAccountsToBeInserted = [
|
|
1356
1357
|
vault.address,
|
|
1357
|
-
vaultState.
|
|
1358
|
+
vaultState.vaultAdminAuthority,
|
|
1358
1359
|
vaultState.baseVaultAuthority,
|
|
1359
1360
|
vaultState.tokenMint,
|
|
1360
1361
|
vaultState.tokenVault,
|
|
@@ -1399,7 +1400,7 @@ export class KaminoVaultClient {
|
|
|
1399
1400
|
let lut = vaultState.vaultLookupTable;
|
|
1400
1401
|
if (lut.equals(PublicKey.default)) {
|
|
1401
1402
|
const recentSlot = await this.getConnection().getSlot();
|
|
1402
|
-
const [ixn, address] = initLookupTableIx(vaultState.
|
|
1403
|
+
const [ixn, address] = initLookupTableIx(vaultState.vaultAdminAuthority, recentSlot);
|
|
1403
1404
|
setupLUTIfNeededIxs.push(ixn);
|
|
1404
1405
|
lut = address;
|
|
1405
1406
|
|
|
@@ -1419,7 +1420,7 @@ export class KaminoVaultClient {
|
|
|
1419
1420
|
}
|
|
1420
1421
|
ixns.push(
|
|
1421
1422
|
...(await this.insertIntoLookupTableIxs(
|
|
1422
|
-
vaultState.
|
|
1423
|
+
vaultState.vaultAdminAuthority,
|
|
1423
1424
|
lut,
|
|
1424
1425
|
allAccountsToBeInserted,
|
|
1425
1426
|
overridenExistentAccounts
|
|
@@ -1528,16 +1529,19 @@ export class KaminoVaultClient {
|
|
|
1528
1529
|
|
|
1529
1530
|
let totalLeftToInvest = holdings.totalAUMIncludingFees.sub(holdings.pendingFees);
|
|
1530
1531
|
let currentAllocationSum = totalAllocation;
|
|
1531
|
-
const
|
|
1532
|
-
while (totalLeftToInvest.gt(
|
|
1532
|
+
const ONE = new Decimal(1);
|
|
1533
|
+
while (totalLeftToInvest.gt(ONE)) {
|
|
1533
1534
|
const totalLeftover = totalLeftToInvest;
|
|
1534
1535
|
for (const reserve of allReserves) {
|
|
1535
1536
|
const reserveWithWeight = initialVaultAllocations.get(reserve);
|
|
1536
1537
|
const targetAllocation = reserveWithWeight!.targetWeight.mul(totalLeftover).div(currentAllocationSum);
|
|
1537
1538
|
const reserveCap = reserveWithWeight!.tokenAllocationCap;
|
|
1538
|
-
|
|
1539
|
+
let amountToInvest = Decimal.min(targetAllocation, totalLeftToInvest);
|
|
1540
|
+
if (reserveCap.gt(ZERO)) {
|
|
1541
|
+
amountToInvest = Decimal.min(amountToInvest, reserveCap);
|
|
1542
|
+
}
|
|
1539
1543
|
totalLeftToInvest = totalLeftToInvest.sub(amountToInvest);
|
|
1540
|
-
if (amountToInvest.eq(reserveCap)) {
|
|
1544
|
+
if (amountToInvest.eq(reserveCap) && reserveCap.gt(ZERO)) {
|
|
1541
1545
|
currentAllocationSum = currentAllocationSum.sub(reserveWithWeight!.targetWeight);
|
|
1542
1546
|
}
|
|
1543
1547
|
const reserveHasPreallocation = expectedHoldingsDistribution.has(reserve);
|
package/src/client.ts
CHANGED
|
@@ -22,6 +22,7 @@ import { VanillaObligation } from './utils/ObligationType';
|
|
|
22
22
|
import { parseTokenSymbol } from './classes/utils';
|
|
23
23
|
import { Env, initEnv } from '../tests/runner/setup_utils';
|
|
24
24
|
import { initializeFarmsForReserve } from '../tests/runner/farms/farms_operations';
|
|
25
|
+
import { Scope } from '@kamino-finance/scope-sdk';
|
|
25
26
|
|
|
26
27
|
const STAGING_LENDING_MARKET = new PublicKey('6WVSwDQXrBZeQVnu6hpnsRZhodaJTZBUaC334SiiBKdb');
|
|
27
28
|
const MAINNET_LENDING_MARKET = new PublicKey('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
|
|
@@ -61,9 +62,17 @@ async function main() {
|
|
|
61
62
|
.option(`--rpc <string>`, 'The RPC URL')
|
|
62
63
|
.action(async ({ rpc }) => {
|
|
63
64
|
const connection = new Connection(rpc, {});
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
let count = 0;
|
|
66
|
+
for await (const [address, lendingMarketAccount] of getAllLendingMarketAccounts(connection)) {
|
|
67
|
+
count++;
|
|
68
|
+
console.log(
|
|
69
|
+
address.toString(),
|
|
70
|
+
lendingMarketAccount.riskCouncil.toString(),
|
|
71
|
+
lendingMarketAccount.autodeleverageEnabled,
|
|
72
|
+
lendingMarketAccount.individualAutodeleverageMarginCallPeriodSecs.toString()
|
|
73
|
+
);
|
|
66
74
|
}
|
|
75
|
+
console.log(`Total lending markets: ${count}`);
|
|
67
76
|
});
|
|
68
77
|
|
|
69
78
|
commands
|
|
@@ -83,9 +92,17 @@ async function main() {
|
|
|
83
92
|
.option(`--rpc <string>`, 'The RPC URL')
|
|
84
93
|
.action(async ({ rpc }) => {
|
|
85
94
|
const connection = new Connection(rpc, {});
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
let count = 0;
|
|
96
|
+
for await (const [address, obligationAccount] of getAllObligationAccounts(connection)) {
|
|
97
|
+
count++;
|
|
98
|
+
if (
|
|
99
|
+
obligationAccount.autodeleverageTargetLtvPct > 0 ||
|
|
100
|
+
obligationAccount.autodeleverageMarginCallStartedTimestamp.toNumber() > 0
|
|
101
|
+
) {
|
|
102
|
+
console.log(address.toString(), toJson(obligationAccount.toJSON()));
|
|
103
|
+
}
|
|
88
104
|
}
|
|
105
|
+
console.log(`Total obligations: ${count}`);
|
|
89
106
|
});
|
|
90
107
|
|
|
91
108
|
commands
|
|
@@ -103,9 +120,19 @@ async function main() {
|
|
|
103
120
|
.option(`--rpc <string>`, 'The RPC URL')
|
|
104
121
|
.action(async ({ rpc }) => {
|
|
105
122
|
const connection = new Connection(rpc, {});
|
|
106
|
-
|
|
107
|
-
|
|
123
|
+
let count = 0;
|
|
124
|
+
const logItems: { address: string; value: string; index: number }[] = [];
|
|
125
|
+
for await (const [address, reserveAccount] of getAllReserveAccounts(connection)) {
|
|
126
|
+
count++;
|
|
127
|
+
const logItem = {
|
|
128
|
+
address: address.toString(),
|
|
129
|
+
value: reserveAccount.config.autodeleverageEnabled.toString(),
|
|
130
|
+
index: count,
|
|
131
|
+
};
|
|
132
|
+
logItems.push(logItem);
|
|
108
133
|
}
|
|
134
|
+
console.log(`Total reserves: ${count}`);
|
|
135
|
+
console.log(logItems);
|
|
109
136
|
});
|
|
110
137
|
|
|
111
138
|
commands
|
|
@@ -309,7 +336,8 @@ async function deposit(connection: Connection, wallet: Keypair, token: string, d
|
|
|
309
336
|
kaminoMarket.getReserveBySymbol(token)!.getLiquidityMint(),
|
|
310
337
|
wallet.publicKey,
|
|
311
338
|
new VanillaObligation(STAGING_LENDING_MARKET),
|
|
312
|
-
true
|
|
339
|
+
true,
|
|
340
|
+
{ scope: new Scope('mainnet-beta', connection), scopeFeed: 'hubble' }
|
|
313
341
|
);
|
|
314
342
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
315
343
|
|
|
@@ -330,7 +358,8 @@ async function withdraw(connection: Connection, wallet: Keypair, token: string,
|
|
|
330
358
|
kaminoMarket.getReserveBySymbol(token)!.getLiquidityMint(),
|
|
331
359
|
wallet.publicKey,
|
|
332
360
|
new VanillaObligation(new PublicKey(STAGING_LENDING_MARKET)),
|
|
333
|
-
true
|
|
361
|
+
true,
|
|
362
|
+
{ scope: new Scope('mainnet-beta', connection), scopeFeed: 'hubble' }
|
|
334
363
|
);
|
|
335
364
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
336
365
|
|
|
@@ -351,7 +380,8 @@ async function borrow(connection: Connection, wallet: Keypair, token: string, bo
|
|
|
351
380
|
kaminoMarket.getReserveBySymbol(token)!.getLiquidityMint(),
|
|
352
381
|
wallet.publicKey,
|
|
353
382
|
new VanillaObligation(new PublicKey(STAGING_LENDING_MARKET)),
|
|
354
|
-
true
|
|
383
|
+
true,
|
|
384
|
+
{ scope: new Scope('mainnet-beta', connection), scopeFeed: 'hubble' }
|
|
355
385
|
);
|
|
356
386
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
357
387
|
|
|
@@ -373,6 +403,7 @@ async function repay(connection: Connection, wallet: Keypair, token: string, bor
|
|
|
373
403
|
wallet.publicKey,
|
|
374
404
|
new VanillaObligation(new PublicKey(STAGING_LENDING_MARKET)),
|
|
375
405
|
true,
|
|
406
|
+
{ scope: new Scope('mainnet-beta', connection), scopeFeed: 'hubble' },
|
|
376
407
|
await connection.getSlot()
|
|
377
408
|
);
|
|
378
409
|
console.log('User obligation', kaminoAction.obligation!.obligationAddress.toString());
|
|
@@ -1019,6 +1019,21 @@ async function main() {
|
|
|
1019
1019
|
);
|
|
1020
1020
|
});
|
|
1021
1021
|
|
|
1022
|
+
commands
|
|
1023
|
+
.command('compute-alloc')
|
|
1024
|
+
.requiredOption('--vault <string>', 'Vault address')
|
|
1025
|
+
.action(async ({ vault }) => {
|
|
1026
|
+
const env = initializeClient(false, false);
|
|
1027
|
+
|
|
1028
|
+
const vaultAddress = new PublicKey(vault);
|
|
1029
|
+
|
|
1030
|
+
const kaminoManager = new KaminoManager(env.connection, env.kLendProgramId, env.kVaultProgramId);
|
|
1031
|
+
const vaultState = await new KaminoVault(vaultAddress, undefined, env.kVaultProgramId).getState(env.connection);
|
|
1032
|
+
|
|
1033
|
+
const computedAllocation = await kaminoManager.getVaultComputedReservesAllocation(vaultState);
|
|
1034
|
+
console.log('computedAllocation', computedAllocation);
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1022
1037
|
commands
|
|
1023
1038
|
.command('download-lending-market-config-and-all-reserves-configs')
|
|
1024
1039
|
.requiredOption('--lending-market <string>', 'Lending Market Address')
|
|
@@ -5,7 +5,7 @@ import * as types from "../types" // eslint-disable-line @typescript-eslint/no-u
|
|
|
5
5
|
import { PROGRAM_ID } from "../programId"
|
|
6
6
|
|
|
7
7
|
export interface VaultStateFields {
|
|
8
|
-
|
|
8
|
+
vaultAdminAuthority: PublicKey
|
|
9
9
|
baseVaultAuthority: PublicKey
|
|
10
10
|
baseVaultAuthorityBump: BN
|
|
11
11
|
tokenMint: PublicKey
|
|
@@ -38,11 +38,12 @@ export interface VaultStateFields {
|
|
|
38
38
|
vaultFarm: PublicKey
|
|
39
39
|
creationTimestamp: BN
|
|
40
40
|
padding1: BN
|
|
41
|
+
allocationAdmin: PublicKey
|
|
41
42
|
padding2: Array<BN>
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export interface VaultStateJSON {
|
|
45
|
-
|
|
46
|
+
vaultAdminAuthority: string
|
|
46
47
|
baseVaultAuthority: string
|
|
47
48
|
baseVaultAuthorityBump: string
|
|
48
49
|
tokenMint: string
|
|
@@ -75,11 +76,12 @@ export interface VaultStateJSON {
|
|
|
75
76
|
vaultFarm: string
|
|
76
77
|
creationTimestamp: string
|
|
77
78
|
padding1: string
|
|
79
|
+
allocationAdmin: string
|
|
78
80
|
padding2: Array<string>
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
export class VaultState {
|
|
82
|
-
readonly
|
|
84
|
+
readonly vaultAdminAuthority: PublicKey
|
|
83
85
|
readonly baseVaultAuthority: PublicKey
|
|
84
86
|
readonly baseVaultAuthorityBump: BN
|
|
85
87
|
readonly tokenMint: PublicKey
|
|
@@ -112,6 +114,7 @@ export class VaultState {
|
|
|
112
114
|
readonly vaultFarm: PublicKey
|
|
113
115
|
readonly creationTimestamp: BN
|
|
114
116
|
readonly padding1: BN
|
|
117
|
+
readonly allocationAdmin: PublicKey
|
|
115
118
|
readonly padding2: Array<BN>
|
|
116
119
|
|
|
117
120
|
static readonly discriminator = Buffer.from([
|
|
@@ -119,7 +122,7 @@ export class VaultState {
|
|
|
119
122
|
])
|
|
120
123
|
|
|
121
124
|
static readonly layout = borsh.struct([
|
|
122
|
-
borsh.publicKey("
|
|
125
|
+
borsh.publicKey("vaultAdminAuthority"),
|
|
123
126
|
borsh.publicKey("baseVaultAuthority"),
|
|
124
127
|
borsh.u64("baseVaultAuthorityBump"),
|
|
125
128
|
borsh.publicKey("tokenMint"),
|
|
@@ -152,11 +155,12 @@ export class VaultState {
|
|
|
152
155
|
borsh.publicKey("vaultFarm"),
|
|
153
156
|
borsh.u64("creationTimestamp"),
|
|
154
157
|
borsh.u64("padding1"),
|
|
155
|
-
borsh.
|
|
158
|
+
borsh.publicKey("allocationAdmin"),
|
|
159
|
+
borsh.array(borsh.u128(), 242, "padding2"),
|
|
156
160
|
])
|
|
157
161
|
|
|
158
162
|
constructor(fields: VaultStateFields) {
|
|
159
|
-
this.
|
|
163
|
+
this.vaultAdminAuthority = fields.vaultAdminAuthority
|
|
160
164
|
this.baseVaultAuthority = fields.baseVaultAuthority
|
|
161
165
|
this.baseVaultAuthorityBump = fields.baseVaultAuthorityBump
|
|
162
166
|
this.tokenMint = fields.tokenMint
|
|
@@ -191,6 +195,7 @@ export class VaultState {
|
|
|
191
195
|
this.vaultFarm = fields.vaultFarm
|
|
192
196
|
this.creationTimestamp = fields.creationTimestamp
|
|
193
197
|
this.padding1 = fields.padding1
|
|
198
|
+
this.allocationAdmin = fields.allocationAdmin
|
|
194
199
|
this.padding2 = fields.padding2
|
|
195
200
|
}
|
|
196
201
|
|
|
@@ -238,7 +243,7 @@ export class VaultState {
|
|
|
238
243
|
const dec = VaultState.layout.decode(data.slice(8))
|
|
239
244
|
|
|
240
245
|
return new VaultState({
|
|
241
|
-
|
|
246
|
+
vaultAdminAuthority: dec.vaultAdminAuthority,
|
|
242
247
|
baseVaultAuthority: dec.baseVaultAuthority,
|
|
243
248
|
baseVaultAuthorityBump: dec.baseVaultAuthorityBump,
|
|
244
249
|
tokenMint: dec.tokenMint,
|
|
@@ -275,13 +280,14 @@ export class VaultState {
|
|
|
275
280
|
vaultFarm: dec.vaultFarm,
|
|
276
281
|
creationTimestamp: dec.creationTimestamp,
|
|
277
282
|
padding1: dec.padding1,
|
|
283
|
+
allocationAdmin: dec.allocationAdmin,
|
|
278
284
|
padding2: dec.padding2,
|
|
279
285
|
})
|
|
280
286
|
}
|
|
281
287
|
|
|
282
288
|
toJSON(): VaultStateJSON {
|
|
283
289
|
return {
|
|
284
|
-
|
|
290
|
+
vaultAdminAuthority: this.vaultAdminAuthority.toString(),
|
|
285
291
|
baseVaultAuthority: this.baseVaultAuthority.toString(),
|
|
286
292
|
baseVaultAuthorityBump: this.baseVaultAuthorityBump.toString(),
|
|
287
293
|
tokenMint: this.tokenMint.toString(),
|
|
@@ -316,13 +322,14 @@ export class VaultState {
|
|
|
316
322
|
vaultFarm: this.vaultFarm.toString(),
|
|
317
323
|
creationTimestamp: this.creationTimestamp.toString(),
|
|
318
324
|
padding1: this.padding1.toString(),
|
|
325
|
+
allocationAdmin: this.allocationAdmin.toString(),
|
|
319
326
|
padding2: this.padding2.map((item) => item.toString()),
|
|
320
327
|
}
|
|
321
328
|
}
|
|
322
329
|
|
|
323
330
|
static fromJSON(obj: VaultStateJSON): VaultState {
|
|
324
331
|
return new VaultState({
|
|
325
|
-
|
|
332
|
+
vaultAdminAuthority: new PublicKey(obj.vaultAdminAuthority),
|
|
326
333
|
baseVaultAuthority: new PublicKey(obj.baseVaultAuthority),
|
|
327
334
|
baseVaultAuthorityBump: new BN(obj.baseVaultAuthorityBump),
|
|
328
335
|
tokenMint: new PublicKey(obj.tokenMint),
|
|
@@ -357,6 +364,7 @@ export class VaultState {
|
|
|
357
364
|
vaultFarm: new PublicKey(obj.vaultFarm),
|
|
358
365
|
creationTimestamp: new BN(obj.creationTimestamp),
|
|
359
366
|
padding1: new BN(obj.padding1),
|
|
367
|
+
allocationAdmin: new PublicKey(obj.allocationAdmin),
|
|
360
368
|
padding2: obj.padding2.map((item) => new BN(item)),
|
|
361
369
|
})
|
|
362
370
|
}
|