@omnipair/dusk-sdk 2.0.1 → 2.16.0-next.20261102

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.
Files changed (192) hide show
  1. package/README.md +1085 -26
  2. package/dist/amounts.d.ts +9 -0
  3. package/dist/amounts.d.ts.map +1 -0
  4. package/dist/amounts.js +10 -0
  5. package/dist/amounts.js.map +1 -0
  6. package/dist/constants.d.ts +80 -33
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/constants.js +175 -64
  9. package/dist/constants.js.map +1 -1
  10. package/dist/delegate.d.ts +94 -0
  11. package/dist/delegate.d.ts.map +1 -0
  12. package/dist/delegate.js +131 -0
  13. package/dist/delegate.js.map +1 -0
  14. package/dist/dusk.d.ts +14 -0
  15. package/dist/dusk.d.ts.map +1 -1
  16. package/dist/dusk.js +22 -0
  17. package/dist/dusk.js.map +1 -1
  18. package/dist/get.d.ts +3285 -237
  19. package/dist/get.d.ts.map +1 -1
  20. package/dist/get.js +140 -71
  21. package/dist/get.js.map +1 -1
  22. package/dist/governance-client.d.ts +169 -0
  23. package/dist/governance-client.d.ts.map +1 -0
  24. package/dist/governance-client.js +146 -0
  25. package/dist/governance-client.js.map +1 -0
  26. package/dist/governance.d.ts +313 -0
  27. package/dist/governance.d.ts.map +1 -0
  28. package/dist/governance.js +902 -0
  29. package/dist/governance.js.map +1 -0
  30. package/dist/hash.d.ts +9 -0
  31. package/dist/hash.d.ts.map +1 -0
  32. package/dist/hash.js +16 -0
  33. package/dist/hash.js.map +1 -0
  34. package/dist/hlp-liquidation-client.d.ts +106 -0
  35. package/dist/hlp-liquidation-client.d.ts.map +1 -0
  36. package/dist/hlp-liquidation-client.js +150 -0
  37. package/dist/hlp-liquidation-client.js.map +1 -0
  38. package/dist/idl_delegate.d.ts +3 -0
  39. package/dist/idl_delegate.d.ts.map +1 -0
  40. package/dist/idl_delegate.js +3 -0
  41. package/dist/idl_delegate.js.map +1 -0
  42. package/dist/idl_delegate.json +6119 -0
  43. package/dist/idl_v2.json +18372 -6121
  44. package/dist/index.d.ts +23 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +23 -0
  47. package/dist/index.js.map +1 -1
  48. package/dist/interest-accounting.d.ts +49 -0
  49. package/dist/interest-accounting.d.ts.map +1 -0
  50. package/dist/interest-accounting.js +72 -0
  51. package/dist/interest-accounting.js.map +1 -0
  52. package/dist/leverage-actions.d.ts +122 -0
  53. package/dist/leverage-actions.d.ts.map +1 -0
  54. package/dist/leverage-actions.js +228 -0
  55. package/dist/leverage-actions.js.map +1 -0
  56. package/dist/leverage-margins.d.ts +12 -0
  57. package/dist/leverage-margins.d.ts.map +1 -0
  58. package/dist/leverage-margins.js +45 -0
  59. package/dist/leverage-margins.js.map +1 -0
  60. package/dist/leverage-preview.d.ts +587 -0
  61. package/dist/leverage-preview.d.ts.map +1 -0
  62. package/dist/leverage-preview.js +89 -0
  63. package/dist/leverage-preview.js.map +1 -0
  64. package/dist/liquidation-client.d.ts +230 -0
  65. package/dist/liquidation-client.d.ts.map +1 -0
  66. package/dist/liquidation-client.js +239 -0
  67. package/dist/liquidation-client.js.map +1 -0
  68. package/dist/liquidation.d.ts +78 -0
  69. package/dist/liquidation.d.ts.map +1 -0
  70. package/dist/liquidation.js +122 -0
  71. package/dist/liquidation.js.map +1 -0
  72. package/dist/lp-naming.d.ts +43 -0
  73. package/dist/lp-naming.d.ts.map +1 -0
  74. package/dist/lp-naming.js +81 -0
  75. package/dist/lp-naming.js.map +1 -0
  76. package/dist/lp-vanity.d.ts +33 -0
  77. package/dist/lp-vanity.d.ts.map +1 -0
  78. package/dist/lp-vanity.js +94 -0
  79. package/dist/lp-vanity.js.map +1 -0
  80. package/dist/market-bootstrap.d.ts +109 -0
  81. package/dist/market-bootstrap.d.ts.map +1 -0
  82. package/dist/market-bootstrap.js +158 -0
  83. package/dist/market-bootstrap.js.map +1 -0
  84. package/dist/market-launch.d.ts +45 -0
  85. package/dist/market-launch.d.ts.map +1 -0
  86. package/dist/market-launch.js +76 -0
  87. package/dist/market-launch.js.map +1 -0
  88. package/dist/oracle.d.ts +46 -0
  89. package/dist/oracle.d.ts.map +1 -0
  90. package/dist/oracle.js +103 -0
  91. package/dist/oracle.js.map +1 -0
  92. package/dist/preview.d.ts +39 -1
  93. package/dist/preview.d.ts.map +1 -1
  94. package/dist/preview.js +12 -0
  95. package/dist/preview.js.map +1 -1
  96. package/dist/protection.d.ts +48 -0
  97. package/dist/protection.d.ts.map +1 -0
  98. package/dist/protection.js +88 -0
  99. package/dist/protection.js.map +1 -0
  100. package/dist/referral.d.ts +28 -28
  101. package/dist/referral.d.ts.map +1 -1
  102. package/dist/referral.js +41 -33
  103. package/dist/referral.js.map +1 -1
  104. package/dist/risk-pricing.d.ts +14 -0
  105. package/dist/risk-pricing.d.ts.map +1 -0
  106. package/dist/risk-pricing.js +25 -0
  107. package/dist/risk-pricing.js.map +1 -0
  108. package/dist/simulation.d.ts +45 -0
  109. package/dist/simulation.d.ts.map +1 -0
  110. package/dist/simulation.js +106 -0
  111. package/dist/simulation.js.map +1 -0
  112. package/dist/tranche-client.d.ts +121 -0
  113. package/dist/tranche-client.d.ts.map +1 -0
  114. package/dist/tranche-client.js +185 -0
  115. package/dist/tranche-client.js.map +1 -0
  116. package/dist/transfer-fees.d.ts +46 -0
  117. package/dist/transfer-fees.d.ts.map +1 -0
  118. package/dist/transfer-fees.js +76 -0
  119. package/dist/transfer-fees.js.map +1 -0
  120. package/dist/type-aliases.d.ts +271 -30
  121. package/dist/type-aliases.d.ts.map +1 -1
  122. package/dist/types_delegate.d.ts +6126 -0
  123. package/dist/types_delegate.d.ts.map +1 -0
  124. package/dist/types_delegate.js +2 -0
  125. package/dist/types_delegate.js.map +1 -0
  126. package/dist/types_v2.d.ts +18105 -5854
  127. package/dist/types_v2.d.ts.map +1 -1
  128. package/dist/virtual-book/index.d.ts +4 -0
  129. package/dist/virtual-book/index.d.ts.map +1 -0
  130. package/dist/virtual-book/index.js +4 -0
  131. package/dist/virtual-book/index.js.map +1 -0
  132. package/dist/virtual-book/market.d.ts +608 -0
  133. package/dist/virtual-book/market.d.ts.map +1 -0
  134. package/dist/virtual-book/market.js +59 -0
  135. package/dist/virtual-book/market.js.map +1 -0
  136. package/dist/virtual-book/projection.d.ts +44 -0
  137. package/dist/virtual-book/projection.d.ts.map +1 -0
  138. package/dist/virtual-book/projection.js +229 -0
  139. package/dist/virtual-book/projection.js.map +1 -0
  140. package/dist/virtual-book/quotes.d.ts +1241 -0
  141. package/dist/virtual-book/quotes.d.ts.map +1 -0
  142. package/dist/virtual-book/quotes.js +233 -0
  143. package/dist/virtual-book/quotes.js.map +1 -0
  144. package/dist/write.d.ts +584 -14
  145. package/dist/write.d.ts.map +1 -1
  146. package/dist/write.js +1371 -47
  147. package/dist/write.js.map +1 -1
  148. package/dist/yield-client.d.ts +51 -0
  149. package/dist/yield-client.d.ts.map +1 -0
  150. package/dist/yield-client.js +98 -0
  151. package/dist/yield-client.js.map +1 -0
  152. package/package.json +9 -2
  153. package/src/amounts.ts +13 -0
  154. package/src/constants.ts +276 -111
  155. package/src/delegate.ts +238 -0
  156. package/src/dusk.ts +28 -0
  157. package/src/get.ts +267 -90
  158. package/src/governance-client.ts +234 -0
  159. package/src/governance.ts +1422 -0
  160. package/src/hash.ts +15 -0
  161. package/src/hlp-liquidation-client.ts +195 -0
  162. package/src/idl_delegate.json +6119 -0
  163. package/src/idl_delegate.ts +3 -0
  164. package/src/idl_v2.json +18372 -6121
  165. package/src/index.ts +31 -0
  166. package/src/interest-accounting.ts +85 -0
  167. package/src/leverage-actions.ts +216 -0
  168. package/src/leverage-margins.ts +48 -0
  169. package/src/leverage-preview.ts +86 -0
  170. package/src/liquidation-client.ts +297 -0
  171. package/src/liquidation.ts +137 -0
  172. package/src/lp-naming.ts +127 -0
  173. package/src/lp-vanity.ts +135 -0
  174. package/src/market-bootstrap.ts +273 -0
  175. package/src/market-launch.ts +103 -0
  176. package/src/oracle.ts +120 -0
  177. package/src/preview.ts +53 -1
  178. package/src/protection.ts +112 -0
  179. package/src/referral.ts +71 -71
  180. package/src/risk-pricing.ts +28 -0
  181. package/src/simulation.ts +169 -0
  182. package/src/tranche-client.ts +187 -0
  183. package/src/transfer-fees.ts +99 -0
  184. package/src/type-aliases.ts +280 -30
  185. package/src/types_delegate.ts +6125 -0
  186. package/src/types_v2.ts +18372 -6121
  187. package/src/virtual-book/index.ts +3 -0
  188. package/src/virtual-book/market.ts +76 -0
  189. package/src/virtual-book/projection.ts +265 -0
  190. package/src/virtual-book/quotes.ts +308 -0
  191. package/src/write.ts +2394 -67
  192. package/src/yield-client.ts +117 -0
@@ -0,0 +1,9 @@
1
+ import type { Market } from "./type-aliases.js";
2
+ /** Decimal precision of normalized quantities in this market (curve depth,
3
+ * hLP NAV/exposure, and debt/collateral values, including legacy `_nad` fields).
4
+ * Prices, interest rates, per-share ratios, and configured launch buy-size
5
+ * references remain scaled by 1e9.
6
+ * Token balances, deposits, withdrawals, fees, and debt amounts use raw atoms.
7
+ */
8
+ export declare function marketAmountDecimals(market: Pick<Market, "baseSide" | "quoteSide">): number;
9
+ //# sourceMappingURL=amounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amounts.d.ts","sourceRoot":"","sources":["../src/amounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC,GAC7C,MAAM,CAER"}
@@ -0,0 +1,10 @@
1
+ /** Decimal precision of normalized quantities in this market (curve depth,
2
+ * hLP NAV/exposure, and debt/collateral values, including legacy `_nad` fields).
3
+ * Prices, interest rates, per-share ratios, and configured launch buy-size
4
+ * references remain scaled by 1e9.
5
+ * Token balances, deposits, withdrawals, fees, and debt amounts use raw atoms.
6
+ */
7
+ export function marketAmountDecimals(market) {
8
+ return Math.max(9, market.baseSide.assetDecimals, market.quoteSide.assetDecimals);
9
+ }
10
+ //# sourceMappingURL=amounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amounts.js","sourceRoot":"","sources":["../src/amounts.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA8C;IAE9C,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;AACpF,CAAC"}
@@ -1,11 +1,29 @@
1
1
  import { AccountMeta, PublicKey } from "@solana/web3.js";
2
+ /** Shared on-chain default; regenerated from the program instead of duplicated here. */
3
+ export declare const DEFAULT_PROTOCOL_REVENUE_SHARE_BPS: number;
2
4
  /**
3
- * Omnipair Dusk (v2) program ID.
5
+ * Omnipair Dusk program ID.
4
6
  * Reads from env DUSK_PROGRAM_ID.
5
7
  */
6
8
  export declare const DUSK_PROGRAM_ID: PublicKey;
7
9
  export declare const PROGRAM_ID: PublicKey;
10
+ /** Current development Market account layout. */
11
+ export declare const MARKET_LAYOUT_VERSION: number;
8
12
  export declare const TOKEN_METADATA_PROGRAM_ID: PublicKey;
13
+ /** Direct-yLP parameter-governance constants. These values are immutable for Dusk market layout v1. */
14
+ export declare const GOVERNANCE_BPS_DENOMINATOR = 10000;
15
+ export declare const PARAMETER_PROPOSAL_SPONSOR_BPS = 100;
16
+ export declare const PARAMETER_PROPOSAL_SUPPORT_BPS = 5000;
17
+ export declare const PARAMETER_PROPOSAL_TIMELOCK_SECONDS: number;
18
+ export declare const PARAMETER_PROPOSAL_EXECUTION_WINDOW_SECONDS: number;
19
+ export declare const PARAMETER_EXECUTION_MAX_UTILIZATION_BPS = 8000;
20
+ export declare const PROPOSAL_METADATA_VERSION = 1;
21
+ export declare const MAX_PROPOSAL_TITLE_BYTES = 96;
22
+ export declare const MAX_PROPOSAL_DESCRIPTION_URI_BYTES = 200;
23
+ export declare const MAX_PROPOSAL_DESCRIPTION_BYTES = 32768;
24
+ export declare const DEFAULT_CONCENTRATION_RAMP_DURATION_SLOTS = 432000;
25
+ export declare const MIN_CONCENTRATION_RAMP_DURATION_SLOTS = 432000;
26
+ export declare const MAX_CONCENTRATION_RAMP_DURATION_SLOTS = 3024000;
9
27
  /**
10
28
  * PDA seeds used by the program
11
29
  */
@@ -13,27 +31,44 @@ export declare const SEEDS: {
13
31
  readonly MARKET_V2: Buffer<ArrayBuffer>;
14
32
  readonly MARKET_RESERVE_VAULT: Buffer<ArrayBuffer>;
15
33
  readonly MARKET_COLLATERAL_VAULT: Buffer<ArrayBuffer>;
16
- readonly MARKET_FEE_VAULT: Buffer<ArrayBuffer>;
17
34
  readonly MARKET_INTEREST_VAULT: Buffer<ArrayBuffer>;
18
35
  readonly BORROW_POSITION: Buffer<ArrayBuffer>;
19
36
  readonly LEVERAGE_POSITION: Buffer<ArrayBuffer>;
37
+ readonly LEVERAGE_COLLATERAL_VAULT: Buffer<ArrayBuffer>;
38
+ readonly LEVERAGE_DELEGATION: Buffer<ArrayBuffer>;
20
39
  readonly YIELD_ACCOUNT: Buffer<ArrayBuffer>;
21
40
  readonly HLP_YLP_VAULT: Buffer<ArrayBuffer>;
41
+ readonly HLP_COHORT: Buffer<ArrayBuffer>;
22
42
  readonly INSURANCE: Buffer<ArrayBuffer>;
43
+ readonly EVENT_AUTHORITY: Buffer<ArrayBuffer>;
23
44
  readonly FUTARCHY_AUTHORITY: Buffer<ArrayBuffer>;
24
- readonly REFERRAL_PROFILE: Buffer<ArrayBuffer>;
45
+ readonly REFERRAL_PARTNER: Buffer<ArrayBuffer>;
46
+ readonly REFERRAL_ACCRUAL: Buffer<ArrayBuffer>;
47
+ readonly PARAMETER_PROPOSAL: Buffer<ArrayBuffer>;
48
+ readonly PROPOSAL_SUPPORT: Buffer<ArrayBuffer>;
25
49
  readonly METADATA: Buffer<ArrayBuffer>;
26
50
  };
51
+ /** Derive the canonical Anchor event-CPI authority for a Dusk program. */
52
+ export declare function deriveEventAuthorityAddress(programId?: PublicKey): [PublicKey, number];
27
53
  /**
28
54
  * Derive Futarchy Authority PDA address
29
55
  */
30
- export declare function deriveFutarchyAuthorityAddress(): [PublicKey, number];
31
- /** Derive the protocol-wide referral profile for a referrer authority. */
32
- export declare function deriveReferralProfileAddress(authority: PublicKey): [PublicKey, number];
56
+ export declare function deriveFutarchyAuthorityAddress(programId?: PublicKey): [PublicKey, number];
57
+ /** Derive the protocol-wide referral partner for a referrer authority. */
58
+ export declare function deriveReferralPartnerAddress(authority: PublicKey): [PublicKey, number];
59
+ /** Derive claimable referral interest for one partner, market, and debt mint. */
60
+ export declare function deriveReferralAccrualAddress(referralPartner: PublicKey, market: PublicKey, assetMint: PublicKey, programId?: PublicKey): [PublicKey, number];
61
+ export type U64SeedLike = bigint | number | string | {
62
+ toString(): string;
63
+ };
64
+ /** Derive one immutable typed parameter proposal. The nonce is Borsh u64 LE. */
65
+ export declare function deriveParameterProposalAddress(market: PublicKey, proposer: PublicKey, nonce: U64SeedLike, programId?: PublicKey): [PublicKey, number];
66
+ /** Derive one support position. Locked yLP cannot be shared across proposals. */
67
+ export declare function deriveProposalSupportAddress(proposal: PublicKey, supporter: PublicKey, programId?: PublicKey): [PublicKey, number];
33
68
  /**
34
69
  * Derive Dusk market PDA address
35
70
  */
36
- export declare function deriveMarketAddress(baseMint: PublicKey, quoteMint: PublicKey, paramsHash: Uint8Array | Buffer | number[]): [PublicKey, number];
71
+ export declare function deriveMarketAddress(baseMint: PublicKey, quoteMint: PublicKey, paramsHash: Uint8Array | Buffer | number[], programId?: PublicKey): [PublicKey, number];
37
72
  /**
38
73
  * Derive a Metaplex Token Metadata PDA for a mint.
39
74
  */
@@ -45,11 +80,9 @@ export declare function deriveMarketReserveVaultAddress(market: PublicKey, reser
45
80
  /**
46
81
  * Derive market collateral vault PDA address
47
82
  */
83
+ /** Per-market collateral custody for leverage positions. */
84
+ export declare function deriveLeverageCollateralVaultAddress(market: PublicKey, collateralMint: PublicKey, programId?: PublicKey): [PublicKey, number];
48
85
  export declare function deriveMarketCollateralVaultAddress(market: PublicKey, collateralMint: PublicKey): [PublicKey, number];
49
- /**
50
- * Derive market fee vault PDA address
51
- */
52
- export declare function deriveMarketFeeVaultAddress(market: PublicKey, feeMint: PublicKey): [PublicKey, number];
53
86
  /**
54
87
  * Derive market interest vault PDA address
55
88
  */
@@ -57,39 +90,48 @@ export declare function deriveMarketInterestVaultAddress(market: PublicKey, inte
57
90
  /**
58
91
  * Derive borrow position PDA address
59
92
  */
60
- export declare function deriveBorrowPositionAddress(market: PublicKey, positionId: PublicKey): [PublicKey, number];
93
+ export declare function deriveBorrowPositionAddress(market: PublicKey, owner: PublicKey, positionId: PublicKey): [PublicKey, number];
61
94
  /**
62
95
  * Derive leverage position PDA address
63
96
  */
64
- export declare function deriveLeveragePositionAddress(market: PublicKey, positionId: PublicKey): [PublicKey, number];
65
- export type YieldTokenKind = "ylp" | "hlp" | 0 | 1;
97
+ /** Delegation is keyed by the position it delegates, not by the owner. */
98
+ export declare function deriveLeverageDelegationAddress(leveragePosition: PublicKey): [PublicKey, number];
99
+ export declare function deriveLeveragePositionAddress(market: PublicKey, positionOwner: PublicKey, positionId: PublicKey, namespaceAuthority?: PublicKey): [PublicKey, number];
100
+ export type YieldTokenKind = "ylp" | "hlp" | "junior" | 0 | 1 | 2;
66
101
  /**
67
102
  * Derive yield-account PDA address for yLP/hLP revenue checkpoints.
68
103
  */
69
- export declare function deriveYieldAccountAddress(market: PublicKey, owner: PublicKey, assetMint: PublicKey, tokenKind: YieldTokenKind): [PublicKey, number];
104
+ export declare function deriveYieldAccountAddress(market: PublicKey, owner: PublicKey, lpMint: PublicKey, assetMint: PublicKey, tokenKind: YieldTokenKind, programId?: PublicKey): [PublicKey, number];
70
105
  export interface YieldTransferHookAccountsArgs {
71
106
  lpMint: PublicKey;
72
107
  market: PublicKey;
73
108
  sourceOwner: PublicKey;
74
109
  destinationOwner: PublicKey;
75
- assetMint: PublicKey;
110
+ baseMint: PublicKey;
111
+ quoteMint: PublicKey;
76
112
  tokenKind: YieldTokenKind;
113
+ programId?: PublicKey;
77
114
  }
78
115
  export declare const TRANSFER_HOOK_EXECUTE_DISCRIMINATOR: Buffer<ArrayBuffer>;
79
- export interface YieldTransferHookValidationArgs {
80
- market: PublicKey;
81
- assetMint: PublicKey;
82
- tokenKind: YieldTokenKind;
83
- }
84
- export interface YlpTransferHookValidationArgs {
116
+ export interface LpTransferHookValidationArgs {
85
117
  market: PublicKey;
86
118
  baseMint: PublicKey;
87
119
  quoteMint: PublicKey;
120
+ tokenKind: YieldTokenKind;
121
+ /**
122
+ * Encode the seven-account layout of mints initialized before the event
123
+ * authority and Dusk program were added. Those mints publish no
124
+ * `LpTransferred` receipt.
125
+ */
126
+ legacyLayout?: boolean;
127
+ programId?: PublicKey;
88
128
  }
89
129
  /**
90
130
  * Derive the standard Token-2022 transfer-hook validation PDA for a Dusk LP mint.
91
131
  */
92
- export declare function deriveYieldTransferHookValidationAddress(lpMint: PublicKey): [PublicKey, number];
132
+ export declare function deriveYieldTransferHookValidationAddress(lpMint: PublicKey, programId?: PublicKey): [PublicKey, number];
133
+ /** Mint-specific hLP cohort; retired mints retain their frozen yield state. */
134
+ export declare function deriveHlpCohortAddress(market: PublicKey, hlpMint: PublicKey, programId?: PublicKey): [PublicKey, number];
93
135
  /**
94
136
  * Encode a static Token-2022 transfer-hook validation account for Execute.
95
137
  *
@@ -105,22 +147,20 @@ export declare function buildYieldTransferHookValidationAccountData(extraMetas:
105
147
  * source/destination YieldAccount PDAs from the source and destination token
106
148
  * account owners observed by Token-2022 during Execute.
107
149
  */
108
- export declare function buildYieldTransferHookYieldValidationAccountData({ market, assetMint, tokenKind, }: YieldTransferHookValidationArgs): Buffer;
109
- export declare function buildYlpTransferHookValidationAccountData({ market, baseMint, quoteMint, }: YlpTransferHookValidationArgs): Buffer;
150
+ export declare function buildLpTransferHookValidationAccountData({ market, baseMint, quoteMint, tokenKind, legacyLayout, programId, }: LpTransferHookValidationArgs): Buffer;
110
151
  /**
111
152
  * Build Dusk yLP/hLP transfer-hook extra account metas.
112
153
  *
113
154
  * Token-2022 passes the source token account, LP mint, destination token
114
- * account, and transfer authority as the base hook accounts. Omnipair Dusk (v2) needs
155
+ * account, and transfer authority as the base hook accounts. Omnipair Dusk needs
115
156
  * the market, underlying asset mint, canonical source/destination yield
116
157
  * accounts, hook program, and standard validation PDA as extra metas so the
117
- * hook can checkpoint revenue before the balance move is finalized.
158
+ * hook can checkpoint revenue before the balance move is finalized. The event
159
+ * authority lets the hook publish `LpTransferred`; Token-2022 ignores it for
160
+ * mints that still use the legacy seven-account layout, so the list works for
161
+ * both layouts.
118
162
  */
119
- export declare function buildYieldTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, assetMint, tokenKind, }: YieldTransferHookAccountsArgs): AccountMeta[];
120
- export declare function buildYlpTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, baseMint, quoteMint, }: Omit<YieldTransferHookAccountsArgs, "assetMint" | "tokenKind"> & {
121
- baseMint: PublicKey;
122
- quoteMint: PublicKey;
123
- }): AccountMeta[];
163
+ export declare function buildLpTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, baseMint, quoteMint, tokenKind, programId, }: YieldTransferHookAccountsArgs): AccountMeta[];
124
164
  /**
125
165
  * Derive canonical aggregate hLP vault yLP token-account PDA.
126
166
  */
@@ -128,5 +168,12 @@ export declare function deriveHlpYlpVaultAddress(market: PublicKey, targetHlpMin
128
168
  /**
129
169
  * Derive insurance PDA address
130
170
  */
131
- export declare function deriveInsuranceAddress(market: PublicKey, assetMint: PublicKey): [PublicKey, number];
171
+ export declare function deriveInsuranceAddress(market: PublicKey, assetMint: PublicKey, programId?: PublicKey): [PublicKey, number];
172
+ /** Owner- and LP-mint-specific reusable governance balance. */
173
+ export declare function deriveGovernanceBalanceAddress(market: PublicKey, owner: PublicKey, lpMint: PublicKey, programId?: PublicKey): [PublicKey, number];
174
+ export declare function deriveGovernanceSupportAddress(proposal: PublicKey, balance: PublicKey, programId?: PublicKey): [PublicKey, number];
175
+ export declare function deriveJuniorMintAddress(market: PublicKey, generation: U64SeedLike, programId?: PublicKey): [PublicKey, number];
176
+ export declare function deriveJuniorCohortAddress(market: PublicKey, mint: PublicKey, programId?: PublicKey): [PublicKey, number];
177
+ export declare function deriveJuniorExitAddress(market: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey): [PublicKey, number];
178
+ export declare function deriveIncomeEpochAddress(market: PublicKey, bookIndex: number, epoch: U64SeedLike, programId?: PublicKey): [PublicKey, number];
132
179
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAUzD;;;GAGG;AACH,eAAO,MAAM,eAAe,WAAyD,CAAC;AAEtF,eAAO,MAAM,UAAU,WAAkB,CAAC;AAC1C,eAAO,MAAM,yBAAyB,WAA+C,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;CAcR,CAAC;AAUX;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAEpE;AAED,0EAA0E;AAC1E,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAKtF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,EAAE,GACzC,CAAC,SAAS,EAAE,MAAM,CAAC,CAUrB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,SAAS,EAAE,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B,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAG9J"}
package/dist/constants.js CHANGED
@@ -1,5 +1,8 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
- const DEFAULT_PROGRAM_ID = "358bjJKXWxeAXAzteX1xTgyd9JNnjtzW8fnwCS8Da1mv";
2
+ import IDL from "./idl_v2.js";
3
+ /** Shared on-chain default; regenerated from the program instead of duplicated here. */
4
+ export const DEFAULT_PROTOCOL_REVENUE_SHARE_BPS = Number(IDL.constants.find(({ name }) => name === "DEFAULT_PROTOCOL_REVENUE_SHARE_BPS").value);
5
+ const DEFAULT_PROGRAM_ID = "5EuU8artxWthfER6GTUY52TfL1aRsQH2TH8DsdGCa8cJ";
3
6
  const MPL_TOKEN_METADATA_PROGRAM_ID = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s";
4
7
  function getProgramIdFromEnv(fallback) {
5
8
  if (typeof process === "undefined" || !process.env)
@@ -7,12 +10,30 @@ function getProgramIdFromEnv(fallback) {
7
10
  return process.env.DUSK_PROGRAM_ID ?? fallback;
8
11
  }
9
12
  /**
10
- * Omnipair Dusk (v2) program ID.
13
+ * Omnipair Dusk program ID.
11
14
  * Reads from env DUSK_PROGRAM_ID.
12
15
  */
13
16
  export const DUSK_PROGRAM_ID = new PublicKey(getProgramIdFromEnv(DEFAULT_PROGRAM_ID));
14
17
  export const PROGRAM_ID = DUSK_PROGRAM_ID;
18
+ /** Current development Market account layout. */
19
+ export const MARKET_LAYOUT_VERSION = Number(IDL.constants.find(({ name }) => name === "MARKET_LAYOUT_VERSION").value);
15
20
  export const TOKEN_METADATA_PROGRAM_ID = new PublicKey(MPL_TOKEN_METADATA_PROGRAM_ID);
21
+ /** Direct-yLP parameter-governance constants. These values are immutable for Dusk market layout v1. */
22
+ export const GOVERNANCE_BPS_DENOMINATOR = 10_000;
23
+ export const PARAMETER_PROPOSAL_SPONSOR_BPS = 100;
24
+ export const PARAMETER_PROPOSAL_SUPPORT_BPS = 5_000;
25
+ export const PARAMETER_PROPOSAL_TIMELOCK_SECONDS = 7 * 24 * 60 * 60;
26
+ export const PARAMETER_PROPOSAL_EXECUTION_WINDOW_SECONDS = 7 * 24 * 60 * 60;
27
+ export const PARAMETER_EXECUTION_MAX_UTILIZATION_BPS = 8_000;
28
+ export const PROPOSAL_METADATA_VERSION = 1;
29
+ export const MAX_PROPOSAL_TITLE_BYTES = 96;
30
+ export const MAX_PROPOSAL_DESCRIPTION_URI_BYTES = 200;
31
+ export const MAX_PROPOSAL_DESCRIPTION_BYTES = 32_768;
32
+ // Nominal 1-7 day ramp at Solana's current 200 ms scheduled slot cadence.
33
+ // Update with the on-chain timing constant if the network cadence changes.
34
+ export const DEFAULT_CONCENTRATION_RAMP_DURATION_SLOTS = 432_000;
35
+ export const MIN_CONCENTRATION_RAMP_DURATION_SLOTS = 432_000;
36
+ export const MAX_CONCENTRATION_RAMP_DURATION_SLOTS = 3_024_000;
16
37
  /**
17
38
  * PDA seeds used by the program
18
39
  */
@@ -20,17 +41,27 @@ export const SEEDS = {
20
41
  MARKET_V2: Buffer.from("market_v2"),
21
42
  MARKET_RESERVE_VAULT: Buffer.from("market_reserve"),
22
43
  MARKET_COLLATERAL_VAULT: Buffer.from("market_collateral"),
23
- MARKET_FEE_VAULT: Buffer.from("market_fee"),
24
44
  MARKET_INTEREST_VAULT: Buffer.from("market_interest"),
25
45
  BORROW_POSITION: Buffer.from("borrow_position_v2"),
26
46
  LEVERAGE_POSITION: Buffer.from("leverage_position_v2"),
47
+ LEVERAGE_COLLATERAL_VAULT: Buffer.from("leverage_collateral"),
48
+ LEVERAGE_DELEGATION: Buffer.from("leverage_delegation_v2"),
27
49
  YIELD_ACCOUNT: Buffer.from("yield"),
28
50
  HLP_YLP_VAULT: Buffer.from("hlp_ylp_vault"),
51
+ HLP_COHORT: Buffer.from("hlp_cohort"),
29
52
  INSURANCE: Buffer.from("insurance"),
53
+ EVENT_AUTHORITY: Buffer.from("__event_authority"),
30
54
  FUTARCHY_AUTHORITY: Buffer.from("futarchy_authority"),
31
- REFERRAL_PROFILE: Buffer.from("referral_profile"),
55
+ REFERRAL_PARTNER: Buffer.from("referral_partner"),
56
+ REFERRAL_ACCRUAL: Buffer.from("referral_accrual"),
57
+ PARAMETER_PROPOSAL: Buffer.from("parameter_proposal"),
58
+ PROPOSAL_SUPPORT: Buffer.from("proposal_support"),
32
59
  METADATA: Buffer.from("metadata"),
33
60
  };
61
+ /** Derive the canonical Anchor event-CPI authority for a Dusk program. */
62
+ export function deriveEventAuthorityAddress(programId = DUSK_PROGRAM_ID) {
63
+ return PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId);
64
+ }
34
65
  function normalizeParamsHash(paramsHash) {
35
66
  const hash = Buffer.from(paramsHash);
36
67
  if (hash.length !== 32) {
@@ -41,23 +72,58 @@ function normalizeParamsHash(paramsHash) {
41
72
  /**
42
73
  * Derive Futarchy Authority PDA address
43
74
  */
44
- export function deriveFutarchyAuthorityAddress() {
45
- return PublicKey.findProgramAddressSync([SEEDS.FUTARCHY_AUTHORITY], DUSK_PROGRAM_ID);
75
+ export function deriveFutarchyAuthorityAddress(programId = DUSK_PROGRAM_ID) {
76
+ return PublicKey.findProgramAddressSync([SEEDS.FUTARCHY_AUTHORITY], programId);
77
+ }
78
+ /** Derive the protocol-wide referral partner for a referrer authority. */
79
+ export function deriveReferralPartnerAddress(authority) {
80
+ return PublicKey.findProgramAddressSync([SEEDS.REFERRAL_PARTNER, authority.toBuffer()], DUSK_PROGRAM_ID);
81
+ }
82
+ /** Derive claimable referral interest for one partner, market, and debt mint. */
83
+ export function deriveReferralAccrualAddress(referralPartner, market, assetMint, programId = DUSK_PROGRAM_ID) {
84
+ return PublicKey.findProgramAddressSync([
85
+ SEEDS.REFERRAL_ACCRUAL,
86
+ referralPartner.toBuffer(),
87
+ market.toBuffer(),
88
+ assetMint.toBuffer(),
89
+ ], programId);
90
+ }
91
+ function u64Seed(value, label) {
92
+ if (typeof value === "number" && !Number.isSafeInteger(value)) {
93
+ throw new Error(`${label} must be a safe integer when supplied as a number`);
94
+ }
95
+ let normalized;
96
+ try {
97
+ normalized = BigInt(value.toString());
98
+ }
99
+ catch {
100
+ throw new Error(`${label} must be an unsigned 64-bit integer`);
101
+ }
102
+ if (normalized < 0n || normalized > 0xffffffffffffffffn) {
103
+ throw new Error(`${label} must be an unsigned 64-bit integer`);
104
+ }
105
+ const encoded = Buffer.alloc(8);
106
+ encoded.writeBigUInt64LE(normalized);
107
+ return encoded;
108
+ }
109
+ /** Derive one immutable typed parameter proposal. The nonce is Borsh u64 LE. */
110
+ export function deriveParameterProposalAddress(market, proposer, nonce, programId = DUSK_PROGRAM_ID) {
111
+ return PublicKey.findProgramAddressSync([SEEDS.PARAMETER_PROPOSAL, market.toBuffer(), proposer.toBuffer(), u64Seed(nonce, "nonce")], programId);
46
112
  }
47
- /** Derive the protocol-wide referral profile for a referrer authority. */
48
- export function deriveReferralProfileAddress(authority) {
49
- return PublicKey.findProgramAddressSync([SEEDS.REFERRAL_PROFILE, authority.toBuffer()], DUSK_PROGRAM_ID);
113
+ /** Derive one support position. Locked yLP cannot be shared across proposals. */
114
+ export function deriveProposalSupportAddress(proposal, supporter, programId = DUSK_PROGRAM_ID) {
115
+ return PublicKey.findProgramAddressSync([SEEDS.PROPOSAL_SUPPORT, proposal.toBuffer(), supporter.toBuffer()], programId);
50
116
  }
51
117
  /**
52
118
  * Derive Dusk market PDA address
53
119
  */
54
- export function deriveMarketAddress(baseMint, quoteMint, paramsHash) {
120
+ export function deriveMarketAddress(baseMint, quoteMint, paramsHash, programId = DUSK_PROGRAM_ID) {
55
121
  return PublicKey.findProgramAddressSync([
56
122
  SEEDS.MARKET_V2,
57
123
  baseMint.toBuffer(),
58
124
  quoteMint.toBuffer(),
59
125
  normalizeParamsHash(paramsHash),
60
- ], DUSK_PROGRAM_ID);
126
+ ], programId);
61
127
  }
62
128
  /**
63
129
  * Derive a Metaplex Token Metadata PDA for a mint.
@@ -74,15 +140,13 @@ export function deriveMarketReserveVaultAddress(market, reserveMint) {
74
140
  /**
75
141
  * Derive market collateral vault PDA address
76
142
  */
143
+ /** Per-market collateral custody for leverage positions. */
144
+ export function deriveLeverageCollateralVaultAddress(market, collateralMint, programId = DUSK_PROGRAM_ID) {
145
+ return PublicKey.findProgramAddressSync([SEEDS.LEVERAGE_COLLATERAL_VAULT, market.toBuffer(), collateralMint.toBuffer()], programId);
146
+ }
77
147
  export function deriveMarketCollateralVaultAddress(market, collateralMint) {
78
148
  return PublicKey.findProgramAddressSync([SEEDS.MARKET_COLLATERAL_VAULT, market.toBuffer(), collateralMint.toBuffer()], DUSK_PROGRAM_ID);
79
149
  }
80
- /**
81
- * Derive market fee vault PDA address
82
- */
83
- export function deriveMarketFeeVaultAddress(market, feeMint) {
84
- return PublicKey.findProgramAddressSync([SEEDS.MARKET_FEE_VAULT, market.toBuffer(), feeMint.toBuffer()], DUSK_PROGRAM_ID);
85
- }
86
150
  /**
87
151
  * Derive market interest vault PDA address
88
152
  */
@@ -92,33 +156,46 @@ export function deriveMarketInterestVaultAddress(market, interestMint) {
92
156
  /**
93
157
  * Derive borrow position PDA address
94
158
  */
95
- export function deriveBorrowPositionAddress(market, positionId) {
96
- return PublicKey.findProgramAddressSync([SEEDS.BORROW_POSITION, market.toBuffer(), positionId.toBuffer()], DUSK_PROGRAM_ID);
159
+ export function deriveBorrowPositionAddress(market, owner, positionId) {
160
+ return PublicKey.findProgramAddressSync([SEEDS.BORROW_POSITION, market.toBuffer(), owner.toBuffer(), positionId.toBuffer()], DUSK_PROGRAM_ID);
97
161
  }
98
162
  /**
99
163
  * Derive leverage position PDA address
100
164
  */
101
- export function deriveLeveragePositionAddress(market, positionId) {
102
- return PublicKey.findProgramAddressSync([SEEDS.LEVERAGE_POSITION, market.toBuffer(), positionId.toBuffer()], DUSK_PROGRAM_ID);
165
+ /** Delegation is keyed by the position it delegates, not by the owner. */
166
+ export function deriveLeverageDelegationAddress(leveragePosition) {
167
+ return PublicKey.findProgramAddressSync([SEEDS.LEVERAGE_DELEGATION, leveragePosition.toBuffer()], DUSK_PROGRAM_ID);
168
+ }
169
+ export function deriveLeveragePositionAddress(market, positionOwner, positionId, namespaceAuthority = positionOwner) {
170
+ return PublicKey.findProgramAddressSync([
171
+ SEEDS.LEVERAGE_POSITION,
172
+ market.toBuffer(),
173
+ positionOwner.toBuffer(),
174
+ namespaceAuthority.toBuffer(),
175
+ positionId.toBuffer(),
176
+ ], DUSK_PROGRAM_ID);
103
177
  }
104
178
  function yieldTokenKindCode(tokenKind) {
105
179
  if (tokenKind === "ylp" || tokenKind === 0)
106
180
  return 0;
107
181
  if (tokenKind === "hlp" || tokenKind === 1)
108
182
  return 1;
183
+ if (tokenKind === "junior" || tokenKind === 2)
184
+ return 2;
109
185
  throw new Error(`Unsupported yield token kind: ${tokenKind}`);
110
186
  }
111
187
  /**
112
188
  * Derive yield-account PDA address for yLP/hLP revenue checkpoints.
113
189
  */
114
- export function deriveYieldAccountAddress(market, owner, assetMint, tokenKind) {
190
+ export function deriveYieldAccountAddress(market, owner, lpMint, assetMint, tokenKind, programId = DUSK_PROGRAM_ID) {
115
191
  return PublicKey.findProgramAddressSync([
116
192
  SEEDS.YIELD_ACCOUNT,
117
193
  market.toBuffer(),
118
194
  owner.toBuffer(),
195
+ lpMint.toBuffer(),
119
196
  assetMint.toBuffer(),
120
197
  Buffer.from([yieldTokenKindCode(tokenKind)]),
121
- ], DUSK_PROGRAM_ID);
198
+ ], programId);
122
199
  }
123
200
  export const TRANSFER_HOOK_EXECUTE_DISCRIMINATOR = Buffer.from([
124
201
  105, 37, 101, 197, 75, 251, 102, 26,
@@ -133,8 +210,12 @@ const TRANSFER_HOOK_QUOTE_ASSET_MINT_ACCOUNT_INDEX = 7;
133
210
  /**
134
211
  * Derive the standard Token-2022 transfer-hook validation PDA for a Dusk LP mint.
135
212
  */
136
- export function deriveYieldTransferHookValidationAddress(lpMint) {
137
- return PublicKey.findProgramAddressSync([Buffer.from("extra-account-metas"), lpMint.toBuffer()], DUSK_PROGRAM_ID);
213
+ export function deriveYieldTransferHookValidationAddress(lpMint, programId = DUSK_PROGRAM_ID) {
214
+ return PublicKey.findProgramAddressSync([Buffer.from("extra-account-metas"), lpMint.toBuffer()], programId);
215
+ }
216
+ /** Mint-specific hLP cohort; retired mints retain their frozen yield state. */
217
+ export function deriveHlpCohortAddress(market, hlpMint, programId = DUSK_PROGRAM_ID) {
218
+ return PublicKey.findProgramAddressSync([SEEDS.HLP_COHORT, market.toBuffer(), hlpMint.toBuffer()], programId);
138
219
  }
139
220
  function assertU8(value, label) {
140
221
  if (!Number.isInteger(value) || value < 0 || value > 255) {
@@ -211,6 +292,7 @@ function yieldAccountTransferHookSeeds(ownerTokenAccountIndex, tokenKind, assetM
211
292
  dataIndex: TRANSFER_HOOK_TOKEN_ACCOUNT_OWNER_OFFSET,
212
293
  length: 32,
213
294
  },
295
+ { kind: "accountKey", index: 1 },
214
296
  { kind: "accountKey", index: assetMintAccountIndex },
215
297
  { kind: "literal", bytes: [yieldTokenKindCode(tokenKind)] },
216
298
  ];
@@ -251,62 +333,70 @@ export function buildYieldTransferHookValidationAccountData(extraMetas) {
251
333
  * source/destination YieldAccount PDAs from the source and destination token
252
334
  * account owners observed by Token-2022 during Execute.
253
335
  */
254
- export function buildYieldTransferHookYieldValidationAccountData({ market, assetMint, tokenKind, }) {
255
- return encodeTransferHookValidationAccountData([
256
- staticTransferHookMeta({ pubkey: market, isSigner: false, isWritable: false }),
257
- staticTransferHookMeta({ pubkey: assetMint, isSigner: false, isWritable: false }),
258
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_SOURCE_ACCOUNT_INDEX, tokenKind), true),
259
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_DESTINATION_ACCOUNT_INDEX, tokenKind), true),
260
- ]);
261
- }
262
- export function buildYlpTransferHookValidationAccountData({ market, baseMint, quoteMint, }) {
336
+ export function buildLpTransferHookValidationAccountData({ market, baseMint, quoteMint, tokenKind, legacyLayout = false, programId = DUSK_PROGRAM_ID, }) {
337
+ const eventMetas = legacyLayout
338
+ ? []
339
+ : [
340
+ staticTransferHookMeta({
341
+ pubkey: deriveEventAuthorityAddress(programId)[0],
342
+ isSigner: false,
343
+ isWritable: false,
344
+ }),
345
+ staticTransferHookMeta({ pubkey: programId, isSigner: false, isWritable: false }),
346
+ ];
263
347
  return encodeTransferHookValidationAccountData([
264
- staticTransferHookMeta({ pubkey: market, isSigner: false, isWritable: false }),
348
+ staticTransferHookMeta({ pubkey: market, isSigner: false, isWritable: true }),
265
349
  staticTransferHookMeta({ pubkey: baseMint, isSigner: false, isWritable: false }),
266
350
  staticTransferHookMeta({ pubkey: quoteMint, isSigner: false, isWritable: false }),
267
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_SOURCE_ACCOUNT_INDEX, "ylp"), true),
268
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_DESTINATION_ACCOUNT_INDEX, "ylp"), true),
269
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_SOURCE_ACCOUNT_INDEX, "ylp", TRANSFER_HOOK_QUOTE_ASSET_MINT_ACCOUNT_INDEX), true),
270
- pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_DESTINATION_ACCOUNT_INDEX, "ylp", TRANSFER_HOOK_QUOTE_ASSET_MINT_ACCOUNT_INDEX), true),
351
+ pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_SOURCE_ACCOUNT_INDEX, tokenKind), true),
352
+ pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_DESTINATION_ACCOUNT_INDEX, tokenKind), true),
353
+ pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_SOURCE_ACCOUNT_INDEX, tokenKind, TRANSFER_HOOK_QUOTE_ASSET_MINT_ACCOUNT_INDEX), true),
354
+ pdaTransferHookMeta(yieldAccountTransferHookSeeds(TRANSFER_HOOK_DESTINATION_ACCOUNT_INDEX, tokenKind, TRANSFER_HOOK_QUOTE_ASSET_MINT_ACCOUNT_INDEX), true),
355
+ ...eventMetas,
356
+ ...(yieldTokenKindCode(tokenKind) === 1 && !legacyLayout
357
+ ? [
358
+ pdaTransferHookMeta([
359
+ { kind: "literal", bytes: SEEDS.HLP_COHORT },
360
+ { kind: "accountKey", index: TRANSFER_HOOK_MARKET_ACCOUNT_INDEX },
361
+ { kind: "accountKey", index: 1 },
362
+ ], false),
363
+ ]
364
+ : []),
271
365
  ]);
272
366
  }
273
367
  /**
274
368
  * Build Dusk yLP/hLP transfer-hook extra account metas.
275
369
  *
276
370
  * Token-2022 passes the source token account, LP mint, destination token
277
- * account, and transfer authority as the base hook accounts. Omnipair Dusk (v2) needs
371
+ * account, and transfer authority as the base hook accounts. Omnipair Dusk needs
278
372
  * the market, underlying asset mint, canonical source/destination yield
279
373
  * accounts, hook program, and standard validation PDA as extra metas so the
280
- * hook can checkpoint revenue before the balance move is finalized.
374
+ * hook can checkpoint revenue before the balance move is finalized. The event
375
+ * authority lets the hook publish `LpTransferred`; Token-2022 ignores it for
376
+ * mints that still use the legacy seven-account layout, so the list works for
377
+ * both layouts.
281
378
  */
282
- export function buildYieldTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, assetMint, tokenKind, }) {
283
- const sourceYieldAccount = deriveYieldAccountAddress(market, sourceOwner, assetMint, tokenKind)[0];
284
- const destinationYieldAccount = deriveYieldAccountAddress(market, destinationOwner, assetMint, tokenKind)[0];
285
- const validationAccount = deriveYieldTransferHookValidationAddress(lpMint)[0];
379
+ export function buildLpTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, baseMint, quoteMint, tokenKind, programId = DUSK_PROGRAM_ID, }) {
380
+ const sourceBaseYieldAccount = deriveYieldAccountAddress(market, sourceOwner, lpMint, baseMint, tokenKind, programId)[0];
381
+ const destinationBaseYieldAccount = deriveYieldAccountAddress(market, destinationOwner, lpMint, baseMint, tokenKind, programId)[0];
382
+ const sourceQuoteYieldAccount = deriveYieldAccountAddress(market, sourceOwner, lpMint, quoteMint, tokenKind, programId)[0];
383
+ const destinationQuoteYieldAccount = deriveYieldAccountAddress(market, destinationOwner, lpMint, quoteMint, tokenKind, programId)[0];
384
+ const validationAccount = deriveYieldTransferHookValidationAddress(lpMint, programId)[0];
286
385
  return [
287
- { pubkey: market, isSigner: false, isWritable: false },
288
- { pubkey: assetMint, isSigner: false, isWritable: false },
289
- { pubkey: sourceYieldAccount, isSigner: false, isWritable: true },
290
- { pubkey: destinationYieldAccount, isSigner: false, isWritable: true },
291
- { pubkey: DUSK_PROGRAM_ID, isSigner: false, isWritable: false },
292
- { pubkey: validationAccount, isSigner: false, isWritable: false },
293
- ];
294
- }
295
- export function buildYlpTransferHookAccountMetas({ lpMint, market, sourceOwner, destinationOwner, baseMint, quoteMint, }) {
296
- const sourceBaseYieldAccount = deriveYieldAccountAddress(market, sourceOwner, baseMint, "ylp")[0];
297
- const destinationBaseYieldAccount = deriveYieldAccountAddress(market, destinationOwner, baseMint, "ylp")[0];
298
- const sourceQuoteYieldAccount = deriveYieldAccountAddress(market, sourceOwner, quoteMint, "ylp")[0];
299
- const destinationQuoteYieldAccount = deriveYieldAccountAddress(market, destinationOwner, quoteMint, "ylp")[0];
300
- const validationAccount = deriveYieldTransferHookValidationAddress(lpMint)[0];
301
- return [
302
- { pubkey: market, isSigner: false, isWritable: false },
386
+ { pubkey: market, isSigner: false, isWritable: true },
303
387
  { pubkey: baseMint, isSigner: false, isWritable: false },
304
388
  { pubkey: quoteMint, isSigner: false, isWritable: false },
305
389
  { pubkey: sourceBaseYieldAccount, isSigner: false, isWritable: true },
306
390
  { pubkey: destinationBaseYieldAccount, isSigner: false, isWritable: true },
307
391
  { pubkey: sourceQuoteYieldAccount, isSigner: false, isWritable: true },
308
392
  { pubkey: destinationQuoteYieldAccount, isSigner: false, isWritable: true },
309
- { pubkey: DUSK_PROGRAM_ID, isSigner: false, isWritable: false },
393
+ { pubkey: deriveEventAuthorityAddress(programId)[0], isSigner: false, isWritable: false },
394
+ { pubkey: programId, isSigner: false, isWritable: false },
395
+ ...(yieldTokenKindCode(tokenKind) === 1
396
+ ? [{ pubkey: deriveHlpCohortAddress(market, lpMint, programId)[0], isSigner: false, isWritable: false }]
397
+ : yieldTokenKindCode(tokenKind) === 2
398
+ ? [{ pubkey: deriveJuniorCohortAddress(market, lpMint, programId)[0], isSigner: false, isWritable: false }]
399
+ : []),
310
400
  { pubkey: validationAccount, isSigner: false, isWritable: false },
311
401
  ];
312
402
  }
@@ -324,7 +414,28 @@ export function deriveHlpYlpVaultAddress(market, targetHlpMint, ylpMint) {
324
414
  /**
325
415
  * Derive insurance PDA address
326
416
  */
327
- export function deriveInsuranceAddress(market, assetMint) {
328
- return PublicKey.findProgramAddressSync([SEEDS.INSURANCE, market.toBuffer(), assetMint.toBuffer()], DUSK_PROGRAM_ID);
417
+ export function deriveInsuranceAddress(market, assetMint, programId = DUSK_PROGRAM_ID) {
418
+ return PublicKey.findProgramAddressSync([SEEDS.INSURANCE, market.toBuffer(), assetMint.toBuffer()], programId);
419
+ }
420
+ /** Owner- and LP-mint-specific reusable governance balance. */
421
+ export function deriveGovernanceBalanceAddress(market, owner, lpMint, programId = DUSK_PROGRAM_ID) {
422
+ return PublicKey.findProgramAddressSync([Buffer.from("governance_balance"), market.toBuffer(), owner.toBuffer(), lpMint.toBuffer()], programId);
423
+ }
424
+ export function deriveGovernanceSupportAddress(proposal, balance, programId = DUSK_PROGRAM_ID) {
425
+ return PublicKey.findProgramAddressSync([Buffer.from("governance_support"), proposal.toBuffer(), balance.toBuffer()], programId);
426
+ }
427
+ export function deriveJuniorMintAddress(market, generation, programId = DUSK_PROGRAM_ID) {
428
+ return PublicKey.findProgramAddressSync([Buffer.from("junior_mint"), market.toBuffer(), u64Seed(generation, "generation")], programId);
429
+ }
430
+ export function deriveJuniorCohortAddress(market, mint, programId = DUSK_PROGRAM_ID) {
431
+ return PublicKey.findProgramAddressSync([Buffer.from("junior_cohort"), market.toBuffer(), mint.toBuffer()], programId);
432
+ }
433
+ export function deriveJuniorExitAddress(market, owner, mint, programId = DUSK_PROGRAM_ID) {
434
+ return PublicKey.findProgramAddressSync([Buffer.from("junior_exit"), market.toBuffer(), owner.toBuffer(), mint.toBuffer()], programId);
435
+ }
436
+ export function deriveIncomeEpochAddress(market, bookIndex, epoch, programId = DUSK_PROGRAM_ID) {
437
+ if (!Number.isInteger(bookIndex) || bookIndex < 0 || bookIndex > 3)
438
+ throw new Error("bookIndex must be 0–3");
439
+ return PublicKey.findProgramAddressSync([Buffer.from("income_epoch"), market.toBuffer(), Buffer.from([bookIndex]), u64Seed(epoch, "epoch")], programId);
329
440
  }
330
441
  //# sourceMappingURL=constants.js.map