@kamino-finance/klend-sdk 5.13.21-beta.0 → 5.13.22
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/farm_utils.d.ts.map +1 -1
- package/dist/classes/farm_utils.js +10 -3
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts +12 -5
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +300 -39
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/obligation.d.ts.map +1 -1
- package/dist/classes/obligation.js +0 -14
- package/dist/classes/obligation.js.map +1 -1
- package/dist/classes/reserve.d.ts +14 -5
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +463 -91
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/utils.d.ts +0 -1
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +0 -12
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +2 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +9 -5
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +26 -27
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +9 -186
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -24
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +7 -25
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +0 -2
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/index.js +1 -3
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +1 -25
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +1 -43
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +1 -2
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js +1 -2
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +0 -6
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +1 -7
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +3 -4
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.js +3 -5
- 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 +6 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +7 -33
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +12 -60
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +2 -6
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +1 -3
- 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/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +6 -1
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.d.ts.map +1 -1
- package/dist/utils/managerTypes.js +4 -10
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +0 -16
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +1 -23
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/farm_utils.ts +11 -3
- package/src/classes/manager.ts +401 -51
- package/src/classes/obligation.ts +0 -16
- package/src/classes/reserve.ts +783 -119
- package/src/classes/utils.ts +0 -12
- package/src/classes/vault.ts +19 -7
- package/src/client_kamino_manager.ts +34 -42
- package/src/idl.json +9 -186
- package/src/idl_codegen/accounts/LendingMarket.ts +9 -41
- package/src/idl_codegen/accounts/index.ts +0 -2
- package/src/idl_codegen/errors/custom.ts +0 -45
- package/src/idl_codegen/instructions/idlMissingTypes.ts +2 -4
- package/src/idl_codegen/instructions/index.ts +0 -9
- package/src/idl_codegen/instructions/updateReserveConfig.ts +5 -7
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +8 -4
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +13 -73
- package/src/idl_codegen/types/index.ts +2 -16
- package/src/utils/accountListing.ts +3 -2
- package/src/utils/lookupTable.ts +7 -1
- package/src/utils/managerTypes.ts +4 -10
- package/src/utils/seeds.ts +0 -25
- package/dist/classes/configItems.d.ts +0 -166
- package/dist/classes/configItems.d.ts.map +0 -1
- package/dist/classes/configItems.js +0 -202
- package/dist/classes/configItems.js.map +0 -1
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts +0 -40
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/accounts/GlobalConfig.js +0 -116
- package/dist/idl_codegen/accounts/GlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +0 -10
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.js +0 -19
- package/dist/idl_codegen/instructions/initGlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +0 -13
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfig.js +0 -61
- package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +0 -7
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +0 -1
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +0 -16
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +0 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +0 -32
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +0 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +0 -108
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +0 -1
- package/src/classes/configItems.ts +0 -295
- package/src/idl_codegen/accounts/GlobalConfig.ts +0 -125
- package/src/idl_codegen/instructions/initGlobalConfig.ts +0 -30
- package/src/idl_codegen/instructions/updateGlobalConfig.ts +0 -47
- package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +0 -24
- package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +0 -90
package/src/classes/utils.ts
CHANGED
|
@@ -287,18 +287,6 @@ export function orThrow(message: string): never {
|
|
|
287
287
|
throw new Error(message);
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
export function blobEquals(left: Uint8Array, right: Uint8Array): boolean {
|
|
291
|
-
if (left.length !== right.length) {
|
|
292
|
-
return false;
|
|
293
|
-
}
|
|
294
|
-
for (let i = 0; i < left.length; ++i) {
|
|
295
|
-
if (left[i] !== right[i]) {
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return true;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
290
|
/**
|
|
303
291
|
* Returns an integer {@link Decimal} nearest to the given one.
|
|
304
292
|
*
|
package/src/classes/vault.ts
CHANGED
|
@@ -966,7 +966,9 @@ export class KaminoVaultClient {
|
|
|
966
966
|
};
|
|
967
967
|
|
|
968
968
|
const depositArgs: DepositArgs = {
|
|
969
|
-
maxAmount: new BN(
|
|
969
|
+
maxAmount: new BN(
|
|
970
|
+
numberToLamportsDecimal(tokenAmount, vaultState.tokenMintDecimals.toNumber()).floor().toString()
|
|
971
|
+
),
|
|
970
972
|
};
|
|
971
973
|
|
|
972
974
|
const depositIx = deposit(depositArgs, depoistAccounts, this._kaminoVaultProgramId);
|
|
@@ -1084,7 +1086,7 @@ export class KaminoVaultClient {
|
|
|
1084
1086
|
);
|
|
1085
1087
|
|
|
1086
1088
|
if (vaultAllocation) {
|
|
1087
|
-
const withdrawFromVaultIxs = await this.
|
|
1089
|
+
const withdrawFromVaultIxs = await this.withdrawWithReserveIxs(
|
|
1088
1090
|
user,
|
|
1089
1091
|
kaminoVault,
|
|
1090
1092
|
shareAmount,
|
|
@@ -1129,7 +1131,7 @@ export class KaminoVaultClient {
|
|
|
1129
1131
|
return [createAtaIx, withdrawFromAvailableIxn];
|
|
1130
1132
|
}
|
|
1131
1133
|
|
|
1132
|
-
private async
|
|
1134
|
+
private async withdrawWithReserveIxs(
|
|
1133
1135
|
user: PublicKey,
|
|
1134
1136
|
vault: KaminoVault,
|
|
1135
1137
|
shareAmount: Decimal,
|
|
@@ -1139,7 +1141,6 @@ export class KaminoVaultClient {
|
|
|
1139
1141
|
const vaultState = await vault.getState(this.getConnection());
|
|
1140
1142
|
|
|
1141
1143
|
const vaultReservesState = vaultReservesMap ? vaultReservesMap : await this.loadVaultReserves(vaultState);
|
|
1142
|
-
|
|
1143
1144
|
const userSharesAta = getAssociatedTokenAddress(vaultState.sharesMint, user);
|
|
1144
1145
|
const [{ ata: userTokenAta, createAtaIx }] = createAtasIdempotent(user, [
|
|
1145
1146
|
{
|
|
@@ -1162,9 +1163,12 @@ export class KaminoVaultClient {
|
|
|
1162
1163
|
let isFirstWithdraw = true;
|
|
1163
1164
|
|
|
1164
1165
|
if (tokenLeftToWithdraw.lte(0)) {
|
|
1165
|
-
// Availabe enough to withdraw all - using first reserve
|
|
1166
|
+
// Availabe enough to withdraw all - using the first existent reserve
|
|
1167
|
+
const firstReserve = vaultState.vaultAllocationStrategy.find(
|
|
1168
|
+
(reserve) => !reserve.reserve.equals(PublicKey.default)
|
|
1169
|
+
);
|
|
1166
1170
|
reserveWithSharesAmountToWithdraw.push({
|
|
1167
|
-
reserve:
|
|
1171
|
+
reserve: firstReserve!.reserve,
|
|
1168
1172
|
shares: shareLamportsToWithdraw,
|
|
1169
1173
|
});
|
|
1170
1174
|
} else {
|
|
@@ -1197,7 +1201,6 @@ export class KaminoVaultClient {
|
|
|
1197
1201
|
|
|
1198
1202
|
const withdrawIxs: TransactionInstruction[] = [];
|
|
1199
1203
|
withdrawIxs.push(createAtaIx);
|
|
1200
|
-
|
|
1201
1204
|
for (let reserveIndex = 0; reserveIndex < reserveWithSharesAmountToWithdraw.length; reserveIndex++) {
|
|
1202
1205
|
const reserveWithTokens = reserveWithSharesAmountToWithdraw[reserveIndex];
|
|
1203
1206
|
const reserveState = vaultReservesState.get(reserveWithTokens.reserve);
|
|
@@ -2784,6 +2787,15 @@ export class KaminoVaultClient {
|
|
|
2784
2787
|
performanceFee: performanceFee,
|
|
2785
2788
|
};
|
|
2786
2789
|
}
|
|
2790
|
+
|
|
2791
|
+
computeUserFarmStateDelegateePDAForUserInVault(
|
|
2792
|
+
farmProgramID: PublicKey,
|
|
2793
|
+
vault: PublicKey,
|
|
2794
|
+
reserve: PublicKey,
|
|
2795
|
+
user: PublicKey
|
|
2796
|
+
): [PublicKey, number] {
|
|
2797
|
+
return PublicKey.findProgramAddressSync([vault.toBuffer(), reserve.toBuffer(), user.toBuffer()], farmProgramID);
|
|
2798
|
+
}
|
|
2787
2799
|
} // KaminoVaultClient
|
|
2788
2800
|
|
|
2789
2801
|
export class KaminoVault {
|
|
@@ -8,20 +8,15 @@ import {
|
|
|
8
8
|
Signer,
|
|
9
9
|
Transaction,
|
|
10
10
|
TransactionInstruction,
|
|
11
|
-
TransactionMessage,
|
|
12
11
|
TransactionSignature,
|
|
13
12
|
VersionedTransaction,
|
|
14
13
|
} from '@solana/web3.js';
|
|
15
14
|
import {
|
|
16
15
|
AssetReserveConfigCli,
|
|
17
16
|
Chain,
|
|
18
|
-
createLookupTableIx,
|
|
19
17
|
DEFAULT_RECENT_SLOT_DURATION_MS,
|
|
20
18
|
encodeTokenName,
|
|
21
|
-
extendLookupTableIxs,
|
|
22
|
-
getLookupTableAccounts,
|
|
23
19
|
getMedianSlotDurationInMsFromLastEpochs,
|
|
24
|
-
globalConfigPda,
|
|
25
20
|
initLookupTableIx,
|
|
26
21
|
KaminoManager,
|
|
27
22
|
KaminoMarket,
|
|
@@ -32,7 +27,6 @@ import {
|
|
|
32
27
|
MAINNET_BETA_CHAIN_ID,
|
|
33
28
|
parseZeroPaddedUtf8,
|
|
34
29
|
printHoldings,
|
|
35
|
-
PROGRAM_ID,
|
|
36
30
|
Reserve,
|
|
37
31
|
ReserveAllocationConfig,
|
|
38
32
|
ReserveWithAddress,
|
|
@@ -159,10 +153,7 @@ async function main() {
|
|
|
159
153
|
|
|
160
154
|
const _createReserveSig = await processTxn(env.client, env.payer, txnIxs[0], mode, 2500, [reserve]);
|
|
161
155
|
|
|
162
|
-
const
|
|
163
|
-
await processTxn(env.client, env.payer, createLutIxs, mode, 2500, []);
|
|
164
|
-
|
|
165
|
-
const _updateSig = await processTxn(env.client, env.payer, txnIxs[1], mode, 2500, [], 400_000, 1000, [lut]);
|
|
156
|
+
const _updateReserveSig = await processTxn(env.client, env.payer, txnIxs[1], mode, 2500, [], 400_000);
|
|
166
157
|
|
|
167
158
|
mode === 'execute' &&
|
|
168
159
|
console.log(
|
|
@@ -618,13 +609,21 @@ async function main() {
|
|
|
618
609
|
const acceptVaultOwnershipSig = await processTxn(
|
|
619
610
|
env.client,
|
|
620
611
|
env.payer,
|
|
621
|
-
[instructions.acceptVaultOwnershipIx
|
|
612
|
+
[instructions.acceptVaultOwnershipIx],
|
|
622
613
|
mode,
|
|
623
614
|
2500,
|
|
624
615
|
[]
|
|
625
616
|
);
|
|
626
617
|
|
|
627
618
|
mode === 'execute' && console.log('Vault ownership accepted:', acceptVaultOwnershipSig);
|
|
619
|
+
|
|
620
|
+
// send the LUT mgmt ixs one by one
|
|
621
|
+
const lutIxs = [...instructions.updateLUTIxs];
|
|
622
|
+
for (let i = 0; i < lutIxs.length; i++) {
|
|
623
|
+
const lutIxsGroup = lutIxs.slice(i, i + 1);
|
|
624
|
+
const lutIxsSig = await processTxn(env.client, env.payer, lutIxsGroup, mode, 2500, []);
|
|
625
|
+
mode === 'execute' && console.log('LUT updated:', lutIxsSig);
|
|
626
|
+
}
|
|
628
627
|
});
|
|
629
628
|
|
|
630
629
|
commands
|
|
@@ -1077,7 +1076,11 @@ async function main() {
|
|
|
1077
1076
|
const walletAddress = new PublicKey(wallet);
|
|
1078
1077
|
const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
|
|
1079
1078
|
const userShares = await kaminoManager.getUserSharesBalanceSingleVault(walletAddress, kaminoVault);
|
|
1080
|
-
console.log(
|
|
1079
|
+
console.log(
|
|
1080
|
+
`User shares for vault ${vaultAddress.toBase58()}: unstaked shares: ${
|
|
1081
|
+
userShares.unstakedShares
|
|
1082
|
+
} staked shares: ${userShares.stakedShares} total shares: ${userShares.totalShares}`
|
|
1083
|
+
);
|
|
1081
1084
|
});
|
|
1082
1085
|
|
|
1083
1086
|
commands
|
|
@@ -1601,46 +1604,45 @@ async function processTxn(
|
|
|
1601
1604
|
priorityFeeMultiplier: number = 2500,
|
|
1602
1605
|
extraSigners: Signer[],
|
|
1603
1606
|
computeUnits: number = 200_000,
|
|
1604
|
-
priorityFeeLamports: number = 1000
|
|
1605
|
-
luts: PublicKey[] = []
|
|
1607
|
+
priorityFeeLamports: number = 1000
|
|
1606
1608
|
): Promise<TransactionSignature> {
|
|
1607
1609
|
if (mode !== 'inspect' && mode !== 'simulate' && mode !== 'execute' && mode !== 'multisig') {
|
|
1608
1610
|
throw new Error('Invalid mode: ' + mode + '. Must be one of: inspect/simulate/execute/multisig');
|
|
1609
1611
|
}
|
|
1610
1612
|
if (mode === 'multisig') {
|
|
1611
1613
|
const { blockhash } = await web3Client.connection.getLatestBlockhash();
|
|
1612
|
-
const
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1614
|
+
for (const ix of ixs) {
|
|
1615
|
+
const txn = new Transaction();
|
|
1616
|
+
txn.add(ix);
|
|
1617
|
+
txn.recentBlockhash = blockhash;
|
|
1618
|
+
txn.feePayer = admin.publicKey;
|
|
1616
1619
|
|
|
1617
|
-
|
|
1620
|
+
console.log(`${binary_to_base58(txn.serializeMessage())} \n`);
|
|
1621
|
+
}
|
|
1618
1622
|
|
|
1619
1623
|
return '';
|
|
1620
1624
|
} else {
|
|
1621
1625
|
const microLamport = priorityFeeLamports * 10 ** 6; // 1000 lamports
|
|
1622
1626
|
const microLamportsPrioritizationFee = microLamport / computeUnits;
|
|
1623
|
-
const { blockhash } = await web3Client.connection.getLatestBlockhash();
|
|
1624
1627
|
|
|
1628
|
+
const tx = new Transaction();
|
|
1629
|
+
const { blockhash } = await web3Client.connection.getLatestBlockhash();
|
|
1625
1630
|
if (priorityFeeMultiplier) {
|
|
1626
1631
|
const priorityFeeIxn = createAddExtraComputeUnitFeeTransaction(
|
|
1627
1632
|
computeUnits,
|
|
1628
1633
|
microLamportsPrioritizationFee * priorityFeeMultiplier
|
|
1629
1634
|
);
|
|
1630
|
-
|
|
1635
|
+
tx.add(...priorityFeeIxn);
|
|
1631
1636
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
recentBlockhash: blockhash,
|
|
1636
|
-
instructions: ixs,
|
|
1637
|
-
}).compileToV0Message(await getLookupTableAccounts(web3Client.connection, luts));
|
|
1637
|
+
tx.recentBlockhash = blockhash;
|
|
1638
|
+
tx.feePayer = admin.publicKey;
|
|
1639
|
+
tx.add(...ixs);
|
|
1638
1640
|
|
|
1639
1641
|
if (mode === 'execute') {
|
|
1640
1642
|
return await signSendAndConfirmRawTransactionWithRetry({
|
|
1641
1643
|
mainConnection: web3Client.sendConnection,
|
|
1642
1644
|
extraConnections: [],
|
|
1643
|
-
tx: new VersionedTransaction(tx),
|
|
1645
|
+
tx: new VersionedTransaction(tx.compileMessage()),
|
|
1644
1646
|
signers: [admin, ...extraSigners],
|
|
1645
1647
|
commitment: 'confirmed',
|
|
1646
1648
|
sendTransactionOptions: {
|
|
@@ -1649,7 +1651,9 @@ async function processTxn(
|
|
|
1649
1651
|
},
|
|
1650
1652
|
});
|
|
1651
1653
|
} else if (mode === 'simulate') {
|
|
1652
|
-
const simulation = await web3Client.sendConnection.simulateTransaction(
|
|
1654
|
+
const simulation = await web3Client.sendConnection.simulateTransaction(
|
|
1655
|
+
new VersionedTransaction(tx.compileMessage())
|
|
1656
|
+
);
|
|
1653
1657
|
if (simulation.value.logs && simulation.value.logs.length > 0) {
|
|
1654
1658
|
console.log('Simulation: \n' + simulation.value.logs);
|
|
1655
1659
|
} else {
|
|
@@ -1659,7 +1663,7 @@ async function processTxn(
|
|
|
1659
1663
|
console.log(
|
|
1660
1664
|
'Tx in B64',
|
|
1661
1665
|
`https://explorer.solana.com/tx/inspector?message=${encodeURIComponent(
|
|
1662
|
-
|
|
1666
|
+
tx.serializeMessage().toString('base64')
|
|
1663
1667
|
)}`
|
|
1664
1668
|
);
|
|
1665
1669
|
}
|
|
@@ -1857,15 +1861,3 @@ function parseReserveConfigToFile(reserveConfig: ReserveConfig) {
|
|
|
1857
1861
|
reserved2: Array(9).fill(0),
|
|
1858
1862
|
};
|
|
1859
1863
|
}
|
|
1860
|
-
|
|
1861
|
-
async function createUpdateReserveConfigLutIxs(
|
|
1862
|
-
env: Env,
|
|
1863
|
-
lendingMarketAddress: PublicKey,
|
|
1864
|
-
reserveAddress: PublicKey
|
|
1865
|
-
): Promise<[PublicKey, TransactionInstruction[]]> {
|
|
1866
|
-
const [globalConfigAddress] = globalConfigPda(PROGRAM_ID);
|
|
1867
|
-
const contents = [globalConfigAddress, lendingMarketAddress, reserveAddress];
|
|
1868
|
-
const [createIx, lut] = await createLookupTableIx(env.connection, env.payer.publicKey);
|
|
1869
|
-
const extendIxs = extendLookupTableIxs(env.payer.publicKey, lut, contents);
|
|
1870
|
-
return [lut, [createIx, ...extendIxs]];
|
|
1871
|
-
}
|
package/src/idl.json
CHANGED
|
@@ -230,15 +230,10 @@
|
|
|
230
230
|
"name": "updateReserveConfig",
|
|
231
231
|
"accounts": [
|
|
232
232
|
{
|
|
233
|
-
"name": "
|
|
233
|
+
"name": "lendingMarketOwner",
|
|
234
234
|
"isMut": false,
|
|
235
235
|
"isSigner": true
|
|
236
236
|
},
|
|
237
|
-
{
|
|
238
|
-
"name": "globalConfig",
|
|
239
|
-
"isMut": false,
|
|
240
|
-
"isSigner": false
|
|
241
|
-
},
|
|
242
237
|
{
|
|
243
238
|
"name": "lendingMarket",
|
|
244
239
|
"isMut": false,
|
|
@@ -253,9 +248,7 @@
|
|
|
253
248
|
"args": [
|
|
254
249
|
{
|
|
255
250
|
"name": "mode",
|
|
256
|
-
"type":
|
|
257
|
-
"defined": "UpdateConfigMode"
|
|
258
|
-
}
|
|
251
|
+
"type": "u64"
|
|
259
252
|
},
|
|
260
253
|
{
|
|
261
254
|
"name": "value",
|
|
@@ -312,9 +305,9 @@
|
|
|
312
305
|
"name": "withdrawProtocolFee",
|
|
313
306
|
"accounts": [
|
|
314
307
|
{
|
|
315
|
-
"name": "
|
|
308
|
+
"name": "lendingMarketOwner",
|
|
316
309
|
"isMut": false,
|
|
317
|
-
"isSigner":
|
|
310
|
+
"isSigner": true
|
|
318
311
|
},
|
|
319
312
|
{
|
|
320
313
|
"name": "lendingMarket",
|
|
@@ -342,7 +335,7 @@
|
|
|
342
335
|
"isSigner": false
|
|
343
336
|
},
|
|
344
337
|
{
|
|
345
|
-
"name": "
|
|
338
|
+
"name": "lendingMarketOwnerAta",
|
|
346
339
|
"isMut": true,
|
|
347
340
|
"isSigner": false
|
|
348
341
|
},
|
|
@@ -2939,93 +2932,14 @@
|
|
|
2939
2932
|
}
|
|
2940
2933
|
]
|
|
2941
2934
|
},
|
|
2942
|
-
{
|
|
2943
|
-
"name": "initGlobalConfig",
|
|
2944
|
-
"accounts": [
|
|
2945
|
-
{
|
|
2946
|
-
"name": "payer",
|
|
2947
|
-
"isMut": true,
|
|
2948
|
-
"isSigner": true
|
|
2949
|
-
},
|
|
2950
|
-
{
|
|
2951
|
-
"name": "globalConfig",
|
|
2952
|
-
"isMut": true,
|
|
2953
|
-
"isSigner": false
|
|
2954
|
-
},
|
|
2955
|
-
{
|
|
2956
|
-
"name": "programData",
|
|
2957
|
-
"isMut": false,
|
|
2958
|
-
"isSigner": false
|
|
2959
|
-
},
|
|
2960
|
-
{
|
|
2961
|
-
"name": "systemProgram",
|
|
2962
|
-
"isMut": false,
|
|
2963
|
-
"isSigner": false
|
|
2964
|
-
},
|
|
2965
|
-
{
|
|
2966
|
-
"name": "rent",
|
|
2967
|
-
"isMut": false,
|
|
2968
|
-
"isSigner": false
|
|
2969
|
-
}
|
|
2970
|
-
],
|
|
2971
|
-
"args": []
|
|
2972
|
-
},
|
|
2973
|
-
{
|
|
2974
|
-
"name": "updateGlobalConfig",
|
|
2975
|
-
"accounts": [
|
|
2976
|
-
{
|
|
2977
|
-
"name": "globalAdmin",
|
|
2978
|
-
"isMut": false,
|
|
2979
|
-
"isSigner": true
|
|
2980
|
-
},
|
|
2981
|
-
{
|
|
2982
|
-
"name": "globalConfig",
|
|
2983
|
-
"isMut": true,
|
|
2984
|
-
"isSigner": false
|
|
2985
|
-
}
|
|
2986
|
-
],
|
|
2987
|
-
"args": [
|
|
2988
|
-
{
|
|
2989
|
-
"name": "mode",
|
|
2990
|
-
"type": {
|
|
2991
|
-
"defined": "UpdateGlobalConfigMode"
|
|
2992
|
-
}
|
|
2993
|
-
},
|
|
2994
|
-
{
|
|
2995
|
-
"name": "value",
|
|
2996
|
-
"type": "bytes"
|
|
2997
|
-
}
|
|
2998
|
-
]
|
|
2999
|
-
},
|
|
3000
|
-
{
|
|
3001
|
-
"name": "updateGlobalConfigAdmin",
|
|
3002
|
-
"accounts": [
|
|
3003
|
-
{
|
|
3004
|
-
"name": "pendingAdmin",
|
|
3005
|
-
"isMut": false,
|
|
3006
|
-
"isSigner": true
|
|
3007
|
-
},
|
|
3008
|
-
{
|
|
3009
|
-
"name": "globalConfig",
|
|
3010
|
-
"isMut": true,
|
|
3011
|
-
"isSigner": false
|
|
3012
|
-
}
|
|
3013
|
-
],
|
|
3014
|
-
"args": []
|
|
3015
|
-
},
|
|
3016
2935
|
{
|
|
3017
2936
|
"name": "idlMissingTypes",
|
|
3018
2937
|
"accounts": [
|
|
3019
2938
|
{
|
|
3020
|
-
"name": "
|
|
2939
|
+
"name": "lendingMarketOwner",
|
|
3021
2940
|
"isMut": false,
|
|
3022
2941
|
"isSigner": true
|
|
3023
2942
|
},
|
|
3024
|
-
{
|
|
3025
|
-
"name": "globalConfig",
|
|
3026
|
-
"isMut": false,
|
|
3027
|
-
"isSigner": false
|
|
3028
|
-
},
|
|
3029
2943
|
{
|
|
3030
2944
|
"name": "lendingMarket",
|
|
3031
2945
|
"isMut": false,
|
|
@@ -3220,47 +3134,6 @@
|
|
|
3220
3134
|
]
|
|
3221
3135
|
}
|
|
3222
3136
|
},
|
|
3223
|
-
{
|
|
3224
|
-
"name": "GlobalConfig",
|
|
3225
|
-
"type": {
|
|
3226
|
-
"kind": "struct",
|
|
3227
|
-
"fields": [
|
|
3228
|
-
{
|
|
3229
|
-
"name": "globalAdmin",
|
|
3230
|
-
"docs": [
|
|
3231
|
-
"Global admin of the program"
|
|
3232
|
-
],
|
|
3233
|
-
"type": "publicKey"
|
|
3234
|
-
},
|
|
3235
|
-
{
|
|
3236
|
-
"name": "pendingAdmin",
|
|
3237
|
-
"docs": [
|
|
3238
|
-
"Pending admin must sign a specific transaction to become the global admin"
|
|
3239
|
-
],
|
|
3240
|
-
"type": "publicKey"
|
|
3241
|
-
},
|
|
3242
|
-
{
|
|
3243
|
-
"name": "feeCollector",
|
|
3244
|
-
"docs": [
|
|
3245
|
-
"Fee collector is the only allowed owner of token accounts receiving protocol fees"
|
|
3246
|
-
],
|
|
3247
|
-
"type": "publicKey"
|
|
3248
|
-
},
|
|
3249
|
-
{
|
|
3250
|
-
"name": "padding",
|
|
3251
|
-
"docs": [
|
|
3252
|
-
"Padding to make the struct size 1024 bytes"
|
|
3253
|
-
],
|
|
3254
|
-
"type": {
|
|
3255
|
-
"array": [
|
|
3256
|
-
"u8",
|
|
3257
|
-
928
|
|
3258
|
-
]
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
]
|
|
3262
|
-
}
|
|
3263
|
-
},
|
|
3264
3137
|
{
|
|
3265
3138
|
"name": "LendingMarket",
|
|
3266
3139
|
"type": {
|
|
@@ -3480,33 +3353,18 @@
|
|
|
3480
3353
|
"type": "u64"
|
|
3481
3354
|
},
|
|
3482
3355
|
{
|
|
3483
|
-
"name": "
|
|
3356
|
+
"name": "obligationOrdersEnabled",
|
|
3484
3357
|
"docs": [
|
|
3485
3358
|
"Whether the obligation orders should be evaluated during liquidations."
|
|
3486
3359
|
],
|
|
3487
3360
|
"type": "u8"
|
|
3488
3361
|
},
|
|
3489
|
-
{
|
|
3490
|
-
"name": "immutable",
|
|
3491
|
-
"docs": [
|
|
3492
|
-
"Whether the lending market is set as immutable."
|
|
3493
|
-
],
|
|
3494
|
-
"type": "u8"
|
|
3495
|
-
},
|
|
3496
|
-
{
|
|
3497
|
-
"name": "obligationOrderCreationEnabled",
|
|
3498
|
-
"docs": [
|
|
3499
|
-
"Whether new obligation orders can be created.",
|
|
3500
|
-
"Note: updating or cancelling existing orders is *not* affected by this flag."
|
|
3501
|
-
],
|
|
3502
|
-
"type": "u8"
|
|
3503
|
-
},
|
|
3504
3362
|
{
|
|
3505
3363
|
"name": "padding2",
|
|
3506
3364
|
"type": {
|
|
3507
3365
|
"array": [
|
|
3508
3366
|
"u8",
|
|
3509
|
-
|
|
3367
|
+
7
|
|
3510
3368
|
]
|
|
3511
3369
|
}
|
|
3512
3370
|
},
|
|
@@ -4328,27 +4186,7 @@
|
|
|
4328
4186
|
"name": "UpdateInitialDepositAmount"
|
|
4329
4187
|
},
|
|
4330
4188
|
{
|
|
4331
|
-
"name": "
|
|
4332
|
-
},
|
|
4333
|
-
{
|
|
4334
|
-
"name": "UpdateImmutableFlag"
|
|
4335
|
-
},
|
|
4336
|
-
{
|
|
4337
|
-
"name": "UpdateObligationOrderCreationEnabled"
|
|
4338
|
-
}
|
|
4339
|
-
]
|
|
4340
|
-
}
|
|
4341
|
-
},
|
|
4342
|
-
{
|
|
4343
|
-
"name": "UpdateGlobalConfigMode",
|
|
4344
|
-
"type": {
|
|
4345
|
-
"kind": "enum",
|
|
4346
|
-
"variants": [
|
|
4347
|
-
{
|
|
4348
|
-
"name": "PendingAdmin"
|
|
4349
|
-
},
|
|
4350
|
-
{
|
|
4351
|
-
"name": "FeeCollector"
|
|
4189
|
+
"name": "UpdateObligationOrdersEnabled"
|
|
4352
4190
|
}
|
|
4353
4191
|
]
|
|
4354
4192
|
}
|
|
@@ -6194,21 +6032,6 @@
|
|
|
6194
6032
|
"code": 6126,
|
|
6195
6033
|
"name": "OperationNotPermittedWithCurrentObligationOrders",
|
|
6196
6034
|
"msg": "Single debt, single collateral obligation orders have to be cancelled before changing the deposit/borrow count"
|
|
6197
|
-
},
|
|
6198
|
-
{
|
|
6199
|
-
"code": 6127,
|
|
6200
|
-
"name": "OperationNotPermittedMarketImmutable",
|
|
6201
|
-
"msg": "Cannot update lending market because it is set as immutable"
|
|
6202
|
-
},
|
|
6203
|
-
{
|
|
6204
|
-
"code": 6128,
|
|
6205
|
-
"name": "OrderCreationDisabled",
|
|
6206
|
-
"msg": "Creation of new orders is disabled"
|
|
6207
|
-
},
|
|
6208
|
-
{
|
|
6209
|
-
"code": 6129,
|
|
6210
|
-
"name": "NoUpgradeAuthority",
|
|
6211
|
-
"msg": "Cannot initialize global config because there is no upgrade authority to the program"
|
|
6212
6035
|
}
|
|
6213
6036
|
]
|
|
6214
6037
|
}
|
|
@@ -73,14 +73,7 @@ export interface LendingMarketFields {
|
|
|
73
73
|
*/
|
|
74
74
|
minInitialDepositAmount: BN
|
|
75
75
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
76
|
-
|
|
77
|
-
/** Whether the lending market is set as immutable. */
|
|
78
|
-
immutable: number
|
|
79
|
-
/**
|
|
80
|
-
* Whether new obligation orders can be created.
|
|
81
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
82
|
-
*/
|
|
83
|
-
obligationOrderCreationEnabled: number
|
|
76
|
+
obligationOrdersEnabled: number
|
|
84
77
|
padding2: Array<number>
|
|
85
78
|
padding1: Array<BN>
|
|
86
79
|
}
|
|
@@ -154,14 +147,7 @@ export interface LendingMarketJSON {
|
|
|
154
147
|
*/
|
|
155
148
|
minInitialDepositAmount: string
|
|
156
149
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
157
|
-
|
|
158
|
-
/** Whether the lending market is set as immutable. */
|
|
159
|
-
immutable: number
|
|
160
|
-
/**
|
|
161
|
-
* Whether new obligation orders can be created.
|
|
162
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
163
|
-
*/
|
|
164
|
-
obligationOrderCreationEnabled: number
|
|
150
|
+
obligationOrdersEnabled: number
|
|
165
151
|
padding2: Array<number>
|
|
166
152
|
padding1: Array<string>
|
|
167
153
|
}
|
|
@@ -235,14 +221,7 @@ export class LendingMarket {
|
|
|
235
221
|
*/
|
|
236
222
|
readonly minInitialDepositAmount: BN
|
|
237
223
|
/** Whether the obligation orders should be evaluated during liquidations. */
|
|
238
|
-
readonly
|
|
239
|
-
/** Whether the lending market is set as immutable. */
|
|
240
|
-
readonly immutable: number
|
|
241
|
-
/**
|
|
242
|
-
* Whether new obligation orders can be created.
|
|
243
|
-
* Note: updating or cancelling existing orders is *not* affected by this flag.
|
|
244
|
-
*/
|
|
245
|
-
readonly obligationOrderCreationEnabled: number
|
|
224
|
+
readonly obligationOrdersEnabled: number
|
|
246
225
|
readonly padding2: Array<number>
|
|
247
226
|
readonly padding1: Array<BN>
|
|
248
227
|
|
|
@@ -277,10 +256,8 @@ export class LendingMarket {
|
|
|
277
256
|
borsh.u64("minValueSkipLiquidationBfChecks"),
|
|
278
257
|
borsh.u64("individualAutodeleverageMarginCallPeriodSecs"),
|
|
279
258
|
borsh.u64("minInitialDepositAmount"),
|
|
280
|
-
borsh.u8("
|
|
281
|
-
borsh.u8("
|
|
282
|
-
borsh.u8("obligationOrderCreationEnabled"),
|
|
283
|
-
borsh.array(borsh.u8(), 5, "padding2"),
|
|
259
|
+
borsh.u8("obligationOrdersEnabled"),
|
|
260
|
+
borsh.array(borsh.u8(), 7, "padding2"),
|
|
284
261
|
borsh.array(borsh.u64(), 169, "padding1"),
|
|
285
262
|
])
|
|
286
263
|
|
|
@@ -319,10 +296,7 @@ export class LendingMarket {
|
|
|
319
296
|
this.individualAutodeleverageMarginCallPeriodSecs =
|
|
320
297
|
fields.individualAutodeleverageMarginCallPeriodSecs
|
|
321
298
|
this.minInitialDepositAmount = fields.minInitialDepositAmount
|
|
322
|
-
this.
|
|
323
|
-
fields.obligationOrderExecutionEnabled
|
|
324
|
-
this.immutable = fields.immutable
|
|
325
|
-
this.obligationOrderCreationEnabled = fields.obligationOrderCreationEnabled
|
|
299
|
+
this.obligationOrdersEnabled = fields.obligationOrdersEnabled
|
|
326
300
|
this.padding2 = fields.padding2
|
|
327
301
|
this.padding1 = fields.padding1
|
|
328
302
|
}
|
|
@@ -403,9 +377,7 @@ export class LendingMarket {
|
|
|
403
377
|
individualAutodeleverageMarginCallPeriodSecs:
|
|
404
378
|
dec.individualAutodeleverageMarginCallPeriodSecs,
|
|
405
379
|
minInitialDepositAmount: dec.minInitialDepositAmount,
|
|
406
|
-
|
|
407
|
-
immutable: dec.immutable,
|
|
408
|
-
obligationOrderCreationEnabled: dec.obligationOrderCreationEnabled,
|
|
380
|
+
obligationOrdersEnabled: dec.obligationOrdersEnabled,
|
|
409
381
|
padding2: dec.padding2,
|
|
410
382
|
padding1: dec.padding1,
|
|
411
383
|
})
|
|
@@ -446,9 +418,7 @@ export class LendingMarket {
|
|
|
446
418
|
individualAutodeleverageMarginCallPeriodSecs:
|
|
447
419
|
this.individualAutodeleverageMarginCallPeriodSecs.toString(),
|
|
448
420
|
minInitialDepositAmount: this.minInitialDepositAmount.toString(),
|
|
449
|
-
|
|
450
|
-
immutable: this.immutable,
|
|
451
|
-
obligationOrderCreationEnabled: this.obligationOrderCreationEnabled,
|
|
421
|
+
obligationOrdersEnabled: this.obligationOrdersEnabled,
|
|
452
422
|
padding2: this.padding2,
|
|
453
423
|
padding1: this.padding1.map((item) => item.toString()),
|
|
454
424
|
}
|
|
@@ -496,9 +466,7 @@ export class LendingMarket {
|
|
|
496
466
|
obj.individualAutodeleverageMarginCallPeriodSecs
|
|
497
467
|
),
|
|
498
468
|
minInitialDepositAmount: new BN(obj.minInitialDepositAmount),
|
|
499
|
-
|
|
500
|
-
immutable: obj.immutable,
|
|
501
|
-
obligationOrderCreationEnabled: obj.obligationOrderCreationEnabled,
|
|
469
|
+
obligationOrdersEnabled: obj.obligationOrdersEnabled,
|
|
502
470
|
padding2: obj.padding2,
|
|
503
471
|
padding1: obj.padding1.map((item) => new BN(item)),
|
|
504
472
|
})
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { UserState } from "./UserState"
|
|
2
2
|
export type { UserStateFields, UserStateJSON } from "./UserState"
|
|
3
|
-
export { GlobalConfig } from "./GlobalConfig"
|
|
4
|
-
export type { GlobalConfigFields, GlobalConfigJSON } from "./GlobalConfig"
|
|
5
3
|
export { LendingMarket } from "./LendingMarket"
|
|
6
4
|
export type { LendingMarketFields, LendingMarketJSON } from "./LendingMarket"
|
|
7
5
|
export { Obligation } from "./Obligation"
|