forked from Agoric/dapp-treasury
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7 Local chain deployment refactored, commands for the borrow offer b…
…eing done via repl is added.
- Loading branch information
Anil Helvaci
committed
May 16, 2022
1 parent
61e54f8
commit 6118232
Showing
8 changed files
with
260 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// @ts-check | ||
import { Far } from '@endo/marshal'; | ||
import { AmountMath, AssetKind, makeIssuerKit } from '@agoric/ertp'; | ||
import { Nat } from '@agoric/nat'; | ||
import '@agoric/zoe/exported.js'; | ||
import { makeScalarMap } from '@agoric/store'; | ||
import { E } from '@agoric/eventual-send'; | ||
|
||
/** | ||
* This is a faucet that provides liquidity for the ertp asset created | ||
* using the parameter in terms. Just for demonstration purposes. | ||
*/ | ||
|
||
/** @type {ContractStartFn} */ | ||
export async function start(zcf) { | ||
|
||
const priceAuthorities = makeScalarMap('priceAuthorities'); | ||
/** @type {MapStore<string, InnerVault>} */ | ||
const supportedAssetPublicFacets = makeScalarMap('supportedAssetPublicFacets'); | ||
|
||
/** | ||
* @param {Brand} brandIn | ||
* @param {PriceAuthority} priceAuthority | ||
* @param {Brand} compareBrand | ||
*/ | ||
const addNewWrappedPriceAuthority = async (brandIn, priceAuthority, compareBrand) => { | ||
const displayInfo = await E(brandIn).getDisplayInfo(); | ||
const decimalPlaces = displayInfo?.decimalPlaces || 0n; | ||
console.log('[DISPLAY_INFO]', displayInfo); | ||
const notifier = E(priceAuthority).makeQuoteNotifier(AmountMath.make(brandIn, 10n ** Nat(decimalPlaces)), compareBrand); | ||
priceAuthorities.init(brandIn, harden({ priceAuthority, notifier })); | ||
console.log('[PRICE_AUTHS]', priceAuthorities.keys()); | ||
return notifier; | ||
} | ||
|
||
const addNewSupportedAssetPublicFacet = (key, value) => { | ||
supportedAssetPublicFacets.init(key, value); | ||
} | ||
|
||
const getPriceAuthority = (key) => { | ||
return priceAuthorities.get(key); | ||
} | ||
|
||
const getsupportedAssetPublicFacets = (key) => { | ||
return supportedAssetPublicFacets.get(key); | ||
} | ||
|
||
const publicFacet = Far('PriceManager', { | ||
addNewWrappedPriceAuthority, | ||
addNewSupportedAssetPublicFacet, | ||
getPriceAuthority, | ||
getsupportedAssetPublicFacets | ||
}) | ||
|
||
const creatorFacet = Far('faucetInvitationMaker', {}); | ||
|
||
return harden({ creatorFacet, publicFacet }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.