Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fe0b633

Browse files
committedNov 18, 2024·
fixup! feat: liquidity pool borrower and repayer facets
1 parent d91c88a commit fe0b633

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed
 

‎packages/fast-usdc/src/exos/liquidity-pool.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,14 @@ export const prepareLiquidityPoolKit = (zone, { zcf, usdc, tools }) => {
150150
},
151151
/**
152152
* @param {ZCFSeat} assetManagerSeat
153-
* @param {{ USDC: Amount<'nat'>}} amounts
153+
* @param {{ USDC: Amount<'nat'>}} amountKWR
154154
*/
155-
borrow(assetManagerSeat, amounts) {
155+
borrow(assetManagerSeat, amountKWR) {
156156
const { outstandingLends, poolSeat, poolStats } = this.state;
157157
const available = poolSeat.getAmountAllocated('USDC', usdc.brand);
158158
// Validate amount is available in pool
159159
const post = borrowCalc(
160-
amounts.USDC,
160+
amountKWR.USDC,
161161
available,
162162
outstandingLends,
163163
poolStats,
@@ -166,7 +166,7 @@ export const prepareLiquidityPoolKit = (zone, { zcf, usdc, tools }) => {
166166
// COMMIT POINT
167167
try {
168168
zcf.atomicRearrange(
169-
harden([[poolSeat, assetManagerSeat, amounts]]),
169+
harden([[poolSeat, assetManagerSeat, amountKWR]]),
170170
);
171171
} catch (cause) {
172172
const reason = Error('🚨 cannot commit borrow', { cause });
@@ -177,7 +177,7 @@ export const prepareLiquidityPoolKit = (zone, { zcf, usdc, tools }) => {
177177
Object.assign(this.state, post);
178178
this.facets.external.publishPoolMetrics();
179179
},
180-
// TODO repay failed `LOA.deposit()`
180+
// TODO method to repay failed `LOA.deposit()`
181181
},
182182
repayer: {
183183
/**

‎packages/fast-usdc/src/pool-share-math.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const { getValue, add, isEmpty, isGTE, subtract } = AmountMath;
1111

1212
/**
1313
* @import {PoolStats} from './types';
14+
* @import {RepayAmountKWR} from './exos/liquidity-pool';
1415
*/
1516

1617
/**
@@ -152,7 +153,7 @@ export const borrowCalc = (
152153

153154
/**
154155
* @param {ShareWorth} shareWorth
155-
* @param {{ Principal: Amount<'nat'>; PoolFee: Amount<'nat'>; ContractFee: Amount<'nat'> }} amounts
156+
* @param {RepayAmountKWR} amounts
156157
* @param {Amount<'nat'>} outstandingLends
157158
* @param {PoolStats} poolStats
158159
*/

‎packages/fast-usdc/test/fast-usdc.contract.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { MockCctpTxEvidences } from './fixtures.js';
1515
import { commonSetup } from './supports.js';
1616
import { makeFeeTools } from '../src/utils/fees.js';
1717
import { makeTestFeeConfig } from './mocks.js';
18+
import type { RepayPaymentKWR } from '../src/exos/liquidity-pool.js';
1819

1920
const dirname = path.dirname(new URL(import.meta.url).pathname);
2021

@@ -238,8 +239,7 @@ test('LP deposits, earns fees, withdraws', async t => {
238239
}
239240
const remaining = await E(creatorFacet).testRepay(
240241
splits,
241-
// @ts-expect-error TODO narrow PaymentKWR keys
242-
repayPayments,
242+
repayPayments as RepayPaymentKWR,
243243
);
244244
for (const r of Object.values(remaining)) {
245245
t.is(r.value, 0n, 'testRepay consumes all payments');

0 commit comments

Comments
 (0)
Please sign in to comment.