@ember-finance/sdk 2.0.2 → 2.0.4

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.
@@ -305,7 +305,7 @@ export class EVMUserCalls extends EVMOnChainCalls {
305
305
  if (!this.provider) {
306
306
  throw new Error("Provider required for bridge send read operations and allowance checks");
307
307
  }
308
- const adapter = this.parser.getOFTAdapterObjectByVaultId(tokenAddress);
308
+ const adapter = this.parser.getOFTAdapterObjectByVaultAddress(tokenAddress);
309
309
  if (!adapter?.address) {
310
310
  throw new Error(`OFT adapter not found for token address: ${tokenAddress}`);
311
311
  }
@@ -464,25 +464,25 @@ export declare class EVMVaultReader {
464
464
  * @returns Array of complete vault info for all vaults
465
465
  */
466
466
  getAllVaultsInfo(): Promise<ICompleteVaultInfo[]>;
467
- getOFTAdapterAddressByVaultId(vaultId: string): string | null;
467
+ getOFTAdapterAddressByVaultAddress(vaultAddress: string): string | null;
468
468
  /**
469
469
  * Creates an ethers Contract instance for an OFT adapter
470
470
  */
471
471
  private getOFTAdapterContract;
472
472
  /**
473
- * Resolves and instantiates the OFT adapter contract for a vault identifier.
473
+ * Resolves and instantiates the OFT adapter contract for a vault address.
474
474
  *
475
- * @param vaultId Vault identifier (receipt token address on EVM)
475
+ * @param vaultAddress Vault address (receipt token address on EVM)
476
476
  * @returns OFT adapter contract instance, or null if no adapter is configured
477
477
  */
478
- private getOFTAdapterByVaultId;
478
+ private getOFTAdapterByVaultAddress;
479
479
  /**
480
480
  * Returns the list of destination chains that an OFT adapter has peers configured for.
481
481
  *
482
- * @param vaultId The vault identifier (receipt token address on EVM)
482
+ * @param vaultAddress The vault identifier (receipt token address on EVM)
483
483
  * @returns Destination chains enriched with OFT adapter and peer metadata
484
484
  */
485
- getOFTSupportedChains(vaultId: string, supportedChains?: Chain[]): Promise<IOFTVaultSupportedChain[]>;
485
+ getOFTSupportedChains(vaultAddress: string, supportedChains?: Chain[]): Promise<IOFTVaultSupportedChain[]>;
486
486
  /**
487
487
  * Gets a fee quote for bridging tokens to another chain via LayerZero OFT.
488
488
  * Combines both the messaging fee (quoteSend) and the OFT transfer details
@@ -572,8 +572,8 @@ export class EVMVaultReader {
572
572
  return this.getMultipleVaultsInfo(addresses);
573
573
  }
574
574
  // ========== Bridge / OFT Methods ==========
575
- getOFTAdapterAddressByVaultId(vaultId) {
576
- const adapter = this.parser.getOFTAdapterObjectByVaultId(vaultId);
575
+ getOFTAdapterAddressByVaultAddress(vaultAddress) {
576
+ const adapter = this.parser.getOFTAdapterObjectByVaultAddress(vaultAddress);
577
577
  if (!adapter?.address) {
578
578
  return null;
579
579
  }
@@ -590,13 +590,13 @@ export class EVMVaultReader {
590
590
  return new Contract(adapterAddress, EmberVaultOFTAdapterABI.abi, this.provider);
591
591
  }
592
592
  /**
593
- * Resolves and instantiates the OFT adapter contract for a vault identifier.
593
+ * Resolves and instantiates the OFT adapter contract for a vault address.
594
594
  *
595
- * @param vaultId Vault identifier (receipt token address on EVM)
595
+ * @param vaultAddress Vault address (receipt token address on EVM)
596
596
  * @returns OFT adapter contract instance, or null if no adapter is configured
597
597
  */
598
- getOFTAdapterByVaultId(vaultId) {
599
- const adapterAddress = this.getOFTAdapterAddressByVaultId(vaultId);
598
+ getOFTAdapterByVaultAddress(vaultAddress) {
599
+ const adapterAddress = this.getOFTAdapterAddressByVaultAddress(vaultAddress);
600
600
  if (!adapterAddress) {
601
601
  return null;
602
602
  }
@@ -605,12 +605,12 @@ export class EVMVaultReader {
605
605
  /**
606
606
  * Returns the list of destination chains that an OFT adapter has peers configured for.
607
607
  *
608
- * @param vaultId The vault identifier (receipt token address on EVM)
608
+ * @param vaultAddress The vault identifier (receipt token address on EVM)
609
609
  * @returns Destination chains enriched with OFT adapter and peer metadata
610
610
  */
611
- async getOFTSupportedChains(vaultId, supportedChains) {
612
- const adapter = this.parser.getOFTAdapterObjectByVaultId(vaultId);
613
- const adapterAddress = this.getOFTAdapterAddressByVaultId(vaultId);
611
+ async getOFTSupportedChains(vaultAddress, supportedChains) {
612
+ const adapter = this.parser.getOFTAdapterObjectByVaultAddress(vaultAddress);
613
+ const adapterAddress = this.getOFTAdapterAddressByVaultAddress(vaultAddress);
614
614
  if (!adapter || !adapterAddress) {
615
615
  return [];
616
616
  }
@@ -627,7 +627,7 @@ export class EVMVaultReader {
627
627
  chains.push({
628
628
  ...chain,
629
629
  adapterAddress,
630
- vaultId,
630
+ vaultId: vaultAddress,
631
631
  lzEndpointId: lzChainId,
632
632
  chainIdentifier: chain.identifier,
633
633
  peerAddress: peer.decodedAddress
@@ -646,7 +646,7 @@ export class EVMVaultReader {
646
646
  * @returns Combined fee quote including native fee and expected amounts
647
647
  */
648
648
  async getOFTFeeQuote(vaultId, sendParam, payInLzToken = false) {
649
- const adapter = this.getOFTAdapterByVaultId(vaultId);
649
+ const adapter = this.getOFTAdapterByVaultAddress(vaultId);
650
650
  if (!adapter) {
651
651
  throw new Error(`OFT adapter not found for vault: ${vaultId}`);
652
652
  }
@@ -99,5 +99,5 @@ export declare class EVMDeploymentParser {
99
99
  * Finds the OFT adapter entry for a given vault address.
100
100
  * @param vaultAddress The vault address (receipt token address in EVM deployment data)
101
101
  */
102
- getOFTAdapterObjectByVaultId(vaultAddress: string): EvmOFTAdapter | undefined;
102
+ getOFTAdapterObjectByVaultAddress(vaultAddress: string): EvmOFTAdapter | undefined;
103
103
  }
@@ -161,7 +161,7 @@ export class EVMDeploymentParser {
161
161
  * Finds the OFT adapter entry for a given vault address.
162
162
  * @param vaultAddress The vault address (receipt token address in EVM deployment data)
163
163
  */
164
- getOFTAdapterObjectByVaultId(vaultAddress) {
164
+ getOFTAdapterObjectByVaultAddress(vaultAddress) {
165
165
  const entry = Object.values(this.deployment.contracts?.oftAdapters ?? {}).find(adapter => adapter.vaultAddress?.toLowerCase() === vaultAddress.toLowerCase());
166
166
  if (!entry) {
167
167
  return undefined;
@@ -1,6 +1,6 @@
1
1
  import { OnChainCalls } from "./onchain-calls.js";
2
2
  import { ISuiDeployment, IVaultOptionalParams } from "../interfaces/index.js";
3
- import { OnChainCallResponse, Signer, SuiClient, SuiTransactionBlockResponseOptions } from "@firefly-exchange/library-sui";
3
+ import { OnChainCallResponse, Signer, SuiAddress, SuiClient, SuiTransactionBlockResponseOptions } from "@firefly-exchange/library-sui";
4
4
  import { NumStr } from "@firefly-exchange/library-sui";
5
5
  export declare class OperatorCalls extends OnChainCalls {
6
6
  constructor(_network: string, _suiClient: SuiClient, _deployment: ISuiDeployment, _signer?: Signer, _walletAddress?: string);
@@ -82,4 +82,22 @@ export declare class OperatorCalls extends OnChainCalls {
82
82
  * @returns OnChainCallResponse
83
83
  */
84
84
  setBlacklistedAccount(vaultId: string, account: string, isBlacklisted: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
85
+ /**
86
+ * Set/unset user in deposit user list
87
+ * @param vaultId The id of the vault
88
+ * @param user The user address to set in the list
89
+ * @param status Whether the user should be in the list
90
+ * @param options Optional tx execution params
91
+ * @returns OnChainCallResponse
92
+ */
93
+ setDepositUserList(vaultId: string, user: SuiAddress, status: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
94
+ /**
95
+ * Set/unset user in fee exemption list
96
+ * @param vaultId The id of the vault
97
+ * @param user The user address to set in the list
98
+ * @param status Whether the user should be in the list
99
+ * @param options Optional tx execution params
100
+ * @returns OnChainCallResponse
101
+ */
102
+ setFeeExemptionList(vaultId: string, user: SuiAddress, status: boolean, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
85
103
  }
@@ -145,4 +145,36 @@ export class OperatorCalls extends OnChainCalls {
145
145
  });
146
146
  return this.execCall(txb, options);
147
147
  }
148
+ /**
149
+ * Set/unset user in deposit user list
150
+ * @param vaultId The id of the vault
151
+ * @param user The user address to set in the list
152
+ * @param status Whether the user should be in the list
153
+ * @param options Optional tx execution params
154
+ * @returns OnChainCallResponse
155
+ */
156
+ async setDepositUserList(vaultId, user, status, options) {
157
+ const txb = options?.txBlock || new TransactionBlock();
158
+ this.txBuilder.setDepositUserList(vaultId, user, status, {
159
+ ...options,
160
+ txBlock: txb
161
+ });
162
+ return this.execCall(txb, options);
163
+ }
164
+ /**
165
+ * Set/unset user in fee exemption list
166
+ * @param vaultId The id of the vault
167
+ * @param user The user address to set in the list
168
+ * @param status Whether the user should be in the list
169
+ * @param options Optional tx execution params
170
+ * @returns OnChainCallResponse
171
+ */
172
+ async setFeeExemptionList(vaultId, user, status, options) {
173
+ const txb = options?.txBlock || new TransactionBlock();
174
+ this.txBuilder.setFeeExemptionList(vaultId, user, status, {
175
+ ...options,
176
+ txBlock: txb
177
+ });
178
+ return this.execCall(txb, options);
179
+ }
148
180
  }
@@ -163,6 +163,48 @@ export declare class TxBuilder {
163
163
  * @returns TransactionBlock
164
164
  */
165
165
  setBlacklistedAccount(vaultId: string, account: string, isBlacklisted: boolean, options?: ITxBuilderOptionalParams): TransactionBlock;
166
+ /**
167
+ * Sets a user on the deposit user list
168
+ * @param vaultId Id of the vault
169
+ * @param user Address of the user
170
+ * @param status Status of the user in the deposit list
171
+ * @param options Optional tx building params
172
+ * @returns TransactionBlock
173
+ */
174
+ setDepositUserList(vaultId: string, user: string, status: boolean, options?: ITxBuilderOptionalParams): TransactionBlock;
175
+ /**
176
+ * Sets a user on the fee exemption list
177
+ * @param vaultId Id of the vault
178
+ * @param user Address of the user
179
+ * @param status Status of the user in the fee exemption list
180
+ * @param options Optional tx building params
181
+ * @returns TransactionBlock
182
+ */
183
+ setFeeExemptionList(vaultId: string, user: string, status: boolean, options?: ITxBuilderOptionalParams): TransactionBlock;
184
+ /**
185
+ * Sets the permanent withdrawal fee percentage
186
+ * @param vaultId Id of the vault
187
+ * @param permanentFeePercentage Permanent fee percentage
188
+ * @param options Optional tx building params
189
+ * @returns TransactionBlock
190
+ */
191
+ setPermanentFeePercentage(vaultId: string, permanentFeePercentage: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
192
+ /**
193
+ * Sets the time based withdrawal fee percentage
194
+ * @param vaultId Id of the vault
195
+ * @param timeBasedFeePercentage Time based fee percentage
196
+ * @param options Optional tx building params
197
+ * @returns TransactionBlock
198
+ */
199
+ setTimeBasedFeePercentage(vaultId: string, timeBasedFeePercentage: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
200
+ /**
201
+ * Sets the time based withdrawal fee threshold
202
+ * @param vaultId Id of the vault
203
+ * @param timeBasedFeeThreshold Time based fee threshold
204
+ * @param options Optional tx building params
205
+ * @returns TransactionBlock
206
+ */
207
+ setTimeBasedFeeThreshold(vaultId: string, timeBasedFeeThreshold: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
166
208
  /**
167
209
  * Updates the rate of the vault
168
210
  * @param vaultId Id of the vault
@@ -501,6 +501,145 @@ export class TxBuilder {
501
501
  txb.setSenderIfNotSet(options.sender);
502
502
  return txb;
503
503
  }
504
+ /**
505
+ * Sets a user on the deposit user list
506
+ * @param vaultId Id of the vault
507
+ * @param user Address of the user
508
+ * @param status Status of the user in the deposit list
509
+ * @param options Optional tx building params
510
+ * @returns TransactionBlock
511
+ */
512
+ setDepositUserList(vaultId, user, status, options) {
513
+ const txb = options?.txBlock || new TransactionBlock();
514
+ txb.moveCall({
515
+ arguments: [
516
+ txb.object(vaultId),
517
+ txb.object(this.parser.getProtocolConfig()),
518
+ txb.pure.address(user),
519
+ txb.pure.bool(status)
520
+ ],
521
+ typeArguments: [
522
+ this.parser.getDepositCoinType(vaultId),
523
+ this.parser.getReceiptCoinType(vaultId)
524
+ ],
525
+ target: `${this.parser.getPackageId()}::gateway::set_deposit_user_list`
526
+ });
527
+ if (options?.gasBudget)
528
+ txb.setGasBudget(options.gasBudget);
529
+ if (options?.sender)
530
+ txb.setSenderIfNotSet(options.sender);
531
+ return txb;
532
+ }
533
+ /**
534
+ * Sets a user on the fee exemption list
535
+ * @param vaultId Id of the vault
536
+ * @param user Address of the user
537
+ * @param status Status of the user in the fee exemption list
538
+ * @param options Optional tx building params
539
+ * @returns TransactionBlock
540
+ */
541
+ setFeeExemptionList(vaultId, user, status, options) {
542
+ const txb = options?.txBlock || new TransactionBlock();
543
+ txb.moveCall({
544
+ arguments: [
545
+ txb.object(vaultId),
546
+ txb.object(this.parser.getProtocolConfig()),
547
+ txb.pure.address(user),
548
+ txb.pure.bool(status)
549
+ ],
550
+ typeArguments: [
551
+ this.parser.getDepositCoinType(vaultId),
552
+ this.parser.getReceiptCoinType(vaultId)
553
+ ],
554
+ target: `${this.parser.getPackageId()}::gateway::set_fee_exemption_list`
555
+ });
556
+ if (options?.gasBudget)
557
+ txb.setGasBudget(options.gasBudget);
558
+ if (options?.sender)
559
+ txb.setSenderIfNotSet(options.sender);
560
+ return txb;
561
+ }
562
+ /**
563
+ * Sets the permanent withdrawal fee percentage
564
+ * @param vaultId Id of the vault
565
+ * @param permanentFeePercentage Permanent fee percentage
566
+ * @param options Optional tx building params
567
+ * @returns TransactionBlock
568
+ */
569
+ setPermanentFeePercentage(vaultId, permanentFeePercentage, options) {
570
+ const txb = options?.txBlock || new TransactionBlock();
571
+ txb.moveCall({
572
+ arguments: [
573
+ txb.object(vaultId),
574
+ txb.object(this.parser.getProtocolConfig()),
575
+ txb.pure.u64(permanentFeePercentage)
576
+ ],
577
+ typeArguments: [
578
+ this.parser.getDepositCoinType(vaultId),
579
+ this.parser.getReceiptCoinType(vaultId)
580
+ ],
581
+ target: `${this.parser.getPackageId()}::gateway::set_permanent_fee_percentage`
582
+ });
583
+ if (options?.gasBudget)
584
+ txb.setGasBudget(options.gasBudget);
585
+ if (options?.sender)
586
+ txb.setSenderIfNotSet(options.sender);
587
+ return txb;
588
+ }
589
+ /**
590
+ * Sets the time based withdrawal fee percentage
591
+ * @param vaultId Id of the vault
592
+ * @param timeBasedFeePercentage Time based fee percentage
593
+ * @param options Optional tx building params
594
+ * @returns TransactionBlock
595
+ */
596
+ setTimeBasedFeePercentage(vaultId, timeBasedFeePercentage, options) {
597
+ const txb = options?.txBlock || new TransactionBlock();
598
+ txb.moveCall({
599
+ arguments: [
600
+ txb.object(vaultId),
601
+ txb.object(this.parser.getProtocolConfig()),
602
+ txb.pure.u64(timeBasedFeePercentage)
603
+ ],
604
+ typeArguments: [
605
+ this.parser.getDepositCoinType(vaultId),
606
+ this.parser.getReceiptCoinType(vaultId)
607
+ ],
608
+ target: `${this.parser.getPackageId()}::gateway::set_time_based_fee_percentage`
609
+ });
610
+ if (options?.gasBudget)
611
+ txb.setGasBudget(options.gasBudget);
612
+ if (options?.sender)
613
+ txb.setSenderIfNotSet(options.sender);
614
+ return txb;
615
+ }
616
+ /**
617
+ * Sets the time based withdrawal fee threshold
618
+ * @param vaultId Id of the vault
619
+ * @param timeBasedFeeThreshold Time based fee threshold
620
+ * @param options Optional tx building params
621
+ * @returns TransactionBlock
622
+ */
623
+ setTimeBasedFeeThreshold(vaultId, timeBasedFeeThreshold, options) {
624
+ const txb = options?.txBlock || new TransactionBlock();
625
+ txb.moveCall({
626
+ arguments: [
627
+ txb.object(vaultId),
628
+ txb.object(this.parser.getProtocolConfig()),
629
+ txb.pure.u64(timeBasedFeeThreshold)
630
+ ],
631
+ typeArguments: [
632
+ this.parser.getDepositCoinType(vaultId),
633
+ this.parser.getReceiptCoinType(vaultId)
634
+ ],
635
+ target: `${this.parser.getPackageId()}::gateway::set_time_based_fee_threshold`
636
+ });
637
+ if (options?.gasBudget)
638
+ txb.setGasBudget(options.gasBudget);
639
+ if (options?.sender)
640
+ txb.setSenderIfNotSet(options.sender);
641
+ return txb;
642
+ }
504
643
  /**
505
644
  * Updates the rate of the vault
506
645
  * @param vaultId Id of the vault
@@ -61,4 +61,28 @@ export declare class VaultAdminCalls extends OnChainCalls {
61
61
  * @returns OnChainCallResponse
62
62
  */
63
63
  updateVaultMaxTVL(vaultId: string, maxTVL: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
64
+ /**
65
+ * Set permanent withdrawal fee percentage
66
+ * @param vaultId The id of the vault
67
+ * @param permanentFeePercentage The new permanent fee percentage
68
+ * @param options Optional tx execution params
69
+ * @returns OnChainCallResponse
70
+ */
71
+ setPermanentFeePercentage(vaultId: string, permanentFeePercentage: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
72
+ /**
73
+ * Set time based withdrawal fee percentage
74
+ * @param vaultId The id of the vault
75
+ * @param timeBasedFeePercentage The new time based fee percentage
76
+ * @param options Optional tx execution params
77
+ * @returns OnChainCallResponse
78
+ */
79
+ setTimeBasedFeePercentage(vaultId: string, timeBasedFeePercentage: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
80
+ /**
81
+ * Set time based withdrawal fee threshold
82
+ * @param vaultId The id of the vault
83
+ * @param timeBasedFeeThreshold The new time based fee threshold
84
+ * @param options Optional tx execution params
85
+ * @returns OnChainCallResponse
86
+ */
87
+ setTimeBasedFeeThreshold(vaultId: string, timeBasedFeeThreshold: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
64
88
  }
@@ -107,4 +107,49 @@ export class VaultAdminCalls extends OnChainCalls {
107
107
  this.txBuilder.updateVaultMaxTVL(vaultId, maxTVL, { ...options, txBlock: txb });
108
108
  return this.execCall(txb, options);
109
109
  }
110
+ /**
111
+ * Set permanent withdrawal fee percentage
112
+ * @param vaultId The id of the vault
113
+ * @param permanentFeePercentage The new permanent fee percentage
114
+ * @param options Optional tx execution params
115
+ * @returns OnChainCallResponse
116
+ */
117
+ async setPermanentFeePercentage(vaultId, permanentFeePercentage, options) {
118
+ const txb = options?.txBlock || new TransactionBlock();
119
+ this.txBuilder.setPermanentFeePercentage(vaultId, permanentFeePercentage, {
120
+ ...options,
121
+ txBlock: txb
122
+ });
123
+ return this.execCall(txb, options);
124
+ }
125
+ /**
126
+ * Set time based withdrawal fee percentage
127
+ * @param vaultId The id of the vault
128
+ * @param timeBasedFeePercentage The new time based fee percentage
129
+ * @param options Optional tx execution params
130
+ * @returns OnChainCallResponse
131
+ */
132
+ async setTimeBasedFeePercentage(vaultId, timeBasedFeePercentage, options) {
133
+ const txb = options?.txBlock || new TransactionBlock();
134
+ this.txBuilder.setTimeBasedFeePercentage(vaultId, timeBasedFeePercentage, {
135
+ ...options,
136
+ txBlock: txb
137
+ });
138
+ return this.execCall(txb, options);
139
+ }
140
+ /**
141
+ * Set time based withdrawal fee threshold
142
+ * @param vaultId The id of the vault
143
+ * @param timeBasedFeeThreshold The new time based fee threshold
144
+ * @param options Optional tx execution params
145
+ * @returns OnChainCallResponse
146
+ */
147
+ async setTimeBasedFeeThreshold(vaultId, timeBasedFeeThreshold, options) {
148
+ const txb = options?.txBlock || new TransactionBlock();
149
+ this.txBuilder.setTimeBasedFeeThreshold(vaultId, timeBasedFeeThreshold, {
150
+ ...options,
151
+ txBlock: txb
152
+ });
153
+ return this.execCall(txb, options);
154
+ }
110
155
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-finance/sdk",
3
3
  "description": "Ember Protocol SDK",
4
- "version": "2.0.2",
4
+ "version": "2.0.4",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
7
7
  "main": "./dist/index.js",