SDK for Rust on-chain solana programs to interact with streamflow protocol
Declare a dependency in your program's Cargo.toml
toml
streamflow_sdk = {version = "0.6", features = ["cpi"]}
To use protocol on mainnet add sdk with mainnet
feature
toml
streamflow_sdk = {version = "0.6", features = ["cpi", "mainnet"]}
Example anchor program invoking streamflow create instruction:
```rust use anchorlang::{prelude::*}; use anchorspl::{ associated_token::AssociatedToken, token::{Mint, Token, TokenAccount}, };
use streamflowsdk; use streamflowsdk::cpi::accounts::Create;
let accs = Create { sender: ctx.accounts.sender.toaccountinfo(), sendertokens: ctx.accounts.sendertokens.toaccountinfo(), recipient: ctx.accounts.recipient.toaccountinfo(), recipienttokens: ctx.accounts.recipienttokens.toaccountinfo(), metadata: ctx.accounts.metadata.toaccountinfo(), escrowtokens: ctx.accounts.escrowtokens.toaccountinfo(), streamflowtreasury: ctx.accounts.streamflowtreasury.toaccountinfo(), streamflowtreasurytokens: ctx.accounts.streamflowtreasurytokens.toaccountinfo(), withdrawor: ctx.accounts.withdrawor.toaccountinfo(), partner: ctx.accounts.partner.toaccountinfo(), partnertokens: ctx.accounts.partnertokens.toaccountinfo(), mint: ctx.accounts.mint.toaccountinfo(), feeoracle: ctx.accounts.feeoracle.toaccountinfo(), rent: ctx.accounts.rent.toaccountinfo(), timelockprogram: ctx.accounts.streamflowprogram.toaccountinfo(), tokenprogram: ctx.accounts.tokenprogram.toaccountinfo(), associatedtokenprogram: ctx.accounts.associatedtokenprogram.toaccountinfo(), systemprogram: ctx.accounts.systemprogram.toaccountinfo(), };
let cpictx = CpiContext::new(ctx.accounts.streamflowprogram.toaccountinfo(), accs);
streamflowsdk::cpi::create( cpictx, starttime, netamountdeposited, period, amountperperiod, cliff, cliffamount, cancelablebysender, cancelablebyrecipient, automaticwithdrawal, transferablebysender, transferablebyrecipient, cantopup, streamname, withdrawfrequency, pausable, canupdaterate ) ```
For a more detailed example, check ./programs/example/lib.rs
| parameter |address| |---------------------|----| | programid |strmRqUCoQUgGUan5YhzUZa6KqdzwX5L6FpUxfmKg5m| | feesoracle |addr| | streamflow_treasury |5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw| | withdrawor |wdrwhnCv4pzW8beKsbPa4S2UDZrXenjg16KJdKSpb5u|
Rust program that provides SPL timelock functionalities
Functionalities are:
- create
a vesting contract.
- update
a vesting contract
- withdraw
from a vesting contract.
- cancel
a vesting contract.
- transfer_recipient
of a vesting contract.
Streamflow protocol transfer 0.25% of contract total amount (netamountdeposit) to streamflow treasury to cover costs of building and maintaining protocl.
Streamflow protocol supports integrating partner fees for other protocols built on top of streamflow. For more information, reach us out on discord. link