-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cosmoverse Workshop #34
Comments
Code Sample For The ArticleThe method below belongs to a module that we rely on to let us know when the loan with the highest
/**
* @template T
* @param {CheckLiquidationOptions<T>} options
* @return {Generator<{state: string}, {state: string}, *>}
*/
function* checkLiquidation({ colQuote, debtQuote, liqPromiseKit, loan }) {
let colLatestQuote = colQuote;
let debtLatestQuote = debtQuote;
let state = "initial"
const { brand: collateralUnderlyingBrand } = getAmountIn(colLatestQuote);
let updates = {};
while (true) {
updates = yield {state};
colLatestQuote = updates.colQuote && updates.colQuote !== undefined ? updates.colQuote : colLatestQuote;
debtLatestQuote = updates.debtQuote && updates.debtQuote !== undefined ? updates.debtQuote : debtLatestQuote;
tracer('Quotes & Updates', {
colQuoteOut: getAmountOut(colLatestQuote),
debtQuoteOut: getAmountOut(debtLatestQuote),
updates
});
const collateral = loan.getCollateralAmount();
const debt = loan.getCurrentDebt();
const colValInCompare = getValInCompareCurrency(collateral, colLatestQuote,
collateralUnderlyingBrand, collateralUnderlyingDecimals, getExchangeRateForPool(collateralUnderlyingBrand));
const debtValInCompare = getValInCompareCurrency(debt, debtLatestQuote,
debt.brand, debtDecimals, undefined);
const colToDebtRatio = makeRatioFromAmounts(colValInCompare, debtValInCompare);
if (ratioGTE(liquidationMargin, colToDebtRatio)) {
liqPromiseKit.resolve({colLatestQuote, debtLatestQuote, loan});
return { state: 'Liquidating' };
}
state = 'Active';
}
} The method
liqPromiseKitA
We use a promiseKit here because we want the consumer of this |
One of the most critical components of a financial system is lending and borrowing. De-Fi has a lot of innovation to bring to the table when it comes to lending and borrowing. Together we will explore how we can use agoric-sdk to empower these innovations and solve the complicated challenges that come with building a financial system.
The text was updated successfully, but these errors were encountered: