@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.
- package/dist/aborts.d.ts +12 -0
- package/dist/aborts.d.ts.map +1 -0
- package/dist/aborts.js +21 -0
- package/dist/aborts.js.map +1 -0
- package/dist/client.d.ts +8 -11
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +12 -14
- package/dist/client.js.map +1 -1
- package/dist/events.d.ts +30 -160
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +33 -168
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/reducer.d.ts +20 -132
- package/dist/reducer.d.ts.map +1 -1
- package/dist/reducer.js +28 -361
- package/dist/reducer.js.map +1 -1
- package/dist/state.d.ts +32 -152
- package/dist/state.d.ts.map +1 -1
- package/dist/state.js +61 -167
- package/dist/state.js.map +1 -1
- package/dist/transactions.d.ts +204 -259
- package/dist/transactions.d.ts.map +1 -1
- package/dist/transactions.js +347 -449
- package/dist/transactions.js.map +1 -1
- package/package.json +7 -10
- package/src/aborts.ts +24 -0
- package/src/client.ts +19 -34
- package/src/events.ts +54 -261
- package/src/index.ts +1 -3
- package/src/reducer.ts +46 -538
- package/src/state.ts +88 -282
- package/src/transactions.ts +569 -838
- package/dist/bluefin-pool.d.ts +0 -57
- package/dist/bluefin-pool.d.ts.map +0 -1
- package/dist/bluefin-pool.js +0 -102
- package/dist/bluefin-pool.js.map +0 -1
- package/dist/cetus-pool.d.ts +0 -44
- package/dist/cetus-pool.d.ts.map +0 -1
- package/dist/cetus-pool.js +0 -57
- package/dist/cetus-pool.js.map +0 -1
- package/src/bluefin-pool.ts +0 -180
- package/src/cetus-pool.ts +0 -107
package/dist/transactions.js
CHANGED
|
@@ -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
|
|
4
|
-
import {
|
|
5
|
-
import { normalizeSharedObjectIdentity,
|
|
6
|
-
import {
|
|
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
|
|
9
|
-
/**
|
|
10
|
-
export const
|
|
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
|
-
|
|
56
|
+
/** `blast_migrators::BLAST_MIGRATORS`, the package's OTW. */
|
|
57
|
+
otw;
|
|
14
58
|
constructor(deployment) {
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
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
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
-
|
|
37
|
-
const types =
|
|
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:
|
|
41
|
-
typeArguments:
|
|
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
|
-
|
|
49
|
-
|
|
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
|
-
*
|
|
56
|
-
*
|
|
92
|
+
* `bluefin::prepare<Meme, Quote>(migrators_version, venue_config,
|
|
93
|
+
* &sealed_treasury_cap, ¤cy, 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
|
-
|
|
59
|
-
const types =
|
|
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:
|
|
64
|
-
typeArguments:
|
|
113
|
+
target: this.#target("bluefin", "prepare"),
|
|
114
|
+
typeArguments: types,
|
|
65
115
|
arguments: [
|
|
66
|
-
tx.object(options.ticket),
|
|
67
116
|
this.#migratorsVersion(tx),
|
|
68
|
-
|
|
69
|
-
|
|
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(
|
|
121
|
+
tx.pure.u64(feeRate),
|
|
72
122
|
],
|
|
73
123
|
});
|
|
74
124
|
}
|
|
75
125
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
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
|
|
82
|
-
const
|
|
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:
|
|
90
|
-
typeArguments
|
|
142
|
+
target: this.#target("cetus", "migrate"),
|
|
143
|
+
typeArguments,
|
|
91
144
|
arguments: [
|
|
92
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
*
|
|
107
|
-
*
|
|
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 =
|
|
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:
|
|
114
|
-
typeArguments:
|
|
172
|
+
target: this.#target("bluefin", "migrate"),
|
|
173
|
+
typeArguments: types,
|
|
115
174
|
arguments: [
|
|
116
|
-
|
|
175
|
+
options.migration,
|
|
117
176
|
this.#migratorsVersion(tx),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
tx.
|
|
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
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
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
|
-
|
|
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
|
-
/**
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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:
|
|
184
|
-
typeArguments
|
|
235
|
+
target: this.#target("cetus", "compound_auto_lp"),
|
|
236
|
+
typeArguments,
|
|
185
237
|
arguments: [
|
|
186
|
-
|
|
238
|
+
deploymentObject(tx, objects.vault, true),
|
|
187
239
|
this.#migratorsVersion(tx),
|
|
188
|
-
this.#
|
|
189
|
-
|
|
190
|
-
tx.object(options.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
|
202
|
-
|
|
203
|
-
const types =
|
|
204
|
-
const
|
|
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:
|
|
208
|
-
typeArguments:
|
|
263
|
+
target: this.#target("bluefin", "compound_auto_lp"),
|
|
264
|
+
typeArguments: types,
|
|
209
265
|
arguments: [
|
|
210
|
-
|
|
266
|
+
deploymentObject(tx, objects.vault, true),
|
|
211
267
|
this.#migratorsVersion(tx),
|
|
212
|
-
this.#
|
|
213
|
-
|
|
214
|
-
tx.object(options.
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
tx.
|
|
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
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
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
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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:
|
|
263
|
-
typeArguments
|
|
299
|
+
target: this.#target("cetus", "buyback_and_burn"),
|
|
300
|
+
typeArguments,
|
|
264
301
|
arguments: [
|
|
265
|
-
|
|
302
|
+
deploymentObject(tx, objects.vault, true),
|
|
266
303
|
this.#migratorsVersion(tx),
|
|
304
|
+
this.#vaultVersion(tx),
|
|
267
305
|
tx.object(options.adminWitness),
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
*
|
|
280
|
-
*
|
|
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
|
-
|
|
302
|
-
const types =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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:
|
|
367
|
-
typeArguments:
|
|
332
|
+
target: this.#target("bluefin", "buyback_and_burn"),
|
|
333
|
+
typeArguments: types,
|
|
368
334
|
arguments: [
|
|
369
|
-
|
|
335
|
+
deploymentObject(tx, objects.vault, true),
|
|
370
336
|
this.#migratorsVersion(tx),
|
|
337
|
+
this.#vaultVersion(tx),
|
|
371
338
|
tx.object(options.adminWitness),
|
|
372
|
-
tx.
|
|
373
|
-
tx.
|
|
374
|
-
tx.
|
|
375
|
-
tx.pure.
|
|
376
|
-
tx.pure.
|
|
377
|
-
tx.
|
|
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
|
-
|
|
385
|
-
|
|
386
|
-
const
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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:
|
|
399
|
-
typeArguments
|
|
360
|
+
target: this.#target("cetus", name),
|
|
361
|
+
typeArguments,
|
|
400
362
|
arguments: [
|
|
401
|
-
|
|
363
|
+
deploymentObject(tx, objects.vault, true),
|
|
402
364
|
this.#migratorsVersion(tx),
|
|
403
|
-
tx
|
|
404
|
-
tx
|
|
405
|
-
tx.
|
|
406
|
-
tx.
|
|
407
|
-
tx.
|
|
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
|
-
#
|
|
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:
|
|
416
|
-
typeArguments,
|
|
387
|
+
target: this.#target("bluefin", name),
|
|
388
|
+
typeArguments: types,
|
|
417
389
|
arguments: [
|
|
418
|
-
deploymentObject(tx,
|
|
390
|
+
deploymentObject(tx, objects.vault, true),
|
|
419
391
|
this.#migratorsVersion(tx),
|
|
420
|
-
tx
|
|
421
|
-
|
|
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
|
-
#
|
|
427
|
-
return
|
|
402
|
+
#target(module, name) {
|
|
403
|
+
return `${this.deployment.packageId}::${module}::${name}`;
|
|
428
404
|
}
|
|
429
|
-
#
|
|
430
|
-
return deploymentObject(tx, this.deployment.
|
|
405
|
+
#migratorsVersion(tx) {
|
|
406
|
+
return deploymentObject(tx, this.deployment.packageVersion, false);
|
|
431
407
|
}
|
|
432
|
-
#
|
|
433
|
-
return deploymentObject(tx, this.deployment.
|
|
408
|
+
#vaultVersion(tx) {
|
|
409
|
+
return deploymentObject(tx, this.deployment.vault.packageVersion, false);
|
|
434
410
|
}
|
|
435
|
-
#
|
|
436
|
-
return deploymentObject(tx, this.deployment.
|
|
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
|
-
|
|
442
|
-
constructor(deployment
|
|
423
|
+
admin;
|
|
424
|
+
constructor(deployment) {
|
|
443
425
|
this.call = new MigratorCalls(deployment);
|
|
444
|
-
this
|
|
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
|
-
|
|
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
|
-
|
|
534
|
-
|
|
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
|
-
|
|
541
|
-
return
|
|
434
|
+
collectBluefinFees(options) {
|
|
435
|
+
return single(this.call.collectBluefinFees(options));
|
|
542
436
|
}
|
|
543
|
-
|
|
544
|
-
return
|
|
437
|
+
settleAndApplyBluefinFeeSplit(options) {
|
|
438
|
+
return single(this.call.settleAndApplyBluefinFeeSplit(options));
|
|
545
439
|
}
|
|
546
|
-
|
|
547
|
-
return
|
|
440
|
+
compoundCetusAutoLp(options) {
|
|
441
|
+
return single(this.call.compoundCetusAutoLp(options));
|
|
548
442
|
}
|
|
549
|
-
|
|
550
|
-
return
|
|
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.#
|
|
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.#
|
|
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
|
-
#
|
|
454
|
+
#asBuybackAdmin(adminCapId, call) {
|
|
570
455
|
const tx = new Transaction();
|
|
571
|
-
const adminWitness = tx.add(this.
|
|
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
|
|
583
|
-
|
|
464
|
+
function single(step) {
|
|
465
|
+
const tx = new Transaction();
|
|
466
|
+
tx.add(step);
|
|
467
|
+
return tx;
|
|
584
468
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
: [memeType, quoteType, quoteType, memeType];
|
|
469
|
+
function pair(types) {
|
|
470
|
+
return [
|
|
471
|
+
normalizeStructTag(types.memeType),
|
|
472
|
+
normalizeStructTag(types.quoteType),
|
|
473
|
+
];
|
|
591
474
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
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
|