@kamino-finance/klend-sdk 5.14.0 → 5.14.1-beta.0
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/configItems.d.ts +166 -0
- package/dist/classes/configItems.d.ts.map +1 -0
- package/dist/classes/configItems.js +202 -0
- package/dist/classes/configItems.js.map +1 -0
- package/dist/classes/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +3 -10
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +6 -21
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +40 -311
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +14 -0
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +5 -14
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +91 -463
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/shared.d.ts +0 -1
- package/dist/classes/shared.d.ts.map +1 -1
- package/dist/classes/shared.js.map +1 -1
- package/dist/classes/utils.d.ts +1 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +12 -0
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -11
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +6 -54
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +27 -26
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +186 -9
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts +40 -0
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js +116 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js.map +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +24 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +25 -7
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +2 -0
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/index.js +3 -1
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +25 -1
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +43 -1
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +6 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +10 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js +19 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +13 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js +61 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +7 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +16 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +4 -3
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.js +5 -3
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +2 -6
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +32 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +108 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +33 -7
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +60 -12
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +6 -2
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +3 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/utils/accountListing.d.ts +1 -1
- package/dist/utils/accountListing.d.ts.map +1 -1
- package/dist/utils/accountListing.js +2 -2
- package/dist/utils/accountListing.js.map +1 -1
- package/dist/utils/api.d.ts +1 -5
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +6 -15
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +1 -6
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +10 -4
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +16 -0
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +23 -1
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/configItems.ts +295 -0
- package/src/classes/farm_utils.ts +3 -11
- package/src/classes/manager.ts +52 -417
- package/src/classes/obligation.ts +16 -0
- package/src/classes/reserve.ts +119 -783
- package/src/classes/shared.ts +0 -1
- package/src/classes/utils.ts +12 -0
- package/src/classes/vault.ts +7 -75
- package/src/client_kamino_manager.ts +42 -34
- package/src/idl.json +186 -9
- package/src/idl_codegen/accounts/GlobalConfig.ts +125 -0
- package/src/idl_codegen/accounts/LendingMarket.ts +41 -9
- package/src/idl_codegen/accounts/index.ts +2 -0
- package/src/idl_codegen/errors/custom.ts +45 -0
- package/src/idl_codegen/instructions/idlMissingTypes.ts +4 -2
- package/src/idl_codegen/instructions/index.ts +9 -0
- package/src/idl_codegen/instructions/initGlobalConfig.ts +30 -0
- package/src/idl_codegen/instructions/updateGlobalConfig.ts +47 -0
- package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +24 -0
- package/src/idl_codegen/instructions/updateReserveConfig.ts +7 -5
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +4 -8
- package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +90 -0
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +73 -13
- package/src/idl_codegen/types/index.ts +16 -2
- package/src/utils/accountListing.ts +2 -3
- package/src/utils/api.ts +6 -20
- package/src/utils/constants.ts +1 -1
- package/src/utils/lookupTable.ts +1 -7
- package/src/utils/managerTypes.ts +10 -4
- package/src/utils/seeds.ts +25 -0
package/src/classes/manager.ts
CHANGED
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
} from './vault';
|
|
29
29
|
import {
|
|
30
30
|
AddAssetToMarketParams,
|
|
31
|
-
assertNever,
|
|
32
31
|
CreateKaminoMarketParams,
|
|
33
32
|
createReserveIxs,
|
|
34
33
|
ENV,
|
|
@@ -45,7 +44,6 @@ import {
|
|
|
45
44
|
KaminoReserve,
|
|
46
45
|
LendingMarket,
|
|
47
46
|
lendingMarketAuthPda,
|
|
48
|
-
LendingMarketFields,
|
|
49
47
|
MarketWithAddress,
|
|
50
48
|
parseForChangesReserveConfigAndGetIxs,
|
|
51
49
|
parseOracleType,
|
|
@@ -53,7 +51,6 @@ import {
|
|
|
53
51
|
PubkeyHashMap,
|
|
54
52
|
Reserve,
|
|
55
53
|
ReserveWithAddress,
|
|
56
|
-
sameLengthArrayEquals,
|
|
57
54
|
ScopeOracleConfig,
|
|
58
55
|
updateEntireReserveConfigIx,
|
|
59
56
|
updateLendingMarket,
|
|
@@ -65,12 +62,7 @@ import {
|
|
|
65
62
|
import { PROGRAM_ID } from '../idl_codegen/programId';
|
|
66
63
|
import { Scope, TokenMetadatas, U16_MAX } from '@kamino-finance/scope-sdk';
|
|
67
64
|
import BN from 'bn.js';
|
|
68
|
-
import {
|
|
69
|
-
ElevationGroup,
|
|
70
|
-
ReserveConfig,
|
|
71
|
-
UpdateLendingMarketMode,
|
|
72
|
-
UpdateLendingMarketModeKind,
|
|
73
|
-
} from '../idl_codegen/types';
|
|
65
|
+
import { ReserveConfig, UpdateLendingMarketMode, UpdateLendingMarketModeKind } from '../idl_codegen/types';
|
|
74
66
|
import Decimal from 'decimal.js';
|
|
75
67
|
import * as anchor from '@coral-xyz/anchor';
|
|
76
68
|
import { VaultState } from '../idl_codegen_kamino_vault/accounts';
|
|
@@ -96,6 +88,7 @@ import { FarmState } from '@kamino-finance/farms-sdk/dist';
|
|
|
96
88
|
import SwitchboardProgram from '@switchboard-xyz/sbv2-lite';
|
|
97
89
|
import { getSquadsMultisigAdminsAndThreshold, walletIsSquadsMultisig, WalletType } from '../utils/multisig';
|
|
98
90
|
import { decodeVaultState } from '../utils/vault';
|
|
91
|
+
import { arrayElementConfigItems, ConfigUpdater } from './configItems';
|
|
99
92
|
|
|
100
93
|
/**
|
|
101
94
|
* KaminoManager is a class that provides a high-level interface to interact with the Kamino Lend and Kamino Vault programs, in order to create and manage a market, as well as vaults
|
|
@@ -391,7 +384,15 @@ export class KaminoManager {
|
|
|
391
384
|
const ixs: TransactionInstruction[] = [];
|
|
392
385
|
|
|
393
386
|
if (!reserveState || updateEntireConfig) {
|
|
394
|
-
ixs.push(
|
|
387
|
+
ixs.push(
|
|
388
|
+
updateEntireReserveConfigIx(
|
|
389
|
+
marketWithAddress.state.lendingMarketOwner,
|
|
390
|
+
marketWithAddress.address,
|
|
391
|
+
reserve,
|
|
392
|
+
config,
|
|
393
|
+
this._kaminoLendProgramId
|
|
394
|
+
)
|
|
395
|
+
);
|
|
395
396
|
} else {
|
|
396
397
|
ixs.push(
|
|
397
398
|
...parseForChangesReserveConfigAndGetIxs(
|
|
@@ -657,9 +658,9 @@ export class KaminoManager {
|
|
|
657
658
|
* Get all lending markets
|
|
658
659
|
* @returns an array of all lending markets
|
|
659
660
|
*/
|
|
660
|
-
async getAllMarkets(
|
|
661
|
+
async getAllMarkets(): Promise<KaminoMarket[]> {
|
|
661
662
|
// Get all lending markets
|
|
662
|
-
const marketGenerator = getAllLendingMarketAccounts(this.getConnection()
|
|
663
|
+
const marketGenerator = getAllLendingMarketAccounts(this.getConnection());
|
|
663
664
|
const slotDuration = await getMedianSlotDurationInMsFromLastEpochs();
|
|
664
665
|
|
|
665
666
|
const lendingMarketPairs: [PublicKey, LendingMarket][] = [];
|
|
@@ -873,7 +874,7 @@ export class KaminoManager {
|
|
|
873
874
|
}
|
|
874
875
|
|
|
875
876
|
/**
|
|
876
|
-
* This will return an VaultOverview object that encapsulates all the information about the vault, including the holdings, reserves details, theoretical APY,
|
|
877
|
+
* This will return an VaultOverview object that encapsulates all the information about the vault, including the holdings, reserves details, theoretical APY, utilization ratio and total borrowed amount
|
|
877
878
|
* @param vault - the kamino vault to get available liquidity to withdraw for
|
|
878
879
|
* @param price - the price of the token in the vault (e.g. USDC)
|
|
879
880
|
* @param [slot] - the slot for which to retrieve the vault overview for. Optional. If not provided the function will fetch the current slot
|
|
@@ -948,21 +949,6 @@ export class KaminoManager {
|
|
|
948
949
|
return this._vaultClient.getVaultTheoreticalAPY(vault, slot, vaultReserves);
|
|
949
950
|
}
|
|
950
951
|
|
|
951
|
-
/**
|
|
952
|
-
* This will return the APY of the vault based on the current invested amounts; for percentage it needs multiplication by 100
|
|
953
|
-
* @param vault - the kamino vault to get APY for
|
|
954
|
-
* @param slot - current slot
|
|
955
|
-
* @param [vaultReservesMap] - hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
956
|
-
* @returns a struct containing estimated gross APY and net APY (gross - vault fees) for the vault
|
|
957
|
-
*/
|
|
958
|
-
async getVaultActualAPY(
|
|
959
|
-
vault: VaultState,
|
|
960
|
-
slot: number,
|
|
961
|
-
vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>
|
|
962
|
-
): Promise<APYs> {
|
|
963
|
-
return this._vaultClient.getVaultActualAPY(vault, slot, vaultReserves);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
952
|
/**
|
|
967
953
|
* Retrive the total amount of interest earned by the vault since its inception, up to the last interaction with the vault on chain, including what was charged as fees
|
|
968
954
|
* @param vaultState the kamino vault state to get total net yield for
|
|
@@ -1028,13 +1014,6 @@ export class KaminoManager {
|
|
|
1028
1014
|
return this._vaultClient.calculateSimulatedFees(vaultState, simulatedCurrentHoldingsWithInterest, currentTimestamp);
|
|
1029
1015
|
}
|
|
1030
1016
|
|
|
1031
|
-
/**
|
|
1032
|
-
* This will compute the PDA that is used as delegatee in Farms program to compute the user state PDA
|
|
1033
|
-
*/
|
|
1034
|
-
computeUserFarmStateForUserInVault(farmProgramID: PublicKey, vault: PublicKey, reserve: PublicKey, user: PublicKey) {
|
|
1035
|
-
return this._vaultClient.computeUserFarmStateDelegateePDAForUserInVault(farmProgramID, reserve, vault, user);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
1017
|
/**
|
|
1039
1018
|
* This will load the onchain state for all the reserves that the vault has allocations for
|
|
1040
1019
|
* @param vaultState - the vault state to load reserves for
|
|
@@ -1269,383 +1248,51 @@ export class KaminoManager {
|
|
|
1269
1248
|
};
|
|
1270
1249
|
}
|
|
1271
1250
|
} // KaminoManager
|
|
1272
|
-
export type BaseLendingMarketKey = keyof LendingMarketFields;
|
|
1273
|
-
const EXCLUDED_LENDING_MARKET_KEYS = [
|
|
1274
|
-
'version',
|
|
1275
|
-
'bumpSeed',
|
|
1276
|
-
'reserved0',
|
|
1277
|
-
'reserved1',
|
|
1278
|
-
'padding1',
|
|
1279
|
-
'padding2',
|
|
1280
|
-
'elevationGroupPadding',
|
|
1281
|
-
'quoteCurrency',
|
|
1282
|
-
] as const;
|
|
1283
|
-
export type ExcludedLendingMarketKey = (typeof EXCLUDED_LENDING_MARKET_KEYS)[number];
|
|
1284
|
-
|
|
1285
|
-
function isExcludedLendingMarketKey(value: unknown): value is ExcludedLendingMarketKey {
|
|
1286
|
-
return EXCLUDED_LENDING_MARKET_KEYS.includes(value as ExcludedLendingMarketKey);
|
|
1287
|
-
}
|
|
1288
1251
|
|
|
1289
|
-
export
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
),
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
break;
|
|
1321
|
-
case 'referralFeeBps':
|
|
1322
|
-
if (market.referralFeeBps !== newMarket.referralFeeBps) {
|
|
1323
|
-
updateLendingMarketIxsArgs.push({
|
|
1324
|
-
mode: UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
1325
|
-
value: updateMarketConfigEncodedValue(
|
|
1326
|
-
UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator,
|
|
1327
|
-
newMarket.referralFeeBps
|
|
1328
|
-
),
|
|
1329
|
-
});
|
|
1330
|
-
}
|
|
1331
|
-
break;
|
|
1332
|
-
case 'emergencyMode':
|
|
1333
|
-
if (market.emergencyMode !== newMarket.emergencyMode) {
|
|
1334
|
-
updateLendingMarketIxsArgs.push({
|
|
1335
|
-
mode: UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
1336
|
-
value: updateMarketConfigEncodedValue(
|
|
1337
|
-
UpdateLendingMarketMode.UpdateEmergencyMode.discriminator,
|
|
1338
|
-
newMarket.emergencyMode
|
|
1339
|
-
),
|
|
1340
|
-
});
|
|
1341
|
-
}
|
|
1342
|
-
break;
|
|
1343
|
-
case 'autodeleverageEnabled':
|
|
1344
|
-
if (market.autodeleverageEnabled !== newMarket.autodeleverageEnabled) {
|
|
1345
|
-
updateLendingMarketIxsArgs.push({
|
|
1346
|
-
mode: UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
1347
|
-
value: updateMarketConfigEncodedValue(
|
|
1348
|
-
UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator,
|
|
1349
|
-
newMarket.autodeleverageEnabled
|
|
1350
|
-
),
|
|
1351
|
-
});
|
|
1352
|
-
}
|
|
1353
|
-
break;
|
|
1354
|
-
case 'borrowDisabled':
|
|
1355
|
-
if (market.borrowDisabled !== newMarket.borrowDisabled) {
|
|
1356
|
-
updateLendingMarketIxsArgs.push({
|
|
1357
|
-
mode: UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
1358
|
-
value: updateMarketConfigEncodedValue(
|
|
1359
|
-
UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator,
|
|
1360
|
-
newMarket.borrowDisabled
|
|
1361
|
-
),
|
|
1362
|
-
});
|
|
1363
|
-
}
|
|
1364
|
-
break;
|
|
1365
|
-
case 'priceRefreshTriggerToMaxAgePct':
|
|
1366
|
-
if (market.priceRefreshTriggerToMaxAgePct !== newMarket.priceRefreshTriggerToMaxAgePct) {
|
|
1367
|
-
updateLendingMarketIxsArgs.push({
|
|
1368
|
-
mode: UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
1369
|
-
value: updateMarketConfigEncodedValue(
|
|
1370
|
-
UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator,
|
|
1371
|
-
newMarket.priceRefreshTriggerToMaxAgePct
|
|
1372
|
-
),
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
break;
|
|
1376
|
-
case 'liquidationMaxDebtCloseFactorPct':
|
|
1377
|
-
if (market.liquidationMaxDebtCloseFactorPct !== newMarket.liquidationMaxDebtCloseFactorPct) {
|
|
1378
|
-
updateLendingMarketIxsArgs.push({
|
|
1379
|
-
mode: UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
1380
|
-
value: updateMarketConfigEncodedValue(
|
|
1381
|
-
UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator,
|
|
1382
|
-
newMarket.liquidationMaxDebtCloseFactorPct
|
|
1383
|
-
),
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
break;
|
|
1387
|
-
case 'insolvencyRiskUnhealthyLtvPct':
|
|
1388
|
-
if (market.insolvencyRiskUnhealthyLtvPct !== newMarket.insolvencyRiskUnhealthyLtvPct) {
|
|
1389
|
-
updateLendingMarketIxsArgs.push({
|
|
1390
|
-
mode: UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
1391
|
-
value: updateMarketConfigEncodedValue(
|
|
1392
|
-
UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator,
|
|
1393
|
-
newMarket.insolvencyRiskUnhealthyLtvPct
|
|
1394
|
-
),
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1397
|
-
break;
|
|
1398
|
-
case 'minFullLiquidationValueThreshold':
|
|
1399
|
-
if (!market.minFullLiquidationValueThreshold.eq(newMarket.minFullLiquidationValueThreshold)) {
|
|
1400
|
-
updateLendingMarketIxsArgs.push({
|
|
1401
|
-
mode: UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
1402
|
-
value: updateMarketConfigEncodedValue(
|
|
1403
|
-
UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator,
|
|
1404
|
-
newMarket.minFullLiquidationValueThreshold.toNumber()
|
|
1405
|
-
),
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
break;
|
|
1409
|
-
case 'maxLiquidatableDebtMarketValueAtOnce':
|
|
1410
|
-
if (!market.maxLiquidatableDebtMarketValueAtOnce.eq(newMarket.maxLiquidatableDebtMarketValueAtOnce)) {
|
|
1411
|
-
updateLendingMarketIxsArgs.push({
|
|
1412
|
-
mode: UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
1413
|
-
value: updateMarketConfigEncodedValue(
|
|
1414
|
-
UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator,
|
|
1415
|
-
newMarket.maxLiquidatableDebtMarketValueAtOnce.toNumber()
|
|
1416
|
-
),
|
|
1417
|
-
});
|
|
1418
|
-
}
|
|
1419
|
-
break;
|
|
1420
|
-
case 'globalAllowedBorrowValue':
|
|
1421
|
-
if (!market.globalAllowedBorrowValue.eq(newMarket.globalAllowedBorrowValue)) {
|
|
1422
|
-
updateLendingMarketIxsArgs.push({
|
|
1423
|
-
mode: UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
1424
|
-
value: updateMarketConfigEncodedValue(
|
|
1425
|
-
UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator,
|
|
1426
|
-
newMarket.globalAllowedBorrowValue.toNumber()
|
|
1427
|
-
),
|
|
1428
|
-
});
|
|
1429
|
-
}
|
|
1430
|
-
break;
|
|
1431
|
-
case 'riskCouncil':
|
|
1432
|
-
if (!market.riskCouncil.equals(newMarket.riskCouncil)) {
|
|
1433
|
-
updateLendingMarketIxsArgs.push({
|
|
1434
|
-
mode: UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
1435
|
-
value: updateMarketConfigEncodedValue(
|
|
1436
|
-
UpdateLendingMarketMode.UpdateRiskCouncil.discriminator,
|
|
1437
|
-
newMarket.riskCouncil
|
|
1438
|
-
),
|
|
1439
|
-
});
|
|
1440
|
-
}
|
|
1441
|
-
break;
|
|
1442
|
-
case 'elevationGroups':
|
|
1443
|
-
let elevationGroupsDiffs = 0;
|
|
1444
|
-
for (let i = 0; i < market.elevationGroups.length; i++) {
|
|
1445
|
-
if (
|
|
1446
|
-
market.elevationGroups[i].id !== newMarket.elevationGroups[i].id ||
|
|
1447
|
-
market.elevationGroups[i].maxLiquidationBonusBps !== newMarket.elevationGroups[i].maxLiquidationBonusBps ||
|
|
1448
|
-
market.elevationGroups[i].ltvPct !== newMarket.elevationGroups[i].ltvPct ||
|
|
1449
|
-
market.elevationGroups[i].liquidationThresholdPct !== newMarket.elevationGroups[i].liquidationThresholdPct ||
|
|
1450
|
-
market.elevationGroups[i].allowNewLoans !== newMarket.elevationGroups[i].allowNewLoans ||
|
|
1451
|
-
market.elevationGroups[i].maxReservesAsCollateral !== newMarket.elevationGroups[i].maxReservesAsCollateral ||
|
|
1452
|
-
!market.elevationGroups[i].debtReserve.equals(newMarket.elevationGroups[i].debtReserve)
|
|
1453
|
-
) {
|
|
1454
|
-
updateLendingMarketIxsArgs.push({
|
|
1455
|
-
mode: UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
1456
|
-
value: updateMarketConfigEncodedValue(
|
|
1457
|
-
UpdateLendingMarketMode.UpdateElevationGroup.discriminator,
|
|
1458
|
-
newMarket.elevationGroups[i]
|
|
1459
|
-
),
|
|
1460
|
-
});
|
|
1461
|
-
elevationGroupsDiffs++;
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
if (elevationGroupsDiffs > 1) {
|
|
1465
|
-
throw new Error('Can only update 1 elevation group at a time');
|
|
1466
|
-
}
|
|
1467
|
-
break;
|
|
1468
|
-
case 'minNetValueInObligationSf':
|
|
1469
|
-
if (!market.minNetValueInObligationSf.eq(newMarket.minNetValueInObligationSf)) {
|
|
1470
|
-
updateLendingMarketIxsArgs.push({
|
|
1471
|
-
mode: UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
1472
|
-
value: updateMarketConfigEncodedValue(
|
|
1473
|
-
UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator,
|
|
1474
|
-
newMarket.minNetValueInObligationSf.toString()
|
|
1475
|
-
),
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
break;
|
|
1479
|
-
case 'minValueSkipLiquidationBfChecks':
|
|
1480
|
-
if (!market.minValueSkipLiquidationBfChecks.eq(newMarket.minValueSkipLiquidationBfChecks)) {
|
|
1481
|
-
updateLendingMarketIxsArgs.push({
|
|
1482
|
-
mode: UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator,
|
|
1483
|
-
value: updateMarketConfigEncodedValue(
|
|
1484
|
-
UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator,
|
|
1485
|
-
newMarket.minValueSkipLiquidationBfChecks.toNumber()
|
|
1486
|
-
),
|
|
1487
|
-
});
|
|
1488
|
-
}
|
|
1489
|
-
break;
|
|
1490
|
-
case 'minValueSkipLiquidationLtvChecks':
|
|
1491
|
-
if (!market.minValueSkipLiquidationLtvChecks.eq(newMarket.minValueSkipLiquidationLtvChecks)) {
|
|
1492
|
-
updateLendingMarketIxsArgs.push({
|
|
1493
|
-
mode: UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator,
|
|
1494
|
-
value: updateMarketConfigEncodedValue(
|
|
1495
|
-
UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator,
|
|
1496
|
-
newMarket.minValueSkipLiquidationLtvChecks.toNumber()
|
|
1497
|
-
),
|
|
1498
|
-
});
|
|
1499
|
-
}
|
|
1500
|
-
break;
|
|
1501
|
-
case 'individualAutodeleverageMarginCallPeriodSecs':
|
|
1502
|
-
if (
|
|
1503
|
-
market.individualAutodeleverageMarginCallPeriodSecs !== newMarket.individualAutodeleverageMarginCallPeriodSecs
|
|
1504
|
-
) {
|
|
1505
|
-
updateLendingMarketIxsArgs.push({
|
|
1506
|
-
mode: UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator,
|
|
1507
|
-
value: updateMarketConfigEncodedValue(
|
|
1508
|
-
UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator,
|
|
1509
|
-
newMarket.individualAutodeleverageMarginCallPeriodSecs.toNumber()
|
|
1510
|
-
),
|
|
1511
|
-
});
|
|
1512
|
-
}
|
|
1513
|
-
break;
|
|
1514
|
-
case 'name':
|
|
1515
|
-
if (!sameLengthArrayEquals(market.name, newMarket.name)) {
|
|
1516
|
-
updateLendingMarketIxsArgs.push({
|
|
1517
|
-
mode: UpdateLendingMarketMode.UpdateName.discriminator,
|
|
1518
|
-
value: updateMarketConfigEncodedValue(UpdateLendingMarketMode.UpdateName.discriminator, newMarket.name),
|
|
1519
|
-
});
|
|
1520
|
-
}
|
|
1521
|
-
break;
|
|
1522
|
-
case 'minInitialDepositAmount':
|
|
1523
|
-
if (!market.minInitialDepositAmount.eq(newMarket.minInitialDepositAmount)) {
|
|
1524
|
-
updateLendingMarketIxsArgs.push({
|
|
1525
|
-
mode: UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator,
|
|
1526
|
-
value: updateMarketConfigEncodedValue(
|
|
1527
|
-
UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator,
|
|
1528
|
-
newMarket.minInitialDepositAmount.toNumber()
|
|
1529
|
-
),
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
break;
|
|
1533
|
-
case 'obligationOrdersEnabled':
|
|
1534
|
-
if (market.obligationOrdersEnabled !== newMarket.obligationOrdersEnabled) {
|
|
1535
|
-
updateLendingMarketIxsArgs.push({
|
|
1536
|
-
mode: UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator,
|
|
1537
|
-
value: updateMarketConfigEncodedValue(
|
|
1538
|
-
UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator,
|
|
1539
|
-
newMarket.obligationOrdersEnabled
|
|
1540
|
-
),
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
break;
|
|
1544
|
-
default:
|
|
1545
|
-
assertNever(key);
|
|
1546
|
-
}
|
|
1547
|
-
return updateLendingMarketIxsArgs;
|
|
1548
|
-
};
|
|
1252
|
+
export const MARKET_UPDATER = new ConfigUpdater(UpdateLendingMarketMode.fromDecoded, LendingMarket, (config) => ({
|
|
1253
|
+
[UpdateLendingMarketMode.UpdateOwner.kind]: config.lendingMarketOwnerCached,
|
|
1254
|
+
[UpdateLendingMarketMode.UpdateImmutableFlag.kind]: config.immutable,
|
|
1255
|
+
[UpdateLendingMarketMode.UpdateEmergencyMode.kind]: config.emergencyMode,
|
|
1256
|
+
[UpdateLendingMarketMode.UpdateLiquidationCloseFactor.kind]: config.liquidationMaxDebtCloseFactorPct,
|
|
1257
|
+
[UpdateLendingMarketMode.UpdateLiquidationMaxValue.kind]: config.maxLiquidatableDebtMarketValueAtOnce,
|
|
1258
|
+
[UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrow.kind]: [], // deprecated
|
|
1259
|
+
[UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.kind]: config.globalAllowedBorrowValue,
|
|
1260
|
+
[UpdateLendingMarketMode.UpdateRiskCouncil.kind]: config.riskCouncil,
|
|
1261
|
+
[UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.kind]: config.minFullLiquidationValueThreshold,
|
|
1262
|
+
[UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.kind]: config.insolvencyRiskUnhealthyLtvPct,
|
|
1263
|
+
[UpdateLendingMarketMode.UpdateElevationGroup.kind]: arrayElementConfigItems(config.elevationGroups),
|
|
1264
|
+
[UpdateLendingMarketMode.UpdateReferralFeeBps.kind]: config.referralFeeBps,
|
|
1265
|
+
[UpdateLendingMarketMode.DeprecatedUpdateMultiplierPoints.kind]: [], // deprecated
|
|
1266
|
+
[UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.kind]: config.priceRefreshTriggerToMaxAgePct,
|
|
1267
|
+
[UpdateLendingMarketMode.UpdateAutodeleverageEnabled.kind]: config.autodeleverageEnabled,
|
|
1268
|
+
[UpdateLendingMarketMode.UpdateBorrowingDisabled.kind]: config.borrowDisabled,
|
|
1269
|
+
[UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.kind]: config.minNetValueInObligationSf,
|
|
1270
|
+
[UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.kind]: config.minValueSkipLiquidationLtvChecks,
|
|
1271
|
+
[UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.kind]: config.minValueSkipLiquidationBfChecks,
|
|
1272
|
+
[UpdateLendingMarketMode.UpdatePaddingFields.kind]: [], // we do not update padding this way
|
|
1273
|
+
[UpdateLendingMarketMode.UpdateName.kind]: config.name,
|
|
1274
|
+
[UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.kind]:
|
|
1275
|
+
config.individualAutodeleverageMarginCallPeriodSecs,
|
|
1276
|
+
[UpdateLendingMarketMode.UpdateInitialDepositAmount.kind]: config.minInitialDepositAmount,
|
|
1277
|
+
[UpdateLendingMarketMode.UpdateObligationOrderCreationEnabled.kind]: config.obligationOrderCreationEnabled,
|
|
1278
|
+
[UpdateLendingMarketMode.UpdateObligationOrderExecutionEnabled.kind]: config.obligationOrderExecutionEnabled,
|
|
1279
|
+
}));
|
|
1549
1280
|
|
|
1550
1281
|
function parseForChangesMarketConfigAndGetIxs(
|
|
1551
1282
|
marketWithAddress: MarketWithAddress,
|
|
1552
1283
|
newMarket: LendingMarket,
|
|
1553
1284
|
programId: PublicKey
|
|
1554
1285
|
): TransactionInstruction[] {
|
|
1555
|
-
const
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
if (isExcludedLendingMarketKey(key)) {
|
|
1560
|
-
continue;
|
|
1561
|
-
}
|
|
1562
|
-
updateLendingMarketIxsArgs.push(...updateLendingMarketConfig(key as LendingMarketKey, market, newMarket));
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
const ixs: TransactionInstruction[] = [];
|
|
1566
|
-
|
|
1567
|
-
updateLendingMarketIxsArgs.forEach((updateLendingMarketConfigArgs) => {
|
|
1568
|
-
ixs.push(
|
|
1569
|
-
updateMarketConfigIx(
|
|
1570
|
-
marketWithAddress,
|
|
1571
|
-
updateLendingMarketConfigArgs.mode,
|
|
1572
|
-
updateLendingMarketConfigArgs.value,
|
|
1573
|
-
programId
|
|
1574
|
-
)
|
|
1575
|
-
);
|
|
1576
|
-
});
|
|
1577
|
-
|
|
1578
|
-
return ixs;
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
function updateMarketConfigEncodedValue(
|
|
1582
|
-
discriminator: UpdateLendingMarketModeKind['discriminator'],
|
|
1583
|
-
value: number | number[] | PublicKey | ElevationGroup | string
|
|
1584
|
-
): Buffer {
|
|
1585
|
-
let buffer: Buffer = Buffer.alloc(72);
|
|
1586
|
-
let pkBuffer: Buffer;
|
|
1587
|
-
let valueBigInt: bigint;
|
|
1588
|
-
let valueArray: number[];
|
|
1589
|
-
|
|
1590
|
-
switch (discriminator) {
|
|
1591
|
-
case UpdateLendingMarketMode.UpdateEmergencyMode.discriminator:
|
|
1592
|
-
case UpdateLendingMarketMode.UpdateLiquidationCloseFactor.discriminator:
|
|
1593
|
-
case UpdateLendingMarketMode.UpdateInsolvencyRiskLtv.discriminator:
|
|
1594
|
-
case UpdateLendingMarketMode.UpdatePriceRefreshTriggerToMaxAgePct.discriminator:
|
|
1595
|
-
case UpdateLendingMarketMode.UpdateAutodeleverageEnabled.discriminator:
|
|
1596
|
-
case UpdateLendingMarketMode.UpdateObligationOrdersEnabled.discriminator:
|
|
1597
|
-
case UpdateLendingMarketMode.UpdateBorrowingDisabled.discriminator:
|
|
1598
|
-
buffer.writeUIntLE(value as number, 0, 1);
|
|
1599
|
-
break;
|
|
1600
|
-
case UpdateLendingMarketMode.UpdateReferralFeeBps.discriminator:
|
|
1601
|
-
buffer.writeUInt16LE(value as number, 0);
|
|
1602
|
-
break;
|
|
1603
|
-
case UpdateLendingMarketMode.UpdateLiquidationMaxValue.discriminator:
|
|
1604
|
-
case UpdateLendingMarketMode.UpdateGlobalAllowedBorrow.discriminator:
|
|
1605
|
-
case UpdateLendingMarketMode.UpdateMinFullLiquidationThreshold.discriminator:
|
|
1606
|
-
case UpdateLendingMarketMode.UpdateMinValueBfSkipPriorityLiqCheck.discriminator:
|
|
1607
|
-
case UpdateLendingMarketMode.UpdateMinValueLtvSkipPriorityLiqCheck.discriminator:
|
|
1608
|
-
case UpdateLendingMarketMode.UpdateIndividualAutodeleverageMarginCallPeriodSecs.discriminator:
|
|
1609
|
-
case UpdateLendingMarketMode.UpdateInitialDepositAmount.discriminator:
|
|
1610
|
-
value = value as number;
|
|
1611
|
-
buffer.writeBigUint64LE(BigInt(value), 0);
|
|
1612
|
-
break;
|
|
1613
|
-
case UpdateLendingMarketMode.UpdateOwner.discriminator:
|
|
1614
|
-
case UpdateLendingMarketMode.UpdateRiskCouncil.discriminator:
|
|
1615
|
-
pkBuffer = (value as PublicKey).toBuffer();
|
|
1616
|
-
pkBuffer.copy(buffer, 0);
|
|
1617
|
-
break;
|
|
1618
|
-
case UpdateLendingMarketMode.UpdateElevationGroup.discriminator:
|
|
1619
|
-
buffer = serializeElevationGroup(value as ElevationGroup);
|
|
1620
|
-
break;
|
|
1621
|
-
case UpdateLendingMarketMode.UpdateMinNetValueObligationPostAction.discriminator:
|
|
1622
|
-
valueBigInt = BigInt(value as string);
|
|
1623
|
-
for (let i = 0; i < 16; i++) {
|
|
1624
|
-
buffer[15 - i] = Number((valueBigInt >> BigInt(i * 8)) & BigInt(0xff));
|
|
1625
|
-
}
|
|
1626
|
-
break;
|
|
1627
|
-
case UpdateLendingMarketMode.UpdateName.discriminator:
|
|
1628
|
-
valueArray = value as number[];
|
|
1629
|
-
for (let i = 0; i < valueArray.length; i++) {
|
|
1630
|
-
buffer.writeUIntLE(valueArray[i], i, 1);
|
|
1631
|
-
}
|
|
1632
|
-
break;
|
|
1633
|
-
case UpdateLendingMarketMode.UpdatePaddingFields.discriminator:
|
|
1634
|
-
case UpdateLendingMarketMode.DeprecatedUpdateGlobalUnhealthyBorrow.discriminator:
|
|
1635
|
-
case UpdateLendingMarketMode.DeprecatedUpdateMultiplierPoints.discriminator:
|
|
1636
|
-
// Deliberately skipped - we are not updating padding or deprecated fields using this method
|
|
1637
|
-
break;
|
|
1638
|
-
default:
|
|
1639
|
-
assertNever(discriminator);
|
|
1640
|
-
}
|
|
1641
|
-
|
|
1642
|
-
return buffer;
|
|
1286
|
+
const encodedMarketUpdates = MARKET_UPDATER.encodeAllUpdates(marketWithAddress.state, newMarket);
|
|
1287
|
+
return encodedMarketUpdates.map((encodedMarketUpdate) =>
|
|
1288
|
+
updateMarketConfigIx(marketWithAddress, encodedMarketUpdate.mode, encodedMarketUpdate.value, programId)
|
|
1289
|
+
);
|
|
1643
1290
|
}
|
|
1644
1291
|
|
|
1645
1292
|
function updateMarketConfigIx(
|
|
1646
1293
|
marketWithAddress: MarketWithAddress,
|
|
1647
|
-
|
|
1648
|
-
value:
|
|
1294
|
+
mode: UpdateLendingMarketModeKind,
|
|
1295
|
+
value: Uint8Array,
|
|
1649
1296
|
programId: PublicKey
|
|
1650
1297
|
): TransactionInstruction {
|
|
1651
1298
|
const accounts: UpdateLendingMarketAccounts = {
|
|
@@ -1654,25 +1301,13 @@ function updateMarketConfigIx(
|
|
|
1654
1301
|
};
|
|
1655
1302
|
|
|
1656
1303
|
const args: UpdateLendingMarketArgs = {
|
|
1657
|
-
mode: new anchor.BN(
|
|
1658
|
-
|
|
1304
|
+
mode: new anchor.BN(mode.discriminator),
|
|
1305
|
+
// NOTE: the Market's update handler expects a `[u8; 72]` (contrary to e.g. the Reserve's update handler accepting
|
|
1306
|
+
// `Vec<u8>`). Hence, we need to add explicit padding here:
|
|
1307
|
+
value: [...value, ...Array(72 - value.length).fill(0)],
|
|
1659
1308
|
};
|
|
1660
1309
|
|
|
1661
1310
|
const ix = updateLendingMarket(args, accounts, programId);
|
|
1662
1311
|
|
|
1663
1312
|
return ix;
|
|
1664
1313
|
}
|
|
1665
|
-
|
|
1666
|
-
function serializeElevationGroup(elevationGroup: ElevationGroup): Buffer {
|
|
1667
|
-
const buffer = Buffer.alloc(72);
|
|
1668
|
-
buffer.writeUInt16LE(elevationGroup.maxLiquidationBonusBps, 0);
|
|
1669
|
-
buffer.writeUIntLE(elevationGroup.id, 2, 1);
|
|
1670
|
-
buffer.writeUIntLE(elevationGroup.ltvPct, 3, 1);
|
|
1671
|
-
buffer.writeUIntLE(elevationGroup.liquidationThresholdPct, 4, 1);
|
|
1672
|
-
buffer.writeUIntLE(elevationGroup.allowNewLoans, 5, 1);
|
|
1673
|
-
buffer.writeUIntLE(elevationGroup.maxReservesAsCollateral, 6, 1);
|
|
1674
|
-
buffer.writeUIntLE(elevationGroup.padding0, 7, 1);
|
|
1675
|
-
const debtReserveBuffer = elevationGroup.debtReserve.toBuffer();
|
|
1676
|
-
debtReserveBuffer.copy(buffer, 8);
|
|
1677
|
-
return buffer;
|
|
1678
|
-
}
|
|
@@ -636,6 +636,14 @@ export class KaminoObligation {
|
|
|
636
636
|
let newObligationDeposits = this.state.deposits;
|
|
637
637
|
let newObligationBorrows = this.state.borrows;
|
|
638
638
|
|
|
639
|
+
// Print deposits and borrows before
|
|
640
|
+
for (const deposit of this.state.deposits) {
|
|
641
|
+
console.log(`Before Deposit: ${deposit.depositReserve.toBase58()} - ${deposit.depositedAmount}`);
|
|
642
|
+
}
|
|
643
|
+
for (const borrow of this.state.borrows) {
|
|
644
|
+
console.log(`Before Borrow: ${borrow.borrowReserve.toBase58()} - ${borrow.borrowedAmountSf}`);
|
|
645
|
+
}
|
|
646
|
+
|
|
639
647
|
switch (action) {
|
|
640
648
|
case 'deposit': {
|
|
641
649
|
if (amountCollateral === undefined || mintCollateral === undefined) {
|
|
@@ -750,6 +758,14 @@ export class KaminoObligation {
|
|
|
750
758
|
null
|
|
751
759
|
);
|
|
752
760
|
|
|
761
|
+
// Print deposits and borrows after
|
|
762
|
+
for (const deposit of newObligationDeposits) {
|
|
763
|
+
console.log(`After Deposit: ${deposit.depositReserve.toBase58()} - ${deposit.depositedAmount}`);
|
|
764
|
+
}
|
|
765
|
+
for (const borrow of newObligationBorrows) {
|
|
766
|
+
console.log(`After Borrow: ${borrow.borrowReserve.toBase58()} - ${borrow.borrowedAmountSf}`);
|
|
767
|
+
}
|
|
768
|
+
|
|
753
769
|
newStats = refreshedStats;
|
|
754
770
|
newDeposits = deposits;
|
|
755
771
|
newBorrows = borrows;
|