@streamflow/stream 10.0.0-alpha.p313.4470e29 → 10.0.0-alpha.p313.fe3720a

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": {
@@ -553,7 +553,7 @@ declare class SolanaStreamClient {
553
553
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
554
554
  * @returns Create stream instructions
555
555
  */
556
- prepareCreateStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
556
+ prepareCreateLinearStreamInstructions({ recipient, tokenId: mint, start, amount: depositedAmount, period, cliff, cliffAmount, amountPerPeriod, name, canPause, canUpdateRate, canTopup, cancelableBySender, cancelableByRecipient, transferableBySender, transferableByRecipient, automaticWithdrawal, withdrawalFrequency, partner, tokenProgramId: streamTokenProgramId, }: ICreateStreamData, { sender, metadataPubKeys, isNative, computePrice, computeLimit }: IPrepareCreateStreamExt): Promise<ICreateStreamInstructions>;
557
557
  /**
558
558
  * Creates a new stream/vesting contract using unchecked instruction.
559
559
  *
@@ -688,7 +688,7 @@ declare class SolanaStreamClient {
688
688
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
689
689
  * @returns Transaction instructions
690
690
  */
691
- prepareCancelStreamInstructions({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
691
+ prepareCancelLinearStream({ id }: ICancelData, { invoker, checkTokenAccounts, computePrice, computeLimit }: IPrepareStreamExt): Promise<TransactionInstruction[]>;
692
692
  /**
693
693
  * Attempts changing the stream/vesting contract's recipient (effectively transferring the stream/vesting contract).
694
694
  * Potential associated token account rent fee (to make it rent-exempt) is paid by the transaction initiator.
@@ -784,8 +784,8 @@ declare class SolanaStreamClient {
784
784
  */
785
785
  extractErrorCode(err: Error): string | null;
786
786
  /**
787
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
788
- */
787
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
788
+ */
789
789
  isAlignedUnlock(streamPublicKey: PublicKey, senderPublicKey: PublicKey): boolean;
790
790
  /**
791
791
  * Utility function to generate metadata for a Contract or return existing Pubkey
@@ -879,7 +879,7 @@ var streamflow_aligned_unlocks_default = {
879
879
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
880
880
  metadata: {
881
881
  name: "streamflow_aligned_unlocks",
882
- version: "1.3.0",
882
+ version: "1.4.0",
883
883
  spec: "0.1.0",
884
884
  description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
885
885
  },
@@ -1753,6 +1753,80 @@ var streamflow_aligned_unlocks_default = {
1753
1753
  ],
1754
1754
  args: []
1755
1755
  },
1756
+ {
1757
+ name: "update_contract",
1758
+ discriminator: [
1759
+ 78,
1760
+ 184,
1761
+ 162,
1762
+ 174,
1763
+ 233,
1764
+ 5,
1765
+ 40,
1766
+ 82
1767
+ ],
1768
+ accounts: [
1769
+ {
1770
+ name: "sender",
1771
+ writable: true,
1772
+ signer: true
1773
+ },
1774
+ {
1775
+ name: "proxy_metadata",
1776
+ docs: [
1777
+ "Proxy Contract"
1778
+ ],
1779
+ writable: true,
1780
+ pda: {
1781
+ seeds: [
1782
+ {
1783
+ kind: "const",
1784
+ value: [
1785
+ 99,
1786
+ 111,
1787
+ 110,
1788
+ 116,
1789
+ 114,
1790
+ 97,
1791
+ 99,
1792
+ 116
1793
+ ]
1794
+ },
1795
+ {
1796
+ kind: "account",
1797
+ path: "stream_metadata"
1798
+ }
1799
+ ]
1800
+ }
1801
+ },
1802
+ {
1803
+ name: "stream_metadata",
1804
+ writable: true
1805
+ },
1806
+ {
1807
+ name: "withdrawor",
1808
+ writable: true
1809
+ },
1810
+ {
1811
+ name: "streamflow_program",
1812
+ address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
1813
+ },
1814
+ {
1815
+ name: "system_program",
1816
+ address: "11111111111111111111111111111111"
1817
+ }
1818
+ ],
1819
+ args: [
1820
+ {
1821
+ name: "params",
1822
+ type: {
1823
+ defined: {
1824
+ name: "UpdateContractParams"
1825
+ }
1826
+ }
1827
+ }
1828
+ ]
1829
+ },
1756
1830
  {
1757
1831
  name: "update_test_oracle",
1758
1832
  discriminator: [
@@ -2348,6 +2422,32 @@ var streamflow_aligned_unlocks_default = {
2348
2422
  ]
2349
2423
  }
2350
2424
  },
2425
+ {
2426
+ name: "UpdateContractParams",
2427
+ type: {
2428
+ kind: "struct",
2429
+ fields: [
2430
+ {
2431
+ name: "transferable_by_sender",
2432
+ type: {
2433
+ option: "bool"
2434
+ }
2435
+ },
2436
+ {
2437
+ name: "transferable_by_recipient",
2438
+ type: {
2439
+ option: "bool"
2440
+ }
2441
+ },
2442
+ {
2443
+ name: "cancelable_by_sender",
2444
+ type: {
2445
+ option: "bool"
2446
+ }
2447
+ }
2448
+ ]
2449
+ }
2450
+ },
2351
2451
  {
2352
2452
  name: "UpdateTestOracleParams",
2353
2453
  type: {
@@ -2538,7 +2638,7 @@ var SolanaStreamClient = class {
2538
2638
  return { ixs, txId: signature, metadataId };
2539
2639
  }
2540
2640
  async prepareCreateInstructions(streamParams, extParams) {
2541
- const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateStreamInstructions(streamParams, extParams);
2641
+ const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
2542
2642
  return { ixs, metadata, metadataPubKey };
2543
2643
  }
2544
2644
  async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
@@ -2572,7 +2672,10 @@ var SolanaStreamClient = class {
2572
2672
  floorPrice
2573
2673
  } = streamParams;
2574
2674
  const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
2575
- invariant(priceOracle || !oracleType || oracleType === "none", "Price oracle is required for the specified oracle type");
2675
+ invariant(
2676
+ priceOracle || !oracleType || oracleType === "none",
2677
+ "Price oracle is required for the specified oracle type"
2678
+ );
2576
2679
  assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2577
2680
  const recipientPublicKey = new PublicKey(recipient);
2578
2681
  const mintPublicKey = isNative ? NATIVE_MINT : new PublicKey(mint);
@@ -2645,7 +2748,7 @@ var SolanaStreamClient = class {
2645
2748
  * @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
2646
2749
  * @returns Create stream instructions
2647
2750
  */
2648
- async prepareCreateStreamInstructions({
2751
+ async prepareCreateLinearStreamInstructions({
2649
2752
  recipient,
2650
2753
  tokenId: mint,
2651
2754
  start,
@@ -2747,10 +2850,7 @@ var SolanaStreamClient = class {
2747
2850
  * @returns Create result
2748
2851
  */
2749
2852
  async createUnchecked(data, extParams) {
2750
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2751
- data,
2752
- extParams
2753
- );
2853
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2754
2854
  const { tx, hash, context } = await prepareTransaction(
2755
2855
  this.connection,
2756
2856
  ixs,
@@ -2902,19 +3002,10 @@ var SolanaStreamClient = class {
2902
3002
  recipient: recipientData.recipient
2903
3003
  });
2904
3004
  }
2905
- const prepareInstructions = await this.getCreateATAInstructions(
2906
- [partnerPublicKey],
2907
- mintPublicKey,
2908
- sender,
2909
- true
2910
- );
3005
+ const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
2911
3006
  if (isNative) {
2912
3007
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3(0));
2913
- const nativeInstructions = await prepareWrappedAccount(
2914
- this.connection,
2915
- sender.publicKey,
2916
- totalDepositedAmount
2917
- );
3008
+ const nativeInstructions = await prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2918
3009
  prepareInstructions.push(...nativeInstructions);
2919
3010
  }
2920
3011
  return {
@@ -3112,10 +3203,7 @@ var SolanaStreamClient = class {
3112
3203
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3113
3204
  const { invoker, customInstructions } = extParams;
3114
3205
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3115
- const ixs = await this.prepareWithdrawInstructions(
3116
- { id, amount },
3117
- extParams
3118
- );
3206
+ const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3119
3207
  const metadata = new PublicKey(id);
3120
3208
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3121
3209
  const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3213,7 +3301,7 @@ var SolanaStreamClient = class {
3213
3301
  }
3214
3302
  const { sender: senderPublicKey } = decodeStream(account.data);
3215
3303
  const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3216
- const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelStreamInstructions(cancelData, extParams);
3304
+ const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
3217
3305
  return ixs;
3218
3306
  }
3219
3307
  /**
@@ -3261,7 +3349,7 @@ var SolanaStreamClient = class {
3261
3349
  * @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
3262
3350
  * @returns Transaction instructions
3263
3351
  */
3264
- async prepareCancelStreamInstructions({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3352
+ async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
3265
3353
  assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3266
3354
  const streamPublicKey = new PublicKey(id);
3267
3355
  const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
@@ -3619,17 +3707,26 @@ var SolanaStreamClient = class {
3619
3707
  const streamPublicKey = new PublicKey(data.id);
3620
3708
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3621
3709
  invariant(escrow, "Couldn't get account info");
3710
+ const { sender: senderPublicKey } = decodeStream(escrow.data);
3711
+ const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3712
+ if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
3713
+ throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
3714
+ }
3622
3715
  const ixs = prepareBaseInstructions(this.connection, {
3623
3716
  computePrice,
3624
3717
  computeLimit
3625
3718
  });
3626
3719
  ixs.push(
3627
- await updateStreamInstruction(data, this.programId, {
3720
+ await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
3721
+ transferableBySender: data.transferableBySender ?? null,
3722
+ transferableByRecipient: data.transferableByRecipient ?? null,
3723
+ cancelableBySender: data.cancelableBySender ?? null
3724
+ }).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
3628
3725
  authority: invoker.publicKey,
3629
3726
  metadata: streamPublicKey,
3630
3727
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
3631
3728
  systemProgram: SystemProgram.programId
3632
- })
3729
+ }))
3633
3730
  );
3634
3731
  return ixs;
3635
3732
  }
@@ -3688,8 +3785,8 @@ var SolanaStreamClient = class {
3688
3785
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3689
3786
  }
3690
3787
  /**
3691
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3692
- */
3788
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3789
+ */
3693
3790
  isAlignedUnlock(streamPublicKey, senderPublicKey) {
3694
3791
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3695
3792
  return senderPublicKey.equals(pda);