@0dotxyz/p0-ts-sdk 2.3.0-alpha.9 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +235 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +129 -3
- package/dist/index.d.ts +129 -3
- package/dist/index.js +229 -2
- package/dist/index.js.map +1 -1
- package/dist/instructions.d.cts +1 -1
- package/dist/instructions.d.ts +1 -1
- package/dist/{types-BC4kJXuQ.d.ts → types-Cxl2AUvk.d.ts} +59 -2
- package/dist/{types-6ULf9Ciw.d.cts → types-DtUR-yHt.d.cts} +59 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var bufferLayout = require('@solana/buffer-layout');
|
|
|
10
10
|
var bufferLayoutUtils = require('@solana/buffer-layout-utils');
|
|
11
11
|
var buffer = require('buffer');
|
|
12
12
|
var borsh$1 = require('borsh');
|
|
13
|
+
var bs58 = require('bs58');
|
|
13
14
|
var borsh = require('@coral-xyz/borsh');
|
|
14
15
|
var WebSocket = require('ws');
|
|
15
16
|
var msgpack = require('@msgpack/msgpack');
|
|
@@ -39,6 +40,7 @@ function _interopNamespace(e) {
|
|
|
39
40
|
var BigNumber3__default = /*#__PURE__*/_interopDefault(BigNumber3);
|
|
40
41
|
var BN11__default = /*#__PURE__*/_interopDefault(BN11);
|
|
41
42
|
var Decimal3__default = /*#__PURE__*/_interopDefault(Decimal3);
|
|
43
|
+
var bs58__default = /*#__PURE__*/_interopDefault(bs58);
|
|
42
44
|
var borsh__namespace = /*#__PURE__*/_interopNamespace(borsh);
|
|
43
45
|
var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
|
|
44
46
|
|
|
@@ -16043,8 +16045,10 @@ function toBankDto(bank) {
|
|
|
16043
16045
|
emissionsRate: bank.emissionsRate,
|
|
16044
16046
|
emissionsMint: bank.emissionsMint.toBase58(),
|
|
16045
16047
|
emissionsRemaining: bank.emissionsRemaining.toString(),
|
|
16048
|
+
collectedProgramFeesOutstanding: bank.collectedProgramFeesOutstanding.toString(),
|
|
16046
16049
|
oracleKey: bank.oracleKey.toBase58(),
|
|
16047
16050
|
emode: toEmodeSettingsDto(bank.emode),
|
|
16051
|
+
rateLimiter: bank.rateLimiter ? toBankRateLimiterDto(bank.rateLimiter) : void 0,
|
|
16048
16052
|
tokenSymbol: bank.tokenSymbol,
|
|
16049
16053
|
feesDestinationAccount: bank.feesDestinationAccount?.toBase58(),
|
|
16050
16054
|
lendingPositionCount: bank.lendingPositionCount?.toString(),
|
|
@@ -16069,6 +16073,21 @@ function toBankDto(bank) {
|
|
|
16069
16073
|
} : void 0
|
|
16070
16074
|
};
|
|
16071
16075
|
}
|
|
16076
|
+
function toRateLimitWindowDto(window) {
|
|
16077
|
+
return {
|
|
16078
|
+
maxOutflow: window.maxOutflow.toString(),
|
|
16079
|
+
windowDuration: window.windowDuration,
|
|
16080
|
+
windowStart: window.windowStart,
|
|
16081
|
+
prevWindowOutflow: window.prevWindowOutflow.toString(),
|
|
16082
|
+
curWindowOutflow: window.curWindowOutflow.toString()
|
|
16083
|
+
};
|
|
16084
|
+
}
|
|
16085
|
+
function toBankRateLimiterDto(rateLimiter) {
|
|
16086
|
+
return {
|
|
16087
|
+
hourly: toRateLimitWindowDto(rateLimiter.hourly),
|
|
16088
|
+
daily: toRateLimitWindowDto(rateLimiter.daily)
|
|
16089
|
+
};
|
|
16090
|
+
}
|
|
16072
16091
|
function toEmodeSettingsDto(emodeSettings) {
|
|
16073
16092
|
return {
|
|
16074
16093
|
emodeTag: emodeSettings.emodeTag,
|
|
@@ -16147,6 +16166,8 @@ function bankRawToDto(bankRaw) {
|
|
|
16147
16166
|
emissionsRate: bankRaw.emissionsRate.toString(),
|
|
16148
16167
|
emissionsRemaining: bankRaw.emissionsRemaining,
|
|
16149
16168
|
emissionsMint: bankRaw.emissionsMint.toBase58(),
|
|
16169
|
+
collectedProgramFeesOutstanding: bankRaw.collectedProgramFeesOutstanding,
|
|
16170
|
+
rateLimiter: bankRaw.rateLimiter ? bankRateLimiterRawToDto(bankRaw.rateLimiter) : void 0,
|
|
16150
16171
|
feesDestinationAccount: bankRaw?.feesDestinationAccount?.toBase58(),
|
|
16151
16172
|
lendingPositionCount: bankRaw?.lendingPositionCount?.toString(),
|
|
16152
16173
|
borrowingPositionCount: bankRaw?.borrowingPositionCount?.toString(),
|
|
@@ -16156,6 +16177,21 @@ function bankRawToDto(bankRaw) {
|
|
|
16156
16177
|
integrationAcc3: bankRaw.integrationAcc3.toBase58()
|
|
16157
16178
|
};
|
|
16158
16179
|
}
|
|
16180
|
+
function rateLimitWindowRawToDto(window) {
|
|
16181
|
+
return {
|
|
16182
|
+
maxOutflow: window.maxOutflow.toString(),
|
|
16183
|
+
windowDuration: window.windowDuration.toString(),
|
|
16184
|
+
windowStart: window.windowStart.toString(),
|
|
16185
|
+
prevWindowOutflow: window.prevWindowOutflow.toString(),
|
|
16186
|
+
curWindowOutflow: window.curWindowOutflow.toString()
|
|
16187
|
+
};
|
|
16188
|
+
}
|
|
16189
|
+
function bankRateLimiterRawToDto(rateLimiter) {
|
|
16190
|
+
return {
|
|
16191
|
+
hourly: rateLimitWindowRawToDto(rateLimiter.hourly),
|
|
16192
|
+
daily: rateLimitWindowRawToDto(rateLimiter.daily)
|
|
16193
|
+
};
|
|
16194
|
+
}
|
|
16159
16195
|
function emodeSettingsRawToDto(emodeSettingsRaw) {
|
|
16160
16196
|
return {
|
|
16161
16197
|
emodeTag: emodeSettingsRaw.emodeTag,
|
|
@@ -16255,6 +16291,21 @@ function parseEmodeSettingsRaw(emodeSettingsRaw) {
|
|
|
16255
16291
|
};
|
|
16256
16292
|
return emodeSettings;
|
|
16257
16293
|
}
|
|
16294
|
+
function parseRateLimitWindowRaw(window) {
|
|
16295
|
+
return {
|
|
16296
|
+
maxOutflow: new BigNumber3__default.default(window.maxOutflow.toString()),
|
|
16297
|
+
windowDuration: window.windowDuration.toNumber(),
|
|
16298
|
+
windowStart: window.windowStart.toNumber(),
|
|
16299
|
+
prevWindowOutflow: new BigNumber3__default.default(window.prevWindowOutflow.toString()),
|
|
16300
|
+
curWindowOutflow: new BigNumber3__default.default(window.curWindowOutflow.toString())
|
|
16301
|
+
};
|
|
16302
|
+
}
|
|
16303
|
+
function parseBankRateLimiterRaw(rateLimiter) {
|
|
16304
|
+
return {
|
|
16305
|
+
hourly: parseRateLimitWindowRaw(rateLimiter.hourly),
|
|
16306
|
+
daily: parseRateLimitWindowRaw(rateLimiter.daily)
|
|
16307
|
+
};
|
|
16308
|
+
}
|
|
16258
16309
|
function parseBankRaw(address, accountParsed, bankMetadata) {
|
|
16259
16310
|
const flags = accountParsed.flags.toNumber();
|
|
16260
16311
|
const mint = accountParsed.mint;
|
|
@@ -16286,8 +16337,10 @@ function parseBankRaw(address, accountParsed, bankMetadata) {
|
|
|
16286
16337
|
const emissionsRate = accountParsed.emissionsRate.toNumber();
|
|
16287
16338
|
const emissionsMint = accountParsed.emissionsMint;
|
|
16288
16339
|
const emissionsRemaining = accountParsed.emissionsRemaining ? wrappedI80F48toBigNumber(accountParsed.emissionsRemaining) : new BigNumber3__default.default(0);
|
|
16340
|
+
const collectedProgramFeesOutstanding = accountParsed.collectedProgramFeesOutstanding ? wrappedI80F48toBigNumber(accountParsed.collectedProgramFeesOutstanding) : new BigNumber3__default.default(0);
|
|
16289
16341
|
const { oracleKey } = { oracleKey: config.oracleKeys[0] };
|
|
16290
16342
|
const emode = parseEmodeSettingsRaw(accountParsed.emode);
|
|
16343
|
+
const rateLimiter = accountParsed.rateLimiter ? parseBankRateLimiterRaw(accountParsed.rateLimiter) : void 0;
|
|
16291
16344
|
const tokenSymbol = bankMetadata?.tokenSymbol;
|
|
16292
16345
|
const feesDestinationAccount = accountParsed.feesDestinationAccount;
|
|
16293
16346
|
const lendingPositionCount = accountParsed.lendingPositionCount ? new BigNumber3__default.default(accountParsed.lendingPositionCount.toString()) : new BigNumber3__default.default(0);
|
|
@@ -16348,11 +16401,13 @@ function parseBankRaw(address, accountParsed, bankMetadata) {
|
|
|
16348
16401
|
emissionsRate,
|
|
16349
16402
|
emissionsMint,
|
|
16350
16403
|
emissionsRemaining,
|
|
16404
|
+
collectedProgramFeesOutstanding,
|
|
16351
16405
|
oracleKey,
|
|
16352
16406
|
feesDestinationAccount,
|
|
16353
16407
|
lendingPositionCount,
|
|
16354
16408
|
borrowingPositionCount,
|
|
16355
16409
|
emode,
|
|
16410
|
+
rateLimiter,
|
|
16356
16411
|
tokenSymbol,
|
|
16357
16412
|
kaminoIntegrationAccounts,
|
|
16358
16413
|
driftIntegrationAccounts,
|
|
@@ -16388,8 +16443,10 @@ function dtoToBank(bankDto) {
|
|
|
16388
16443
|
emissionsRate: bankDto.emissionsRate,
|
|
16389
16444
|
emissionsMint: new web3_js.PublicKey(bankDto.emissionsMint),
|
|
16390
16445
|
emissionsRemaining: new BigNumber3__default.default(bankDto.emissionsRemaining),
|
|
16446
|
+
collectedProgramFeesOutstanding: new BigNumber3__default.default(bankDto.collectedProgramFeesOutstanding ?? "0"),
|
|
16391
16447
|
oracleKey: new web3_js.PublicKey(bankDto.oracleKey),
|
|
16392
16448
|
emode: dtoToEmodeSettings(bankDto.emode),
|
|
16449
|
+
rateLimiter: bankDto.rateLimiter ? dtoToBankRateLimiter(bankDto.rateLimiter) : void 0,
|
|
16393
16450
|
tokenSymbol: bankDto.tokenSymbol,
|
|
16394
16451
|
feesDestinationAccount: bankDto.feesDestinationAccount ? new web3_js.PublicKey(bankDto.feesDestinationAccount) : void 0,
|
|
16395
16452
|
lendingPositionCount: bankDto.lendingPositionCount ? new BigNumber3__default.default(bankDto.lendingPositionCount) : void 0,
|
|
@@ -16414,6 +16471,21 @@ function dtoToBank(bankDto) {
|
|
|
16414
16471
|
} : void 0
|
|
16415
16472
|
};
|
|
16416
16473
|
}
|
|
16474
|
+
function dtoToRateLimitWindow(window) {
|
|
16475
|
+
return {
|
|
16476
|
+
maxOutflow: new BigNumber3__default.default(window.maxOutflow),
|
|
16477
|
+
windowDuration: window.windowDuration,
|
|
16478
|
+
windowStart: window.windowStart,
|
|
16479
|
+
prevWindowOutflow: new BigNumber3__default.default(window.prevWindowOutflow),
|
|
16480
|
+
curWindowOutflow: new BigNumber3__default.default(window.curWindowOutflow)
|
|
16481
|
+
};
|
|
16482
|
+
}
|
|
16483
|
+
function dtoToBankRateLimiter(rateLimiter) {
|
|
16484
|
+
return {
|
|
16485
|
+
hourly: dtoToRateLimitWindow(rateLimiter.hourly),
|
|
16486
|
+
daily: dtoToRateLimitWindow(rateLimiter.daily)
|
|
16487
|
+
};
|
|
16488
|
+
}
|
|
16417
16489
|
function dtoToEmodeSettings(emodeSettingsDto) {
|
|
16418
16490
|
return {
|
|
16419
16491
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
@@ -16492,6 +16564,8 @@ function dtoToBankRaw(bankDto) {
|
|
|
16492
16564
|
emissionsRate: new BN11__default.default(bankDto.emissionsRate),
|
|
16493
16565
|
emissionsRemaining: bankDto.emissionsRemaining,
|
|
16494
16566
|
emissionsMint: new web3_js.PublicKey(bankDto.emissionsMint),
|
|
16567
|
+
collectedProgramFeesOutstanding: bankDto.collectedProgramFeesOutstanding,
|
|
16568
|
+
rateLimiter: bankDto.rateLimiter ? dtoToBankRateLimiterRaw(bankDto.rateLimiter) : void 0,
|
|
16495
16569
|
feesDestinationAccount: bankDto.feesDestinationAccount ? new web3_js.PublicKey(bankDto.feesDestinationAccount) : void 0,
|
|
16496
16570
|
lendingPositionCount: bankDto.lendingPositionCount ? Number(bankDto.lendingPositionCount) : void 0,
|
|
16497
16571
|
borrowingPositionCount: bankDto.borrowingPositionCount ? Number(bankDto.borrowingPositionCount) : void 0,
|
|
@@ -16501,6 +16575,21 @@ function dtoToBankRaw(bankDto) {
|
|
|
16501
16575
|
integrationAcc3: new web3_js.PublicKey(bankDto.integrationAcc3)
|
|
16502
16576
|
};
|
|
16503
16577
|
}
|
|
16578
|
+
function dtoToRateLimitWindowRaw(window) {
|
|
16579
|
+
return {
|
|
16580
|
+
maxOutflow: new BN11__default.default(window.maxOutflow),
|
|
16581
|
+
windowDuration: new BN11__default.default(window.windowDuration),
|
|
16582
|
+
windowStart: new BN11__default.default(window.windowStart),
|
|
16583
|
+
prevWindowOutflow: new BN11__default.default(window.prevWindowOutflow),
|
|
16584
|
+
curWindowOutflow: new BN11__default.default(window.curWindowOutflow)
|
|
16585
|
+
};
|
|
16586
|
+
}
|
|
16587
|
+
function dtoToBankRateLimiterRaw(rateLimiter) {
|
|
16588
|
+
return {
|
|
16589
|
+
hourly: dtoToRateLimitWindowRaw(rateLimiter.hourly),
|
|
16590
|
+
daily: dtoToRateLimitWindowRaw(rateLimiter.daily)
|
|
16591
|
+
};
|
|
16592
|
+
}
|
|
16504
16593
|
function dtoToEmodeSettingsRaw(emodeSettingsDto) {
|
|
16505
16594
|
return {
|
|
16506
16595
|
emodeTag: emodeSettingsDto.emodeTag,
|
|
@@ -65711,6 +65800,76 @@ var fetchMarginfiAccountAddresses = async (program, authority, group) => {
|
|
|
65711
65800
|
])).map((a) => a.publicKey);
|
|
65712
65801
|
return marginfiAccounts;
|
|
65713
65802
|
};
|
|
65803
|
+
var MARGINFI_ACCOUNT_DISCRIMINATOR = Buffer.from([67, 178, 130, 109, 126, 114, 28, 42]);
|
|
65804
|
+
var GROUP_OFFSET = 8;
|
|
65805
|
+
var BALANCES_OFFSET = 72;
|
|
65806
|
+
var BALANCE_SIZE = 104;
|
|
65807
|
+
var BANK_PK_OFFSET_IN_BALANCE = 1;
|
|
65808
|
+
var MAX_BALANCES = 16;
|
|
65809
|
+
var scanBankSlots = async (program, group, bank, options) => {
|
|
65810
|
+
const connection = program.provider.connection;
|
|
65811
|
+
const programId = program.programId;
|
|
65812
|
+
const discriminatorBytes = bs58__default.default.encode(MARGINFI_ACCOUNT_DISCRIMINATOR);
|
|
65813
|
+
const groupBytes = group.toBase58();
|
|
65814
|
+
const bankBytes = bank.toBase58();
|
|
65815
|
+
const slotOffsets = Array.from(
|
|
65816
|
+
{ length: MAX_BALANCES },
|
|
65817
|
+
(_, n) => BALANCES_OFFSET + BANK_PK_OFFSET_IN_BALANCE + n * BALANCE_SIZE
|
|
65818
|
+
);
|
|
65819
|
+
const scanSlot = (offset) => {
|
|
65820
|
+
const filters = [
|
|
65821
|
+
{ memcmp: { offset: 0, bytes: discriminatorBytes } },
|
|
65822
|
+
{ memcmp: { offset: GROUP_OFFSET, bytes: groupBytes } },
|
|
65823
|
+
{ memcmp: { offset, bytes: bankBytes } }
|
|
65824
|
+
];
|
|
65825
|
+
return connection.getProgramAccounts(programId, {
|
|
65826
|
+
filters,
|
|
65827
|
+
dataSlice: options.dataSlice
|
|
65828
|
+
});
|
|
65829
|
+
};
|
|
65830
|
+
const byAddress = /* @__PURE__ */ new Map();
|
|
65831
|
+
const collect = (slotResults) => {
|
|
65832
|
+
for (const { pubkey, account } of slotResults) {
|
|
65833
|
+
byAddress.set(pubkey.toBase58(), account);
|
|
65834
|
+
}
|
|
65835
|
+
};
|
|
65836
|
+
const concurrency = options.concurrency;
|
|
65837
|
+
if (concurrency === void 0 || concurrency >= slotOffsets.length) {
|
|
65838
|
+
(await Promise.all(slotOffsets.map(scanSlot))).forEach(collect);
|
|
65839
|
+
} else {
|
|
65840
|
+
const batchSize = Math.max(1, Math.floor(concurrency));
|
|
65841
|
+
for (let i = 0; i < slotOffsets.length; i += batchSize) {
|
|
65842
|
+
const batch = slotOffsets.slice(i, i + batchSize);
|
|
65843
|
+
(await Promise.all(batch.map(scanSlot))).forEach(collect);
|
|
65844
|
+
}
|
|
65845
|
+
}
|
|
65846
|
+
return byAddress;
|
|
65847
|
+
};
|
|
65848
|
+
var fetchMarginfiAccountAddressesHoldingBank = async (program, group, bank, options) => {
|
|
65849
|
+
const byAddress = await scanBankSlots(program, group, bank, {
|
|
65850
|
+
concurrency: options?.concurrency,
|
|
65851
|
+
dataSlice: { offset: 0, length: 0 }
|
|
65852
|
+
});
|
|
65853
|
+
return Array.from(byAddress.keys(), (a) => new web3_js.PublicKey(a));
|
|
65854
|
+
};
|
|
65855
|
+
var fetchMarginfiAccountActiveBalancesForBank = async (program, group, bank, options) => {
|
|
65856
|
+
const byAddress = await scanBankSlots(program, group, bank, {
|
|
65857
|
+
concurrency: options?.concurrency
|
|
65858
|
+
});
|
|
65859
|
+
const results = [];
|
|
65860
|
+
for (const [address, account] of byAddress) {
|
|
65861
|
+
const accountAddress = new web3_js.PublicKey(address);
|
|
65862
|
+
const raw = program.coder.accounts.decode(
|
|
65863
|
+
"marginfiAccount" /* MarginfiAccount */,
|
|
65864
|
+
account.data
|
|
65865
|
+
);
|
|
65866
|
+
const parsed = parseMarginfiAccountRaw(accountAddress, raw);
|
|
65867
|
+
const balance = parsed.balances.find((b) => b.active && b.bankPk.equals(bank));
|
|
65868
|
+
if (!balance) continue;
|
|
65869
|
+
results.push({ accountAddress, authority: parsed.authority, balance });
|
|
65870
|
+
}
|
|
65871
|
+
return results;
|
|
65872
|
+
};
|
|
65714
65873
|
var fetchMarginfiAccountData = async (program, marginfiAccountPk, banksMap, bankIntegrationMap) => {
|
|
65715
65874
|
const marginfiAccountRaw = await program.account.marginfiAccount.fetch(
|
|
65716
65875
|
marginfiAccountPk,
|
|
@@ -68965,7 +69124,7 @@ async function fetchBankIntegrationMetadata(options) {
|
|
|
68965
69124
|
return bankIntegrationMap;
|
|
68966
69125
|
}
|
|
68967
69126
|
var Bank = class _Bank {
|
|
68968
|
-
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, oracleKey, emode, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
69127
|
+
constructor(address, mint, mintDecimals, group, assetShareValue, liabilityShareValue, liquidityVault, liquidityVaultBump, liquidityVaultAuthorityBump, insuranceVault, insuranceVaultBump, insuranceVaultAuthorityBump, collectedInsuranceFeesOutstanding, feeVault, feeVaultBump, feeVaultAuthorityBump, collectedGroupFeesOutstanding, lastUpdate, config, totalAssetShares, totalLiabilityShares, emissionsActiveBorrowing, emissionsActiveLending, emissionsRate, emissionsMint, emissionsRemaining, collectedProgramFeesOutstanding, oracleKey, emode, rateLimiter, kaminoIntegrationAccounts, driftIntegrationAccounts, solendIntegrationAccounts, jupLendIntegrationAccounts, feesDestinationAccount, lendingPositionCount, borrowingPositionCount, tokenSymbol) {
|
|
68969
69128
|
this.address = address;
|
|
68970
69129
|
this.mint = mint;
|
|
68971
69130
|
this.mintDecimals = mintDecimals;
|
|
@@ -68992,8 +69151,10 @@ var Bank = class _Bank {
|
|
|
68992
69151
|
this.emissionsRate = emissionsRate;
|
|
68993
69152
|
this.emissionsMint = emissionsMint;
|
|
68994
69153
|
this.emissionsRemaining = emissionsRemaining;
|
|
69154
|
+
this.collectedProgramFeesOutstanding = collectedProgramFeesOutstanding;
|
|
68995
69155
|
this.oracleKey = oracleKey;
|
|
68996
69156
|
this.emode = emode;
|
|
69157
|
+
this.rateLimiter = rateLimiter;
|
|
68997
69158
|
this.kaminoIntegrationAccounts = kaminoIntegrationAccounts;
|
|
68998
69159
|
this.driftIntegrationAccounts = driftIntegrationAccounts;
|
|
68999
69160
|
this.solendIntegrationAccounts = solendIntegrationAccounts;
|
|
@@ -69061,8 +69222,10 @@ var Bank = class _Bank {
|
|
|
69061
69222
|
bankType.emissionsRate,
|
|
69062
69223
|
bankType.emissionsMint,
|
|
69063
69224
|
bankType.emissionsRemaining,
|
|
69225
|
+
bankType.collectedProgramFeesOutstanding,
|
|
69064
69226
|
bankType.oracleKey,
|
|
69065
69227
|
bankType.emode,
|
|
69228
|
+
bankType.rateLimiter,
|
|
69066
69229
|
bankType.kaminoIntegrationAccounts,
|
|
69067
69230
|
bankType.driftIntegrationAccounts,
|
|
69068
69231
|
bankType.solendIntegrationAccounts,
|
|
@@ -69102,8 +69265,10 @@ var Bank = class _Bank {
|
|
|
69102
69265
|
props.emissionsRate,
|
|
69103
69266
|
props.emissionsMint,
|
|
69104
69267
|
props.emissionsRemaining,
|
|
69268
|
+
props.collectedProgramFeesOutstanding,
|
|
69105
69269
|
props.oracleKey,
|
|
69106
69270
|
props.emode,
|
|
69271
|
+
props.rateLimiter,
|
|
69107
69272
|
props.kaminoIntegrationAccounts,
|
|
69108
69273
|
props.driftIntegrationAccounts,
|
|
69109
69274
|
props.solendIntegrationAccounts,
|
|
@@ -70170,6 +70335,69 @@ var Project0Client = class _Project0Client {
|
|
|
70170
70335
|
async getAccountAddresses(authority) {
|
|
70171
70336
|
return fetchMarginfiAccountAddresses(this.program, authority, this.group.address);
|
|
70172
70337
|
}
|
|
70338
|
+
/**
|
|
70339
|
+
* Fetches the addresses of all marginfi accounts in the group that hold a position in a
|
|
70340
|
+
* specific bank.
|
|
70341
|
+
*
|
|
70342
|
+
* Because a marginfi account holds up to 16 balance slots (sorted descending by bank, so the
|
|
70343
|
+
* target can be at any slot), this scans all 16 slots in parallel via filtered
|
|
70344
|
+
* `getProgramAccounts` calls. It returns only addresses (no account data is transferred),
|
|
70345
|
+
* which keeps it viable across the group's ~500k accounts. Hydrate any address you care about
|
|
70346
|
+
* with `fetchAccount`.
|
|
70347
|
+
*
|
|
70348
|
+
* @param bank - The bank public key to search for in account balances
|
|
70349
|
+
* @param options - Optional settings:
|
|
70350
|
+
* - `concurrency`: max number of the 16 slot scans to run at once. Omit to fire all 16 in
|
|
70351
|
+
* parallel; pass a smaller value (e.g. 4) to batch them and avoid RPC rate limits.
|
|
70352
|
+
* @returns Deduplicated array of account addresses holding the bank
|
|
70353
|
+
*/
|
|
70354
|
+
async getAccountAddressesHoldingBank(bank, options) {
|
|
70355
|
+
return fetchMarginfiAccountAddressesHoldingBank(
|
|
70356
|
+
this.program,
|
|
70357
|
+
this.group.address,
|
|
70358
|
+
bank,
|
|
70359
|
+
options
|
|
70360
|
+
);
|
|
70361
|
+
}
|
|
70362
|
+
/**
|
|
70363
|
+
* Fetches every account's active balance for a given mint, with its authority, account
|
|
70364
|
+
* address, and the deposited/borrowed amounts in UI units.
|
|
70365
|
+
*
|
|
70366
|
+
* A mint can map to multiple banks (e.g. DEFAULT + Kamino), so this resolves all matching
|
|
70367
|
+
* banks via {@link getBanksByMint}, scans each for accounts holding it, and emits one row per
|
|
70368
|
+
* (account, bank). An account that holds the mint in several banks yields several rows.
|
|
70369
|
+
*
|
|
70370
|
+
* Amounts are computed with each bank's share multiplier (`assetShareValueMultiplierByBank`)
|
|
70371
|
+
* and the bank's mint decimals, matching `Balance.computeQuantityUi`.
|
|
70372
|
+
*
|
|
70373
|
+
* @param mint - The mint to search account balances for
|
|
70374
|
+
* @param options - Optional settings:
|
|
70375
|
+
* - `assetTag`: restrict to banks with this asset tag (e.g. only Kamino banks for the mint)
|
|
70376
|
+
* - `concurrency`: max number of the 16 slot scans to run at once per bank (see
|
|
70377
|
+
* {@link getAccountAddressesHoldingBank})
|
|
70378
|
+
* @returns One row per (account, bank) holding the mint
|
|
70379
|
+
*/
|
|
70380
|
+
async getAuthorityBalancesForMint(mint, options) {
|
|
70381
|
+
const banks = this.getBanksByMint(mint, options?.assetTag);
|
|
70382
|
+
const rows = [];
|
|
70383
|
+
for (const bank of banks) {
|
|
70384
|
+
const multiplier = this.assetShareValueMultiplierByBank.get(bank.address.toBase58());
|
|
70385
|
+
const balances = await fetchMarginfiAccountActiveBalancesForBank(
|
|
70386
|
+
this.program,
|
|
70387
|
+
this.group.address,
|
|
70388
|
+
bank.address,
|
|
70389
|
+
{ concurrency: options?.concurrency }
|
|
70390
|
+
);
|
|
70391
|
+
for (const { accountAddress, authority, balance } of balances) {
|
|
70392
|
+
const { assets, liabilities } = Balance.fromBalanceType(balance).computeQuantityUi(
|
|
70393
|
+
bank,
|
|
70394
|
+
multiplier
|
|
70395
|
+
);
|
|
70396
|
+
rows.push({ authority, accountAddress, bank: bank.address, assets, liabilities });
|
|
70397
|
+
}
|
|
70398
|
+
}
|
|
70399
|
+
return rows;
|
|
70400
|
+
}
|
|
70173
70401
|
/**
|
|
70174
70402
|
* Fetches and wraps a marginfi account in one call.
|
|
70175
70403
|
*
|
|
@@ -70459,6 +70687,7 @@ exports.bankConfigRawToDto = bankConfigRawToDto;
|
|
|
70459
70687
|
exports.bankConfigToBankConfigRaw = bankConfigToBankConfigRaw;
|
|
70460
70688
|
exports.bankMetadataMapToDto = bankMetadataMapToDto;
|
|
70461
70689
|
exports.bankMetadataToDto = bankMetadataToDto;
|
|
70690
|
+
exports.bankRateLimiterRawToDto = bankRateLimiterRawToDto;
|
|
70462
70691
|
exports.bankRawToDto = bankRawToDto;
|
|
70463
70692
|
exports.bigNumberToWrappedI80F48 = bigNumberToWrappedI80F48;
|
|
70464
70693
|
exports.bpsToPercentile = bpsToPercentile;
|
|
@@ -70554,6 +70783,8 @@ exports.dtoToBankConfig = dtoToBankConfig;
|
|
|
70554
70783
|
exports.dtoToBankConfigRaw = dtoToBankConfigRaw;
|
|
70555
70784
|
exports.dtoToBankMetadata = dtoToBankMetadata;
|
|
70556
70785
|
exports.dtoToBankMetadataMap = dtoToBankMetadataMap;
|
|
70786
|
+
exports.dtoToBankRateLimiter = dtoToBankRateLimiter;
|
|
70787
|
+
exports.dtoToBankRateLimiterRaw = dtoToBankRateLimiterRaw;
|
|
70557
70788
|
exports.dtoToBankRaw = dtoToBankRaw;
|
|
70558
70789
|
exports.dtoToEmodeSettings = dtoToEmodeSettings;
|
|
70559
70790
|
exports.dtoToEmodeSettingsRaw = dtoToEmodeSettingsRaw;
|
|
@@ -70567,7 +70798,9 @@ exports.emodeSettingsRawToDto = emodeSettingsRawToDto;
|
|
|
70567
70798
|
exports.extractPythOracleKeys = extractPythOracleKeys;
|
|
70568
70799
|
exports.fetchBank = fetchBank;
|
|
70569
70800
|
exports.fetchBankIntegrationMetadata = fetchBankIntegrationMetadata;
|
|
70801
|
+
exports.fetchMarginfiAccountActiveBalancesForBank = fetchMarginfiAccountActiveBalancesForBank;
|
|
70570
70802
|
exports.fetchMarginfiAccountAddresses = fetchMarginfiAccountAddresses;
|
|
70803
|
+
exports.fetchMarginfiAccountAddressesHoldingBank = fetchMarginfiAccountAddressesHoldingBank;
|
|
70571
70804
|
exports.fetchMarginfiAccountData = fetchMarginfiAccountData;
|
|
70572
70805
|
exports.fetchMultipleBanks = fetchMultipleBanks;
|
|
70573
70806
|
exports.fetchNativeStakeAccounts = fetchNativeStakeAccounts;
|
|
@@ -70717,6 +70950,7 @@ exports.nativeToUi = nativeToUi;
|
|
|
70717
70950
|
exports.oraclePriceToDto = oraclePriceToDto;
|
|
70718
70951
|
exports.parseBalanceRaw = parseBalanceRaw;
|
|
70719
70952
|
exports.parseBankConfigRaw = parseBankConfigRaw;
|
|
70953
|
+
exports.parseBankRateLimiterRaw = parseBankRateLimiterRaw;
|
|
70720
70954
|
exports.parseBankRaw = parseBankRaw;
|
|
70721
70955
|
exports.parseEmodeSettingsRaw = parseEmodeSettingsRaw;
|
|
70722
70956
|
exports.parseEmodeTag = parseEmodeTag;
|