From f66de078859eed4d227195c44aa937dfed5df9da Mon Sep 17 00:00:00 2001 From: Ikenna Omekam Date: Mon, 16 Dec 2024 11:43:44 -0500 Subject: [PATCH] fix(reserve): add missing collaterel proposal --- .../addCollateral/add-collateral-permit.json | 7 +++ .../addCollateral/add-collateral.js | 45 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral-permit.json create mode 100644 a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral.js diff --git a/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral-permit.json b/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral-permit.json new file mode 100644 index 00000000000..e65238594ea --- /dev/null +++ b/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral-permit.json @@ -0,0 +1,7 @@ +{ + "consume": { + "reserveKit": true, + "namesByAddressAdmin": true, + "agoricNames": true + } +} diff --git a/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral.js b/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral.js new file mode 100644 index 00000000000..e485d3caae3 --- /dev/null +++ b/a3p-integration/proposals/p:upgrade-19/addCollateral/add-collateral.js @@ -0,0 +1,45 @@ +// @ts-nocheck +/* eslint-disable no-undef */ +const PROVISIONING_POOL_ADDR = 'agoric1megzytg65cyrgzs6fvzxgrcqvwwl7ugpt62346'; + +const addCollateral = async powers => { + const { + consume: { + reserveKit: reserveKitP, + namesByAddressAdmin: namesByAddressAdminP, + agoricNames, + }, + } = powers; + + const namesByAddressAdmin = await namesByAddressAdminP; + + const getDepositFacet = async address => { + const hub = E(E(namesByAddressAdmin).lookupAdmin(address)).readonly(); + return E(hub).lookup('depositFacet'); + }; + + const [reserveKit] = await Promise.all([reserveKitP]); + + const { adminFacet, instance } = reserveKit; + + let usdLemonsMint; + for (const { publicFacet, creatorFacet: mint } of contractKits.values()) { + if (publicFacet === usdLemonsIssuer) { + usdLemonsMint = mint; + console.log('BINGO', mint); + break; + } + } + + console.log('Minting USD_LEMONS'); + const helloPayment = await E(usdLemonsMint).mintPayment( + harden({ brand: usdLemonsBrand, value: 500000n }), + ); + + console.log('Funding provision pool...'); + await E(ppDepositFacet).receive(helloPayment); + + console.log('Done.'); +}; + +addCollateral;