@streamflow/stream 10.0.0-alpha.p313.3ce4d29 → 10.0.0-alpha.p313.4046054

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.
@@ -1,4 +1,4 @@
1
- export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, OracleTypeName, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, UpdateTestOracleParams, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isPayment, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
1
+ export { AIRDROP_AMOUNT, AIRDROP_TEST_TOKEN, ALIGNED_COMPUTE_LIMIT, ALIGNED_PRECISION_FACTOR_POW, ALIGNED_UNLOCKS_PROGRAM_ID, Account, AlignedContract, AlignedProxyErrorCode, AlignedStream, AlignedStreamData, AlignedUnlocksContract, BatchItem, BatchItemError, BatchItemResult, BatchItemSuccess, CONTRACT_DISCRIMINATOR, CONTRACT_SEED, CREATE_PARAMS_PADDING, ChangeOracleParams, ClientCreationOptions, Contract, ContractErrorCode, CreateParams, CreateTestOracleParams, DEFAULT_STREAMFLOW_FEE, DecodedStream, ESCROW_SEED, FEES_METADATA_SEED, FEE_ORACLE_PUBLIC_KEY, IAlignedStreamConfig, IBaseStreamConfig, ICancelData, ICreateAlignedStreamData, ICreateExt, ICreateLinearStreamData, ICreateMultiError, ICreateMultipleAlignedStreamData, ICreateMultipleLinearStreamData, ICreateMultipleStreamData, ICreateResult, ICreateStreamData, ICreateStreamExt, ICreateStreamInstructions, IFees, IGetAllData, IGetFeesData, IGetOneData, IInteractData, IInteractStreamExt, IMultiTransactionResult, IPrepareCreateStreamExt, IPrepareStreamExt, IRecipient, ISearchStreams, ITopUpData, ITopUpStreamExt, ITransactionExtWithInstructions, ITransactionResult, ITransferData, IUpdateData, IWithdrawData, InstructionGenerator, LinearStream, MAX_SAFE_UNIX_TIME_VALUE, MetadataRecipientHashMap, ORIGINAL_CONTRACT_SENDER_OFFSET, OracleType, OracleTypeName, PARTNERS_SCHEMA, PARTNER_ORACLE_PROGRAM_ID, PARTNER_SCHEMA, PROGRAM_ID, SOLANA_ERROR_MAP, SOLANA_ERROR_MATCH_REGEX, STREAMFLOW_TREASURY_PUBLIC_KEY, STREAM_STRUCT_OFFSETS, STREAM_STRUCT_OFFSET_CLOSED, STREAM_STRUCT_OFFSET_MINT, STREAM_STRUCT_OFFSET_RECIPIENT, STREAM_STRUCT_OFFSET_SENDER, SolanaStreamClient, Stream, StreamClientOptions, StreamDirection, StreamType, TEST_ORACLE_DISCRIMINATOR, TEST_ORACLE_SEED, TX_FINALITY_CONFIRMED, TestOracle, TransactionSchedulingOptions, UpdateTestOracleParams, WITHDRAWOR_PUBLIC_KEY, WITHDRAW_AVAILABLE_AMOUNT, buildStreamType, calculateTotalAmountToDeposit, calculateUnlockedAmount, cancelStreamInstruction, createStreamInstruction, createUncheckedStreamInstruction, decodeEndTime, decodeStream, deriveContractPDA, deriveEscrowPDA, deriveTestOraclePDA, extractSolanaErrorCode, handleContractError, isAligned, isCliffCloseToDepositedAmount, isCreateAlignedStreamData, isDynamicLock, isTokenLock, isVesting, sendAndConfirmStreamRawTransaction, signAllTransactionWithRecipients, timelockIDL, topupStreamInstruction, transferStreamInstruction, updateStreamInstruction, withdrawStreamInstruction } from './solana/index.cjs';
2
2
  export { ContractError, ICluster, getBN, getNumberFromBN } from '@streamflow/common';
3
3
  import 'p-queue';
4
4
  import '@solana/web3.js';
@@ -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": {
@@ -59,11 +59,8 @@ var calculateUnlockedAmount = ({
59
59
  var isCliffCloseToDepositedAmount = (streamData) => {
60
60
  return streamData.cliffAmount.gte(streamData.depositedAmount.sub(new BN3__default.default(1)));
61
61
  };
62
- var isPayment = (streamData) => {
63
- return streamData.canTopup;
64
- };
65
62
  var isVesting = (streamData) => {
66
- return !streamData.canTopup && !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
63
+ return !isCliffCloseToDepositedAmount(streamData) && !isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage);
67
64
  };
68
65
  var isAligned = (stream) => {
69
66
  return "minPrice" in stream && "maxPrice" in stream && "minPercentage" in stream && "maxPercentage" in stream;
@@ -78,13 +75,10 @@ var isTokenLock = (streamData) => {
78
75
  return !streamData.canTopup && !streamData.automaticWithdrawal && !streamData.cancelableBySender && !streamData.cancelableByRecipient && !streamData.transferableBySender && (isCliffCloseToDepositedAmount(streamData) || isDynamicLock(streamData.minPrice, streamData.maxPrice, streamData.minPercentage, streamData.maxPercentage));
79
76
  };
80
77
  var buildStreamType = (streamData) => {
81
- if (isVesting(streamData)) {
82
- return "vesting" /* Vesting */;
83
- }
84
78
  if (isTokenLock(streamData)) {
85
79
  return "lock" /* Lock */;
86
80
  }
87
- return "payment" /* Payment */;
81
+ return "vesting" /* Vesting */;
88
82
  };
89
83
  var decodeEndTime = (endTime) => {
90
84
  if (endTime.gt(new BN3__default.default(MAX_SAFE_UNIX_TIME_VALUE))) {
@@ -101,7 +95,6 @@ var StreamDirection = /* @__PURE__ */ ((StreamDirection2) => {
101
95
  })(StreamDirection || {});
102
96
  var StreamType = /* @__PURE__ */ ((StreamType2) => {
103
97
  StreamType2["All"] = "all";
104
- StreamType2["Payment"] = "payment";
105
98
  StreamType2["Vesting"] = "vesting";
106
99
  StreamType2["Lock"] = "lock";
107
100
  return StreamType2;
@@ -912,7 +905,7 @@ var streamflow_aligned_unlocks_default = {
912
905
  address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
913
906
  metadata: {
914
907
  name: "streamflow_aligned_unlocks",
915
- version: "1.3.0",
908
+ version: "1.4.0",
916
909
  spec: "0.1.0",
917
910
  description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
918
911
  },
@@ -1786,6 +1779,80 @@ var streamflow_aligned_unlocks_default = {
1786
1779
  ],
1787
1780
  args: []
1788
1781
  },
1782
+ {
1783
+ name: "update_contract",
1784
+ discriminator: [
1785
+ 78,
1786
+ 184,
1787
+ 162,
1788
+ 174,
1789
+ 233,
1790
+ 5,
1791
+ 40,
1792
+ 82
1793
+ ],
1794
+ accounts: [
1795
+ {
1796
+ name: "sender",
1797
+ writable: true,
1798
+ signer: true
1799
+ },
1800
+ {
1801
+ name: "proxy_metadata",
1802
+ docs: [
1803
+ "Proxy Contract"
1804
+ ],
1805
+ writable: true,
1806
+ pda: {
1807
+ seeds: [
1808
+ {
1809
+ kind: "const",
1810
+ value: [
1811
+ 99,
1812
+ 111,
1813
+ 110,
1814
+ 116,
1815
+ 114,
1816
+ 97,
1817
+ 99,
1818
+ 116
1819
+ ]
1820
+ },
1821
+ {
1822
+ kind: "account",
1823
+ path: "stream_metadata"
1824
+ }
1825
+ ]
1826
+ }
1827
+ },
1828
+ {
1829
+ name: "stream_metadata",
1830
+ writable: true
1831
+ },
1832
+ {
1833
+ name: "withdrawor",
1834
+ writable: true
1835
+ },
1836
+ {
1837
+ name: "streamflow_program",
1838
+ address: "strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m"
1839
+ },
1840
+ {
1841
+ name: "system_program",
1842
+ address: "11111111111111111111111111111111"
1843
+ }
1844
+ ],
1845
+ args: [
1846
+ {
1847
+ name: "params",
1848
+ type: {
1849
+ defined: {
1850
+ name: "UpdateContractParams"
1851
+ }
1852
+ }
1853
+ }
1854
+ ]
1855
+ },
1789
1856
  {
1790
1857
  name: "update_test_oracle",
1791
1858
  discriminator: [
@@ -2381,6 +2448,32 @@ var streamflow_aligned_unlocks_default = {
2381
2448
  ]
2382
2449
  }
2383
2450
  },
2451
+ {
2452
+ name: "UpdateContractParams",
2453
+ type: {
2454
+ kind: "struct",
2455
+ fields: [
2456
+ {
2457
+ name: "transferable_by_sender",
2458
+ type: {
2459
+ option: "bool"
2460
+ }
2461
+ },
2462
+ {
2463
+ name: "transferable_by_recipient",
2464
+ type: {
2465
+ option: "bool"
2466
+ }
2467
+ },
2468
+ {
2469
+ name: "cancelable_by_sender",
2470
+ type: {
2471
+ option: "bool"
2472
+ }
2473
+ }
2474
+ ]
2475
+ }
2476
+ },
2384
2477
  {
2385
2478
  name: "UpdateTestOracleParams",
2386
2479
  type: {
@@ -2605,7 +2698,10 @@ var SolanaStreamClient = class {
2605
2698
  floorPrice
2606
2699
  } = streamParams;
2607
2700
  const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
2608
- common.invariant(priceOracle || !oracleType || oracleType === "none", "Price oracle is required for the specified oracle type");
2701
+ common.invariant(
2702
+ priceOracle || !oracleType || oracleType === "none",
2703
+ "Price oracle is required for the specified oracle type"
2704
+ );
2609
2705
  common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
2610
2706
  const recipientPublicKey = new web3_js.PublicKey(recipient);
2611
2707
  const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
@@ -2780,10 +2876,7 @@ var SolanaStreamClient = class {
2780
2876
  * @returns Create result
2781
2877
  */
2782
2878
  async createUnchecked(data, extParams) {
2783
- const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
2784
- data,
2785
- extParams
2786
- );
2879
+ const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
2787
2880
  const { tx, hash, context } = await common.prepareTransaction(
2788
2881
  this.connection,
2789
2882
  ixs,
@@ -2935,19 +3028,10 @@ var SolanaStreamClient = class {
2935
3028
  recipient: recipientData.recipient
2936
3029
  });
2937
3030
  }
2938
- const prepareInstructions = await this.getCreateATAInstructions(
2939
- [partnerPublicKey],
2940
- mintPublicKey,
2941
- sender,
2942
- true
2943
- );
3031
+ const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
2944
3032
  if (isNative) {
2945
3033
  const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3__default.default(0));
2946
- const nativeInstructions = await common.prepareWrappedAccount(
2947
- this.connection,
2948
- sender.publicKey,
2949
- totalDepositedAmount
2950
- );
3034
+ const nativeInstructions = await common.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
2951
3035
  prepareInstructions.push(...nativeInstructions);
2952
3036
  }
2953
3037
  return {
@@ -3145,10 +3229,7 @@ var SolanaStreamClient = class {
3145
3229
  async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
3146
3230
  const { invoker, customInstructions } = extParams;
3147
3231
  common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
3148
- const ixs = await this.prepareWithdrawInstructions(
3149
- { id, amount },
3150
- extParams
3151
- );
3232
+ const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
3152
3233
  const metadata = new web3_js.PublicKey(id);
3153
3234
  await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
3154
3235
  const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker.publicKey);
@@ -3598,10 +3679,20 @@ var SolanaStreamClient = class {
3598
3679
  const accounts = await this.connection.getProgramAccounts(this.programId, {
3599
3680
  filters
3600
3681
  });
3601
- return accounts.map(({ pubkey, account }) => ({
3602
- publicKey: pubkey,
3603
- account: new Contract(decodeStream(account.data))
3604
- }));
3682
+ const mapped = await Promise.all(
3683
+ accounts.map(async ({ pubkey, account }) => {
3684
+ const stream = decodeStream(account.data);
3685
+ if (this.isAlignedUnlock(pubkey, stream.sender)) {
3686
+ const alignedProxy = await this.alignedProxyProgram.account.contract.fetch(
3687
+ deriveContractPDA(this.alignedProxyProgram.programId, pubkey)
3688
+ );
3689
+ common.invariant(alignedProxy, "Couldn't get aligned proxy account info");
3690
+ return { publicKey: pubkey, account: new AlignedContract(stream, alignedProxy) };
3691
+ }
3692
+ return { publicKey: pubkey, account: new Contract(stream) };
3693
+ })
3694
+ );
3695
+ return mapped;
3605
3696
  }
3606
3697
  /**
3607
3698
  * Attempts updating the stream auto withdrawal params and amount per period
@@ -3642,17 +3733,26 @@ var SolanaStreamClient = class {
3642
3733
  const streamPublicKey = new web3_js.PublicKey(data.id);
3643
3734
  const escrow = await this.connection.getAccountInfo(streamPublicKey);
3644
3735
  common.invariant(escrow, "Couldn't get account info");
3736
+ const { sender: senderPublicKey } = decodeStream(escrow.data);
3737
+ const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
3738
+ if (isAlignedUnlock && (data.enableAutomaticWithdrawal !== void 0 || data.amountPerPeriod !== void 0)) {
3739
+ throw new Error("Automatic withdrawal and rate update are not possible in price-based vesting!");
3740
+ }
3645
3741
  const ixs = common.prepareBaseInstructions(this.connection, {
3646
3742
  computePrice,
3647
3743
  computeLimit
3648
3744
  });
3649
3745
  ixs.push(
3650
- await updateStreamInstruction(data, this.programId, {
3746
+ await (isAlignedUnlock ? this.alignedProxyProgram.methods.updateContract({
3747
+ transferableBySender: data.transferableBySender ?? null,
3748
+ transferableByRecipient: data.transferableByRecipient ?? null,
3749
+ cancelableBySender: data.cancelableBySender ?? null
3750
+ }).accounts({ sender: invoker.publicKey, streamMetadata: streamPublicKey, withdrawor: WITHDRAWOR_PUBLIC_KEY }).accountsPartial({ streamflowProgram: this.programId }).instruction() : updateStreamInstruction(data, this.programId, {
3651
3751
  authority: invoker.publicKey,
3652
3752
  metadata: streamPublicKey,
3653
3753
  withdrawor: WITHDRAWOR_PUBLIC_KEY,
3654
3754
  systemProgram: web3_js.SystemProgram.programId
3655
- })
3755
+ }))
3656
3756
  );
3657
3757
  return ixs;
3658
3758
  }
@@ -3711,8 +3811,8 @@ var SolanaStreamClient = class {
3711
3811
  return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
3712
3812
  }
3713
3813
  /**
3714
- * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3715
- */
3814
+ * Utility function that checks whether the associated stream address is an aligned unlock contract, indicated by whether the sender/creator is a PDA
3815
+ */
3716
3816
  isAlignedUnlock(streamPublicKey, senderPublicKey) {
3717
3817
  const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
3718
3818
  return senderPublicKey.equals(pda);
@@ -4247,7 +4347,6 @@ exports.isAligned = isAligned;
4247
4347
  exports.isCliffCloseToDepositedAmount = isCliffCloseToDepositedAmount;
4248
4348
  exports.isCreateAlignedStreamData = isCreateAlignedStreamData;
4249
4349
  exports.isDynamicLock = isDynamicLock;
4250
- exports.isPayment = isPayment;
4251
4350
  exports.isTokenLock = isTokenLock;
4252
4351
  exports.isVesting = isVesting;
4253
4352
  exports.sendAndConfirmStreamRawTransaction = sendAndConfirmStreamRawTransaction;