Skip to content

Commit

Permalink
chore(fast-usdc): proposal shapes for deposit, withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 5, 2024
1 parent ddfdf20 commit 54d97c7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/fast-usdc/src/type-guards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { M } from '@endo/patterns';

/**
* @param {Brand} brand must be a 'nat' brand, not checked
* @param {NatValue} [min]
*/
export const makeNatAmountShape = (brand, min) =>
harden({ brand, value: min ? M.gte(min) : M.nat() });

/** @param {Record<'PoolShares' | 'USDC', Brand<'nat'>>} brands */
export const makeProposalShapes = ({ PoolShares, USDC }) =>
harden({
deposit: M.splitRecord(
{ give: { ToPool: makeNatAmountShape(USDC, 1n) } },
{ want: { Shares: makeNatAmountShape(PoolShares) } },
),
withdraw: M.splitRecord({
give: { Shares: makeNatAmountShape(PoolShares, 1n) },
want: { FromPool: makeNatAmountShape(USDC, 1n) },
}),
});

0 comments on commit 54d97c7

Please sign in to comment.