Skip to content

Commit

Permalink
[Bootstrapping]: Add manifest sbor types for initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Jan 22, 2024
1 parent b395376 commit 9e88a73
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
2 changes: 2 additions & 0 deletions libraries/scrypto-interface/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ fn generate_scrypto_stub(
quote! {
#[derive(
::radix_engine_interface::prelude::ScryptoSbor,
::radix_engine_interface::prelude::ManifestSbor,
Clone,
Copy,
Debug,
Expand Down Expand Up @@ -348,6 +349,7 @@ fn generate_scrypto_test_stub(
quote! {
#[derive(
::radix_engine_interface::prelude::ScryptoSbor,
::radix_engine_interface::prelude::ManifestSbor,
Clone,
Copy,
Debug,
Expand Down
2 changes: 1 addition & 1 deletion packages/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ mod bootstrap {
.values()
.copied()
.collect(),
liquidity_receipt: caviar_nine_liquidity_receipt,
liquidity_receipt: caviar_nine_liquidity_receipt.address(),
}
}),
initial_user_resource_volatility: Some(
Expand Down
42 changes: 38 additions & 4 deletions packages/ignition/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ mod ignition {
self.pool_information
.get_mut(&blueprint_id)
.expect(NO_ADAPTER_FOUND_FOR_POOL_ERROR)
.liquidity_receipt = liquidity_receipt;
.liquidity_receipt = liquidity_receipt.address();
}

/// Inserts the pool information, adding it to the protocol, performing
Expand Down Expand Up @@ -1519,7 +1519,7 @@ mod ignition {
POOL_IS_NOT_IN_ALLOW_LIST_ERROR
);

(entry.adapter, entry.liquidity_receipt, entry)
(entry.adapter, entry.liquidity_receipt(), entry)
})
}

Expand Down Expand Up @@ -1595,7 +1595,7 @@ mod ignition {
}

/// Represents the information of pools belonging to a particular blueprint.
#[derive(Clone, Debug, PartialEq, Eq, ScryptoSbor)]
#[derive(Clone, Debug, PartialEq, Eq, ScryptoSbor, ManifestSbor)]
pub struct PoolBlueprintInformation {
/// The adapter to utilize when making calls to pools belonging to this
/// blueprint.
Expand All @@ -1608,7 +1608,13 @@ pub struct PoolBlueprintInformation {

/// A reference to the resource manager of the resource used as a receipt
/// for providing liquidity to pools of this blueprint
pub liquidity_receipt: ResourceManager,
pub liquidity_receipt: ResourceAddress,
}

impl PoolBlueprintInformation {
pub fn liquidity_receipt(&self) -> ResourceManager {
ResourceManager::from(self.liquidity_receipt)
}
}

/// The reserves of the ignition protocol asset split by the assets to use in
Expand Down Expand Up @@ -1697,3 +1703,31 @@ pub struct InitializationParameters {
/// position or not. Defaults to [`false`] if not specified.
pub initial_is_close_position_enabled: Option<bool>,
}

#[derive(Debug, PartialEq, Eq, ManifestSbor, Default)]
pub struct InitializationParametersManifest {
/// The initial set of pool information to add to to Ignition.
pub initial_pool_information:
Option<IndexMap<BlueprintId, PoolBlueprintInformation>>,

/// The initial volatility settings to add to Ignition.
pub initial_user_resource_volatility:
Option<IndexMap<ResourceAddress, Volatility>>,

/// The initial set of reward rates to add to Ignition.
pub initial_reward_rates: Option<IndexMap<LockupPeriod, Decimal>>,

/// The initial volatile protocol resources to deposit into that vault.
pub initial_volatile_protocol_resources: Option<ManifestBucket>,

/// The initial non volatile protocol resources to deposit into that vault.
pub initial_non_volatile_protocol_resources: Option<ManifestBucket>,

/// The initial control of whether the user is allowed to open a liquidity
/// position or not. Defaults to [`false`] if not specified.
pub initial_is_open_position_enabled: Option<bool>,

/// The initial control of whether the user is allowed to close a liquidity
/// position or not. Defaults to [`false`] if not specified.
pub initial_is_close_position_enabled: Option<bool>,
}
5 changes: 1 addition & 4 deletions tests/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,7 @@ impl ScryptoUnitEnv {
.maximum_allowed_price_staleness_seconds,
configuration
.maximum_allowed_relative_price_difference,
(
None::<()>, None::<()>, None::<()>, None::<()>,
None::<()>, None::<()>, None::<()>,
),
InitializationParametersManifest::default(),
None::<ManifestAddressReservation>,
),
)
Expand Down

0 comments on commit 9e88a73

Please sign in to comment.