@omnipair/dusk-sdk 2.27.0 → 3.0.1
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/README.md +92 -104
- package/dist/constants.d.ts +0 -6
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +0 -12
- package/dist/constants.js.map +1 -1
- package/dist/get.d.ts +97 -345
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +1 -2
- package/dist/get.js.map +1 -1
- package/dist/hlp-liquidation-client.d.ts.map +1 -1
- package/dist/hlp-liquidation-client.js +0 -1
- package/dist/hlp-liquidation-client.js.map +1 -1
- package/dist/idl_delegate.json +82 -390
- package/dist/idl_v2.json +226 -1098
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/indexer.d.ts +1 -1
- package/dist/indexer.d.ts.map +1 -1
- package/dist/interest-accounting.d.ts +82 -47
- package/dist/interest-accounting.d.ts.map +1 -1
- package/dist/interest-accounting.js +103 -53
- package/dist/interest-accounting.js.map +1 -1
- package/dist/leverage-preview.d.ts +24 -86
- package/dist/leverage-preview.d.ts.map +1 -1
- package/dist/liquidation-client.js +2 -2
- package/dist/liquidation-client.js.map +1 -1
- package/dist/operator-client.d.ts.map +1 -1
- package/dist/operator-client.js +8 -9
- package/dist/operator-client.js.map +1 -1
- package/dist/referral.d.ts +6 -3
- package/dist/referral.d.ts.map +1 -1
- package/dist/referral.js +8 -7
- package/dist/referral.js.map +1 -1
- package/dist/tranche-client.d.ts +0 -56
- package/dist/tranche-client.d.ts.map +1 -1
- package/dist/tranche-client.js +2 -103
- package/dist/tranche-client.js.map +1 -1
- package/dist/transfer-fees.d.ts +6 -0
- package/dist/transfer-fees.d.ts.map +1 -1
- package/dist/transfer-fees.js +19 -0
- package/dist/transfer-fees.js.map +1 -1
- package/dist/type-aliases.d.ts +3 -15
- package/dist/type-aliases.d.ts.map +1 -1
- package/dist/types_delegate.d.ts +82 -390
- package/dist/types_delegate.d.ts.map +1 -1
- package/dist/types_v2.d.ts +227 -1099
- package/dist/types_v2.d.ts.map +1 -1
- package/dist/virtual-book/market.d.ts +24 -86
- package/dist/virtual-book/market.d.ts.map +1 -1
- package/dist/virtual-book/quotes.d.ts +61 -173
- package/dist/virtual-book/quotes.d.ts.map +1 -1
- package/dist/virtual-book/quotes.js +55 -6
- package/dist/virtual-book/quotes.js.map +1 -1
- package/dist/write.d.ts +1 -3
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +7 -24
- package/dist/write.js.map +1 -1
- package/dist/yield-client.d.ts +7 -20
- package/dist/yield-client.d.ts.map +1 -1
- package/dist/yield-client.js +6 -37
- package/dist/yield-client.js.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +0 -25
- package/src/get.ts +0 -3
- package/src/hlp-liquidation-client.ts +0 -1
- package/src/idl_delegate.json +82 -390
- package/src/idl_v2.json +226 -1098
- package/src/index.ts +0 -1
- package/src/indexer.ts +1 -1
- package/src/interest-accounting.ts +149 -71
- package/src/liquidation-client.ts +2 -2
- package/src/operator-client.ts +8 -9
- package/src/referral.ts +9 -14
- package/src/tranche-client.ts +3 -106
- package/src/transfer-fees.ts +18 -0
- package/src/type-aliases.ts +3 -15
- package/src/types_delegate.ts +82 -390
- package/src/types_v2.ts +226 -1098
- package/src/virtual-book/quotes.ts +70 -6
- package/src/write.ts +8 -36
- package/src/yield-client.ts +9 -48
- package/dist/income-receivable.d.ts +0 -77
- package/dist/income-receivable.d.ts.map +0 -1
- package/dist/income-receivable.js +0 -135
- package/dist/income-receivable.js.map +0 -1
- package/src/income-receivable.ts +0 -145
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DuskWrite } from "../write.js";
|
|
2
2
|
import { oracleReadAccounts, encodeOraclePolicy } from "../oracle.js";
|
|
3
3
|
import { DEFAULT_READONLY_PUBLIC_KEY } from "../address.js";
|
|
4
|
+
import { LAUNCH_FEE_DECAY_DISABLED, LAUNCH_RATE_LIMIT_ASSET_DISABLED } from "../parameters.js";
|
|
4
5
|
import * as anchor from "@coral-xyz/anchor";
|
|
5
6
|
import type { Program } from "@coral-xyz/anchor";
|
|
6
7
|
const BN: typeof anchor.BN = Reflect.get(anchor, "BN") ?? Reflect.get(anchor, "default")?.BN;
|
|
@@ -43,6 +44,11 @@ export type DuskVirtualBookQuotes = DuskVirtualBookSnapshot & {
|
|
|
43
44
|
const CLOCK_OWNER = "Sysvar1111111111111111111111111111111111111";
|
|
44
45
|
const BATCH_SIZE = 4;
|
|
45
46
|
const U64_MAX = (1n << 64n) - 1n;
|
|
47
|
+
const NAD = 1_000_000_000n;
|
|
48
|
+
/** Matches the stream clients' first-to-last quote slot limit. */
|
|
49
|
+
const MAX_CLOCK_SPREAD_SLOTS = 8;
|
|
50
|
+
/** One part per million: 0.01 bps, a five-hundredth of the finest grouping. */
|
|
51
|
+
const MAX_CLOCK_DRIFT_NAD = 1_000n;
|
|
46
52
|
const raw = (value: { toString(): string }) => {
|
|
47
53
|
const amount = BigInt(value.toString());
|
|
48
54
|
if (amount < 0n || amount > U64_MAX) throw new Error("Invalid depth amount");
|
|
@@ -164,10 +170,13 @@ export function decodeDuskVirtualBookBatch(
|
|
|
164
170
|
quotes,
|
|
165
171
|
slot,
|
|
166
172
|
epoch,
|
|
167
|
-
|
|
168
|
-
//
|
|
169
|
-
//
|
|
173
|
+
unixTimestamp: clock.data.readBigInt64LE(32),
|
|
174
|
+
// Every source account except Clock: market, mints, authority and oracle
|
|
175
|
+
// feeds. Equal bytes mean no transaction touched any quote input between
|
|
176
|
+
// batches. The Clock is compared on its own in combineVirtualBookBatches,
|
|
177
|
+
// because parallel simulations reach confirmed banks a few slots apart.
|
|
170
178
|
state: infos
|
|
179
|
+
.filter((_, index) => index !== 4)
|
|
171
180
|
.map((info) => `${info.owner}:${info.data.toString("base64")}`)
|
|
172
181
|
.join("|"),
|
|
173
182
|
};
|
|
@@ -271,7 +280,17 @@ export async function previewVirtualBookQuotes(
|
|
|
271
280
|
return combineVirtualBookBatches(snapshot, groupingBps, curve.mid, results);
|
|
272
281
|
}
|
|
273
282
|
|
|
274
|
-
/** Refuse to combine observations across trades, fee changes, epochs or stale banks.
|
|
283
|
+
/** Refuse to combine observations across trades, fee changes, epochs or stale banks.
|
|
284
|
+
*
|
|
285
|
+
* Batches may come from confirmed banks up to eight slots apart when no
|
|
286
|
+
* transaction touched their inputs. Within one epoch, a swap preview reads the
|
|
287
|
+
* Clock for interest, EMA and volatility decay (at a fixed 200 ms per slot,
|
|
288
|
+
* half-lives of at least one minute), the concentration ramp, recentring gates
|
|
289
|
+
* and the Unix-timestamp launch fees. Combining then requires everything a
|
|
290
|
+
* Clock change could move to agree: no active ramp, launch windows over unless
|
|
291
|
+
* the timestamps match, one centre, and start prices and volatility surcharges
|
|
292
|
+
* within one part per million.
|
|
293
|
+
*/
|
|
275
294
|
export function combineVirtualBookBatches(
|
|
276
295
|
snapshot: DuskVirtualBookSnapshot,
|
|
277
296
|
groupingBps: number,
|
|
@@ -284,16 +303,61 @@ export function combineVirtualBookBatches(
|
|
|
284
303
|
? Math.min(...results.map((result) => result.slot))
|
|
285
304
|
: snapshot.slot;
|
|
286
305
|
if (
|
|
287
|
-
lastSlot - firstQuoteSlot >
|
|
306
|
+
lastSlot - firstQuoteSlot > MAX_CLOCK_SPREAD_SLOTS ||
|
|
288
307
|
results.some(
|
|
289
308
|
(result) =>
|
|
290
309
|
result.slot < snapshot.slot || result.state !== first.state || result.epoch !== first.epoch
|
|
291
310
|
)
|
|
292
311
|
)
|
|
293
312
|
throw new Error("Market depth changed during native previews");
|
|
313
|
+
if (
|
|
314
|
+
results.some(
|
|
315
|
+
(result) => result.slot !== first.slot || result.unixTimestamp !== first.unixTimestamp
|
|
316
|
+
)
|
|
317
|
+
) {
|
|
318
|
+
// A ramp applies a new curve candidate each slot. Launch fees and the launch
|
|
319
|
+
// size limit step with whole Unix seconds until their windows end.
|
|
320
|
+
const { amm, config } = first.market;
|
|
321
|
+
const fees = config.amm;
|
|
322
|
+
const feeWindow =
|
|
323
|
+
fees.launchFeeDecayMode !== LAUNCH_FEE_DECAY_DISABLED || fees.launchMarketPriceStepBps > 0
|
|
324
|
+
? BigInt(fees.launchFeeDurationSeconds.toString())
|
|
325
|
+
: 0n;
|
|
326
|
+
const limitWindow =
|
|
327
|
+
fees.launchRateLimitAsset !== LAUNCH_RATE_LIMIT_ASSET_DISABLED
|
|
328
|
+
? BigInt(fees.launchRateLimitDurationSeconds.toString())
|
|
329
|
+
: 0n;
|
|
330
|
+
const launchEnd =
|
|
331
|
+
BigInt(config.startTime.toString()) + (feeWindow > limitWindow ? feeWindow : limitWindow);
|
|
332
|
+
if (
|
|
333
|
+
amm.concentrationRamp.active ||
|
|
334
|
+
(results.some((result) => result.unixTimestamp !== first.unixTimestamp) &&
|
|
335
|
+
results.some((result) => result.unixTimestamp < launchEnd))
|
|
336
|
+
)
|
|
337
|
+
throw new Error("Market depth changed during native previews");
|
|
338
|
+
}
|
|
294
339
|
const allQuotes = results.flatMap((result) => result.quotes);
|
|
295
340
|
const start = allQuotes[0]?.preview.startPriceNad.toString();
|
|
296
|
-
|
|
341
|
+
const center = allQuotes[0]?.preview.centerPriceNad.toString();
|
|
342
|
+
const bounds = (values: bigint[]) => [
|
|
343
|
+
values.reduce((a, b) => (a < b ? a : b), values[0] ?? 0n),
|
|
344
|
+
values.reduce((a, b) => (a > b ? a : b), 0n),
|
|
345
|
+
];
|
|
346
|
+
const [lowStart, highStart] = bounds(allQuotes.map((quote) => raw(quote.preview.startPriceNad)));
|
|
347
|
+
const [lowVolatility, highVolatility] = bounds(
|
|
348
|
+
allQuotes.map((quote) => raw(quote.preview.decayedVolatilityNad))
|
|
349
|
+
);
|
|
350
|
+
const [, volatilityRate] = bounds(
|
|
351
|
+
allQuotes.map((quote) => raw(quote.preview.volatilityFeeRateNad))
|
|
352
|
+
);
|
|
353
|
+
// Interest accrual moves the reserves, and with them the start price, by
|
|
354
|
+
// the elapsed slots. The volatility surcharge rate scales at most linearly
|
|
355
|
+
// with decayed volatility. Both stay within one part per million.
|
|
356
|
+
if (
|
|
357
|
+
allQuotes.some((quote) => quote.preview.centerPriceNad.toString() !== center) ||
|
|
358
|
+
(highStart - lowStart) * NAD > MAX_CLOCK_DRIFT_NAD * lowStart ||
|
|
359
|
+
volatilityRate * (highVolatility - lowVolatility) > MAX_CLOCK_DRIFT_NAD * highVolatility
|
|
360
|
+
)
|
|
297
361
|
throw new Error("Market depth price changed during native previews");
|
|
298
362
|
return {
|
|
299
363
|
...snapshot,
|
package/src/write.ts
CHANGED
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
deriveLeveragePositionAddress,
|
|
42
42
|
deriveMarketAddress,
|
|
43
43
|
deriveMarketCollateralVaultAddress,
|
|
44
|
-
deriveMarketInterestVaultAddress,
|
|
45
44
|
deriveMarketReserveVaultAddress,
|
|
46
45
|
deriveTokenMetadataAddress,
|
|
47
46
|
TOKEN_METADATA_PROGRAM_ID,
|
|
@@ -420,8 +419,6 @@ export class DuskWrite {
|
|
|
420
419
|
const market = address(marketAddress);
|
|
421
420
|
const state = (marketSnapshot ?? await this.fetchMarketAccount(market)) as {
|
|
422
421
|
srlpMint: AccountMeta["pubkey"];
|
|
423
|
-
baseSide: { interestVault: AccountMeta["pubkey"]; assetMint: AccountMeta["pubkey"]; reserveVault: AccountMeta["pubkey"] };
|
|
424
|
-
quoteSide: { interestVault: AccountMeta["pubkey"]; assetMint: AccountMeta["pubkey"]; reserveVault: AccountMeta["pubkey"] };
|
|
425
422
|
baseHlpVault: {
|
|
426
423
|
hlpSupply: { toString(): string };
|
|
427
424
|
residualExposure: { toString(): string };
|
|
@@ -439,18 +436,13 @@ export class DuskWrite {
|
|
|
439
436
|
BigInt(state.baseHlpVault.residualExposure.toString()) !== 0n ||
|
|
440
437
|
BigInt(state.quoteHlpVault.residualExposure.toString()) !== 0n;
|
|
441
438
|
if (!hlpActive && !required) return [];
|
|
439
|
+
// Exactly the program's three-account prefix (`HLP_SWAP_ACCOUNT_PREFIX_LEN`).
|
|
440
|
+
// The program reads every account after it as a callback or transfer-hook
|
|
441
|
+
// account, so anything more here would shift them.
|
|
442
442
|
return [
|
|
443
443
|
{ pubkey: state.srlpMint, isSigner: false, isWritable: true },
|
|
444
444
|
{ pubkey: state.baseHlpVault.srlpVault, isSigner: false, isWritable: true },
|
|
445
445
|
{ pubkey: state.quoteHlpVault.srlpVault, isSigner: false, isWritable: true },
|
|
446
|
-
{ pubkey: state.baseSide.interestVault, isSigner: false, isWritable: true },
|
|
447
|
-
{ pubkey: state.quoteSide.interestVault, isSigner: false, isWritable: true },
|
|
448
|
-
// Fresh public-interest settlements rebalance both vaults. These keys
|
|
449
|
-
// usually duplicate fixed swap accounts; repayments need them explicitly.
|
|
450
|
-
{ pubkey: state.baseSide.assetMint, isSigner: false, isWritable: false },
|
|
451
|
-
{ pubkey: state.quoteSide.assetMint, isSigner: false, isWritable: false },
|
|
452
|
-
{ pubkey: state.baseSide.reserveVault, isSigner: false, isWritable: true },
|
|
453
|
-
{ pubkey: state.quoteSide.reserveVault, isSigner: false, isWritable: true },
|
|
454
446
|
];
|
|
455
447
|
}
|
|
456
448
|
|
|
@@ -470,8 +462,6 @@ export class DuskWrite {
|
|
|
470
462
|
const market = address(options.market);
|
|
471
463
|
const state = (await this.fetchMarketAccount(market)) as {
|
|
472
464
|
srlpMint: AccountMeta["pubkey"];
|
|
473
|
-
baseSide: { interestVault: AccountMeta["pubkey"] };
|
|
474
|
-
quoteSide: { interestVault: AccountMeta["pubkey"] };
|
|
475
465
|
baseHlpVault: {
|
|
476
466
|
hlpSupply: { toString(): string };
|
|
477
467
|
residualExposure: { toString(): string };
|
|
@@ -493,8 +483,6 @@ export class DuskWrite {
|
|
|
493
483
|
{ pubkey: state.srlpMint, isSigner: false, isWritable: true },
|
|
494
484
|
{ pubkey: state.baseHlpVault.srlpVault, isSigner: false, isWritable: true },
|
|
495
485
|
{ pubkey: state.quoteHlpVault.srlpVault, isSigner: false, isWritable: true },
|
|
496
|
-
{ pubkey: state.baseSide.interestVault, isSigner: false, isWritable: true },
|
|
497
|
-
{ pubkey: state.quoteSide.interestVault, isSigner: false, isWritable: true },
|
|
498
486
|
]
|
|
499
487
|
: [];
|
|
500
488
|
|
|
@@ -1047,8 +1035,6 @@ export class DuskWrite {
|
|
|
1047
1035
|
quoteReserveVault: deriveMarketReserveVaultAddress(market, quoteMint, programId)[0],
|
|
1048
1036
|
baseCollateralVault: deriveMarketCollateralVaultAddress(market, baseMint, programId)[0],
|
|
1049
1037
|
quoteCollateralVault: deriveMarketCollateralVaultAddress(market, quoteMint, programId)[0],
|
|
1050
|
-
baseInterestVault: deriveMarketInterestVaultAddress(market, baseMint, programId)[0],
|
|
1051
|
-
quoteInterestVault: deriveMarketInterestVaultAddress(market, quoteMint, programId)[0],
|
|
1052
1038
|
teamTreasury: address(params.teamTreasury),
|
|
1053
1039
|
teamTreasuryWsolAccount: address(params.teamTreasuryWsolAccount),
|
|
1054
1040
|
systemProgram: SystemProgram.programId,
|
|
@@ -1428,7 +1414,7 @@ export class DuskWrite {
|
|
|
1428
1414
|
authority: AddressLike;
|
|
1429
1415
|
market: AddressLike;
|
|
1430
1416
|
mint: AddressLike;
|
|
1431
|
-
|
|
1417
|
+
reserveVault?: AddressLike;
|
|
1432
1418
|
recipientTokenAccount: AddressLike;
|
|
1433
1419
|
remainingAccounts?: AccountMeta[];
|
|
1434
1420
|
}): Promise<TransactionInstruction> {
|
|
@@ -1441,8 +1427,8 @@ export class DuskWrite {
|
|
|
1441
1427
|
assetMint: mintKey,
|
|
1442
1428
|
programId: this.program.programId,
|
|
1443
1429
|
});
|
|
1444
|
-
const
|
|
1445
|
-
params.
|
|
1430
|
+
const reserveVault = address(
|
|
1431
|
+
params.reserveVault ?? deriveMarketReserveVaultAddress(market, mintKey, this.program.programId)[0]
|
|
1446
1432
|
);
|
|
1447
1433
|
const recipientTokenAccount = address(params.recipientTokenAccount);
|
|
1448
1434
|
const tokenProgram = await tokenProgramForMint(
|
|
@@ -1469,7 +1455,7 @@ export class DuskWrite {
|
|
|
1469
1455
|
this.program.provider.connection,
|
|
1470
1456
|
[
|
|
1471
1457
|
{
|
|
1472
|
-
source:
|
|
1458
|
+
source: reserveVault,
|
|
1473
1459
|
mint: mintKey,
|
|
1474
1460
|
destination: recipientTokenAccount,
|
|
1475
1461
|
authority: market,
|
|
@@ -1486,7 +1472,7 @@ export class DuskWrite {
|
|
|
1486
1472
|
referralPartner: referral.referralPartner,
|
|
1487
1473
|
assetMint: mintKey,
|
|
1488
1474
|
referralAccrual: referral.referralAccrual,
|
|
1489
|
-
|
|
1475
|
+
reserveVault,
|
|
1490
1476
|
recipientTokenAccount,
|
|
1491
1477
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
1492
1478
|
token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
@@ -1676,10 +1662,6 @@ export class DuskWrite {
|
|
|
1676
1662
|
params.reserveVault ??
|
|
1677
1663
|
deriveMarketReserveVaultAddress(market, debtAssetMint, programId)[0]
|
|
1678
1664
|
),
|
|
1679
|
-
interestVault: address(
|
|
1680
|
-
params.interestVault ??
|
|
1681
|
-
deriveMarketInterestVaultAddress(market, debtAssetMint, programId)[0]
|
|
1682
|
-
),
|
|
1683
1665
|
ownerDebtAccount: address(params.ownerDebtAccount),
|
|
1684
1666
|
borrowPosition: address(
|
|
1685
1667
|
params.borrowPosition ??
|
|
@@ -1867,7 +1849,6 @@ export class DuskWrite {
|
|
|
1867
1849
|
collateralMint: core.collateralMint,
|
|
1868
1850
|
debtReserveVault: core.debtReserveVault,
|
|
1869
1851
|
collateralReserveVault: core.collateralReserveVault,
|
|
1870
|
-
debtInterestVault: core.debtInterestVault,
|
|
1871
1852
|
ownerDebtAccount: address(params.ownerDebtAccount),
|
|
1872
1853
|
leverageCollateralVault: core.leverageCollateralVault,
|
|
1873
1854
|
referralPartner: core.referralPartner,
|
|
@@ -1920,7 +1901,6 @@ export class DuskWrite {
|
|
|
1920
1901
|
debtMint: core.debtMint,
|
|
1921
1902
|
collateralMint: core.collateralMint,
|
|
1922
1903
|
debtReserveVault: core.debtReserveVault,
|
|
1923
|
-
debtInterestVault: core.debtInterestVault,
|
|
1924
1904
|
ownerDebtAccount: address(params.ownerDebtAccount),
|
|
1925
1905
|
referralPartner: core.referralPartner,
|
|
1926
1906
|
referralAccrual: core.referralAccrual,
|
|
@@ -1973,7 +1953,6 @@ export class DuskWrite {
|
|
|
1973
1953
|
collateralMint: core.collateralMint,
|
|
1974
1954
|
debtReserveVault: core.debtReserveVault,
|
|
1975
1955
|
collateralReserveVault: core.collateralReserveVault,
|
|
1976
|
-
debtInterestVault: core.debtInterestVault,
|
|
1977
1956
|
leverageCollateralVault: core.leverageCollateralVault,
|
|
1978
1957
|
ownerDebtAccount: address(params.ownerDebtAccount),
|
|
1979
1958
|
delegateFeeRecipient: params.delegateFeeRecipient
|
|
@@ -2042,10 +2021,6 @@ export class DuskWrite {
|
|
|
2042
2021
|
params.collateralReserveVault ??
|
|
2043
2022
|
deriveMarketReserveVaultAddress(market, collateralMint, programId)[0]
|
|
2044
2023
|
),
|
|
2045
|
-
debtInterestVault: address(
|
|
2046
|
-
params.debtInterestVault ??
|
|
2047
|
-
deriveMarketInterestVaultAddress(market, debtMint, programId)[0]
|
|
2048
|
-
),
|
|
2049
2024
|
leverageCollateralVault: address(
|
|
2050
2025
|
params.leverageCollateralVault ??
|
|
2051
2026
|
deriveLeverageCollateralVaultAddress(market, collateralMint, programId)[0]
|
|
@@ -2146,7 +2121,6 @@ export interface RepayParams extends LendingPositionAccounts {
|
|
|
2146
2121
|
/** Omit when the position has no referrer. */
|
|
2147
2122
|
referralPartner?: AddressLike | null;
|
|
2148
2123
|
reserveVault?: AddressLike;
|
|
2149
|
-
interestVault?: AddressLike;
|
|
2150
2124
|
}
|
|
2151
2125
|
|
|
2152
2126
|
/** Which side of the pair carries the debt. */
|
|
@@ -2174,7 +2148,6 @@ interface LeverageAccounts {
|
|
|
2174
2148
|
leveragePosition?: AddressLike;
|
|
2175
2149
|
debtReserveVault?: AddressLike;
|
|
2176
2150
|
collateralReserveVault?: AddressLike;
|
|
2177
|
-
debtInterestVault?: AddressLike;
|
|
2178
2151
|
leverageCollateralVault?: AddressLike;
|
|
2179
2152
|
referralPartner?: AddressLike | null;
|
|
2180
2153
|
remainingAccounts?: AccountMeta[];
|
|
@@ -2467,7 +2440,6 @@ const ORACLE_READ_INSTRUCTIONS = new Set<string>([
|
|
|
2467
2440
|
"addLiquidity",
|
|
2468
2441
|
"openLiquidityGates",
|
|
2469
2442
|
"removeLiquidity",
|
|
2470
|
-
"fundInterest",
|
|
2471
2443
|
"compoundJuniorSeed",
|
|
2472
2444
|
"harvest",
|
|
2473
2445
|
"swap",
|
package/src/yield-client.ts
CHANGED
|
@@ -2,40 +2,31 @@ import type { Program } from "@coral-xyz/anchor";
|
|
|
2
2
|
import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
3
3
|
import { ComputeBudgetProgram, Transaction, type AccountMeta, type TransactionInstruction } from "@solana/web3.js";
|
|
4
4
|
import { address, type AddressLike } from "./address.js";
|
|
5
|
-
import {
|
|
6
|
-
import { integerBN, type IntegerLike } from "./parameters.js";
|
|
5
|
+
import { deriveHlpCohortAddress, deriveJuniorCohortAddress, deriveYieldAccountAddress, yieldTokenKindArg } from "./constants.js";
|
|
7
6
|
import { DuskGet } from "./get.js";
|
|
8
|
-
import { previewReturnDataBytes } from "./preview.js";
|
|
9
7
|
import { tokenProgramForMint } from "./referral.js";
|
|
10
8
|
import type { Dusk as DuskIdl } from "./types_v2.js";
|
|
11
|
-
import type { FundInterestReceipt } from "./type-aliases.js";
|
|
12
9
|
import { DuskWrite } from "./write.js";
|
|
13
10
|
|
|
14
|
-
export interface
|
|
11
|
+
export interface HarvestYieldParams {
|
|
15
12
|
market: AddressLike;
|
|
13
|
+
/** The LP holder, its designated recipient, or its harvest authority. */
|
|
16
14
|
caller: AddressLike;
|
|
17
|
-
/** Gross debt-token atoms, including the protocol allocation. Defaults to available cash. */
|
|
18
|
-
maxBaseGross?: IntegerLike;
|
|
19
|
-
maxQuoteGross?: IntegerLike;
|
|
20
|
-
}
|
|
21
|
-
export type { FundInterestReceipt };
|
|
22
|
-
export interface HarvestYieldParams extends FundInterestParams {
|
|
23
15
|
owner: AddressLike;
|
|
24
16
|
kind: "srlp" | "junior" | "baseHlp" | "quoteHlp";
|
|
25
17
|
asset: "base" | "quote";
|
|
26
|
-
/** Set false to collect existing funded claims independently of new funding. */
|
|
27
|
-
fundAccruedInterest?: boolean;
|
|
28
18
|
/** Old hLP mint after terminal closure. Its yield indexes are frozen in its cohort PDA. */
|
|
29
19
|
retiredHlpMint?: AddressLike;
|
|
30
|
-
/** Wiped junior generation;
|
|
20
|
+
/** Wiped junior generation; interest credited before the wipe remains claimable. */
|
|
31
21
|
retiredJuniorMint?: AddressLike;
|
|
32
22
|
/** Extra accounts required by a Token-2022 asset transfer hook. */
|
|
33
23
|
transferHookAccounts?: readonly AccountMeta[];
|
|
34
24
|
}
|
|
35
25
|
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
26
|
+
/** Holder-specific harvesting. Builders never sign or submit. Interest is
|
|
27
|
+
* credited to holders when it accrues; a harvest pays swap fees in full and
|
|
28
|
+
* credited interest from reserve cash as it allows, leaving the rest
|
|
29
|
+
* claimable. Harvesting does not change swap reserves.
|
|
39
30
|
*/
|
|
40
31
|
export class DuskYield {
|
|
41
32
|
readonly write: DuskWrite;
|
|
@@ -45,35 +36,6 @@ export class DuskYield {
|
|
|
45
36
|
this.get = new DuskGet(program, feePayer);
|
|
46
37
|
}
|
|
47
38
|
|
|
48
|
-
async fundInstruction(params: FundInterestParams): Promise<TransactionInstruction> {
|
|
49
|
-
const market = address(params.market);
|
|
50
|
-
const s = await this.get.market(market);
|
|
51
|
-
return this.write.instruction("fundInterest", {
|
|
52
|
-
maxBaseGross: integerBN(params.maxBaseGross ?? 0xffffffffffffffffn, "maxBaseGross"),
|
|
53
|
-
maxQuoteGross: integerBN(params.maxQuoteGross ?? 0xffffffffffffffffn, "maxQuoteGross"),
|
|
54
|
-
}, { accounts: {
|
|
55
|
-
market, caller: address(params.caller), futarchyAuthority: deriveFutarchyAuthorityAddress(this.program.programId)[0],
|
|
56
|
-
baseMint: s.baseSide.assetMint, quoteMint: s.quoteSide.assetMint,
|
|
57
|
-
baseReserveVault: s.baseSide.reserveVault, quoteReserveVault: s.quoteSide.reserveVault,
|
|
58
|
-
baseInterestVault: s.baseSide.interestVault, quoteInterestVault: s.quoteSide.interestVault,
|
|
59
|
-
tokenProgram: TOKEN_PROGRAM_ID, token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
60
|
-
}, remainingAccounts: await this.write.hlpRemainingAccounts(market, s) });
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** Simulates actual funding, transfer fees and the joint hLP rebalance.
|
|
64
|
-
* This is a current-bank estimate, not a reservation of cash or yield.
|
|
65
|
-
*/
|
|
66
|
-
async previewFunding(params: FundInterestParams): Promise<FundInterestReceipt> {
|
|
67
|
-
const ix = await this.fundInstruction(params);
|
|
68
|
-
const simulation = await this.get.simulateWithContext([
|
|
69
|
-
ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 }),
|
|
70
|
-
ComputeBudgetProgram.requestHeapFrame({ bytes: 256 * 1024 }), ix,
|
|
71
|
-
]);
|
|
72
|
-
const data = simulation.value.returnData;
|
|
73
|
-
if (!data || data.programId !== this.program.programId.toBase58()) throw new Error("Missing Dusk funding return data");
|
|
74
|
-
return this.program.coder.types.decode("fundInterestReceipt", previewReturnDataBytes(data)) as FundInterestReceipt;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
39
|
async buildHarvest(params: HarvestYieldParams) {
|
|
78
40
|
if (!["srlp", "junior", "baseHlp", "quoteHlp"].includes(params.kind)) throw new Error("Invalid yield token kind");
|
|
79
41
|
if (params.asset !== "base" && params.asset !== "quote") throw new Error("Invalid yield asset");
|
|
@@ -96,11 +58,10 @@ export class DuskYield {
|
|
|
96
58
|
ComputeBudgetProgram.requestHeapFrame({ bytes: 256 * 1024 }),
|
|
97
59
|
createAssociatedTokenAccountIdempotentInstruction(caller, recipientAssetAccount, claim.recipient, side.assetMint, tokenProgram),
|
|
98
60
|
];
|
|
99
|
-
if (params.fundAccruedInterest !== false) instructions.push(await this.fundInstruction(params));
|
|
100
61
|
instructions.push(await this.write.instruction("harvest", { tokenKind: yieldTokenKindArg(kind) }, { accounts: {
|
|
101
62
|
market, owner, caller, assetMint: side.assetMint, lpMint,
|
|
102
63
|
ownerLpAccount: getAssociatedTokenAddressSync(lpMint, owner, true, TOKEN_2022_PROGRAM_ID),
|
|
103
|
-
reserveVault: side.reserveVault,
|
|
64
|
+
reserveVault: side.reserveVault, recipientAssetAccount, yieldAccount,
|
|
104
65
|
tokenProgram: TOKEN_PROGRAM_ID, token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
105
66
|
}, remainingAccounts: [
|
|
106
67
|
...(params.retiredHlpMint
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { IntegerLike } from "./parameters.js";
|
|
2
|
-
import type { Dusk } from "./dusk.js";
|
|
3
|
-
import { type AddressLike } from "./address.js";
|
|
4
|
-
export interface IncomeGrowthInput {
|
|
5
|
-
unitsQ64: IntegerLike;
|
|
6
|
-
weightedPaidQ128: readonly IntegerLike[];
|
|
7
|
-
}
|
|
8
|
-
export interface IncomeClaimInput {
|
|
9
|
-
epoch: IntegerLike;
|
|
10
|
-
unitsQ64: IntegerLike;
|
|
11
|
-
paidCheckpointQ64: IntegerLike;
|
|
12
|
-
growthCheckpoint: IncomeGrowthInput;
|
|
13
|
-
paidFractionQ128: IntegerLike;
|
|
14
|
-
claimable: IntegerLike;
|
|
15
|
-
}
|
|
16
|
-
export interface IncomeBookInput {
|
|
17
|
-
epoch: IntegerLike;
|
|
18
|
-
unpaid: IntegerLike;
|
|
19
|
-
units: IntegerLike;
|
|
20
|
-
paidPerUnitQ64: IntegerLike;
|
|
21
|
-
growth: readonly IncomeGrowthInput[];
|
|
22
|
-
}
|
|
23
|
-
export interface IncomeEndInput {
|
|
24
|
-
ended: boolean;
|
|
25
|
-
epoch: IntegerLike;
|
|
26
|
-
growth: IncomeGrowthInput;
|
|
27
|
-
}
|
|
28
|
-
export interface IncomeHolderInput {
|
|
29
|
-
tokenKind: number;
|
|
30
|
-
incomeInitialized: boolean;
|
|
31
|
-
escrowBalance: IntegerLike;
|
|
32
|
-
income: readonly IncomeClaimInput[];
|
|
33
|
-
}
|
|
34
|
-
export interface IncomeClaimProjection {
|
|
35
|
-
epoch: bigint;
|
|
36
|
-
unitsQ64: bigint;
|
|
37
|
-
paidCheckpointQ64: bigint;
|
|
38
|
-
growthCheckpoint: IncomeGrowthInput;
|
|
39
|
-
paidFractionQ128: bigint;
|
|
40
|
-
claimable: bigint;
|
|
41
|
-
}
|
|
42
|
-
export type IncomeArchiveMap = ReadonlyMap<string, IncomeBookInput>;
|
|
43
|
-
/** Pure copy of IncomeReceivableClaim::checkpoint_exposure. Fractional cash
|
|
44
|
-
* stays at Q128 precision; newly issued units cannot earn prior payments. */
|
|
45
|
-
export declare function projectIncomeClaim(input: {
|
|
46
|
-
claim: IncomeClaimInput;
|
|
47
|
-
book: IncomeBookInput;
|
|
48
|
-
balance: IntegerLike;
|
|
49
|
-
lane: number;
|
|
50
|
-
end?: IncomeEndInput;
|
|
51
|
-
}): IncomeClaimProjection;
|
|
52
|
-
/** Archived denominations required by the selected asset's two income books. */
|
|
53
|
-
export declare function incomeArchiveRequests(holder: IncomeHolderInput, books: readonly IncomeBookInput[], asset: 0 | 1, maximumEpochs?: number): {
|
|
54
|
-
bookIndex: number;
|
|
55
|
-
epoch: bigint;
|
|
56
|
-
}[];
|
|
57
|
-
/** Additional funded interest Harvest materializes before ordinary growth.
|
|
58
|
-
* Historical units remain with their owner after transfers, exits and wipes. */
|
|
59
|
-
export declare function projectHolderIncome(input: {
|
|
60
|
-
holder: IncomeHolderInput;
|
|
61
|
-
books: readonly IncomeBookInput[];
|
|
62
|
-
asset: 0 | 1;
|
|
63
|
-
walletBalance: IntegerLike;
|
|
64
|
-
ends?: readonly IncomeEndInput[];
|
|
65
|
-
archives?: IncomeArchiveMap;
|
|
66
|
-
}): bigint;
|
|
67
|
-
/** Read only immutable, PDA-authenticated archives. Callers pass the bank
|
|
68
|
-
* floor that supplied the holder and current books; no observation is cached. */
|
|
69
|
-
export declare function readIncomeArchives(input: {
|
|
70
|
-
dusk: Dusk;
|
|
71
|
-
market: AddressLike;
|
|
72
|
-
holder: IncomeHolderInput;
|
|
73
|
-
books: readonly IncomeBookInput[];
|
|
74
|
-
asset: 0 | 1;
|
|
75
|
-
minContextSlot: number;
|
|
76
|
-
}): Promise<IncomeArchiveMap>;
|
|
77
|
-
//# sourceMappingURL=income-receivable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"income-receivable.d.ts","sourceRoot":"","sources":["../src/income-receivable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAczD,MAAM,WAAW,iBAAiB;IAAG,QAAQ,EAAE,WAAW,CAAC;IAAC,gBAAgB,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE;AACtG,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,WAAW,CAAC;IAAC,iBAAiB,EAAE,WAAW,CAAC;IAC1E,gBAAgB,EAAE,iBAAiB,CAAC;IAAC,gBAAgB,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,WAAW,CAAC;CAC5F;A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F,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,MAAM,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IAC3E,aAAa,EAAE,WAAW,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC;CAC3F,UA0BA;AAED;iFACiF;AACjF,wBAAsB,kBAAkB,CAAC,KAAK,EAAE;IAC9C,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9F,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;CACtC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAqB5B"}
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { address } from "./address.js";
|
|
2
|
-
import { deriveIncomeEpochAddress } from "./constants.js";
|
|
3
|
-
const U64 = (1n << 64n) - 1n;
|
|
4
|
-
const U128 = (1n << 128n) - 1n;
|
|
5
|
-
const U256 = (1n << 256n) - 1n;
|
|
6
|
-
const value = (input, max = U128) => {
|
|
7
|
-
if (typeof input === "number" && !Number.isSafeInteger(input))
|
|
8
|
-
throw new Error("Income value lost integer precision");
|
|
9
|
-
const text = String(input);
|
|
10
|
-
if (!/^(0|[1-9]\d*)$/.test(text))
|
|
11
|
-
throw new Error("Invalid income value");
|
|
12
|
-
const n = BigInt(text);
|
|
13
|
-
if (n > max)
|
|
14
|
-
throw new Error("Income value overflow");
|
|
15
|
-
return n;
|
|
16
|
-
};
|
|
17
|
-
function weighted(growth) {
|
|
18
|
-
if (growth.weightedPaidQ128.length !== 4)
|
|
19
|
-
throw new Error("Invalid weighted income index");
|
|
20
|
-
return growth.weightedPaidQ128.reduce((sum, limb, i) => sum + (value(limb, U64) << BigInt(i * 64)), 0n);
|
|
21
|
-
}
|
|
22
|
-
/** Pure copy of IncomeReceivableClaim::checkpoint_exposure. Fractional cash
|
|
23
|
-
* stays at Q128 precision; newly issued units cannot earn prior payments. */
|
|
24
|
-
export function projectIncomeClaim(input) {
|
|
25
|
-
const { claim, book, end } = input;
|
|
26
|
-
if (end && typeof end.ended !== "boolean")
|
|
27
|
-
throw new Error("Invalid income exposure end");
|
|
28
|
-
const epoch = value(book.epoch, U64);
|
|
29
|
-
if (value(claim.epoch, U64) !== epoch)
|
|
30
|
-
throw new Error("IncomeHistoryRequired");
|
|
31
|
-
if (!Number.isInteger(input.lane) || input.lane < 0 || input.lane > 3 || book.growth.length !== 4)
|
|
32
|
-
throw new Error("Invalid income lane");
|
|
33
|
-
const ended = end?.ended === true;
|
|
34
|
-
const endEpoch = ended ? value(end.epoch, U64) : 0n;
|
|
35
|
-
const growth = ended && epoch === endEpoch ? end.growth : book.growth[input.lane];
|
|
36
|
-
const balance = ended && epoch > endEpoch ? 0n : value(input.balance, U64);
|
|
37
|
-
const delta = value(growth.unitsQ64) - value(claim.growthCheckpoint.unitsQ64);
|
|
38
|
-
const weightedDelta = weighted(growth) - weighted(claim.growthCheckpoint);
|
|
39
|
-
const paid = value(book.paidPerUnitQ64);
|
|
40
|
-
const paidDelta = paid - value(claim.paidCheckpointQ64);
|
|
41
|
-
if (delta < 0n || weightedDelta < 0n || paidDelta < 0n)
|
|
42
|
-
throw new Error("Income index regressed");
|
|
43
|
-
const newCash = delta * paid - weightedDelta;
|
|
44
|
-
if (newCash < 0n)
|
|
45
|
-
throw new Error("Income weighted index exceeds payment");
|
|
46
|
-
const scaled = newCash * balance + value(claim.unitsQ64) * paidDelta + value(claim.paidFractionQ128);
|
|
47
|
-
if (scaled > U256)
|
|
48
|
-
throw new Error("Income value overflow");
|
|
49
|
-
const unitsQ64 = value(value(claim.unitsQ64) + balance * delta);
|
|
50
|
-
return { epoch, unitsQ64, paidCheckpointQ64: paid, growthCheckpoint: growth,
|
|
51
|
-
paidFractionQ128: scaled & U128, claimable: value(value(claim.claimable, U64) + (scaled >> 128n), U64) };
|
|
52
|
-
}
|
|
53
|
-
/** Archived denominations required by the selected asset's two income books. */
|
|
54
|
-
export function incomeArchiveRequests(holder, books, asset, maximumEpochs = 32) {
|
|
55
|
-
if (asset !== 0 && asset !== 1)
|
|
56
|
-
throw new Error("Invalid income asset");
|
|
57
|
-
if (!Number.isInteger(maximumEpochs) || maximumEpochs < 1 || maximumEpochs > 64)
|
|
58
|
-
throw new Error("Invalid income history bound");
|
|
59
|
-
if (!holder.incomeInitialized || holder.tokenKind === 1)
|
|
60
|
-
return [];
|
|
61
|
-
if (![0, 2].includes(holder.tokenKind) || holder.income.length !== 2 || books.length !== 4)
|
|
62
|
-
throw new Error("Invalid income holder");
|
|
63
|
-
const requests = [];
|
|
64
|
-
for (let source = 0; source < 2; source++) {
|
|
65
|
-
const bookIndex = asset + source * 2;
|
|
66
|
-
const first = value(holder.income[source].epoch, U64), current = value(books[bookIndex].epoch, U64);
|
|
67
|
-
if (first > current || current - first > BigInt(maximumEpochs))
|
|
68
|
-
throw new Error("IncomeHistoryRequired");
|
|
69
|
-
for (let epoch = first; epoch < current; epoch++)
|
|
70
|
-
requests.push({ bookIndex, epoch });
|
|
71
|
-
}
|
|
72
|
-
return requests;
|
|
73
|
-
}
|
|
74
|
-
/** Additional funded interest Harvest materializes before ordinary growth.
|
|
75
|
-
* Historical units remain with their owner after transfers, exits and wipes. */
|
|
76
|
-
export function projectHolderIncome(input) {
|
|
77
|
-
const { holder, books, asset } = input;
|
|
78
|
-
if (input.ends && input.ends.length !== 4)
|
|
79
|
-
throw new Error("Invalid income exposure ends");
|
|
80
|
-
incomeArchiveRequests(holder, books, asset);
|
|
81
|
-
if (holder.tokenKind === 1)
|
|
82
|
-
return 0n;
|
|
83
|
-
if (![0, 2].includes(holder.tokenKind) || holder.income.length !== 2 || books.length !== 4)
|
|
84
|
-
throw new Error("Invalid income holder");
|
|
85
|
-
const lane = holder.tokenKind === 2 ? 1 : 0;
|
|
86
|
-
const balance = holder.incomeInitialized ? value(value(input.walletBalance, U64) + value(holder.escrowBalance, U64), U64) : 0n;
|
|
87
|
-
let amount = 0n;
|
|
88
|
-
for (let source = 0; source < 2; source++) {
|
|
89
|
-
const bookIndex = asset + source * 2, book = books[bookIndex];
|
|
90
|
-
let claim = { ...holder.income[source], epoch: holder.incomeInitialized ? holder.income[source].epoch : book.epoch };
|
|
91
|
-
const end = lane === 1 ? input.ends?.[bookIndex] : undefined;
|
|
92
|
-
while (value(claim.epoch, U64) < value(book.epoch, U64)) {
|
|
93
|
-
const archived = input.archives?.get(`${bookIndex}:${claim.epoch}`);
|
|
94
|
-
if (!archived)
|
|
95
|
-
throw new Error("IncomeHistoryRequired");
|
|
96
|
-
const projected = projectIncomeClaim({ claim, book: archived, balance, lane, end });
|
|
97
|
-
const units = value(archived.units, U64), unpaid = value(archived.unpaid, U64);
|
|
98
|
-
if (units === 0n && unpaid !== 0n)
|
|
99
|
-
throw new Error("Invalid income book");
|
|
100
|
-
claim = { ...projected, epoch: projected.epoch + 1n, unitsQ64: units === 0n ? 0n : value(projected.unitsQ64 * unpaid / units),
|
|
101
|
-
paidCheckpointQ64: 0n, growthCheckpoint: { unitsQ64: 0n, weightedPaidQ128: [0n, 0n, 0n, 0n] } };
|
|
102
|
-
}
|
|
103
|
-
const projected = projectIncomeClaim({ claim, book, balance, lane, end });
|
|
104
|
-
amount = value(amount + projected.claimable, U64);
|
|
105
|
-
}
|
|
106
|
-
return amount;
|
|
107
|
-
}
|
|
108
|
-
/** Read only immutable, PDA-authenticated archives. Callers pass the bank
|
|
109
|
-
* floor that supplied the holder and current books; no observation is cached. */
|
|
110
|
-
export async function readIncomeArchives(input) {
|
|
111
|
-
if (!Number.isSafeInteger(input.minContextSlot) || input.minContextSlot < 0)
|
|
112
|
-
throw new Error("Invalid income archive bank floor");
|
|
113
|
-
const { dusk } = input, program = dusk.program.programId, market = address(input.market);
|
|
114
|
-
const requests = incomeArchiveRequests(input.holder, input.books, input.asset);
|
|
115
|
-
const result = new Map();
|
|
116
|
-
for (let offset = 0; offset < requests.length; offset += 100) {
|
|
117
|
-
const batch = requests.slice(offset, offset + 100).map(request => ({ ...request,
|
|
118
|
-
derived: deriveIncomeEpochAddress(market, request.bookIndex, request.epoch, program) }));
|
|
119
|
-
const read = await dusk.program.provider.connection.getMultipleAccountsInfoAndContext(batch.map(row => row.derived[0]), { commitment: "confirmed", minContextSlot: input.minContextSlot });
|
|
120
|
-
if (read.context.slot < input.minContextSlot || read.value.length !== batch.length)
|
|
121
|
-
throw new Error("Income archives are stale");
|
|
122
|
-
batch.forEach((request, index) => {
|
|
123
|
-
const account = read.value[index];
|
|
124
|
-
if (!account || account.executable || !account.owner.equals(program))
|
|
125
|
-
throw new Error("IncomeHistoryRequired");
|
|
126
|
-
const decoded = dusk.program.coder.accounts.decode("incomeEpoch", account.data);
|
|
127
|
-
if (!decoded.market.equals(market) || decoded.bookIndex !== request.bookIndex || decoded.bump !== request.derived[1] ||
|
|
128
|
-
String(decoded.book.epoch) !== request.epoch.toString())
|
|
129
|
-
throw new Error("Invalid income archive");
|
|
130
|
-
result.set(`${request.bookIndex}:${request.epoch}`, decoded.book);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=income-receivable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"income-receivable.js","sourceRoot":"","sources":["../src/income-receivable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAoB,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,GAAG,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;AAC7B,MAAM,IAAI,GAAG,CAAC,EAAE,IAAI,IAAI,CAAC,GA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