Skip to content

Commit

Permalink
Rename to index
Browse files Browse the repository at this point in the history
  • Loading branch information
pselle committed Jul 23, 2024
1 parent f2a54d2 commit 51d3323
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use loam_sdk::{
soroban_sdk::{Address, Lazy},
subcontract,
};

#[subcontract]
pub trait CDP {
pub trait IsCDP {
// Deploy new xAsset contract (so it will need to store the wasm of the xAsset contract, or a reference to it by name on the Loam Registry), which is only callable by admin.

fn create_contract(&self, asset: Asset, contract: Address);
// TODO

// List all CDPs for a given account, so it can iterate the "map of asset names" keys and make cross-contract calls to see if the given account has an entry in its CDPs map.
fn list_cdps(&self, account: Address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use loam_sdk::{
IntoKey,
};

use crate::cdp::CDP;
use crate::cdp::IsCDP;

pub enum Asset {
/// Can be a Stellar Classic or Soroban asset
Expand All @@ -14,38 +14,31 @@ pub enum Asset {

#[contracttype]
#[derive(IntoKey)]
pub struct Landscape {
pub struct EquitXIndex {
// A map of asset names ("xUSD") to contract addresses ("C123…")
assets: Map<Asset, Address>,
}

impl Landscape {
impl EquitXIndex {
#[must_use]
pub fn new(assets: Map<Asset, Address>) -> Self {
let mut asset_map = Map::new(env());
for asset in assets.into_iter() {
asset_map.set(asset, Map::new(env()));
}
Landscape { assets: asset_map }
EquitXIndex { assets: asset_map }
}
}

/// Loam SDK currently requires us to implement `Default`. This will be fixed in
/// https://github.com/loambuild/loam/issues/92
impl Default for Landscape {
impl Default for EquitXIndex {
fn default() -> Self {
Landscape::new(Map::new(env()))
EquitXIndex::new(Map::new(env()))
}
}

impl CDP for Landscape {
// Deploy new xAsset contract (so it will need to store the wasm of the xAsset contract, or a reference to it by name on the Loam Registry), which is only callable by admin.

fn create_contract(&self, asset: Asset, contract: Address) {
todo!()
//self.assets.set(asset, contract);
}

impl IsCDP for EquitXIndex {
// List all CDPs for a given account, so it can iterate the "map of asset names" keys and make cross-contract calls to see if the given account has an entry in its CDPs map.
fn list_cdps(&self, account: Address) {
todo!()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use loam_sdk::{derive_contract, soroban_sdk::Vec};
use loam_subcontract_core::{admin::Admin, Core};

mod contract;
pub mod cdp;

pub use contract::Landscape;
mod equitx_index;

pub use equitx_index::EquitXIndex;

0 comments on commit 51d3323

Please sign in to comment.