@gvnrdao/dh-lit-actions 0.0.328 → 0.0.330
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a_dev_address-probe-signer.meta.json +1 -1
- package/dist/a_dev_address-probe.meta.json +1 -1
- package/dist/a_dev_always-signer.meta.json +1 -1
- package/dist/a_dev_authorization-dummy-b.meta.json +1 -1
- package/dist/a_dev_authorization-dummy.meta.json +1 -1
- package/dist/a_dev_ethers-version-probe.meta.json +1 -1
- package/dist/a_dev_process-payment-sign-only.meta.json +1 -1
- package/dist/agent-module-executor.meta.json +1 -1
- package/dist/backing-attestation.action.js +1 -0
- package/dist/backing-attestation.hash +1 -0
- package/dist/backing-attestation.meta.json +9 -0
- package/dist/btc-address-balance.meta.json +1 -1
- package/dist/btc-provider-probe.meta.json +1 -1
- package/dist/btc-transaction-signer.meta.json +1 -1
- package/dist/btc-utxo-invalidator.meta.json +1 -1
- package/dist/btc-withdrawal.meta.json +1 -1
- package/dist/carry-collateral-attestation.meta.json +1 -1
- package/dist/carry-funding-attestation.meta.json +1 -1
- package/dist/encrypt-parameter.meta.json +1 -1
- package/dist/extend-position-validator.meta.json +1 -1
- package/dist/liquidation-validator.meta.json +1 -1
- package/dist/loan-vault-btc-balance.meta.json +1 -1
- package/dist/pkp-validator.meta.json +1 -1
- package/dist/price-oracle.meta.json +1 -1
- package/dist/process-payment-validator.meta.json +1 -1
- package/dist/stale-spend-recovery-validator.meta.json +1 -1
- package/dist/ucd-mint-validator.meta.json +1 -1
- package/package.json +1 -1
- package/pkg-dist/pkg-src/constants/chunks/lit-actions-registry.d.ts.map +1 -1
- package/pkg-dist/pkg-src/index.js +15 -2
- package/pkg-dist/pkg-src/index.js.map +3 -3
- package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts +2 -0
- package/pkg-dist/pkg-src/interfaces/chunks/diamond-hands-lit-actions.i.d.ts.map +1 -1
- package/pkg-dist/src/constants/chunks/backing.d.ts +40 -0
- package/pkg-dist/src/constants/chunks/backing.d.ts.map +1 -0
- package/pkg-dist/src/modules/backing-attestation.module.d.ts +86 -0
- package/pkg-dist/src/modules/backing-attestation.module.d.ts.map +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var _LIT_ACTION_=(()=>{var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.prototype.hasOwnProperty,i={};((e,r)=>{for(var n in r)t(e,n,{get:r[n],enumerable:!0})})(i,{main:()=>main});var o=60,a=16,s={1:{PositionManager:"0x12A1836e56139ccaD8722B89519d84233efc224B",LoanOperationsManagerModule:"0x2561974A40F1AEed1251d0A090A83cF8536FB9E9",BTCSpendAuthorizer:"0xfBbF108486fa07F1B06a811C5b66ed68DD9c508a",BitcoinProviderRegistry:"0x4ab3Fb96e02893Ed6FAa61bad1918390c8DbbFFC",LITActionValidator:"0xD2c5d59c2CC5c409AC65ce0A817236aeC6869512",PositionDelegateRegistry:"0xf0aa2678aD4F60f49e8F7725089B5E86B7F8FE4C",TermManagerModule:"0xDB99CdF883ffa38acD099bC39F8d1f4508c9239E",UCDController:"0x4b4f8063048bCD59D469219E3f07C6aaDF4f6157",LiquidationManagerModule:"0x74B28695352E7bf736D6c9F76ccb7B4439477De9"},11155111:{PositionManager:"0x68e0507D982AEBF1D1C1Af8FBbd842327e2deeFF",LoanOperationsManagerModule:"0x3e05e760a87715207b7F4e8fD35EF7559BcA72C0",BTCSpendAuthorizer:"0xd7E9Eb5eE53f1d9ee55Dc162bBC7486bE437B6bD",BitcoinProviderRegistry:"0xbfA0c48B070D0a9A9CD27469AeacFD2d4261cEE2",LITActionValidator:"0x54eECd7C90F8A8fac27749Ba30BbE8AFBAccc856",PositionDelegateRegistry:"0x482369De283622E7b05731875ec137d4E3D208F9",TermManagerModule:"0x94Adc6F9558368B1482197584f1fc7133Ecf835b",UCDController:"0x360Bde4e489ee94E26601B206932De09EE60FF04",LiquidationManagerModule:"0xC4AB00f39e7ceD812F5C67058C9fa44e15d40e76"}};var c="DiamondHands.Protocol",d="1",l=(t=>(t.SEPOLIA="sepolia",t.ETHEREUM="ethereum",t.HARDHAT="hardhat",t))(l||{}),u={sepolia:"regtest",ethereum:"mainnet",hardhat:"regtest"},h=["infura.io","drpc.org","drpc.live"],g={ethereum:1,sepolia:11155111,hardhat:1337};var p={Backing:[{name:"btcSats",type:"uint256"},{name:"btcPriceE8",type:"uint256"},{name:"ucdDebt",type:"uint256"},{name:"ratioBps",type:"uint256"},{name:"asOf",type:"uint256"},{name:"ethBlock",type:"uint256"},{name:"btcBlockHash",type:"bytes32"},{name:"vaultsRoot",type:"bytes32"},{name:"vaultCount",type:"uint256"}]},f=50,w=100,b=3,m=5,y=21n*10n**14n,v=10n**16n,k={11155111:{oracle:"0x003b97EF135e414198bCc4D2c50AC6B1BFb602C0",signer:"0x38a1ddb3a4463E621bd97242f91e04f41DD94611"}};function E(){const t=Math.floor(Date.now()/1e3);return e=t,Math.floor(e/o)*o;var e}async function A(){const t=Math.floor(Date.now()/1e3),e=t%o;if(!function(t){const e=(t??Math.floor(Date.now()/1e3))%o;return e<8||e>=o-8}(t))return;const r=a/2;let n;n=e>=o-r?o-e+r:r-e,console.log(`[Quantum] Waiting ${n}s for safe moment (current time in quantum: ${e}s)`),await new Promise((t=>setTimeout(t,1e3*n))),console.log(`[Quantum] Safe quantum ready: ${E()}`)}var B={hardhat:{chain:"hardhat",chainId:g.hardhat,bitcoinNetwork:u.hardhat,allowArbitraryBitcoinProvider:!0,allowArbitraryEvmRpc:!0,pinContractAddresses:!1,allowDevSinglePriceProvider:!0,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:1},sepolia:{chain:"sepolia",chainId:g.sepolia,bitcoinNetwork:u.sepolia,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:1,minBitcoinSpendConfirmations:1,minConsensusProviders:2},ethereum:{chain:"ethereum",chainId:g.ethereum,bitcoinNetwork:u.ethereum,allowArbitraryBitcoinProvider:!1,allowArbitraryEvmRpc:!1,pinContractAddresses:!0,allowDevSinglePriceProvider:!1,minBitcoinBalanceConfirmations:6,minBitcoinSpendConfirmations:6,minConsensusProviders:2}};function C(t){const e=function(t){const e=t.toLowerCase().trim();if("sepolia"===e)return"sepolia";if("ethereum"===e||"mainnet"===e)return"ethereum";if("hardhat"===e)return"hardhat";throw new Error(`Unsupported EVM chain: "${t}". Supported chains: ${Object.values(l).join(", ")}`)}(t),r=B[e];if(!r)throw new Error(`No chain policy registered for "${t}"`);return r}var $=["drpc.org","drpc.live"],I="Drpc-Key",P=/^[A-Za-z0-9_-]{16,128}$/;function D(t){return $.some((e=>t===e||t.endsWith(`.${e}`)))}function S(t,e){if("string"!=typeof t||!P.test(t))throw new Error(`Invalid ${e}: expected 16-128 characters of [A-Za-z0-9_-]`)}function T(t){if("https:"!==t.protocol)throw new Error(`A dRPC key is only sent over https, but the RPC URL scheme is "${t.protocol}"`)}function R(t,e){if(void 0===e)return;S(e,'"drpcKey"');const r=new URL(t);if(!D(r.hostname))throw new Error(`"drpcKey" is only sent to dRPC, but the RPC host is "${r.hostname}" (expected ${$.join(" or ")})`);if(T(r),r.searchParams.has("dkey"))throw new Error('"drpcKey" and a keyed rpcUrl (?dkey=) are mutually exclusive \u2014 send one');return e}var M=["PositionManager","LoanOperationsManagerModule","BTCSpendAuthorizer","BitcoinProviderRegistry","LITActionValidator","PositionDelegateRegistry","TermManagerModule","UCDController","LiquidationManagerModule"];function x(t,e){const r={...e??{}};if(!t.pinContractAddresses)return r;const n=(i=t.chainId,s[i]??null);var i;if(!n)throw new Error(`No pinned contract-address set for chainId ${t.chainId} (${t.chain}); refusing to trust caller-supplied addresses on an enforced chain`);for(const e of M){const i=n[e];if(!i)throw new Error(`Pinned address set for ${t.chain} is missing required "${e}"; refusing to fall through to a caller-supplied value`);const o=r[e];if("string"==typeof o&&o.length>0&&o.toLowerCase()!==i.toLowerCase())throw new Error(`Caller-supplied "${e}" (${o}) contradicts the pinned ${t.chain} address (${i}); refusing to sign`);r[e]=i}return r}async function F(t,e){const r=e.rpcUrl,n=e.rpcSource??"params-or-lit-node";let i;if("string"==typeof r&&r.length>0)!function(t,e){if(t.allowArbitraryEvmRpc)return;if(!e||"string"!=typeof e)throw new Error("validateEvmRpcForPolicy: rpcUrl must be a non-empty string");let r;try{r=new URL(e).hostname}catch(t){throw new Error(`Invalid rpcUrl: ${t?.message??String(t)}`)}if(!h.some((t=>r===t||r.endsWith(`.${t}`))))throw new Error(`Custom RPC domain "${r}" is not in the approved list: ${h.join(", ")}`)}(t,r),i=r;else{if("params-only"===n)throw new Error('Missing required parameter "rpcUrl" \u2014 this action cannot resolve an RPC endpoint itself (Chipotle has no Lit.Actions.getRpcUrl)');if(i=await async function(t,e){if(void 0!==e)throw new Error('"drpcKey" was supplied without an "rpcUrl" \u2014 the key only authenticates a caller-supplied dRPC rpcUrl, never the Lit node\'s own endpoint');return Lit.Actions.getRpcUrl({chain:t})}(e.chain,e.drpcKey),"string"!=typeof i||0===i.length)throw new Error(`Lit.Actions.getRpcUrl returned no endpoint for chain "${e.chain}"`)}return{rpcUrl:i,drpcKey:R(i,e.drpcKey),addresses:x(t,e.contractAddresses)}}var L={BalanceConfirmation:[{name:"actionTag",type:"bytes32"},{name:"positionId",type:"bytes32"},{name:"collateralValue",type:"uint256"},{name:"btcPrice",type:"uint256"},{name:"quantumTimestamp",type:"uint256"},{name:"borrower",type:"address"}]},O="updateBalance(bytes32,uint256,uint256,uint256,bytes)",U=180;function N(t){const e=t.confirmation;if(!e||"string"!=typeof e.signature||!/^0x[0-9a-fA-F]{130}$/.test(e.signature))throw new Error("[carry] balanceConfirmation.signature is missing or malformed");if(!/^\d+$/.test(String(e.vaultBalance))||!/^\d+$/.test(String(e.btcPrice))||!/^\d+$/.test(String(e.quantumTimestamp)))throw new Error("[carry] balanceConfirmation fields must be unsigned integers");const r=Number(e.quantumTimestamp);if(r>t.nowSeconds+60||t.nowSeconds-r>U)throw new Error(`[carry] balanceConfirmation at ${r} is outside the window at ${t.nowSeconds}`);const n={actionTag:ethers.utils.keccak256(ethers.utils.toUtf8Bytes("balance-confirmation")),positionId:t.positionId,collateralValue:String(e.vaultBalance),btcPrice:String(e.btcPrice),quantumTimestamp:String(e.quantumTimestamp),borrower:ethers.utils.getAddress(t.borrower)},i=ethers.utils._TypedDataEncoder.hash(t.domain,L,n),o=ethers.utils.recoverAddress(i,e.signature);if(o!==ethers.utils.getAddress(t.validator))throw new Error(`[carry] balanceConfirmation signed by ${o}, not the updateBalance validator ${t.validator}`);return BigInt(e.vaultBalance)}var _=/^0x[0-9a-fA-F]{64}$/,H=/^\d+$/;function j(t){let e=t;for(let t=0;e&&t<4;t++){const t="string"==typeof e.code?e.code:"",r="string"==typeof e.reason?e.reason:"",n="string"==typeof e.message?e.message:"";if("CALL_EXCEPTION"===t&&"string"==typeof e.data&&"0x"!==e.data)return!1;if("SERVER_ERROR"===t||"NETWORK_ERROR"===t||"TIMEOUT"===t)return!0;if(/missing response|bad response|failed to fetch|fetch failed|socket hang up|ECONNRESET|ETIMEDOUT|ECONNREFUSED/i.test(r+" "+n))return!0;if("number"==typeof e.status&&e.status>=500)return!0;e=e.error??e.cause}return!1}var z=[500,1e3];var V,q=(t,e)=>async function(t,e,r=()=>{},n=z,i=t=>new Promise((e=>setTimeout(e,t)))){for(let o=0;;o++)try{return await e()}catch(e){if(!j(e)||o>=n.length)throw e;r("rpc-retry",{label:t,attempt:o+1,delayMs:n[o],reason:String(e?.reason??e?.message??e).slice(0,160)}),await i(n[o])}}(t,e,((t,e)=>console.log(JSON.stringify({component:"backing-attestation",event:t,...e})))),K=["function views() view returns (address)","function core() view returns (address)","function authorizationRegistry() view returns (address)"],W=["function getBackingVaults(uint256 offset, uint256 limit) view returns (tuple(bytes32 positionId, string vaultAddress, uint256 ucdDebt, uint8 status)[] vaults, uint256 nextOffset, uint256 total)"],Z=["function getPositionDetails(bytes32 positionId) view returns (tuple(bytes32 positionId, bytes32 pkpId, uint256 ucdDebt, string vaultAddress, address borrower, uint40 createdAt, uint40 lastUpdated, uint16 selectedTerm, uint40 expiryAt, uint8 status, uint40 previousExpiryAt, uint16 totalTerm, uint40 lastRenewedAt) position)"],J=["function getValidator(bytes4) view returns (tuple(address pkpAddress, uint256 version, bool active))"],Q=["function getAuthorizedSpends(bytes32 positionId) view returns (tuple(string txid, uint32 vout, uint256 satoshis, string targetAddress, uint256 targetAmount, uint256 authorizedAt)[])"],X=["function btcUsdPriceFeed() view returns (address)","function maxBtcFeedAgeBorrow() view returns (uint32)"],G=["function latestRoundData() view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)"];async function main(t){if(!t||"object"!=typeof t)throw new Error("[backing] missing args");for(const e of["chain","backingOracle","validatorWalletAddress","rpcUrl"])if("string"!=typeof t[e]||0===t[e].length)throw new Error(`[backing] missing "${e}"`);const e=function(t){if(!t||"object"!=typeof t)throw new Error('[backing] missing "snapshot"');const e=t;if(!Number.isInteger(e.ethBlock)||e.ethBlock<=0)throw new Error("[backing] snapshot.ethBlock must be a positive integer");if(!Number.isInteger(e.btcBlockHeight)||e.btcBlockHeight<=0)throw new Error("[backing] snapshot.btcBlockHeight must be a positive integer");if("string"!=typeof e.btcBlockHash||!_.test(e.btcBlockHash)||/^0x0{64}$/.test(e.btcBlockHash))throw new Error("[backing] snapshot.btcBlockHash must be a non-zero 32-byte hex hash");if(!Array.isArray(e.leaves))throw new Error("[backing] snapshot.leaves must be an array");const r=e.leaves.map(((t,e)=>{if(!t||"object"!=typeof t)throw new Error(`[backing] snapshot.leaves[${e}] is not an object`);const r=t;if("string"!=typeof r.positionId||!_.test(r.positionId))throw new Error(`[backing] snapshot.leaves[${e}].positionId is not bytes32`);if("string"!=typeof r.vaultAddress||0===r.vaultAddress.length)throw new Error(`[backing] snapshot.leaves[${e}].vaultAddress is empty`);if("string"!=typeof r.sats||!H.test(r.sats))throw new Error(`[backing] snapshot.leaves[${e}].sats must be an unsigned integer string`);return{positionId:r.positionId.toLowerCase(),vaultAddress:r.vaultAddress,sats:BigInt(r.sats)}}));return{ethBlock:e.ethBlock,btcBlockHash:e.btcBlockHash.toLowerCase(),btcBlockHeight:e.btcBlockHeight,leaves:r}}(t.snapshot),r=function(t){if(!Array.isArray(t))throw new Error('[backing] missing "samples" (an array)');return t.map(((t,e)=>{if(!t||"object"!=typeof t)throw new Error(`[backing] samples[${e}] is not an object`);const r=t;if("string"!=typeof r.positionId||!_.test(r.positionId))throw new Error(`[backing] samples[${e}].positionId is not bytes32`);if(!r.confirmation||"object"!=typeof r.confirmation)throw new Error(`[backing] samples[${e}].confirmation is missing`);return{positionId:r.positionId.toLowerCase(),confirmation:r.confirmation}}))}(t.samples),n=C(t.chain),i=function(t,e,r,n,i,o){const a=ethers.utils.getAddress(e),s=ethers.utils.getAddress(r);if(t.pinContractAddresses){if(!n)throw new Error(`[backing] no pinned backing pairing for ${t.chain} (${t.chainId}) \u2014 the oracle is not deployed/pinned there; refusing to sign`);if(a!==ethers.utils.getAddress(n.oracle))throw new Error(`[backing] requested oracle ${a} is not the pinned oracle ${n.oracle} for ${t.chain}; refusing to sign`);if(s!==ethers.utils.getAddress(n.signer))throw new Error(`[backing] signer ${s} is not the pinned backing signer ${n.signer}; refusing to sign`)}return{name:i,version:o,chainId:t.chainId,verifyingContract:a}}(n,t.backingOracle,t.validatorWalletAddress,(o=n.chainId,k[o]??null),c,d);var o;const{rpcUrl:a,drpcKey:s,addresses:l}=await F(n,{chain:t.chain,rpcUrl:t.rpcUrl,drpcKey:t.drpcKey,contractAddresses:t.contractAddresses,rpcSource:"params-only"});for(const t of["PositionManager","LoanOperationsManagerModule","BTCSpendAuthorizer"])if(!l[t])throw new Error(`[backing] contractAddresses.${t} is required`);const u=new ethers.providers.JsonRpcProvider(function(t,e,r){const n={url:t},i=R(t,e);if(void 0!==i)n.headers={[I]:i};else{const e=new URL(t),r=e.searchParams.getAll("dkey");if(r.length>1)throw new Error(`rpcUrl carries ${r.length} "dkey" parameters \u2014 send exactly one dRPC key`);if(1===r.length&&!D(e.hostname))throw new Error(`rpcUrl carries a dRPC key (?dkey=) but the RPC host is "${e.hostname}" \u2014 a dRPC key is only sent to ${$.join(" or ")}`);if(1===r.length){const t=r[0];S(t,"dRPC key in rpcUrl (?dkey=)"),T(e),e.searchParams.delete("dkey"),n.url=e.toString(),n.headers={[I]:t}}}return void 0!==r&&(n.timeout=r),n}(a,s)),h=await q("getBlockNumber",(()=>u.getBlockNumber())),g=e.ethBlock;if(g>h)throw new Error(`[backing] snapshot.ethBlock ${g} is ahead of this node's latest ${h}`);if(h-g>w)throw new Error(`[backing] snapshot.ethBlock ${g} is ${h-g} blocks behind latest ${h} (max ${w})`);const B=await q(`getBlock(${g})`,(()=>u.getBlock(g)));if(!B||!Number.isInteger(B.timestamp)||B.timestamp<=0)throw new Error(`[backing] no block ${g}`);const P=BigInt(B.timestamp),M=new ethers.Contract(l.PositionManager,K,u),x=new ethers.Contract(await q("PositionManager.views",(()=>M.views({blockTag:g}))),W,u),L=await async function(t,e){const r=[];let n=0;for(let i=0;i<1e4;i++){const i=await q(`getBackingVaults(${n})`,(()=>t.getBackingVaults(n,f,{blockTag:e})));for(const t of i.vaults)r.push({positionId:String(t.positionId).toLowerCase(),vaultAddress:String(t.vaultAddress),ucdDebt:BigInt(t.ucdDebt.toString()),status:Number(t.status)});const o=Number(i.nextOffset.toString());if(o>=Number(i.total.toString()))return r;if(o<=n)throw new Error(`[backing] getBackingVaults did not advance at offset ${n}`);n=o}throw new Error("[backing] getBackingVaults did not finish within 10,000 pages")}(x,g);!function(t,e){if(t.length!==e.length)throw new Error(`[backing] snapshot has ${e.length} leaves but the chain's backing set has ${t.length} entries at this block`);for(let r=0;r<t.length;r++){const n=t[r],i=e[r];if(n.positionId.toLowerCase()!==i.positionId)throw new Error(`[backing] leaf ${r}: positionId ${i.positionId} is not the chain's ${n.positionId}`);if(n.vaultAddress!==i.vaultAddress)throw new Error(`[backing] leaf ${r} (${n.positionId}): vault ${i.vaultAddress} is not the chain's ${n.vaultAddress}`)}}(L,e.leaves);let U=0n,j=0n;const z=[];for(let t=0;t<L.length;t++)U+=e.leaves[t].sats,j+=L[t].ucdDebt,z.push((V=L[t].positionId,Y=L[t].vaultAddress,tt=e.leaves[t].sats,ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode(["bytes32","string","uint256"],[V,Y,tt.toString()]))));var V,Y,tt;const et=function(t){if(0===t.length)return ethers.constants.HashZero;let e=t.map((t=>t.toLowerCase()));for(;e.length>1;){const t=[];for(let r=0;r<e.length;r+=2)if(r+1===e.length)t.push(e[r]);else{const[n,i]=e[r]<e[r+1]?[e[r],e[r+1]]:[e[r+1],e[r]];t.push(ethers.utils.keccak256(ethers.utils.concat([n,i])))}e=t}return e[0]}(z),rt=function(t,e){const r=t.length;if(0===r)return[];const n=new Set,i=t.map(((t,e)=>({i:e,d:t.ucdDebt}))).sort(((t,e)=>t.d===e.d?t.i-e.i:t.d>e.d?-1:1));for(let t=0;t<Math.min(b,r);t++)n.add(i[t].i);for(let t=0;t<m;t++){const i=ethers.utils.keccak256(ethers.utils.solidityPack(["bytes32","uint8"],[e,t]));n.add(Number(BigInt(i)%BigInt(r)))}return[...n].sort(((t,e)=>t-e))}(L,e.btcBlockHash),nt=new Map(r.map((t=>[t.positionId,t])));if(r.length!==rt.length)throw new Error(`[backing] ${r.length} samples supplied; the sample set at this block has ${rt.length}`);if(rt.length>0){const t=new ethers.Contract(await q("PositionManager.authorizationRegistry",(()=>M.authorizationRegistry({blockTag:g}))),J,u),r=await q("OAR.getValidator(updateBalance)",(()=>t.getValidator(ethers.utils.id(O).slice(0,10),{blockTag:g})));if(!r.active)throw new Error("[backing] the updateBalance validator is not active");const i=new ethers.Contract(await q("PositionManager.core",(()=>M.core({blockTag:g}))),Z,u),o=new ethers.Contract(l.BTCSpendAuthorizer,Q,u);await A();const a=E(),s={name:c,version:d,chainId:n.chainId,verifyingContract:ethers.utils.getAddress(l.LoanOperationsManagerModule)};for(const t of rt){const n=L[t],c=nt.get(n.positionId);if(!c)throw new Error(`[backing] no sample for sampled position ${n.positionId} (index ${t})`);const d=await q(`core.getPositionDetails(${n.positionId.slice(0,10)})`,(()=>i.getPositionDetails(n.positionId,{blockTag:g}))),l=N({confirmation:c.confirmation,positionId:n.positionId,borrower:ethers.utils.getAddress(d.borrower),validator:r.pkpAddress,domain:s,nowSeconds:a}),u=e.leaves[t].sats,h=await q(`BTCSpendAuthorizer.getAuthorizedSpends(${n.positionId.slice(0,10)})`,(()=>o.getAuthorizedSpends(n.positionId,{blockTag:g})));if(0===h.length){if(l!==u)throw new Error(`[backing] sample ${n.positionId}: the loans' signed balance is ${l} sats but the leaf says ${u}; refusing to sign`)}else if(l<u)throw new Error(`[backing] sample ${n.positionId}: ${h.length} authorised spend(s) in flight; the loans' signed balance ${l} sats is below the leaf ${u} (a lagging leaf may only understate); refusing to sign`)}}const it=new ethers.Contract(l.LoanOperationsManagerModule,X,u),ot=new ethers.Contract(await q("LOM.btcUsdPriceFeed",(()=>it.btcUsdPriceFeed({blockTag:g}))),G,u),at=await q("feed.latestRoundData",(()=>ot.latestRoundData({blockTag:g}))),st=BigInt(at.answer.toString()),ct=BigInt(at.updatedAt.toString()),dt=await q("LOM.maxBtcFeedAgeBorrow",(()=>it.maxBtcFeedAgeBorrow({blockTag:g}))),lt=BigInt(dt.toString());if(ct>P)throw new Error(`[backing] price feed updatedAt ${ct} is after block ${g} (${P})`);if(P-ct>lt)throw new Error(`[backing] price feed is ${P-ct}s old at block ${g}; the protocol allows ${lt}s`);!function(t,e){if(t>y)throw new Error(`[backing] btcSats ${t} exceeds 21,000,000 BTC`);if(e<=0n)throw new Error("[backing] btcPriceE8 must be positive");if(e>v)throw new Error(`[backing] btcPriceE8 ${e} exceeds the $100,000,000 ceiling`)}(U,st);const ut=function(t,e,r){if(0n===r)throw new Error("[backing] ucdDebt is zero; the oracle refuses a report over no debt");return t*e*1000000n/r}(U,st,j),ht={btcSats:U.toString(),btcPriceE8:st.toString(),ucdDebt:j.toString(),ratioBps:ut.toString(),asOf:P.toString(),ethBlock:String(g),btcBlockHash:e.btcBlockHash,vaultsRoot:et,vaultCount:String(L.length)},{signature:gt,signer:pt}=await async function(t,e,r,n){const i=await Lit.Actions.getPrivateKey({pkpId:t}),o="string"==typeof i?i.startsWith("0x")?i:`0x${i}`:String(i),a=new ethers.Wallet(o);if(a.address!==ethers.utils.getAddress(t))throw new Error(`[carry] key for ${t} derives ${a.address}; refusing to sign`);return{signature:await a._signTypedData(e,r,n),signer:a.address}}(t.validatorWalletAddress,i,p,ht);return{backing:ht,signature:gt,signer:pt,domain:i,sampled:rt.map((t=>L[t].positionId))}}return V=i,((i,o,a,s)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let c of r(o))n.call(i,c)||c===a||t(i,c,{get:()=>o[c],enumerable:!(s=e(o,c))||s.enumerable});return i})(t({},"__esModule",{value:!0}),V)})();if("object"==typeof _LIT_ACTION_)if("function"==typeof _LIT_ACTION_.main)var main=_LIT_ACTION_.main;else"function"==typeof _LIT_ACTION_.go&&_LIT_ACTION_.go();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4e355300b67b7b2ad2d833b39c6b130952beb1f67c24e9de2346d4922418e1f8
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"actionName": "backing-attestation",
|
|
3
|
+
"originalSize": 36080,
|
|
4
|
+
"minifiedSize": 20591,
|
|
5
|
+
"compressionRatio": 0.4292960088691796,
|
|
6
|
+
"hash": "4e355300b67b7b2ad2d833b39c6b130952beb1f67c24e9de2346d4922418e1f8",
|
|
7
|
+
"buildTime": 1793951465880,
|
|
8
|
+
"version": "0.1.0"
|
|
9
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lit-actions-registry.d.ts","sourceRoot":"","sources":["../../../../pkg-src/constants/chunks/lit-actions-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,sBAAsB,
|
|
1
|
+
{"version":3,"file":"lit-actions-registry.d.ts","sourceRoot":"","sources":["../../../../pkg-src/constants/chunks/lit-actions-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAG1D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAAO,CAAC,sBAAsB,CA6UnE,CAAC;AAEF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,sBAAsB,CAAC,CAGjC;AAED,eAAO,MAAM,oBAAoB,iCAA0B,CAAC"}
|
|
@@ -485,7 +485,7 @@ __export(index_exports, {
|
|
|
485
485
|
});
|
|
486
486
|
module.exports = __toCommonJS(index_exports);
|
|
487
487
|
|
|
488
|
-
// node_modules/base-x/src/esm/index.js
|
|
488
|
+
// ../../diamond-hands/lit-actions/node_modules/base-x/src/esm/index.js
|
|
489
489
|
function base(ALPHABET2) {
|
|
490
490
|
if (ALPHABET2.length >= 255) {
|
|
491
491
|
throw new TypeError("Alphabet too long");
|
|
@@ -616,7 +616,7 @@ function base(ALPHABET2) {
|
|
|
616
616
|
}
|
|
617
617
|
var esm_default = base;
|
|
618
618
|
|
|
619
|
-
// node_modules/bs58/src/esm/index.js
|
|
619
|
+
// ../../diamond-hands/lit-actions/node_modules/bs58/src/esm/index.js
|
|
620
620
|
var ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
621
621
|
var esm_default2 = esm_default(ALPHABET);
|
|
622
622
|
|
|
@@ -943,6 +943,19 @@ var DH_LIT_ACTIONS_CHIPOTLE = {
|
|
|
943
943
|
deployedAt: 1790925699980,
|
|
944
944
|
size: 7193,
|
|
945
945
|
hash: "4944ada61610cf64b32e33b5be62087088dcf5e821040c69e67942e643ce74c9"
|
|
946
|
+
},
|
|
947
|
+
backingAttestation: {
|
|
948
|
+
cid: "QmTqKxYQ2XrN8vVQU1Nc7BqAvJqyg19UnR6xjjpDPj89qF",
|
|
949
|
+
authorizedCidHex: cidToHex(
|
|
950
|
+
"QmTqKxYQ2XrN8vVQU1Nc7BqAvJqyg19UnR6xjjpDPj89qF"
|
|
951
|
+
),
|
|
952
|
+
name: "Backing Attestation",
|
|
953
|
+
description: "BackingOracle report: BTC collateral over loan UCD at a pinned block, from a keeper snapshot the action verifies",
|
|
954
|
+
version: "1.0.1",
|
|
955
|
+
deployed: true,
|
|
956
|
+
deployedAt: 1793951405193,
|
|
957
|
+
size: 20591,
|
|
958
|
+
hash: "4e355300b67b7b2ad2d833b39c6b130952beb1f67c24e9de2346d4922418e1f8"
|
|
946
959
|
}
|
|
947
960
|
};
|
|
948
961
|
function getDeploymentsForNetwork(network) {
|