@omnipair/dusk-sdk 2.0.2 → 2.18.0-next.20261106
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 +863 -42
- package/dist/amounts.d.ts +9 -0
- package/dist/amounts.d.ts.map +1 -0
- package/dist/amounts.js +10 -0
- package/dist/amounts.js.map +1 -0
- package/dist/constants.d.ts +68 -27
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +153 -41
- package/dist/constants.js.map +1 -1
- package/dist/delegate.d.ts +97 -0
- package/dist/delegate.d.ts.map +1 -0
- package/dist/delegate.js +152 -0
- package/dist/delegate.js.map +1 -0
- package/dist/dusk.d.ts +14 -0
- package/dist/dusk.d.ts.map +1 -1
- package/dist/dusk.js +22 -0
- package/dist/dusk.js.map +1 -1
- package/dist/get.d.ts +3033 -385
- package/dist/get.d.ts.map +1 -1
- package/dist/get.js +109 -72
- package/dist/get.js.map +1 -1
- package/dist/hash.d.ts +9 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +16 -0
- package/dist/hash.js.map +1 -0
- package/dist/hlp-liquidation-client.d.ts +104 -0
- package/dist/hlp-liquidation-client.d.ts.map +1 -0
- package/dist/hlp-liquidation-client.js +146 -0
- package/dist/hlp-liquidation-client.js.map +1 -0
- package/dist/idl_delegate.d.ts +3 -0
- package/dist/idl_delegate.d.ts.map +1 -0
- package/dist/idl_delegate.js +3 -0
- package/dist/idl_delegate.js.map +1 -0
- package/dist/idl_delegate.json +6268 -0
- package/dist/idl_v2.json +16746 -6676
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/interest-accounting.d.ts +45 -0
- package/dist/interest-accounting.d.ts.map +1 -0
- package/dist/interest-accounting.js +59 -0
- package/dist/interest-accounting.js.map +1 -0
- package/dist/leverage-actions.d.ts +122 -0
- package/dist/leverage-actions.d.ts.map +1 -0
- package/dist/leverage-actions.js +228 -0
- package/dist/leverage-actions.js.map +1 -0
- package/dist/leverage-margins.d.ts +12 -0
- package/dist/leverage-margins.d.ts.map +1 -0
- package/dist/leverage-margins.js +45 -0
- package/dist/leverage-margins.js.map +1 -0
- package/dist/leverage-preview.d.ts +598 -0
- package/dist/leverage-preview.d.ts.map +1 -0
- package/dist/leverage-preview.js +89 -0
- package/dist/leverage-preview.js.map +1 -0
- package/dist/liquidation-client.d.ts +226 -0
- package/dist/liquidation-client.d.ts.map +1 -0
- package/dist/liquidation-client.js +237 -0
- package/dist/liquidation-client.js.map +1 -0
- package/dist/liquidation.d.ts +72 -0
- package/dist/liquidation.d.ts.map +1 -0
- package/dist/liquidation.js +104 -0
- package/dist/liquidation.js.map +1 -0
- package/dist/lp-naming.d.ts +43 -0
- package/dist/lp-naming.d.ts.map +1 -0
- package/dist/lp-naming.js +81 -0
- package/dist/lp-naming.js.map +1 -0
- package/dist/lp-vanity.d.ts +33 -0
- package/dist/lp-vanity.d.ts.map +1 -0
- package/dist/lp-vanity.js +94 -0
- package/dist/lp-vanity.js.map +1 -0
- package/dist/market-bootstrap.d.ts +109 -0
- package/dist/market-bootstrap.d.ts.map +1 -0
- package/dist/market-bootstrap.js +156 -0
- package/dist/market-bootstrap.js.map +1 -0
- package/dist/market-launch.d.ts +45 -0
- package/dist/market-launch.d.ts.map +1 -0
- package/dist/market-launch.js +76 -0
- package/dist/market-launch.js.map +1 -0
- package/dist/operator-client.d.ts +99 -0
- package/dist/operator-client.d.ts.map +1 -0
- package/dist/operator-client.js +153 -0
- package/dist/operator-client.js.map +1 -0
- package/dist/oracle.d.ts +46 -0
- package/dist/oracle.d.ts.map +1 -0
- package/dist/oracle.js +103 -0
- package/dist/oracle.js.map +1 -0
- package/dist/parameters.d.ts +231 -0
- package/dist/parameters.d.ts.map +1 -0
- package/dist/parameters.js +683 -0
- package/dist/parameters.js.map +1 -0
- package/dist/preview.d.ts +39 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +12 -0
- package/dist/preview.js.map +1 -1
- package/dist/protection.d.ts +48 -0
- package/dist/protection.d.ts.map +1 -0
- package/dist/protection.js +88 -0
- package/dist/protection.js.map +1 -0
- package/dist/risk-pricing.d.ts +12 -0
- package/dist/risk-pricing.d.ts.map +1 -0
- package/dist/risk-pricing.js +23 -0
- package/dist/risk-pricing.js.map +1 -0
- package/dist/simulation.d.ts +45 -0
- package/dist/simulation.d.ts.map +1 -0
- package/dist/simulation.js +106 -0
- package/dist/simulation.js.map +1 -0
- package/dist/tranche-client.d.ts +121 -0
- package/dist/tranche-client.d.ts.map +1 -0
- package/dist/tranche-client.js +185 -0
- package/dist/tranche-client.js.map +1 -0
- package/dist/transfer-fees.d.ts +46 -0
- package/dist/transfer-fees.d.ts.map +1 -0
- package/dist/transfer-fees.js +76 -0
- package/dist/transfer-fees.js.map +1 -0
- package/dist/type-aliases.d.ts +265 -31
- package/dist/type-aliases.d.ts.map +1 -1
- package/dist/types_delegate.d.ts +6275 -0
- package/dist/types_delegate.d.ts.map +1 -0
- package/dist/types_delegate.js +2 -0
- package/dist/types_delegate.js.map +1 -0
- package/dist/types_v2.d.ts +16654 -6584
- package/dist/types_v2.d.ts.map +1 -1
- package/dist/virtual-book/index.d.ts +4 -0
- package/dist/virtual-book/index.d.ts.map +1 -0
- package/dist/virtual-book/index.js +4 -0
- package/dist/virtual-book/index.js.map +1 -0
- package/dist/virtual-book/market.d.ts +619 -0
- package/dist/virtual-book/market.d.ts.map +1 -0
- package/dist/virtual-book/market.js +59 -0
- package/dist/virtual-book/market.js.map +1 -0
- package/dist/virtual-book/projection.d.ts +44 -0
- package/dist/virtual-book/projection.d.ts.map +1 -0
- package/dist/virtual-book/projection.js +229 -0
- package/dist/virtual-book/projection.js.map +1 -0
- package/dist/virtual-book/quotes.d.ts +1263 -0
- package/dist/virtual-book/quotes.d.ts.map +1 -0
- package/dist/virtual-book/quotes.js +233 -0
- package/dist/virtual-book/quotes.js.map +1 -0
- package/dist/write.d.ts +427 -0
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +970 -26
- package/dist/write.js.map +1 -1
- package/dist/yield-client.d.ts +51 -0
- package/dist/yield-client.d.ts.map +1 -0
- package/dist/yield-client.js +98 -0
- package/dist/yield-client.js.map +1 -0
- package/package.json +11 -4
- package/src/amounts.ts +13 -0
- package/src/constants.ts +220 -46
- package/src/delegate.ts +259 -0
- package/src/dusk.ts +28 -0
- package/src/get.ts +201 -86
- package/src/hash.ts +15 -0
- package/src/hlp-liquidation-client.ts +189 -0
- package/src/idl_delegate.json +6268 -0
- package/src/idl_delegate.ts +3 -0
- package/src/idl_v2.json +16746 -6676
- package/src/index.ts +31 -0
- package/src/interest-accounting.ts +73 -0
- package/src/leverage-actions.ts +216 -0
- package/src/leverage-margins.ts +48 -0
- package/src/leverage-preview.ts +86 -0
- package/src/liquidation-client.ts +295 -0
- package/src/liquidation.ts +119 -0
- package/src/lp-naming.ts +127 -0
- package/src/lp-vanity.ts +135 -0
- package/src/market-bootstrap.ts +271 -0
- package/src/market-launch.ts +103 -0
- package/src/operator-client.ts +169 -0
- package/src/oracle.ts +120 -0
- package/src/parameters.ts +1019 -0
- package/src/preview.ts +53 -1
- package/src/protection.ts +112 -0
- package/src/risk-pricing.ts +26 -0
- package/src/simulation.ts +169 -0
- package/src/tranche-client.ts +187 -0
- package/src/transfer-fees.ts +99 -0
- package/src/type-aliases.ts +294 -32
- package/src/types_delegate.ts +6274 -0
- package/src/types_v2.ts +16745 -6675
- package/src/virtual-book/index.ts +3 -0
- package/src/virtual-book/market.ts +76 -0
- package/src/virtual-book/projection.ts +265 -0
- package/src/virtual-book/quotes.ts +308 -0
- package/src/write.ts +1650 -28
- package/src/yield-client.ts +117 -0
package/dist/get.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../src/get.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../src/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;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKpF"}
|
package/dist/get.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DuskWrite } from "./write.js";
|
|
2
|
+
import { previewLeverageAction } from "./leverage-preview.js";
|
|
3
|
+
import { simulatePreviewWithContext, } from "./simulation.js";
|
|
4
|
+
export { DuskSimulationError, DuskPreviewTimeoutError } from "./simulation.js";
|
|
5
|
+
import { previewVirtualBookSnapshot, previewVirtualBookQuotes, previewVirtualBookBatch, projectDuskVirtualBook, } from "./virtual-book/index.js";
|
|
6
|
+
import { deriveBorrowPositionAddress, deriveFutarchyAuthorityAddress, deriveHlpSrlpVaultAddress, deriveLeveragePositionAddress, deriveMarketAddress, deriveMarketCollateralVaultAddress, deriveMarketInterestVaultAddress, deriveMarketReserveVaultAddress, deriveReferralAccrualAddress, deriveReferralPartnerAddress, deriveTokenMetadataAddress, deriveYieldAccountAddress, deriveYieldTransferHookValidationAddress, } from "./constants.js";
|
|
3
7
|
import { address, DEFAULT_READONLY_PUBLIC_KEY, normalizeAccountKeys } from "./address.js";
|
|
4
|
-
import {
|
|
8
|
+
import { getStoredLeverageMargins } from "./leverage-margins.js";
|
|
9
|
+
import { decodePreviewHlpDepositCapacityReturnData, decodePreviewAddLiquidityReturnData, decodePreviewBorrowCapacityReturnData, decodePreviewBorrowPositionReturnData, decodePreviewBorrowPositionCapacityReturnData, decodePreviewMarketReturnData, decodePreviewSwapReturnData, } from "./preview.js";
|
|
5
10
|
export const pda = {
|
|
6
11
|
futarchyAuthority: deriveFutarchyAuthorityAddress,
|
|
7
12
|
market: deriveMarketAddress,
|
|
@@ -13,19 +18,10 @@ export const pda = {
|
|
|
13
18
|
leveragePosition: deriveLeveragePositionAddress,
|
|
14
19
|
yieldAccount: deriveYieldAccountAddress,
|
|
15
20
|
yieldTransferHookValidation: deriveYieldTransferHookValidationAddress,
|
|
16
|
-
|
|
17
|
-
insurance: deriveInsuranceAddress,
|
|
21
|
+
hlpSrlpVault: deriveHlpSrlpVaultAddress,
|
|
18
22
|
referralPartner: deriveReferralPartnerAddress,
|
|
19
23
|
referralAccrual: deriveReferralAccrualAddress,
|
|
20
24
|
};
|
|
21
|
-
export class DuskSimulationError extends Error {
|
|
22
|
-
simulation;
|
|
23
|
-
constructor(message, simulation) {
|
|
24
|
-
super(message);
|
|
25
|
-
this.simulation = simulation;
|
|
26
|
-
this.name = "DuskSimulationError";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
25
|
export class DuskGet {
|
|
30
26
|
program;
|
|
31
27
|
defaultFeePayer;
|
|
@@ -44,118 +40,159 @@ export class DuskGet {
|
|
|
44
40
|
}
|
|
45
41
|
return client.fetch(address(account));
|
|
46
42
|
}
|
|
43
|
+
allProgramAccounts(name) {
|
|
44
|
+
const client = this.program.account[name];
|
|
45
|
+
if (!client) {
|
|
46
|
+
throw new Error(`Unknown Dusk account type: ${name}`);
|
|
47
|
+
}
|
|
48
|
+
return client.all();
|
|
49
|
+
}
|
|
47
50
|
market(account) {
|
|
48
|
-
return this.
|
|
51
|
+
return this.programAccount("market", account);
|
|
49
52
|
}
|
|
50
53
|
borrowPosition(account) {
|
|
51
|
-
return this.
|
|
54
|
+
return this.programAccount("borrowPosition", account);
|
|
52
55
|
}
|
|
53
56
|
leveragePosition(account) {
|
|
54
|
-
return this.
|
|
57
|
+
return this.programAccount("leveragePosition", account);
|
|
58
|
+
}
|
|
59
|
+
/** Fetch saved margin terms; does not quote an opening or an increase. */
|
|
60
|
+
async leverageMargins(account) {
|
|
61
|
+
return getStoredLeverageMargins(await this.leveragePosition(account));
|
|
62
|
+
}
|
|
63
|
+
previewLeverageAction(params) {
|
|
64
|
+
return previewLeverageAction(this.program, params);
|
|
55
65
|
}
|
|
56
66
|
leverageDelegation(account) {
|
|
57
|
-
return this.
|
|
67
|
+
return this.programAccount("leverageDelegation", account);
|
|
58
68
|
}
|
|
59
69
|
yieldAccount(account) {
|
|
60
|
-
return this.
|
|
70
|
+
return this.programAccount("yieldAccount", account);
|
|
61
71
|
}
|
|
62
72
|
futarchyAuthority(account = deriveFutarchyAuthorityAddress()[0]) {
|
|
63
|
-
return this.
|
|
73
|
+
return this.programAccount("futarchyAuthority", account);
|
|
64
74
|
}
|
|
65
75
|
referralPartner(account) {
|
|
66
|
-
return this.
|
|
76
|
+
return this.programAccount("referralPartner", account);
|
|
67
77
|
}
|
|
68
78
|
referralAccrual(account) {
|
|
69
|
-
return this.
|
|
79
|
+
return this.programAccount("referralAccrual", account);
|
|
70
80
|
}
|
|
71
81
|
allMarkets() {
|
|
72
|
-
return this.
|
|
82
|
+
return this.allProgramAccounts("market");
|
|
73
83
|
}
|
|
74
84
|
allBorrowPositions() {
|
|
75
|
-
return this.
|
|
85
|
+
return this.allProgramAccounts("borrowPosition");
|
|
76
86
|
}
|
|
77
87
|
allLeveragePositions() {
|
|
78
|
-
return this.
|
|
88
|
+
return this.allProgramAccounts("leveragePosition");
|
|
79
89
|
}
|
|
80
90
|
allReferralPartners() {
|
|
81
|
-
return this.
|
|
91
|
+
return this.allProgramAccounts("referralPartner");
|
|
82
92
|
}
|
|
83
93
|
allReferralAccruals() {
|
|
84
|
-
return this.
|
|
94
|
+
return this.allProgramAccounts("referralAccrual");
|
|
95
|
+
}
|
|
96
|
+
previewInstruction(name, args, accounts) {
|
|
97
|
+
return new DuskWrite(this.program).instruction(name, args, { accounts });
|
|
85
98
|
}
|
|
86
99
|
async previewMarket(market, options = {}) {
|
|
87
|
-
const instruction = await this.
|
|
88
|
-
.previewMarket()
|
|
89
|
-
.accounts(normalizeAccountKeys({ market }))
|
|
90
|
-
.instruction();
|
|
100
|
+
const instruction = await this.previewInstruction("previewMarket", [], normalizeAccountKeys({ market }));
|
|
91
101
|
return decodePreviewMarketReturnData(await this.simulateReturnData(instruction, options));
|
|
92
102
|
}
|
|
103
|
+
/** Current full-value hedge admission and funding ceiling, including transfer fees.
|
|
104
|
+
* A Ready status is not an amount-specific execution guarantee; simulate the
|
|
105
|
+
* completed deposit transaction to check rounding, slippage and custody.
|
|
106
|
+
*/
|
|
107
|
+
async previewHlpDepositCapacity(params) {
|
|
108
|
+
const instruction = await this.previewInstruction("previewHlpDepositCapacity", [], normalizeAccountKeys({
|
|
109
|
+
market: params.market,
|
|
110
|
+
futarchyAuthority: params.futarchyAuthority ?? deriveFutarchyAuthorityAddress(this.program.programId)[0],
|
|
111
|
+
baseMint: params.baseMint,
|
|
112
|
+
quoteMint: params.quoteMint,
|
|
113
|
+
targetHlpMint: params.targetHlpMint,
|
|
114
|
+
}));
|
|
115
|
+
return decodePreviewHlpDepositCapacityReturnData(await this.simulateReturnData(instruction, params));
|
|
116
|
+
}
|
|
93
117
|
async previewAddLiquidity(params) {
|
|
94
|
-
const instruction = await this.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
})
|
|
99
|
-
.accounts(normalizeAccountKeys({
|
|
118
|
+
const instruction = await this.previewInstruction("previewAddLiquidity", [{
|
|
119
|
+
baseDepositAmount: params.baseDepositAmount,
|
|
120
|
+
quoteDepositAmount: params.quoteDepositAmount,
|
|
121
|
+
}], normalizeAccountKeys({
|
|
100
122
|
market: params.market,
|
|
101
123
|
baseMint: params.baseMint,
|
|
102
124
|
quoteMint: params.quoteMint,
|
|
103
|
-
}))
|
|
104
|
-
.instruction();
|
|
125
|
+
}));
|
|
105
126
|
return decodePreviewAddLiquidityReturnData(await this.simulateReturnData(instruction, params));
|
|
106
127
|
}
|
|
107
128
|
async previewSwap(params) {
|
|
108
|
-
const instruction = await this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
})
|
|
112
|
-
.accounts(normalizeAccountKeys({
|
|
129
|
+
const instruction = await this.previewInstruction("previewSwap", [{
|
|
130
|
+
exactAssetIn: params.exactAssetIn,
|
|
131
|
+
}], normalizeAccountKeys({
|
|
113
132
|
market: params.market,
|
|
133
|
+
futarchyAuthority: params.futarchyAuthority ?? deriveFutarchyAuthorityAddress()[0],
|
|
114
134
|
assetInMint: params.assetInMint,
|
|
115
135
|
assetOutMint: params.assetOutMint,
|
|
116
|
-
}))
|
|
117
|
-
.instruction();
|
|
136
|
+
}));
|
|
118
137
|
return decodePreviewSwapReturnData(await this.simulateReturnData(instruction, params));
|
|
119
138
|
}
|
|
120
139
|
async previewBorrowCapacity(params) {
|
|
121
|
-
const instruction = await this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
})
|
|
126
|
-
.accounts(normalizeAccountKeys({
|
|
140
|
+
const instruction = await this.previewInstruction("previewBorrowCapacity", [{
|
|
141
|
+
collateralAmount: params.collateralAmount,
|
|
142
|
+
projectedBorrowAmount: params.projectedBorrowAmount ?? null,
|
|
143
|
+
}], normalizeAccountKeys({
|
|
127
144
|
market: params.market,
|
|
128
145
|
collateralAssetMint: params.collateralAssetMint,
|
|
129
146
|
debtAssetMint: params.debtAssetMint,
|
|
130
|
-
}))
|
|
131
|
-
.instruction();
|
|
147
|
+
}));
|
|
132
148
|
return decodePreviewBorrowCapacityReturnData(await this.simulateReturnData(instruction, params));
|
|
133
149
|
}
|
|
150
|
+
async previewBorrowPositionCapacity(params) {
|
|
151
|
+
const instruction = await this.previewInstruction("previewBorrowPositionCapacity", [{
|
|
152
|
+
capacityKind: params.capacityKind === "borrow" ? { borrow: {} } : { withdraw: {} },
|
|
153
|
+
collateralChange: params.collateralChange,
|
|
154
|
+
projectedBorrowAmount: params.projectedBorrowAmount ?? null,
|
|
155
|
+
}], normalizeAccountKeys({
|
|
156
|
+
market: params.market,
|
|
157
|
+
borrowPosition: params.borrowPosition,
|
|
158
|
+
collateralAssetMint: params.collateralAssetMint,
|
|
159
|
+
debtAssetMint: params.debtAssetMint,
|
|
160
|
+
}));
|
|
161
|
+
return decodePreviewBorrowPositionCapacityReturnData(await this.simulateReturnData(instruction, params));
|
|
162
|
+
}
|
|
134
163
|
async previewBorrowPosition(params) {
|
|
135
|
-
const instruction = await this.
|
|
136
|
-
.previewBorrowPosition()
|
|
137
|
-
.accounts(normalizeAccountKeys({
|
|
164
|
+
const instruction = await this.previewInstruction("previewBorrowPosition", [], normalizeAccountKeys({
|
|
138
165
|
market: params.market,
|
|
139
166
|
borrowPosition: params.borrowPosition,
|
|
140
|
-
|
|
141
|
-
.
|
|
167
|
+
baseMint: params.baseMint,
|
|
168
|
+
quoteMint: params.quoteMint,
|
|
169
|
+
}));
|
|
142
170
|
return decodePreviewBorrowPositionReturnData(await this.simulateReturnData(instruction, params));
|
|
143
171
|
}
|
|
172
|
+
/** Simulate one or more instructions while retaining bank and account provenance. */
|
|
173
|
+
simulateWithContext(instructions, options = {}) {
|
|
174
|
+
return simulatePreviewWithContext(this.program, instructions, {
|
|
175
|
+
...options,
|
|
176
|
+
feePayer: options.feePayer ?? this.program.provider.publicKey ?? this.defaultFeePayer,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
144
179
|
async simulateReturnData(instruction, options = {}) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
180
|
+
return (await this.simulateWithContext([instruction], options)).value.returnData;
|
|
181
|
+
}
|
|
182
|
+
previewVirtualBookSnapshot(market, options = {}) {
|
|
183
|
+
return previewVirtualBookSnapshot(this.program, market, options);
|
|
184
|
+
}
|
|
185
|
+
previewVirtualBookBatch(snapshot, requests, options = {}) {
|
|
186
|
+
return previewVirtualBookBatch(this.program, snapshot, requests, options);
|
|
187
|
+
}
|
|
188
|
+
previewVirtualBookQuotes(snapshot, options = {}) {
|
|
189
|
+
return previewVirtualBookQuotes(this.program, snapshot, options);
|
|
190
|
+
}
|
|
191
|
+
/** Fee-inclusive display depth. Transaction quotes must still use the exact requested input. */
|
|
192
|
+
async previewVirtualBook(market, options = {}) {
|
|
193
|
+
const snapshot = await this.previewVirtualBookSnapshot(market, options);
|
|
194
|
+
const quotes = await this.previewVirtualBookQuotes(snapshot, options);
|
|
195
|
+
return { ...quotes, book: projectDuskVirtualBook(quotes) };
|
|
159
196
|
}
|
|
160
197
|
}
|
|
161
198
|
//# sourceMappingURL=get.js.map
|
package/dist/get.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../src/get.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../src/get.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4B,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAoC,MAAM,uBAAuB,CAAC;AAEhG,OAAO,EACL,0BAA0B,GAG3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAM/E,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,uBAAuB,EACvB,sBAAsB,GAIvB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,EAC9B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,kCAAkC,EAClC,gCAAgC,EAChC,+BAA+B,EAC/B,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,yBAAyB,EACzB,wCAAwC,GAEzC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAoB,MAAM,cAAc,CAAC;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EACL,yCAAyC,EAEzC,mCAAmC,EACnC,qCAAqC,EACrC,qCAAqC,EACrC,6CAA6C,EAC7C,6BAA6B,EAC7B,2BAA2B,GAQ5B,MAAM,cAAc,CAAC;AAatB,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,iBAAiB,E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AgG;IAChG,KAAK,CAAC,kBAAkB,CAAC,MAAmB,EAAE,UAAmC,EAAE;QACjF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACtE,OAAO,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAE,EAAE,CAAC;IAC9D,CAAC;CACF"}
|
package/dist/hash.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-256 that works in a browser and in Node.
|
|
3
|
+
*
|
|
4
|
+
* WebCrypto is the only digest a browser bundle can rely on and it is async,
|
|
5
|
+
* so every caller of this is async too. `node:crypto` is imported lazily so a
|
|
6
|
+
* bundler targeting the browser never has to resolve it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sha256(bytes: Uint8Array): Promise<Uint8Array>;
|
|
9
|
+
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAsB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAOnE"}
|
package/dist/hash.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHA-256 that works in a browser and in Node.
|
|
3
|
+
*
|
|
4
|
+
* WebCrypto is the only digest a browser bundle can rely on and it is async,
|
|
5
|
+
* so every caller of this is async too. `node:crypto` is imported lazily so a
|
|
6
|
+
* bundler targeting the browser never has to resolve it.
|
|
7
|
+
*/
|
|
8
|
+
export async function sha256(bytes) {
|
|
9
|
+
if (globalThis.crypto?.subtle) {
|
|
10
|
+
const stableBytes = Uint8Array.from(bytes);
|
|
11
|
+
return new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", stableBytes));
|
|
12
|
+
}
|
|
13
|
+
const { createHash } = await import("node:crypto");
|
|
14
|
+
return Uint8Array.from(createHash("sha256").update(bytes).digest());
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=hash.js.map
|
package/dist/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,KAAiB;IAC5C,IAAI,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,IAAI,UAAU,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;IACvF,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IACnD,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { Program } from "@coral-xyz/anchor";
|
|
2
|
+
import { PublicKey, type AccountMeta, type TransactionInstruction } from "@solana/web3.js";
|
|
3
|
+
import { type AddressLike } from "./address.js";
|
|
4
|
+
import { DuskGet } from "./get.js";
|
|
5
|
+
import { type IntegerLike } from "./parameters.js";
|
|
6
|
+
import type { Dusk as DuskIdl } from "./types_v2.js";
|
|
7
|
+
import type { HlpFlashQuote } from "./type-aliases.js";
|
|
8
|
+
import { DuskWrite, type HlpLiquidityBuildOptions } from "./write.js";
|
|
9
|
+
export type { HlpFlashQuote };
|
|
10
|
+
export interface HlpRecoveryParams {
|
|
11
|
+
market: AddressLike;
|
|
12
|
+
targetAsset: "base" | "quote";
|
|
13
|
+
}
|
|
14
|
+
export interface HlpFlashRouteContext {
|
|
15
|
+
quote: HlpFlashQuote;
|
|
16
|
+
session: PublicKey;
|
|
17
|
+
repaymentVault: PublicKey;
|
|
18
|
+
buyerCollateralAccount: PublicKey;
|
|
19
|
+
buyerDebtAccount: PublicKey;
|
|
20
|
+
collateralMint: PublicKey;
|
|
21
|
+
debtMint: PublicKey;
|
|
22
|
+
collateralTokenProgram: PublicKey;
|
|
23
|
+
debtTokenProgram: PublicKey;
|
|
24
|
+
/** Net spendable atoms required in repaymentVault. A route must gross up
|
|
25
|
+
* its incoming transfer; this already includes the vault-to-reserve fee. */
|
|
26
|
+
requiredPaymentCredit: bigint;
|
|
27
|
+
}
|
|
28
|
+
export interface HlpFlashParams extends HlpRecoveryParams {
|
|
29
|
+
buyer: AddressLike;
|
|
30
|
+
/** Explicit opt-in to closing an insolvent vault's entire backing. */
|
|
31
|
+
allowFull?: boolean;
|
|
32
|
+
maxPayment?: IntegerLike;
|
|
33
|
+
maxCollateralDebit?: IntegerLike;
|
|
34
|
+
minCollateralCredit?: IntegerLike;
|
|
35
|
+
maxSocializedLoss?: IntegerLike;
|
|
36
|
+
prefixInstructions?: readonly TransactionInstruction[];
|
|
37
|
+
settleRemainingAccounts?: readonly AccountMeta[];
|
|
38
|
+
route: (context: HlpFlashRouteContext) => Promise<readonly TransactionInstruction[]> | readonly TransactionInstruction[];
|
|
39
|
+
/** Append an owner-signed withdrawal after funded recovery or terminal
|
|
40
|
+
* settlement. A terminal close pays zero principal. */
|
|
41
|
+
exit?: HlpRecoveryExit;
|
|
42
|
+
}
|
|
43
|
+
export interface HlpRecoveryExit {
|
|
44
|
+
hlpAmount: IntegerLike;
|
|
45
|
+
minTargetAmountOut?: IntegerLike;
|
|
46
|
+
options: HlpLiquidityBuildOptions;
|
|
47
|
+
}
|
|
48
|
+
export interface HlpNativeCloseAndExitParams extends HlpRecoveryParams {
|
|
49
|
+
exit: HlpRecoveryExit;
|
|
50
|
+
maxSocializedLoss?: IntegerLike;
|
|
51
|
+
minCallerBountyOut?: IntegerLike;
|
|
52
|
+
closeRemainingAccounts?: readonly AccountMeta[];
|
|
53
|
+
}
|
|
54
|
+
/** Atomic vault recovery. A solvent funding gap can be rescued before the
|
|
55
|
+
* native critical-stress boundary; a full quote still requires insolvency.
|
|
56
|
+
* Keeps a fixed payment obligation and permits an external route or inventory
|
|
57
|
+
* payment. A direct Dusk swap may be used when the complete transaction fits
|
|
58
|
+
* Solana's compute limit; callers must simulate their chosen route. Native
|
|
59
|
+
* Dusk recovery remains available through an ordinary swap. Never signs or
|
|
60
|
+
* submits. */
|
|
61
|
+
export declare class DuskHlpLiquidations {
|
|
62
|
+
readonly program: Program<DuskIdl>;
|
|
63
|
+
readonly write: DuskWrite;
|
|
64
|
+
readonly get: DuskGet;
|
|
65
|
+
constructor(program: Program<DuskIdl>, feePayer?: AddressLike);
|
|
66
|
+
private resolve;
|
|
67
|
+
/** Uses the program's full-value eligibility, EMA payment quote, transfer
|
|
68
|
+
* fees and affordable incentive. A positive funding gap or frozen vault can
|
|
69
|
+
* quote a solvent rescue; inspect quote.full before building a transaction.
|
|
70
|
+
* It does not reserve liquidity or payment. */
|
|
71
|
+
preview(params: HlpRecoveryParams): Promise<HlpFlashQuote>;
|
|
72
|
+
isFrozen(params: HlpRecoveryParams): Promise<boolean>;
|
|
73
|
+
private exitInstruction;
|
|
74
|
+
/** One signed transaction: permissionless native junior/senior loss close,
|
|
75
|
+
* then the holder burns receipts. Eligibility uses current-slot symmetric
|
|
76
|
+
* EMA health; native recovery uses EMA price, smoothed depth, concentration,
|
|
77
|
+
* and the configured fee schedule. The receipt burn pays zero principal. */
|
|
78
|
+
buildNativeCloseAndExit(params: HlpNativeCloseAndExitParams): Promise<{
|
|
79
|
+
closeInstruction: TransactionInstruction;
|
|
80
|
+
exitInstruction: TransactionInstruction;
|
|
81
|
+
instructions: TransactionInstruction[];
|
|
82
|
+
}>;
|
|
83
|
+
buildFlash(params: HlpFlashParams): Promise<{
|
|
84
|
+
beginIndex: number;
|
|
85
|
+
settleIndex: number;
|
|
86
|
+
beginInstruction: TransactionInstruction;
|
|
87
|
+
settleInstruction: TransactionInstruction;
|
|
88
|
+
exitInstruction: TransactionInstruction | undefined;
|
|
89
|
+
instructions: TransactionInstruction[];
|
|
90
|
+
quote: HlpFlashQuote;
|
|
91
|
+
session: PublicKey;
|
|
92
|
+
repaymentVault: PublicKey;
|
|
93
|
+
buyerCollateralAccount: PublicKey;
|
|
94
|
+
buyerDebtAccount: PublicKey;
|
|
95
|
+
collateralMint: PublicKey;
|
|
96
|
+
debtMint: PublicKey;
|
|
97
|
+
collateralTokenProgram: PublicKey;
|
|
98
|
+
debtTokenProgram: PublicKey;
|
|
99
|
+
/** Net spendable atoms required in repaymentVault. A route must gross up
|
|
100
|
+
* its incoming transfer; this already includes the vault-to-reserve fee. */
|
|
101
|
+
requiredPaymentCredit: bigint;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=hlp-liquidation-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hlp-liquidation-client.d.ts","sourceRoot":"","sources":["../src/hlp-liquidation-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAwB,SAAS,EAA6C,KAAK,WAAW,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC5J,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAa,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,eAAe,CAA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WAAW,CAAC;IACvB,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC,OAAO,EAAE,wBAAwB,CAAC;CACnC;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,IAAI,EAAE,eAAe,CAAC;IACtB,iBAAiB,CAAC,EAAE,WAAW,CAAC;IAChC,kBAAkB,CAAC,EAAE,WAAW,CAAC;IACjC,sBAAsB,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CACjD;AAED;;;;;;cAMc;AACd,qBAAa,mBAAmB;IAGlB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IAF9C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;gBACD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAE,WAAW;YAKxD,OAAO;IAUrB;;;mDAG+C;IACzC,OAAO,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;IAQ1D,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;YAK7C,eAAe;IAY7B;;;gFAG4E;IACtE,uBAAuB,CAAC,MAAM,EAAE,2BAA2B;;;;;IAyB3D,UAAU,CAAC,MAAM,EAAE,cAAc;;;;;;;eA7HhC,aAAa;iBACX,SAAS;wBACF,SAAS;gCACD,SAAS;0BACf,SAAS;wBACX,SAAS;kBACf,SAAS;gCACK,SAAS;0BACf,SAAS;QAC3B;oFAC4E;+BACrD,MAAM;;CAiK9B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { createAssociatedTokenAccountIdempotentInstruction, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID } from "@solana/spl-token";
|
|
2
|
+
import { ComputeBudgetProgram, PublicKey, SystemProgram, SYSVAR_INSTRUCTIONS_PUBKEY } from "@solana/web3.js";
|
|
3
|
+
import { address } from "./address.js";
|
|
4
|
+
import { deriveFutarchyAuthorityAddress } from "./constants.js";
|
|
5
|
+
import { DuskGet } from "./get.js";
|
|
6
|
+
import { integerBN } from "./parameters.js";
|
|
7
|
+
import { previewReturnDataBytes } from "./preview.js";
|
|
8
|
+
import { tokenProgramForMint } from "./referral.js";
|
|
9
|
+
import { DuskWrite } from "./write.js";
|
|
10
|
+
/** Atomic vault recovery. A solvent funding gap can be rescued before the
|
|
11
|
+
* native critical-stress boundary; a full quote still requires insolvency.
|
|
12
|
+
* Keeps a fixed payment obligation and permits an external route or inventory
|
|
13
|
+
* payment. A direct Dusk swap may be used when the complete transaction fits
|
|
14
|
+
* Solana's compute limit; callers must simulate their chosen route. Native
|
|
15
|
+
* Dusk recovery remains available through an ordinary swap. Never signs or
|
|
16
|
+
* submits. */
|
|
17
|
+
export class DuskHlpLiquidations {
|
|
18
|
+
program;
|
|
19
|
+
write;
|
|
20
|
+
get;
|
|
21
|
+
constructor(program, feePayer) {
|
|
22
|
+
this.program = program;
|
|
23
|
+
this.write = new DuskWrite(program);
|
|
24
|
+
this.get = new DuskGet(program, feePayer);
|
|
25
|
+
}
|
|
26
|
+
async resolve(params) {
|
|
27
|
+
if (params.targetAsset !== "base" && params.targetAsset !== "quote")
|
|
28
|
+
throw new Error("Invalid hLP target asset");
|
|
29
|
+
const market = address(params.market), target = params.targetAsset === "base" ? 0 : 1;
|
|
30
|
+
const state = await this.get.market(market);
|
|
31
|
+
const collateral = target === 0 ? state.baseSide : state.quoteSide;
|
|
32
|
+
const debt = target === 0 ? state.quoteSide : state.baseSide;
|
|
33
|
+
const futarchyAuthority = deriveFutarchyAuthorityAddress(this.program.programId)[0];
|
|
34
|
+
return { market, target, state, collateral, debt, futarchyAuthority };
|
|
35
|
+
}
|
|
36
|
+
/** Uses the program's full-value eligibility, EMA payment quote, transfer
|
|
37
|
+
* fees and affordable incentive. A positive funding gap or frozen vault can
|
|
38
|
+
* quote a solvent rescue; inspect quote.full before building a transaction.
|
|
39
|
+
* It does not reserve liquidity or payment. */
|
|
40
|
+
async preview(params) {
|
|
41
|
+
const r = await this.resolve(params);
|
|
42
|
+
const instruction = await this.write.instruction("previewHlpFlash", [r.target], {
|
|
43
|
+
accounts: { market: r.market, futarchyAuthority: r.futarchyAuthority, targetMint: r.collateral.assetMint, borrowedMint: r.debt.assetMint },
|
|
44
|
+
});
|
|
45
|
+
return this.program.coder.types.decode("hlpFlashQuote", previewReturnDataBytes(await this.get.simulateReturnData(instruction)));
|
|
46
|
+
}
|
|
47
|
+
async isFrozen(params) {
|
|
48
|
+
const r = await this.resolve(params);
|
|
49
|
+
return (r.state.amm.frozenHlpMask & (r.target === 0 ? 1 : 2)) !== 0;
|
|
50
|
+
}
|
|
51
|
+
async exitInstruction(r, exit) {
|
|
52
|
+
if (!address(exit.options.market).equals(r.market))
|
|
53
|
+
throw new Error("Exit market differs from liquidation market");
|
|
54
|
+
if (!address(exit.options.targetHlpMint).equals(r.collateral.hlpMint))
|
|
55
|
+
throw new Error("Exit hLP mint differs from liquidation target");
|
|
56
|
+
if (!address(exit.options.baseMint).equals(r.state.baseSide.assetMint) ||
|
|
57
|
+
!address(exit.options.quoteMint).equals(r.state.quoteSide.assetMint))
|
|
58
|
+
throw new Error("Exit asset mints differ from market");
|
|
59
|
+
const built = await this.write.withdrawSingleSided({
|
|
60
|
+
hlpAmount: integerBN(exit.hlpAmount, "hlpAmount"),
|
|
61
|
+
minTargetAmountOut: integerBN(exit.minTargetAmountOut ?? 0, "minTargetAmountOut"),
|
|
62
|
+
}, exit.options);
|
|
63
|
+
return built;
|
|
64
|
+
}
|
|
65
|
+
/** One signed transaction: permissionless native junior/senior loss close,
|
|
66
|
+
* then the holder burns receipts. Eligibility uses current-slot symmetric
|
|
67
|
+
* EMA health; native recovery uses EMA price, smoothed depth, concentration,
|
|
68
|
+
* and the configured fee schedule. The receipt burn pays zero principal. */
|
|
69
|
+
async buildNativeCloseAndExit(params) {
|
|
70
|
+
const r = await this.resolve(params);
|
|
71
|
+
const exit = await this.exitInstruction(r, params.exit);
|
|
72
|
+
const caller = address(params.exit.options.owner);
|
|
73
|
+
const debtTokenProgram = await tokenProgramForMint(this.program.provider.connection, r.debt.assetMint);
|
|
74
|
+
const callerBountyAccount = getAssociatedTokenAddressSync(r.debt.assetMint, caller, true, debtTokenProgram);
|
|
75
|
+
const targetVault = r.target === 0 ? r.state.baseHlpVault : r.state.quoteHlpVault;
|
|
76
|
+
const close = await this.write.instruction("closeInsolventHlp", {
|
|
77
|
+
targetAsset: r.target,
|
|
78
|
+
maxSocializedLoss: integerBN(params.maxSocializedLoss ?? 0xffffffffffffffffn, "maxSocializedLoss"),
|
|
79
|
+
minCallerBountyOut: integerBN(params.minCallerBountyOut ?? 0, "minCallerBountyOut"),
|
|
80
|
+
}, { accounts: {
|
|
81
|
+
market: r.market, futarchyAuthority: r.futarchyAuthority, caller,
|
|
82
|
+
borrowedMint: r.debt.assetMint, borrowedReserveVault: r.debt.reserveVault,
|
|
83
|
+
borrowedInterestVault: r.debt.interestVault,
|
|
84
|
+
callerBountyAccount, srlpMint: r.state.srlpMint, targetHlpSrlpVault: targetVault.srlpVault,
|
|
85
|
+
tokenProgram: TOKEN_PROGRAM_ID, token2022Program: TOKEN_2022_PROGRAM_ID,
|
|
86
|
+
}, remainingAccounts: params.closeRemainingAccounts ? [...params.closeRemainingAccounts] : undefined });
|
|
87
|
+
const instructions = [
|
|
88
|
+
createAssociatedTokenAccountIdempotentInstruction(caller, callerBountyAccount, caller, r.debt.assetMint, debtTokenProgram),
|
|
89
|
+
...exit.setupInstructions, close, exit.actionInstruction,
|
|
90
|
+
];
|
|
91
|
+
return { closeInstruction: close, exitInstruction: exit.actionInstruction, instructions };
|
|
92
|
+
}
|
|
93
|
+
async buildFlash(params) {
|
|
94
|
+
if (typeof params.route !== "function")
|
|
95
|
+
throw new Error("An explicit payment route is required");
|
|
96
|
+
const r = await this.resolve(params), buyer = address(params.buyer);
|
|
97
|
+
const [quote, collateralTokenProgram, debtTokenProgram] = await Promise.all([
|
|
98
|
+
this.preview(params), tokenProgramForMint(this.program.provider.connection, r.collateral.assetMint),
|
|
99
|
+
tokenProgramForMint(this.program.provider.connection, r.debt.assetMint),
|
|
100
|
+
]);
|
|
101
|
+
if (quote.full && !params.allowFull)
|
|
102
|
+
throw new Error("This vault needs full recovery; set allowFull explicitly");
|
|
103
|
+
const exit = params.exit ? await this.exitInstruction(r, params.exit) : undefined;
|
|
104
|
+
const [session] = PublicKey.findProgramAddressSync([Buffer.from("hlp-flash-session"), r.market.toBuffer(), Buffer.from([r.target])], this.program.programId);
|
|
105
|
+
const [repaymentVault] = PublicKey.findProgramAddressSync([Buffer.from("hlp-flash-payment"), session.toBuffer()], this.program.programId);
|
|
106
|
+
const buyerCollateralAccount = getAssociatedTokenAddressSync(r.collateral.assetMint, buyer, true, collateralTokenProgram);
|
|
107
|
+
const buyerDebtAccount = getAssociatedTokenAddressSync(r.debt.assetMint, buyer, true, debtTokenProgram);
|
|
108
|
+
const prefix = [...(params.prefixInstructions ?? []), ...(exit?.setupInstructions ?? [])];
|
|
109
|
+
for (const [tag, instruction] of [[2, ComputeBudgetProgram.setComputeUnitLimit({ units: 1_400_000 })],
|
|
110
|
+
[1, ComputeBudgetProgram.requestHeapFrame({ bytes: 256 * 1024 })]]) {
|
|
111
|
+
const matching = prefix.filter(ix => ix.programId.equals(ComputeBudgetProgram.programId) && ix.data[0] === tag);
|
|
112
|
+
if (matching.length > 1)
|
|
113
|
+
throw new Error("Duplicate compute budget instruction");
|
|
114
|
+
if (!matching.length)
|
|
115
|
+
prefix.unshift(instruction);
|
|
116
|
+
}
|
|
117
|
+
prefix.push(createAssociatedTokenAccountIdempotentInstruction(buyer, buyerCollateralAccount, buyer, r.collateral.assetMint, collateralTokenProgram), createAssociatedTokenAccountIdempotentInstruction(buyer, buyerDebtAccount, buyer, r.debt.assetMint, debtTokenProgram));
|
|
118
|
+
const context = { quote, session, repaymentVault, buyerCollateralAccount, buyerDebtAccount,
|
|
119
|
+
collateralMint: r.collateral.assetMint, debtMint: r.debt.assetMint, collateralTokenProgram, debtTokenProgram,
|
|
120
|
+
requiredPaymentCredit: BigInt(quote.payment.toString()) };
|
|
121
|
+
const route = [...await params.route(context)];
|
|
122
|
+
if (route.some(ix => ix.programId.equals(ComputeBudgetProgram.programId)))
|
|
123
|
+
throw new Error("Compute budgets must precede flash begin");
|
|
124
|
+
const beginIndex = prefix.length, settleIndex = beginIndex + 1 + route.length;
|
|
125
|
+
if (settleIndex > 65_535)
|
|
126
|
+
throw new RangeError("Too many instructions for the bound settle index");
|
|
127
|
+
const accounts = { market: r.market, futarchyAuthority: r.futarchyAuthority, buyer, targetMint: r.collateral.assetMint,
|
|
128
|
+
borrowedMint: r.debt.assetMint, targetReserve: r.collateral.reserveVault, borrowedReserve: r.debt.reserveVault,
|
|
129
|
+
buyerCollateralAccount, buyerRefundAccount: buyerDebtAccount,
|
|
130
|
+
tokenProgram: TOKEN_PROGRAM_ID, token2022Program: TOKEN_2022_PROGRAM_ID, borrowedTokenProgram: debtTokenProgram };
|
|
131
|
+
const common = { accounts, session, repaymentVault, instructions: SYSVAR_INSTRUCTIONS_PUBKEY };
|
|
132
|
+
const begin = await this.write.instruction("beginHlpFlash", {
|
|
133
|
+
targetAsset: r.target, allowFull: params.allowFull ?? false,
|
|
134
|
+
maxPayment: integerBN(params.maxPayment ?? BigInt(quote.payment.toString()), "maxPayment"),
|
|
135
|
+
maxCollateralDebit: integerBN(params.maxCollateralDebit ?? BigInt(quote.collateralDebit.toString()), "maxCollateralDebit"),
|
|
136
|
+
minCollateralCredit: integerBN(params.minCollateralCredit ?? BigInt(quote.collateralCredit.toString()), "minCollateralCredit"),
|
|
137
|
+
maxSocializedLoss: integerBN(params.maxSocializedLoss ?? 0xffffffffffffffffn, "maxSocializedLoss"), settleIndex,
|
|
138
|
+
}, { accounts: { ...common, systemProgram: SystemProgram.programId } });
|
|
139
|
+
const settle = await this.write.instruction("settleHlpFlash", [], { accounts: common,
|
|
140
|
+
remainingAccounts: params.settleRemainingAccounts ? [...params.settleRemainingAccounts] : await this.write.hlpRemainingAccounts(r.market, r.state) });
|
|
141
|
+
return { ...context, beginIndex, settleIndex, beginInstruction: begin, settleInstruction: settle,
|
|
142
|
+
exitInstruction: exit?.actionInstruction,
|
|
143
|
+
instructions: [...prefix, begin, ...route, settle, ...(exit ? [exit.actionInstruction] : [])] };
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=hlp-liquidation-client.js.map
|