@t2000/sdk 10.3.1 → 10.6.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/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/{commerce-CUGyTRcv.d.cts → commerce-D78r4-MZ.d.cts} +1 -1
- package/dist/{commerce-CUGyTRcv.d.ts → commerce-D78r4-MZ.d.ts} +1 -1
- package/dist/index.cjs +354 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +171 -8
- package/dist/index.d.ts +171 -8
- package/dist/index.js +337 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { normalizeStructTag, isValidSuiAddress,
|
|
1
|
+
import { normalizeSuiAddress, normalizeStructTag, isValidSuiAddress, fromBase64 } from '@mysten/sui/utils';
|
|
2
2
|
import { coinWithBalance, Transaction } from '@mysten/sui/transactions';
|
|
3
3
|
import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
|
|
4
4
|
import BN from 'bn.js';
|
|
@@ -17,6 +17,7 @@ import { sha256 } from '@noble/hashes/sha256';
|
|
|
17
17
|
import { hexToBytes, bytesToHex } from '@noble/hashes/utils';
|
|
18
18
|
import { readFileSync, existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
19
19
|
import { SuinsTransaction } from '@mysten/suins';
|
|
20
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
20
21
|
|
|
21
22
|
var __defProp = Object.defineProperty;
|
|
22
23
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -3882,6 +3883,340 @@ function displayHandle(label, parentName = AUDRIC_PARENT_NAME) {
|
|
|
3882
3883
|
// src/index.ts
|
|
3883
3884
|
init_preflight();
|
|
3884
3885
|
|
|
3885
|
-
|
|
3886
|
+
// src/capital/launch.ts
|
|
3887
|
+
init_errors();
|
|
3888
|
+
init_token_registry();
|
|
3889
|
+
init_coinSelection();
|
|
3890
|
+
|
|
3891
|
+
// src/protocols/cetus-clmm.ts
|
|
3892
|
+
var CETUS_CLMM_PACKAGE_ID = process.env.CETUS_CLMM_PACKAGE_ID ?? "0x1eabed72c53feb3805120a081dc15963c204dc8d091542592abaf7a35689b2fb";
|
|
3893
|
+
var CETUS_CLMM_PUBLISHED_AT = process.env.CETUS_CLMM_PUBLISHED_AT ?? "0x25ebb9a7c50eb17b3fa9c5a30fb8b5ad8f97caaf4928943acbcff7153dfee5e3";
|
|
3894
|
+
var CETUS_GLOBAL_CONFIG_ID = process.env.CETUS_GLOBAL_CONFIG_ID ?? "0xdaa46292632c3c4d8f31f23ea0f9b36a28ff3677e9684980e4438403a67a3d8f";
|
|
3895
|
+
var CETUS_POOLS_ID = process.env.CETUS_POOLS_ID ?? "0xf699e7f2276f5c9a75944b37a0c5b5d9ddfd2471bf6242483b03ab2887d198d0";
|
|
3896
|
+
var CETUS_POSITION_TYPE = `${CETUS_CLMM_PACKAGE_ID}::position::Position`;
|
|
3897
|
+
var AGENT_POOL_TICK_SPACING = 200;
|
|
3898
|
+
function sqrtPriceX64FromAmounts(rawA, rawB) {
|
|
3899
|
+
if (rawA <= 0n || rawB <= 0n) {
|
|
3900
|
+
throw new Error("sqrtPriceX64FromAmounts: amounts must be positive");
|
|
3901
|
+
}
|
|
3902
|
+
return bigintSqrt((rawB << 128n) / rawA);
|
|
3903
|
+
}
|
|
3904
|
+
function bigintSqrt(n) {
|
|
3905
|
+
if (n < 0n) throw new Error("bigintSqrt: negative input");
|
|
3906
|
+
if (n < 2n) return n;
|
|
3907
|
+
let x = 1n << BigInt(n.toString(2).length + 1) / 2n;
|
|
3908
|
+
let prev = x + 1n;
|
|
3909
|
+
while (x < prev) {
|
|
3910
|
+
prev = x;
|
|
3911
|
+
x = (x + n / x) / 2n;
|
|
3912
|
+
}
|
|
3913
|
+
return prev;
|
|
3914
|
+
}
|
|
3915
|
+
function createPoolV2(tx, args) {
|
|
3916
|
+
const [tickLower, tickUpper] = fullRangeTickRange(tx);
|
|
3917
|
+
return tx.moveCall({
|
|
3918
|
+
target: `${CETUS_CLMM_PUBLISHED_AT}::pool_creator::create_pool_v2`,
|
|
3919
|
+
typeArguments: [args.coinTypeA, args.coinTypeB],
|
|
3920
|
+
arguments: [
|
|
3921
|
+
tx.object(CETUS_GLOBAL_CONFIG_ID),
|
|
3922
|
+
tx.object(CETUS_POOLS_ID),
|
|
3923
|
+
tx.pure.u32(AGENT_POOL_TICK_SPACING),
|
|
3924
|
+
tx.pure.u128(args.sqrtPriceX64),
|
|
3925
|
+
tx.pure.string(args.url ?? ""),
|
|
3926
|
+
tickLower,
|
|
3927
|
+
tickUpper,
|
|
3928
|
+
args.coinA,
|
|
3929
|
+
args.coinB,
|
|
3930
|
+
tx.object(args.metadataA),
|
|
3931
|
+
tx.object(args.metadataB),
|
|
3932
|
+
tx.pure.bool(args.fixAmountA),
|
|
3933
|
+
tx.object.clock()
|
|
3934
|
+
]
|
|
3935
|
+
});
|
|
3936
|
+
}
|
|
3937
|
+
function fullRangeTickRange(tx) {
|
|
3938
|
+
const result = tx.moveCall({
|
|
3939
|
+
target: `${CETUS_CLMM_PUBLISHED_AT}::pool_creator::full_range_tick_range`,
|
|
3940
|
+
arguments: [tx.pure.u32(AGENT_POOL_TICK_SPACING)]
|
|
3941
|
+
});
|
|
3942
|
+
return [result[0], result[1]];
|
|
3943
|
+
}
|
|
3944
|
+
function positionPoolId(tx, position) {
|
|
3945
|
+
return tx.moveCall({
|
|
3946
|
+
target: `${CETUS_CLMM_PUBLISHED_AT}::position::pool_id`,
|
|
3947
|
+
arguments: [position]
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
// src/capital/template.ts
|
|
3952
|
+
init_errors();
|
|
3953
|
+
|
|
3954
|
+
// src/capital/template-bytecode.json
|
|
3955
|
+
var template_bytecode_default = {
|
|
3956
|
+
modules: [
|
|
3957
|
+
"oRzrCwcAAAUKAQAMAgwkAzAoBFgMBWRoB8wBzwEImwNgBvsDiQEKhAUFDIkFNAARAQ0CBwISAhMCFAADAgABAgcBAAACAAwBAAECAQwBAAECBAwBAAEEBQIABQYHAAAKAAEAARAFBgEAAggICQECAgsKCwEAAw4FAQEMAw8NAQEMBQwDBAABBAIHAwcFDAQOBA8CCAAHCAUAAgsDAQgACwQBCAABCgIBCAYBCQABCwEBCQABCAAHCQACCgIKAgoCCwEBCAYHCAUCCwQBCQALAwEJAAMHCwQBCQADBwgFAQsCAQkAAQsCAQgAAgkABQELAwEIAAELBAEIAARDb2luDENvaW5NZXRhZGF0YQZPcHRpb24IVEVNUExBVEULVHJlYXN1cnlDYXAJVHhDb250ZXh0A1VybARjb2luD2NyZWF0ZV9jdXJyZW5jeQtkdW1teV9maWVsZARpbml0BG1pbnQVbmV3X3Vuc2FmZV9mcm9tX2J5dGVzBm9wdGlvbhRwdWJsaWNfZnJlZXplX29iamVjdA9wdWJsaWNfdHJhbnNmZXIEc29tZQh0ZW1wbGF0ZQh0cmFuc2Zlcgp0eF9jb250ZXh0A3VybAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgIBBgoCBQRUTVBMCgIODVRlbXBsYXRlIENvaW4KAh4dYnl0ZWNvZGUgdGVtcGxhdGUgcGxhY2Vob2xkZXIKAh0caHR0cHM6Ly9leGFtcGxlLmNvbS9pY29uLnN2ZwMIAIDGpH6NAwAFIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMr+AAIBCQEAAAAAAhcLAAcABwEHAgcDBwQRBjgACgE4AQwCDAMNAwcFCwE4AgcGOAMLAjgECwM4BQIAAA=="
|
|
3958
|
+
],
|
|
3959
|
+
dependencies: [
|
|
3960
|
+
"0x0000000000000000000000000000000000000000000000000000000000000001",
|
|
3961
|
+
"0x0000000000000000000000000000000000000000000000000000000000000002"
|
|
3962
|
+
]};
|
|
3963
|
+
|
|
3964
|
+
// src/capital/template.ts
|
|
3965
|
+
var TEMPLATE = {
|
|
3966
|
+
module: "template",
|
|
3967
|
+
otw: "TEMPLATE",
|
|
3968
|
+
symbol: "TMPL",
|
|
3969
|
+
name: "Template Coin",
|
|
3970
|
+
description: "bytecode template placeholder",
|
|
3971
|
+
iconUrl: "https://example.com/icon.svg",
|
|
3972
|
+
totalSupply: 1000000000000000n,
|
|
3973
|
+
recipient: normalizeSuiAddress("0xCAFE")
|
|
3974
|
+
};
|
|
3975
|
+
var AGENT_TOKEN_DECIMALS = 6;
|
|
3976
|
+
var AGENT_TOKEN_TOTAL_SUPPLY = 1000000000000000n;
|
|
3977
|
+
var AGENT_TOKEN_LP_ALLOCATION = AGENT_TOKEN_TOTAL_SUPPLY / 2n;
|
|
3978
|
+
var AGENT_TOKEN_TREASURY_ALLOCATION = AGENT_TOKEN_TOTAL_SUPPLY - AGENT_TOKEN_LP_ALLOCATION;
|
|
3979
|
+
var SYMBOL_BLOCKLIST = /* @__PURE__ */ new Set([
|
|
3980
|
+
"SUI",
|
|
3981
|
+
"USDC",
|
|
3982
|
+
"USDT",
|
|
3983
|
+
"USDSUI",
|
|
3984
|
+
"WAL",
|
|
3985
|
+
"CETUS",
|
|
3986
|
+
"DEEP",
|
|
3987
|
+
"NS",
|
|
3988
|
+
"NAVX",
|
|
3989
|
+
"SCA",
|
|
3990
|
+
"AFSUI",
|
|
3991
|
+
"HASUI",
|
|
3992
|
+
"VSUI",
|
|
3993
|
+
"BUCK",
|
|
3994
|
+
"FUD",
|
|
3995
|
+
"BLUB",
|
|
3996
|
+
"HIPPO",
|
|
3997
|
+
"BTC",
|
|
3998
|
+
"WBTC",
|
|
3999
|
+
"ETH",
|
|
4000
|
+
"WETH",
|
|
4001
|
+
"SOL",
|
|
4002
|
+
"BNB",
|
|
4003
|
+
"XRP",
|
|
4004
|
+
"ADA",
|
|
4005
|
+
"DOGE",
|
|
4006
|
+
"AVAX",
|
|
4007
|
+
"LINK",
|
|
4008
|
+
"TRX",
|
|
4009
|
+
"TON",
|
|
4010
|
+
"SHIB",
|
|
4011
|
+
"PEPE",
|
|
4012
|
+
"USDE",
|
|
4013
|
+
"DAI",
|
|
4014
|
+
"GOLD",
|
|
4015
|
+
"XAUM",
|
|
4016
|
+
"T2000",
|
|
4017
|
+
"T2K",
|
|
4018
|
+
"AUDRIC"
|
|
4019
|
+
]);
|
|
4020
|
+
var SYMBOL_RE = /^[A-Z][A-Z0-9]{1,7}$/;
|
|
4021
|
+
function validateAgentCoinParams(params) {
|
|
4022
|
+
const symbol = params.symbol.toUpperCase();
|
|
4023
|
+
if (!SYMBOL_RE.test(symbol)) {
|
|
4024
|
+
throw new T2000Error(
|
|
4025
|
+
"INVALID_INPUT",
|
|
4026
|
+
`symbol must be 2-8 chars, A-Z then A-Z0-9 (got "${params.symbol}")`
|
|
4027
|
+
);
|
|
4028
|
+
}
|
|
4029
|
+
if (SYMBOL_BLOCKLIST.has(symbol)) {
|
|
4030
|
+
throw new T2000Error(
|
|
4031
|
+
"INVALID_INPUT",
|
|
4032
|
+
`symbol ${symbol} impersonates an existing ticker`
|
|
4033
|
+
);
|
|
4034
|
+
}
|
|
4035
|
+
if (!params.name.trim() || params.name.length > 64) {
|
|
4036
|
+
throw new T2000Error("INVALID_INPUT", "name must be 1-64 chars");
|
|
4037
|
+
}
|
|
4038
|
+
if (params.description.length > 256) {
|
|
4039
|
+
throw new T2000Error("INVALID_INPUT", "description must be \u2264256 chars");
|
|
4040
|
+
}
|
|
4041
|
+
if (!/^https:\/\/.+/.test(params.iconUrl) || params.iconUrl.length > 256) {
|
|
4042
|
+
throw new T2000Error("INVALID_INPUT", "iconUrl must be https and \u2264256 chars");
|
|
4043
|
+
}
|
|
4044
|
+
if (!isValidSuiAddress(params.recipient)) {
|
|
4045
|
+
throw new T2000Error("INVALID_ADDRESS", `bad recipient: ${params.recipient}`);
|
|
4046
|
+
}
|
|
4047
|
+
}
|
|
4048
|
+
async function buildAgentCoinModule(params) {
|
|
4049
|
+
const { deserialize, serialize, update_constants, update_identifiers } = await import('@mysten/move-bytecode-template');
|
|
4050
|
+
validateAgentCoinParams(params);
|
|
4051
|
+
const symbol = params.symbol.toUpperCase();
|
|
4052
|
+
const moduleName = symbol.toLowerCase();
|
|
4053
|
+
const recipient = normalizeSuiAddress(params.recipient);
|
|
4054
|
+
let bytes = Uint8Array.from(
|
|
4055
|
+
Buffer.from(template_bytecode_default.modules[0], "base64")
|
|
4056
|
+
);
|
|
4057
|
+
deserialize(bytes);
|
|
4058
|
+
bytes = update_identifiers(bytes, {
|
|
4059
|
+
[TEMPLATE.module]: moduleName,
|
|
4060
|
+
[TEMPLATE.otw]: symbol
|
|
4061
|
+
});
|
|
4062
|
+
const str = (s) => bcs.string().serialize(s).toBytes();
|
|
4063
|
+
const rewrites = [
|
|
4064
|
+
[str(symbol), str(TEMPLATE.symbol), "Vector(U8)"],
|
|
4065
|
+
[str(params.name), str(TEMPLATE.name), "Vector(U8)"],
|
|
4066
|
+
[str(params.description), str(TEMPLATE.description), "Vector(U8)"],
|
|
4067
|
+
[str(params.iconUrl), str(TEMPLATE.iconUrl), "Vector(U8)"],
|
|
4068
|
+
[
|
|
4069
|
+
bcs.Address.serialize(recipient).toBytes(),
|
|
4070
|
+
bcs.Address.serialize(TEMPLATE.recipient).toBytes(),
|
|
4071
|
+
"Address"
|
|
4072
|
+
],
|
|
4073
|
+
// Supply + decimals are LOCKED v1 constants — not caller-parameterized —
|
|
4074
|
+
// but rewritten anyway so a drifted template recompile can't silently
|
|
4075
|
+
// change the economics out from under this module's exported constants.
|
|
4076
|
+
[
|
|
4077
|
+
bcs.u64().serialize(AGENT_TOKEN_TOTAL_SUPPLY).toBytes(),
|
|
4078
|
+
bcs.u64().serialize(TEMPLATE.totalSupply).toBytes(),
|
|
4079
|
+
"U64"
|
|
4080
|
+
]
|
|
4081
|
+
];
|
|
4082
|
+
for (const [next, prev, type] of rewrites) {
|
|
4083
|
+
bytes = update_constants(bytes, next, prev, type);
|
|
4084
|
+
}
|
|
4085
|
+
serialize(deserialize(bytes));
|
|
4086
|
+
return {
|
|
4087
|
+
modules: [Array.from(bytes)],
|
|
4088
|
+
dependencies: template_bytecode_default.dependencies,
|
|
4089
|
+
moduleName,
|
|
4090
|
+
otw: symbol
|
|
4091
|
+
};
|
|
4092
|
+
}
|
|
4093
|
+
|
|
4094
|
+
// src/capital/launch.ts
|
|
4095
|
+
var AGENT_CAPITAL_PACKAGE_ID = process.env.AGENT_CAPITAL_PACKAGE_ID ?? "0x33a04c672381c1de7178f56221e4ebfc4712675feecc2a0b70c25efbb500fc25";
|
|
4096
|
+
var CAPITAL_REGISTRY_ID = process.env.CAPITAL_REGISTRY_ID ?? "0xd75a72e80c1a5181cc9bb095089cc236e3e20be11b5982ab21e76c54508bd2d7";
|
|
4097
|
+
var CAPITAL_REGISTRY_VERSION = Number(
|
|
4098
|
+
process.env.CAPITAL_REGISTRY_VERSION ?? 951301211
|
|
4099
|
+
);
|
|
4100
|
+
function assertDeployed() {
|
|
4101
|
+
if (!AGENT_CAPITAL_PACKAGE_ID || !CAPITAL_REGISTRY_ID) {
|
|
4102
|
+
throw new T2000Error(
|
|
4103
|
+
"PROTOCOL_UNAVAILABLE",
|
|
4104
|
+
"agent_capital is not deployed on this network (set AGENT_CAPITAL_PACKAGE_ID + CAPITAL_REGISTRY_ID)"
|
|
4105
|
+
);
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
var MIN_LP_USDC = 5000000n;
|
|
4109
|
+
var REGISTRY_MODULE = "registry";
|
|
4110
|
+
var LP_LOCK_MODULE = "lp_lock";
|
|
4111
|
+
async function buildPublishAgentCoinTx(args) {
|
|
4112
|
+
if (!isValidSuiAddress(args.launcher)) {
|
|
4113
|
+
throw new T2000Error("INVALID_ADDRESS", `bad launcher: ${args.launcher}`);
|
|
4114
|
+
}
|
|
4115
|
+
if (args.coin.recipient !== args.launcher) {
|
|
4116
|
+
throw new T2000Error(
|
|
4117
|
+
"INVALID_INPUT",
|
|
4118
|
+
"coin.recipient must equal launcher \u2014 the full supply lands with the launch signer, never a third party"
|
|
4119
|
+
);
|
|
4120
|
+
}
|
|
4121
|
+
const mod = await buildAgentCoinModule(args.coin);
|
|
4122
|
+
const tx = new Transaction();
|
|
4123
|
+
tx.setSender(args.launcher);
|
|
4124
|
+
const [upgradeCap] = tx.publish({
|
|
4125
|
+
modules: mod.modules,
|
|
4126
|
+
dependencies: mod.dependencies
|
|
4127
|
+
});
|
|
4128
|
+
tx.moveCall({
|
|
4129
|
+
target: "0x2::package::make_immutable",
|
|
4130
|
+
arguments: [upgradeCap]
|
|
4131
|
+
});
|
|
4132
|
+
return { tx, moduleName: mod.moduleName, otw: mod.otw };
|
|
4133
|
+
}
|
|
4134
|
+
var USDC_COIN_METADATA_ID = "0x75cfbbf8c962d542e99a1d15731e6069f60a00db895407785b15d14f606f2b4a";
|
|
4135
|
+
async function buildTokenizeTx(args) {
|
|
4136
|
+
assertDeployed();
|
|
4137
|
+
if (!isValidSuiAddress(args.agent)) {
|
|
4138
|
+
throw new T2000Error("INVALID_ADDRESS", `bad agent: ${args.agent}`);
|
|
4139
|
+
}
|
|
4140
|
+
if (!isValidSuiAddress(args.launcher)) {
|
|
4141
|
+
throw new T2000Error("INVALID_ADDRESS", `bad launcher: ${args.launcher}`);
|
|
4142
|
+
}
|
|
4143
|
+
if (args.lpUsdcAmount < MIN_LP_USDC) {
|
|
4144
|
+
throw new T2000Error(
|
|
4145
|
+
"INVALID_AMOUNT",
|
|
4146
|
+
`lpUsdcAmount ${args.lpUsdcAmount} < minimum ${MIN_LP_USDC} raw (5 USDC)`
|
|
4147
|
+
);
|
|
4148
|
+
}
|
|
4149
|
+
const tx = new Transaction();
|
|
4150
|
+
tx.setSender(args.launcher);
|
|
4151
|
+
const registryArg = () => tx.sharedObjectRef({
|
|
4152
|
+
objectId: CAPITAL_REGISTRY_ID,
|
|
4153
|
+
initialSharedVersion: CAPITAL_REGISTRY_VERSION,
|
|
4154
|
+
mutable: true
|
|
4155
|
+
});
|
|
4156
|
+
tx.moveCall({
|
|
4157
|
+
target: `${AGENT_CAPITAL_PACKAGE_ID}::${REGISTRY_MODULE}::bind`,
|
|
4158
|
+
typeArguments: [args.coinType],
|
|
4159
|
+
arguments: [
|
|
4160
|
+
registryArg(),
|
|
4161
|
+
tx.object(args.agentRegistryId),
|
|
4162
|
+
tx.pure.address(args.agent),
|
|
4163
|
+
tx.object.clock()
|
|
4164
|
+
]
|
|
4165
|
+
});
|
|
4166
|
+
const supplyCoin = tx.object(args.supplyCoinId);
|
|
4167
|
+
const [lpCoin] = tx.splitCoins(supplyCoin, [
|
|
4168
|
+
tx.pure.u64(AGENT_TOKEN_LP_ALLOCATION)
|
|
4169
|
+
]);
|
|
4170
|
+
const { coin: lpUsdc } = await selectAndSplitCoin(
|
|
4171
|
+
tx,
|
|
4172
|
+
args.client,
|
|
4173
|
+
args.launcher,
|
|
4174
|
+
USDC_TYPE,
|
|
4175
|
+
args.lpUsdcAmount
|
|
4176
|
+
);
|
|
4177
|
+
const usdcFirst = args.usdcFirst ?? false;
|
|
4178
|
+
const sqrtPrice = usdcFirst ? sqrtPriceX64FromAmounts(args.lpUsdcAmount, AGENT_TOKEN_LP_ALLOCATION) : sqrtPriceX64FromAmounts(AGENT_TOKEN_LP_ALLOCATION, args.lpUsdcAmount);
|
|
4179
|
+
const usdcMeta = args.usdcMetadataId ?? USDC_COIN_METADATA_ID;
|
|
4180
|
+
const poolResult = createPoolV2(tx, {
|
|
4181
|
+
coinTypeA: usdcFirst ? USDC_TYPE : args.coinType,
|
|
4182
|
+
coinTypeB: usdcFirst ? args.coinType : USDC_TYPE,
|
|
4183
|
+
metadataA: usdcFirst ? usdcMeta : args.coinMetadataId,
|
|
4184
|
+
metadataB: usdcFirst ? args.coinMetadataId : usdcMeta,
|
|
4185
|
+
coinA: usdcFirst ? lpUsdc : lpCoin,
|
|
4186
|
+
coinB: usdcFirst ? lpCoin : lpUsdc,
|
|
4187
|
+
sqrtPriceX64: sqrtPrice,
|
|
4188
|
+
fixAmountA: !usdcFirst,
|
|
4189
|
+
// always fix the AGENT side
|
|
4190
|
+
url: args.poolUrl
|
|
4191
|
+
});
|
|
4192
|
+
const position = poolResult[0];
|
|
4193
|
+
const refundA = poolResult[1];
|
|
4194
|
+
const refundB = poolResult[2];
|
|
4195
|
+
const poolId = positionPoolId(tx, position);
|
|
4196
|
+
const [lockId] = tx.moveCall({
|
|
4197
|
+
target: `${AGENT_CAPITAL_PACKAGE_ID}::${LP_LOCK_MODULE}::lock`,
|
|
4198
|
+
typeArguments: [CETUS_POSITION_TYPE],
|
|
4199
|
+
arguments: [position, tx.pure.address(args.agent), tx.object.clock()]
|
|
4200
|
+
});
|
|
4201
|
+
tx.moveCall({
|
|
4202
|
+
target: `${AGENT_CAPITAL_PACKAGE_ID}::${REGISTRY_MODULE}::finalize`,
|
|
4203
|
+
typeArguments: [args.coinType],
|
|
4204
|
+
arguments: [
|
|
4205
|
+
registryArg(),
|
|
4206
|
+
tx.object(args.agentRegistryId),
|
|
4207
|
+
tx.pure.address(args.agent),
|
|
4208
|
+
poolId,
|
|
4209
|
+
lockId,
|
|
4210
|
+
tx.object.clock()
|
|
4211
|
+
]
|
|
4212
|
+
});
|
|
4213
|
+
const agentRefund = usdcFirst ? refundB : refundA;
|
|
4214
|
+
const usdcRefund = usdcFirst ? refundA : refundB;
|
|
4215
|
+
tx.transferObjects([supplyCoin, agentRefund], tx.pure.address(args.agent));
|
|
4216
|
+
tx.transferObjects([usdcRefund], tx.pure.address(args.launcher));
|
|
4217
|
+
return tx;
|
|
4218
|
+
}
|
|
4219
|
+
|
|
4220
|
+
export { A2A_ESCROW_FEE_CONFIG_ID, A2A_ESCROW_PACKAGE_ID, AGENT_CAPITAL_PACKAGE_ID, AGENT_ID_PARENT, AGENT_ID_PARENT_NAME, AGENT_ID_PARENT_NFT_ID, AGENT_POOL_TICK_SPACING, AGENT_TOKEN_DECIMALS, AGENT_TOKEN_LP_ALLOCATION, AGENT_TOKEN_TOTAL_SUPPLY, AGENT_TOKEN_TREASURY_ALLOCATION, AUDRIC_PARENT, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, CAPITAL_REGISTRY_ID, CAPITAL_REGISTRY_VERSION, CETUS_CLMM_PACKAGE_ID, CETUS_GLOBAL_CONFIG_ID, CETUS_POOLS_ID, CETUS_POSITION_TYPE, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, DEFAULT_API_BASE, DEFAULT_COMMERCE_API_BASE, DEFAULT_GRPC_URL, DEFAULT_NETWORK, ETH_TYPE, GASLESS_MIN_STABLE_AMOUNT, GASLESS_STABLE_TYPES, GAS_RESERVE_MIN, IKA_TYPE, InvalidAddressError, JOB_STATES, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, LimitEnforcer, LimitExceededError, MANIFEST_TYPE, MAX_DELIVER_HORIZON_MS, MAX_JOB_USDC, MAX_REVIEW_WINDOW_MS, MIN_LP_USDC, MIST_PER_SUI, NAVX_TYPE, OPERATION_ASSETS, OVERLAY_FEE_RATE, PREFLIGHT_MAX_AMOUNT, PREFLIGHT_OK, SENDABLE_ASSETS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SYMBOL_BLOCKLIST, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_COIN_METADATA_ID, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addSendToTx, addSwapToTx, approxUsdValue, assertAllowedAsset, assertLimitConfig, buildAddLeafTx, buildAgentCoinModule, buildCreateJobTx, buildDeliverJobTx, buildPublishAgentCoinTx, buildRefundJobTx, buildRejectJobTx, buildReleaseJobTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, buildTokenizeTx, chatCompletion, chatCompletionStream, checkPositiveAmount, checkSuiAddress, classifyAction, classifyLabel, classifyTransaction, clearLimits, composeTx, dailySpentToday, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, executeTx, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, fetchService, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getJob, getJobSpec, getLimits, getSponsoredSwapProviders, getSuiClient, getSuiGrpcClient, getSwapQuote, hasLimits, isAllowedAsset, isCetusRouteFresh, isInRegistry, jobActionsFor, keypairFromPrivateKey, listModels, listServices, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseMppSuiChallenge, parseSuiRpcTx, payWithMpp, preflightCreateJob, preflightFail, preflightPay, preflightSend, preflightSwap, putJobSpec, queryBalance, queryHistory, queryTransaction, rawToStable, rawToUsdc, readLimitsFile, recordDailySpend, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveBech32, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, setLimits, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateAgentCoinParams, validateLabel, verifyCetusRouteCoinMatch, verifyJobForSeller, verifyReceipt, walletExists, writeLimitsFile };
|
|
3886
4221
|
//# sourceMappingURL=index.js.map
|
|
3887
4222
|
//# sourceMappingURL=index.js.map
|