@ember-finance/sdk 2.3.1 → 2.5.0-pre.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 (58) hide show
  1. package/dist/src/abis/AtomicLiquidity.json +4050 -0
  2. package/dist/src/abis/ERC20Token.json +2 -2
  3. package/dist/src/abis/EmberETHVault.json +279 -5
  4. package/dist/src/abis/EmberProtocolConfig.json +137 -2
  5. package/dist/src/abis/EmberVault.json +2 -2
  6. package/dist/src/abis/EmberVaultMintBurnOFTAdapter.json +43 -2
  7. package/dist/src/api/v2/apis/vaults-api.d.ts +16 -4
  8. package/dist/src/api/v2/apis/vaults-api.js +21 -7
  9. package/dist/src/api/v2/models/chain-vault-details.d.ts +7 -0
  10. package/dist/src/api/v2/models/evm-atomic-liquidity-lib.d.ts +48 -0
  11. package/dist/src/api/v2/models/evm-atomic-liquidity-lib.js +14 -0
  12. package/dist/src/api/v2/models/evm-atomic-vault.d.ts +102 -0
  13. package/dist/src/api/v2/models/evm-atomic-vault.js +14 -0
  14. package/dist/src/api/v2/models/evm-contracts.d.ts +16 -0
  15. package/dist/src/api/v2/models/fee-multiplier-tier.d.ts +30 -0
  16. package/dist/src/api/v2/models/fee-multiplier-tier.js +14 -0
  17. package/dist/src/api/v2/models/index.d.ts +4 -0
  18. package/dist/src/api/v2/models/index.js +4 -0
  19. package/dist/src/api/v2/models/instant-withdraw-config.d.ts +67 -0
  20. package/dist/src/api/v2/models/instant-withdraw-config.js +14 -0
  21. package/dist/src/api/v2/models/vault-detail.d.ts +11 -0
  22. package/dist/src/api/v2/models/vault-detail.js +4 -0
  23. package/dist/src/atomic/instant-withdraw.d.ts +125 -0
  24. package/dist/src/atomic/instant-withdraw.js +122 -0
  25. package/dist/src/evm-vaults/on-chain-calls/atomic-liquidity.d.ts +98 -0
  26. package/dist/src/evm-vaults/on-chain-calls/atomic-liquidity.js +209 -0
  27. package/dist/src/evm-vaults/on-chain-calls/index.d.ts +1 -0
  28. package/dist/src/evm-vaults/on-chain-calls/index.js +1 -0
  29. package/dist/src/evm-vaults/on-chain-calls/operator.d.ts +10 -0
  30. package/dist/src/evm-vaults/on-chain-calls/operator.js +28 -0
  31. package/dist/src/evm-vaults/on-chain-calls/tx-builder.d.ts +103 -0
  32. package/dist/src/evm-vaults/on-chain-calls/tx-builder.js +273 -0
  33. package/dist/src/evm-vaults/on-chain-calls/user.d.ts +50 -0
  34. package/dist/src/evm-vaults/on-chain-calls/user.js +75 -0
  35. package/dist/src/evm-vaults/on-chain-calls/vault-admin.d.ts +48 -0
  36. package/dist/src/evm-vaults/on-chain-calls/vault-admin.js +112 -0
  37. package/dist/src/evm-vaults/on-chain-calls/vault-reader.d.ts +6 -0
  38. package/dist/src/evm-vaults/on-chain-calls/vault-reader.js +9 -0
  39. package/dist/src/evm-vaults/utils/deployment-parser.d.ts +8 -0
  40. package/dist/src/evm-vaults/utils/deployment-parser.js +11 -0
  41. package/dist/src/sui-vaults/interfaces/index.d.ts +15 -0
  42. package/dist/src/sui-vaults/on-chain-calls/admin.d.ts +35 -0
  43. package/dist/src/sui-vaults/on-chain-calls/admin.js +56 -0
  44. package/dist/src/sui-vaults/on-chain-calls/atomic-liquidity.d.ts +62 -0
  45. package/dist/src/sui-vaults/on-chain-calls/atomic-liquidity.js +174 -0
  46. package/dist/src/sui-vaults/on-chain-calls/index.d.ts +1 -0
  47. package/dist/src/sui-vaults/on-chain-calls/index.js +1 -0
  48. package/dist/src/sui-vaults/on-chain-calls/operator.d.ts +127 -0
  49. package/dist/src/sui-vaults/on-chain-calls/operator.js +210 -0
  50. package/dist/src/sui-vaults/on-chain-calls/tx-builder.d.ts +482 -0
  51. package/dist/src/sui-vaults/on-chain-calls/tx-builder.js +1430 -0
  52. package/dist/src/sui-vaults/on-chain-calls/user.d.ts +105 -0
  53. package/dist/src/sui-vaults/on-chain-calls/user.js +190 -0
  54. package/dist/src/sui-vaults/on-chain-calls/vault-admin.d.ts +228 -1
  55. package/dist/src/sui-vaults/on-chain-calls/vault-admin.js +391 -0
  56. package/dist/src/sui-vaults/utils/deployment-parser.d.ts +12 -0
  57. package/dist/src/sui-vaults/utils/deployment-parser.js +24 -0
  58. package/package.json +3 -2
@@ -27,6 +27,17 @@ export class EVMDeploymentParser {
27
27
  getProtocolConfigAddress() {
28
28
  return this.deployment.contracts?.protocolConfig.proxyAddress;
29
29
  }
30
+ /**
31
+ * Resolves the protocol config that governs a specific vault. Atomic Liquidity vaults can be
32
+ * deployed against their own protocol config (carried per-vault in the deployment), which may
33
+ * differ from the global one; admin ops for an atomic vault MUST route through that config.
34
+ * Falls back to the global protocol config for non-atomic vaults (and atomic vaults that don't
35
+ * specify one).
36
+ */
37
+ getProtocolConfigAddressForVault(vaultAddress) {
38
+ const atomic = Object.values(this.deployment.contracts?.atomicLiquidityVaults ?? {}).find(v => v.proxyAddress?.toLowerCase() === vaultAddress.toLowerCase());
39
+ return atomic?.protocolConfig ?? this.getProtocolConfigAddress();
40
+ }
30
41
  /**
31
42
  * Gets the protocol config implementation address
32
43
  */
@@ -29,6 +29,21 @@ export interface ISuiDeployment {
29
29
  DepositCoinDecimals: number;
30
30
  };
31
31
  };
32
+ AtomicVaults?: {
33
+ [key: string]: {
34
+ Admin?: Address;
35
+ Operator?: Address;
36
+ RateManager?: Address;
37
+ Name: string;
38
+ MaxRateChangePerUpdate?: string;
39
+ FeePercentage?: string;
40
+ MinWithdrawalShares?: string;
41
+ SubAccounts?: Address[];
42
+ ObjectId: Address;
43
+ CollateralCoinType: Address;
44
+ CollateralCoinDecimals: number;
45
+ };
46
+ };
32
47
  }
33
48
  export interface IDeploymentConfig {
34
49
  rpc: string;
@@ -85,4 +85,39 @@ export declare class AdminCalls extends OnChainCalls {
85
85
  * @returns OnChainCallResponse
86
86
  */
87
87
  updateMaxRateInterval(maxRateInterval: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
88
+ /**
89
+ * Create and execute a create-atomic-vault transaction. Allows admin to
90
+ * create a new atomic liquidity vault on the protocol.
91
+ * @param collateralCoinType The type of the collateral coin (T)
92
+ * @param vaultName Name of the vault
93
+ * @param adminAddress The admin address of the vault
94
+ * @param operatorAddress The operator address of the vault
95
+ * @param rateManagerAddress The rate manager address of the vault
96
+ * @param maxRateChangePerUpdate The maximum rate change per update
97
+ * @param feePercentage The fee percentage
98
+ * @param minWithdrawalShares The minimum withdrawal shares
99
+ * @param rateUpdateInterval The rate update interval
100
+ * @param maxTVL The maximum TVL of the vault
101
+ * @param subAccounts The sub accounts of the vault
102
+ * @param options Optional tx execution params
103
+ * @returns OnChainCallResponse
104
+ */
105
+ createAtomicVault(collateralCoinType: string, vaultName: string, adminAddress: SuiAddress, operatorAddress: SuiAddress, rateManagerAddress: SuiAddress, maxRateChangePerUpdate: NumStr, feePercentage: NumStr, minWithdrawalShares: NumStr, rateUpdateInterval: NumStr, maxTVL: NumStr, subAccounts: SuiAddress[], options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
106
+ /**
107
+ * Change the admin address of an atomic vault
108
+ * @param vaultId The id of the atomic vault
109
+ * @param adminAddress The new admin address
110
+ * @param options Optional tx execution params
111
+ * @returns OnChainCallResponse
112
+ */
113
+ atomicChangeVaultAdmin(vaultId: string, adminAddress: SuiAddress, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
114
+ /**
115
+ * Set / unset a blacklisted account on an atomic vault
116
+ * @param vaultId The id of the atomic vault
117
+ * @param account The account to set the blacklist status for
118
+ * @param status Whether the account should be blacklisted
119
+ * @param options Optional tx execution params
120
+ * @returns OnChainCallResponse
121
+ */
122
+ atomicSetBlacklistedAccount(vaultId: string, account: SuiAddress, status: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
88
123
  }
@@ -137,4 +137,60 @@ export class AdminCalls extends OnChainCalls {
137
137
  });
138
138
  return this.execCall(txb, options);
139
139
  }
140
+ // ============================================================================
141
+ // Atomic Liquidity Vault (BFE-818) — protocol admin methods
142
+ // ============================================================================
143
+ /**
144
+ * Create and execute a create-atomic-vault transaction. Allows admin to
145
+ * create a new atomic liquidity vault on the protocol.
146
+ * @param collateralCoinType The type of the collateral coin (T)
147
+ * @param vaultName Name of the vault
148
+ * @param adminAddress The admin address of the vault
149
+ * @param operatorAddress The operator address of the vault
150
+ * @param rateManagerAddress The rate manager address of the vault
151
+ * @param maxRateChangePerUpdate The maximum rate change per update
152
+ * @param feePercentage The fee percentage
153
+ * @param minWithdrawalShares The minimum withdrawal shares
154
+ * @param rateUpdateInterval The rate update interval
155
+ * @param maxTVL The maximum TVL of the vault
156
+ * @param subAccounts The sub accounts of the vault
157
+ * @param options Optional tx execution params
158
+ * @returns OnChainCallResponse
159
+ */
160
+ async createAtomicVault(collateralCoinType, vaultName, adminAddress, operatorAddress, rateManagerAddress, maxRateChangePerUpdate, feePercentage, minWithdrawalShares, rateUpdateInterval, maxTVL, subAccounts, options) {
161
+ const txb = options?.txBlock || new TransactionBlock();
162
+ this.txBuilder.createAtomicVault(collateralCoinType, vaultName, adminAddress, operatorAddress, rateManagerAddress, maxRateChangePerUpdate, feePercentage, minWithdrawalShares, rateUpdateInterval, maxTVL, subAccounts, { ...options, txBlock: txb });
163
+ return this.execCall(txb, options);
164
+ }
165
+ /**
166
+ * Change the admin address of an atomic vault
167
+ * @param vaultId The id of the atomic vault
168
+ * @param adminAddress The new admin address
169
+ * @param options Optional tx execution params
170
+ * @returns OnChainCallResponse
171
+ */
172
+ async atomicChangeVaultAdmin(vaultId, adminAddress, options) {
173
+ const txb = options?.txBlock || new TransactionBlock();
174
+ this.txBuilder.atomicChangeVaultAdmin(vaultId, adminAddress, {
175
+ ...options,
176
+ txBlock: txb
177
+ });
178
+ return this.execCall(txb, options);
179
+ }
180
+ /**
181
+ * Set / unset a blacklisted account on an atomic vault
182
+ * @param vaultId The id of the atomic vault
183
+ * @param account The account to set the blacklist status for
184
+ * @param status Whether the account should be blacklisted
185
+ * @param options Optional tx execution params
186
+ * @returns OnChainCallResponse
187
+ */
188
+ async atomicSetBlacklistedAccount(vaultId, account, status, options) {
189
+ const txb = options?.txBlock || new TransactionBlock();
190
+ this.txBuilder.atomicSetBlacklistedAccount(vaultId, account, status, {
191
+ ...options,
192
+ txBlock: txb
193
+ });
194
+ return this.execCall(txb, options);
195
+ }
140
196
  }
@@ -0,0 +1,62 @@
1
+ import { SuiClient } from "@firefly-exchange/library-sui";
2
+ import { FeeMultiplierTier, InstantWithdrawQuote } from "../../atomic/instant-withdraw.js";
3
+ /**
4
+ * Read-only views + instant-withdraw quotes for the Sui Atomic Liquidity Vault (BET-4111).
5
+ *
6
+ * There is no on-chain preview function and no off-chain view calls on Sui, so this reads
7
+ * the ALV (and source vault) object fields directly and replicates the Move math
8
+ * (`calculate_amount_from_shares`, `get_vault_tvl`, `swap_ember_shares`,
9
+ * `do_instant_withdraw_core`) via the shared chain-agnostic quote core at scale 1e9.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const reader = new SuiAtomicLiquidityReader(suiClient);
14
+ * const q = await reader.previewSwapInstantWithdraw(vaultId, sourceVaultId, 100_000000n, owner);
15
+ * ```
16
+ */
17
+ export declare class SuiAtomicLiquidityReader {
18
+ suiClient: SuiClient;
19
+ constructor(suiClient: SuiClient);
20
+ /** Raw Move fields of the AtomicLiquidityVault object. */
21
+ private vaultFields;
22
+ /**
23
+ * Read a `Table<K, V>` entry value. Table entries are plain dynamic fields, so we
24
+ * resolve the `Field<K,V>` object id via `getDynamicField`, then fetch its json
25
+ * (`{ name, value }`). Returns the unwrapped `value`, or null if absent.
26
+ */
27
+ private readTableValue;
28
+ /** Rate value (1e9) of any vault object (ALV or source EmberVault). */
29
+ private rateValue;
30
+ /** Per-source-share EmberShare config from the `ember_share_configs` table. */
31
+ getEmberShareConfig(vaultId: string, sourceVaultId: string): Promise<{
32
+ whitelisted: boolean;
33
+ feePercentage: bigint;
34
+ holdbackPercentage: bigint;
35
+ maxCapacityPercentage: bigint;
36
+ maxUtilizationPercentage: bigint;
37
+ epochStartedAt: bigint;
38
+ epochUsedAmount: bigint;
39
+ feeMultiplierCurve: FeeMultiplierTier[];
40
+ } | null>;
41
+ /** Caller's ALV (non-transferable) share balance from the `shares` table. */
42
+ shareOf(vaultId: string, account: string): Promise<bigint>;
43
+ /**
44
+ * Live quote for the EmberShare swap-with-holdback "instant withdraw" on Sui.
45
+ * Reads ALV + source vault fields and replicates `swap_ember_shares` math.
46
+ *
47
+ * `currentHeldValue` defaults to 0 (the common case before any swap); pass it when the
48
+ * ALV already custodies source shares. `availableCapacity` (remaining 24h epoch capacity,
49
+ * collateral units) is bfvs-sourced when precise epoch accounting is required — when
50
+ * omitted, only the utilization cap gates `withinCapacity`.
51
+ */
52
+ previewSwapInstantWithdraw(vaultId: string, sourceVaultId: string, shareAmount: bigint, owner: string, opts?: {
53
+ availableCapacity?: bigint;
54
+ currentHeldValue?: bigint;
55
+ userShareBalance?: bigint;
56
+ }): Promise<InstantWithdrawQuote>;
57
+ /**
58
+ * Live quote for the ALV's own plain `instant_withdraw` on Sui (atomic-share holders).
59
+ * `net = gross - fee`, no holdback, capped by `max_instant_withdraw_shares`.
60
+ */
61
+ previewPlainInstantWithdraw(vaultId: string, shareAmount: bigint, owner: string): Promise<InstantWithdrawQuote>;
62
+ }
@@ -0,0 +1,174 @@
1
+ import { bcs } from "@mysten/sui/bcs";
2
+ import { computeSwapQuote, computePlainInstantQuote } from "../../atomic/instant-withdraw.js";
3
+ /** Sui fixed-point scale (1e9) used by the Atomic Liquidity Vault Move math. */
4
+ const SUI_SCALE = 1000000000n;
5
+ const unwrapMoveFields = (value) => value?.fields ?? value;
6
+ const toBig = (v) => v === undefined || v === null ? 0n : BigInt(v);
7
+ /** `math::div(a, b)` = floor(a * scale / b). */
8
+ const divFloor = (a, b) => (b === 0n ? 0n : (a * SUI_SCALE) / b);
9
+ /** `math::div_ceil(a, b)` = ceil(a * scale / b) — used by `calculate_amount_from_shares`. */
10
+ const divCeil = (a, b) => b === 0n ? 0n : (a * SUI_SCALE + (b - 1n)) / b;
11
+ /**
12
+ * Read-only views + instant-withdraw quotes for the Sui Atomic Liquidity Vault (BET-4111).
13
+ *
14
+ * There is no on-chain preview function and no off-chain view calls on Sui, so this reads
15
+ * the ALV (and source vault) object fields directly and replicates the Move math
16
+ * (`calculate_amount_from_shares`, `get_vault_tvl`, `swap_ember_shares`,
17
+ * `do_instant_withdraw_core`) via the shared chain-agnostic quote core at scale 1e9.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const reader = new SuiAtomicLiquidityReader(suiClient);
22
+ * const q = await reader.previewSwapInstantWithdraw(vaultId, sourceVaultId, 100_000000n, owner);
23
+ * ```
24
+ */
25
+ export class SuiAtomicLiquidityReader {
26
+ constructor(suiClient) {
27
+ this.suiClient = suiClient;
28
+ }
29
+ /** Raw Move fields of the AtomicLiquidityVault object. */
30
+ async vaultFields(vaultId) {
31
+ const res = await this.suiClient.core.getObject({
32
+ objectId: vaultId,
33
+ include: { json: true }
34
+ });
35
+ const fields = unwrapMoveFields(res.object?.json);
36
+ if (!fields)
37
+ throw new Error(`Atomic vault ${vaultId} not found`);
38
+ return fields;
39
+ }
40
+ /**
41
+ * Read a `Table<K, V>` entry value. Table entries are plain dynamic fields, so we
42
+ * resolve the `Field<K,V>` object id via `getDynamicField`, then fetch its json
43
+ * (`{ name, value }`). Returns the unwrapped `value`, or null if absent.
44
+ */
45
+ async readTableValue(parentId, nameType, keyAddress) {
46
+ try {
47
+ const df = await this.suiClient.core.getDynamicField({
48
+ parentId,
49
+ name: { type: nameType, bcs: bcs.Address.serialize(keyAddress).toBytes() }
50
+ });
51
+ const fieldId = df?.dynamicField?.fieldId;
52
+ if (!fieldId)
53
+ return null;
54
+ const obj = await this.suiClient.core.getObject({
55
+ objectId: fieldId,
56
+ include: { json: true }
57
+ });
58
+ return unwrapMoveFields(obj.object?.json)?.value;
59
+ }
60
+ catch {
61
+ return null;
62
+ }
63
+ }
64
+ /** Rate value (1e9) of any vault object (ALV or source EmberVault). */
65
+ async rateValue(vaultId) {
66
+ const res = await this.suiClient.core.getObject({
67
+ objectId: vaultId,
68
+ include: { json: true }
69
+ });
70
+ const fields = unwrapMoveFields(res.object?.json);
71
+ return toBig(unwrapMoveFields(fields?.rate)?.value);
72
+ }
73
+ /** Per-source-share EmberShare config from the `ember_share_configs` table. */
74
+ async getEmberShareConfig(vaultId, sourceVaultId) {
75
+ const fields = await this.vaultFields(vaultId);
76
+ const tableId = unwrapMoveFields(fields.ember_share_configs)?.id?.id;
77
+ if (!tableId)
78
+ return null;
79
+ {
80
+ const cfg = unwrapMoveFields(await this.readTableValue(tableId, "0x2::object::ID", sourceVaultId));
81
+ if (!cfg)
82
+ return null;
83
+ const curve = (cfg.fee_multiplier_curve || []).map((t) => {
84
+ const tf = unwrapMoveFields(t);
85
+ return {
86
+ threshold: toBig(tf.threshold),
87
+ multiplier: toBig(tf.multiplier)
88
+ };
89
+ });
90
+ return {
91
+ whitelisted: !!cfg.whitelisted,
92
+ feePercentage: toBig(cfg.fee_percentage),
93
+ holdbackPercentage: toBig(cfg.holdback_percentage),
94
+ maxCapacityPercentage: toBig(cfg.max_capacity_percentage),
95
+ maxUtilizationPercentage: toBig(cfg.max_utilization_percentage),
96
+ epochStartedAt: toBig(cfg.epoch_started_at),
97
+ epochUsedAmount: toBig(cfg.epoch_used_amount),
98
+ feeMultiplierCurve: curve
99
+ };
100
+ }
101
+ }
102
+ /** Caller's ALV (non-transferable) share balance from the `shares` table. */
103
+ async shareOf(vaultId, account) {
104
+ const fields = await this.vaultFields(vaultId);
105
+ const tableId = unwrapMoveFields(fields.shares)?.id?.id;
106
+ if (!tableId)
107
+ return 0n;
108
+ return toBig(await this.readTableValue(tableId, "address", account));
109
+ }
110
+ /**
111
+ * Live quote for the EmberShare swap-with-holdback "instant withdraw" on Sui.
112
+ * Reads ALV + source vault fields and replicates `swap_ember_shares` math.
113
+ *
114
+ * `currentHeldValue` defaults to 0 (the common case before any swap); pass it when the
115
+ * ALV already custodies source shares. `availableCapacity` (remaining 24h epoch capacity,
116
+ * collateral units) is bfvs-sourced when precise epoch accounting is required — when
117
+ * omitted, only the utilization cap gates `withinCapacity`.
118
+ */
119
+ async previewSwapInstantWithdraw(vaultId, sourceVaultId, shareAmount, owner, opts = {}) {
120
+ const fields = await this.vaultFields(vaultId);
121
+ const atomicRate = toBig(unwrapMoveFields(fields.rate)?.value);
122
+ const totalShares = toBig(fields.total_shares);
123
+ const feeWaived = fields.fee_waived_addresses || [];
124
+ const holdbackWaived = fields.holdback_waived_addresses || [];
125
+ const [config, sourceRate] = await Promise.all([
126
+ this.getEmberShareConfig(vaultId, sourceVaultId),
127
+ this.rateValue(sourceVaultId)
128
+ ]);
129
+ if (!config)
130
+ throw new Error(`source vault ${sourceVaultId} not whitelisted`);
131
+ // gross = calculate_amount_from_shares(source, shareAmount) = div_ceil(shares, sourceRate)
132
+ const grossAmount = divCeil(shareAmount, sourceRate);
133
+ // tvl = get_vault_tvl(atomic) = div(total_shares, atomicRate)
134
+ const vaultTotalAssets = divFloor(totalShares, atomicRate);
135
+ return computeSwapQuote({
136
+ scale: SUI_SCALE,
137
+ grossAmount,
138
+ shareAmount,
139
+ userShareBalance: opts.userShareBalance ?? 0n,
140
+ currentHeldValue: opts.currentHeldValue ?? 0n,
141
+ vaultTotalAssets,
142
+ // Default to "epoch capacity not binding" when not supplied; the on-chain
143
+ // swap still enforces it. Pass from bfvs for an exact pre-check.
144
+ availableCapacity: opts.availableCapacity ?? grossAmount,
145
+ config: {
146
+ feePercentage: config.feePercentage,
147
+ holdbackPercentage: config.holdbackPercentage,
148
+ maxUtilizationPercentage: config.maxUtilizationPercentage,
149
+ feeMultiplierCurve: config.feeMultiplierCurve
150
+ },
151
+ feeWaived: feeWaived.includes(owner),
152
+ holdbackWaived: holdbackWaived.includes(owner)
153
+ });
154
+ }
155
+ /**
156
+ * Live quote for the ALV's own plain `instant_withdraw` on Sui (atomic-share holders).
157
+ * `net = gross - fee`, no holdback, capped by `max_instant_withdraw_shares`.
158
+ */
159
+ async previewPlainInstantWithdraw(vaultId, shareAmount, owner) {
160
+ const fields = await this.vaultFields(vaultId);
161
+ const atomicRate = toBig(unwrapMoveFields(fields.rate)?.value);
162
+ const grossAmount = divCeil(shareAmount, atomicRate);
163
+ const userShareBalance = await this.shareOf(vaultId, owner);
164
+ return computePlainInstantQuote({
165
+ scale: SUI_SCALE,
166
+ grossAmount,
167
+ shareAmount,
168
+ userShareBalance,
169
+ instantWithdrawFeePercentage: toBig(fields.instant_withdraw_fee_percentage),
170
+ cumulativeInstantWithdrawShares: toBig(fields.cumulative_instant_withdraw_shares),
171
+ maxInstantWithdrawShares: toBig(fields.max_instant_withdraw_shares)
172
+ });
173
+ }
174
+ }
@@ -4,3 +4,4 @@ export * from "./user.js";
4
4
  export * from "./vault-admin.js";
5
5
  export * from "./operator.js";
6
6
  export * from "./vault.js";
7
+ export * from "./atomic-liquidity.js";
@@ -4,3 +4,4 @@ export * from "./user.js";
4
4
  export * from "./vault-admin.js";
5
5
  export * from "./operator.js";
6
6
  export * from "./vault.js";
7
+ export * from "./atomic-liquidity.js";
@@ -100,4 +100,131 @@ export declare class OperatorCalls extends OnChainCalls {
100
100
  * @returns OnChainCallResponse
101
101
  */
102
102
  setFeeExemptionList(vaultId: string, user: SuiAddress, status: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
103
+ /**
104
+ * Process pending withdrawal requests of an atomic vault
105
+ * @param vaultId The id of the atomic vault
106
+ * @param maxRequests The maximum number of withdrawal requests to process
107
+ * @param options Optional tx execution params
108
+ * @returns OnChainCallResponse
109
+ */
110
+ atomicProcessWithdrawalRequests(vaultId: string, maxRequests: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
111
+ /**
112
+ * Process pending withdrawal requests of an atomic vault up to a timestamp
113
+ * @param vaultId The id of the atomic vault
114
+ * @param timestamp The timestamp to process withdrawal requests up to
115
+ * @param options Optional tx execution params
116
+ * @returns OnChainCallResponse
117
+ */
118
+ atomicProcessWithdrawalRequestsUpToTimestamp(vaultId: string, timestamp: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
119
+ /**
120
+ * Collect the platform fee of an atomic vault
121
+ * @param vaultId The id of the atomic vault
122
+ * @param loss The reported loss amount
123
+ * @param options Optional tx execution params
124
+ * @returns OnChainCallResponse
125
+ */
126
+ atomicCollectPlatformFee(vaultId: string, loss: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
127
+ /**
128
+ * Supply collateral from an atomic vault into the Suilend strategy
129
+ * @param vaultId The id of the atomic vault
130
+ * @param poolCoinType The Suilend pool coin type (P)
131
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
132
+ * @param amount The amount to supply
133
+ * @param options Optional tx execution params
134
+ * @returns OnChainCallResponse
135
+ */
136
+ atomicSupplyToSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
137
+ /**
138
+ * Supply collateral from an atomic vault into the AlphaLend strategy
139
+ * @param vaultId The id of the atomic vault
140
+ * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
141
+ * @param amount The amount to supply
142
+ * @param options Optional tx execution params
143
+ * @returns OnChainCallResponse
144
+ */
145
+ atomicSupplyToAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
146
+ /**
147
+ * Withdraw collateral from the Suilend strategy back into an atomic vault
148
+ * @param vaultId The id of the atomic vault
149
+ * @param poolCoinType The Suilend pool coin type (P)
150
+ * @param lendingMarketId Object id of the Suilend LendingMarket<P>
151
+ * @param amount The amount to withdraw
152
+ * @param options Optional tx execution params
153
+ * @returns OnChainCallResponse
154
+ */
155
+ atomicWithdrawFromSuilendStrategy(vaultId: string, poolCoinType: string, lendingMarketId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
156
+ /**
157
+ * Withdraw collateral from the AlphaLend strategy back into an atomic vault
158
+ * @param vaultId The id of the atomic vault
159
+ * @param lendingProtocolId Object id of the AlphaLend LendingProtocol
160
+ * @param amount The amount to withdraw
161
+ * @param options Optional tx execution params
162
+ * @returns OnChainCallResponse
163
+ */
164
+ atomicWithdrawFromAlphalendStrategy(vaultId: string, lendingProtocolId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
165
+ /**
166
+ * Supply collateral from an atomic vault to one of its sub accounts
167
+ * @param vaultId The id of the atomic vault
168
+ * @param subAccount The sub account address
169
+ * @param amount The amount to supply
170
+ * @param options Optional tx execution params
171
+ * @returns OnChainCallResponse
172
+ */
173
+ atomicSupplyToSubAccount(vaultId: string, subAccount: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
174
+ /**
175
+ * Deposit collateral back into an atomic vault from a sub account
176
+ * @param vaultId The id of the atomic vault
177
+ * @param tokenId Object id of the Receiving<Coin<T>> payment to claim
178
+ * @param subAccount The sub account address
179
+ * @param options Optional tx execution params
180
+ * @returns OnChainCallResponse
181
+ */
182
+ atomicDepositFromSubAccount(vaultId: string, tokenId: string, subAccount: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
183
+ /**
184
+ * Redeem collected ember shares from an atomic vault against a source vault
185
+ * @param vaultId The id of the atomic vault
186
+ * @param sourceReceiptType The receipt coin type of the source vault (R)
187
+ * @param sourceVaultId Object id of the source Vault<T, R>
188
+ * @param amount The amount of shares to redeem
189
+ * @param options Optional tx execution params
190
+ * @returns OnChainCallResponse
191
+ */
192
+ atomicRedeemCollectedEmberShares(vaultId: string, sourceReceiptType: string, sourceVaultId: string, amount: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
193
+ /**
194
+ * Release users' holdback for an ember share source vault
195
+ * @param vaultId The id of the atomic vault
196
+ * @param shareVaultId Id of the source ember share vault
197
+ * @param unwindingPercentage The unwinding percentage
198
+ * @param maxEntries The max entries to process
199
+ * @param options Optional tx execution params
200
+ * @returns OnChainCallResponse
201
+ */
202
+ atomicReleaseUsersHoldback(vaultId: string, shareVaultId: string, unwindingPercentage: NumStr, maxEntries: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
203
+ /**
204
+ * Claim received collateral (a Receiving<Coin<T>>) for an atomic vault
205
+ * @param vaultId The id of the atomic vault
206
+ * @param tokenId Object id of the Receiving<Coin<T>> payment to claim
207
+ * @param options Optional tx execution params
208
+ * @returns OnChainCallResponse
209
+ */
210
+ atomicClaimReceivedCollateral(vaultId: string, tokenId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
211
+ /**
212
+ * Claim returned ember shares (a Receiving<Coin<R>>) for an atomic vault
213
+ * @param vaultId The id of the atomic vault
214
+ * @param sourceReceiptType The receipt coin type of the source vault (R)
215
+ * @param sourceVaultId Id of the source vault the shares belong to
216
+ * @param tokenId Object id of the Receiving<Coin<R>> payment to claim
217
+ * @param options Optional tx execution params
218
+ * @returns OnChainCallResponse
219
+ */
220
+ atomicClaimReturnedEmberShares(vaultId: string, sourceReceiptType: string, sourceVaultId: string, tokenId: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
221
+ /**
222
+ * Update the rate of an atomic vault (rate manager role; uses operator class
223
+ * to mirror the receipt-vault `updateVaultRate` placement)
224
+ * @param vaultId The id of the atomic vault
225
+ * @param newRate The new rate to set for the vault
226
+ * @param options Optional tx execution params
227
+ * @returns OnChainCallResponse
228
+ */
229
+ atomicUpdateVaultRate(vaultId: string, newRate: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
103
230
  }