@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.
- package/dist/cjs/index.cjs +126 -29
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/descriptor/streamflow_aligned_unlocks.d.cts +101 -1
- package/dist/cjs/solana/index.cjs +126 -29
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +4 -4
- package/dist/esm/index.js +126 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/idl/streamflow_aligned_unlocks.json +101 -1
- package/dist/esm/solana/descriptor/streamflow_aligned_unlocks.d.ts +101 -1
- package/dist/esm/solana/index.d.ts +4 -4
- package/dist/esm/solana/index.js +126 -29
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.cjs
CHANGED
|
@@ -905,7 +905,7 @@ var streamflow_aligned_unlocks_default = {
|
|
|
905
905
|
address: "aSTRM2NKoKxNnkmLWk9sz3k74gKBk9t7bpPrTGxMszH",
|
|
906
906
|
metadata: {
|
|
907
907
|
name: "streamflow_aligned_unlocks",
|
|
908
|
-
version: "1.
|
|
908
|
+
version: "1.4.0",
|
|
909
909
|
spec: "0.1.0",
|
|
910
910
|
description: "Proxy to update unlock amount within Streamflow vesting protocol according to Token performance and other metrics"
|
|
911
911
|
},
|
|
@@ -1779,6 +1779,80 @@ var streamflow_aligned_unlocks_default = {
|
|
|
1779
1779
|
],
|
|
1780
1780
|
args: []
|
|
1781
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
|
+
},
|
|
1782
1856
|
{
|
|
1783
1857
|
name: "update_test_oracle",
|
|
1784
1858
|
discriminator: [
|
|
@@ -2374,6 +2448,32 @@ var streamflow_aligned_unlocks_default = {
|
|
|
2374
2448
|
]
|
|
2375
2449
|
}
|
|
2376
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
|
+
},
|
|
2377
2477
|
{
|
|
2378
2478
|
name: "UpdateTestOracleParams",
|
|
2379
2479
|
type: {
|
|
@@ -2564,7 +2664,7 @@ var SolanaStreamClient = class {
|
|
|
2564
2664
|
return { ixs, txId: signature, metadataId };
|
|
2565
2665
|
}
|
|
2566
2666
|
async prepareCreateInstructions(streamParams, extParams) {
|
|
2567
|
-
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.
|
|
2667
|
+
const { ixs, metadata, metadataPubKey } = isCreateAlignedStreamData(streamParams) ? await this.prepareCreateAlignedUnlockInstructions(streamParams, extParams) : await this.prepareCreateLinearStreamInstructions(streamParams, extParams);
|
|
2568
2668
|
return { ixs, metadata, metadataPubKey };
|
|
2569
2669
|
}
|
|
2570
2670
|
async prepareCreateAlignedUnlockInstructions(streamParams, extParams) {
|
|
@@ -2598,7 +2698,10 @@ var SolanaStreamClient = class {
|
|
|
2598
2698
|
floorPrice
|
|
2599
2699
|
} = streamParams;
|
|
2600
2700
|
const { isNative, sender, computeLimit, computePrice, metadataPubKeys } = extParams;
|
|
2601
|
-
common.invariant(
|
|
2701
|
+
common.invariant(
|
|
2702
|
+
priceOracle || !oracleType || oracleType === "none",
|
|
2703
|
+
"Price oracle is required for the specified oracle type"
|
|
2704
|
+
);
|
|
2602
2705
|
common.assertHasPublicKey(sender, "Sender's PublicKey is not available, check passed wallet adapter!");
|
|
2603
2706
|
const recipientPublicKey = new web3_js.PublicKey(recipient);
|
|
2604
2707
|
const mintPublicKey = isNative ? splToken.NATIVE_MINT : new web3_js.PublicKey(mint);
|
|
@@ -2671,7 +2774,7 @@ var SolanaStreamClient = class {
|
|
|
2671
2774
|
* @param {IPrepareCreateStreamExt} extParams - Transaction configuration including sender wallet, metadata keys, and compute settings
|
|
2672
2775
|
* @returns Create stream instructions
|
|
2673
2776
|
*/
|
|
2674
|
-
async
|
|
2777
|
+
async prepareCreateLinearStreamInstructions({
|
|
2675
2778
|
recipient,
|
|
2676
2779
|
tokenId: mint,
|
|
2677
2780
|
start,
|
|
@@ -2773,10 +2876,7 @@ var SolanaStreamClient = class {
|
|
|
2773
2876
|
* @returns Create result
|
|
2774
2877
|
*/
|
|
2775
2878
|
async createUnchecked(data, extParams) {
|
|
2776
|
-
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(
|
|
2777
|
-
data,
|
|
2778
|
-
extParams
|
|
2779
|
-
);
|
|
2879
|
+
const { ixs, metadata, metadataPubKey } = await this.prepareCreateUncheckedInstructions(data, extParams);
|
|
2780
2880
|
const { tx, hash, context } = await common.prepareTransaction(
|
|
2781
2881
|
this.connection,
|
|
2782
2882
|
ixs,
|
|
@@ -2928,19 +3028,10 @@ var SolanaStreamClient = class {
|
|
|
2928
3028
|
recipient: recipientData.recipient
|
|
2929
3029
|
});
|
|
2930
3030
|
}
|
|
2931
|
-
const prepareInstructions = await this.getCreateATAInstructions(
|
|
2932
|
-
[partnerPublicKey],
|
|
2933
|
-
mintPublicKey,
|
|
2934
|
-
sender,
|
|
2935
|
-
true
|
|
2936
|
-
);
|
|
3031
|
+
const prepareInstructions = await this.getCreateATAInstructions([partnerPublicKey], mintPublicKey, sender, true);
|
|
2937
3032
|
if (isNative) {
|
|
2938
3033
|
const totalDepositedAmount = recipients.reduce((acc, recipient) => recipient.amount.add(acc), new BN3__default.default(0));
|
|
2939
|
-
const nativeInstructions = await common.prepareWrappedAccount(
|
|
2940
|
-
this.connection,
|
|
2941
|
-
sender.publicKey,
|
|
2942
|
-
totalDepositedAmount
|
|
2943
|
-
);
|
|
3034
|
+
const nativeInstructions = await common.prepareWrappedAccount(this.connection, sender.publicKey, totalDepositedAmount);
|
|
2944
3035
|
prepareInstructions.push(...nativeInstructions);
|
|
2945
3036
|
}
|
|
2946
3037
|
return {
|
|
@@ -3138,10 +3229,7 @@ var SolanaStreamClient = class {
|
|
|
3138
3229
|
async withdraw({ id, amount = WITHDRAW_AVAILABLE_AMOUNT }, extParams) {
|
|
3139
3230
|
const { invoker, customInstructions } = extParams;
|
|
3140
3231
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3141
|
-
const ixs = await this.prepareWithdrawInstructions(
|
|
3142
|
-
{ id, amount },
|
|
3143
|
-
extParams
|
|
3144
|
-
);
|
|
3232
|
+
const ixs = await this.prepareWithdrawInstructions({ id, amount }, extParams);
|
|
3145
3233
|
const metadata = new web3_js.PublicKey(id);
|
|
3146
3234
|
await this.applyCustomAfterInstructions(ixs, customInstructions, metadata);
|
|
3147
3235
|
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker.publicKey);
|
|
@@ -3239,7 +3327,7 @@ var SolanaStreamClient = class {
|
|
|
3239
3327
|
}
|
|
3240
3328
|
const { sender: senderPublicKey } = decodeStream(account.data);
|
|
3241
3329
|
const isAlignedUnlock = this.isAlignedUnlock(streamPublicKey, senderPublicKey);
|
|
3242
|
-
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.
|
|
3330
|
+
const ixs = isAlignedUnlock ? await this.prepareCancelAlignedUnlockInstructions(cancelData, extParams) : await this.prepareCancelLinearStream(cancelData, extParams);
|
|
3243
3331
|
return ixs;
|
|
3244
3332
|
}
|
|
3245
3333
|
/**
|
|
@@ -3287,7 +3375,7 @@ var SolanaStreamClient = class {
|
|
|
3287
3375
|
* @param {IPrepareStreamExt} extParams - Transaction configuration including invoker wallet, token account validation, and compute settings
|
|
3288
3376
|
* @returns Transaction instructions
|
|
3289
3377
|
*/
|
|
3290
|
-
async
|
|
3378
|
+
async prepareCancelLinearStream({ id }, { invoker, checkTokenAccounts, computePrice, computeLimit }) {
|
|
3291
3379
|
common.assertHasPublicKey(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
3292
3380
|
const streamPublicKey = new web3_js.PublicKey(id);
|
|
3293
3381
|
const escrowAcc = await this.connection.getAccountInfo(streamPublicKey);
|
|
@@ -3645,17 +3733,26 @@ var SolanaStreamClient = class {
|
|
|
3645
3733
|
const streamPublicKey = new web3_js.PublicKey(data.id);
|
|
3646
3734
|
const escrow = await this.connection.getAccountInfo(streamPublicKey);
|
|
3647
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
|
+
}
|
|
3648
3741
|
const ixs = common.prepareBaseInstructions(this.connection, {
|
|
3649
3742
|
computePrice,
|
|
3650
3743
|
computeLimit
|
|
3651
3744
|
});
|
|
3652
3745
|
ixs.push(
|
|
3653
|
-
await
|
|
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, {
|
|
3654
3751
|
authority: invoker.publicKey,
|
|
3655
3752
|
metadata: streamPublicKey,
|
|
3656
3753
|
withdrawor: WITHDRAWOR_PUBLIC_KEY,
|
|
3657
3754
|
systemProgram: web3_js.SystemProgram.programId
|
|
3658
|
-
})
|
|
3755
|
+
}))
|
|
3659
3756
|
);
|
|
3660
3757
|
return ixs;
|
|
3661
3758
|
}
|
|
@@ -3714,8 +3811,8 @@ var SolanaStreamClient = class {
|
|
|
3714
3811
|
return extractSolanaErrorCode(err.toString() ?? "Unknown error!", logs);
|
|
3715
3812
|
}
|
|
3716
3813
|
/**
|
|
3717
|
-
|
|
3718
|
-
|
|
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
|
+
*/
|
|
3719
3816
|
isAlignedUnlock(streamPublicKey, senderPublicKey) {
|
|
3720
3817
|
const pda = deriveContractPDA(this.alignedProxyProgram.programId, streamPublicKey);
|
|
3721
3818
|
return senderPublicKey.equals(pda);
|