@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/state.d.ts
CHANGED
|
@@ -1,166 +1,46 @@
|
|
|
1
|
-
import type { SharedObjectReference } from "@interest-protocol/blast-core/sui";
|
|
2
|
-
import type { FeeSplit } from "@interest-protocol/blast-launchpad-sdk/allocation";
|
|
3
1
|
import type { ClientWithCoreApi } from "@mysten/sui/client";
|
|
4
|
-
|
|
5
|
-
export declare const MIGRATOR_VENUES: readonly ["bluefin", "cetus"];
|
|
6
|
-
export type MigratorVenue = (typeof MIGRATOR_VENUES)[number];
|
|
7
|
-
export type LaunchMigrationRoute = {
|
|
8
|
-
venue: MigratorVenue;
|
|
9
|
-
tickSpacing: number;
|
|
10
|
-
feeRate: bigint;
|
|
11
|
-
};
|
|
2
|
+
import type { MigratorsDeployment } from "./transactions.ts";
|
|
12
3
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
4
|
+
* BCS layout of `venue_config::VenueConfig`: its UID only. Venue records are
|
|
5
|
+
* dynamic fields of it, keyed by venue-sealed field-less structs
|
|
6
|
+
* (`PoolTierKey<Meme>()`, `CreationCapKey<Meme>()`) that encode as one zero
|
|
7
|
+
* byte.
|
|
16
8
|
*/
|
|
17
|
-
export declare
|
|
18
|
-
migrationWitnessType: string;
|
|
19
|
-
poolTickSpacing: number;
|
|
20
|
-
poolFeeRate: bigint;
|
|
21
|
-
}, migratorsOriginalPackageId: string): LaunchMigrationRoute;
|
|
22
|
-
/** BCS layout of `blast_fun_migrators::vault::LpVault<Meme, Quote>`. */
|
|
23
|
-
export declare const lpVaultBcs: import("@mysten/sui/bcs").BcsStruct<{
|
|
9
|
+
export declare const venueConfigBcs: import("@mysten/sui/bcs").BcsStruct<{
|
|
24
10
|
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
25
11
|
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
26
12
|
bytes: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
27
13
|
}, string>;
|
|
28
14
|
}, string>;
|
|
29
|
-
pool_id: import("@mysten/sui/bcs").BcsStruct<{
|
|
30
|
-
bytes: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
31
|
-
}, string>;
|
|
32
|
-
partner_id: import("@mysten/sui/bcs").BcsType<string | null, string | null | undefined, `Option<${string}>`>;
|
|
33
|
-
protocol_meme_residual: import("@mysten/sui/bcs").BcsStruct<{
|
|
34
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
35
|
-
}, string>;
|
|
36
|
-
protocol_quote_residual: import("@mysten/sui/bcs").BcsStruct<{
|
|
37
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
38
|
-
}, string>;
|
|
39
|
-
unpaid_protocol_meme: import("@mysten/sui/bcs").BcsStruct<{
|
|
40
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
41
|
-
}, string>;
|
|
42
|
-
unpaid_protocol_quote: import("@mysten/sui/bcs").BcsStruct<{
|
|
43
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
44
|
-
}, string>;
|
|
45
|
-
fee_split: import("@mysten/sui/bcs").BcsStruct<{
|
|
46
|
-
creatorBps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
47
|
-
autoLpBps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
48
|
-
rewardsBps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
49
|
-
burnBps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
50
|
-
recipients: import("@mysten/sui/bcs").BcsType<{
|
|
51
|
-
destination: string;
|
|
52
|
-
bps: bigint;
|
|
53
|
-
}[], Iterable<{
|
|
54
|
-
destination: string;
|
|
55
|
-
bps: bigint;
|
|
56
|
-
}> & {
|
|
57
|
-
length: number;
|
|
58
|
-
}, string>;
|
|
59
|
-
}, string>;
|
|
60
|
-
creator_meme: import("@mysten/sui/bcs").BcsStruct<{
|
|
61
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
62
|
-
}, string>;
|
|
63
|
-
creator_quote: import("@mysten/sui/bcs").BcsStruct<{
|
|
64
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
65
|
-
}, string>;
|
|
66
|
-
auto_lp_meme: import("@mysten/sui/bcs").BcsStruct<{
|
|
67
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
68
|
-
}, string>;
|
|
69
|
-
auto_lp_quote: import("@mysten/sui/bcs").BcsStruct<{
|
|
70
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
71
|
-
}, string>;
|
|
72
|
-
rewards_meme: import("@mysten/sui/bcs").BcsStruct<{
|
|
73
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
74
|
-
}, string>;
|
|
75
|
-
rewards_quote: import("@mysten/sui/bcs").BcsStruct<{
|
|
76
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
77
|
-
}, string>;
|
|
78
|
-
burn_quote: import("@mysten/sui/bcs").BcsStruct<{
|
|
79
|
-
value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
80
|
-
}, string>;
|
|
81
|
-
next_round: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
82
|
-
last_checkpoint: import("@mysten/sui/bcs").BcsType<string | null, string | number | bigint | null | undefined, "Option<u64>">;
|
|
83
|
-
}, string>;
|
|
84
|
-
/** BCS layout of `blast_fun_migrators::lp_fee_policy::SharePair`. */
|
|
85
|
-
export declare const lpFeeSharePairBcs: import("@mysten/sui/bcs").BcsStruct<{
|
|
86
|
-
meme_bps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
87
|
-
quote_bps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
88
15
|
}, string>;
|
|
89
|
-
/**
|
|
90
|
-
export declare const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
bytes: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
94
|
-
}, string>;
|
|
95
|
-
}, string>;
|
|
96
|
-
destination: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
97
|
-
defaults: import("@mysten/sui/bcs").BcsStruct<{
|
|
98
|
-
meme_bps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
99
|
-
quote_bps: import("@mysten/sui/bcs").BcsType<bigint, bigint, string>;
|
|
100
|
-
}, string>;
|
|
101
|
-
coins: import("@mysten/sui/bcs").BcsStruct<{
|
|
102
|
-
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
103
|
-
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
104
|
-
bytes: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
105
|
-
}, string>;
|
|
106
|
-
}, string>;
|
|
107
|
-
size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
108
|
-
}, string>;
|
|
16
|
+
/** `bluefin::PoolTier`: the Bluefin pool tier a Meme's migration uses. */
|
|
17
|
+
export declare const bluefinPoolTierBcs: import("@mysten/sui/bcs").BcsStruct<{
|
|
18
|
+
tick_spacing: import("@mysten/sui/bcs").BcsType<number, number, "u32">;
|
|
19
|
+
fee_rate: import("@mysten/sui/bcs").BcsType<bigint, bigint, "u64">;
|
|
109
20
|
}, string>;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
/** The partner the launch named, paid its cut of Blast's LP fees; null for none. */
|
|
115
|
-
partnerId: string | null;
|
|
116
|
-
/** Protocol-owned migration residuals, claimable by an administrator. */
|
|
117
|
-
protocolMemeResidual: bigint;
|
|
118
|
-
protocolQuoteResidual: bigint;
|
|
119
|
-
/** Blast's LP fees a partnered vault holds until `claimProtocolLpFeesWithPartner`. */
|
|
120
|
-
unpaidProtocolMeme: bigint;
|
|
121
|
-
unpaidProtocolQuote: bigint;
|
|
122
|
-
feeSplit: FeeSplit;
|
|
123
|
-
/** Creator LP fees claimable by the launch's live `CurveFeeCap`. */
|
|
124
|
-
creatorMeme: bigint;
|
|
125
|
-
creatorQuote: bigint;
|
|
126
|
-
/** Auto-LP amounts the pool did not take yet; the next collection retries. */
|
|
127
|
-
autoLpMeme: bigint;
|
|
128
|
-
autoLpQuote: bigint;
|
|
129
|
-
/** Rewards not yet reserved by a holder-reward round. */
|
|
130
|
-
rewardsMeme: bigint;
|
|
131
|
-
rewardsQuote: bigint;
|
|
132
|
-
/** Burn-share Quote waiting for a buyback admin to swap it for Meme to burn. */
|
|
133
|
-
burnQuote: bigint;
|
|
134
|
-
/** Number the next holder-reward round must carry. */
|
|
135
|
-
nextRound: bigint;
|
|
136
|
-
/** Checkpoint the next round must start at; null before the first round. */
|
|
137
|
-
lastCheckpoint: bigint | null;
|
|
138
|
-
};
|
|
139
|
-
export type LpVaultObject = SharedObjectReference<true> & {
|
|
140
|
-
type: string;
|
|
141
|
-
content: Uint8Array;
|
|
142
|
-
};
|
|
143
|
-
export type LpFeeShares = {
|
|
144
|
-
memeBps: bigint;
|
|
145
|
-
quoteBps: bigint;
|
|
146
|
-
};
|
|
147
|
-
export type LpFeePolicyState = SharedObjectReference<false> & {
|
|
148
|
-
/** Address every collection pays Blast's share to. */
|
|
149
|
-
protocolDestination: string;
|
|
150
|
-
defaultShares: LpFeeShares;
|
|
151
|
-
/** Table of per-coin share pairs, keyed by original Meme `TypeName`. */
|
|
152
|
-
coinSharesTableId: string;
|
|
153
|
-
coinSharesCount: bigint;
|
|
21
|
+
/** A Bluefin pool tier; `feeRate` is in Bluefin fee units (1,000,000 is 100%). */
|
|
22
|
+
export type BluefinPoolTier = {
|
|
23
|
+
tickSpacing: number;
|
|
24
|
+
feeRate: bigint;
|
|
154
25
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
26
|
+
type VenueConfigReader = Pick<MigratorsDeployment, "originalPackageId" | "venueConfig">;
|
|
27
|
+
/**
|
|
28
|
+
* The tick spacing `cetus::prepare` recorded for `memeType`
|
|
29
|
+
* (`cetus::PoolTierKey<Meme>`), or null before the Meme is prepared for
|
|
30
|
+
* Cetus. Pass the Meme's original (defining) type address.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getCetusPoolTier(client: ClientWithCoreApi, migrators: VenueConfigReader, memeType: string): Promise<number | null>;
|
|
33
|
+
/**
|
|
34
|
+
* The tier `bluefin::prepare` recorded for `memeType`
|
|
35
|
+
* (`bluefin::PoolTierKey<Meme>`), or null before the Meme is prepared for
|
|
36
|
+
* Bluefin.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getBluefinPoolTier(client: ClientWithCoreApi, migrators: VenueConfigReader, memeType: string): Promise<BluefinPoolTier | null>;
|
|
159
39
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
40
|
+
* The ID of the Meme type's Cetus `PoolCreationCap`, kept in `VenueConfig`
|
|
41
|
+
* under `cetus::CreationCapKey<Meme>` (the `pool_creation_cap_id` of its
|
|
42
|
+
* `CetusPoolReserved`), or null before the Meme is prepared for Cetus.
|
|
162
43
|
*/
|
|
163
|
-
export declare function
|
|
164
|
-
|
|
165
|
-
}>;
|
|
44
|
+
export declare function getCetusPoolCreationCapId(client: ClientWithCoreApi, migrators: VenueConfigReader, memeType: string): Promise<string | null>;
|
|
45
|
+
export {};
|
|
166
46
|
//# sourceMappingURL=state.d.ts.map
|
package/dist/state.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,cAAc;;;;;;UAA+C,CAAC;AAE3E,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB;;;UAG7B,CAAC;AAEH,kFAAkF;AAClF,MAAM,MAAM,eAAe,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,KAAK,iBAAiB,GAAG,IAAI,CAC3B,mBAAmB,EACnB,mBAAmB,GAAG,aAAa,CACpC,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,iBAAiB,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAGxB;AAED;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,iBAAiB,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAKjC;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,iBAAiB,EACzB,SAAS,EAAE,iBAAiB,EAC5B,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYxB"}
|
package/dist/state.js
CHANGED
|
@@ -1,187 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { normalizePositiveU64 } from "@interest-protocol/blast-core/integers";
|
|
3
|
-
import { bpsBcs, feeSplitBcs, } from "@interest-protocol/blast-launchpad-sdk/allocation";
|
|
1
|
+
import { suiUidBcs, u64Bcs, unitKeyBcs, } from "@interest-protocol/blast-core/bcs";
|
|
4
2
|
import { bcs } from "@mysten/sui/bcs";
|
|
5
3
|
import { ObjectError } from "@mysten/sui/client";
|
|
6
|
-
import { normalizeStructTag,
|
|
7
|
-
/** Venues whose adapters the migrators package ships. */
|
|
8
|
-
export const MIGRATOR_VENUES = ["bluefin", "cetus"];
|
|
4
|
+
import { normalizeStructTag, normalizeSuiObjectId } from "@mysten/sui/utils";
|
|
9
5
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
6
|
+
* BCS layout of `venue_config::VenueConfig`: its UID only. Venue records are
|
|
7
|
+
* dynamic fields of it, keyed by venue-sealed field-less structs
|
|
8
|
+
* (`PoolTierKey<Meme>()`, `CreationCapKey<Meme>()`) that encode as one zero
|
|
9
|
+
* byte.
|
|
13
10
|
*/
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const venue = tag.module;
|
|
20
|
-
if (!MIGRATOR_VENUES.includes(venue) || tag.name !== "Witness") {
|
|
21
|
-
throw new RangeError(`unsupported migration route ${tag.module}::${tag.name}`);
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
venue,
|
|
25
|
-
tickSpacing: launch.poolTickSpacing,
|
|
26
|
-
feeRate: launch.poolFeeRate,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/** BCS layout of `blast_fun_migrators::vault::LpVault<Meme, Quote>`. */
|
|
30
|
-
export const lpVaultBcs = bcs.struct("LpVault", {
|
|
31
|
-
id: suiUidBcs,
|
|
32
|
-
pool_id: suiIdBcs,
|
|
33
|
-
partner_id: bcs.option(suiObjectIdBcs),
|
|
34
|
-
protocol_meme_residual: suiBalanceBcs,
|
|
35
|
-
protocol_quote_residual: suiBalanceBcs,
|
|
36
|
-
unpaid_protocol_meme: suiBalanceBcs,
|
|
37
|
-
unpaid_protocol_quote: suiBalanceBcs,
|
|
38
|
-
fee_split: feeSplitBcs,
|
|
39
|
-
creator_meme: suiBalanceBcs,
|
|
40
|
-
creator_quote: suiBalanceBcs,
|
|
41
|
-
auto_lp_meme: suiBalanceBcs,
|
|
42
|
-
auto_lp_quote: suiBalanceBcs,
|
|
43
|
-
rewards_meme: suiBalanceBcs,
|
|
44
|
-
rewards_quote: suiBalanceBcs,
|
|
45
|
-
burn_quote: suiBalanceBcs,
|
|
46
|
-
next_round: bcs.u64(),
|
|
47
|
-
last_checkpoint: bcs.option(bcs.u64()),
|
|
11
|
+
export const venueConfigBcs = bcs.struct("VenueConfig", { id: suiUidBcs });
|
|
12
|
+
/** `bluefin::PoolTier`: the Bluefin pool tier a Meme's migration uses. */
|
|
13
|
+
export const bluefinPoolTierBcs = bcs.struct("PoolTier", {
|
|
14
|
+
tick_spacing: bcs.u32(),
|
|
15
|
+
fee_rate: u64Bcs,
|
|
48
16
|
});
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
destination: bcs.Address,
|
|
58
|
-
defaults: lpFeeSharePairBcs,
|
|
59
|
-
coins: bcs.struct("Table", { id: suiUidBcs, size: bcs.u64() }),
|
|
60
|
-
});
|
|
61
|
-
export function decodeLpVaultObject(object, originalPackageId) {
|
|
62
|
-
const tag = parseStructTag(object.type);
|
|
63
|
-
if (tag.module !== "vault" || tag.name !== "LpVault") {
|
|
64
|
-
throw new TypeError(`object ${object.objectId} is not an LP vault`);
|
|
65
|
-
}
|
|
66
|
-
if (tag.typeParams.length !== 2) {
|
|
67
|
-
throw new TypeError(`LP vault ${object.objectId} must have two type arguments`);
|
|
68
|
-
}
|
|
69
|
-
if (tag.address !== normalizeSuiAddress(originalPackageId)) {
|
|
70
|
-
throw new TypeError(`LP vault ${object.objectId} has an unexpected package`);
|
|
71
|
-
}
|
|
72
|
-
if (object.mutable !== true) {
|
|
73
|
-
throw new TypeError(`LP vault ${object.objectId} must be mutable`);
|
|
74
|
-
}
|
|
75
|
-
const parsed = lpVaultBcs.parse(object.content);
|
|
76
|
-
const objectId = normalizeSuiObjectId(object.objectId);
|
|
77
|
-
if (normalizeSuiObjectId(parsed.id.id.bytes) !== objectId) {
|
|
78
|
-
throw new TypeError(`LP vault ${object.objectId} has a mismatched UID`);
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
objectId,
|
|
82
|
-
initialSharedVersion: normalizePositiveU64("initialSharedVersion", object.initialSharedVersion),
|
|
83
|
-
mutable: true,
|
|
84
|
-
memeType: normalizeTypeParameter(tag.typeParams[0]),
|
|
85
|
-
quoteType: normalizeTypeParameter(tag.typeParams[1]),
|
|
86
|
-
poolId: normalizeSuiObjectId(parsed.pool_id.bytes),
|
|
87
|
-
partnerId: parsed.partner_id,
|
|
88
|
-
protocolMemeResidual: BigInt(parsed.protocol_meme_residual.value),
|
|
89
|
-
protocolQuoteResidual: BigInt(parsed.protocol_quote_residual.value),
|
|
90
|
-
unpaidProtocolMeme: BigInt(parsed.unpaid_protocol_meme.value),
|
|
91
|
-
unpaidProtocolQuote: BigInt(parsed.unpaid_protocol_quote.value),
|
|
92
|
-
feeSplit: parsed.fee_split,
|
|
93
|
-
creatorMeme: BigInt(parsed.creator_meme.value),
|
|
94
|
-
creatorQuote: BigInt(parsed.creator_quote.value),
|
|
95
|
-
autoLpMeme: BigInt(parsed.auto_lp_meme.value),
|
|
96
|
-
autoLpQuote: BigInt(parsed.auto_lp_quote.value),
|
|
97
|
-
rewardsMeme: BigInt(parsed.rewards_meme.value),
|
|
98
|
-
rewardsQuote: BigInt(parsed.rewards_quote.value),
|
|
99
|
-
burnQuote: BigInt(parsed.burn_quote.value),
|
|
100
|
-
nextRound: BigInt(parsed.next_round),
|
|
101
|
-
lastCheckpoint: parsed.last_checkpoint === null ? null : BigInt(parsed.last_checkpoint),
|
|
102
|
-
};
|
|
17
|
+
/**
|
|
18
|
+
* The tick spacing `cetus::prepare` recorded for `memeType`
|
|
19
|
+
* (`cetus::PoolTierKey<Meme>`), or null before the Meme is prepared for
|
|
20
|
+
* Cetus. Pass the Meme's original (defining) type address.
|
|
21
|
+
*/
|
|
22
|
+
export async function getCetusPoolTier(client, migrators, memeType) {
|
|
23
|
+
const value = await venueField(client, migrators, "cetus", memeType);
|
|
24
|
+
return value === null ? null : bcs.u32().parse(value);
|
|
103
25
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
mutable: true,
|
|
116
|
-
type: object.type,
|
|
117
|
-
content: object.content,
|
|
118
|
-
}, originalPackageId);
|
|
26
|
+
/**
|
|
27
|
+
* The tier `bluefin::prepare` recorded for `memeType`
|
|
28
|
+
* (`bluefin::PoolTierKey<Meme>`), or null before the Meme is prepared for
|
|
29
|
+
* Bluefin.
|
|
30
|
+
*/
|
|
31
|
+
export async function getBluefinPoolTier(client, migrators, memeType) {
|
|
32
|
+
const value = await venueField(client, migrators, "bluefin", memeType);
|
|
33
|
+
if (value === null)
|
|
34
|
+
return null;
|
|
35
|
+
const tier = bluefinPoolTierBcs.parse(value);
|
|
36
|
+
return { tickSpacing: tier.tick_spacing, feeRate: tier.fee_rate };
|
|
119
37
|
}
|
|
120
|
-
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
38
|
+
/**
|
|
39
|
+
* The ID of the Meme type's Cetus `PoolCreationCap`, kept in `VenueConfig`
|
|
40
|
+
* under `cetus::CreationCapKey<Meme>` (the `pool_creation_cap_id` of its
|
|
41
|
+
* `CetusPoolReserved`), or null before the Meme is prepared for Cetus.
|
|
42
|
+
*/
|
|
43
|
+
export async function getCetusPoolCreationCapId(client, migrators, memeType) {
|
|
44
|
+
try {
|
|
45
|
+
const { object } = await client.core.getDynamicObjectField({
|
|
46
|
+
parentId: normalizeSuiObjectId(migrators.venueConfig.objectId),
|
|
47
|
+
name: venueKey(migrators, "cetus", "CreationCapKey", memeType),
|
|
48
|
+
});
|
|
49
|
+
return normalizeSuiObjectId(object.objectId);
|
|
132
50
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
throw
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof ObjectError && error.reason === "notFound")
|
|
53
|
+
return null;
|
|
54
|
+
throw error;
|
|
137
55
|
}
|
|
138
|
-
return {
|
|
139
|
-
objectId: normalizeSuiObjectId(object.objectId),
|
|
140
|
-
initialSharedVersion: normalizePositiveU64("initialSharedVersion", object.owner.Shared.initialSharedVersion),
|
|
141
|
-
mutable: false,
|
|
142
|
-
protocolDestination: normalizeSuiAddress(parsed.destination),
|
|
143
|
-
defaultShares: {
|
|
144
|
-
memeBps: parsed.defaults.meme_bps,
|
|
145
|
-
quoteBps: parsed.defaults.quote_bps,
|
|
146
|
-
},
|
|
147
|
-
coinSharesTableId: normalizeSuiObjectId(parsed.coins.id.id.bytes),
|
|
148
|
-
coinSharesCount: BigInt(parsed.coins.size),
|
|
149
|
-
};
|
|
150
56
|
}
|
|
151
57
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
58
|
+
* The `VenueConfig` dynamic-field name `<original>::<venue>::<key><Meme>()`:
|
|
59
|
+
* the key type with the Meme's original type address, and one zero byte.
|
|
154
60
|
*/
|
|
155
|
-
|
|
61
|
+
function venueKey(migrators, venue, key, memeType) {
|
|
62
|
+
return {
|
|
63
|
+
type: normalizeStructTag(`${normalizeSuiObjectId(migrators.originalPackageId)}::${venue}::${key}<${normalizeStructTag(memeType)}>`),
|
|
64
|
+
bcs: unitKeyBcs.serialize(null).toBytes(),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function venueField(client, migrators, venue, memeType) {
|
|
156
68
|
try {
|
|
157
69
|
const { dynamicField } = await client.core.getDynamicField({
|
|
158
|
-
parentId:
|
|
159
|
-
name:
|
|
160
|
-
type: "0x1::type_name::TypeName",
|
|
161
|
-
bcs: moveTypeNameBcs
|
|
162
|
-
.serialize(originalTypeNameText(memeType))
|
|
163
|
-
.toBytes(),
|
|
164
|
-
},
|
|
70
|
+
parentId: normalizeSuiObjectId(migrators.venueConfig.objectId),
|
|
71
|
+
name: venueKey(migrators, venue, "PoolTierKey", memeType),
|
|
165
72
|
});
|
|
166
|
-
|
|
167
|
-
return { memeBps: pair.meme_bps, quoteBps: pair.quote_bps, source: "coin" };
|
|
73
|
+
return dynamicField.value.bcs;
|
|
168
74
|
}
|
|
169
75
|
catch (error) {
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return { ...policy.defaultShares, source: "default" };
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/** Move `TypeName` text: the normalized tag without the `0x` address prefix. */
|
|
177
|
-
function originalTypeNameText(type) {
|
|
178
|
-
const normalized = normalizeStructTag(type);
|
|
179
|
-
return normalized.startsWith("0x") ? normalized.slice(2) : normalized;
|
|
180
|
-
}
|
|
181
|
-
function normalizeTypeParameter(type) {
|
|
182
|
-
if (type === undefined || typeof type === "string") {
|
|
183
|
-
throw new TypeError("LP vault coin type must be a struct type");
|
|
76
|
+
if (error instanceof ObjectError && error.reason === "notFound")
|
|
77
|
+
return null;
|
|
78
|
+
throw error;
|
|
184
79
|
}
|
|
185
|
-
return normalizeStructTag(type);
|
|
186
80
|
}
|
|
187
81
|
//# sourceMappingURL=state.js.map
|
package/dist/state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,MAAM,EACN,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OA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