@interest-protocol/blast-migrators-sdk 0.1.2 → 0.2.0

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 (46) hide show
  1. package/dist/aborts.d.ts +12 -0
  2. package/dist/aborts.d.ts.map +1 -0
  3. package/dist/aborts.js +21 -0
  4. package/dist/aborts.js.map +1 -0
  5. package/dist/client.d.ts +8 -11
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +12 -14
  8. package/dist/client.js.map +1 -1
  9. package/dist/events.d.ts +30 -160
  10. package/dist/events.d.ts.map +1 -1
  11. package/dist/events.js +33 -168
  12. package/dist/events.js.map +1 -1
  13. package/dist/index.d.ts +1 -3
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +1 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/reducer.d.ts +20 -132
  18. package/dist/reducer.d.ts.map +1 -1
  19. package/dist/reducer.js +28 -361
  20. package/dist/reducer.js.map +1 -1
  21. package/dist/state.d.ts +32 -152
  22. package/dist/state.d.ts.map +1 -1
  23. package/dist/state.js +61 -167
  24. package/dist/state.js.map +1 -1
  25. package/dist/transactions.d.ts +204 -259
  26. package/dist/transactions.d.ts.map +1 -1
  27. package/dist/transactions.js +347 -449
  28. package/dist/transactions.js.map +1 -1
  29. package/package.json +7 -10
  30. package/src/aborts.ts +24 -0
  31. package/src/client.ts +19 -34
  32. package/src/events.ts +54 -261
  33. package/src/index.ts +1 -3
  34. package/src/reducer.ts +46 -538
  35. package/src/state.ts +88 -282
  36. package/src/transactions.ts +569 -838
  37. package/dist/bluefin-pool.d.ts +0 -57
  38. package/dist/bluefin-pool.d.ts.map +0 -1
  39. package/dist/bluefin-pool.js +0 -102
  40. package/dist/bluefin-pool.js.map +0 -1
  41. package/dist/cetus-pool.d.ts +0 -44
  42. package/dist/cetus-pool.d.ts.map +0 -1
  43. package/dist/cetus-pool.js +0 -57
  44. package/dist/cetus-pool.js.map +0 -1
  45. package/src/bluefin-pool.ts +0 -180
  46. package/src/cetus-pool.ts +0 -107
@@ -1,599 +1,489 @@
1
+ import { AdminCalls } from "@interest-protocol/blast-admin-sdk/transactions";
2
+ import { cetusMemeSide } from "@interest-protocol/blast-core/cetus";
1
3
  import { grossGasBudget } from "@interest-protocol/blast-core/gas";
2
- import { requirePositiveU64, requireU64, } from "@interest-protocol/blast-core/integers";
3
- import { deploymentObject, moveResults, } from "@interest-protocol/blast-core/ptb";
4
- import { MIGRATOR_REWARD_LEAF_DOMAIN, rewardAddress, rewardDigest, validateRewardManifest, } from "@interest-protocol/blast-core/rewards/allocations";
5
- import { normalizeSharedObjectIdentity, normalizeSharedObjectReference, normalizeSuiPackageReference, } from "@interest-protocol/blast-core/sui";
6
- import { addLaunchCompletion, LaunchpadCalls, normalizeLaunchTypes, } from "@interest-protocol/blast-launchpad-sdk/transactions";
4
+ import { requirePositiveU64, requireU64, requireU128, } from "@interest-protocol/blast-core/integers";
5
+ import { deploymentObject } from "@interest-protocol/blast-core/ptb";
6
+ import { coreRoleType } from "@interest-protocol/blast-core/roles";
7
+ import { normalizeSharedObjectIdentity, normalizeSuiPackageReference, } from "@interest-protocol/blast-core/sui";
8
+ import { normalizeVaultDeployment } from "@interest-protocol/blast-vault-sdk/transactions";
7
9
  import { Transaction } from "@mysten/sui/transactions";
8
- import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
9
- /** Maximum Merkle proof depth the holder-reward leaf count (65,536) allows. */
10
- export const MAX_HOLDER_REWARD_PROOF_DEPTH = 16;
10
+ import { normalizeStructTag } from "@mysten/sui/utils";
11
+ /** The venues `blast_migrators` defines, one module each. */
12
+ export const MIGRATOR_VENUES = ["bluefin", "cetus"];
13
+ /** `constants::bluefin_max_tick_spacing`: Bluefin pool creation's own bound. */
14
+ export const BLUEFIN_MAX_TICK_SPACING = 400;
15
+ /** `constants::bluefin_max_fee_rate`: Bluefin pool creation's own bound (1,000,000 is 100%). */
16
+ export const BLUEFIN_MAX_FEE_RATE = 20000n;
17
+ export function normalizeMigratorsDeployment(deployment) {
18
+ return {
19
+ ...normalizeSuiPackageReference("migrators", deployment),
20
+ packageVersion: normalizeSharedObjectIdentity("migrators.packageVersion", deployment.packageVersion),
21
+ packageAdmin: normalizeSharedObjectIdentity("migrators.packageAdmin", deployment.packageAdmin),
22
+ venueConfig: normalizeSharedObjectIdentity("migrators.venueConfig", deployment.venueConfig),
23
+ vault: normalizeVaultDeployment(deployment.vault),
24
+ };
25
+ }
26
+ /**
27
+ * `<migrators original>::<venue>::Venue`: the witness a venue seals tickets
28
+ * and redeems migrations under, and that a product and the vault registry
29
+ * admit.
30
+ */
31
+ export function venueWitnessType(migrators, venue) {
32
+ if (!MIGRATOR_VENUES.includes(venue))
33
+ throw new TypeError(`unknown migrators venue ${String(venue)}`);
34
+ return normalizeStructTag(`${migrators.originalPackageId}::${venue}::Venue`);
35
+ }
36
+ /**
37
+ * The migrators venue a `Launch.venue` or `Presale.venue` `TypeName`
38
+ * (original-ID form) names, or null for any other venue.
39
+ */
40
+ export function venueOf(migrators, typeName) {
41
+ const type = normalizeStructTag(typeName);
42
+ return (MIGRATOR_VENUES.find((venue) => venueWitnessType(migrators, venue) === type) ?? null);
43
+ }
44
+ /**
45
+ * `blast_migrators` venue calls, in Move argument order; `&mut TxContext` is
46
+ * implicit and the `Clock` is `0x6`. The migrators and vault package
47
+ * versions, the `VenueConfig`, the `VaultRegistry` and the core treasury
48
+ * come from the deployment. `prepare*` return the `VenueTicket<Meme, Quote>`
49
+ * the product's `new` consumes; `migrate*` consume the product's
50
+ * `Migration<Meme, Quote>` in the same PTB. Cetus calls take
51
+ * `<Meme, Quote, CoinA, CoinB>` with the pool's coin order from
52
+ * `cetusMemeSide`, so pass original (defining) type addresses.
53
+ */
11
54
  export class MigratorCalls {
12
55
  deployment;
13
- launchpad;
56
+ /** `blast_migrators::BLAST_MIGRATORS`, the package's OTW. */
57
+ otw;
14
58
  constructor(deployment) {
15
- this.launchpad = new LaunchpadCalls(deployment.launchpad);
16
- this.deployment = {
17
- ...normalizeSuiPackageReference("migrators", deployment),
18
- launchpad: this.launchpad.deployment,
19
- migratorsVersion: normalizeSharedObjectIdentity("migratorsVersion", deployment.migratorsVersion),
20
- lpFeePolicy: normalizeSharedObjectIdentity("lpFeePolicy", deployment.lpFeePolicy),
21
- venueConfig: normalizeSharedObjectIdentity("venueConfig", deployment.venueConfig),
22
- };
23
- }
24
- /** The adapter witness type a launch stores as its `migration_witness`. */
25
- migrationWitnessType(venue) {
26
- return normalizeStructTag(`${this.deployment.originalPackageId}::${venue}::Witness`);
27
- }
28
- signIn(options) {
29
- return this.launchpad.signIn(options);
59
+ this.deployment = normalizeMigratorsDeployment(deployment);
60
+ this.otw = normalizeStructTag(`${this.deployment.originalPackageId}::blast_migrators::BLAST_MIGRATORS`);
30
61
  }
31
62
  /**
32
- * Starts a Cetus launch at `tickSpacing`: Cetus derives the fee rate, and the
33
- * Meme type's single `PoolCreationCap` is minted and reserved for the pair.
34
- * Returns the `LaunchInitializer`, which the same PTB must finalize.
63
+ * `cetus::prepare<Meme, Quote>(migrators_version, venue_config,
64
+ * cetus_config, pools, &mut sealed_treasury_cap, admission, tick_spacing)`:
65
+ * borrows the coin's sealed `TreasuryCap` with the product's `VenueAdmission`
66
+ * of this venue (`launch_config::venue_admission` or
67
+ * `creation_policy::venue_admission`, built earlier in the same PTB),
68
+ * reserves the Meme's Cetus pool and returns its `VenueTicket`.
35
69
  */
36
- newCetusLaunch(options) {
37
- const types = normalizeLaunchTypes(options);
70
+ prepareCetus(options) {
71
+ const types = pair(options);
38
72
  const tickSpacing = requireU32("tickSpacing", options.tickSpacing);
73
+ const cetus = {
74
+ config: normalizeSharedObjectIdentity("cetus.config", options.cetus.config),
75
+ pools: normalizeSharedObjectIdentity("cetus.pools", options.cetus.pools),
76
+ };
39
77
  return (tx) => tx.moveCall({
40
- target: `${this.deployment.packageId}::cetus::new`,
41
- typeArguments: [types.memeType, types.quoteType],
78
+ target: this.#target("cetus", "prepare"),
79
+ typeArguments: types,
42
80
  arguments: [
43
- tx.object(options.ticket),
44
81
  this.#migratorsVersion(tx),
45
- this.#launchpadVersion(tx),
46
- this.#launchConfig(tx),
47
82
  deploymentObject(tx, this.deployment.venueConfig, true),
48
- sharedObject(tx, "cetusConfig", options.cetusConfig, false),
49
- sharedObject(tx, "cetusPools", options.cetusPools, true),
83
+ deploymentObject(tx, cetus.config, false),
84
+ deploymentObject(tx, cetus.pools, true),
85
+ tx.object(options.sealedTreasuryCap),
86
+ options.admission,
50
87
  tx.pure.u32(tickSpacing),
51
88
  ],
52
89
  });
53
90
  }
54
91
  /**
55
- * Starts a Bluefin launch at the creator's tier (tick spacing 1-400, fee rate
56
- * 1-20,000, Bluefin's own bounds). Returns the `LaunchInitializer`.
92
+ * `bluefin::prepare<Meme, Quote>(migrators_version, venue_config,
93
+ * &sealed_treasury_cap, &currency, tick_spacing, fee_rate)`: records the
94
+ * Meme's Bluefin tier and returns its `VenueTicket`. The sealed cap only
95
+ * proves control of the coin; Bluefin reserves nothing, so it is never
96
+ * borrowed. Rejects a tier outside
97
+ * Bluefin's own bounds (`EInvalidTier`: tick spacing 1..=400, fee rate
98
+ * 1..=20,000); the contract also aborts with `ESymbolTooLong` when the
99
+ * Meme symbol exceeds 32 bytes.
57
100
  */
58
- newBluefinLaunch(options) {
59
- const types = normalizeLaunchTypes(options);
101
+ prepareBluefin(options) {
102
+ const types = pair(options);
60
103
  const tickSpacing = requireU32("tickSpacing", options.tickSpacing);
61
- requireU64("feeRate", options.feeRate);
104
+ const feeRate = requireU64("feeRate", options.feeRate);
105
+ if (tickSpacing === 0 ||
106
+ tickSpacing > BLUEFIN_MAX_TICK_SPACING ||
107
+ feeRate === 0n ||
108
+ feeRate > BLUEFIN_MAX_FEE_RATE) {
109
+ throw new RangeError(`a Bluefin tier needs a tick spacing in 1..=${BLUEFIN_MAX_TICK_SPACING} and a fee rate in 1..=${BLUEFIN_MAX_FEE_RATE}`);
110
+ }
111
+ const currency = normalizeSharedObjectIdentity("currency", options.currency);
62
112
  return (tx) => tx.moveCall({
63
- target: `${this.deployment.packageId}::bluefin::new`,
64
- typeArguments: [types.memeType, types.quoteType],
113
+ target: this.#target("bluefin", "prepare"),
114
+ typeArguments: types,
65
115
  arguments: [
66
- tx.object(options.ticket),
67
116
  this.#migratorsVersion(tx),
68
- this.#launchpadVersion(tx),
69
- this.#launchConfig(tx),
117
+ deploymentObject(tx, this.deployment.venueConfig, true),
118
+ tx.object(options.sealedTreasuryCap),
119
+ deploymentObject(tx, currency, false),
70
120
  tx.pure.u32(tickSpacing),
71
- tx.pure.u64(options.feeRate),
121
+ tx.pure.u64(feeRate),
72
122
  ],
73
123
  });
74
124
  }
75
125
  /**
76
- * Migrates a MigrationReady Cetus launch: creates the pool with the reserved
77
- * capability, seeds full-range liquidity, and burns the position through
78
- * Cetus LP Burn. Anyone may call it.
126
+ * `cetus::migrate<Meme, Quote, CoinA, CoinB>(migration, migrators_version,
127
+ * venue_config, cetus_config, pools, burn_manager, registry, vault_version,
128
+ * treasury, clock)`; `CoinA`/`CoinB` follow `cetusMemeSide`. Cetus writes
129
+ * a clock-dependent amount of storage, so the PTB is budgeted at gross
130
+ * cost (`grossGasBudget`).
79
131
  */
80
132
  migrateCetus(options) {
81
- const types = normalizeLaunchTypes(options);
82
- const memeSide = normalizeMemeSide(options.memeSide);
133
+ const typeArguments = cetusTypeArguments(options);
134
+ const cetus = {
135
+ config: normalizeSharedObjectIdentity("cetus.config", options.cetus.config),
136
+ pools: normalizeSharedObjectIdentity("cetus.pools", options.cetus.pools),
137
+ burnManager: normalizeSharedObjectIdentity("cetus.burnManager", options.cetus.burnManager),
138
+ };
83
139
  return (tx) => {
84
- // Cetus seeds a new pool's tick skip list from the clock, so its storage
85
- // differs between simulation and execution by up to 18 bytes, more than
86
- // the default budget's headroom: budget this transaction at gross cost.
87
140
  tx.addBuildPlugin(grossGasBudget());
88
141
  tx.moveCall({
89
- target: `${this.deployment.packageId}::cetus::migrate`,
90
- typeArguments: cetusTypeArguments(types, memeSide),
142
+ target: this.#target("cetus", "migrate"),
143
+ typeArguments,
91
144
  arguments: [
92
- sharedObject(tx, "launch", options.launch, true),
145
+ options.migration,
93
146
  this.#migratorsVersion(tx),
94
- this.#launchpadVersion(tx),
95
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
96
147
  deploymentObject(tx, this.deployment.venueConfig, false),
97
- sharedObject(tx, "cetusConfig", options.cetusConfig, false),
98
- sharedObject(tx, "cetusPools", options.cetusPools, true),
99
- sharedObject(tx, "burnManager", options.burnManager, true),
148
+ deploymentObject(tx, cetus.config, false),
149
+ deploymentObject(tx, cetus.pools, true),
150
+ deploymentObject(tx, cetus.burnManager, true),
151
+ deploymentObject(tx, this.deployment.vault.registry, true),
152
+ this.#vaultVersion(tx),
153
+ this.#treasury(tx),
100
154
  tx.object.clock(),
101
155
  ],
102
156
  });
103
157
  };
104
158
  }
105
159
  /**
106
- * Migrates a MigrationReady Bluefin launch into a new `Pool<Meme, Quote>`.
107
- * `creationFee` must be exactly Bluefin's configured SUI pool-creation fee.
160
+ * `bluefin::migrate<Meme, Quote>(migration, migrators_version,
161
+ * venue_config, currency, quote_currency, bluefin_config, registry,
162
+ * vault_version, treasury, creation_fee, clock)`; `creationFee` is a
163
+ * `Coin<SUI>` of Bluefin's pool creation fee.
108
164
  */
109
165
  migrateBluefin(options) {
110
- const types = normalizeLaunchTypes(options);
166
+ const types = pair(options);
167
+ const currency = normalizeSharedObjectIdentity("currency", options.currency);
168
+ const quoteCurrency = normalizeSharedObjectIdentity("quoteCurrency", options.quoteCurrency);
169
+ const bluefinConfig = normalizeSharedObjectIdentity("bluefinConfig", options.bluefinConfig);
111
170
  return (tx) => {
112
171
  tx.moveCall({
113
- target: `${this.deployment.packageId}::bluefin::migrate`,
114
- typeArguments: [types.memeType, types.quoteType],
172
+ target: this.#target("bluefin", "migrate"),
173
+ typeArguments: types,
115
174
  arguments: [
116
- sharedObject(tx, "launch", options.launch, true),
175
+ options.migration,
117
176
  this.#migratorsVersion(tx),
118
- this.#launchpadVersion(tx),
119
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
120
- sharedObject(tx, "quoteCurrency", options.quoteCurrency, false),
121
- sharedObject(tx, "bluefinConfig", options.bluefinConfig, true),
122
- tx.object(options.creationFee),
177
+ deploymentObject(tx, this.deployment.venueConfig, false),
178
+ deploymentObject(tx, currency, false),
179
+ deploymentObject(tx, quoteCurrency, false),
180
+ deploymentObject(tx, bluefinConfig, true),
181
+ deploymentObject(tx, this.deployment.vault.registry, true),
182
+ this.#vaultVersion(tx),
183
+ this.#treasury(tx),
184
+ options.creationFee,
123
185
  tx.object.clock(),
124
186
  ],
125
187
  });
126
188
  };
127
189
  }
128
190
  /**
129
- * Collects the burned migration position's and the auto-LP position's fees,
130
- * pays Blast's live share, splits the rest, burns the burn share's Meme, and
131
- * adds the auto-LP share back. Anyone may call it.
191
+ * `cetus::collect_fees<Meme, Quote, CoinA, CoinB>(vault, migrators_version,
192
+ * vault_version, treasury, currency, cetus_config, burn_manager, pool)`:
193
+ * collects both positions' fees, splits them and burns the burn share's
194
+ * Meme; the auto-LP share waits in the vault for `compoundCetusAutoLp`.
195
+ * Anyone may call it.
132
196
  */
133
197
  collectCetusFees(options) {
134
- const types = normalizeLaunchTypes(options);
135
- const memeSide = normalizeMemeSide(options.memeSide);
136
- return (tx) => {
137
- tx.moveCall({
138
- target: `${this.deployment.packageId}::cetus::collect_fees`,
139
- typeArguments: cetusTypeArguments(types, memeSide),
140
- arguments: [
141
- sharedObject(tx, "vault", options.vault, true),
142
- this.#migratorsVersion(tx),
143
- this.#lpFeePolicy(tx),
144
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
145
- sharedObject(tx, "cetusConfig", options.cetusConfig, false),
146
- sharedObject(tx, "burnManager", options.burnManager, false),
147
- sharedObject(tx, "pool", options.pool, true),
148
- tx.object.clock(),
149
- ],
150
- });
151
- };
198
+ return this.#cetusFees("collect_fees", options);
152
199
  }
153
- /** Collects, splits, burns, and adds auto-LP for a Bluefin vault. Anyone may call it. */
154
- collectBluefinFees(options) {
155
- const types = normalizeLaunchTypes(options);
156
- return (tx) => {
157
- tx.moveCall({
158
- target: `${this.deployment.packageId}::bluefin::collect_fees`,
159
- typeArguments: [types.memeType, types.quoteType],
160
- arguments: [
161
- sharedObject(tx, "vault", options.vault, true),
162
- this.#migratorsVersion(tx),
163
- this.#lpFeePolicy(tx),
164
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
165
- sharedObject(tx, "bluefinConfig", options.bluefinConfig, false),
166
- sharedObject(tx, "pool", options.pool, true),
167
- tx.object.clock(),
168
- ],
169
- });
170
- };
200
+ /**
201
+ * `cetus::settle_and_apply_fee_split(..., pool, clock)`: `collectCetusFees`
202
+ * under the current split, then applies the ready scheduled split. Anyone
203
+ * may call it.
204
+ */
205
+ settleAndApplyCetusFeeSplit(options) {
206
+ return this.#cetusFees("settle_and_apply_fee_split", options);
171
207
  }
172
208
  /**
173
- * Settles the fees accrued under the current split, then commits `feeSplit`
174
- * as the vault's split. Only the launch's live `CurveFeeCap` authorizes it.
175
- * `launch` is read immutably by Move.
209
+ * `bluefin::collect_fees<Meme, Quote>(vault, migrators_version,
210
+ * vault_version, treasury, currency, bluefin_config, pool, clock)`: the
211
+ * auto-LP share waits in the vault for `compoundBluefinAutoLp`. Anyone may
212
+ * call it.
176
213
  */
177
- settleAndUpdateCetusFeeSplit(options) {
178
- const types = normalizeLaunchTypes(options);
179
- const memeSide = normalizeMemeSide(options.memeSide);
180
- const feeSplit = this.launchpad.feeSplit(options.feeSplit);
214
+ collectBluefinFees(options) {
215
+ return this.#bluefinFees("collect_fees", options);
216
+ }
217
+ /** `bluefin::settle_and_apply_fee_split`, same arguments as `collectBluefinFees`. */
218
+ settleAndApplyBluefinFeeSplit(options) {
219
+ return this.#bluefinFees("settle_and_apply_fee_split", options);
220
+ }
221
+ /** Adds waiting auto-LP balances under AutoLpAdmin and keeper price bounds.
222
+ * The private entry consumes and re-shares the pool, so put it last in a PTB.
223
+ * Bounds are inclusive Q64.64 sqrt prices in venue pool coin order.
224
+ */
225
+ compoundCetusAutoLp(options) {
226
+ const typeArguments = cetusTypeArguments(options);
227
+ const objects = {
228
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
229
+ config: normalizeSharedObjectIdentity("cetus.config", options.cetus.config),
230
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
231
+ };
232
+ const [min, max] = autoLpPriceBounds(options);
181
233
  return (tx) => {
182
234
  tx.moveCall({
183
- target: `${this.deployment.packageId}::cetus::settle_and_update_fee_split`,
184
- typeArguments: cetusTypeArguments(types, memeSide),
235
+ target: this.#target("cetus", "compound_auto_lp"),
236
+ typeArguments,
185
237
  arguments: [
186
- sharedObject(tx, "vault", options.vault, true),
238
+ deploymentObject(tx, objects.vault, true),
187
239
  this.#migratorsVersion(tx),
188
- this.#lpFeePolicy(tx),
189
- sharedObject(tx, "launch", options.launch, options.launch.mutable),
190
- tx.object(options.curveFeeCap),
191
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
192
- sharedObject(tx, "cetusConfig", options.cetusConfig, false),
193
- sharedObject(tx, "burnManager", options.burnManager, false),
194
- sharedObject(tx, "pool", options.pool, true),
195
- tx.add(feeSplit),
240
+ this.#vaultVersion(tx),
241
+ deploymentObject(tx, this.deployment.vault.admin.acl, false),
242
+ tx.object(options.adminCap),
243
+ deploymentObject(tx, objects.config, false),
244
+ deploymentObject(tx, objects.pool, true),
245
+ tx.pure.u128(min),
246
+ tx.pure.u128(max),
196
247
  tx.object.clock(),
197
248
  ],
198
249
  });
199
250
  };
200
251
  }
201
- /** Bluefin counterpart of `settleAndUpdateCetusFeeSplit`. */
202
- settleAndUpdateBluefinFeeSplit(options) {
203
- const types = normalizeLaunchTypes(options);
204
- const feeSplit = this.launchpad.feeSplit(options.feeSplit);
252
+ /** Bluefin's private AutoLpAdmin entry; see compoundCetusAutoLp. */
253
+ compoundBluefinAutoLp(options) {
254
+ const types = pair(options);
255
+ const objects = {
256
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
257
+ config: normalizeSharedObjectIdentity("bluefinConfig", options.bluefinConfig),
258
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
259
+ };
260
+ const [min, max] = autoLpPriceBounds(options);
205
261
  return (tx) => {
206
262
  tx.moveCall({
207
- target: `${this.deployment.packageId}::bluefin::settle_and_update_fee_split`,
208
- typeArguments: [types.memeType, types.quoteType],
263
+ target: this.#target("bluefin", "compound_auto_lp"),
264
+ typeArguments: types,
209
265
  arguments: [
210
- sharedObject(tx, "vault", options.vault, true),
266
+ deploymentObject(tx, objects.vault, true),
211
267
  this.#migratorsVersion(tx),
212
- this.#lpFeePolicy(tx),
213
- sharedObject(tx, "launch", options.launch, options.launch.mutable),
214
- tx.object(options.curveFeeCap),
215
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
216
- sharedObject(tx, "bluefinConfig", options.bluefinConfig, false),
217
- sharedObject(tx, "pool", options.pool, true),
218
- tx.add(feeSplit),
268
+ this.#vaultVersion(tx),
269
+ deploymentObject(tx, this.deployment.vault.admin.acl, false),
270
+ tx.object(options.adminCap),
271
+ deploymentObject(tx, objects.config, false),
272
+ deploymentObject(tx, objects.pool, true),
273
+ tx.pure.u128(min),
274
+ tx.pure.u128(max),
219
275
  tx.object.clock(),
220
276
  ],
221
277
  });
222
278
  };
223
279
  }
224
280
  /**
225
- * Swaps `quoteIn` atomic units of the vault's burn Quote for Meme in its
226
- * Cetus pool and burns it, under a `BuybackAdmin` witness. The contract
227
- * aborts with `EBuybackQuoteOutOfRange` when `quoteIn` exceeds the vault's
228
- * burn Quote, and unless the swap returns at least `minMemeOut`; set it from
229
- * an off-chain price, since anyone can move the pool's price within a
230
- * transaction. Unspent Quote waits for the next buyback.
281
+ * `cetus::buyback_and_burn<Meme, Quote, CoinA, CoinB>(vault,
282
+ * migrators_version, vault_version, admin_witness, currency, cetus_config,
283
+ * pool, quote_in, min_meme_out, clock)` under a `BuybackAdmin` witness.
284
+ * Swaps `quoteIn` of the vault's burn Quote and burns the Meme bought;
285
+ * aborts unless the swap returns at least `minMemeOut`, which the admin
286
+ * sets from an off-chain price.
231
287
  */
232
288
  buybackAndBurnCetus(options) {
233
- const types = normalizeLaunchTypes(options);
234
- const memeSide = normalizeMemeSide(options.memeSide);
235
- const quoteIn = requirePositiveU64("quoteIn", options.quoteIn);
236
- const minMemeOut = requireU64("minMemeOut", options.minMemeOut);
237
- return (tx) => {
238
- tx.moveCall({
239
- target: `${this.deployment.packageId}::cetus::buyback_and_burn`,
240
- typeArguments: cetusTypeArguments(types, memeSide),
241
- arguments: [
242
- sharedObject(tx, "vault", options.vault, true),
243
- this.#migratorsVersion(tx),
244
- tx.object(options.adminWitness),
245
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
246
- sharedObject(tx, "cetusConfig", options.cetusConfig, false),
247
- sharedObject(tx, "pool", options.pool, true),
248
- tx.pure.u64(quoteIn),
249
- tx.pure.u64(minMemeOut),
250
- tx.object.clock(),
251
- ],
252
- });
289
+ const typeArguments = cetusTypeArguments(options);
290
+ const objects = {
291
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
292
+ currency: normalizeSharedObjectIdentity("currency", options.currency),
293
+ config: normalizeSharedObjectIdentity("cetus.config", options.cetus.config),
294
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
253
295
  };
254
- }
255
- /** Bluefin counterpart of `buybackAndBurnCetus`. */
256
- buybackAndBurnBluefin(options) {
257
- const types = normalizeLaunchTypes(options);
258
- const quoteIn = requirePositiveU64("quoteIn", options.quoteIn);
259
- const minMemeOut = requireU64("minMemeOut", options.minMemeOut);
296
+ const amounts = buybackAmounts(options);
260
297
  return (tx) => {
261
298
  tx.moveCall({
262
- target: `${this.deployment.packageId}::bluefin::buyback_and_burn`,
263
- typeArguments: [types.memeType, types.quoteType],
299
+ target: this.#target("cetus", "buyback_and_burn"),
300
+ typeArguments,
264
301
  arguments: [
265
- sharedObject(tx, "vault", options.vault, true),
302
+ deploymentObject(tx, objects.vault, true),
266
303
  this.#migratorsVersion(tx),
304
+ this.#vaultVersion(tx),
267
305
  tx.object(options.adminWitness),
268
- sharedObject(tx, "memeCurrency", options.memeCurrency, true),
269
- sharedObject(tx, "bluefinConfig", options.bluefinConfig, false),
270
- sharedObject(tx, "pool", options.pool, true),
271
- tx.pure.u64(quoteIn),
272
- tx.pure.u64(minMemeOut),
306
+ deploymentObject(tx, objects.currency, true),
307
+ deploymentObject(tx, objects.config, false),
308
+ deploymentObject(tx, objects.pool, true),
309
+ tx.pure.u64(amounts.quoteIn),
310
+ tx.pure.u64(amounts.minMemeOut),
273
311
  tx.object.clock(),
274
312
  ],
275
313
  });
276
314
  };
277
315
  }
278
316
  /**
279
- * Claims the creator's accrued LP fees with the launch's live `CurveFeeCap`.
280
- * `launch` is read immutably by Move.
281
- */
282
- claimCreatorFees(options) {
283
- const types = normalizeLaunchTypes(options);
284
- return (tx) => tx.moveCall({
285
- target: `${this.deployment.packageId}::vault::claim_creator_fees`,
286
- typeArguments: [types.memeType, types.quoteType],
287
- arguments: [
288
- sharedObject(tx, "vault", options.vault, true),
289
- this.#migratorsVersion(tx),
290
- sharedObject(tx, "launch", options.launch, options.launch.mutable),
291
- tx.object(options.curveFeeCap),
292
- ],
293
- });
294
- }
295
- /**
296
- * `vault::claim_protocol_lp_fees_with_partner`: pays a partnered vault's held
297
- * Blast LP fees, the launch's partner its cut in force of each asset, rounded
298
- * down, and the `LpFeePolicy` destination the rest. Anyone may call it;
299
- * holding nothing pays nothing.
317
+ * `bluefin::buyback_and_burn<Meme, Quote>(vault, migrators_version,
318
+ * vault_version, admin_witness, currency, bluefin_config, pool, quote_in,
319
+ * min_meme_out, clock)`; see `buybackAndBurnCetus`.
300
320
  */
301
- claimProtocolLpFeesWithPartner(options) {
302
- const types = normalizeLaunchTypes(options);
303
- return (tx) => {
304
- tx.moveCall({
305
- target: `${this.deployment.packageId}::vault::claim_protocol_lp_fees_with_partner`,
306
- typeArguments: [types.memeType, types.quoteType],
307
- arguments: [
308
- sharedObject(tx, "vault", options.vault, true),
309
- this.#migratorsVersion(tx),
310
- this.#lpFeePolicy(tx),
311
- sharedObject(tx, "partner", options.partner, false),
312
- tx.object.clock(),
313
- ],
314
- });
321
+ buybackAndBurnBluefin(options) {
322
+ const types = pair(options);
323
+ const objects = {
324
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
325
+ currency: normalizeSharedObjectIdentity("currency", options.currency),
326
+ config: normalizeSharedObjectIdentity("bluefinConfig", options.bluefinConfig),
327
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
315
328
  };
316
- }
317
- /** Claims the protocol-owned migration residuals under a `TreasuryAdmin` witness. */
318
- claimProtocolFees(options) {
319
- const types = normalizeLaunchTypes(options);
320
- return (tx) => tx.moveCall({
321
- target: `${this.deployment.packageId}::vault::claim_protocol_fees`,
322
- typeArguments: [types.memeType, types.quoteType],
323
- arguments: [
324
- sharedObject(tx, "vault", options.vault, true),
325
- this.#migratorsVersion(tx),
326
- tx.object(options.adminWitness),
327
- ],
328
- });
329
- }
330
- /** Changes Blast's default Meme and Quote LP-fee shares for coins without their own pair (`FeeAdmin`). */
331
- setLpFeeDefaultShares(options) {
332
- return this.#lpFeePolicyAdmin("set_default_shares", [], options, (tx) => [
333
- tx.add(this.launchpad.bps(options.memeBps)),
334
- tx.add(this.launchpad.bps(options.quoteBps)),
335
- ]);
336
- }
337
- /** Sets Blast's LP-fee shares for one original Meme type (`FeeAdmin`). */
338
- setLpFeeCoinShares(options) {
339
- return this.#lpFeePolicyAdmin("set_coin_shares", [normalizeStructTag(options.memeType)], options, (tx) => [
340
- tx.add(this.launchpad.bps(options.memeBps)),
341
- tx.add(this.launchpad.bps(options.quoteBps)),
342
- ]);
343
- }
344
- /** Removes one Meme type's own pair so its collections use the defaults again (`FeeAdmin`). */
345
- clearLpFeeCoinShares(options) {
346
- return this.#lpFeePolicyAdmin("clear_coin_shares", [normalizeStructTag(options.memeType)], options, () => []);
347
- }
348
- /** Redirects every later protocol LP-fee payout (`TreasuryAdmin`). */
349
- setLpFeeProtocolDestination(options) {
350
- const destination = normalizeSuiAddress(options.destination);
351
- return this.#lpFeePolicyAdmin("set_protocol_destination", [], options, (tx) => [tx.pure.address(destination)]);
352
- }
353
- /**
354
- * Publishes a holder-reward round from a validated manifest, reserving its
355
- * budget from the vault's rewards balance, and shares the `Round`
356
- * (`RewardsAdmin`).
357
- */
358
- publishHolderRewardRound(options) {
359
- const types = normalizeLaunchTypes(options);
360
- const manifest = validateRewardManifest(options.manifest, MIGRATOR_REWARD_LEAF_DOMAIN);
361
- if (rewardAddress(manifest.vaultId) !== rewardAddress(options.vault.objectId)) {
362
- throw new TypeError("manifest belongs to another vault");
363
- }
329
+ const amounts = buybackAmounts(options);
364
330
  return (tx) => {
365
331
  tx.moveCall({
366
- target: `${this.deployment.packageId}::blast_holder_rewards::publish_round`,
367
- typeArguments: [types.memeType, types.quoteType],
332
+ target: this.#target("bluefin", "buyback_and_burn"),
333
+ typeArguments: types,
368
334
  arguments: [
369
- sharedObject(tx, "vault", options.vault, true),
335
+ deploymentObject(tx, objects.vault, true),
370
336
  this.#migratorsVersion(tx),
337
+ this.#vaultVersion(tx),
371
338
  tx.object(options.adminWitness),
372
- tx.pure.u64(manifest.number),
373
- tx.pure.u64(manifest.startCheckpoint),
374
- tx.pure.u64(manifest.endCheckpoint),
375
- tx.pure.vector("u8", rewardDigest(manifest.root)),
376
- tx.pure.vector("u8", rewardDigest(manifest.manifestDigest)),
377
- tx.pure.u64(manifest.allocations.length),
378
- tx.pure.u64(manifest.memeAmount),
379
- tx.pure.u64(manifest.quoteAmount),
339
+ deploymentObject(tx, objects.currency, true),
340
+ deploymentObject(tx, objects.config, false),
341
+ deploymentObject(tx, objects.pool, true),
342
+ tx.pure.u64(amounts.quoteIn),
343
+ tx.pure.u64(amounts.minMemeOut),
344
+ tx.object.clock(),
380
345
  ],
381
346
  });
382
347
  };
383
348
  }
384
- /** Relays one allocation's proof; the round pays its committed beneficiary. */
385
- claimHolderReward(options) {
386
- const types = normalizeLaunchTypes(options);
387
- const { allocation } = options;
388
- const index = requireU64("index", BigInt(allocation.index));
389
- const memeAmount = requireU64("memeAmount", BigInt(allocation.memeAmount));
390
- const quoteAmount = requireU64("quoteAmount", BigInt(allocation.quoteAmount));
391
- const beneficiary = rewardAddress(allocation.beneficiary);
392
- if (allocation.proof.length > MAX_HOLDER_REWARD_PROOF_DEPTH) {
393
- throw new RangeError(`proof exceeds ${MAX_HOLDER_REWARD_PROOF_DEPTH} siblings`);
394
- }
395
- const proof = allocation.proof.map((sibling) => Array.from(rewardDigest(sibling)));
349
+ #cetusFees(name, options) {
350
+ const typeArguments = cetusTypeArguments(options);
351
+ const objects = {
352
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
353
+ currency: normalizeSharedObjectIdentity("currency", options.currency),
354
+ config: normalizeSharedObjectIdentity("cetus.config", options.cetus.config),
355
+ burnManager: normalizeSharedObjectIdentity("cetus.burnManager", options.cetus.burnManager),
356
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
357
+ };
396
358
  return (tx) => {
397
359
  tx.moveCall({
398
- target: `${this.deployment.packageId}::blast_holder_rewards::claim`,
399
- typeArguments: [types.memeType, types.quoteType],
360
+ target: this.#target("cetus", name),
361
+ typeArguments,
400
362
  arguments: [
401
- sharedObject(tx, "round", options.round, true),
363
+ deploymentObject(tx, objects.vault, true),
402
364
  this.#migratorsVersion(tx),
403
- tx.pure.u64(index),
404
- tx.pure.address(beneficiary),
405
- tx.pure.u64(memeAmount),
406
- tx.pure.u64(quoteAmount),
407
- tx.pure.vector("vector<u8>", proof),
365
+ this.#vaultVersion(tx),
366
+ this.#treasury(tx),
367
+ deploymentObject(tx, objects.currency, true),
368
+ deploymentObject(tx, objects.config, false),
369
+ deploymentObject(tx, objects.burnManager, false),
370
+ deploymentObject(tx, objects.pool, true),
371
+ // Only the split's apply reads the clock.
372
+ ...(name === "settle_and_apply_fee_split" ? [tx.object.clock()] : []),
408
373
  ],
409
374
  });
410
375
  };
411
376
  }
412
- #lpFeePolicyAdmin(functionName, typeArguments, options, extra) {
377
+ #bluefinFees(name, options) {
378
+ const types = pair(options);
379
+ const objects = {
380
+ vault: normalizeSharedObjectIdentity("vault", options.vault),
381
+ currency: normalizeSharedObjectIdentity("currency", options.currency),
382
+ config: normalizeSharedObjectIdentity("bluefinConfig", options.bluefinConfig),
383
+ pool: normalizeSharedObjectIdentity("pool", options.pool),
384
+ };
413
385
  return (tx) => {
414
386
  tx.moveCall({
415
- target: `${this.deployment.packageId}::lp_fee_policy::${functionName}`,
416
- typeArguments,
387
+ target: this.#target("bluefin", name),
388
+ typeArguments: types,
417
389
  arguments: [
418
- deploymentObject(tx, this.deployment.lpFeePolicy, true),
390
+ deploymentObject(tx, objects.vault, true),
419
391
  this.#migratorsVersion(tx),
420
- tx.object(options.adminWitness),
421
- ...extra(tx),
392
+ this.#vaultVersion(tx),
393
+ this.#treasury(tx),
394
+ deploymentObject(tx, objects.currency, true),
395
+ deploymentObject(tx, objects.config, false),
396
+ deploymentObject(tx, objects.pool, true),
397
+ tx.object.clock(),
422
398
  ],
423
399
  });
424
400
  };
425
401
  }
426
- #migratorsVersion(tx) {
427
- return deploymentObject(tx, this.deployment.migratorsVersion, false);
402
+ #target(module, name) {
403
+ return `${this.deployment.packageId}::${module}::${name}`;
428
404
  }
429
- #launchpadVersion(tx) {
430
- return deploymentObject(tx, this.deployment.launchpad.packageVersion, false);
405
+ #migratorsVersion(tx) {
406
+ return deploymentObject(tx, this.deployment.packageVersion, false);
431
407
  }
432
- #launchConfig(tx) {
433
- return deploymentObject(tx, this.deployment.launchpad.launchConfig, false);
408
+ #vaultVersion(tx) {
409
+ return deploymentObject(tx, this.deployment.vault.packageVersion, false);
434
410
  }
435
- #lpFeePolicy(tx) {
436
- return deploymentObject(tx, this.deployment.lpFeePolicy, false);
411
+ #treasury(tx) {
412
+ return deploymentObject(tx, this.deployment.vault.core.treasury, false);
437
413
  }
438
414
  }
415
+ /**
416
+ * One-call PTBs for a migrated vault's venue routes: fee collection,
417
+ * settlement and auto-LP compounding (anyone) and buybacks (an `AdminCap` holding
418
+ * `blast_domain::BuybackAdmin`). Preparation and migration are composed
419
+ * with the product's own calls by the launchpad and presale packages.
420
+ */
439
421
  export class MigratorTransactions {
440
422
  call;
441
- #useGasCoin;
442
- constructor(deployment, options = {}) {
423
+ admin;
424
+ constructor(deployment) {
443
425
  this.call = new MigratorCalls(deployment);
444
- this.#useGasCoin = options.useGasCoin ?? true;
445
- }
446
- /**
447
- * Starts, configures, finalizes, and shares a Cetus launch atomically, with
448
- * an optional purchase on the owned launch, routed to its recipient.
449
- */
450
- createCetusLaunch(options) {
451
- const tx = new Transaction();
452
- const initializer = tx.add(this.call.newCetusLaunch(options));
453
- addLaunchCompletion(tx, this.call.launchpad, {
454
- ...options,
455
- initializer,
456
- currency: options.memeCurrency,
457
- useGasCoin: options.useGasCoin ?? this.#useGasCoin,
458
- });
459
- return tx;
460
- }
461
- /** Bluefin counterpart of `createCetusLaunch`. */
462
- createBluefinLaunch(options) {
463
- const tx = new Transaction();
464
- const initializer = tx.add(this.call.newBluefinLaunch(options));
465
- addLaunchCompletion(tx, this.call.launchpad, {
466
- ...options,
467
- initializer,
468
- currency: options.memeCurrency,
469
- useGasCoin: options.useGasCoin ?? this.#useGasCoin,
470
- });
471
- return tx;
472
- }
473
- migrateCetus(options) {
474
- const tx = new Transaction();
475
- tx.add(this.call.migrateCetus(options));
476
- return tx;
477
- }
478
- /** Pays Bluefin's SUI pool-creation fee as an exact-balance coin. */
479
- migrateBluefin(options) {
480
- requireU64("creationFee", options.creationFee);
481
- const tx = new Transaction();
482
- const creationFee = tx.coin({
483
- type: "0x2::sui::SUI",
484
- balance: options.creationFee,
485
- useGasCoin: options.useGasCoin ?? this.#useGasCoin,
486
- });
487
- tx.add(this.call.migrateBluefin({ ...options, creationFee }));
488
- return tx;
426
+ this.admin = new AdminCalls(this.call.deployment.vault.admin);
489
427
  }
490
- /** Then pays the vault's partner when `partner` is given; see `claimProtocolLpFeesWithPartner`. */
491
428
  collectCetusFees(options) {
492
- const tx = new Transaction();
493
- tx.add(this.call.collectCetusFees(options));
494
- return this.#claimProtocolLpFeesWithPartnerAfter(tx, options);
495
- }
496
- /** Then pays the vault's partner when `partner` is given; see `claimProtocolLpFeesWithPartner`. */
497
- collectBluefinFees(options) {
498
- const tx = new Transaction();
499
- tx.add(this.call.collectBluefinFees(options));
500
- return this.#claimProtocolLpFeesWithPartnerAfter(tx, options);
501
- }
502
- /** Pays a partnered vault's partner and Blast the LP fees its collections held. */
503
- claimProtocolLpFeesWithPartner(options) {
504
- const tx = new Transaction();
505
- tx.add(this.call.claimProtocolLpFeesWithPartner(options));
506
- return tx;
507
- }
508
- settleAndUpdateCetusFeeSplit(options) {
509
- const tx = new Transaction();
510
- tx.add(this.call.settleAndUpdateCetusFeeSplit({
511
- ...options,
512
- curveFeeCap: options.curveFeeCapId,
513
- }));
514
- return tx;
515
- }
516
- settleAndUpdateBluefinFeeSplit(options) {
517
- const tx = new Transaction();
518
- tx.add(this.call.settleAndUpdateBluefinFeeSplit({
519
- ...options,
520
- curveFeeCap: options.curveFeeCapId,
521
- }));
522
- return tx;
523
- }
524
- claimCreatorFees(options) {
525
- const tx = new Transaction();
526
- const result = tx.add(this.call.claimCreatorFees({
527
- ...options,
528
- curveFeeCap: options.curveFeeCapId,
529
- }));
530
- tx.transferObjects(moveResults(result, 2), normalizeSuiAddress(options.recipient));
531
- return tx;
429
+ return single(this.call.collectCetusFees(options));
532
430
  }
533
- claimProtocolFees(options) {
534
- const tx = new Transaction();
535
- const adminWitness = tx.add(this.call.signIn({ adminCap: options.adminCapId, role: "TreasuryAdmin" }));
536
- const result = tx.add(this.call.claimProtocolFees({ ...options, adminWitness }));
537
- tx.transferObjects(moveResults(result, 2), normalizeSuiAddress(options.recipient));
538
- return tx;
431
+ settleAndApplyCetusFeeSplit(options) {
432
+ return single(this.call.settleAndApplyCetusFeeSplit(options));
539
433
  }
540
- setLpFeeDefaultShares(options) {
541
- return this.#asAdmin(options.adminCapId, "FeeAdmin", (adminWitness) => this.call.setLpFeeDefaultShares({ ...options, adminWitness }));
434
+ collectBluefinFees(options) {
435
+ return single(this.call.collectBluefinFees(options));
542
436
  }
543
- setLpFeeCoinShares(options) {
544
- return this.#asAdmin(options.adminCapId, "FeeAdmin", (adminWitness) => this.call.setLpFeeCoinShares({ ...options, adminWitness }));
437
+ settleAndApplyBluefinFeeSplit(options) {
438
+ return single(this.call.settleAndApplyBluefinFeeSplit(options));
545
439
  }
546
- clearLpFeeCoinShares(options) {
547
- return this.#asAdmin(options.adminCapId, "FeeAdmin", (adminWitness) => this.call.clearLpFeeCoinShares({ ...options, adminWitness }));
440
+ compoundCetusAutoLp(options) {
441
+ return single(this.call.compoundCetusAutoLp(options));
548
442
  }
549
- setLpFeeProtocolDestination(options) {
550
- return this.#asAdmin(options.adminCapId, "TreasuryAdmin", (adminWitness) => this.call.setLpFeeProtocolDestination({ ...options, adminWitness }));
443
+ compoundBluefinAutoLp(options) {
444
+ return single(this.call.compoundBluefinAutoLp(options));
551
445
  }
446
+ /** Signs in as `BuybackAdmin` with `adminCapId`, then `buybackAndBurnCetus`. */
552
447
  buybackAndBurnCetus(options) {
553
- return this.#asAdmin(options.adminCapId, "BuybackAdmin", (adminWitness) => this.call.buybackAndBurnCetus({ ...options, adminWitness }));
448
+ return this.#asBuybackAdmin(options.adminCapId, (adminWitness) => this.call.buybackAndBurnCetus({ ...options, adminWitness }));
554
449
  }
450
+ /** Signs in as `BuybackAdmin` with `adminCapId`, then `buybackAndBurnBluefin`. */
555
451
  buybackAndBurnBluefin(options) {
556
- return this.#asAdmin(options.adminCapId, "BuybackAdmin", (adminWitness) => this.call.buybackAndBurnBluefin({ ...options, adminWitness }));
557
- }
558
- publishHolderRewardRound(options) {
559
- return this.#asAdmin(options.adminCapId, "RewardsAdmin", (adminWitness) => this.call.publishHolderRewardRound({ ...options, adminWitness }));
560
- }
561
- /** Relays up to `allocations.length` proofs of one round in a single PTB. */
562
- claimHolderRewards(options) {
563
- const tx = new Transaction();
564
- for (const allocation of options.allocations) {
565
- tx.add(this.call.claimHolderReward({ ...options, allocation }));
566
- }
567
- return tx;
452
+ return this.#asBuybackAdmin(options.adminCapId, (adminWitness) => this.call.buybackAndBurnBluefin({ ...options, adminWitness }));
568
453
  }
569
- #asAdmin(adminCapId, role, call) {
454
+ #asBuybackAdmin(adminCapId, call) {
570
455
  const tx = new Transaction();
571
- const adminWitness = tx.add(this.call.signIn({ adminCap: adminCapId, role }));
456
+ const adminWitness = tx.add(this.admin.signIn({
457
+ adminCap: adminCapId,
458
+ role: coreRoleType(this.call.deployment.vault.core, "BuybackAdmin"),
459
+ }));
572
460
  tx.add(call(adminWitness));
573
461
  return tx;
574
462
  }
575
- #claimProtocolLpFeesWithPartnerAfter(tx, options) {
576
- const { partner } = options;
577
- if (partner)
578
- tx.add(this.call.claimProtocolLpFeesWithPartner({ ...options, partner }));
579
- return tx;
580
- }
581
463
  }
582
- function sharedObject(tx, name, reference, mutable) {
583
- return tx.sharedObjectRef(normalizeSharedObjectReference(name, reference, mutable));
464
+ function single(step) {
465
+ const tx = new Transaction();
466
+ tx.add(step);
467
+ return tx;
584
468
  }
585
- /** `[Meme, Quote, CoinA, CoinB]`, the pool's coins in Cetus order. */
586
- function cetusTypeArguments(types, memeSide) {
587
- const { memeType, quoteType } = types;
588
- return memeSide === "a"
589
- ? [memeType, quoteType, memeType, quoteType]
590
- : [memeType, quoteType, quoteType, memeType];
469
+ function pair(types) {
470
+ return [
471
+ normalizeStructTag(types.memeType),
472
+ normalizeStructTag(types.quoteType),
473
+ ];
591
474
  }
592
- function normalizeMemeSide(value) {
593
- if (value !== "a" && value !== "b") {
594
- throw new RangeError("memeSide must be a or b");
595
- }
596
- return value;
475
+ /** `<Meme, Quote, CoinA, CoinB>`, with the pool's coin order from `cetusMemeSide`. */
476
+ function cetusTypeArguments(types) {
477
+ const [meme, quote] = pair(types);
478
+ return cetusMemeSide(meme, quote) === "a"
479
+ ? [meme, quote, meme, quote]
480
+ : [meme, quote, quote, meme];
481
+ }
482
+ function buybackAmounts(options) {
483
+ return {
484
+ quoteIn: requirePositiveU64("quoteIn", options.quoteIn),
485
+ minMemeOut: requireU64("minMemeOut", options.minMemeOut),
486
+ };
597
487
  }
598
488
  function requireU32(name, value) {
599
489
  if (!Number.isInteger(value) || value < 0 || value > 0xffff_ffff) {
@@ -601,4 +491,12 @@ function requireU32(name, value) {
601
491
  }
602
492
  return value;
603
493
  }
494
+ function autoLpPriceBounds(options) {
495
+ const min = requireU128("minSqrtPrice", options.minSqrtPrice);
496
+ const max = requireU128("maxSqrtPrice", options.maxSqrtPrice);
497
+ if (min === 0n || min > max) {
498
+ throw new RangeError("auto-LP needs 0 < minSqrtPrice <= maxSqrtPrice");
499
+ }
500
+ return [min, max];
501
+ }
604
502
  //# sourceMappingURL=transactions.js.map