@ember-finance/sdk 1.3.0 → 1.4.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.
@@ -232,18 +232,20 @@ export declare class TxBuilder {
232
232
  * Deposit asset
233
233
  * @param vaultId Id of the vault
234
234
  * @param coinId Id of the coin
235
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
235
236
  * @param options Optional tx building params
236
237
  * @returns TransactionBlock
237
238
  */
238
- depositAsset(vaultId: string, coinId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
239
+ depositAsset(vaultId: string, coinId: string, minSharesToMint: NumStr, receiver: string, options?: ITxBuilderOptionalParams): TransactionBlock;
239
240
  /**
240
241
  * Deposit asset internal
241
242
  * @param vaultId Id of the vault
242
243
  * @param coinId Id of the coin
244
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
243
245
  * @param options Optional tx building params
244
246
  * @returns TransactionBlock
245
247
  */
246
- depositAssetInternal(vaultId: string, coinId: string, options?: ITxBuilderOptionalParams): TransactionBlock;
248
+ depositAssetInternal(vaultId: string, coinId: string, minSharesToMint: NumStr, options?: ITxBuilderOptionalParams): TransactionBlock;
247
249
  /**
248
250
  * Mint shares
249
251
  * @param vaultId Id of the vault
@@ -253,7 +255,7 @@ export declare class TxBuilder {
253
255
  * @param options Optional tx building params
254
256
  * @returns TransactionBlock
255
257
  */
256
- mintShares(vaultId: string, coinId: string, shares: NumStr, receiver: string, options?: ITxBuilderOptionalParams): TransactionBlock;
258
+ mintShares(vaultId: string, coinId: string, shares: NumStr, maxAmountToDeposit: NumStr, receiver: string, options?: ITxBuilderOptionalParams): TransactionBlock;
257
259
  /**
258
260
  * Redeems shares
259
261
  * @param vaultId Id of the vault
@@ -433,13 +433,14 @@ class TxBuilder {
433
433
  arguments: [
434
434
  txb.object(vaultId),
435
435
  txb.object(this.parser.getProtocolConfig()),
436
- txb.pure.u64(feePercentage)
436
+ txb.pure.u64(feePercentage),
437
+ txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
437
438
  ],
438
439
  typeArguments: [
439
440
  this.parser.getDepositCoinType(vaultId),
440
441
  this.parser.getReceiptCoinType(vaultId)
441
442
  ],
442
- target: `${this.parser.getPackageId()}::gateway::update_vault_fee_percentage`
443
+ target: `${this.parser.getPackageId()}::gateway::update_vault_fee_percentage_v2`
443
444
  });
444
445
  if (options?.gasBudget)
445
446
  txb.setGasBudget(options.gasBudget);
@@ -726,22 +727,26 @@ class TxBuilder {
726
727
  * Deposit asset
727
728
  * @param vaultId Id of the vault
728
729
  * @param coinId Id of the coin
730
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
729
731
  * @param options Optional tx building params
730
732
  * @returns TransactionBlock
731
733
  */
732
- depositAsset(vaultId, coinId, options) {
734
+ depositAsset(vaultId, coinId, minSharesToMint, receiver, options) {
733
735
  const txb = options?.txBlock || new library_sui_1.TransactionBlock();
734
736
  txb.moveCall({
735
737
  arguments: [
736
738
  txb.object(vaultId),
737
739
  txb.object(this.parser.getProtocolConfig()),
738
- txb.object(coinId)
740
+ txb.object(coinId),
741
+ txb.pure.u64(minSharesToMint),
742
+ txb.pure.vector("address", [receiver]),
743
+ txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
739
744
  ],
740
745
  typeArguments: [
741
746
  this.parser.getDepositCoinType(vaultId),
742
747
  this.parser.getReceiptCoinType(vaultId)
743
748
  ],
744
- target: `${this.parser.getPackageId()}::gateway::deposit_asset`
749
+ target: `${this.parser.getPackageId()}::gateway::deposit_asset_v2`
745
750
  });
746
751
  if (options?.gasBudget)
747
752
  txb.setGasBudget(options.gasBudget);
@@ -753,10 +758,11 @@ class TxBuilder {
753
758
  * Deposit asset internal
754
759
  * @param vaultId Id of the vault
755
760
  * @param coinId Id of the coin
761
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
756
762
  * @param options Optional tx building params
757
763
  * @returns TransactionBlock
758
764
  */
759
- depositAssetInternal(vaultId, coinId, options) {
765
+ depositAssetInternal(vaultId, coinId, minSharesToMint, options) {
760
766
  const txb = options?.txBlock || new library_sui_1.TransactionBlock();
761
767
  const balance = txb.moveCall({
762
768
  target: `0x2::coin::into_balance`,
@@ -767,13 +773,15 @@ class TxBuilder {
767
773
  arguments: [
768
774
  txb.object(vaultId),
769
775
  txb.object(this.parser.getProtocolConfig()),
770
- txb.object(balance)
776
+ txb.object(balance),
777
+ txb.pure.u64(minSharesToMint),
778
+ txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
771
779
  ],
772
780
  typeArguments: [
773
781
  this.parser.getDepositCoinType(vaultId),
774
782
  this.parser.getReceiptCoinType(vaultId)
775
783
  ],
776
- target: `${this.parser.getPackageId()}::vault::deposit_asset`
784
+ target: `${this.parser.getPackageId()}::vault::deposit_asset_v2`
777
785
  });
778
786
  if (options?.sender) {
779
787
  txb.transferObjects([receiptToken], txb.pure.address(options.sender));
@@ -793,7 +801,7 @@ class TxBuilder {
793
801
  * @param options Optional tx building params
794
802
  * @returns TransactionBlock
795
803
  */
796
- mintShares(vaultId, coinId, shares, receiver, options) {
804
+ mintShares(vaultId, coinId, shares, maxAmountToDeposit, receiver, options) {
797
805
  const txb = options?.txBlock || new library_sui_1.TransactionBlock();
798
806
  txb.moveCall({
799
807
  arguments: [
@@ -801,13 +809,15 @@ class TxBuilder {
801
809
  txb.object(this.parser.getProtocolConfig()),
802
810
  txb.object(coinId),
803
811
  txb.pure.u64(shares),
804
- txb.pure.vector("address", [receiver])
812
+ txb.pure.u64(maxAmountToDeposit),
813
+ txb.pure.vector("address", [receiver]),
814
+ txb.object(utils_2.SUI_CLOCK_OBJECT_ID)
805
815
  ],
806
816
  typeArguments: [
807
817
  this.parser.getDepositCoinType(vaultId),
808
818
  this.parser.getReceiptCoinType(vaultId)
809
819
  ],
810
- target: `${this.parser.getPackageId()}::gateway::mint_shares`
820
+ target: `${this.parser.getPackageId()}::gateway::mint_shares_v2`
811
821
  });
812
822
  if (options?.gasBudget)
813
823
  txb.setGasBudget(options.gasBudget);
@@ -11,17 +11,19 @@ export declare class UserCalls extends OnChainCalls {
11
11
  * @param options Optional tx execution params
12
12
  * @returns OnChainCallResponse
13
13
  */
14
- depositAsset(vaultId: string, amount: NumStr, options?: IVaultOptionalParams & {
14
+ depositAsset(vaultId: string, amount: NumStr, minSharesToMint: NumStr, options?: IVaultOptionalParams & {
15
15
  coinId?: string;
16
+ receiver?: SuiAddress;
16
17
  } & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
17
18
  /**
18
19
  * Deposit asset into a vault internal
19
20
  * @param vaultId The id of the vault to deposit into
20
21
  * @param coinId The id of the coin to deposit
22
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
21
23
  * @param options Optional tx execution params
22
24
  * @returns OnChainCallResponse
23
25
  */
24
- depositAssetInternal(vaultId: string, coinId: string | TransactionObjectArgument, sender: string, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
26
+ depositAssetInternal(vaultId: string, coinId: string | TransactionObjectArgument, sender: string, minSharesToMint: NumStr, options?: IVaultOptionalParams & SuiTransactionBlockResponseOptions): Promise<OnChainCallResponse>;
25
27
  /**
26
28
  * Mint shares of a vault
27
29
  * @param vaultId The id of the vault to mint shares for
@@ -15,7 +15,7 @@ class UserCalls extends onchain_calls_1.OnChainCalls {
15
15
  * @param options Optional tx execution params
16
16
  * @returns OnChainCallResponse
17
17
  */
18
- async depositAsset(vaultId, amount, options) {
18
+ async depositAsset(vaultId, amount, minSharesToMint, options) {
19
19
  let coinId = options?.coinId;
20
20
  const txb = options?.txBlock || new library_sui_1.TransactionBlock();
21
21
  let split;
@@ -29,7 +29,7 @@ class UserCalls extends onchain_calls_1.OnChainCalls {
29
29
  [split, merged] = await library_sui_1.CoinUtils.validateCoinBalance(this.suiClient, txb, (0, library_sui_1.bigNumber)(amount).toFixed(0), coinId);
30
30
  coinId = split;
31
31
  }
32
- this.txBuilder.depositAsset(vaultId, coinId, { ...options, txBlock: txb });
32
+ this.txBuilder.depositAsset(vaultId, coinId, minSharesToMint, options.receiver || this.walletAddress, { ...options, txBlock: txb });
33
33
  if (merged) {
34
34
  txb.transferObjects([merged], this.walletAddress);
35
35
  }
@@ -39,12 +39,13 @@ class UserCalls extends onchain_calls_1.OnChainCalls {
39
39
  * Deposit asset into a vault internal
40
40
  * @param vaultId The id of the vault to deposit into
41
41
  * @param coinId The id of the coin to deposit
42
+ * @param minSharesToMint The minimum number of shares to mint for given deposit amount.
42
43
  * @param options Optional tx execution params
43
44
  * @returns OnChainCallResponse
44
45
  */
45
- async depositAssetInternal(vaultId, coinId, sender, options) {
46
+ async depositAssetInternal(vaultId, coinId, sender, minSharesToMint, options) {
46
47
  const txb = options?.txBlock || new library_sui_1.TransactionBlock();
47
- this.txBuilder.depositAssetInternal(vaultId, coinId, {
48
+ this.txBuilder.depositAssetInternal(vaultId, coinId, minSharesToMint, {
48
49
  ...options,
49
50
  txBlock: txb,
50
51
  sender
@@ -78,7 +79,7 @@ class UserCalls extends onchain_calls_1.OnChainCalls {
78
79
  [split, merged] = await library_sui_1.CoinUtils.validateCoinBalance(this.suiClient, txb, assetAmountRequired, coinId);
79
80
  coinId = split;
80
81
  }
81
- this.txBuilder.mintShares(vaultId, coinId, numberOfShares, options?.receiver || this.walletAddress, { ...options, txBlock: txb });
82
+ this.txBuilder.mintShares(vaultId, coinId, numberOfShares, assetAmountRequired, options?.receiver || this.walletAddress, { ...options, txBlock: txb });
82
83
  if (merged) {
83
84
  txb.transferObjects([merged], this.walletAddress);
84
85
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ember-finance/sdk",
3
3
  "description": "Ember Protocol SDK",
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
5
5
  "module": "./dist/index.js",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",