Skip to content

Commit

Permalink
WIP: Liquidity Pools v2 (#1909)
Browse files Browse the repository at this point in the history
* feat: LPv2 message reorder (#1892)

* wip: add new msgs + reorder

* refactor: apply renaming

* fix: ITs

* feat: UpdateRestriction message

* fix: cancel_unprocessed_investment IT

* fix: fmt

* fix: clippy

* tests: reanchor solidity to reorder branch

* feat: apply hook to AddTranche msg

* tests: fix pool_management ITs

* wip: fix lp investments

* fmt

* fix: Tranche namespace

* refactor: remove fulfilled from FulfilledRedeemRequest

* chore: update lp submodule

* minor cleanup

* chore: update lp submodule

* chore: add missing cleanup

* fixes + ignore failing tests

* fmt

* tests: fix message indices

* ignore failing tests (#1910)

* LPv2: ForeignInvestments changes (#1895)

* add uts (#1905)

* main changes for FI

* fix correlation precission

* minor renames

* update investment UTs

* update redemption UTs

* miscelaneous UTs

* minor renames

* simplify correlation and embed to the only needed place

* doc change

* remove unused bound

* swapping calls into entities.rs file

* merge SwapDone methods into FulfilledSwapHook

* fix events

* working without pallet-swaps

* remove boilerplate for removing entries

* minor msg change

* minor simplification

* correct fulfilled sum after last collect

* check OrderIdToSwapId storage

* sending the message inside Info closure is not really a problem

* send msgs from the entities

* remove same currency check in impl.rs

* unify hooks

* remove pallet-swaps

* minor fmt

* add docs

* add architecture diagram

* return cancelled foreign amount from FI interface

* update liquidity-pools

* add messages to diagram

* implement hooks

* fix runtimes

* adapt integration-tests

* fix docs

* fix clippy

* fix clippy

* fix tests after merge

* fix foreign investment tests (#1918)

* ignore failing tests (#1919)

* fix previous merge

* LP v2: fix integration tests (#1915)

* chore: update submodule to latest `main` 6d7f242c0dd83b1b5a4f6d506370a1f3ecbef9ce

* wip: fix ITs

* chore: update submodule

* fix: remove sender param from `Transfer*` messages

* chore: cleanup

* docs: setup evm

* fix: msg tests

* fix: more ITs

* fix: missing refactor after rebase

* chore: update submodule to 223a0f36edabc675f8c74c47b20e366178df7ca3

* chore: improvements

* fmt

* Apply suggestions from code review

* chore: bump spec_version

* fmt: taplo

* LPv2: Batch Message serialization (#1920)

* custo serialize/deserialize for batch

* compiling solution

* serialization/deserialization working for batch message

* remove gmpf changes

* add batch nested protection

* faster serialization for submessages

* correct termination

* add tests for deserialize batch of batch

* add into_iter

* remove unused Box and add pack methods

* fix non_std compilation

* non_std

* fix max_encoded_len recursion issue

* fix submodules

* reduce batch limit

* feat: add domain hook storage (#1928)

* refactor: add domain hook address storage

* tests: add gateway lp admin account checks

* refactor: use GetByKey

* fix: outboundq mock

* refactor: hook 20 bytes instead of 32

* fix cargo fmt

* Feat/lp v2 gateway queue (#1930)

* pallets: Add LP Gateway queue pallet

* lp-gateway-queue: Add benchmarks

* integration-tests: Add LP gateway tests

* docs: Update LP gateway queue entry

* lp-gateway-queue: Use default weight for PostDispatchInfo

* lp-gateway-queue: Add DEFAULT_WEIGHT_REF_TIME const, extract message processing logic, use BaseArithmetic for nonce

* runtime: Add defensive weights for LP gateway queue

* lint: Obey

* taplo: Obey

* pallet: Use DispatchResult for extrinsics

* runtime: Update benchmarks and weight info

* benchmarks: Add default for Message type (wip)

* pallet: Add Default bound to Message type

* lp-v2: fix message fields (#1933)

* fix: add remark call to borrow proxy

* fix: add missing message fields

* chore: bump to v0.13.3

* chore: update submodule

* chore: enable fixed tests

---------

Co-authored-by: Frederik Gartenmeister <mustermeiszer@posteo.de>

* refactor: cleanup my leftovers (#1935)

* LPv2: Bump-up foreign investment. Fix failing investment ITs  (#1934)

* increase version for foreign investments

* fix investment issue

* fix solidity call for transfers_tokens

* fix tests

* minimize required tranche investors for IT

* fix docs

* fix docs

* docs: fix hyperlink

* refactor: enable ITs for centrifuge + dev runtimes (#1938)

* fix: enable ITs for centrifuge + dev runtimes

* fmt

* fix: revert some centrifuge ITs

* fmt

* revert centrifuge addition to ITs

---------

Co-authored-by: William Freudenberger <w.freude@icloud.com>

---------

Co-authored-by: William Freudenberger <w.freude@icloud.com>
Co-authored-by: Cosmin Damian <17934949+cdamian@users.noreply.github.com>
Co-authored-by: Frederik Gartenmeister <mustermeiszer@posteo.de>
  • Loading branch information
4 people authored Aug 1, 2024
1 parent 1edf2b0 commit b682138
Show file tree
Hide file tree
Showing 79 changed files with 5,793 additions and 6,233 deletions.
54 changes: 30 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ members = [
"pallets/liquidity-pools-gateway",
"pallets/liquidity-pools-gateway/axelar-gateway-precompile",
"pallets/liquidity-pools-gateway/routers",
"pallets/liquidity-pools-gateway/queue",
"pallets/liquidity-rewards",
"pallets/loans",
"pallets/oracle-feed",
Expand All @@ -35,7 +36,6 @@ members = [
"pallets/restricted-tokens",
"pallets/restricted-xtokens",
"pallets/rewards",
"pallets/swaps",
"pallets/token-mux",
"pallets/transfer-allowlist",
"runtime/altair",
Expand All @@ -53,7 +53,7 @@ license = "LGPL-3.0"
homepage = "https://centrifuge.io/"
repository = "https://github.com/centrifuge/centrifuge-chain"
documentation = "https://reference.centrifuge.io/centrifuge_chain/index.html"
version = "0.13.0"
version = "0.14.0"

[workspace.dependencies]
hex-literal = { version = "0.4.1" }
Expand Down Expand Up @@ -237,6 +237,7 @@ pallet-investments = { path = "pallets/investments", default-features = false }
pallet-keystore = { path = "pallets/keystore", default-features = false }
pallet-liquidity-pools = { path = "pallets/liquidity-pools", default-features = false }
pallet-liquidity-pools-gateway = { path = "pallets/liquidity-pools-gateway", default-features = false }
pallet-liquidity-pools-gateway-queue = { path = "pallets/liquidity-pools-gateway/queue", default-features = false }
pallet-liquidity-rewards = { path = "pallets/liquidity-rewards", default-features = false }
pallet-loans = { path = "pallets/loans", default-features = false }
pallet-oracle-feed = { path = "pallets/oracle-feed", default-features = false }
Expand All @@ -249,7 +250,6 @@ pallet-pool-system = { path = "pallets/pool-system", default-features = false }
pallet-restricted-tokens = { path = "pallets/restricted-tokens", default-features = false }
pallet-restricted-xtokens = { path = "pallets/restricted-xtokens", default-features = false }
pallet-rewards = { path = "pallets/rewards", default-features = false }
pallet-swaps = { path = "pallets/swaps", default-features = false }
pallet-token-mux = { path = "pallets/token-mux", default-features = false }
pallet-transfer-allowlist = { path = "pallets/transfer-allowlist", default-features = false }

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ On top of the [Substrate FRAME](https://docs.substrate.io/reference/frame-pallet
- [**liquidity-pools**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools/index.html)): Provides the toolset to enable foreign investments on foreign domains.

- [**liquidity-pools-gateway**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway/index.html)): The main handler of incoming and outgoing Liquidity Pools messages.
-
- [**liquidity-pools-gateway-queue**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/queue) ([docs](https://reference.centrifuge.io/pallet_liquidity_pools_gateway_queue/index.html)): The queue used by the Liquidity Pools Gateway for processing inbound/outbound messages.

- [**liquidity-pools-gateway-routers**](https://github.com/centrifuge/centrifuge-chain/tree/main/pallets/liquidity-pools-gateway/routers) ([docs](https://reference.centrifuge.io/liquidity_pools_gateway_routers/index.html)): This crate contains the `DomainRouters` used by the Liquidity Pools Gateway pallet.

Expand Down
80 changes: 10 additions & 70 deletions libs/mocks/src/foreign_investment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ pub mod pallet {
register_call!(move |(a, b, c, d)| f(a, b, c, d));
}

pub fn mock_decrease_foreign_investment(
f: impl Fn(&T::AccountId, T::InvestmentId, T::Amount, T::CurrencyId) -> DispatchResult
+ 'static,
pub fn mock_cancel_foreign_investment(
f: impl Fn(&T::AccountId, T::InvestmentId, T::CurrencyId) -> DispatchResult + 'static,
) {
register_call!(move |(a, b, c, d)| f(a, b, c, d));
register_call!(move |(a, b, c)| f(a, b, c));
}

pub fn mock_increase_foreign_redemption(
Expand All @@ -45,48 +44,21 @@ pub mod pallet {
register_call!(move |(a, b, c, d)| f(a, b, c, d));
}

pub fn mock_decrease_foreign_redemption(
pub fn mock_cancel_foreign_redemption(
f: impl Fn(
&T::AccountId,
T::InvestmentId,
T::TrancheAmount,
T::CurrencyId,
) -> DispatchResult
) -> Result<T::TrancheAmount, DispatchError>
+ 'static,
) {
register_call!(move |(a, b, c, d)| f(a, b, c, d));
}

pub fn mock_collect_foreign_investment(
f: impl Fn(&T::AccountId, T::InvestmentId, T::CurrencyId) -> DispatchResult + 'static,
) {
register_call!(move |(a, b, c)| f(a, b, c));
}

pub fn mock_collect_foreign_redemption(
f: impl Fn(&T::AccountId, T::InvestmentId, T::CurrencyId) -> DispatchResult + 'static,
) {
register_call!(move |(a, b, c)| f(a, b, c));
}

pub fn mock_investment(
f: impl Fn(&T::AccountId, T::InvestmentId) -> Result<T::Amount, DispatchError> + 'static,
) {
register_call!(move |(a, b)| f(a, b));
}

pub fn mock_redemption(
f: impl Fn(&T::AccountId, T::InvestmentId) -> Result<T::TrancheAmount, DispatchError>
+ 'static,
) {
register_call!(move |(a, b)| f(a, b));
}
}

impl<T: Config> ForeignInvestment<T::AccountId> for Pallet<T> {
type Amount = T::Amount;
type CurrencyId = T::CurrencyId;
type Error = DispatchError;
type InvestmentId = T::InvestmentId;
type TrancheAmount = T::TrancheAmount;

Expand All @@ -99,13 +71,12 @@ pub mod pallet {
execute_call!((a, b, c, d))
}

fn decrease_foreign_investment(
fn cancel_foreign_investment(
a: &T::AccountId,
b: Self::InvestmentId,
c: Self::Amount,
d: Self::CurrencyId,
c: Self::CurrencyId,
) -> DispatchResult {
execute_call!((a, b, c, d))
execute_call!((a, b, c))
}

fn increase_foreign_redemption(
Expand All @@ -117,43 +88,12 @@ pub mod pallet {
execute_call!((a, b, c, d))
}

fn decrease_foreign_redemption(
a: &T::AccountId,
b: Self::InvestmentId,
c: Self::TrancheAmount,
d: Self::CurrencyId,
) -> DispatchResult {
execute_call!((a, b, c, d))
}

fn collect_foreign_investment(
a: &T::AccountId,
b: Self::InvestmentId,
c: Self::CurrencyId,
) -> DispatchResult {
execute_call!((a, b, c))
}

fn collect_foreign_redemption(
fn cancel_foreign_redemption(
a: &T::AccountId,
b: Self::InvestmentId,
c: Self::CurrencyId,
) -> DispatchResult {
) -> Result<T::TrancheAmount, DispatchError> {
execute_call!((a, b, c))
}

fn investment(
a: &T::AccountId,
b: Self::InvestmentId,
) -> Result<Self::Amount, DispatchError> {
execute_call!((a, b))
}

fn redemption(
a: &T::AccountId,
b: Self::InvestmentId,
) -> Result<Self::TrancheAmount, DispatchError> {
execute_call!((a, b))
}
}
}
Loading

0 comments on commit b682138

Please sign in to comment.