From aaf75e7285fed169d5b92a694bec571ea14cff40 Mon Sep 17 00:00:00 2001 From: samsiegart Date: Wed, 27 Nov 2024 11:17:39 -0800 Subject: [PATCH] feat(fast-usdc): publish feeConfig to vstorage --- .../boot/test/fast-usdc/fast-usdc.test.ts | 9 +++++++ .../fast-usdc/snapshots/fast-usdc.test.ts.md | 14 +++++++++++ .../snapshots/fast-usdc.test.ts.snap | Bin 806 -> 1010 bytes packages/fast-usdc/src/fast-usdc.contract.js | 22 ++++++++++++++---- 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/packages/boot/test/fast-usdc/fast-usdc.test.ts b/packages/boot/test/fast-usdc/fast-usdc.test.ts index c75205d5cb4..73d8b4e6baf 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -117,6 +117,15 @@ test.serial('writes feed policy to vstorage', async t => { await documentStorageSchema(t, storage, doc); }); +test.serial('writes fee config to vstorage', async t => { + const { storage } = t.context; + const doc = { + node: 'fastUsdc.feeConfig', + owner: 'the fee configuration for Fast USDC', + }; + await documentStorageSchema(t, storage, doc); +}); + test.serial('writes status updates to vstorage', async t => { const { walletFactoryDriver: wd, storage } = t.context; const wallet = await wd.provideSmartWallet( diff --git a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md index fb98a2008c2..08400eda5f5 100644 --- a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md +++ b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.md @@ -18,6 +18,20 @@ Generated by [AVA](https://avajs.dev). ], ] +## writes fee config to vstorage + +> Under "published", the "fastUsdc.feeConfig" node is delegated to the fee configuration for Fast USDC. +> The example below illustrates the schema of the data published there. +> +> See also board marshalling conventions (_to appear_). + + [ + [ + 'published.fastUsdc.feeConfig', + '{"blockHeight":"0","values":["{\\"body\\":\\"#{\\\\\\"contractRate\\\\\\":{\\\\\\"denominator\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0.Alleged: USDC brand\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+10\\\\\\"},\\\\\\"numerator\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+2\\\\\\"}},\\\\\\"flat\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+10000\\\\\\"},\\\\\\"maxVariable\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+5000000\\\\\\"},\\\\\\"variableRate\\\\\\":{\\\\\\"denominator\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+100\\\\\\"},\\\\\\"numerator\\\\\\":{\\\\\\"brand\\\\\\":\\\\\\"$0\\\\\\",\\\\\\"value\\\\\\":\\\\\\"+1\\\\\\"}}}\\",\\"slots\\":[\\"board01029\\"]}"]}', + ], + ] + ## writes status updates to vstorage > Under "published", the "fastUsdc.status" node is delegated to the statuses of fast USDC transfers identified by their tx hashes. diff --git a/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap b/packages/boot/test/fast-usdc/snapshots/fast-usdc.test.ts.snap index 9282a421d07b53e46e7250e0c04444c0fb5ddd81..2a1d52ca9c2583ea874af629b23823841ca7e292 100644 GIT binary patch literal 1010 zcmVSuC=?)+H0$anj{ERA)sk0 zp>9;o?tJSVWjtfej8jLE4~Rbj2M(0~!H?m@fj__jgl5)pLI@5?D-|DhJ+t5U=IzXT zZ+|Rvp^AO;?F+En3Yfk3TyqPClmLuOl;Fi7v5FiRt27+}HuDh2%#7ubPK<66JHx@O%E|X{0@0zzmXA@u#3#>Uyk z2EuQlTeyMV!A*p(-Nd&i(_C;<0c)4k*j>YlwqyRKC%&l0cv0TCkBdEGR09K4=kJ0SV4Ifq+QGfN(6nb--df;0tGL5 zQOk}y5i0F#KcU8w-JPvXFU$7Y;|d7O=y)Q4o7$HV@g!%M^30@ z$=6M3Xs@m901zsSBDtcPkulY#qC#*vB88F%ApIeb51&~@=wt#^KfBvLHp=Z2qY!^+ zqt!lX{PxOx^4+C<^6vRQ+4Q{sVUuCwLYw4@9eUxsf0SijwO*W$s0BA3_*n*0jk%;& z>66J^Q_1|$T|NlgLm^-UY)~KY@^Q;u{F=++kD}1s=KhhKjzO=6{x_J|qtq~^p!V_z zQ5c4&xQyxS3DunD0xpl0gyG-O4i->X*vu7tU&+oz_0G+GNEo54%b}-E4pg%+3gdnj z?48PrU;ay0)GAyN6(<&(Y9EX~7?z>%|Hy+oi##xv+NmMa39A=h`R)AuR3l4Nq`f4Gd)=rP#%Hq# z-(4L=Uwpi?{piW|R*Iyk7781)ROIgMJDC0Pnl$;Q#;t literal 806 zcmV+>1KIpRRzVU|_VzjtM! ztvK?p-(yfg{$8U)?0v#?J8*LeBoSx3__80UTdvSg+3x9-ja{LFTg=xpAwvDk9-;XWy+<=cHkU<&+WEao$WN9S*OHa#f?GTHgAnIv-?Th`f7C(J3n`~V$WBod4YQQ&!Lg% zC_BG;)}x_9%0BS|j2bJEDo-V9obiCNNmC=Ap+Uzr8t(fVg({U;$4)gNw64`Y z=04EFgUMbS%l_803Mnr6yw*qy)b=G+S}%NXyoqj8;YEdWPHoxFnxN8izs-`v{?^t3 zBIVj!T3GHRopa|auC+2VDy%t1(>?;d`yyD%>l(Rxaj$;{%AE};KJc*cbWzK7^GjLz z>p!e?BLK(%;NexgbXs1Xt_yDv5}J{;d%OjJ4*>8jxeT4_r2CWr{6YXeUJ!P#WNi8g z#@2`KM@x~%g~;M4EwYFwgB>vxX~ac5%;O9TA=5OAzNrt+=ny|G(_~3$P&a^lk} node + * @param {ERef} marshaller + * @param {FeeConfig} feeConfig + */ +const publishFeeConfig = async (node, marshaller, feeConfig) => { + const feeNode = E(node).makeChildNode(FEE_NODE); + const value = await E(marshaller).toCapData(feeConfig); + return E(feeNode).setValue(JSON.stringify(value)); +}; + /** * @param {ZCF} zcf * @param {OrchestrationPowers & { @@ -80,14 +93,13 @@ export const contract = async (zcf, privateArgs, zone, tools) => { assert('USDC' in terms.brands, 'no USDC brand'); assert('usdcDenom' in terms, 'no usdcDenom'); - const { feeConfig, marshaller } = privateArgs; + const { feeConfig, marshaller, storageNode } = privateArgs; const { makeRecorderKit } = prepareRecorderKitMakers( zone.mapStore('vstorage'), marshaller, ); - const makeStatusNode = () => - E(privateArgs.storageNode).makeChildNode(STATUS_NODE); + const makeStatusNode = () => E(storageNode).makeChildNode(STATUS_NODE); const statusManager = prepareStatusManager(zone, makeStatusNode); const { USDC } = terms.brands; @@ -209,6 +221,8 @@ export const contract = async (zcf, privateArgs, zone, tools) => { // So we use zone.exoClassKit above to define the liquidity pool kind // and pass the shareMint into the maker / init function. + void publishFeeConfig(storageNode, marshaller, feeConfig); + const shareMint = await provideSingleton( zone.mapStore('mint'), 'PoolShare',