The getActions
method generates a set of actions required for the fractionalization process of a market based on the traits provided by the client. These actions typically involve approving the spending of assets and creating fractions on the blockchain. The traits, which are defined client-side, specify the characteristics and rules for fractionalization (e.g., types of assets, time boundaries, capitalization rules).
Parameters
traits
(IMarketFractionTraits): An optional object defined by the client that specifies how fractionalization should be performed for the market. This parameter allows for static typing of the market's configuration, ensuring that the actions align with the market's predefined features.
Returns
IFractionActions: An object that represents a set of actions (IActionsSet
) needed to fractionalize assets. This includes the approve-fractions
action to approve asset spending and the create-fractions
action to mint the fractions.
Usage Example
// Step 1: Define the traits for the market's fractionalization
const traits = {
// Example traits defining the market's fractionalization features
wrappedAssetKind: MarketTraitEnum.WRAPPED_ASSET_KIND,
fractionAssetKinds: MarketTraitEnum.FRACTION_ASSET_KINDS,
time: MarketTraitEnum.TIME,
capitalization: MarketTraitEnum.CAPITALISATION,
// Additional traits as needed
};
// Step 2: Call getActions to generate the actions required for fractionalizing the market
const actions = sdk.FractionalizeService.getActions(traits);
// Step 3: Optionally, subscribe to the execution state to track progress
actions.on('state', (state) => {
console.log('Current state:', state);
});