Data source
What everyone needs to knowβ
- A data source contract is a way of providing extensions to a treasury that either override or augment the default
JBPayoutRedemptionPaymentTerminal3_1_1
functionality. - A data source contract can be used to provide custom data to the
JBPayoutRedemptionPaymentTerminal3_1_1.pay(...)
transaction and/or theJBPayoutRedemptionPaymentTerminal3_1_1.redeemTokensOf(...)
transaction. - A data source is passed contextual information from the transactions, from which it can derive custom data for the protocol to use to affect subsequent behaviors in the pay and redeem transactions. Contextual information from the pay transaction is passed to the data source in the form of
JBPayParamsData
, and contextual information from the redeem transaction is passed to the data source in the form ofJBRedeemParamsData
. - Data sources can revert under custom circumstances, which can be used to create a gated treasury, max token supply, min contribution amount, etc.
- A data source is responsible for specifying any delegate hooks that should be triggered after the core functionality of a
pay(...)
orredeemTokensOf(...)
transaction executes successfully. - Each
IJBPaymentTerminal
fork can leverage data sources in unique ways.
What you'll want to know if you're buildingβ
- A data source must adhere to the
IJBFundingCycleDataSource3_1_1
interface. - A data source contract can be specified in a funding cycle, along with flags that indicate if the funding cycle should
useDataSourceForPay
and/oruseDataSourceForRedeem
. These are set either inJBController3_1.launchProjectFor(...)
orJBController3_1.reconfigureFundingCyclesOf(...)
. - A funding cycle's data source is called upon in
JBSingleTokenPaymentTerminalStore3_1_1.recordPaymentFrom(...)
and inJBSingleTokenPaymentTerminalStore3_1_1.recordRedemptionFor(...)
. - A data source has implicit permissions to
JBController3_1.mintTokensFor(...)
on a project's behalf. - If a data source is not specified in a funding cycle, or if flags aren't explicitly set, default protocol data will be used.