Skip to content

Commit

Permalink
test(Runtime Integration Tests): Updated with #560 & #616.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Types aren't updated yet!

Signed-off-by: Dominik Roth <dominik@composable.finance>

Revert "liquidation test and runtime"

This reverts commit 825d824.

Revert "build fix"

This reverts commit cf02153.

test(Runtime Integration Tests): Fixed type defitions and liquidation strategy test.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending Tests W.I.P.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests W.I.P.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending Tests integration W.I.P. & types.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Market Creation & Types.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Market Creation & Types.

Signed-off-by: Dominik Roth <dominik@composable.finance>

refactor(Lending Pallet): Added lending pallet to runtime.

Signed-off-by: Dominik Roth <dominik@composable.finance>

refactor(Lending Pallet): Added lending pallet to runtime W.I.P.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Vault Setup

BREAKING CHANGE: vault.create fails.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Vault Setup

BREAKING CHANGE: vault.create causes a timeout.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Vault Setup

BREAKING CHANGE: vault.create causes a timeout.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Vault Setup

BREAKING CHANGE: vault.create causes a timeout.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Oracle Setup.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P. Boilerplate added.

Signed-off-by: Dominik Roth <dominik@composable.finance>

test(Runtime Integration Tests): Lending tests integration W.I.P.

Signed-off-by: Dominik Roth <dominik@composable.finance>

build fix

Signed-off-by: Dzmitry Lahoda <dzmitry@lahoda.pro>

liquidation test and runtime
Signed-off-by: Dzmitry Lahoda <dzmitry@lahoda.pro>
  • Loading branch information
dzmitry-lahoda authored and Dominik Roth committed Feb 15, 2022
1 parent f73752e commit 8e6e6ae
Show file tree
Hide file tree
Showing 8 changed files with 492 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,40 @@ declare module '@polkadot/api-base/types/consts' {
**/
[key: string]: Codec;
};
lending: {
/**
* Minimal price of borrow asset in Oracle price required to create
* Creators puts that amount and it is staked under Vault account.
* So he does not owns it anymore.
* So borrow is both stake and tool to create market.
*
* # Why not pure borrow amount minimum?
*
* Borrow may have very small price. Will imbalance some markets on creation.
*
* # Why not native parachain token?
*
* Possible option. But I doubt closing market as easy as transferring back rent. So it is
* not exactly platform rent only.
*
* # Why borrow amount priced by Oracle?
*
* We depend on Oracle to price in Lending. So we know price anyway.
* We normalized price over all markets and protect from spam all possible pairs equally.
* Locking borrow amount ensures manager can create market wit borrow assets, and we force
* him to really create it.
*
* This solution forces to have amount before creating market.
* Vault can take that amount if reconfigured so, but that may be changed during runtime
* upgrades.
**/
marketCreationStake: u128 & AugmentedConst<ApiType>;
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
mosaic: {
minimumTimeLockPeriod: u32 & AugmentedConst<ApiType>;
minimumTTL: u32 & AugmentedConst<ApiType>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,50 @@ declare module '@polkadot/api-base/types/errors' {
**/
[key: string]: AugmentedError<ApiType>;
};
lending: {
/**
* Only assets for which we can track price are supported
**/
AssetNotSupportedByOracle: AugmentedError<ApiType>;
AssetPriceNotFound: AugmentedError<ApiType>;
BorrowAndRepayInSameBlockIsNotSupported: AugmentedError<ApiType>;
BorrowDoesNotExist: AugmentedError<ApiType>;
BorrowerDataCalculationFailed: AugmentedError<ApiType>;
BorrowIndexDoesNotExist: AugmentedError<ApiType>;
BorrowRateDoesNotExist: AugmentedError<ApiType>;
CannotRepayMoreThanBorrowAmount: AugmentedError<ApiType>;
CannotWithdrawFromProvidedBorrowAccount: AugmentedError<ApiType>;
CollateralDepositFailed: AugmentedError<ApiType>;
CollateralFactorIsLessOrEqualOne: AugmentedError<ApiType>;
ExceedLendingCount: AugmentedError<ApiType>;
InvalidTimestampOnBorrowRequest: AugmentedError<ApiType>;
LiquidationFailed: AugmentedError<ApiType>;
MarketAndAccountPairNotFound: AugmentedError<ApiType>;
MarketCollateralWasNotDepositedByAccount: AugmentedError<ApiType>;
/**
* The market could not be found
**/
MarketDoesNotExist: AugmentedError<ApiType>;
MarketIsClosing: AugmentedError<ApiType>;
NotEnoughBorrowAsset: AugmentedError<ApiType>;
NotEnoughCollateral: AugmentedError<ApiType>;
NotEnoughCollateralToBorrowAmount: AugmentedError<ApiType>;
NotEnoughRent: AugmentedError<ApiType>;
Overflow: AugmentedError<ApiType>;
PriceOfInitialBorrowVaultShoyldBeGreaterThanZero: AugmentedError<ApiType>;
RepayAmountMustBeGraterThanZero: AugmentedError<ApiType>;
TransferFailed: AugmentedError<ApiType>;
Unauthorized: AugmentedError<ApiType>;
Underflow: AugmentedError<ApiType>;
/**
* vault provided does not exist
**/
VaultNotFound: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
liquidations: {
NoLiquidationEngineFound: AugmentedError<ApiType>;
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */

import type { Enum, Null, Struct, bool, u128, u32 } from '@polkadot/types-codec';
import type { BTreeMap, Enum, Null, Struct, U8aFixed, Vec, bool, i128, u128, u32, u64 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { EthereumAccountId } from '@polkadot/types/interfaces/eth';
import type { EcdsaSignature, MultiSignature } from '@polkadot/types/interfaces/extrinsics';
import type { ParachainInherentData, PersistedValidationData } from '@polkadot/types/interfaces/parachains';
import type { AccountId32, Balance } from '@polkadot/types/interfaces/runtime';
import type { AccountId32, Balance, Percent, Permill, Perquintill } from '@polkadot/types/interfaces/runtime';

/** @name ComposableSupportValidationValidated */
export interface ComposableSupportValidationValidated extends Struct {
readonly value: ComposableTraitsLendingCreateInput;
readonly reservedFactor: Perquintill;
}

/** @name ComposableTraitsAssetsXcmAssetLocation */
export interface ComposableTraitsAssetsXcmAssetLocation extends Null {}
Expand All @@ -20,6 +26,12 @@ export interface ComposableTraitsBondedFinanceBondOffer extends Null {}
/** @name ComposableTraitsCallFilterCallFilterEntry */
export interface ComposableTraitsCallFilterCallFilterEntry extends Null {}

/** @name ComposableTraitsDefiCurrencyPair */
export interface ComposableTraitsDefiCurrencyPair extends Struct {
readonly base: u128;
readonly quote: u128;
}

/** @name ComposableTraitsDefiSell */
export interface ComposableTraitsDefiSell extends Null {}

Expand All @@ -29,11 +41,94 @@ export interface ComposableTraitsDefiTake extends Null {}
/** @name ComposableTraitsGovernanceSignedRawOrigin */
export interface ComposableTraitsGovernanceSignedRawOrigin extends Null {}

/** @name ComposableTraitsLendingCreateInput */
export interface ComposableTraitsLendingCreateInput extends Struct {
readonly updatable: ComposableTraitsLendingUpdateInput;
readonly currencyPair: ComposableTraitsDefiCurrencyPair;
}

/** @name ComposableTraitsLendingMarketConfig */
export interface ComposableTraitsLendingMarketConfig extends Null {}

/** @name ComposableTraitsLendingMathCurveModel */
export interface ComposableTraitsLendingMathCurveModel extends Struct {
readonly baseRate: u128;
}

/** @name ComposableTraitsLendingMathDoubleExponentModel */
export interface ComposableTraitsLendingMathDoubleExponentModel extends Struct {
readonly coefficients: U8aFixed;
}

/** @name ComposableTraitsLendingMathDynamicPIDControllerModel */
export interface ComposableTraitsLendingMathDynamicPIDControllerModel extends Struct {
readonly proportionalParameter: i128;
readonly integralParameter: i128;
readonly derivativeParameter: i128;
readonly previousErrorValue: i128;
readonly previousIntegralTerm: i128;
readonly previousInterestRate: u128;
readonly targetUtilization: u128;
}

/** @name ComposableTraitslendingMathInterestRateModel */
export interface ComposableTraitslendingMathInterestRateModel extends Enum {
readonly isCurve: boolean;
readonly asCurve: ComposableTraitsLendingMathCurveModel;
readonly isJump: boolean;
readonly asJump: ComposableTraitsLendingMathJumpModel;
readonly isDynamicPIDController: boolean;
readonly asDynamicPIDController: ComposableTraitsLendingMathDynamicPIDControllerModel;
readonly isDoubleExponent: boolean;
readonly asDoubleExponent: ComposableTraitsLendingMathDoubleExponentModel;
readonly type: 'Curve' | 'Jump' | 'DynamicPIDController' | 'DoubleExponent';
}

/** @name ComposableTraitsLendingMathJumpModel */
export interface ComposableTraitsLendingMathJumpModel extends Struct {
readonly baseRate: u128;
readonly jumpRate: u128;
readonly fullRate: u128;
readonly targetUtilization: Percent;
}

/** @name ComposableTraitsLendingUpdateInput */
export interface ComposableTraitsLendingUpdateInput extends Struct {
readonly collateralFactor: u128;
readonly underCollaterizedWarnPercent: Percent;
readonly liquidators: Vec<u32>;
readonly interestRateModel: ComposableTraitslendingMathInterestRateModel;
}

/** @name ComposableTraitsTimeLinearDecrease */
export interface ComposableTraitsTimeLinearDecrease extends Struct {
readonly total: u64;
}

/** @name ComposableTraitsTimeStairstepExponentialDecrease */
export interface ComposableTraitsTimeStairstepExponentialDecrease extends Struct {
readonly step: u64;
readonly cut: Permill;
}

/** @name ComposableTraitsTimeTimeReleaseFunction */
export interface ComposableTraitsTimeTimeReleaseFunction extends Null {}
export interface ComposableTraitsTimeTimeReleaseFunction extends Enum {
readonly isLinearDecrease: boolean;
readonly asLinearDecrease: {
readonly type: ComposableTraitsTimeLinearDecrease;
} & Struct;
readonly isStairstepExponentialDecrease: boolean;
readonly asStairstepExponentialDecrease: ComposableTraitsTimeStairstepExponentialDecrease;
readonly type: 'LinearDecrease' | 'StairstepExponentialDecrease';
}

/** @name ComposableTraitsVaultVaultConfig */
export interface ComposableTraitsVaultVaultConfig extends Null {}
export interface ComposableTraitsVaultVaultConfig extends Struct {
readonly assetId: u128;
readonly reserved: Perquintill;
readonly manager: AccountId32;
readonly strategies: BTreeMap<AccountId32, Perquintill>;
}

/** @name ComposableTraitsVestingVestingSchedule */
export interface ComposableTraitsVestingVestingSchedule extends Null {}
Expand Down Expand Up @@ -165,7 +260,19 @@ export interface PalletIdentityRegistrarInfo extends Null {}
export interface PalletIdentityRegistration extends Null {}

/** @name PalletLiquidationsLiquidationStrategyConfiguration */
export interface PalletLiquidationsLiquidationStrategyConfiguration extends Null {}
export interface PalletLiquidationsLiquidationStrategyConfiguration extends Enum {
readonly isDutchAuction: boolean;
readonly asDutchAuction: ComposableTraitsTimeTimeReleaseFunction;
readonly isUniswapV2: boolean;
readonly asUniswapV2: {
readonly slippage: Perquintill;
} & Struct;
readonly isXcmDex: boolean;
readonly asXcmDex: {
readonly parachainId: u32;
} & Struct;
readonly type: 'DutchAuction' | 'UniswapV2' | 'XcmDex';
}

/** @name PalletMosaicAssetInfo */
export interface PalletMosaicAssetInfo extends Null {}
Expand Down
Loading

0 comments on commit 8e6e6ae

Please sign in to comment.