@streamflow/stream 9.0.4 → 9.2.0-alpha.p0.5034440

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.
@@ -2,7 +2,7 @@
2
2
  "address": "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
3
3
  "metadata": {
4
4
  "name": "streamflow_aligned_unlocks",
5
- "version": "1.3.0",
5
+ "version": "1.4.0",
6
6
  "spec": "0.1.0",
7
7
  "description": "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
8
8
  },
@@ -876,6 +876,80 @@
876
876
  ],
877
877
  "args": []
878
878
  },
879
+ {
880
+ "name": "update_contract",
881
+ "discriminator": [
882
+ 78,
883
+ 184,
884
+ 162,
885
+ 174,
886
+ 233,
887
+ 5,
888
+ 40,
889
+ 82
890
+ ],
891
+ "accounts": [
892
+ {
893
+ "name": "sender",
894
+ "writable": true,
895
+ "signer": true
896
+ },
897
+ {
898
+ "name": "proxy_metadata",
899
+ "docs": [
900
+ "Proxy Contract"
901
+ ],
902
+ "writable": true,
903
+ "pda": {
904
+ "seeds": [
905
+ {
906
+ "kind": "const",
907
+ "value": [
908
+ 99,
909
+ 111,
910
+ 110,
911
+ 116,
912
+ 114,
913
+ 97,
914
+ 99,
915
+ 116
916
+ ]
917
+ },
918
+ {
919
+ "kind": "account",
920
+ "path": "stream_metadata"
921
+ }
922
+ ]
923
+ }
924
+ },
925
+ {
926
+ "name": "stream_metadata",
927
+ "writable": true
928
+ },
929
+ {
930
+ "name": "withdrawor",
931
+ "writable": true
932
+ },
933
+ {
934
+ "name": "streamflow_program",
935
+ "address": "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
936
+ },
937
+ {
938
+ "name": "system_program",
939
+ "address": "11111111111111111111111111111111"
940
+ }
941
+ ],
942
+ "args": [
943
+ {
944
+ "name": "params",
945
+ "type": {
946
+ "defined": {
947
+ "name": "UpdateContractParams"
948
+ }
949
+ }
950
+ }
951
+ ]
952
+ },
879
953
  {
880
954
  "name": "update_test_oracle",
881
955
  "discriminator": [
@@ -1471,6 +1545,32 @@
1471
1545
  ]
1472
1546
  }
1473
1547
  },
1548
+ {
1549
+ "name": "UpdateContractParams",
1550
+ "type": {
1551
+ "kind": "struct",
1552
+ "fields": [
1553
+ {
1554
+ "name": "transferable_by_sender",
1555
+ "type": {
1556
+ "option": "bool"
1557
+ }
1558
+ },
1559
+ {
1560
+ "name": "transferable_by_recipient",
1561
+ "type": {
1562
+ "option": "bool"
1563
+ }
1564
+ },
1565
+ {
1566
+ "name": "cancelable_by_sender",
1567
+ "type": {
1568
+ "option": "bool"
1569
+ }
1570
+ }
1571
+ ]
1572
+ }
1573
+ },
1474
1574
  {
1475
1575
  "name": "UpdateTestOracleParams",
1476
1576
  "type": {
@@ -8,7 +8,7 @@ type StreamflowAlignedUnlocks = {
8
8
  "address": "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH";
9
9
  "metadata": {
10
10
  "name": "streamflowAlignedUnlocks";
11
- "version": "1.3.0";
11
+ "version": "1.4.0";
12
12
  "spec": "0.1.0";
13
13
  "description": "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics";
14
14
  };
@@ -882,6 +882,80 @@ type StreamflowAlignedUnlocks = {
882
882
  ];
883
883
  "args": [];
884
884
  },
885
+ {
886
+ "name": "updateContract";
887
+ "discriminator": [
888
+ 78,
889
+ 184,
890
+ 162,
891
+ 174,
892
+ 233,
893
+ 5,
894
+ 40,
895
+ 82
896
+ ];
897
+ "accounts": [
898
+ {
899
+ "name": "sender";
900
+ "writable": true;
901
+ "signer": true;
902
+ },
903
+ {
904
+ "name": "proxyMetadata";
905
+ "docs": [
906
+ "Proxy Contract"
907
+ ];
908
+ "writable": true;
909
+ "pda": {
910
+ "seeds": [
911
+ {
912
+ "kind": "const";
913
+ "value": [
914
+ 99,
915
+ 111,
916
+ 110,
917
+ 116,
918
+ 114,
919
+ 97,
920
+ 99,
921
+ 116
922
+ ];
923
+ },
924
+ {
925
+ "kind": "account";
926
+ "path": "streamMetadata";
927
+ }
928
+ ];
929
+ };
930
+ },
931
+ {
932
+ "name": "streamMetadata";
933
+ "writable": true;
934
+ },
935
+ {
936
+ "name": "withdrawor";
937
+ "writable": true;
938
+ },
939
+ {
940
+ "name": "streamflowProgram";
941
+ "address": "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m";
942
+ },
943
+ {
944
+ "name": "systemProgram";
945
+ "address": "11111111111111111111111111111111";
946
+ }
947
+ ];
948
+ "args": [
949
+ {
950
+ "name": "params";
951
+ "type": {
952
+ "defined": {
953
+ "name": "updateContractParams";
954
+ };
955
+ };
956
+ }
957
+ ];
958
+ },
885
959
  {
886
960
  "name": "updateTestOracle";
887
961
  "discriminator": [
@@ -1477,6 +1551,32 @@ type StreamflowAlignedUnlocks = {
1477
1551
  ];
1478
1552
  };
1479
1553
  },
1554
+ {
1555
+ "name": "updateContractParams";
1556
+ "type": {
1557
+ "kind": "struct";
1558
+ "fields": [
1559
+ {
1560
+ "name": "transferableBySender";
1561
+ "type": {
1562
+ "option": "bool";
1563
+ };
1564
+ },
1565
+ {
1566
+ "name": "transferableByRecipient";
1567
+ "type": {
1568
+ "option": "bool";
1569
+ };
1570
+ },
1571
+ {
1572
+ "name": "cancelableBySender";
1573
+ "type": {
1574
+ "option": "bool";
1575
+ };
1576
+ }
1577
+ ];
1578
+ };
1579
+ },
1480
1580
  {
1481
1581
  "name": "updateTestOracleParams";
1482
1582
  "type": {
@@ -1,4 +1,4 @@
1
- export { Z as Account, a5 as AlignedContract, M as AlignedUnlocksContract, a8 as BatchItem, aa as BatchItemError, ab as BatchItemResult, a9 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a4 as Contract, R as CreateParams, V as CreateTestOracleParams, a6 as DecodedStream, $ as ICreateSolanaExt, a3 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, a1 as IPrepareCreateStreamSolanaExt, a2 as IPrepareStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, ac as InstructionGenerator, a7 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, ah as cancelStreamInstruction, x as constants, ad as createStreamInstruction, ae as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, aj as topupStreamInstruction, ai as transferStreamInstruction, ag as updateStreamInstruction, af as withdrawStreamInstruction } from '../index-Dp5DXxr-.js';
1
+ export { Z as Account, a5 as AlignedContract, M as AlignedUnlocksContract, a8 as BatchItem, aa as BatchItemError, ab as BatchItemResult, a9 as BatchItemSuccess, U as ChangeOracleParams, y as ClientCreationOptions, a4 as Contract, R as CreateParams, V as CreateTestOracleParams, a6 as DecodedStream, $ as ICreateSolanaExt, a3 as ICreateStreamInstructions, I as ICreateStreamSolanaExt, a as IInteractStreamSolanaExt, a1 as IPrepareCreateStreamSolanaExt, a2 as IPrepareStreamSolanaExt, Y as ISearchStreams, b as ITopUpStreamSolanaExt, a0 as ITransactionSolanaExtWithInstructions, ac as InstructionGenerator, a7 as MetadataRecipientHashMap, N as OracleType, S as SolanaStreamClient, Q as TestOracle, X as UpdateTestOracleParams, ah as cancelStreamInstruction, x as constants, ad as createStreamInstruction, ae as createUncheckedStreamInstruction, z as decodeStream, J as deriveContractPDA, K as deriveEscrowPDA, L as deriveTestOraclePDA, H as extractSolanaErrorCode, G as sendAndConfirmStreamRawTransaction, B as signAllTransactionWithRecipients, _ as timelockIDL, aj as topupStreamInstruction, ai as transferStreamInstruction, ag as updateStreamInstruction, af as withdrawStreamInstruction } from '../index-DsFyl13W.js';
2
2
  export { ContractError, IChain, ICluster } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -874,7 +874,7 @@ var streamflow_aligned_unlocks_default = {
874
874
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
875
875
  metadata: {
876
876
  name: "streamflow_aligned_unlocks",
877
- version: "1.3.0",
877
+ version: "1.4.0",
878
878
  spec: "0.1.0",
879
879
  description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
880
880
  },
@@ -1748,6 +1748,80 @@ var streamflow_aligned_unlocks_default = {
1748
1748
  ],
1749
1749
  args: []
1750
1750
  },
1751
+ {
1752
+ name: "update_contract",
1753
+ discriminator: [
1754
+ 78,
1755
+ 184,
1756
+ 162,
1757
+ 174,
1758
+ 233,
1759
+ 5,
1760
+ 40,
1761
+ 82
1762
+ ],
1763
+ accounts: [
1764
+ {
1765
+ name: "sender",
1766
+ writable: true,
1767
+ signer: true
1768
+ },
1769
+ {
1770
+ name: "proxy_metadata",
1771
+ docs: [
1772
+ "Proxy Contract"
1773
+ ],
1774
+ writable: true,
1775
+ pda: {
1776
+ seeds: [
1777
+ {
1778
+ kind: "const",
1779
+ value: [
1780
+ 99,
1781
+ 111,
1782
+ 110,
1783
+ 116,
1784
+ 114,
1785
+ 97,
1786
+ 99,
1787
+ 116
1788
+ ]
1789
+ },
1790
+ {
1791
+ kind: "account",
1792
+ path: "stream_metadata"
1793
+ }
1794
+ ]
1795
+ }
1796
+ },
1797
+ {
1798
+ name: "stream_metadata",
1799
+ writable: true
1800
+ },
1801
+ {
1802
+ name: "withdrawor",
1803
+ writable: true
1804
+ },
1805
+ {
1806
+ name: "streamflow_program",
1807
+ address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
1808
+ },
1809
+ {
1810
+ name: "system_program",
1811
+ address: "11111111111111111111111111111111"
1812
+ }
1813
+ ],
1814
+ args: [
1815
+ {
1816
+ name: "params",
1817
+ type: {
1818
+ defined: {
1819
+ name: "UpdateContractParams"
1820
+ }
1821
+ }
1822
+ }
1823
+ ]
1824
+ },
1751
1825
  {
1752
1826
  name: "update_test_oracle",
1753
1827
  discriminator: [
@@ -2343,6 +2417,32 @@ var streamflow_aligned_unlocks_default = {
2343
2417
  ]
2344
2418
  }
2345
2419
  },
2420
+ {
2421
+ name: "UpdateContractParams",
2422
+ type: {
2423
+ kind: "struct",
2424
+ fields: [
2425
+ {
2426
+ name: "transferable_by_sender",
2427
+ type: {
2428
+ option: "bool"
2429
+ }
2430
+ },
2431
+ {
2432
+ name: "transferable_by_recipient",
2433
+ type: {
2434
+ option: "bool"
2435
+ }
2436
+ },
2437
+ {
2438
+ name: "cancelable_by_sender",
2439
+ type: {
2440
+ option: "bool"
2441
+ }
2442
+ }
2443
+ ]
2444
+ }
2445
+ },
2346
2446
  {
2347
2447
  name: "UpdateTestOracleParams",
2348
2448
  type: {
@@ -2568,7 +2668,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2568
2668
  floorPrice
2569
2669
  } = streamParams;
2570
2670
  const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
2571
- invariant(priceOracle || !oracleType || oracleType === "none", "Price oracle is required for the specified oracle type");
2671
+ invariant(
2672
+ priceOracle || !oracleType || oracleType === "none",
2673
+ "Price oracle is required for the specified oracle type"
2674
+ );
2572
2675
  assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2573
2676
  const recipientPublicKey = new PublicKey(recipient);
2574
2677
  const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
@@ -2743,10 +2846,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
2743
2846
  * @returns Create result
2744
2847
  */
2745
2848
  async createUnchecked(data, extParams) {
2746
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2747
- data,
2748
- extParams
2749
- );
2849
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2750
2850
  const { tx, hash, context } = await prepareTransaction(
2751
2851
  this.connection,
2752
2852
  ixs,
@@ -2872,7 +2972,6 @@ var SolanaStreamClient = class extends BaseStreamClient {
2872
2972
  const metadatas = [];
2873
2973
  const metadataToRecipient = {};
2874
2974
  const instructionsBatch = [];
2875
- const metadataPubKeys = metadataPubKeysExt || [];
2876
2975
  const partnerPublicKey = data.partner ? new PublicKey(data.partner) : WITHDRAWOR_PUBLIC_KEY;
2877
2976
  const mintPublicKey = new PublicKey(data.tokenId);
2878
2977
  if (recipients.length === 0) {
@@ -2882,8 +2981,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
2882
2981
  const recipientData = recipients[i];
2883
2982
  const createStreamData = { ...streamParams, ...recipientData };
2884
2983
  const createStreamExtParams = {
2885
- metadataPubKeys: metadataPubKeys[i] ? [metadataPubKeys[i]] : void 0,
2886
- ...extParams
2984
+ ...extParams,
2985
+ metadataPubKeys: metadataPubKeysExt?.[i] ? [metadataPubKeysExt[i]] : void 0
2887
2986
  };
2888
2987
  const { ixs, metadata, metadataPubKey } = await this.prepareCreateInstructions(
2889
2988
  createStreamData,
@@ -2898,19 +2997,10 @@ var SolanaStreamClient = class extends BaseStreamClient {
2898
2997
  recipient: recipientData.recipient
2899
2998
  });
2900
2999
  }
2901
- const prepareInstructions = await this.getCreateATAInstructions(
2902
- [partnerPublicKey],
2903
- mintPublicKey,
2904
- sender,
2905
- true
2906
- );
3000
+ const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
2907
3001
  if (isNative) {
2908
3002
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN4(0));
2909
- const nativeInstructions = await prepareWrappedAccount(
2910
- this.connection,
2911
- sender.publicKey,
2912
- totalDepositedAmount
2913
- );
3003
+ const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2914
3004
  prepareInstructions.push(...nativeInstructions);
2915
3005
  }
2916
3006
  return {
@@ -3108,10 +3198,7 @@ var SolanaStreamClient = class extends BaseStreamClient {
3108
3198
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3109
3199
  const { invoker, customInstructions } = extParams;
3110
3200
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3111
- const ixs = await this.prepareWithdrawInstructions(
3112
- { id, amount },
3113
- extParams
3114
- );
3201
+ const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3115
3202
  const metadata = new PublicKey(id);
3116
3203
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3117
3204
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3615,17 +3702,26 @@ var SolanaStreamClient = class extends BaseStreamClient {
3615
3702
  const streamPublicKey = new PublicKey(data.id);
3616
3703
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3617
3704
  invariant(escrow, "Couldn't get account info");
3705
+ const { sender: senderPublicKey } = decodeStream(escrow.data);
3706
+ const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3707
+ if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
3708
+ throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
3709
+ }
3618
3710
  const ixs = prepareBaseInstructions(this.connection, {
3619
3711
  computePrice,
3620
3712
  computeLimit
3621
3713
  });
3622
3714
  ixs.push(
3623
- await updateStreamInstruction(data, this.programId, {
3715
+ await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
3716
+ transferableBySender: data.transferableBySender ?? null,
3717
+ transferableByRecipient: data.transferableByRecipient ?? null,
3718
+ cancelableBySender: data.cancelableBySender ?? null
3719
+ }).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
3624
3720
  authority: invoker.publicKey,
3625
3721
  metadata: streamPublicKey,
3626
3722
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
3627
3723
  systemProgram: SystemProgram.programId
3628
- })
3724
+ }))
3629
3725
  );
3630
3726
  return ixs;
3631
3727
  }
@@ -3670,8 +3766,8 @@ var SolanaStreamClient = class extends BaseStreamClient {
3670
3766
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3671
3767
  }
3672
3768
  /**
3673
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3674
- */
3769
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3770
+ */
3675
3771
  isAlignedUnlock(streamPublicKey, senderPublicKey) {
3676
3772
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3677
3773
  return senderPublicKey.equals(pda);