@indigo-labs/indigo-sdk 0.1.2 → 0.1.4

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.
Files changed (40) hide show
  1. package/README.md +52 -7
  2. package/dist/index.d.mts +1064 -182
  3. package/dist/index.d.ts +1064 -182
  4. package/dist/index.js +2565 -561
  5. package/dist/index.mjs +2546 -593
  6. package/package.json +64 -43
  7. package/.nvmrc +0 -1
  8. package/.prettierrc +0 -6
  9. package/babel.config.cjs +0 -13
  10. package/examples/sample-cdp.ts +0 -43
  11. package/jest.config.js +0 -13
  12. package/src/contracts/cdp-creator.ts +0 -86
  13. package/src/contracts/cdp.ts +0 -892
  14. package/src/contracts/collector.ts +0 -91
  15. package/src/contracts/gov.ts +0 -58
  16. package/src/contracts/interest-oracle.ts +0 -49
  17. package/src/contracts/price-oracle.ts +0 -24
  18. package/src/contracts/treasury.ts +0 -95
  19. package/src/helpers/asset-helpers.ts +0 -28
  20. package/src/helpers/cdp-helpers.ts +0 -9
  21. package/src/helpers/helpers.ts +0 -17
  22. package/src/helpers/lucid-utils.ts +0 -24
  23. package/src/helpers/time-helpers.ts +0 -3
  24. package/src/index.ts +0 -23
  25. package/src/scripts/cdp-creator-validator.ts +0 -9
  26. package/src/scripts/cdp-validator.ts +0 -9
  27. package/src/scripts/collector-validator.ts +0 -8
  28. package/src/scripts/interest-oracle-validator.ts +0 -8
  29. package/src/scripts/treasury-validator.ts +0 -8
  30. package/src/types/generic.ts +0 -13
  31. package/src/types/indigo/cdp.ts +0 -33
  32. package/src/types/indigo/gov.ts +0 -21
  33. package/src/types/indigo/interest-oracle.ts +0 -5
  34. package/src/types/indigo/price-oracle.ts +0 -4
  35. package/src/types/system-params.ts +0 -228
  36. package/tests/data/system-params.json +0 -989
  37. package/tests/datums.test.ts +0 -51
  38. package/tests/hash-checks.test.ts +0 -17
  39. package/tests/interest-calculations.test.ts +0 -143
  40. package/tsconfig.json +0 -35
package/dist/index.js CHANGED
@@ -29,169 +29,354 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  // src/index.ts
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
+ AccountAction: () => AccountAction,
33
+ AccountActionSchema: () => AccountActionSchema,
34
+ AccountContent: () => AccountContent,
35
+ AccountContentSchema: () => AccountContentSchema,
36
+ ActionReturnDatum: () => ActionReturnDatum,
37
+ ActionReturnDatumSchema: () => ActionReturnDatumSchema,
38
+ Address: () => Address,
39
+ AddressSchema: () => AddressSchema,
40
+ AssetClassSchema: () => AssetClassSchema,
41
+ CDPContentSchema: () => CDPContentSchema,
32
42
  CDPContract: () => CDPContract,
33
- CDPCreatorContract: () => CDPCreatorContract,
34
- CDPHelpers: () => CDPHelpers,
43
+ CDPDatumSchema: () => CDPDatumSchema,
44
+ CDPFeesSchema: () => CDPFeesSchema,
35
45
  CollectorContract: () => CollectorContract,
46
+ Credential: () => Credential,
47
+ CredentialSchema: () => CredentialSchema,
48
+ EpochToScaleToSum: () => EpochToScaleToSum,
49
+ EpochToScaleToSumSchema: () => EpochToScaleToSumSchema,
50
+ ExecuteParams: () => ExecuteParams,
51
+ FeedInterestOracleRedeemerSchema: () => FeedInterestOracleRedeemerSchema,
36
52
  GovContract: () => GovContract,
53
+ GovParams: () => GovParams,
54
+ IAssetContentSchema: () => IAssetContentSchema,
37
55
  IAssetHelpers: () => IAssetHelpers,
38
56
  InterestOracleContract: () => InterestOracleContract,
39
- PriceOracleContract: () => PriceOracleContract,
57
+ InterestOracleDatumSchema: () => InterestOracleDatumSchema,
58
+ InterestOracleParamsSchema: () => InterestOracleParamsSchema,
59
+ LRPDatumSchema: () => LRPDatumSchema,
60
+ LRPParamsSchema: () => LRPParamsSchema,
61
+ LRPRedeemerSchema: () => LRPRedeemerSchema,
62
+ ONE_SECOND: () => ONE_SECOND,
63
+ OracleAssetNftSchema: () => OracleAssetNftSchema,
64
+ OutputReferenceSchema: () => OutputReferenceSchema,
65
+ PollManagerParams: () => PollManagerParams,
66
+ PollShardParams: () => PollShardParams,
67
+ PriceOracleDatumSchema: () => PriceOracleDatumSchema,
68
+ PriceOracleParamsSchema: () => PriceOracleParamsSchema,
69
+ SPInteger: () => SPInteger,
70
+ SPIntegerSchema: () => SPIntegerSchema,
71
+ SnapshotEpochToScaleToSumContent: () => SnapshotEpochToScaleToSumContent,
72
+ SnapshotEpochToScaleToSumContentSchema: () => SnapshotEpochToScaleToSumContentSchema,
73
+ StabilityPoolContent: () => StabilityPoolContent,
74
+ StabilityPoolContentSchema: () => StabilityPoolContentSchema,
75
+ StabilityPoolContract: () => StabilityPoolContract,
76
+ StabilityPoolDatum: () => StabilityPoolDatum,
77
+ StabilityPoolDatumSchema: () => StabilityPoolDatumSchema,
78
+ StabilityPoolParams: () => StabilityPoolParams,
79
+ StabilityPoolRedeemer: () => StabilityPoolRedeemer,
80
+ StabilityPoolRedeemerSchema: () => StabilityPoolRedeemerSchema,
81
+ StabilityPoolSnapshot: () => StabilityPoolSnapshot,
82
+ StakingContract: () => StakingContract,
40
83
  TreasuryContract: () => TreasuryContract,
41
- _cdpCreatorValidator: () => _cdpCreatorValidator,
84
+ VerificationKeyHashSchema: () => VerificationKeyHashSchema,
42
85
  _cdpValidator: () => _cdpValidator,
43
86
  _collectorValidator: () => _collectorValidator,
44
- _interestOracleValidator: () => _interestOracleValidator,
45
87
  _treasuryValidator: () => _treasuryValidator,
46
88
  addrDetails: () => addrDetails,
89
+ addressFromBech32: () => addressFromBech32,
90
+ addressToBech32: () => addressToBech32,
47
91
  balance: () => balance,
48
92
  calculateFeeFromPercentage: () => calculateFeeFromPercentage,
93
+ cancelLrp: () => cancelLrp,
94
+ castExecuteParams: () => castExecuteParams,
95
+ castGovParams: () => castGovParams,
96
+ castInterestOracleParams: () => castInterestOracleParams,
97
+ castLrpParams: () => castLrpParams,
98
+ castPollManagerParams: () => castPollManagerParams,
99
+ castPollShardParams: () => castPollShardParams,
100
+ castPriceOracleParams: () => castPriceOracleParams,
101
+ castStabilityPoolParams: () => castStabilityPoolParams,
102
+ cdpCreatorValidator: () => cdpCreatorValidator,
103
+ createScriptAddress: () => createScriptAddress,
104
+ fromSPInteger: () => fromSPInteger,
105
+ fromSystemParamsAsset: () => fromSystemParamsAsset,
106
+ getInlineDatumOrThrow: () => getInlineDatumOrThrow,
49
107
  getRandomElement: () => getRandomElement,
50
108
  loadSystemParamsFromFile: () => loadSystemParamsFromFile,
51
109
  loadSystemParamsFromUrl: () => loadSystemParamsFromUrl,
110
+ matchSingle: () => matchSingle,
111
+ mkCDPCreatorValidator: () => mkCDPCreatorValidator,
112
+ mkCDPCreatorValidatorFromSP: () => mkCDPCreatorValidatorFromSP,
113
+ mkInterestOracleValidator: () => mkInterestOracleValidator,
114
+ mkLrpValidator: () => mkLrpValidator,
115
+ mkPollManagerValidator: () => mkPollManagerValidator,
116
+ mkPollManagerValidatorFromSP: () => mkPollManagerValidatorFromSP,
117
+ mkPollShardValidator: () => mkPollShardValidator,
118
+ mkPollShardValidatorFromSP: () => mkPollShardValidatorFromSP,
119
+ mkSPInteger: () => mkSPInteger,
52
120
  oneDay: () => oneDay,
53
121
  oneHour: () => oneHour,
122
+ oneShotMintTx: () => oneShotMintTx,
54
123
  oneYear: () => oneYear,
55
- scriptRef: () => scriptRef
124
+ openLrp: () => openLrp,
125
+ parseAccountDatum: () => parseAccountDatum,
126
+ parseCDPDatum: () => parseCDPDatum,
127
+ parseGovDatum: () => parseGovDatum,
128
+ parseIAssetDatum: () => parseIAssetDatum,
129
+ parseInterestOracleDatum: () => parseInterestOracleDatum,
130
+ parseLrpDatum: () => parseLrpDatum,
131
+ parsePriceOracleDatum: () => parsePriceOracleDatum,
132
+ parseSnapshotEpochToScaleToSumDatum: () => parseSnapshotEpochToScaleToSumDatum,
133
+ parseStabilityPoolDatum: () => parseStabilityPoolDatum,
134
+ redeemLrp: () => redeemLrp,
135
+ runCreateScriptRefTx: () => runCreateScriptRefTx,
136
+ runOneShotMintTx: () => runOneShotMintTx,
137
+ scriptRef: () => scriptRef,
138
+ serialiseCDPDatum: () => serialiseCDPDatum,
139
+ serialiseFeedInterestOracleRedeemer: () => serialiseFeedInterestOracleRedeemer,
140
+ serialiseGovDatum: () => serialiseGovDatum,
141
+ serialiseIAssetDatum: () => serialiseIAssetDatum,
142
+ serialiseInterestOracleDatum: () => serialiseInterestOracleDatum,
143
+ serialiseLrpDatum: () => serialiseLrpDatum,
144
+ serialiseLrpRedeemer: () => serialiseLrpRedeemer,
145
+ serialisePriceOracleDatum: () => serialisePriceOracleDatum,
146
+ serialiseStabilityPoolDatum: () => serialiseStabilityPoolDatum,
147
+ serialiseStabilityPoolRedeemer: () => serialiseStabilityPoolRedeemer,
148
+ spAdd: () => spAdd,
149
+ spDiv: () => spDiv,
150
+ spMul: () => spMul,
151
+ spSub: () => spSub,
152
+ toSystemParamsAsset: () => toSystemParamsAsset
56
153
  });
57
154
  module.exports = __toCommonJS(index_exports);
58
155
 
59
- // src/contracts/cdp-creator.ts
60
- var import_lucid2 = require("@lucid-evolution/lucid");
156
+ // src/contracts/cdp.ts
157
+ var import_lucid12 = require("@lucid-evolution/lucid");
61
158
 
62
- // src/scripts/cdp-creator-validator.ts
63
- var _cdpCreatorValidator = {
64
- type: "PlutusV2",
65
- description: "",
66
- cborHex: "591a6c591a6901000032323232323232322232322323225333009323232533300c3006300e37540022646464646464646464646464646464646464a66603c603660406ea80644c8c8c8ccccc8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c88888c8c8c8c8c8c94ccc0f8c0ecc100dd50008991919192999821181e18221baa00213232533304433034490115496e636f72726563742074782076616c69646974790032325333046325333047302d00114a22a66608e6082002294452818241baa3301d303930493754004607260926ea80044c94ccc11cc1100045288a99982398208008a5114a060906ea8cc074c0c4c124dd5001181898249baa00114a06034606e66094606e660946036660946ea0cdc08071bad30163048375408897ae03304a3330454a298103d87a80004c0103d87980004bd7019825181b99825180d998251ba83370001c6eb4c058c120dd502225eb80cc128ccc11528a6103d87a80004c0103d87980004bd7025eb80c064c058c11cdd501d0a9998221981a24811754582069736e74207369676e6564206279206f776e657200330283758602a608e6ea80e804054ccc110cc0d124011543445043726561746f724e4654206d697373696e67003302e3756605e608e6ea8c0bcc11cdd5003181b98239baa04315333044330344912043445043726561746f72206f757470757420646f6573206e6f74206d617463680033333014008301a330490054bd70260107d87b9fd87980ff00301330373047375408698103d87a80001533304433034491174d696e7465642076616c756520697320696e76616c6964003375e6e98c0c8dd5981898239baa03a374c66660306026604e608e6ea810cdd7181798239baa043375c606e608e6ea800803c54ccc110cc0d1240115434450206f757470757420697320696e76616c69640033333014008303633049301a33049304a304b304b304b304b304b3047375408697ae04bd7019ba548010cc124c0d8cc124c0d8cc124c0d8cc124dd480825eb80cc124c0dcc11cdd5001198249ba800f33049303633049375001a660926ea0cdc01bad303730473754002a66608866e20dd6981398239baa00100d13370666e0ccdc119b823370201a6eb4c09cc11cdd50009bad303730473754605e608e6ea8005208080a0f6f4acdbe01b48202c227efa8052080897a15330454901254d75737420686f6c643a206e6f77203e206c61737420696e7465726573742075706461746500164bd7025eb812f5c097ae033012301330273047375408601c980103d87980001325332330463303649115556e646572636f6c6c61746572697a65642043445000337126eb4c0e4c124dd51980c9980c981998249baa00430383304b3750600202297ae03039304937540046eb4c0e4c124dd51980c981c198259ba830010104bd70181c198259ba833704906400a410112f497ae01533304633036491164e6f6e706f736974697665206d696e74656420616d7400302e011153330463303649012e4d7573742070726f76696465206d6f7265207468616e206d696e436f6c6c61746572616c496e4c6f76656c61636500337126eb4c060c124dd50228080a9998231981b249174f7261636c652063616e2774206265206578706972656400333046325333047304130493754002266e24dd6981918251baa003375a609a60946ea800454cc121240124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e67650016303930493754606260926ea8c060c124dd501e2504a226606c9201194d757374207061792064656274206d696e74696e67206665650033322232533304a3032002132533304b3232302c00232533304d304a00115333051305037540042930b0a99982698238008a99982898281baa00214985854ccc134c0cc00454ccc144c140dd50010a4c2c2c609c6ea8004c94ccc130c124c138dd50008982918279baa001153304d49117436f756c64206e6f742066696e642072656465656d6572001632323300100100722533305200114c0103d87a8000132323253330513375e00c60a600626086660ac00297ae0133005005002305300230560023054001302133050303e304e375400297ae013333301b00f302133050303d33050002330504c103d87a80004bd7025eb8130107d87b9fd87980ff00330193756606c609c6ea8c0d8c138dd5000801a60103d879800014a064a66609e0022a66098921284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400161533304f305200113051001153304c4901284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400163303301123375e607c609c6ea8c0f8c138dd5181b18271baa00100214a2603e6609c6ea40092f5c06eacc130c134c134c134c134c134c134c134c134c134c124dd501e1bae30133049375408a6644a66609066e2400520001480004dd6981d98259baa303a3304d375066e0cc00cdd6981d98259baa3301b303a3304d375000297ae0002375a607660966ea8c0e8cc134dd419b8248320052080897a4bd7025eb80c04cc124dd50021bad303930493754660326070660966ea00452f5c0607260926ea80085280a5014a06e092080897a14a064a66608a6084608e6ea800454cc11924012543616e6e6f74206f70656e206120434450206f6620612064656c69737465642061737365740016132320025333046304330483754002264646464a66609c60a20042649318118018b1bad304f001304f002304d001304937540022c6054605060906ea8c0c0c120dd51929998250008a99823a492145787065637465642065786163746c79206f6e65206f7261636c6520696e70757400161533304a304d0011304c001153304749012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001633302c00a304b30483754609660906ea8005300103d8798000302f3047375400429405280a5014a0294052819190012999822182098231baa0011323232323232533304e3051002132498c08c00c58dd698278009827801182680098268011bad304b001304737540022c6050604c608c6ea8c0b8c118dd51929998240008a99822a492a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001615333048304b0011304a001153304549012a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001633302a008302630463754002980103d87980003048304537540042c64a666084607e00226464a6660906096004264932999822182098231baa001132323232323232325333050305300213232498c94ccc138c12c0044c8c8c8c94ccc158c16400852616375a60ae00260ae0046eb4c154004c144dd50018a9998271824000899191919299982b182c8010a4c2c6eb4c15c004c15c008dd6982a80098289baa00316304f3754004604800e2c60a200260a20046eb4c13c004c13c008dd718268009826801182580098239baa00116163049001304537540042a666084607800226464a6660906096004264932999822182098231baa001132323232323232323232323232323232323232323232323232323232533306430670021323232323232323232323232498c10c030c10c03cc108040c104044c100048c0fc04cc0f8050c0f4054c0f0058c0ec05cc0f4060c94ccc184c1780044c8c94ccc19cc1a80084c926303c001163068001306437540342a6660c260b600226464a6660ce60d4004264932999831983018329baa001132325333069306c002132498c10400458c1a8004c198dd50008b0b183400098321baa01a16306237540322c60ca00260ca00464a6660c460c20022a6660bc60b060c0002294454ccc178c16cc1800045280b0b1baa3063001306300230610013061002305f001305f002305d001305d002305b001305b0023059001305900230570013057002305500130550023053001305300230510013051002304f001304f002304d001304d002375c6096002608e6ea80045858c124004c114dd50010b18219baa0013025302330433754605660866ea8c94ccc11400454cc10924012145787065637465642065786163746c79206f6e652069617373657420696e707574001615333045304800113047001153304249012145787065637465642065786163746c79206f6e652069617373657420696e707574001633302700530463047304730473043375407e980103d8798000303230423754605460846ea8004c110c104dd50008b198170020189bac304230430023758608200260820046eb0c0fc004c0ecdd50171181d181d981d981d981d981d981d800911999804001244100488100001233225333034302e4800052f5bded8c0264646600200297adef6c6022533303b00113303c337606ea4014dd3001a5eb7bdb1804c8c8c8c94ccc0ecc068cc0540240084cc100cdd81ba9009374c00e00a2a66607666e3c0240084cc100cdd81ba9009374c00e00626608066ec0dd48011ba6001330060060033756607a0066eb8c0ec008c0fc008c0f4004c8cc0040052f5bded8c044a66607400226607666ec0dd4801a610101004bd6f7b630099191919299981d180c9980a00380109981f99bb0375200e9810101000051533303a3371e00e00426607e66ec0dd4803a6101010000313303f337606ea4008dd4000998030030019bad303c003375c6074004607c00460780026eb8c094c0d4dd50009bae301d303537540024444464660020026603e00ca66606c606660706ea80144c88cdd79815981d9baa302b303b3754002004607860726ea80144c88cdd79815981d9baa001002303c3039375400a44a66607600229404c94ccc0e0c94ccc0e4cdd7980e181e1baa001007132533303e00114a22a66607c60820022646464a66607a60586eb8c10c00c54ccc0f4c0b000454ccc0f4c0e8c0fcdd50048a99981e99b89480000084cdc48012410137dc0429404cdc4a400000429405281bae30423043002375a6082608460840026eb0c1000045281919800800991998008009bab3026303e3754006646600200201244a666082002297adef6c6013233043337606ea4dd718200009ba632330010013756608400444a666088002297adef6c6013233046337606ea4dd718218009ba83370290001bad3044001330030033048002304600133003003304500230430012225333041002100113233300400430450033333301b002375c60800026eacc104004888c94ccc108c0740045300103d87a80001303433047374c00297ae03233300100100300222253330480021001132333004004304c00333333023002375c608e0026eb4c120004888c94ccc124c1180045300103d87a80001303b3304e375000297ae03370000400203e6094004030608600444a66607e002297ae01323332223233001001003225333045001100313233047374e6608e6ea4018cc11cdd49bae30440013304737506eb4c1140052f5c0660060066092004608e0026eb8c0f8004dd5981f80099801801982180118208008a50303e00214a2266006006002607c0024606c606e606e606e606e606e606e606e606e0024606a606c606c606c606c606c606c606c002446042660686ea0cdc199b82375a604460646ea8008dd6981118191baa0014820225e92f5c04444a666060605a002200826666601a0080066464004646600200200444a66606e002293099299981c0008a4c26464a66606c606660706ea8cc040dd7181c181e0021bae30380021330050053303b0020011533037491326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016303c002303a001303a00133035337606ea4008dd4000a5eb7bdb180888c94ccc0d0c03c004530103d87a80001302633039374c00297ae033333011001005004222325333037303400114c103d87a8000130293303c375000297ae03370000200401a0144603c6606264a66605a604e605e6ea80044c94ccc0b8c94ccc0ccc0c800454ccc0bcc0a4c0c40045288a999817981618188008a5016163754603260626ea8c084c0c4dd500189802198199ba80014bd7009802198199ba833700002900125eb80dd6981998181baa0011001301f302f3754603e605e6ea8004cc0c4c94ccc0b4c09cc0bcdd5000899299981719299981998190008a999817981498188008a511533302f302c303100114a02c2c6ea8c064c0c4dd5180c98189baa0031300433033375000297ae01300433033375066e0000520014bd701bad3033303037540022002603e605e6ea8c05cc0bcdd5000a5eb80dd2a40044464a66605860520022a6660586052605c6ea8008530103d87a800014c103d87980001533302c30120011533302c3012302e3754004298103d87a800014c103d87b800013232533302e3028001132533302f33710006002298103d87980001533302f337100020062980103d87b800014c103d87a8000375a606860626ea801054ccc0b8c0ac004530103d87b800014c103d8798000302f37540066eb4c0c8c0bcdd500198169baa002232533302a30270011323253330303033002149858dd7181880098169baa0021533302a30240011533302e302d37540042930b0b18159baa001253330283025302a375400226464a66605c60620042930b1bad302f001302b37540022c44a66605066e40008004530103d8798000153330283371e0040022980103d87a800014c103d87b80002533302a00114a2294094ccc094c088c09cdd5000899191919299981698180010a4c2c6eb8c0b8004c0b8008dd7181600098141baa0011622222323300100100622533302e00113302f337606ea4018dd3002a5eb7bdb1804c8c8c8c94ccc0b8c034cc01c0280084cc0cccdd81ba900a374c01200a2a66605c66e3c0280084c94ccc0bcc0b0c0c4dd500089981a19bb03752016606a60646ea80040104010ccc0200280240044cc0cccdd81ba9002374c0026600c00c0066eacc0c000cdd718170011819001181800091111191980080080311299981680089981719bb0375200c6ea00152f5bded8c0264646464a66605a60186600e01400426606466ec0dd48051ba80090051533302d3371e014004264a66605c605660606ea80044cc0cccdd81ba900b303430313754002008200866601001401200226606466ec0dd48011ba800133006006003375a605e0066eb8c0b4008c0c4008c0bc004dd7a6103d8798000375c604e0066eb4c09c008dd698138009bad302730280013027001302600130213754032266646464446464646464a666050604a60546ea80044c94ccc0a4c08cc0acdd500089919192999818181980109919192999817981618189baa00113301f3300f3303437526e61241084d697373696e6720003303437526e60038cc0d0dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd7024900330133010301d009375c606a60646ea800454cc0c0cc03ccc0d0dd49b98491084d697373696e6720003303437526e60038cc0d0dd49b9849010d20757067726164652070617468004bd70249001632533302f302930313754002298103d87a8000130213303437526eb8c0c8c8cdd8181b000981b181b8009bac30353032375400297ae032330010013756603460646ea800c894ccc0d00045300103d87a80001323253330323371e6eb8c0d00080244c090cc0dcdd39981b981a0011981b981a80125eb812f5c02660080080026070004606c002a66605a6054605e6ea80044c8c8c8c94ccc0d4c0e00084c926323300100100222533303700114984c8cc00c00cc0ec008c8c8dd7181c0011bae30360013039001163756606c002606c0046eb4c0d0004c0c0dd50008b1808980798179baa3017302f37540022c606200266602200a01098103d8798000375c605e60586ea800458c06cc0acdd5180d98159baa3013302b3754605c60566ea800458cc060dd6181680200d9bab302c302d302d302d002375860560026056002604c6ea806488dcc9919199800800802244100222533302a0021001132333004004302e00353330273024371a00426e600044cdc500119b8a00537300026e64dd718160011b98001300100122533302400114bd7009981298111813000998010011813800a490a43445043726561746f7200300b3021375403a46048604a604a00244646600200200644a66604800229404c94ccc084cdc79bae302700200414a2266006006002604e0024a6660386004603c6ea80044c088c07cdd50008a9980ea481134e6f7420616e20696e6c696e6520646174756d0016370e9002111191980300211801180498109baa001533301c3019301e3754002246600e6eacc020c080dd50008018918029998049bab3008302037540026eb8c040c080dd50019bae3008302037540066e21200022323300100100322533301f00114bd7009919299980e980280109981100119802002000899802002000981180118108009118091998020011bae300b301b37540026eb8c00cc06cdd50009180e180e80091119299980c1809180d1baa0011480004dd6980f180d9baa0013253330183012301a37540022980103d87a8000132330010013756603e60386ea8008894ccc078004530103d87a80001323232533301d3371e00e6eb8c07c00c4c03ccc088dd4000a5eb804cc014014008dd6980f80118110011810000991980080080211299980e8008a6103d87a80001323232533301c3371e00e6eb8c07800c4c038cc084dd3000a5eb804cc014014008dd5980f0011810801180f8009180d180d980d980d980d8009191980080080111299980c8008a5eb7bdb1804c8c8c8c94ccc064c020008400c4cc078cdd81ba9002374c0026600c00c0066eacc06c00cdd7180c801180e801180d8009b8f4881002253330123330120014a094454cc04c0084004400488c8cc00400400c894ccc05c0045300103d87a80001323253330153375e601060306ea80080144c01ccc0680092f5c0266008008002603600460320026e952000230140013012300f37540022c60226024004602000260186ea80045261365632533300830050011323232323232323253330143017002149858dd6980a800980a8011bad30130013013002375a602200260220046eb8c03c004c02cdd50018a99980418010008a99980618059baa00314985858c024dd50011b8748008c94ccc014c008c01c00454ccc024c020004526161637540046e1d20005734ae7155ceaab9e5573eae815d0aba21"
67
- };
159
+ // src/helpers/asset-helpers.ts
160
+ var import_lucid5 = require("@lucid-evolution/lucid");
68
161
 
69
- // src/helpers/lucid-utils.ts
162
+ // src/types/indigo/cdp.ts
163
+ var import_lucid4 = require("@lucid-evolution/lucid");
164
+
165
+ // src/types/generic.ts
70
166
  var import_lucid = require("@lucid-evolution/lucid");
71
- async function addrDetails(lucid) {
72
- const addr = await lucid.wallet().address();
73
- return [
74
- (0, import_lucid.paymentCredentialOf)(addr),
75
- (0, import_lucid.stakeCredentialOf)(addr)
76
- ];
167
+ var AssetClassSchema = import_lucid.Data.Object({
168
+ currencySymbol: import_lucid.Data.Bytes(),
169
+ /** Use the HEX encoding */
170
+ tokenName: import_lucid.Data.Bytes()
171
+ });
172
+ var OutputReferenceSchema = import_lucid.Data.Object({
173
+ txHash: import_lucid.Data.Object({ hash: import_lucid.Data.Bytes({ minLength: 32, maxLength: 32 }) }),
174
+ outputIndex: import_lucid.Data.Integer()
175
+ });
176
+ var VerificationKeyHashSchema = import_lucid.Data.Bytes({
177
+ minLength: 28,
178
+ maxLength: 28
179
+ });
180
+ var CredentialSchema = import_lucid.Data.Enum([
181
+ import_lucid.Data.Object({
182
+ PublicKeyCredential: import_lucid.Data.Tuple([VerificationKeyHashSchema])
183
+ }),
184
+ import_lucid.Data.Object({
185
+ ScriptCredential: import_lucid.Data.Tuple([
186
+ import_lucid.Data.Bytes({ minLength: 28, maxLength: 28 })
187
+ ])
188
+ })
189
+ ]);
190
+ var Credential = CredentialSchema;
191
+ var AddressSchema = import_lucid.Data.Object({
192
+ paymentCredential: CredentialSchema,
193
+ stakeCredential: import_lucid.Data.Nullable(
194
+ import_lucid.Data.Enum([
195
+ import_lucid.Data.Object({ Inline: import_lucid.Data.Tuple([CredentialSchema]) }),
196
+ import_lucid.Data.Object({
197
+ Pointer: import_lucid.Data.Tuple([
198
+ import_lucid.Data.Object({
199
+ slotNumber: import_lucid.Data.Integer(),
200
+ transactionIndex: import_lucid.Data.Integer(),
201
+ certificateIndex: import_lucid.Data.Integer()
202
+ })
203
+ ])
204
+ })
205
+ ])
206
+ )
207
+ });
208
+ var Address = AddressSchema;
209
+ function addressToBech32(lucid, address) {
210
+ const paymentCredential = "PublicKeyCredential" in address.paymentCredential ? { type: "Key", hash: address.paymentCredential.PublicKeyCredential[0] } : { type: "Script", hash: address.paymentCredential.ScriptCredential[0] };
211
+ const stakeCredential = address.stakeCredential && "Inline" in address.stakeCredential ? "PublicKeyCredential" in address.stakeCredential.Inline[0] ? {
212
+ type: "Key",
213
+ hash: address.stakeCredential.Inline[0].PublicKeyCredential[0]
214
+ } : {
215
+ type: "Script",
216
+ hash: address.stakeCredential.Inline[0].ScriptCredential[0]
217
+ } : void 0;
218
+ return (0, import_lucid.credentialToAddress)(
219
+ lucid.config().network,
220
+ paymentCredential,
221
+ stakeCredential
222
+ );
77
223
  }
78
- async function scriptRef(ref, lucid) {
79
- const utxos = await lucid.utxosByOutRef([{ txHash: ref.input.transactionId, outputIndex: ref.input.index }]);
80
- if (utxos.length === 0)
81
- throw "Unable to locate script ref.";
82
- return utxos[0];
224
+ function addressFromBech32(address) {
225
+ const details = (0, import_lucid.getAddressDetails)(address);
226
+ return {
227
+ paymentCredential: {
228
+ PublicKeyCredential: [details.paymentCredential.hash]
229
+ },
230
+ stakeCredential: details.stakeCredential ? { Inline: [{ PublicKeyCredential: [details.stakeCredential.hash] }] } : void 0
231
+ };
83
232
  }
84
- function balance(utxos) {
85
- return utxos.reduce((acc, utxo) => (0, import_lucid.addAssets)(acc, utxo.assets), {});
233
+
234
+ // src/types/on-chain-decimal.ts
235
+ var import_lucid2 = require("@lucid-evolution/lucid");
236
+ var OCD_DECIMAL_UNIT = 1000000n;
237
+ var OnChainDecimalSchema = import_lucid2.Data.Object({
238
+ getOnChainInt: import_lucid2.Data.Integer()
239
+ });
240
+ function ocdMul(a, b) {
241
+ return {
242
+ getOnChainInt: a.getOnChainInt * b.getOnChainInt / OCD_DECIMAL_UNIT
243
+ };
244
+ }
245
+ function ocdDiv(a, b) {
246
+ return {
247
+ getOnChainInt: a.getOnChainInt * OCD_DECIMAL_UNIT / b.getOnChainInt
248
+ };
86
249
  }
87
- var getRandomElement = (arr) => arr.length ? arr[Math.floor(Math.random() * arr.length)] : void 0;
88
250
 
89
- // src/contracts/cdp-creator.ts
90
- var CDPCreatorContract = class _CDPCreatorContract {
91
- static address(params, lucid) {
92
- const network = lucid.config().network;
93
- if (!network) {
94
- throw new Error("Network configuration is undefined");
95
- }
96
- return (0, import_lucid2.validatorToAddress)(network, _CDPCreatorContract.validator(params));
97
- }
98
- static validator(params) {
99
- return {
100
- type: "PlutusV2",
101
- script: (0, import_lucid2.applyParamsToScript)(_cdpCreatorValidator.cborHex, [
102
- new import_lucid2.Constr(0, [
103
- new import_lucid2.Constr(0, [
104
- params.cdpCreatorNft[0].unCurrencySymbol,
105
- (0, import_lucid2.fromText)(params.cdpCreatorNft[1].unTokenName)
106
- ]),
107
- params.cdpAssetCs.unCurrencySymbol,
108
- new import_lucid2.Constr(0, [
109
- params.cdpAuthTk[0].unCurrencySymbol,
110
- (0, import_lucid2.fromText)(params.cdpAuthTk[1].unTokenName)
111
- ]),
112
- new import_lucid2.Constr(0, [
113
- params.iAssetAuthTk[0].unCurrencySymbol,
114
- (0, import_lucid2.fromText)(params.iAssetAuthTk[1].unTokenName)
115
- ]),
116
- new import_lucid2.Constr(0, [
117
- params.versionRecordToken[0].unCurrencySymbol,
118
- (0, import_lucid2.fromText)(params.versionRecordToken[1].unTokenName)
119
- ]),
120
- params.cdpScriptHash,
121
- params.collectorValHash,
122
- BigInt(params.minCollateralInLovelace),
123
- BigInt(params.biasTime)
124
- ])
125
- ])
126
- };
127
- }
128
- static validatorHash(params) {
129
- return (0, import_lucid2.validatorToScriptHash)(_CDPCreatorContract.validator(params));
130
- }
131
- static redeemer(hash, mintedAmount, collateralAmount, currentTime) {
132
- if (hash.type !== "Key") throw new Error("Cannot support script hash.");
133
- return new import_lucid2.Constr(0, [
134
- hash.hash,
135
- BigInt(mintedAmount),
136
- BigInt(collateralAmount),
137
- currentTime
138
- ]);
139
- }
140
- static scriptRef(params, lucid) {
141
- return scriptRef(params.cdpCreatorValidatorRef, lucid);
142
- }
143
- };
251
+ // src/types/indigo/price-oracle.ts
252
+ var import_lucid3 = require("@lucid-evolution/lucid");
253
+ var OracleAssetNftSchema = import_lucid3.Data.Object({
254
+ oracleNft: import_lucid3.Data.Object({ asset: AssetClassSchema })
255
+ });
256
+ var PriceOracleParamsSchema = import_lucid3.Data.Object({
257
+ owner: import_lucid3.Data.Bytes(),
258
+ /** Milliseconds */
259
+ biasTime: import_lucid3.Data.Integer(),
260
+ /** Milliseconds */
261
+ expiration: import_lucid3.Data.Integer()
262
+ });
263
+ var PriceOracleParams = PriceOracleParamsSchema;
264
+ var PriceOracleDatumSchema = import_lucid3.Data.Object({
265
+ price: OnChainDecimalSchema,
266
+ expiration: import_lucid3.Data.Integer()
267
+ });
268
+ var PriceOracleDatum = PriceOracleDatumSchema;
269
+ function parsePriceOracleDatum(datum) {
270
+ return import_lucid3.Data.from(datum, PriceOracleDatum);
271
+ }
272
+ function serialisePriceOracleDatum(datum) {
273
+ return import_lucid3.Data.to(datum, PriceOracleDatum);
274
+ }
275
+ function castPriceOracleParams(params) {
276
+ return import_lucid3.Data.castTo(params, PriceOracleParams);
277
+ }
144
278
 
145
- // src/contracts/cdp.ts
146
- var import_lucid9 = require("@lucid-evolution/lucid");
279
+ // src/types/indigo/cdp.ts
280
+ var import_ts_pattern = require("ts-pattern");
281
+ var CDPFeesSchema = import_lucid4.Data.Enum([
282
+ import_lucid4.Data.Object({
283
+ ActiveCDPInterestTracking: import_lucid4.Data.Object({
284
+ lastSettled: import_lucid4.Data.Integer(),
285
+ unitaryInterestSnapshot: import_lucid4.Data.Integer()
286
+ })
287
+ }),
288
+ import_lucid4.Data.Object({
289
+ FrozenCDPAccumulatedFees: import_lucid4.Data.Object({
290
+ lovelacesTreasury: import_lucid4.Data.Integer(),
291
+ lovelacesIndyStakers: import_lucid4.Data.Integer()
292
+ })
293
+ })
294
+ ]);
295
+ var CDPContentSchema = import_lucid4.Data.Object({
296
+ cdpOwner: import_lucid4.Data.Nullable(import_lucid4.Data.Bytes()),
297
+ iasset: import_lucid4.Data.Bytes(),
298
+ mintedAmt: import_lucid4.Data.Integer(),
299
+ cdpFees: CDPFeesSchema
300
+ });
301
+ var IAssetContentSchema = import_lucid4.Data.Object({
302
+ /** Use the HEX encoding */
303
+ assetName: import_lucid4.Data.Bytes(),
304
+ price: import_lucid4.Data.Enum([
305
+ import_lucid4.Data.Object({ Delisted: OnChainDecimalSchema }),
306
+ import_lucid4.Data.Object({
307
+ Oracle: OracleAssetNftSchema
308
+ })
309
+ ]),
310
+ interestOracleNft: AssetClassSchema,
311
+ redemptionRatio: OnChainDecimalSchema,
312
+ maintenanceRatio: OnChainDecimalSchema,
313
+ liquidationRatio: OnChainDecimalSchema,
314
+ debtMintingFeePercentage: OnChainDecimalSchema,
315
+ liquidationProcessingFeePercentage: OnChainDecimalSchema,
316
+ stabilityPoolWithdrawalFeePercentage: OnChainDecimalSchema,
317
+ redemptionReimbursementPercentage: OnChainDecimalSchema,
318
+ redemptionProcessingFeePercentage: OnChainDecimalSchema,
319
+ interestCollectorPortionPercentage: OnChainDecimalSchema,
320
+ firstIAsset: import_lucid4.Data.Boolean(),
321
+ nextIAsset: import_lucid4.Data.Nullable(import_lucid4.Data.Bytes())
322
+ });
323
+ var CDPDatumSchema = import_lucid4.Data.Enum([
324
+ import_lucid4.Data.Object({ CDP: import_lucid4.Data.Object({ content: CDPContentSchema }) }),
325
+ import_lucid4.Data.Object({ IAsset: import_lucid4.Data.Object({ content: IAssetContentSchema }) })
326
+ ]);
327
+ var CDPDatum = CDPDatumSchema;
328
+ function parseCDPDatum(datum) {
329
+ return (0, import_ts_pattern.match)(import_lucid4.Data.from(datum, CDPDatum)).with({ CDP: { content: import_ts_pattern.P.select() } }, (res) => res).otherwise(() => {
330
+ throw new Error("Expected an CDP datum.");
331
+ });
332
+ }
333
+ function serialiseCDPDatum(cdpDatum) {
334
+ return import_lucid4.Data.to({ CDP: { content: cdpDatum } }, CDPDatum);
335
+ }
336
+ function parseIAssetDatum(datum) {
337
+ return (0, import_ts_pattern.match)(import_lucid4.Data.from(datum, CDPDatum)).with({ IAsset: { content: import_ts_pattern.P.select() } }, (res) => res).otherwise(() => {
338
+ throw new Error("Expected an IAsset datum.");
339
+ });
340
+ }
341
+ function serialiseIAssetDatum(iassetDatum) {
342
+ return import_lucid4.Data.to({ IAsset: { content: iassetDatum } }, CDPDatum);
343
+ }
147
344
 
148
345
  // src/helpers/asset-helpers.ts
149
- var import_lucid3 = require("@lucid-evolution/lucid");
150
346
  var IAssetHelpers = class {
151
- static async findIAssetByRef(outRef, params, lucid) {
152
- throw new Error("Not implemented");
347
+ static async findIAssetByRef(outRef, lucid) {
348
+ return lucid.utxosByOutRef([outRef]).then(
349
+ (utxos) => utxos.map((utxo) => {
350
+ if (!utxo.datum) return void 0;
351
+ const datum = parseIAssetDatum(utxo.datum);
352
+ return { utxo, datum };
353
+ }).find((utxo) => utxo !== void 0)
354
+ ).then((result) => {
355
+ if (!result)
356
+ throw new Error("Unable to locate IAsset by output reference.");
357
+ return result;
358
+ });
153
359
  }
154
360
  static async findIAssetByName(assetName, params, lucid) {
155
361
  return lucid.utxosAtWithUnit(
156
362
  CDPContract.address(params.cdpParams, lucid),
157
- params.cdpParams.iAssetAuthToken[0].unCurrencySymbol + (0, import_lucid3.fromText)(params.cdpParams.iAssetAuthToken[1].unTokenName)
158
- ).then((utxos) => utxos.map((utxo) => {
159
- if (!utxo.datum) return void 0;
160
- const datum = CDPContract.decodeCdpDatum(utxo.datum);
161
- if (datum.type !== "IAsset") return void 0;
162
- if (datum.name !== assetName) return void 0;
163
- return { utxo, datum };
164
- }).find((utxo) => utxo !== void 0)).then((result) => {
165
- if (!result) throw "Unable to locate IAsset by name.";
363
+ params.cdpParams.iAssetAuthToken[0].unCurrencySymbol + (0, import_lucid5.fromText)(params.cdpParams.iAssetAuthToken[1].unTokenName)
364
+ ).then(
365
+ (utxos) => utxos.map((utxo) => {
366
+ if (!utxo.datum) return void 0;
367
+ const datum = parseIAssetDatum(utxo.datum);
368
+ if (datum.assetName !== (0, import_lucid5.fromText)(assetName)) return void 0;
369
+ return { utxo, datum };
370
+ }).find((utxo) => utxo !== void 0)
371
+ ).then((result) => {
372
+ if (!result) throw new Error("Unable to locate IAsset by name.");
166
373
  return result;
167
374
  });
168
375
  }
169
376
  };
170
377
 
171
- // src/contracts/price-oracle.ts
172
- var import_lucid4 = require("@lucid-evolution/lucid");
173
- var PriceOracleContract = class {
174
- static decodePriceOracleDatum(datum) {
175
- const oracleDatum = import_lucid4.Data.from(datum);
176
- if (oracleDatum.index != 0 || oracleDatum.fields.length !== 2 || oracleDatum.fields[0].index !== 0)
177
- throw "Invalid Price Oracle Datum provided.";
178
- return {
179
- price: oracleDatum.fields[0].fields[0],
180
- expiration: oracleDatum.fields[1]
181
- };
182
- }
183
- static encodePriceOracleDatum(datum) {
184
- return import_lucid4.Data.to(
185
- new import_lucid4.Constr(0, [
186
- new import_lucid4.Constr(0, [datum.price]),
187
- datum.expiration
188
- ])
189
- );
190
- }
191
- };
192
-
193
378
  // src/contracts/collector.ts
194
- var import_lucid5 = require("@lucid-evolution/lucid");
379
+ var import_lucid7 = require("@lucid-evolution/lucid");
195
380
 
196
381
  // src/scripts/collector-validator.ts
197
382
  var _collectorValidator = {
@@ -200,22 +385,81 @@ var _collectorValidator = {
200
385
  cborHex: "590e7f590e7c010000323232323232323222323223232322533300a323232533300d3007300f37540022646464646464646464a6466602e60280122646464646464a66603a6034603e6ea80044c8c94ccc07ccc03524012f4d757374207370656e642073696e676c6520636f6c6c6563746f7220696e7075742077697468206f6e6c79204144410032533302400114a02a666048604e00226466ebcc058c090dd5180b18121baa001374c64a666044603e002297adef6c6013232330010014bd6f7b63011299981480089981519bb04c01014000374c00697adef6c60132323232533302930123300e48810000213302e337609801014000374c00e00a2a666052602600426605c66ec13001014000374c00e00626605c66ec0dd48011ba600133006006003375660560066eb8c0a4008c0b4008c0ac004c8cc0040052f5bded8c044a66605000226605266ec13001014000375000697adef6c60132323232533302830113300d48810000213302d337609801014000375000e00a2a666050602400426605a66ec13001014000375000e00626605a66ec0dd48011ba800133006006003375a60540066eb8c0a0008c0b0008c0a8004ccc030dd5980b18121baa30163024375400291100488100302600114a0660166eb0c040c088dd500a919baf301130233754602260466ea8c054c08cdd5000801099806a49364d7573742070726f6475636520636f6c6c6563746f72206f7574707574207769746820696e63726561736564204144412076616c75650033322232330010013300f0045333023302030253754006264466ebcc058c0a0dd5180b18141baa001002302930263754006264466ebcc058c0a0dd5000801181498131baa00322533302800114a0264a66604a64a66604c66ebcc04cc0a4dd5000a60107d87b9fd87980ff00132533302b00114a22a666056605c0022646464a66605460286eb8c0c000c54ccc0a8c05000454ccc0a8c09cc0b0dd526103d87a80001533302a337129000001099b89002482026fb808528099b89480000085280a50375c605e60600046eb4c0b8c0bcc0bc004dd618168008a503233001001323330010013756603a60566ea800cc8cc004004020894ccc0b800452f5bded8c02646606066ec0dd49bae302d001374c64660020026eacc0bc008894ccc0c400452f5bded8c02646606666ec0dd49bae3030001375066e052000375a606200266006006606a00460660026600600660640046060002444a66605c00420022646660080086064006666660240046eb8c0b4004dd59817000911192999817980a8008a60103d87a80001301f33034374c00297ae0323330010010030022225333035002100113233300400430390033333301a002375c60680026eb4c0d4004888c94ccc0d8c0cc0045300103d87a8000130263303b375000297ae03370000400202e606e004020606000444a666058002297ae01323332223233001001003225333032001100313233034374e660686ea4018cc0d0dd49bae30310013303437506eb4c0c80052f5c066006006606c00460680026eb8c0ac004dd5981600099801801981800118170008a50302b00214a226600600600260560026eb0c030c088dd500a99ba548008cc090c03ccc090004cc091300103d87a80004bd7025eb80c94ccc080c069200010011333330070014881003232002323300100100222533302700114984c94ccc0a0004526132325333026302330283754660166eb8c0a0c0b0010dd71814001099802802998158010008a99813a49326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016302c002302a001302a00133025337609810140004c010101004bd6f7b63011119299981218050008a60103d87a80001301433029374c00297ae03333300b0014890048008888c94ccc09cc090004530103d87a8000130173302c375000297ae03370000200401000a6eacc050c088dd5180a18111baa00214a0601e60426ea8c03cc084dd5180998109baa0013023302037540022c660166eb0c034c07cdd500900791299980e99b9000200114c103d87980001533301d3371e0040022980103d87a800014c103d87b80002533301f00114a2294088888c8cc004004018894ccc0900044cc094cdd81ba9006374c00a97adef6c601323232325333024300d3300700a002133029337606ea4028dd30048028a99981219b8f00a002132533302530223027375400226605466ec0dd4805981598141baa001004100433300800a009001133029337606ea4008dd3000998030030019bab3026003375c60480046050004604c00244444646600200200c44a66604600226604866ec0dd48031ba80054bd6f7b630099191919299981198061980380500109981419bb037520146ea002401454ccc08ccdc78050010992999812181098131baa001133029337606ea402cc0a8c09cdd5000802080219980400500480089981419bb037520046ea0004cc01801800cdd698128019bae302300230270023025001375e98103d87980001325333018301200a13233007491334d757374207370656e64207374616b696e67206d616e61676572207769746820446973747269627574652072656465656d65720032533301e00114a02a66603c60420022646466ebc009300103d87b800032533301c30190011323253330223025002149858dd71811800980f9baa0021533301c301600115333020301f37540042930b0a99980e180a8008a999810180f9baa00214985854ccc070cdc3a400c00226464a666044604a0042930b1bad3023001301f37540042a66603866e1d200800115333020301f37540042930b0a99980e19b874802800454ccc080c07cdd50010a4c2c2a66603866e1d200c00115333020301f37540042930b0b180e9baa00132533301b3018301d375400226042603c6ea800454cc071240117436f756c64206e6f742066696e642072656465656d6572001632323300100137566044604660466046604660466046604660466046603e6ea8048894ccc0840045300103d87a8000132323253330203375e00c6044006260206604a00297ae01330050050023022002302500230230013374a90011980f9805980e9baa30200014bd700a50330053758601460386ea803c8cc00cdd59807980e9baa300f301d3754002004601260366ea805c4cccc8c8c8888c8c8c8c8c94ccc08cc080c094dd50008992999812180f18131baa0011323232533302b302e0021323232533302a3027302c3754002266030660206605e6ea4dcc2481084d697373696e6720003302f37526e6003ccc0bcdd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003322323300100100322533303200114a0264a66605e66e3cdd7181a8010020a5113300300300130350013011323300100100a22533303000114bd6f7b6300991919192999818180d001080189981a99bb037520046e98004cc01801800cdd598190019bae303000230340023032001375c6060605a6ea800454cc0accc040cc0bcdd49b98491084d697373696e6720003302f37526e6003ccc0bcdd49b9849010d20757067726164652070617468004bd70249001632533302a3024302c3754002298103d87a80001301a3302f37526eb8c0b4c8cdd81818800981898190009bac3030302d375400297ae032330010013756603e605a6ea800c894ccc0bc0045300103d87a800013232533302d3371e6eb8c0bc0080244c074cc0c8dd399819181780119819181800125eb812f5c026600800800260660046062002a666050604a60546ea80044c8c8c8c94ccc0c0c0cc0084c926323300100100222533303200114984c8cc00c00cc0d8008c8c8dd718198011bae30310013034001163756606200260620046eb4c0bc004c0acdd50008b192999814181098151baa0011302e302b37540022a660529201134e6f7420616e20696e6c696e6520646174756d00163014302a3754603860546ea800458c0b0004c8cc0480188c008c070c0a8dd5000a999812981118139baa4c0103d8798000123300f3756603660526ea800402448cdc4240006660226eacc06cc0a4dd50009bae3017302937540126eb8c06cc0a4dd50049bae302a302737540022c6028604c6ea8c050c098dd5180c18131baa3029302637540022c660226eb0c0a0010054dd598139814181418140011bac3026001302600130213754004446e64c8c8ccc0040040112201002225333024002100113233300400430280035333021301e371a00426e600044cdc500119b8a00537300026e64dd718130011b98001300100122533301e00114bd7009980f980e1810000998010011810800a4909436f6c6c6563746f72003009301b375401e600a60366ea805c88c04cccc010008dd71805180e1baa001375c601c60386ea8004dc7a45002223253330193013301b37540022900009bad301f301c375400264a666032602660366ea8004530103d87a80001323300100137566040603a6ea8008894ccc07c004530103d87a80001323232533301e3371e00e6eb8c08000c4c038cc08cdd4000a5eb804cc014014008dd6981000118118011810800991980080080211299980f0008a6103d87a80001323232533301d3371e00e6eb8c07c00c4c034cc088dd3000a5eb804cc014014008dd5980f8011811001181000091191980080080191299980e0008a5eb804c8c94ccc068c0140084cc07c008cc0100100044cc010010004c080008c0780048c068c06cc06c004894ccc050ccc0500052825115330150021001100122323300100100322533301900114c103d87a80001323253330173375e601060346ea80080144c01ccc0700092f5c0266008008002603a00460360026e9520002301600130103754012602660206ea800458c004c03cdd5001918091809800980818069baa00114984d958c94ccc024c01800454ccc034c030dd50020a4c2c2a66601260060022a66601a60186ea8010526161533300930020011533300d300c37540082930b0b18051baa003370e90021b8748008c94ccc014c008c01c00454ccc024c020004526161637540046e1d20005734ae7155ceaab9e5573eae815d0aba21"
201
386
  };
202
387
 
388
+ // src/helpers/lucid-utils.ts
389
+ var import_lucid6 = require("@lucid-evolution/lucid");
390
+ function getInlineDatumOrThrow(utxo) {
391
+ if (utxo.datum != null) {
392
+ return utxo.datum;
393
+ }
394
+ throw new Error(
395
+ "Expected an inline datum for OutRef: " + JSON.stringify({
396
+ txHash: utxo.txHash,
397
+ outputIndex: utxo.outputIndex
398
+ })
399
+ );
400
+ }
401
+ async function addrDetails(lucid) {
402
+ const addr = await lucid.wallet().address();
403
+ return [(0, import_lucid6.paymentCredentialOf)(addr), (0, import_lucid6.stakeCredentialOf)(addr)];
404
+ }
405
+ function createScriptAddress(network, scriptHash, stakeCredential) {
406
+ return (0, import_lucid6.credentialToAddress)(
407
+ network,
408
+ (0, import_lucid6.scriptHashToCredential)(scriptHash),
409
+ stakeCredential
410
+ );
411
+ }
412
+ async function scriptRef(ref, lucid) {
413
+ const utxos = await lucid.utxosByOutRef([
414
+ { txHash: ref.input.transactionId, outputIndex: ref.input.index }
415
+ ]);
416
+ if (utxos.length === 0) throw Error("Unable to locate script ref.");
417
+ return utxos[0];
418
+ }
419
+ function balance(utxos) {
420
+ return utxos.reduce((acc, utxo) => (0, import_lucid6.addAssets)(acc, utxo.assets), {});
421
+ }
422
+
423
+ // src/helpers/helpers.ts
424
+ var fs = __toESM(require("fs"));
425
+ var import_ts_pattern2 = require("ts-pattern");
426
+ function matchSingle(xs, mkErr) {
427
+ return (0, import_ts_pattern2.match)(xs).with([import_ts_pattern2.P.select()], (res) => res).otherwise(() => {
428
+ throw mkErr(xs);
429
+ });
430
+ }
431
+ function calculateFeeFromPercentage(percent, amount) {
432
+ if (amount <= 0n) return 0n;
433
+ const a = amount * percent / 1000000n;
434
+ const b = BigInt(1e8);
435
+ return a * 1000000n / b;
436
+ }
437
+ function loadSystemParamsFromFile(file) {
438
+ return JSON.parse(fs.readFileSync(file, "utf-8"));
439
+ }
440
+ function loadSystemParamsFromUrl(url) {
441
+ return fetch(url).then((res) => res.json()).then((data) => data);
442
+ }
443
+ var getRandomElement = (arr) => arr.length ? arr[Math.floor(Math.random() * arr.length)] : void 0;
444
+
203
445
  // src/contracts/collector.ts
204
446
  var CollectorContract = class _CollectorContract {
205
447
  static async feeTx(fee, lucid, params, tx, collectorRef) {
206
- const collectorUtxo = collectorRef ? getRandomElement(await lucid.utxosByOutRef([collectorRef])) : getRandomElement(await lucid.utxosAt(
207
- _CollectorContract.address(params.collectorParams, lucid)
208
- ));
448
+ const collectorUtxo = collectorRef ? getRandomElement(await lucid.utxosByOutRef([collectorRef])) : getRandomElement(
449
+ await lucid.utxosAt(
450
+ _CollectorContract.address(params.collectorParams, lucid)
451
+ )
452
+ );
209
453
  const collectorScriptRefUtxo = await _CollectorContract.scriptRef(
210
454
  params.scriptReferences,
211
455
  lucid
212
456
  );
213
- tx.collectFrom([collectorUtxo], import_lucid5.Data.to(new import_lucid5.Constr(0, []))).pay.ToContract(
457
+ tx.collectFrom([collectorUtxo], import_lucid7.Data.to(new import_lucid7.Constr(0, []))).pay.ToContract(
214
458
  collectorUtxo.address,
215
- { kind: "inline", value: import_lucid5.Data.to(new import_lucid5.Constr(0, [])) },
459
+ { kind: "inline", value: import_lucid7.Data.to(new import_lucid7.Constr(0, [])) },
216
460
  {
217
461
  ...collectorUtxo.assets,
218
- lovelace: collectorUtxo.assets["lovelace"] + fee
462
+ lovelace: collectorUtxo.assets.lovelace + fee
219
463
  }
220
464
  ).readFrom([collectorScriptRefUtxo]);
221
465
  }
@@ -223,139 +467,39 @@ var CollectorContract = class _CollectorContract {
223
467
  static validator(params) {
224
468
  return {
225
469
  type: "PlutusV2",
226
- script: (0, import_lucid5.applyParamsToScript)(_collectorValidator.cborHex, [
227
- new import_lucid5.Constr(0, [
228
- new import_lucid5.Constr(0, [
470
+ script: (0, import_lucid7.applyParamsToScript)(_collectorValidator.cborHex, [
471
+ new import_lucid7.Constr(0, [
472
+ new import_lucid7.Constr(0, [
229
473
  params.stakingManagerNFT[0].unCurrencySymbol,
230
- (0, import_lucid5.fromText)(params.stakingManagerNFT[1].unTokenName)
474
+ (0, import_lucid7.fromText)(params.stakingManagerNFT[1].unTokenName)
231
475
  ]),
232
- new import_lucid5.Constr(0, [
476
+ new import_lucid7.Constr(0, [
233
477
  params.stakingToken[0].unCurrencySymbol,
234
- (0, import_lucid5.fromText)(params.stakingToken[1].unTokenName)
478
+ (0, import_lucid7.fromText)(params.stakingToken[1].unTokenName)
235
479
  ]),
236
- new import_lucid5.Constr(0, [
480
+ new import_lucid7.Constr(0, [
237
481
  params.versionRecordToken[0].unCurrencySymbol,
238
- (0, import_lucid5.fromText)(params.versionRecordToken[1].unTokenName)
482
+ (0, import_lucid7.fromText)(params.versionRecordToken[1].unTokenName)
239
483
  ])
240
484
  ])
241
485
  ])
242
486
  };
243
487
  }
244
488
  static validatorHash(params) {
245
- return (0, import_lucid5.validatorToScriptHash)(_CollectorContract.validator(params));
489
+ return (0, import_lucid7.validatorToScriptHash)(_CollectorContract.validator(params));
246
490
  }
247
491
  static address(params, lucid) {
248
492
  const network = lucid.config().network;
249
493
  if (!network) {
250
494
  throw new Error("Network configuration is undefined");
251
495
  }
252
- return (0, import_lucid5.validatorToAddress)(network, _CollectorContract.validator(params));
496
+ return (0, import_lucid7.validatorToAddress)(network, _CollectorContract.validator(params));
253
497
  }
254
498
  static async scriptRef(params, lucid) {
255
499
  return scriptRef(params.collectorValidatorRef, lucid);
256
500
  }
257
501
  };
258
502
 
259
- // src/contracts/interest-oracle.ts
260
- var import_lucid6 = require("@lucid-evolution/lucid");
261
-
262
- // src/helpers/time-helpers.ts
263
- var oneHour = 3600000n;
264
- var oneDay = 86400000n;
265
- var oneYear = 31536000000n;
266
-
267
- // src/contracts/interest-oracle.ts
268
- var unitaryInterestPrecision = 1000000000000000000n;
269
- var decimalUnit = 1000000n;
270
- var InterestOracleContract = class _InterestOracleContract {
271
- static decodeInterestOracleDatum(datum) {
272
- const oracleDatum = import_lucid6.Data.from(datum);
273
- if (oracleDatum.index != 0 || oracleDatum.fields.length !== 3 || oracleDatum.fields[1].index !== 0)
274
- throw "Invalid Interest Oracle Datum provided.";
275
- return {
276
- unitaryInterest: oracleDatum.fields[0],
277
- interestRate: oracleDatum.fields[1].fields[0],
278
- lastUpdated: oracleDatum.fields[2]
279
- };
280
- }
281
- static encodeInterestOracleDatum(datum) {
282
- return import_lucid6.Data.to(
283
- new import_lucid6.Constr(0, [
284
- datum.unitaryInterest,
285
- new import_lucid6.Constr(0, [datum.interestRate]),
286
- datum.lastUpdated
287
- ])
288
- );
289
- }
290
- static calculateUnitaryInterestSinceOracleLastUpdated(now, oracleDatum) {
291
- return _InterestOracleContract.calculateUnitaryInterest(now - oracleDatum.lastUpdated, oracleDatum.interestRate);
292
- }
293
- static calculateUnitaryInterest(timePeriod, interestRate) {
294
- return timePeriod * interestRate * unitaryInterestPrecision / oneYear / decimalUnit;
295
- }
296
- static calculateAccruedInterest(now, unitaryInterestSnapshot, mintedAmount, interestLastSettled, interestOracleDatum) {
297
- if (interestOracleDatum.unitaryInterest >= unitaryInterestSnapshot) {
298
- const interestFromPreviousRates = (interestOracleDatum.unitaryInterest - unitaryInterestSnapshot) * mintedAmount / unitaryInterestPrecision;
299
- const lastRateInterest = (now - interestOracleDatum.lastUpdated) * interestOracleDatum.interestRate * mintedAmount / oneYear / decimalUnit;
300
- return interestFromPreviousRates + lastRateInterest;
301
- } else {
302
- return (now - interestLastSettled) * interestOracleDatum.interestRate * mintedAmount / oneYear / decimalUnit;
303
- }
304
- }
305
- };
306
-
307
- // src/contracts/gov.ts
308
- var import_lucid7 = require("@lucid-evolution/lucid");
309
- var GovContract = class {
310
- static decodeGovDatum(datum) {
311
- const d = import_lucid7.Data.from(datum);
312
- if (d.index !== 0 || d.fields.length !== 6 || d.fields[1].fields.length !== 10)
313
- throw "Invalid GovDatum found";
314
- return {
315
- currentProposal: d.fields[0],
316
- protocolParams: {
317
- proposalDeposit: d.fields[1].fields[0],
318
- votingPeriod: d.fields[1].fields[1],
319
- effectiveDelay: d.fields[1].fields[2],
320
- expirationPeriod: d.fields[1].fields[3],
321
- collateralFeePercentage: d.fields[1].fields[4].fields[0],
322
- proposingPeriod: d.fields[1].fields[5],
323
- totalShards: d.fields[1].fields[6],
324
- minimumQuorum: d.fields[1].fields[7],
325
- maxTreasuryLovelaceSpend: d.fields[1].fields[8],
326
- maxTreasuryIndySpend: d.fields[1].fields[9]
327
- },
328
- currentVersion: d.fields[2],
329
- iassetsCount: d.fields[3],
330
- activeProposals: d.fields[4],
331
- treasuryIndyWithdrawnAmt: d.fields[5]
332
- };
333
- }
334
- static encodeGovDatum(datum) {
335
- return import_lucid7.Data.to(
336
- new import_lucid7.Constr(0, [
337
- datum.currentProposal,
338
- new import_lucid7.Constr(0, [
339
- datum.protocolParams.proposalDeposit,
340
- datum.protocolParams.votingPeriod,
341
- datum.protocolParams.effectiveDelay,
342
- datum.protocolParams.expirationPeriod,
343
- new import_lucid7.Constr(0, [datum.protocolParams.collateralFeePercentage]),
344
- datum.protocolParams.proposingPeriod,
345
- datum.protocolParams.totalShards,
346
- datum.protocolParams.minimumQuorum,
347
- datum.protocolParams.maxTreasuryLovelaceSpend,
348
- datum.protocolParams.maxTreasuryIndySpend
349
- ]),
350
- datum.currentVersion,
351
- datum.iassetsCount,
352
- datum.activeProposals,
353
- datum.treasuryIndyWithdrawnAmt
354
- ])
355
- );
356
- }
357
- };
358
-
359
503
  // src/contracts/treasury.ts
360
504
  var import_lucid8 = require("@lucid-evolution/lucid");
361
505
 
@@ -369,9 +513,11 @@ var _treasuryValidator = {
369
513
  // src/contracts/treasury.ts
370
514
  var TreasuryContract = class _TreasuryContract {
371
515
  static async feeTx(fee, lucid, params, tx, treasuryRef) {
372
- const treasuryUtxo = treasuryRef ? getRandomElement(await lucid.utxosByOutRef([treasuryRef])) : getRandomElement(await lucid.utxosAt(
373
- _TreasuryContract.address(params.treasuryParams, lucid)
374
- ));
516
+ const treasuryUtxo = treasuryRef ? getRandomElement(await lucid.utxosByOutRef([treasuryRef])) : getRandomElement(
517
+ await lucid.utxosAt(
518
+ _TreasuryContract.address(params.treasuryParams, lucid)
519
+ )
520
+ );
375
521
  const treasuryScriptRefUtxo = await _TreasuryContract.scriptRef(
376
522
  params.scriptReferences,
377
523
  lucid
@@ -418,28 +564,20 @@ var TreasuryContract = class _TreasuryContract {
418
564
  if (!network) {
419
565
  throw new Error("Network configuration is undefined");
420
566
  }
421
- return (0, import_lucid8.validatorToAddress)(network, _TreasuryContract.validator(params), params.treasuryUtxosStakeCredential ? { type: "Script", hash: params.treasuryUtxosStakeCredential.contents.contents } : void 0);
567
+ return (0, import_lucid8.validatorToAddress)(
568
+ network,
569
+ _TreasuryContract.validator(params),
570
+ params.treasuryUtxosStakeCredential ? {
571
+ type: "Script",
572
+ hash: params.treasuryUtxosStakeCredential.contents.contents
573
+ } : void 0
574
+ );
422
575
  }
423
576
  static async scriptRef(params, lucid) {
424
577
  return scriptRef(params.treasuryValidatorRef, lucid);
425
578
  }
426
579
  };
427
580
 
428
- // src/helpers/helpers.ts
429
- var fs = __toESM(require("fs"));
430
- function calculateFeeFromPercentage(percent, amount) {
431
- if (amount <= 0n) return 0n;
432
- const a = amount * percent / 1000000n;
433
- const b = BigInt(1e8);
434
- return a * 1000000n / b;
435
- }
436
- function loadSystemParamsFromFile(file) {
437
- return JSON.parse(fs.readFileSync(file, "utf-8"));
438
- }
439
- function loadSystemParamsFromUrl(url) {
440
- return fetch(url).then((res) => res.json()).then((data) => data);
441
- }
442
-
443
581
  // src/scripts/cdp-validator.ts
444
582
  var _cdpValidator = {
445
583
  type: "PlutusV2",
@@ -447,61 +585,215 @@ var _cdpValidator = {
447
585
  cborHex: "593a8e593a8b010000323232323232323222323232323232323223232323232322533301332323253330163011301837540022646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464646464a6464646660b660b008826464646464a6660c000c264646464646464a6660ce60c860d26ea80044c8c94ccc1a4c198c1acdd5000899192999835983418369baa001132323232325333074307700213232533307630790021325333073306e3075375400226464a6660f260f800426464646464646464a6660fa660c492010f4261642074782076616c6964697479003302f305930800137540d26605c66e04084dd6981a1840009baa07c337000426eb4c0d0c20004dd503e0a99983e9983124811942616420696e707574206265696e672076616c6964617465640030253065308001375401c2a6660fa660c492010e4d697865642076657273696f6e73003375e60ca6100026ea8058c194c20004dd518329840009baa305c30800137540182a6660fa660c49211754582069736e74207369676e6564206279206f776e657200330280690141533307d3306249010d4d696e742069732077726f6e67003375e6e98018dd319982e9bae305c30800137540f86eb8c170c20004dd500e80f8a99983e998312481104261642069417373657420696e707574003371e6eb8c194c20004dd50049bae305c308001375403a2a6660fa660c49210e42616420434450206f7574707574003333304a018304c33082010164bd70181219841009832198410098321984100983219841009ba90144bd701984100982e1840009baa01d33082013750002661040260c866104026ea0084cc20804dd419b80375a60ca6100026ea801ccc0ac08401d2f5c097ae04bd7025eb80cc124c16cc194c20004dd503e00126103d87980001533307d330624911357726f6e6720706169642074726561737572790033333047375860a06100026ea81a406cdd598231840009baa069375c608a6100026ea81f0dd6982e1840009baa0031533307d533307d00513232533307f33064490115556e646572636f6c6c61746572697a65642043445000333302f004003006302930820137540162660c89211757726f6e67207061696420746f20636f6c6c6563746f72003333304601a01d375660906104026ea81acdd718229841009baa07e3370066e00008004dd698339841009baa00514a06606c60886102026ea8028dd698331840809baa3303a30653308301375004097ae00053303533026019302930800137540f860aa03c2660c492011b57726f6e67207061696420636f6c6c6563746f7220696e74727374003333304401801b3756608c6100026ea81a4dd718219840009baa07c375a60ca6100026ea800c54ccc1f4cc189241164e6f6e706f736974697665206d696e74656420616d740030480011533307d3306249011a43616e2774206d696e742064656c69737465642069417373657400533307d533307d3078307f375460b86100026ea80245288a5014a2266e2407d20001330624911a636f6c6c61746572616c203c206d696e436f6c6c61746572616c00337126eb4c118c20004dd503e0010a5014a029405280a5014a029405280a5014a02940cdc01bad304f307f375403803c66e04cdc0181f9bab305a307e375460b460fc6ea8030070c0c0004c94ccc1ecc1180044cc0c4dd69831983f1baa3303700230623308001375000297ae000714c0106d8799f0000ff003333303701e00d375a609a60fa6ea80680380114ccc1e40044ccc0a0c160c1f0dd500280a982a983e1baa0651330373058307c375400a02aa6660f0608603429444cdc400ca400060b46eacc084c1e8dd50319981b0091824983c9baa002306d00116307a001307637540022c6066608a60ea6ea8c144c1d4dd50008b183b800999819006182198399baa06f4c0103d879800016307500133303000c3056307137540da98103d8798000375a60e660e80046eb4c1c8004c1b8dd50008b182398369baa00a375c60de60d86ea800458c140c1acdd5004182798351baa3046306a375460da60d46ea800458cc130010140dd6183598360011bac306a001306a002375860d000260c86ea8134c198c18cdd502f0a50375a60ca60cc0046eb4c190004c190008dd69831000982f1baa0501533305b3056044132533305c002132323232323232533306330603065375400226464a6660ca60c460ce6ea80044c8c94ccc19cc190c1a4dd50008991919191929998381839801099192999839183a801099192999838183598391baa0011323253330763079002132325333074330594910f4261642074782076616c696469747900330263050307737540c06604a66e04064dd69815983b9baa073337000326eb4c0acc1dcdd50398a99983a1982ca4811357726f6e672070616964207472656173757279003333303e3758608e60ee6ea8180058dd5981e983b9baa060375c607860ee6ea81ccdd69829983b9baa001153330743305949011942616420696e707574206265696e672076616c69646174656400301c305c307737540122a6660e8660b292010e4d697865642076657273696f6e73003375e02260b860ee6ea8c170c1dcdd51829983b9baa00715333074330594911754582069736e74207369676e6564206279206f776e6572003301f06000f15333074330594901154275726e65642076616c75652069732077726f6e67003375e6e98c15cdd5980f183b9baa060374c666608a609660a460b860ee6ea81ccdd71829983b9baa073375c60a660ee6ea8060c130dd69823983b9baa01813305949011457726f6e67207061696420636f6c6c6563746f72003333303b0130163756607a60ee6ea8180dd7181d183b9baa07333700660586603a028604060ee6ea81cccdc080318148009bad305c3077375400229405280a5014a0294052819299983a181f8008998151bad305c30773754660606606460a660ee6ea800c050c16ccc1e4dd4000a5eb8000c5300106d8799f0000ff003333303001800a375a608c60ec6ea805c02ccc0cc04cc118c1d8dd500118350008b183b80098399baa001163030304230723754609c60e46ea8008c0c8dd5982698389baa304d307137540062c60e600266605c018607e60de6ea81ad30103d879800016307100133302c00c3052306d37540d298103d8798000375a60de60e00046eb4c1b8004c1a8dd50008b182198349baa00a375c60d660d06ea800458c130c19cdd5004182598331baa304b30663754608460cc6ea8c1a4c198dd50008b198240020261bac30673068002375860cc00260cc0046eb0c190004c180dd50249831182f9baa05a14a06eb4c184c178dd502809919299982e9828823099299982f002099911919191919192999833183198341baa0011323253330683065306a375400226464a6660d460ce60d86ea80044c8c8c8c8c94ccc1ccc1d80084c8c94ccc1d4c1e00084c94ccc1c8c1b4c1d0dd500089919299983c183d801099191919191919191919191929998400099832a490f4261642074782076616c69646974790033032305c30830137540d86606266e0408cdd6981b9841809baa07f337000466eb4c0dcc20c04dd503f8a9998400099832a4811942616420696e707574206265696e672076616c696461746564003028306830830137540242a66610002660ca92010e4d697865642076657273696f6e73003375e60d06106026ea8068c1a0c20c04dd518341841809baa305f30830137540202a66610002660ca9211643522068617320746f20626520756e64657220524d5200333080013333030007375a60a66106026ea8084024c174c20c04dd5006a504a22a66610002660ca9211a43522068617320746f206265206174206c656173742031303025003333030007375a60a66106026ea8084024c19ccc21404dd401ca5eb8054ccc20004cc19524010d4d696e742069732077726f6e67003375e6e98028dd31998301bae305f30830137540fe6eb8c17cc20c04dd5010982c0028a9998400099832a4811242616420726564656d7074696f6e20616d7400533308001304b00513371200a00c294054ccc20004cc1952410e42616420434450206f7574707574003333304d01c304f330850101a4bd70181399842809833998428098339984280983399842809ba90184bd701984280982f9841809baa021330850137500066610a0260ce6610a026ea008ccc21404dd419b80375a60d06106026ea802ccc0b808c02d2f5c097ae04bd7025eb80cc130c178c1a0c20c04dd503f800a6103d87980001533308001330654911357726f6e672070616964207472656173757279003333304a375860a66106026ea81b007cdd598249841809baa06c375c60906106026ea81fcdd6982f9841809baa00815333080013306549011457726f6e67207061696420636f6c6c6563746f72003333304701c01f375660926106026ea81b0dd718231841809baa07f3370066e00dd698341841809baa008330383022308301375401a004a6661000200826eb4c088c20c04dd503f8a40002a66610002660ca92011a636f6c6c61746572616c203c206d696e436f6c6c61746572616c00337126eb4c124c20c04dd503f800899832a481164e6f6e706f736974697665206d696e74656420616d7400304b00314a029405280a5014a029405280a5014a0294052819b803370200c0026606e60906104026ea8030004dd698331840809baa3303a30653308301375000697ae0007337026eb4c140c20004dd500f00119b880010023053333040005375c60b460fc6ea81e8dd7182d183f1baa01c33223020330363302130633308101375060a86eb4c190c1fcdd51981b183199840809ba830370034bd70002a5eb80cc0d8cc0e0004c18ccc20404dd4181b80125eb80c18ccc20404dd401aa5eb80c18ccc20404dd419b81375a60c860fe6ea8cc0d8004c18ccc20404dd401aa5eb80dd69832183f9baa4c109d8799f1a000f4240ff004bd701bad304d307d375403660ae60fa6ea801ccdc0981e9bab3058307c375460b060f86ea802cc0b8004c94ccc1e4c1100044cc0bcdd69830983e1baa3303500230603307e375000297ae000614c106d8799f0000ff003333303501b00c375a609660f66ea806403400cccc098c158c1e8dd500200a1829983d1baa06330593756604060f26ea8188cc0d4048c120c1e0dd500118360008b183c800983a9baa00116303230443074375460a060e86ea800458c1d8004ccc0c4030c108c1c8dd5037260103d879800016307400133302f00c3055307037540d898103d8798000375a60e460e60046eb4c1c4004c1b4dd50008b182318361baa00a375c60dc60d66ea800458c13cc1a8dd5004182718349baa30453069375460d860d26ea800458cc12c01013cdd6183518358011bac30690013069002375860ce00260c66ea81308c194c198c198c198c198c198c198c198c198c198c198004c190c184dd502e0a50375a60c660c06ea81484c94ccc178c14411c4c94ccc17c0144cc88c8c8c8c94ccc194c188c19cdd5000899192999833983218349baa00113232323232533307030730021323253330723075002132533306f306a3071375400226464a6660ea60f000426464646464a6660ec660b69210f4261642074782076616c696469747900330283052307937540c46604e66e04060dd69816983c9baa075337000306eb4c0b4c1e4dd503a8a99983b1982da4811942616420696e707574206265696e672076616c69646174656400301e305e307937540162a6660ec660b692010e4d697865642076657273696f6e73003375e02260bc60f26ea8c178c1e4dd5182a983c9baa009153330763305b4911543445020697320616c72656164792066726f7a656e00533307630733078375460bc60f26ea80585288a50153330763305b4901104261642069417373657420696e707574003371e6eb8c178c1e4dd50031bae30553079375402c2a6660ec660b69210a43616e2774206d696e74003375e6e98c164dd59810183c9baa0624c101a000153330763305b4911a434450207374696c6c206f766572636f6c6c61746572697a6564003330763333026002375a609260f26ea8058010c064c1e4dd50032504a22660b692010e42616420434450206f757470757400333330433758609260f26ea8188c114cc1ecc174cc1ec044cc1ed30103d87a80004bd7025eb80c074cc1ecc174cc1ecc174cc1ed300103d87a80003307b30553079375402c660f6609260f26ea8058cc1ecc114cc1ecc154c1e4dd50019983d9ba8337000026eb4c178c1e4dd5001a5eb812f5c097ae04bd701bab30553079375460aa60f26ea802d30103d879800014a029405280a5014a029405281980b198169828983c1baa005375a60ba60f06ea8cc0c4c170cc1e8c120c1e0dd500aa5eb8000ccc0b4c144c1e0dd500280099b813038375660a660ee6ea8c14cc1dcdd500498148009919299983a98200008998159980b0011bad305d307837546606200660b8660f46ea00052f5c000a298106d8799f0000ff003333303101600b375a608e60ee6ea8050030cc0d0044c11cc1dcdd500219299983a19b89375a60b860ee6ea800520001480004c060004cc060c168cc1e0dd41817181b9bab30523076375460a460ec6ea80212f5c06605e60b4660f06ea0c0b8c12cdd69823183b1baa0134bd70000998181828983a9baa00200f3069001163076001307237540022c605e608260e26ea8c134c1c4dd50008b1839800999817004981f98379baa06b4c103d879800016307100133302c0083052306d37540d298103d8798000375a60de60e00046eb4c1b8004c1a8dd50008b182198349baa006304d30683754609a60d06ea8c110c1a0dd5183598341baa001163304a00204e375860d260d40046eb0c1a0004c190dd502691299983099b88001002100110023065306237540ba2940dd6983218309baa053132533305f30510481533305f00513322325333062305f30643754002264646464a6660d460da6eb0c1a00084c8c8c8c8c8c8c94ccc1b4cc14924011a4174206c656173742031206f746865722043445020696e7075740033306d533307100814a22941282511533306d3305249012743445020696e70757473206d75737420757365204d65726765417578696c696172792072646d72003300e008232323375e00466e95200a3307505a4bd70182f8009981e182b18389baa0013756606e60e26ea816854ccc1b4cc14924012943445020696e70757473206d7573742062652066726f7a656e20776974682073616d65206173736574003300e00a232325333070306d3072375400426464a6660e4602860f0004266e3c0040485281bae307730780013073375460ec60e66ea800852818330009817982098389baa304d307137540022a6660da660a4921074e6f206d696e74003375e6e98c140dd5980b98381baa0594c101a00013305249010e42616420434450206f7574707574003333303a3758608060e06ea8164c0f0cc1c8c150cc1c802ccc1c930103d87a80004bd7025eb80c050cc1c8c150cc1c8c150cc1c9300103d87a800033072375201a660e46ea0010cc1c8c0f0cc1c8dd4001198391ba80014bd7025eb812f5c097ae00064c0103d87a800014a029405280a50375a60e460e60046eb4c1c4004c1c4008dd6983780098378011bab306d001323300100100422533306c00114bd70901a00081010000810100008101000009991191919191919192999838983718399baa001132325333077307a0021533307330703075375400226464646464646464a6660fe610402004264a6660f860ee60fc6ea80084c8c8c8c94ccc21004c21c040084cc21404dd31982b00b1bab305f308301375460be6106026ea8060cc21404dd419b800140083308501375066e0004800ccc21404dd419b800110014bd700b1bad308501001308501002375a61060200260fe6ea800858c1d401c58c20004004c20004008dd6983f000983f0011bae307c001307c002307a001307637540022c2c60f000260e86ea800458c0c4c10cc1ccdd5182798399baa008375a60ea60ec0046eb4c1d0004c1d0008dd6983900098390011bab3070001306e00133002002306f00116375860d0002646600200200444a6660d4002297bdb180101800001018000132323232533306a30123052306d3754008266ec0dd3998378020011ba70011337606e9c008dd3998378020009bac306c002375860d40026600600660dc00460d800266604a6eb0c12cc198dd5027982598331baa0624c0103d87a8000304a30653754609460ca6ea8c104c194dd5183418329baa00116330473758609260c86ea813412c88c8cc00400400c894ccc19c0045288992999832180218350010998018018008a50306a001375c60ca60cc60c46ea8c194c188dd502e8a501533305f30500481325333060006132325333062305f30643754002264a6660c6660909212b546865206d61696e206d65726765205554584f206973207573696e67204d65726765434450732072646d720032323375e004980103d87d80003054001330310043756605860cc6ea813c4cc1212401256d65726765205554584f20636f6d65732066726f6d207468652073616d65207363726970740033038003253330643375e00a609860ce6ea80044cdd7982618339baa304c30673754608660ce6ea80040085280a50304a30653754609460ca6ea8c104c194dd5183418329baa001163304700104b375860cc60c66ea8130528183298311baa05413253330603370e90060248a99983000309991191919192999833183198341baa0011323253330683063306a375400226464646464a6660e260e80042646464a6660e860ee004264646464a6660e8660b29211942616420696e707574206265696e672076616c69646174656400301c305c307737540102a6660e8660b292011357726f6e672070616964207472656173757279003333303e3758608e60ee6ea8180044dd5981e983b9baa060375c607860ee6ea81cc02c54ccc1d0cc1652411457726f6e67207061696420636f6c6c6563746f72003333303b0100113756607a60ee6ea8180dd7181d183b9baa07300a153330743305949116434450206e6565647320746f2062652066726f7a656e003016305c307737540262a6660e8660b292010e57726f6e6720535020746f6b656e0033037375660a660ee6ea8c14cc1dcdd50039828983b9baa073153330740021323253330763305b49010e42616420434450206f7574707574003333304301230453307b0104bd70180e9983d982e9983d982e9983d982f183c9baa0153307b30553079375402a660f66ea0cdc01bad30493079375402a00a660f6980106d87a9f0000ff004bd7025eb812f5c066084006609c00498103d8798000153330763305b49113426164205350206f75747075742076616c7565003375e60aa60f26ea801cdd31999823998210008011bae3055307937540ea6eb8c154c1e4dd500a80289982da491b4d757374206275726e20616c6c206941737365747320696e205350003375e6e98018dd318269980b000982e9983d982a983c9baa0753307b30553079375402a97ae014a02940dd5982a183c1baa30543078375401066e0ccdc1181c00098260019bad3047307737540262a6660e8660b2921374d757374206275726e20616c6c206d696e74656420694173736574732026206175746820746f6b656e7320696e2063647020696e707574003375e6e98010dd3199982298259980a000982e183b9baa073375c60a660ee6ea81ccdd71829983b9baa013304c375a608e60ee6ea804c4cc16524113426164205350206f75747075742076616c7565003375e60a660ee6ea8014dd31999822998201bab30533077375460a660ee6ea801cc0e0004dd71829983b9baa073375c60a660ee6ea804cc130dd69823983b9baa01314a029405280a5014a02940cc0fccc0fcdd59829183b1baa30523076375400e6096014609601266e20c128004dd69822983a9baa011333036001375c60a060e86ea81c0dd71828183a1baa01030533756603460e66ea817058c1d4004cc108028c100c0f4cc1ccc154cc1ccc0f4cc1ccc128c1c4dd5036a5eb80cc1cd30103d87a80004bd7025eb80c94ccc1c800454cc1bd2401144f6e6520535020696e70757420616c6c6f776564001615333072307500113074001153306f4901144f6e6520535020696e70757420616c6c6f77656400163303d00a303c330723049307037540d897ae016307200133302d0083053306e37540d4980103d87a8000375a60e060e20046eb4c1bc004c1acdd50008b182218351baa006304e30693754608a60d26ea8c1b0c1a4dd50008b198258010279bac306a306b306b002375860d200260ca6ea813888ccc108dd7182518329baa001375c608260ca6ea8004cc00c008004c198c18cdd502f0a50153330603370e90070248a999830182d98311baa05e132533306133046491125370656e642031207570677261646520746b00305c332232330010010032253330690011480004cdc0198010011836000998031bab304430683754608860d06ea8c1ac00400cdd6182498321baa04d3004306437540c026608c921354d757374206275726e207570677261646520746b2c206f7074696f6e616c6c79206d696e74206941737365742026206974732053500053330613375e6e98004dd3181c181f980218321baa06014a2266ebcdd30009ba63303733037303f303e306437540c0607e606860c86ea8180c0e0c0fcc010c190dd50300a5030433756601460c66ea81305280999919191119191919192999835183398361baa001132533306b3066306d37540022646464a6660e460ea0042646464a6660e260dc60e66ea80044cc158cc03ccc1d8dd49b984901084d697373696e6720003307637526e60038cc1d8dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003301e30103054009375c60ee60e86ea800454cc1c8cc03ccc1d8dd49b98491084d697373696e6720003307637526e60038cc1d8dd49b9849010d20757067726164652070617468004bd702490016325333071306c30733754002298103d87a8000130583307637526eb8c1d0c8cdd8183c000983c183c8009bac30773074375400297ae03233001001375660a060e86ea800c894ccc1d80045300103d87a80001323253330743371e6eb8c1d80080244c16ccc1e4dd39983c983b0011983c983b80125eb812f5c026600800800260f400460f0002a6660de60d860e26ea80044c8c8c8c94ccc1dcc1e80084c926323300100100222533307900114984c8cc00c00cc1f4008c8c8dd7183d0011bae3078001307b00116375660f000260f00046eb4c1d8004c1c8dd50008b1817982098389baa304d307137540022c60e600266605c00a01098103d8798000375c60e260dc6ea800458c148c1b4dd5182918369baa3049306d375460e060da6ea800458cc13cdd618378020299bab306e306f306f306f002375860da00260da00260d06ea814488dcc9919199800800802244100222533306c0021001132333004004307000353330693066371a00426e600044cdc500119b8a00537300026e64dd718370011b98001300100122533306600114bd7009983398321834000998010011834800a490343445000300a306337540be4466604c0046eb8c124c190dd50009bae3040306437540024a6660be60b860c26ea80045280a512306430653065306530653065001232533305e3371060320026eb4c118c184dd5001099b80001480084004cdc19bad304530603754002904044bd111822198311ba8337006eb4c114c180dd50011bad30453060375400297ae03057305c37540b06e952004375e08444600660b86ea8c0e0c170dd51919299982f983100109919001299982e182c982f1baa0011323232323232323232323232533306c306f0021324994ccc1a0c194c1a8dd50048991919191919191919191919191919191919191929998400098418080109924c60ea0162c6eb4c20404004c20404008dd6983f800983f8011bad307d001307d002375a60f600260f60046eb4c1e4004c1e4008c1dc004c1dc008dd6983a800983a8011bad30730013073002375a60e200260e20046eb4c1bc004c1acdd50048b0b1bad306d001306d002375a60d600260d60046eb4c1a4004c1a4008dd698338009833801183280098328011bad3063001305f37540022c6038605c60bc6ea8c0e8c178dd50008b183000099980d801000a60103d87980002305d305e305e305e305e00122330043758600660b46ea80080048c16cc170c170c170c170c170c170c170c17000488c8cc00400400c894ccc16c004528099299982c19b8f375c60bc00400829444cc00c00c004c178004894ccc150cdc41bad302730573754002004266e0ccdc199b823370466e04008dd69813982b9baa001375a607860ae6ea8c0ccc15cdd5000a41010141ede959b7c03690405844fdf500a410112f42a660aa921254d75737420686f6c643a206e6f77203e206c61737420696e7465726573742075706461746500162225333054305130563754006260b460ae6ea800c4c94ccc154c94ccc158c144c160dd5000899b89375a606a60b26ea8008dd6982e182c9baa0011533057490124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e67650016303d30583754606860b06ea800854cc1592401174f7261636c652063616e2774206265206578706972656400161303d305837540026602600460b460ae6ea800c8888cdc49bad303c3057375466020660200026076660b26ea0c03c00d2f5c00046eb4c0f0c15cdd519808181d9982c9ba8300f0044bd70181d9982c9ba800d4bd7011181c1982b181c1982b18101982b1ba80024bd701982b199828a514c103d87a80004c0103d87980004bd701982b181c1982b18101982b1ba80014bd701982b199828a514c0103d87a80004c0103d87980004bd7025eb8088c8c94ccc148c94ccc14cc11c0045288a99982998270008a5114a060a86ea8cc014c0e8c154dd5001181d182a9baa0011325333053305000114a22a6660a6609c0022944528182a1baa33005303130553754004606260aa6ea8004528180280118020011119299982818268008a999828182698291baa00214c103d87a800014c103d879800015333050304400115333050304430523754004298103d87a800014c103d87b8000132325333052304d001132533305333710006002298103d879800015333053337100020062980103d87b800014c103d87a8000375a60b060aa6ea801054ccc148c13c004530103d87b800014c103d8798000305337540066eb4c158c14cdd500198289baa002230343305232533304e304930503754002264a66609e64a6660a860a60022a6660a0609660a4002294454ccc140c134c1480045280b0b1baa302e30523754606e60a46ea800c4c078cc150dd4000a5eb804c078cc150dd419b80001480092f5c06eb4c150c144dd50008800981a98281baa303530503754002660a464a66609c609260a06ea80044c94ccc13cc94ccc150c14c00454ccc140c12cc1480045288a999828182698290008a5016163754605c60a46ea8c0b8c148dd50018980f1982a1ba80014bd700980f1982a1ba8337000029000a5eb80dd6982a18289baa0011001303530503754605860a06ea80052f5c0466e00dd6981a18279baa001375a6056609e6ea800488c8c0d0cc148dd4000998291ba83370200600297ae0330043003304f3754002004460a060a260a260a260a260a260a260a260a260a260a260a200244a66609466e2400520001480004dd6981918269baa330043300630313304f375000297ae000230313304f375000697ae03002483200488c0bccc134dd419b833003375a606060966ea8008dd6981818259baa0014bd701b824820225e888c0b4cc12cdd419b83337046eb4c0b8c124dd50011bad302e30493754002904044bd25eb80888894ccc120cdc48021bad3030304b37540022a66609066e20dd6980d98259baa00100513370066e0ccdc119b81375a606060966ea800401000d208080a0f6f4acdbe01b3370666e0ccdc119b823370200a6eb4c06cc12cdd50009bad3030304b3754604e60966ea800400d2080b089fbea014820225e854cc1252401254d75737420686f6c643a206e6f77203e206c61737420696e746572657374207570646174650016153330483371000400a266e0ccdc199b823370466e04014008dd6981818259baa3027304b375400200690405844fdf500a410112f42a66092921264d75737420686f6c643a206e6f77203e20696e746572657374206c61737420736574746c6564001622533304430413046375400426094608e6ea80084c0b0c11cdd519801800982518239baa0022232320025333044304130463754002264646464a666098609e0042649318208018b1bad304d001304d002304b001304737540022c6008602c608c6ea8c088c118dd51929998240008a99822a492145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001615333048304b0011304a001153304549012145787065637465642065786163746c79206f6e65206f7261636c6520696e7075740016333005002304930463754002980103d879800022323200253330433040304537540022646464646464a66609a60a00042649318210018b1bad304e001304e002304c001304c002375a6094002608c6ea800458c00cc054c114dd5181098229baa325333047001153304449012a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001615333047304a00113049001153304449012a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e70757400163330040020014c0103d8798000253330403034304237540022608c60866ea800454cc1052401134e6f7420616e20696e6c696e6520646174756d0016222323301600423002302230463754002a666082607c60866ea800448cc014dd5981098229baa00100312300d33300737566042608a6ea8004dd7181518229baa003375c6042608a6ea800c88c0e8ccc010008dd7181398211baa001375c603c60846ea80048ccc0080052210048810022232533303f303a304137540022900009bad30453042375400264a66607e607460826ea8004530103d87a8000132330010013756608c60866ea8008894ccc114004530103d87a8000132323253330443371e00e6eb8c11800c4c0accc124dd4000a5eb804cc014014008dd698230011824801182380099198008008021129998220008a6103d87a8000132323253330433371e00e6eb8c11400c4c0a8cc120dd3000a5eb804cc014014008dd5982280118240011823000918209821182118211821182118210009111119299981f9805001099299982019191811801192999821181f8008a99982318229baa00214985854ccc108c0f400454ccc118c114dd50010a4c2c2a666084606c0022a66608c608a6ea80085261616304337540026601c605060866ea80040144ccccc03401cc03ccc114c09ccc114008cc115300103d87a80004bd7025eb8130107d87b9fd87980ff003300c3756603e60866ea8c07cc10cdd5000801a60103d879800014a064a6660880022a66082921284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400161533304430470011304600115330414901284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400163300f00500114a2601a660866ea40092f5c04607e6080608060806080608060806080608060806080608060800024607c607e607e607e607e607e607e607e607e607e0024444464a666078600e004264a66607a646466ebc00930103d87d800032533303f303c00115333043304237540042930b0a99981f981d0008a99982198211baa00214985854ccc0fcc0cc00454ccc10cc108dd50010a4c2c2a66607e60640022a66608660846ea8008526161533303f303100115333043304237540042930b0a99981f98180008a99982198211baa00214985858c100dd500099805981298201baa00100513333300a007302433042302530403754604a60806ea8c070c100dd5000a5eb8130107d87b9fd87980ff00330093756603860806ea8c070c100dd5000801a60103d879800014a064a6660820022a6607c921274d757374207370656e64203120696e7075742066726f6d20747265617375727920736372697074001615333041304400113043001153303e4901274d757374207370656e64203120696e7075742066726f6d2074726561737572792073637269707400163300c00500114a26014660806ea40092f5c06e212000223333007002488100488100001222223300d3300c005300a004253330393375e601860786ea80040104c94ccc0f80045288a99981f18208008991919299981e98109bae30430031533303d30210011533303d303a303f375400c2a66607a66e25200000213371200490404df7010a5013371290000010a5014a06eb8c108c10c008dd69820982118210009bac304000114a06466002002660206eacc064c0f4dd5001180880211299981f8008a5eb804c8ccc888c8cc00400400c894ccc114004400c4c8cc11cdd3998239ba90063304737526eb8c110004cc11cdd41bad30450014bd7019801801982480118238009bae303e0013756607e0026600600660860046082002294088c94ccc0d4c0c8c0dcdd50008981d981c1baa001153303649117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533303b00114c0103d87a80001323232533303a3375e00c6078006260426607e00297ae0133005005002303c002303f002303d0013003330390024bd701ba54800888cc0180088cdd7980d981b1baa301b303637546024606c6ea800400888894ccc0ccc0c000440104ccccc03401000cc8c8008c8cc004004008894ccc0e8004526132533303b00114984c8c94ccc0e4c0d8c0ecdd51980d9bae303b303f004375c607600426600a00a6607c0040022a66074921326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016303f002303d001303d00133038337606ea4008dd4000a5eb7bdb180888c94ccc0dcc040004530103d87a80001301e3303c374c00297ae03333301100100500422232533303a303700114c103d87a8000130213303f375000297ae03370000200403002a4a66605e605860626ea80044c88cdd7980c981a1baa301930343754002004606a60646ea80044c88cdd7980c981a1baa00100230353032375400246068606a606a00244646600200200644a666068002297ae01323253330323005002133037002330040040011330040040013038002303600122323300100100322533303300114a0264a6660606008606c00429444cc00c00c004c0d800488c8ccc00400400c0088894ccc0cc00840044c8ccc010010c0dc00cccccc028008dd718190009bab3033001222325333034300d00114c0103d87a80001301b33039374c00297ae032333001001003002222533303a0021001132333004004303e00333333012002375c60720026eb4c0e8004888c94ccc0ecc0e00045300103d87a80001302233040375000297ae0337000040020326078004024606a0044646600200200444a666060002297adef6c6013233032337606ea4dd718178009ba632330010013756606200444a666066002297adef6c6013233035337606ea4dd718190009ba83008375a606600266006006606e004606a00266006006606800460640026e0520002533302c00114a2294088888c8cc004004018894ccc0c40044cc0c8cdd81ba9006374c00a97adef6c60132323232533303130123300700a002133036337606ea4028dd30048028a99981899b8f00a0021325333032302f3034375400226606e66ec0dd4805981c181a9baa001004100433300800a009001133036337606ea4008dd3000998030030019bab3033003375c6062004606a004606600244444646600200200c44a66606000226606266ec0dd48031ba80054bd6f7b630099191919299981818089980380500109981a99bb037520146ea002401454ccc0c0cdc78050010992999818981718199baa001133036337606ea402cc0dcc0d0dd5000802080219980400500480089981a99bb037520046ea0004cc01801800cdd698190019bae3030002303400230320012302b302c302c302c302c302c302c302c0012302a302b302b302b0012333003375c6016604c6ea8004dd7180118131baa001480088c0a0c0a40048894ccc08cc08000452f5bded8c0264646600200297adef6c6022533302a00113302b337606ea4018dd3001a5eb7bdb1804c8c8c8c94ccc0a8c02ccc0300280084cc0bccdd81ba900a374c00e00a2a66605466e3c0280084cc0bccdd81ba900a374c00e00626605e66ec0dd48011ba600133006006003375660580066eb8c0a8008c0b8008c0b0004c8cc0040052f5bded8c044a66605200226605466ec0dd48021ba80034bd6f7b630099191919299981498051980580400109981719bb037520106ea001c01454ccc0a4cdc780400109981719bb037520106ea001c00c4cc0b8cdd81ba900237500026600c00c0066eb4c0ac00cdd71814801181680118158009baf4c103d879800022533302033720004002298103d8798000153330203371e0040022980103d87a800014c103d87b80002323300100100222533302400114bd6f7b63009919191929998121804001080189981499bb037520046e98004cc01801800cdd598130019bae302400230280023026001371e9110022533301d33301d0014a094454cc0780084004400488c8cc00400400c894ccc0880045300103d87a80001323253330203375e601060466ea80080144c01ccc0940092f5c0266008008002604c00460480026e9520002301f00130193754018603860326ea800458c06cc070008c068004c058dd50008a4c26cac600200c464a666024601e0022646464646464a666038603e0042930b1bad301d001301d002375a603600260360046eb4c064004c054dd50010a999809180680089919299980c180d8010a4c2c6eb4c064004c054dd50010a999809180300089919299980c180d8010a4c2c6eb4c064004c054dd50010a999809180280089919299980c180d8010a4c2c6eb4c064004c054dd50010a99980918020008a99980b180a9baa00214985854ccc048c00c0044c8c94ccc060c06c0084c9265333014301130163754002264646464a666038603e00426493299980c180a980d1baa00313232533301e3021002149858dd7180f800980d9baa0031616375a603a002603a0046036002602e6ea80045858c064004c054dd50010a99980919b874803000454ccc058c054dd50010a4c2c2a66602466e1d200e00115333016301537540042930b0a99980919b874804000454ccc058c054dd50010a4c2c2c60266ea8004dc3a40146e1d2008370e90031b8748010c0040208c94ccc02cc0200044c8c94ccc044c0500084c926533300d300a300f375400226464646464646464a6660326038004264649319299980b980a000899191919299980f98110010a4c2c6eb4c080004c080008dd6980f000980d1baa003153330173012001132323232533301f3022002149858dd6981000098100011bad301e001301a37540062c60306ea8008c03c01c58c068004c068008dd6980c000980c0011bae301600130160023014001301037540022c2c6024002601c6ea800854ccc02cc0180044c8c94ccc044c0500084c9263005001163012001300e37540042c60186ea800494ccc024c018c02cdd500089919191919191919191919191919191919191919191919191919191929998149816001099191919191919191919191924c6054018605001e604e020604c022604a02460480266046028604402a604202c604002e604403064a66604c604600226464a666058605e0042649318108008b181680098149baa01a15333026302100113232533302c302f0021324994ccc0a0c094c0a8dd5000899192999817181880109924c604c0022c605e00260566ea80045858c0b4004c0a4dd500d0b18139baa01916302a001302a002325333027302600115333023301e302500114a22a6660466040604a00229405858dd51814000981400118130009813001181200098120011811000981100118100009810001180f000980f001180e000980e001180d000980d001180c000980c001180b000980b001180a000980a001180900098090011bae3010001300c37540022c4a666010600a60146ea80044c8c94ccc038c04400852616375a601e00260166ea8004588c94ccc020c0140044c8c94ccc038c04400852616375c601e00260166ea800854ccc020c00c00454ccc030c02cdd50010a4c2c2c60126ea8004dc3a40044a66600a6004600e6ea80044c8c8c8c94ccc034c04000852616375c601c002601c0046eb8c030004c020dd50008b1b87480015cd2b9c5573aaae7955cfaba05742ae89"
448
586
  };
449
587
 
588
+ // src/types/indigo/interest-oracle.ts
589
+ var import_lucid9 = require("@lucid-evolution/lucid");
590
+ var InterestOracleDatumSchema = import_lucid9.Data.Object({
591
+ unitaryInterest: import_lucid9.Data.Integer(),
592
+ interestRate: OnChainDecimalSchema,
593
+ lastUpdated: import_lucid9.Data.Integer()
594
+ });
595
+ var InterestOracleDatum = InterestOracleDatumSchema;
596
+ function parseInterestOracleDatum(datum) {
597
+ return import_lucid9.Data.from(datum, InterestOracleDatum);
598
+ }
599
+ function serialiseInterestOracleDatum(datum) {
600
+ return import_lucid9.Data.to(datum, InterestOracleDatum);
601
+ }
602
+ var FeedInterestOracleRedeemerSchema = import_lucid9.Data.Object({
603
+ newInterestRate: OnChainDecimalSchema,
604
+ currentTime: import_lucid9.Data.Integer()
605
+ });
606
+ var FeedInterestOracleRedeemer = FeedInterestOracleRedeemerSchema;
607
+ function serialiseFeedInterestOracleRedeemer(redeemer) {
608
+ return import_lucid9.Data.to(
609
+ redeemer,
610
+ FeedInterestOracleRedeemer
611
+ );
612
+ }
613
+ var InterestOracleParamsSchema = import_lucid9.Data.Object({
614
+ /** Milliseconds */
615
+ biasTime: import_lucid9.Data.Integer(),
616
+ owner: import_lucid9.Data.Bytes()
617
+ });
618
+ var InterestOracleParams = InterestOracleParamsSchema;
619
+ function castInterestOracleParams(params) {
620
+ return import_lucid9.Data.castTo(params, InterestOracleParams);
621
+ }
622
+
623
+ // src/types/indigo/cdp-creator.ts
624
+ var import_lucid10 = require("@lucid-evolution/lucid");
625
+ var CDPCreatorParamsSchema = import_lucid10.Data.Object({
626
+ cdpCreatorNft: AssetClassSchema,
627
+ cdpAssetCs: import_lucid10.Data.Bytes(),
628
+ cdpAuthTk: AssetClassSchema,
629
+ iAssetAuthTk: AssetClassSchema,
630
+ versionRecordToken: AssetClassSchema,
631
+ cdpScriptHash: import_lucid10.Data.Bytes(),
632
+ collectorValHash: import_lucid10.Data.Bytes(),
633
+ minCollateralInLovelace: import_lucid10.Data.Integer(),
634
+ biasTime: import_lucid10.Data.Integer()
635
+ });
636
+ var CDPCreatorParams = CDPCreatorParamsSchema;
637
+ function castCDPCreatorParams(params) {
638
+ return import_lucid10.Data.castTo(params, CDPCreatorParams);
639
+ }
640
+ var CDPCreatorRedeemerSchema = import_lucid10.Data.Enum([
641
+ import_lucid10.Data.Object({
642
+ CreateCDP: import_lucid10.Data.Object({
643
+ cdpOwner: import_lucid10.Data.Bytes(),
644
+ minted: import_lucid10.Data.Integer(),
645
+ collateral: import_lucid10.Data.Integer(),
646
+ currentTime: import_lucid10.Data.Integer()
647
+ })
648
+ }),
649
+ import_lucid10.Data.Object({ UpgradeCreatorVersion: import_lucid10.Data.Object({}) })
650
+ ]);
651
+ var CDPCreatorRedeemer = CDPCreatorRedeemerSchema;
652
+ function castCDPCreatorRedeemer(params) {
653
+ return import_lucid10.Data.castTo(params, CDPCreatorRedeemer);
654
+ }
655
+
656
+ // src/types/indigo/gov.ts
657
+ var import_lucid11 = require("@lucid-evolution/lucid");
658
+ var GovDatumSchema = import_lucid11.Data.Object({
659
+ currentProposal: import_lucid11.Data.Integer(),
660
+ protocolParams: import_lucid11.Data.Object({
661
+ proposalDeposit: import_lucid11.Data.Integer(),
662
+ votingPeriod: import_lucid11.Data.Integer(),
663
+ effectiveDelay: import_lucid11.Data.Integer(),
664
+ expirationPeriod: import_lucid11.Data.Integer(),
665
+ collateralFeePercentage: OnChainDecimalSchema,
666
+ proposingPeriod: import_lucid11.Data.Integer(),
667
+ totalShards: import_lucid11.Data.Integer(),
668
+ minimumQuorum: import_lucid11.Data.Integer(),
669
+ maxTreasuryLovelaceSpend: import_lucid11.Data.Integer(),
670
+ maxTreasuryIndySpend: import_lucid11.Data.Integer()
671
+ }),
672
+ currentVersion: import_lucid11.Data.Integer(),
673
+ iassetsCount: import_lucid11.Data.Integer(),
674
+ activeProposals: import_lucid11.Data.Integer(),
675
+ treasuryIndyWithdrawnAmt: import_lucid11.Data.Integer()
676
+ });
677
+ var GovDatum = GovDatumSchema;
678
+ function parseGovDatum(datum) {
679
+ return import_lucid11.Data.from(datum, GovDatum);
680
+ }
681
+ function serialiseGovDatum(d) {
682
+ return import_lucid11.Data.to(d, GovDatum);
683
+ }
684
+ var GovParamsSchema = import_lucid11.Data.Object({
685
+ govNFT: AssetClassSchema,
686
+ pollToken: AssetClassSchema,
687
+ upgradeToken: AssetClassSchema,
688
+ indyAsset: AssetClassSchema,
689
+ versionRecordToken: AssetClassSchema,
690
+ pollManagerValHash: import_lucid11.Data.Bytes(),
691
+ gBiasTime: import_lucid11.Data.Integer(),
692
+ daoIdentityToken: AssetClassSchema,
693
+ iAssetAuthToken: AssetClassSchema
694
+ });
695
+ var GovParams = GovParamsSchema;
696
+ function castGovParams(params) {
697
+ return import_lucid11.Data.castTo(params, GovParams);
698
+ }
699
+
700
+ // src/helpers/time-helpers.ts
701
+ var ONE_SECOND = 1e3;
702
+ var oneHour = 3600000n;
703
+ var oneDay = 86400000n;
704
+ var oneYear = 31536000000n;
705
+
706
+ // src/helpers/interest-oracle.ts
707
+ var unitaryInterestPrecision = 1000000000000000000n;
708
+ var decimalUnit = 1000000n;
709
+ function calculateUnitaryInterest(timePeriod, interestRate) {
710
+ return timePeriod * interestRate * unitaryInterestPrecision / oneYear / decimalUnit;
711
+ }
712
+ function calculateUnitaryInterestSinceOracleLastUpdated(now, oracleDatum) {
713
+ return calculateUnitaryInterest(
714
+ now - oracleDatum.lastUpdated,
715
+ oracleDatum.interestRate.getOnChainInt
716
+ );
717
+ }
718
+ function calculateAccruedInterest(now, unitaryInterestSnapshot, mintedAmount, interestLastSettled, interestOracleDatum) {
719
+ if (interestOracleDatum.unitaryInterest >= unitaryInterestSnapshot) {
720
+ const interestFromPreviousRates = (interestOracleDatum.unitaryInterest - unitaryInterestSnapshot) * mintedAmount / unitaryInterestPrecision;
721
+ const lastRateInterest = (now - interestOracleDatum.lastUpdated) * interestOracleDatum.interestRate.getOnChainInt * mintedAmount / oneYear / decimalUnit;
722
+ return interestFromPreviousRates + lastRateInterest;
723
+ } else {
724
+ return (now - interestLastSettled) * interestOracleDatum.interestRate.getOnChainInt * mintedAmount / oneYear / decimalUnit;
725
+ }
726
+ }
727
+
450
728
  // src/contracts/cdp.ts
451
729
  var CDPContract = class _CDPContract {
452
- static async openPosition(asset, collateralAmount, mintedAmount, params, lucid, assetRef, priceOracleRef, interestOracleRef, cdpCreatorRef, collectorRef) {
730
+ static async openPosition(asset, collateralAmount, mintedAmount, params, lucid, assetRef, priceOracleRef, interestOracleRef, cdpCreatorRef, collectorRef, now = Date.now()) {
453
731
  const [pkh, skh] = await addrDetails(lucid);
454
- const now = Date.now();
455
- const assetOut = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, params, lucid) : IAssetHelpers.findIAssetByName(asset, params, lucid));
456
- if ("getOnChainPrice" in assetOut.datum.price)
457
- return Promise.reject("Trying to open CDP against delisted asset");
458
- const oracleAsset = assetOut.datum.price;
732
+ const assetOut = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, lucid) : IAssetHelpers.findIAssetByName(asset, params, lucid));
733
+ if (!assetOut || !assetOut.datum) throw new Error("Unable to find IAsset");
734
+ if ("Delisted" in assetOut.datum.price)
735
+ return Promise.reject(
736
+ new Error("Trying to open CDP against delisted asset")
737
+ );
738
+ const oracleAsset = assetOut.datum.price.Oracle.oracleNft.asset;
459
739
  const oracleOut = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
460
- oracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(oracleAsset[1].unTokenName)
461
- );
462
- if (!oracleOut.datum) return Promise.reject("Price Oracle datum not found");
463
- const oracleDatum = PriceOracleContract.decodePriceOracleDatum(
464
- oracleOut.datum
740
+ oracleAsset.currencySymbol + oracleAsset.tokenName
465
741
  );
466
- const interestOracleAsset = assetOut.datum.interestOracle;
742
+ if (!oracleOut.datum)
743
+ return Promise.reject(new Error("Price Oracle datum not found"));
744
+ const oracleDatum = parsePriceOracleDatum(oracleOut.datum);
745
+ const interestOracleAsset = assetOut.datum.interestOracleNft;
467
746
  const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
468
- interestOracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(interestOracleAsset[1].unTokenName)
747
+ interestOracleAsset.currencySymbol + interestOracleAsset.tokenName
469
748
  );
470
749
  if (!interestOracleOut.datum)
471
- return Promise.reject("Interest Oracle datum not found");
472
- const interestOracleDatum = InterestOracleContract.decodeInterestOracleDatum(interestOracleOut.datum);
750
+ return Promise.reject(new Error("Interest Oracle datum not found"));
751
+ const interestOracleDatum = parseInterestOracleDatum(
752
+ interestOracleOut.datum
753
+ );
473
754
  const cdpCreatorOut = getRandomElement(
474
755
  cdpCreatorRef ? await lucid.utxosByOutRef([cdpCreatorRef]) : await lucid.utxosAtWithUnit(
475
- CDPCreatorContract.address(params.cdpCreatorParams, lucid),
476
- params.cdpCreatorParams.cdpCreatorNft[0].unCurrencySymbol + (0, import_lucid9.fromText)(params.cdpCreatorParams.cdpCreatorNft[1].unTokenName)
756
+ (0, import_lucid12.credentialToAddress)(lucid.config().network, {
757
+ type: "Script",
758
+ hash: params.validatorHashes.cdpCreatorHash
759
+ }),
760
+ params.cdpCreatorParams.cdpCreatorNft[0].unCurrencySymbol + (0, import_lucid12.fromText)(params.cdpCreatorParams.cdpCreatorNft[1].unTokenName)
477
761
  )
478
762
  );
479
- const cdpCreatorRedeemer = CDPCreatorContract.redeemer(
480
- pkh,
481
- mintedAmount,
482
- collateralAmount,
483
- BigInt(now)
484
- );
485
- const cdpCreatorScriptRefUtxo = await CDPCreatorContract.scriptRef(
486
- params.scriptReferences,
763
+ const cdpCreatorRedeemer = castCDPCreatorRedeemer({
764
+ CreateCDP: {
765
+ cdpOwner: pkh.hash,
766
+ minted: mintedAmount,
767
+ collateral: collateralAmount,
768
+ currentTime: BigInt(now)
769
+ }
770
+ });
771
+ const cdpCreatorScriptRefUtxo = await scriptRef(
772
+ params.scriptReferences.cdpCreatorValidatorRef,
487
773
  lucid
488
774
  );
489
775
  const cdpAddress = _CDPContract.address(params.cdpParams, lucid, skh);
490
- const cdpToken = params.cdpParams.cdpAuthToken[0].unCurrencySymbol + (0, import_lucid9.fromText)(params.cdpParams.cdpAuthToken[1].unTokenName);
776
+ const cdpToken = params.cdpParams.cdpAuthToken[0].unCurrencySymbol + (0, import_lucid12.fromText)(params.cdpParams.cdpAuthToken[1].unTokenName);
491
777
  const cdpValue = {
492
778
  lovelace: collateralAmount
493
779
  };
494
780
  cdpValue[cdpToken] = 1n;
495
- const newSnapshot = InterestOracleContract.calculateUnitaryInterestSinceOracleLastUpdated(
781
+ const newSnapshot = calculateUnitaryInterestSinceOracleLastUpdated(
496
782
  BigInt(now),
497
783
  interestOracleDatum
498
784
  ) + interestOracleDatum.unitaryInterest;
499
- const cdpDatum = _CDPContract.datum(pkh, asset, mintedAmount, {
500
- type: "ActiveCDPInterestTracking",
501
- last_settled: BigInt(now),
502
- unitary_interest_snapshot: newSnapshot
503
- });
504
- const assetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + (0, import_lucid9.fromText)(asset);
785
+ const cdpDatum = {
786
+ cdpOwner: pkh.hash,
787
+ iasset: (0, import_lucid12.fromText)(asset),
788
+ mintedAmt: mintedAmount,
789
+ cdpFees: {
790
+ ActiveCDPInterestTracking: {
791
+ lastSettled: BigInt(now),
792
+ unitaryInterestSnapshot: newSnapshot
793
+ }
794
+ }
795
+ };
796
+ const assetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + (0, import_lucid12.fromText)(asset);
505
797
  const cdpTokenMintValue = {};
506
798
  cdpTokenMintValue[cdpToken] = 1n;
507
799
  const iassetTokenMintValue = {};
@@ -516,21 +808,21 @@ var CDPContract = class _CDPContract {
516
808
  );
517
809
  const debtMintingFee = calculateFeeFromPercentage(
518
810
  BigInt(assetOut.datum.debtMintingFeePercentage.getOnChainInt),
519
- mintedAmount * oracleDatum.price / 1000000n
811
+ mintedAmount * oracleDatum.price.getOnChainInt / 1000000n
520
812
  );
521
813
  const cappedValidateTo = oracleDatum.expiration - 20001n;
522
814
  const timeValidFrom = now - 1e3;
523
- const timeValidTo_ = now + params.cdpCreatorParams.biasTime - 1e3;
815
+ const timeValidTo_ = now + Number(params.cdpCreatorParams.biasTime) - 1e3;
524
816
  const timeValidTo = cappedValidateTo <= timeValidFrom ? timeValidTo_ : Math.min(timeValidTo_, Number(cappedValidateTo));
525
- const tx = lucid.newTx().collectFrom([cdpCreatorOut], import_lucid9.Data.to(cdpCreatorRedeemer)).readFrom([cdpCreatorScriptRefUtxo]).pay.ToContract(
817
+ const tx = lucid.newTx().collectFrom([cdpCreatorOut], import_lucid12.Data.to(cdpCreatorRedeemer)).readFrom([cdpCreatorScriptRefUtxo]).pay.ToContract(
526
818
  cdpAddress,
527
- { kind: "inline", value: import_lucid9.Data.to(cdpDatum) },
819
+ { kind: "inline", value: serialiseCDPDatum(cdpDatum) },
528
820
  cdpValue
529
821
  ).pay.ToContract(
530
822
  cdpCreatorOut.address,
531
823
  { kind: "inline", value: cdpCreatorOut.datum },
532
824
  cdpCreatorOut.assets
533
- ).readFrom([oracleOut, interestOracleOut, assetOut.utxo]).mintAssets(cdpTokenMintValue, import_lucid9.Data.to(new import_lucid9.Constr(0, []))).readFrom([cdpAuthTokenScriptRefUtxo]).mintAssets(iassetTokenMintValue, import_lucid9.Data.to(new import_lucid9.Constr(0, []))).readFrom([iAssetTokenScriptRefUtxo]).addSignerKey(pkh.hash).validFrom(Number(now - 6e4)).validTo(Number(timeValidTo));
825
+ ).readFrom([oracleOut, interestOracleOut, assetOut.utxo]).mintAssets(cdpTokenMintValue, import_lucid12.Data.to(new import_lucid12.Constr(0, []))).readFrom([cdpAuthTokenScriptRefUtxo]).mintAssets(iassetTokenMintValue, import_lucid12.Data.to(new import_lucid12.Constr(0, []))).readFrom([iAssetTokenScriptRefUtxo]).addSignerKey(pkh.hash).validFrom(Number(now - 100)).validTo(Number(timeValidTo));
534
826
  if (debtMintingFee > 0) {
535
827
  await CollectorContract.feeTx(
536
828
  debtMintingFee,
@@ -603,104 +895,110 @@ var CDPContract = class _CDPContract {
603
895
  );
604
896
  }
605
897
  static async adjust(cdpRef, collateralAmount, mintAmount, params, lucid, assetRef, priceOracleRef, interestOracleRef, collectorRef, govRef, treasuryRef) {
606
- const [pkh, skh] = await addrDetails(lucid);
898
+ const [pkh, _] = await addrDetails(lucid);
607
899
  const now = Date.now();
608
- if (!pkh)
609
- return Promise.reject(
610
- "Unable to determine the pub key hash of the wallet"
611
- );
612
900
  const cdp = (await lucid.utxosByOutRef([cdpRef]))[0];
613
- if (!cdp.datum) throw "Unable to find CDP Datum";
614
- const cdpDatum = _CDPContract.decodeCdpDatum(cdp.datum);
615
- if (cdpDatum.type !== "CDP") throw "Invalid CDP Datum";
616
- const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, params, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.asset, params, lucid));
901
+ if (!cdp.datum) throw new Error("Unable to find CDP Datum");
902
+ const cdpDatum = parseCDPDatum(cdp.datum);
903
+ const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.iasset, params, lucid));
617
904
  const gov = govRef ? (await lucid.utxosByOutRef([govRef]))[0] : await lucid.utxoByUnit(
618
- params.govParams.govNFT[0].unCurrencySymbol + (0, import_lucid9.fromText)(params.govParams.govNFT[1].unTokenName)
905
+ params.govParams.govNFT[0].unCurrencySymbol + (0, import_lucid12.fromText)(params.govParams.govNFT[1].unTokenName)
619
906
  );
620
- if (!gov.datum) throw "Unable to find Gov Datum";
621
- const govData = GovContract.decodeGovDatum(gov.datum);
622
- if (!govData) throw "No Governance datum found";
907
+ if (!gov.datum) throw new Error("Unable to find Gov Datum");
908
+ const govData = parseGovDatum(gov.datum);
623
909
  const cdpScriptRefUtxo = await _CDPContract.scriptRef(
624
910
  params.scriptReferences,
625
911
  lucid
626
912
  );
627
913
  const cdpAssets = Object.assign({}, cdp.assets);
628
914
  cdpAssets["lovelace"] = cdp.assets["lovelace"] + collateralAmount;
629
- const interestOracleAsset = iAsset.datum.interestOracle;
915
+ const interestOracleAsset = iAsset.datum.interestOracleNft;
630
916
  const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
631
- interestOracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(interestOracleAsset[1].unTokenName)
917
+ interestOracleAsset.currencySymbol + (0, import_lucid12.fromText)(interestOracleAsset.tokenName)
632
918
  );
633
919
  if (!interestOracleOut.datum)
634
- return Promise.reject("Interest Oracle datum not found");
635
- const interestOracleDatum = InterestOracleContract.decodeInterestOracleDatum(interestOracleOut.datum);
636
- let tx = lucid.newTx().collectFrom([cdp], import_lucid9.Data.to(new import_lucid9.Constr(0, [BigInt(now), mintAmount, collateralAmount]))).readFrom([iAsset.utxo, gov, cdpScriptRefUtxo]).addSignerKey(pkh.hash);
637
- if (!cdp.datum) throw "Unable to find CDP Datum";
638
- let cdpD = _CDPContract.decodeCdpDatum(cdp.datum);
639
- if (!cdpD || cdpD.type !== "CDP") throw "Invalid CDP Datum";
640
- if (cdpD.fees.type !== "ActiveCDPInterestTracking")
641
- throw "Invalid CDP Fees";
642
- const newSnapshot = InterestOracleContract.calculateUnitaryInterestSinceOracleLastUpdated(
920
+ return Promise.reject(new Error("Interest Oracle datum not found"));
921
+ const interestOracleDatum = parseInterestOracleDatum(
922
+ interestOracleOut.datum
923
+ );
924
+ const tx = lucid.newTx().collectFrom(
925
+ [cdp],
926
+ import_lucid12.Data.to(new import_lucid12.Constr(0, [BigInt(now), mintAmount, collateralAmount]))
927
+ ).readFrom([iAsset.utxo, gov, cdpScriptRefUtxo]).addSignerKey(pkh.hash);
928
+ if (!cdp.datum) throw new Error("Unable to find CDP Datum");
929
+ const cdpD = parseCDPDatum(cdp.datum);
930
+ if (!("ActiveCDPInterestTracking" in cdpD.cdpFees))
931
+ throw new Error("Invalid CDP Fees");
932
+ const newSnapshot = calculateUnitaryInterestSinceOracleLastUpdated(
643
933
  BigInt(now),
644
934
  interestOracleDatum
645
935
  ) + interestOracleDatum.unitaryInterest;
646
936
  const cdpD_ = {
647
937
  ...cdpD,
648
- mintedAmount: cdpD.mintedAmount + mintAmount,
649
- fees: {
650
- type: "ActiveCDPInterestTracking",
651
- last_settled: BigInt(now),
652
- unitary_interest_snapshot: newSnapshot
938
+ mintedAmt: cdpD.mintedAmt + mintAmount,
939
+ cdpFees: {
940
+ ActiveCDPInterestTracking: {
941
+ lastSettled: BigInt(now),
942
+ unitaryInterestSnapshot: newSnapshot
943
+ }
653
944
  }
654
945
  };
655
946
  tx.pay.ToContract(
656
947
  cdp.address,
657
948
  {
658
949
  kind: "inline",
659
- value: _CDPContract.encodeCdpDatum(cdpD_)
950
+ value: serialiseCDPDatum(cdpD_)
660
951
  },
661
952
  cdpAssets
662
953
  );
663
954
  const oracleAsset = iAsset.datum.price;
955
+ if (!("Oracle" in oracleAsset)) throw new Error("Invalid oracle asset");
664
956
  const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
665
- oracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(oracleAsset[1].unTokenName)
957
+ oracleAsset.Oracle.oracleNft.asset.currencySymbol + (0, import_lucid12.fromText)(oracleAsset.Oracle.oracleNft.asset.tokenName)
666
958
  );
667
- if (!oracleRefInput.datum) return Promise.reject("Invalid oracle input");
668
- const od = PriceOracleContract.decodePriceOracleDatum(oracleRefInput.datum);
669
- if (!od) return Promise.reject("Invalid oracle input");
959
+ if (!oracleRefInput.datum)
960
+ return Promise.reject(new Error("Invalid oracle input"));
961
+ const od = parsePriceOracleDatum(oracleRefInput.datum);
962
+ if (!od) return Promise.reject(new Error("Invalid oracle input"));
670
963
  const cappedValidateTo = od.expiration - 20001n;
671
964
  const timeValidFrom = now - 1e3;
672
- const timeValidTo_ = now + params.cdpCreatorParams.biasTime - 1e3;
965
+ const timeValidTo_ = now + Number(params.cdpCreatorParams.biasTime) - 1e3;
673
966
  const timeValidTo = cappedValidateTo <= timeValidFrom ? timeValidTo_ : Math.min(timeValidTo_, Number(cappedValidateTo));
674
967
  tx.readFrom([oracleRefInput]).validFrom(Number(timeValidFrom)).validTo(Number(timeValidTo));
675
968
  let fee = 0n;
676
969
  if (collateralAmount < 0) {
677
970
  fee += calculateFeeFromPercentage(
678
- govData.protocolParams.collateralFeePercentage,
971
+ govData.protocolParams.collateralFeePercentage.getOnChainInt,
679
972
  collateralAmount
680
973
  );
681
974
  }
682
975
  if (mintAmount > 0) {
683
976
  fee += calculateFeeFromPercentage(
684
977
  iAsset.datum.debtMintingFeePercentage.getOnChainInt,
685
- mintAmount * od.price / 1000000n
978
+ mintAmount * od.price.getOnChainInt / 1000000n
686
979
  );
687
980
  }
688
- const interestPaymentAsset = InterestOracleContract.calculateAccruedInterest(
981
+ const interestPaymentAsset = calculateAccruedInterest(
689
982
  BigInt(now),
690
- cdpD.fees.unitary_interest_snapshot,
691
- cdpD.mintedAmount,
692
- cdpD.fees.last_settled,
983
+ cdpD.cdpFees.ActiveCDPInterestTracking.unitaryInterestSnapshot,
984
+ cdpD.mintedAmt,
985
+ cdpD.cdpFees.ActiveCDPInterestTracking.lastSettled,
693
986
  interestOracleDatum
694
987
  );
695
- const interestPayment = interestPaymentAsset * od.price / 1000000n;
988
+ const interestPayment = interestPaymentAsset * od.price.getOnChainInt / 1000000n;
696
989
  const interestCollectorPayment = calculateFeeFromPercentage(
697
990
  iAsset.datum.interestCollectorPortionPercentage.getOnChainInt,
698
991
  interestPayment
699
992
  );
700
993
  const interestTreasuryPayment = interestPayment - interestCollectorPayment;
701
- console.log(interestPayment, interestCollectorPayment, interestTreasuryPayment);
702
994
  if (interestTreasuryPayment > 0) {
703
- await TreasuryContract.feeTx(interestTreasuryPayment, lucid, params, tx, treasuryRef);
995
+ await TreasuryContract.feeTx(
996
+ interestTreasuryPayment,
997
+ lucid,
998
+ params,
999
+ tx,
1000
+ treasuryRef
1001
+ );
704
1002
  }
705
1003
  fee += interestCollectorPayment;
706
1004
  tx.readFrom([interestOracleOut]);
@@ -709,12 +1007,12 @@ var CDPContract = class _CDPContract {
709
1007
  params.scriptReferences,
710
1008
  lucid
711
1009
  );
712
- const iassetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + (0, import_lucid9.fromText)(cdpD.asset);
1010
+ const iassetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + cdpD.iasset;
713
1011
  const mintValue = {};
714
1012
  mintValue[iassetToken] = mintAmount;
715
1013
  tx.readFrom([iAssetTokenScriptRefUtxo]).mintAssets(
716
1014
  mintValue,
717
- import_lucid9.Data.to(new import_lucid9.Constr(0, []))
1015
+ import_lucid12.Data.to(new import_lucid12.Constr(0, []))
718
1016
  );
719
1017
  }
720
1018
  if (fee > 0n) {
@@ -723,69 +1021,70 @@ var CDPContract = class _CDPContract {
723
1021
  return tx;
724
1022
  }
725
1023
  static async close(cdpRef, params, lucid, assetRef, priceOracleRef, interestOracleRef, collectorRef, govRef, treasuryRef) {
726
- const [pkh, skh] = await addrDetails(lucid);
1024
+ const [pkh, _] = await addrDetails(lucid);
727
1025
  const now = Date.now();
728
- if (!pkh)
729
- return Promise.reject(
730
- "Unable to determine the pub key hash of the wallet"
731
- );
732
1026
  const cdp = (await lucid.utxosByOutRef([cdpRef]))[0];
733
- if (!cdp.datum) throw "Unable to find CDP Datum";
734
- const cdpDatum = _CDPContract.decodeCdpDatum(cdp.datum);
735
- if (cdpDatum.type !== "CDP") throw "Invalid CDP Datum";
736
- const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, params, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.asset, params, lucid));
1027
+ if (!cdp.datum) throw new Error("Unable to find CDP Datum");
1028
+ const cdpDatum = parseCDPDatum(cdp.datum);
1029
+ const iAsset = await (assetRef ? IAssetHelpers.findIAssetByRef(assetRef, lucid) : IAssetHelpers.findIAssetByName(cdpDatum.iasset, params, lucid));
737
1030
  const gov = govRef ? (await lucid.utxosByOutRef([govRef]))[0] : await lucid.utxoByUnit(
738
- params.govParams.govNFT[0].unCurrencySymbol + (0, import_lucid9.fromText)(params.govParams.govNFT[1].unTokenName)
1031
+ params.govParams.govNFT[0].unCurrencySymbol + (0, import_lucid12.fromText)(params.govParams.govNFT[1].unTokenName)
739
1032
  );
740
- if (!gov.datum) throw "Unable to find Gov Datum";
741
- const govData = GovContract.decodeGovDatum(gov.datum);
742
- if (!govData) throw "No Governance datum found";
1033
+ if (!gov.datum) throw new Error("Unable to find Gov Datum");
743
1034
  const cdpScriptRefUtxo = await _CDPContract.scriptRef(
744
1035
  params.scriptReferences,
745
1036
  lucid
746
1037
  );
747
- const interestOracleAsset = iAsset.datum.interestOracle;
1038
+ const interestOracleAsset = iAsset.datum.interestOracleNft;
748
1039
  const interestOracleOut = interestOracleRef ? (await lucid.utxosByOutRef([interestOracleRef]))[0] : await lucid.utxoByUnit(
749
- interestOracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(interestOracleAsset[1].unTokenName)
1040
+ interestOracleAsset.currencySymbol + (0, import_lucid12.fromText)(interestOracleAsset.tokenName)
750
1041
  );
751
1042
  if (!interestOracleOut.datum)
752
- return Promise.reject("Interest Oracle datum not found");
753
- const interestOracleDatum = InterestOracleContract.decodeInterestOracleDatum(interestOracleOut.datum);
754
- let tx = lucid.newTx().collectFrom([cdp], import_lucid9.Data.to(new import_lucid9.Constr(1, [BigInt(now)]))).readFrom([iAsset.utxo, gov, cdpScriptRefUtxo]).addSignerKey(pkh.hash);
755
- if (!cdp.datum) throw "Unable to find CDP Datum";
756
- let cdpD = _CDPContract.decodeCdpDatum(cdp.datum);
757
- if (!cdpD || cdpD.type !== "CDP") throw "Invalid CDP Datum";
758
- if (cdpD.fees.type !== "ActiveCDPInterestTracking")
759
- throw "Invalid CDP Fees";
760
- const oracleAsset = iAsset.datum.price;
1043
+ return Promise.reject(new Error("Interest Oracle datum not found"));
1044
+ const interestOracleDatum = parseInterestOracleDatum(
1045
+ interestOracleOut.datum
1046
+ );
1047
+ const tx = lucid.newTx().collectFrom([cdp], import_lucid12.Data.to(new import_lucid12.Constr(1, [BigInt(now)]))).readFrom([iAsset.utxo, gov, cdpScriptRefUtxo]).addSignerKey(pkh.hash);
1048
+ if (!cdp.datum) throw new Error("Unable to find CDP Datum");
1049
+ const cdpD = parseCDPDatum(cdp.datum);
1050
+ if (!("ActiveCDPInterestTracking" in cdpD.cdpFees))
1051
+ throw new Error("Invalid CDP Fees");
1052
+ if (!("Oracle" in iAsset.datum.price))
1053
+ throw new Error("iAsset is delisted");
1054
+ const oracleAsset = iAsset.datum.price.Oracle.oracleNft.asset;
761
1055
  const oracleRefInput = priceOracleRef ? (await lucid.utxosByOutRef([priceOracleRef]))[0] : await lucid.utxoByUnit(
762
- oracleAsset[0].unCurrencySymbol + (0, import_lucid9.fromText)(oracleAsset[1].unTokenName)
1056
+ oracleAsset.currencySymbol + (0, import_lucid12.fromText)(oracleAsset.tokenName)
763
1057
  );
764
- if (!oracleRefInput.datum) return Promise.reject("Invalid oracle input");
765
- const od = PriceOracleContract.decodePriceOracleDatum(oracleRefInput.datum);
766
- if (!od) return Promise.reject("Invalid oracle input");
1058
+ if (!oracleRefInput.datum)
1059
+ return Promise.reject(new Error("Invalid oracle input"));
1060
+ const od = parsePriceOracleDatum(oracleRefInput.datum);
767
1061
  const cappedValidateTo = od.expiration - 20001n;
768
1062
  const timeValidFrom = now - 1e3;
769
- const timeValidTo_ = now + params.cdpCreatorParams.biasTime - 1e3;
1063
+ const timeValidTo_ = now + Number(params.cdpCreatorParams.biasTime) - 1e3;
770
1064
  const timeValidTo = cappedValidateTo <= timeValidFrom ? timeValidTo_ : Math.min(timeValidTo_, Number(cappedValidateTo));
771
1065
  tx.readFrom([oracleRefInput]).validFrom(Number(timeValidFrom)).validTo(Number(timeValidTo));
772
1066
  let fee = 0n;
773
- const interestPaymentAsset = InterestOracleContract.calculateAccruedInterest(
1067
+ const interestPaymentAsset = calculateAccruedInterest(
774
1068
  BigInt(now),
775
- cdpD.fees.unitary_interest_snapshot,
776
- cdpD.mintedAmount,
777
- cdpD.fees.last_settled,
1069
+ cdpD.cdpFees.ActiveCDPInterestTracking.unitaryInterestSnapshot,
1070
+ cdpD.mintedAmt,
1071
+ cdpD.cdpFees.ActiveCDPInterestTracking.lastSettled,
778
1072
  interestOracleDatum
779
1073
  );
780
- const interestPayment = interestPaymentAsset * od.price / 1000000n;
1074
+ const interestPayment = interestPaymentAsset * od.price.getOnChainInt / 1000000n;
781
1075
  const interestCollectorPayment = calculateFeeFromPercentage(
782
1076
  iAsset.datum.interestCollectorPortionPercentage.getOnChainInt,
783
1077
  interestPayment
784
1078
  );
785
1079
  const interestTreasuryPayment = interestPayment - interestCollectorPayment;
786
- console.log(interestPayment, interestCollectorPayment, interestTreasuryPayment);
787
1080
  if (interestTreasuryPayment > 0) {
788
- await TreasuryContract.feeTx(interestTreasuryPayment, lucid, params, tx, treasuryRef);
1081
+ await TreasuryContract.feeTx(
1082
+ interestTreasuryPayment,
1083
+ lucid,
1084
+ params,
1085
+ tx,
1086
+ treasuryRef
1087
+ );
789
1088
  }
790
1089
  fee += interestCollectorPayment;
791
1090
  tx.readFrom([interestOracleOut]);
@@ -793,205 +1092,52 @@ var CDPContract = class _CDPContract {
793
1092
  params.scriptReferences,
794
1093
  lucid
795
1094
  );
796
- const iassetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + (0, import_lucid9.fromText)(cdpD.asset);
1095
+ const iassetToken = params.cdpParams.cdpAssetSymbol.unCurrencySymbol + cdpD.iasset;
797
1096
  const assetBurnValue = {};
798
- assetBurnValue[iassetToken] = -BigInt(cdpD.mintedAmount);
1097
+ assetBurnValue[iassetToken] = -BigInt(cdpD.mintedAmt);
799
1098
  const cdpTokenBurnValue = {};
800
- cdpTokenBurnValue[params.cdpParams.cdpAuthToken[0].unCurrencySymbol + (0, import_lucid9.fromText)(params.cdpParams.cdpAuthToken[1].unTokenName)] = -1n;
1099
+ cdpTokenBurnValue[params.cdpParams.cdpAuthToken[0].unCurrencySymbol + (0, import_lucid12.fromText)(params.cdpParams.cdpAuthToken[1].unTokenName)] = -1n;
801
1100
  const cdpAuthTokenScriptRefUtxo = await _CDPContract.cdpAuthTokenRef(
802
1101
  params.scriptReferences,
803
1102
  lucid
804
1103
  );
805
- tx.readFrom([iAssetTokenScriptRefUtxo]).mintAssets(
806
- assetBurnValue,
807
- import_lucid9.Data.to(new import_lucid9.Constr(0, []))
808
- ).readFrom([cdpAuthTokenScriptRefUtxo]).mintAssets(
809
- cdpTokenBurnValue,
810
- import_lucid9.Data.to(new import_lucid9.Constr(0, []))
811
- );
1104
+ tx.readFrom([iAssetTokenScriptRefUtxo]).mintAssets(assetBurnValue, import_lucid12.Data.to(new import_lucid12.Constr(0, []))).readFrom([cdpAuthTokenScriptRefUtxo]).mintAssets(cdpTokenBurnValue, import_lucid12.Data.to(new import_lucid12.Constr(0, [])));
812
1105
  if (fee > 0n) {
813
1106
  await CollectorContract.feeTx(fee, lucid, params, tx, collectorRef);
814
1107
  }
815
1108
  return tx;
816
1109
  }
817
- static decodeCdpDatum(datum) {
818
- const cdpDatum = import_lucid9.Data.from(datum);
819
- if (cdpDatum.index == 1 && cdpDatum.fields[0].index == 0) {
820
- const iasset = cdpDatum.fields[0].fields;
821
- return {
822
- type: "IAsset",
823
- name: (0, import_lucid9.toText)(iasset[0]),
824
- price: iasset[1].index === 0 ? { getOnChainInt: iasset[1].fields[0] } : [
825
- { unCurrencySymbol: iasset[1].fields[0].fields[0].fields[0] },
826
- {
827
- unTokenName: (0, import_lucid9.toText)(iasset[1].fields[0].fields[0].fields[1])
828
- }
829
- ],
830
- interestOracle: [
831
- { unCurrencySymbol: iasset[2].fields[0] },
832
- { unTokenName: (0, import_lucid9.toText)(iasset[2].fields[1]) }
833
- ],
834
- redemptionRatioPercentage: { getOnChainInt: iasset[3].fields[0] },
835
- maintenanceRatioPercentage: { getOnChainInt: iasset[4].fields[0] },
836
- liquidationRatioPercentage: { getOnChainInt: iasset[5].fields[0] },
837
- debtMintingFeePercentage: { getOnChainInt: iasset[6].fields[0] },
838
- liquidationProcessingFeePercentage: {
839
- getOnChainInt: iasset[7].fields[0]
840
- },
841
- stabilityPoolWithdrawalFeePercentage: {
842
- getOnChainInt: iasset[8].fields[0]
843
- },
844
- redemptionReimbursementPercentage: {
845
- getOnChainInt: iasset[9].fields[0]
846
- },
847
- redemptionProcessingFeePercentage: {
848
- getOnChainInt: iasset[10].fields[0]
849
- },
850
- interestCollectorPortionPercentage: {
851
- getOnChainInt: iasset[11].fields[0]
852
- },
853
- firstAsset: iasset[12].index === 1,
854
- nextAsset: iasset[13].index === 0 ? (0, import_lucid9.toText)(iasset[13].fields[0]) : void 0
855
- };
856
- } else if (cdpDatum.index == 0 && cdpDatum.fields[0].index == 0) {
857
- const cdp = cdpDatum.fields[0].fields;
858
- return {
859
- type: "CDP",
860
- owner: cdp[0].fields[0],
861
- asset: (0, import_lucid9.toText)(cdp[1]),
862
- mintedAmount: cdp[2],
863
- fees: cdp[3].index === 0 ? {
864
- type: "ActiveCDPInterestTracking",
865
- last_settled: cdp[3].fields[0],
866
- unitary_interest_snapshot: cdp[3].fields[1]
867
- } : {
868
- type: "FrozenCDPAccumulatedFees",
869
- lovelaces_treasury: cdp[3].fields[0],
870
- lovelaces_indy_stakers: cdp[3].fields[1]
871
- }
872
- };
873
- }
874
- throw "Invalid CDP Datum provided";
875
- }
876
- static encodeCdpDatum(datum) {
877
- if (datum.type === "CDP") {
878
- return import_lucid9.Data.to(
879
- new import_lucid9.Constr(0, [
880
- new import_lucid9.Constr(0, [
881
- datum.owner ? new import_lucid9.Constr(0, [datum.owner]) : new import_lucid9.Constr(1, []),
882
- (0, import_lucid9.fromText)(datum.asset),
883
- BigInt(datum.mintedAmount),
884
- datum.fees.type === "ActiveCDPInterestTracking" ? new import_lucid9.Constr(0, [
885
- datum.fees.last_settled,
886
- datum.fees.unitary_interest_snapshot
887
- ]) : new import_lucid9.Constr(1, [
888
- datum.fees.lovelaces_treasury,
889
- datum.fees.lovelaces_indy_stakers
890
- ])
891
- ])
892
- ])
893
- );
894
- } else if (datum.type === "IAsset") {
895
- return import_lucid9.Data.to(
896
- new import_lucid9.Constr(1, [
897
- new import_lucid9.Constr(0, [
898
- (0, import_lucid9.fromText)(datum.name),
899
- "getOnChainInt" in datum.price ? new import_lucid9.Constr(0, [
900
- new import_lucid9.Constr(0, [BigInt(datum.price.getOnChainInt)])
901
- ]) : new import_lucid9.Constr(1, [
902
- new import_lucid9.Constr(0, [
903
- new import_lucid9.Constr(0, [
904
- datum.price[0].unCurrencySymbol,
905
- (0, import_lucid9.fromText)(datum.price[1].unTokenName)
906
- ])
907
- ])
908
- ]),
909
- new import_lucid9.Constr(0, [
910
- datum.interestOracle[0].unCurrencySymbol,
911
- (0, import_lucid9.fromText)(datum.interestOracle[1].unTokenName)
912
- ]),
913
- new import_lucid9.Constr(0, [
914
- BigInt(datum.redemptionRatioPercentage.getOnChainInt)
915
- ]),
916
- new import_lucid9.Constr(0, [
917
- BigInt(datum.maintenanceRatioPercentage.getOnChainInt)
918
- ]),
919
- new import_lucid9.Constr(0, [
920
- BigInt(datum.liquidationRatioPercentage.getOnChainInt)
921
- ]),
922
- new import_lucid9.Constr(0, [
923
- BigInt(datum.debtMintingFeePercentage.getOnChainInt)
924
- ]),
925
- new import_lucid9.Constr(0, [
926
- BigInt(datum.liquidationProcessingFeePercentage.getOnChainInt)
927
- ]),
928
- new import_lucid9.Constr(0, [
929
- BigInt(datum.stabilityPoolWithdrawalFeePercentage.getOnChainInt)
930
- ]),
931
- new import_lucid9.Constr(0, [
932
- BigInt(datum.redemptionReimbursementPercentage.getOnChainInt)
933
- ]),
934
- new import_lucid9.Constr(0, [
935
- BigInt(datum.redemptionProcessingFeePercentage.getOnChainInt)
936
- ]),
937
- new import_lucid9.Constr(0, [
938
- BigInt(datum.interestCollectorPortionPercentage.getOnChainInt)
939
- ]),
940
- datum.firstAsset ? new import_lucid9.Constr(1, []) : new import_lucid9.Constr(0, []),
941
- datum.nextAsset ? new import_lucid9.Constr(0, [(0, import_lucid9.fromText)(datum.nextAsset)]) : new import_lucid9.Constr(1, [])
942
- ])
943
- ])
944
- );
945
- }
946
- throw "Invalid CDP Datum provided";
947
- }
948
- static datum(hash, asset, mintedAmount, fees) {
949
- return new import_lucid9.Constr(0, [
950
- new import_lucid9.Constr(0, [
951
- new import_lucid9.Constr(0, [hash.hash]),
952
- (0, import_lucid9.fromText)(asset),
953
- BigInt(mintedAmount),
954
- fees.type === "ActiveCDPInterestTracking" ? new import_lucid9.Constr(0, [
955
- BigInt(fees.last_settled),
956
- BigInt(fees.unitary_interest_snapshot)
957
- ]) : new import_lucid9.Constr(0, [
958
- BigInt(fees.lovelaces_treasury),
959
- BigInt(fees.lovelaces_indy_stakers)
960
- ])
961
- ])
962
- ]);
963
- }
964
1110
  static validator(params) {
965
1111
  return {
966
1112
  type: _cdpValidator.type,
967
- script: (0, import_lucid9.applyParamsToScript)(_cdpValidator.cborHex, [
968
- new import_lucid9.Constr(0, [
969
- new import_lucid9.Constr(0, [
1113
+ script: (0, import_lucid12.applyParamsToScript)(_cdpValidator.cborHex, [
1114
+ new import_lucid12.Constr(0, [
1115
+ new import_lucid12.Constr(0, [
970
1116
  params.cdpAuthToken[0].unCurrencySymbol,
971
- (0, import_lucid9.fromText)(params.cdpAuthToken[1].unTokenName)
1117
+ (0, import_lucid12.fromText)(params.cdpAuthToken[1].unTokenName)
972
1118
  ]),
973
1119
  params.cdpAssetSymbol.unCurrencySymbol,
974
- new import_lucid9.Constr(0, [
1120
+ new import_lucid12.Constr(0, [
975
1121
  params.iAssetAuthToken[0].unCurrencySymbol,
976
- (0, import_lucid9.fromText)(params.iAssetAuthToken[1].unTokenName)
1122
+ (0, import_lucid12.fromText)(params.iAssetAuthToken[1].unTokenName)
977
1123
  ]),
978
- new import_lucid9.Constr(0, [
1124
+ new import_lucid12.Constr(0, [
979
1125
  params.stabilityPoolAuthToken[0].unCurrencySymbol,
980
- (0, import_lucid9.fromText)(params.stabilityPoolAuthToken[1].unTokenName)
1126
+ (0, import_lucid12.fromText)(params.stabilityPoolAuthToken[1].unTokenName)
981
1127
  ]),
982
- new import_lucid9.Constr(0, [
1128
+ new import_lucid12.Constr(0, [
983
1129
  params.versionRecordToken[0].unCurrencySymbol,
984
- (0, import_lucid9.fromText)(params.versionRecordToken[1].unTokenName)
1130
+ (0, import_lucid12.fromText)(params.versionRecordToken[1].unTokenName)
985
1131
  ]),
986
- new import_lucid9.Constr(0, [
1132
+ new import_lucid12.Constr(0, [
987
1133
  params.upgradeToken[0].unCurrencySymbol,
988
- (0, import_lucid9.fromText)(params.upgradeToken[1].unTokenName)
1134
+ (0, import_lucid12.fromText)(params.upgradeToken[1].unTokenName)
989
1135
  ]),
990
1136
  params.collectorValHash,
991
1137
  params.spValHash,
992
- new import_lucid9.Constr(0, [
1138
+ new import_lucid12.Constr(0, [
993
1139
  params.govNFT[0].unCurrencySymbol,
994
- (0, import_lucid9.fromText)(params.govNFT[1].unTokenName)
1140
+ (0, import_lucid12.fromText)(params.govNFT[1].unTokenName)
995
1141
  ]),
996
1142
  BigInt(params.minCollateralInLovelace),
997
1143
  BigInt(params.partialRedemptionExtraFeeLovelace),
@@ -1002,14 +1148,14 @@ var CDPContract = class _CDPContract {
1002
1148
  };
1003
1149
  }
1004
1150
  static validatorHash(params) {
1005
- return (0, import_lucid9.validatorToScriptHash)(_CDPContract.validator(params));
1151
+ return (0, import_lucid12.validatorToScriptHash)(_CDPContract.validator(params));
1006
1152
  }
1007
1153
  static address(cdpParams, lucid, skh) {
1008
1154
  const network = lucid.config().network;
1009
1155
  if (!network) {
1010
1156
  throw new Error("Network configuration is undefined");
1011
1157
  }
1012
- return (0, import_lucid9.validatorToAddress)(network, _CDPContract.validator(cdpParams), skh);
1158
+ return (0, import_lucid12.validatorToAddress)(network, _CDPContract.validator(cdpParams), skh);
1013
1159
  }
1014
1160
  static scriptRef(params, lucid) {
1015
1161
  return scriptRef(params.cdpValidatorRef, lucid);
@@ -1025,43 +1171,1901 @@ var CDPContract = class _CDPContract {
1025
1171
  }
1026
1172
  };
1027
1173
 
1028
- // src/helpers/cdp-helpers.ts
1029
- var CDPHelpers = class {
1030
- static async cdps(params, lucid) {
1031
- throw new Error("Not implemented");
1174
+ // src/contracts/gov.ts
1175
+ var GovContract = class {
1176
+ };
1177
+
1178
+ // src/contracts/stability-pool.ts
1179
+ var import_lucid16 = require("@lucid-evolution/lucid");
1180
+
1181
+ // src/types/indigo/stability-pool.ts
1182
+ var import_lucid13 = require("@lucid-evolution/lucid");
1183
+ var import_ts_pattern3 = require("ts-pattern");
1184
+ var SPIntegerSchema = import_lucid13.Data.Object({
1185
+ value: import_lucid13.Data.Integer()
1186
+ });
1187
+ var SPInteger = SPIntegerSchema;
1188
+ var StabilityPoolSnapshotSchema = import_lucid13.Data.Object({
1189
+ productVal: SPIntegerSchema,
1190
+ depositVal: SPIntegerSchema,
1191
+ sumVal: SPIntegerSchema,
1192
+ epoch: import_lucid13.Data.Integer(),
1193
+ scale: import_lucid13.Data.Integer()
1194
+ });
1195
+ var StabilityPoolSnapshot = StabilityPoolSnapshotSchema;
1196
+ var EpochToScaleToSumSchema = import_lucid13.Data.Map(
1197
+ import_lucid13.Data.Object({ epoch: import_lucid13.Data.Integer(), scale: import_lucid13.Data.Integer() }),
1198
+ SPIntegerSchema,
1199
+ { minItems: 0 }
1200
+ );
1201
+ var EpochToScaleToSum = EpochToScaleToSumSchema;
1202
+ var StabilityPoolContentSchema = import_lucid13.Data.Object({
1203
+ asset: import_lucid13.Data.Bytes(),
1204
+ snapshot: StabilityPoolSnapshotSchema,
1205
+ epochToScaleToSum: EpochToScaleToSumSchema
1206
+ });
1207
+ var StabilityPoolContent = StabilityPoolContentSchema;
1208
+ var AccountActionSchema = import_lucid13.Data.Enum([
1209
+ import_lucid13.Data.Literal("Create"),
1210
+ import_lucid13.Data.Object({
1211
+ Adjust: import_lucid13.Data.Object({
1212
+ amount: import_lucid13.Data.Integer(),
1213
+ outputAddress: AddressSchema
1214
+ })
1215
+ }),
1216
+ import_lucid13.Data.Object({ Close: import_lucid13.Data.Object({ outputAddress: AddressSchema }) })
1217
+ ]);
1218
+ var AccountAction = AccountActionSchema;
1219
+ var AccountContentSchema = import_lucid13.Data.Object({
1220
+ owner: import_lucid13.Data.Bytes(),
1221
+ asset: import_lucid13.Data.Bytes(),
1222
+ snapshot: StabilityPoolSnapshotSchema,
1223
+ request: import_lucid13.Data.Nullable(AccountActionSchema)
1224
+ });
1225
+ var AccountContent = AccountContentSchema;
1226
+ var SnapshotEpochToScaleToSumContentSchema = import_lucid13.Data.Object({
1227
+ asset: import_lucid13.Data.Bytes(),
1228
+ snapshot: EpochToScaleToSumSchema
1229
+ });
1230
+ var SnapshotEpochToScaleToSumContent = SnapshotEpochToScaleToSumContentSchema;
1231
+ var StabilityPoolDatumSchema = import_lucid13.Data.Enum([
1232
+ import_lucid13.Data.Object({
1233
+ StabilityPool: import_lucid13.Data.Object({ content: StabilityPoolContentSchema })
1234
+ }),
1235
+ import_lucid13.Data.Object({ Account: import_lucid13.Data.Object({ content: AccountContentSchema }) }),
1236
+ import_lucid13.Data.Object({
1237
+ SnapshotEpochToScaleToSum: import_lucid13.Data.Object({
1238
+ content: SnapshotEpochToScaleToSumContentSchema
1239
+ })
1240
+ })
1241
+ ]);
1242
+ var StabilityPoolDatum = StabilityPoolDatumSchema;
1243
+ var ActionReturnDatumSchema = import_lucid13.Data.Enum([
1244
+ import_lucid13.Data.Object({
1245
+ IndigoStabilityPoolAccountAdjustment: import_lucid13.Data.Object({
1246
+ spent_account: OutputReferenceSchema
1247
+ })
1248
+ }),
1249
+ import_lucid13.Data.Object({
1250
+ IndigoStabilityPoolAccountClosure: import_lucid13.Data.Object({
1251
+ closed_account: OutputReferenceSchema
1252
+ })
1253
+ })
1254
+ ]);
1255
+ var ActionReturnDatum = ActionReturnDatumSchema;
1256
+ var StabilityPoolRedeemerSchema = import_lucid13.Data.Enum([
1257
+ import_lucid13.Data.Object({ RequestAction: import_lucid13.Data.Object({ action: AccountActionSchema }) }),
1258
+ import_lucid13.Data.Object({
1259
+ ProcessRequest: import_lucid13.Data.Object({ requestRef: OutputReferenceSchema })
1260
+ }),
1261
+ import_lucid13.Data.Object({ AnnulRequest: import_lucid13.Data.Object({}) }),
1262
+ import_lucid13.Data.Object({ LiquidateCDP: import_lucid13.Data.Object({}) }),
1263
+ import_lucid13.Data.Object({ RecordEpochToScaleToSum: import_lucid13.Data.Object({}) }),
1264
+ import_lucid13.Data.Object({ UpgradeVersion: import_lucid13.Data.Object({}) })
1265
+ ]);
1266
+ var StabilityPoolRedeemer = StabilityPoolRedeemerSchema;
1267
+ function parseStabilityPoolDatum(datum) {
1268
+ return (0, import_ts_pattern3.match)(import_lucid13.Data.from(datum, StabilityPoolDatum)).with({ StabilityPool: { content: import_ts_pattern3.P.select() } }, (res) => res).otherwise(() => {
1269
+ throw new Error("Expected a Stability Pool datum.");
1270
+ });
1271
+ }
1272
+ function parseAccountDatum(datum) {
1273
+ return (0, import_ts_pattern3.match)(import_lucid13.Data.from(datum, StabilityPoolDatum)).with({ Account: { content: import_ts_pattern3.P.select() } }, (res) => res).otherwise(() => {
1274
+ throw new Error("Expected a StakingPosition datum.");
1275
+ });
1276
+ }
1277
+ function parseSnapshotEpochToScaleToSumDatum(datum) {
1278
+ return (0, import_ts_pattern3.match)(import_lucid13.Data.from(datum, StabilityPoolDatum)).with({ SnapshotEpochToScaleToSum: { content: import_ts_pattern3.P.select() } }, (res) => res).otherwise(() => {
1279
+ throw new Error("Expected a SnapshotEpochToScaleToSum datum.");
1280
+ });
1281
+ }
1282
+ function serialiseStabilityPoolDatum(d) {
1283
+ let cbor = import_lucid13.Data.to(d, StabilityPoolDatum);
1284
+ if ("StabilityPool" in d) {
1285
+ if (cbor.includes("bf")) {
1286
+ if (d.StabilityPool.content.epochToScaleToSum.size > 0) {
1287
+ cbor = cbor.replace(
1288
+ "bf",
1289
+ "a" + d.StabilityPool.content.epochToScaleToSum.size
1290
+ );
1291
+ cbor = cbor.replace("ffffff", "ffff");
1292
+ }
1293
+ }
1032
1294
  }
1295
+ return cbor;
1296
+ }
1297
+ function serialiseStabilityPoolRedeemer(params) {
1298
+ return import_lucid13.Data.to(params, StabilityPoolRedeemer);
1299
+ }
1300
+ var StabilityPoolParamsSchema = import_lucid13.Data.Object({
1301
+ assetSymbol: import_lucid13.Data.Bytes(),
1302
+ stabilityPoolToken: AssetClassSchema,
1303
+ snapshotEpochToScaleToSumToken: AssetClassSchema,
1304
+ accountToken: AssetClassSchema,
1305
+ cdpToken: AssetClassSchema,
1306
+ iAssetAuthToken: AssetClassSchema,
1307
+ versionRecordToken: AssetClassSchema,
1308
+ collectorValHash: import_lucid13.Data.Bytes(),
1309
+ govNFT: AssetClassSchema,
1310
+ accountCreateFeeLovelaces: import_lucid13.Data.Integer(),
1311
+ accountAdjustmentFeeLovelaces: import_lucid13.Data.Integer(),
1312
+ requestCollateralLovelaces: import_lucid13.Data.Integer()
1313
+ });
1314
+ var StabilityPoolParams = StabilityPoolParamsSchema;
1315
+ function castStabilityPoolParams(params) {
1316
+ return import_lucid13.Data.castTo(params, StabilityPoolParams);
1317
+ }
1318
+ var spPrecision = 1000000000000000000n;
1319
+ function mkSPInteger(value) {
1320
+ return { value: value * spPrecision };
1321
+ }
1322
+ function fromSPInteger(value) {
1323
+ return value.value / spPrecision;
1324
+ }
1325
+ function spAdd(a, b) {
1326
+ return { value: a.value + b.value };
1327
+ }
1328
+ function spSub(a, b) {
1329
+ return { value: a.value - b.value };
1330
+ }
1331
+ function spMul(a, b) {
1332
+ return { value: a.value * b.value / spPrecision };
1333
+ }
1334
+ function spDiv(a, b) {
1335
+ return { value: a.value * spPrecision / b.value };
1336
+ }
1337
+
1338
+ // src/scripts/stability-pool-validator.ts
1339
+ var import_lucid15 = require("@lucid-evolution/lucid");
1340
+
1341
+ // src/types/system-params.ts
1342
+ var import_lucid14 = require("@lucid-evolution/lucid");
1343
+ function toSystemParamsAsset(asset) {
1344
+ return [
1345
+ { unCurrencySymbol: asset.currencySymbol },
1346
+ { unTokenName: (0, import_lucid14.toText)(asset.tokenName) }
1347
+ ];
1348
+ }
1349
+ function fromSystemParamsAsset(asset) {
1350
+ return {
1351
+ currencySymbol: asset[0].unCurrencySymbol,
1352
+ tokenName: (0, import_lucid14.fromText)(asset[1].unTokenName)
1353
+ };
1354
+ }
1355
+
1356
+ // src/scripts/stability-pool-validator.ts
1357
+ var stabilityPoolValidator = {
1358
+ type: "PlutusV2",
1359
+ description: "",
1360
+ cborHex: "5939ed5939ea01000032323232323232322232323232323232323232323232322323232323225333018323232533301b3012301d37540022646464646464646464646464646464646464646464646464646464646464646464646464646464a646464646466608e6088056264a666090607e60946ea81184cc88c8c94ccc140c14c00854ccc140c14ccc074dd6181318279baa0333026304f3754604c609e6ea8c094c13cdd5000899299982699816a48115496e76616c6964206163636f756e742069706e757400300b3027305037540042a66609a6605a9201274163636f756e74206f776e6572206d757374207369676e20746865207472616e73636174696f6e003302e034375c604e60a06ea801054ccc134cc0b524011543616e6e6f74206d696e7420616e7920746f6b656e0000713302d49116496d70726f706572204163636f756e7420646174756d0032533304e304500113302e49011d4163636f756e74206f757470757420646f6573206e6f74206d6174636800333330133758602a60a26ea80d4c024cc14c0092f5c06014660a66012660a664646034660aa60ac004660aa60ac002660aa60ac60ae002660aa6034660aa01297ae04bd70182b00098289baa0054bd7025eb80cccc048cc044c098c088c144dd502699b80375a604a60a26ea8134dd6980318289baa04d375c605060a26ea8134dd7181398289baa0053023375a60a860a26ea801d300103d87a80001533304e304200113302e4911d4163636f756e74206f757470757420646f6573206e6f74206d6174636800333330133758602a60a26ea80d4c024cc14c0092f5c06014660a66012660a664646034660aa60ac004660aa60ac002660aa60ac60ae002660aa6034660aa01297ae04bd70182b00098289baa0054bd7025eb80cc044c098c088c144dd50269bad30063051375409a980103d87a800014a0609e6ea80185280a5014a0604c609e6ea8c094c13cdd50008b0b18288009998049bac3024304d3754062603c609a6ea812530103d87980002304f30503050305030503050305030503050305030503050001304e304b375408c2940c134c128dd501b099191919191919191919191919191929919982b982701d89919299982c982b000899191929998301831801099299982e982d182f9baa00113232533305f30563061375400226464a6660ca60d0004264a6660c46464a6660c860c260cc6ea800854ccc190c184c198dd5183518339baa00213304449138437265617465206163636f756e7420726571756573742063616e6e6f74206861766520616e206175746820746f6b656e20616c72656164790030613322333028002375c608060d26ea8004dd7181f98349baa0013756607a60ce6ea8c0f4c19cdd5003981c18339baa063001001133043491204163636f756e74206973206d697373696e6720616e206175746820746f6b656e00330243756607860cc6ea8c0f0c198dd5003181b98331baa0623036306537540042a6660c46608492011c496e76616c69642073746162696c69747920706f6f6c20696e707574003020303c3065375400e2a6660c4660849201314d697865642076657273696f6e73206265747765656e2073746162696c69747920706f6f6c20616e642072657175657374003375e607860ca6ea8c0f0c194dd5181d98329baa005303c30653754607860ca6ea8c0ecc194dd5003899821249234d75737420636f6e73756d65204163636f756e74205554784f20636f72726563746c790032323375e004603e660d201a97ae0304e0013300e00b3756603460ca6ea81245280a5014a060a60022c60cc00260c46ea800458c024c094c184dd5181b98309baa0013063306037540022c6602a00600a2c60c2002666032002606660ba6ea8165300103d8798000375860be60b86ea810054ccc164c1400044cc8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c88c8c94ccc1bcc1b0c1c4dd5000899191919299983b983d001099299983a1838983b1baa00113232533307a307d0021325332330783305849011854686520617373657420646f6573206e6f74206d61746368003001375c60a260f66ea803054ccc1e0cc1612401354f6e6c79207468652053746162696c69747920506f6f6c20616e6420746865204163636f756e742063616e20626520696e7075747300306c300d008153330783305849012a4d75737420636f6e73756d652053746162696c69747920506f6f6c205554784f20636f72726563746c790032323375e004606a660fe60a860fa6ea802d2f5c060c80026604860a460f66ea8018dd59818183d9baa05f13232533307a3071001153307b49012043616e6e6f742070726f6365737320616e20656d70747920726571756573742e0016132533307b30780021533307b3078307d375461020260fc6ea800c4c8c8c94ccc1f8cc1792411a4d757374206d696e7420616e206163636f756e7420746f6b656e00303b374c60ac60a46102026ea81f454ccc1f8cc1792401275265717565737420696e7075742063616e20636f6e7461696e206f6e6c792032206173736574730030723021304b375660ae6102026ea8c15cc20404dd50078a99983f1982f2490b4163636f756e74203e203000303e0011533307e3305e49012453746162696c69747920506f6f6c206f757470757420646f6573206e6f74206d61746368003232333330453758608e6106026ea819cc0eccc214040112f5c060786610a0260946610a0260946610a0260b46106026ea802ccc21404004cc21404dd319981a9bab3047308301375401660946610a0260a86106026ea8c164c20c04dd5005998428098299841809baa3059308301375401697ae03047308301375400297ae04bd7025eb80cc10ccccc110dd5982c9841809baa3059308301375401c6eb8c168c20c04dd503f9bae305a30830137540160066eb4c0e0c20c04dd503fa60103d879800032304a3308501308601001330850100233085013302d3047308301375460b26106026ea802ccc0c8cc0c4c0b8dd6981c1841809baa07f305a308301375460b26106026ea802c008c21c04c21c04c21c04004c20804dd5182c1841009baa00a3302b3057308101375460ae6102026ea8024c0b00044cc1792411d4163636f756e74206f757470757420646f6573206e6f74206d6174636800333330433758608a6102026ea8194c0e4cc20c040092f5c06074661060260726610602609066106026ea400ccc20c04c160c20404dd500499841809918249984200984280800998420098168011843009843008009840809baa30573081013754012661060298103d87a80004bd7025eb812f5c06608260ac60a46102026ea81f4cdc099b813032375660ae6102026ea8c15cc20404dd50079bad303630810137540fa60646eacc148c20404dd5032a60103d87a800014a029405280a5033303f375660ac6100026ea8c158c20004dd50071bae305730800137540f86eb8c15cc20004dd5004182b183f9baa3055307f37540146eb8c154c1f8dd5007800800899299983d983c001099299983e1838183f1baa0011323232325333084013087010021325333081013078308301375400226464a66610e02611402004264646464646464646464a66611a02660da9211854686520617373657420646f6573206e6f74206d61746368003016375c60ce6120026ea802c54ccc23404cc1b524011b4d757374206275726e20746865206163636f756e7420746f6b656e00304a374c60b060ca60c26120026ea82300454ccc23404cc1b524012453746162696c69747920506f6f6c206f757470757420646f6573206e6f74206d617463680033333052375860a86120026ea81d0c120cc248040412f5c06092661240260ae66124026460b066126026128020026612602004612a02612a020026120026ea80612f5c097ae0333305133050375660cc6120026ea8c198c24004dd500d982c8039bae30673090013754118026eb8c19cc24004dd500c19b8030590040034c103d87980001533308d013306d491524d7573742073656e642074686520616d6f756e7420696e20746865206163636f756e7420616e64207468652072656d61696e696e6720636f6c6c61746572616c206261636b20746f20746865206f776e65720033333052375860a86120026ea81d0c120cc248040452f5c0609266124026090661240260ce6120026ea80792f5c097ae033330513305033056375660cc6120026ea8c198c24004dd500f182c183298309848009baa08c013370266e0401c018c104dd598309848009baa074375c60ce6120026ea823004dd718339848009baa0183370200800698103d87a800013306d49011f4d757374207061792070726f746f636f6c2066656520636f72726563746c79003333302c375860a86120026ea81d0dd618339848009baa0743756608a6120026ea81d0dd718169848009baa08c0100614a029405280a5030563309101308f010013309101308e01001309301309301308f01375460ca611e026ea805cccc0a400400cc190c23804dd500b29998450099baf00230384800052000133025306c308d01375401000260bc6056008604a6606e60c26116026ea8c184c22c04dd500980199811198119bac3060308a0137540dc60d26114026ea821804004dd69844808011843808009919192999843809842009844809baa00213376060c06114026ea8004c23404c22804dd50010a9984400a492245706f6368546f5363616c65546f53756d206d6170206d697373696e67206974656d001630880100230880100133301d305d308701375401e6096610e026ea8060cccc07820c04dd7182f1843809baa00f37566096610e026ea803cdd6182e9843809baa06b301b0011630880100130840137540022c6056608e6106026ea8c164c20c04dd50008b18428080099981e9bac305730810137540ca602a6102026ea81f530103d87980003057308001375460ac6100026ea802cc20804c1fcdd5000801184080983f1baa003001132332232323253330840130870100213232533308601308901002132533308301307a308501375400226464a666112026118020042646464646464646464646464646464a66612802660e89211854686520617373657420646f6573206e6f74206d6174636800301d375c60dc612e026ea804054ccc25004cc1d124011d4163636f756e74206f757470757420646f6573206e6f74206d617463680033333059375860b6612e026ea81ecc13ccc26404c1b8c25c04dd51836984b809baa0224bd7018281984c8098279984c80982f1984c809837184b809baa0283309901306e309701375403e66132020106613202980103d87a80004bd7025eb812f5c0660ae60d860d0612e026ea824c04cdc099b813370260906eacc1b4c25c04dd51836984b809baa025375a60d6612e026ea824c04c120dd59834184b809baa07b3370066e04c120dd59836984b809baa01500c00b4c103d87a80001533309401330744911f4d757374207061792070726f746f636f6c2066656520636f72726563746c790033333033375860b6612e026ea81ecdd61837184b809baa07b37566098612e026ea81ecdd7181a184b809baa0930100b15333094013307449012453746162696c69747920506f6f6c206f757470757420646f6573206e6f74206d617463680033333059375860b6612e026ea81ecc13ccc2640405d2f5c060a0661320260bc661320260bc661320260dc612e026ea807ccc26404008cc26404dd3000a5eb812f5c097ae0333305833057375660da612e026ea8c1b4c25c04dd501119b81375a60d6612e026ea824c04030dd71837184b809baa09301375c60dc612e026ea807ccdc000480326103d87a8000153330940133074491244d7573742073656e6420617070726f7072696174652076616c756520746f206f776e6572003333305933099010154bd7018279984c8080c25eb80c140cc26404c178cc26404c1b8c25c04dd5012a5eb812f5c0a666128020142606a66e0403002c4cccc160c0d4cdc08060059bae306e3097013754126026eb8c1b8c25c04dd500f99b8130600090064c0103d87a800013307449011543616e6e6f74206d696e7420616e7920746f6b656e0004e14a029405280a5014a06660906eacc168c25804dd500f182e9984c009833984b009baa306c309601375403c661300260cc612c026ea8c1b0c25804dd500f25eb80c168c25804dd5000982e1984b808009984b808011984b809981f982c984a809baa306b309501375403a660886608660806eb4c1a4c25404dd504880800801184c80984c80984c80984a809baa306b309501375403a61280200461240200266605a00200460d06124026ea80694ccc238054ccc23804010528899baf001303c48000520001330293070309101375401460b400660546607460cc6120026ea8c198c24004dd500c181d80119182b998490098498080099849009981d18331848009baa006303b002309401309401001308f01375400aa6661160200220202660c202060ae605a60c8611c026ea8010c14003ccc090cc094dd618311846009baa070306b308c013754110020026eb4c22c04008c22404004c8c8c94ccc22404c21804c22c04dd5001099bb0001308f01308c0137540042a661140292012245706f6368546f5363616c65546f53756d206d6170206d697373696e67206974656d0016308a01002308a0100133301f305f3089013754022609a6112026ea8068cccc08021404dd718301844809baa0113756609a6112026ea8044dd6182f9844809baa06d301d00116308a0100130860137540022c605a6092610a026ea8c16cc21404dd50008b18438080099981f9bac305930830137540ce602e6106026ea81fd30103d879800016308501001330313758608a6102026ea8194c0e4cc20c040092f5c060ae6100026ea8c158c20004dd50059bad308101001308101308201001307d375461000260fa6ea8008c1ecdd50009826183d9baa00c14a02940dc79bae3051307a37540042940c1b800458c1ec004c1dcdd50008b180f181d183b1baa304c307637540022c60f0002666060002609460e86ea81c1300103d879800033041003304a30733754609460e66ea8c124c1ccdd5000983a98391baa0011633027001053375860e660e06ea8150c004004894ccc1c000452000130163300200230730012307030713071307130713071001253330693066306b3754002264646464646464646464646464646464646464646464646464646464a666112026118020042646464646464646464646464931820006181b007981a808181a00898198091819009981880a181800a981780b181700b981600c192999843009841808008991929998460098478080109924c605e0022c611a020026112026ea806854ccc21804c1f40044c8c94ccc23004c23c040084c926533308801308501308a01375400226464a66611c026122020042649318180008b1847808009845809baa0011616308d0100130890137540342c610e026ea806458c22804004c22804008c94ccc21c04c2180400454ccc20c04c1e8c214040045288a999841809840009842808008a5016163754611002002611002004610c02002610c0200461080200261080200461040200261040200461000200261000200460fc00260fc00460f800260f800460f400260f400460f000260f000460ec00260ec00460e800260e800460e400260e40046eb8c1c0004c1b0dd50008b1111919bb032303633071307200133071533306c337106eb4c118c1bcdd50011bad3046306f37546603c608a60de6ea8010c0692080a8d6b90714c0105d8799f00ff00100230733073001306e375400864a6660d860c660dc6ea8004530103d87a80001303633071375064601e6603e6603c6603466038002606860e06ea8014cc07ccc070c94ccc1b8c194c1c0dd500088010983a18389baa0013301200430373307230413070375400a660e46ea0c05cdd6982018381baa0054bd70000980da410151ad720e608c60e06ea8014c11cc1c0dd5002983918379baa0014bd7019808001181a99838181f98371baa00333070303e306e375400697ae0533306a337106eb4c0f8c1b4dd50011bad303e306d3754006298105d8799f00ff001533306a33710900119b81375a607a60da6ea800cdd6981e98369baa00214c0105d8799f00ff001533306a337106eb4c0f4c1b4dd50011bad303d306d375400626603866036608660da6ea8008c110c1b4dd5001981a198379ba8337046eb4c110c1b4dd5182218369baa00248202a35ae41d2f5c026603866036608660da6ea8008c110c1b4dd5001982218369baa00222223302032333001001323300100100322533307100114bd6f7b630099192999837983318389baa001133004004002133074323376060ec00260ec60ee0026eb0c1d4c1c8dd500099802002001192999837998181bab304830723754002606c60e46ea80244c94ccc1c0c190c1c8dd500089919299983b183c801099299983999b8f375c609860ec6ea80080304c0f4cc1e0c8dd39983c983b0009983c983b800a5eb80cdd81826983b1baa002304c3076375400497ae015330744912d45706f6368546f5363616c65546f53756d2072656620696e7075747320686176652077726f6e6720617373657400163063001163077001307337540022c6034606c60e46ea8004530103d87a800030473071375460e800460e800297adef6c60222533307100210011333003003307400233023001375660de60e600400444a6660ce66e2400520001480004dd6982098351baa30313306c375066e0ccdc11bad3041306a37546062660d86ea0cdc199b82375a608260d46ea8c0c4cc1b0dd4000a5eb80dd6982098351baa0024820225e92f5c0904044bd1bad3041306a37546062660d86ea0cdc12419002904044bd25eb812f5c044607260d26ea8c0fcc1a4dd5191929998361837801099190012999834983318359baa00113232323232323232323232325333079307c0021324994ccc1d4c1c8c1dcdd50048991919191919191919191919191919191919191929998468098480080109924c60600162c6eb4c23804004c23804008dd69846008009846008011bad308a01001308a01002375a6110020026110020046eb4c21804004c21804008c21004004c21004008dd69841008009841008011bad308001001308001002375a60fc00260fc0046eb4c1f0004c1e0dd50048b0b1bad307a001307a002375a60f000260f00046eb4c1d8004c1d8008dd6983a000983a001183900098390011bad3070001306c37540022c6026605e60d66ea8c104c1acdd50008b1836800999812801000a6103d8798000253330643024375a607c60ce6ea800440045300105d8799f00ff00222323376066026006002a6660cc60c60082608060d26ea80084cc05cc100c1a4dd500119809980a240046603000200660260064444464a6660ce604e004264a6660d06464608c00464a6660d460ce0022a6660dc60da6ea8008526161533306a30610011533306e306d37540042930b0a999835182f0008a99983718369baa00214985858c1acdd50009980a182118359baa00100513333302d00730233306d30323306d0023306d4c103d87a80004bd7025eb8130107d87b9fd87980ff003302b3756608260d66ea8c104c1acdd5000801a60103d879800014a064a6660d80022a660d2921284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400161533306c306f0011306e00115330694901284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400163303800500114a26042660d66ea40092f5c0460ce60d060d060d060d060d060d060d00024666076911004881000012337066eb4c0e4c188dd5000a41010141ede959b7c036600200244a6660c400229000098041980100118328009119299982f182a98301baa00114c103d87a800013028330633061323376060ca00260ca60cc0026eb0c190c184dd5000a5eb80cc0500088cdd798300008011299982d982c182e9baa00113232323253330633066002149858dd7183200098320011bae3062001305e37540022c4a6660b460ae60b86ea80044c8c94ccc180c18c00852616375a60c200260ba6ea800458c17cc170dd502b8a50305a37540ac60ba60b46ea811854ccc15cc12c0ec54ccc15cc138c164dd502a89919299982c982b182d9baa001132533305e30613302b3758606860ba6ea8104c0d0c174dd50008a99982d1981d249415265717565737420616e6e756c6d656e74207472616e73616374696f6e206d757374206265207369676e6564206279207468652072657175657374206f776e6572003303b041375c606860ba6ea800c54ccc168cc0e924011543616e6e6f74206d696e7420616e7920746f6b656e0001413232533305c3053001153305d491185265717565737420697320616c726561647920656d7074790016132533305d305a0021533305d305a305f375460c660c06ea800c52880080089981e2491d4163636f756e74206f757470757420646f6573206e6f74206d6174636800333330213758604660be6ea810cc05ccc18400d2f5c06030660c2602e660c264646050660c660c8004660c660c8002660c660c860ca002660c698103d87a80004bd701832000982f9baa0054bd7025eb80c0d0c0c0c17cdd502da60103d87a8000305d3754002605c60ba6ea800c5280a50163033305c3754606460b86ea8c17cc170dd50008b198089bac3032305b375407e07a60ba60b46ea815452809919299982c982301e8a99982c982b182d9baa05713232323232533305e305b30603754002264646464a6660cc60d2004264a6660c660c060ca6ea80044c8c94ccc1a4c1b000854ccc194c188c19cdd5000899191919191919192999838983a001099191919299983a983c0010991919299983a1982a2493f45706f6368546f5363616c65546f53756d206d617020697320746f6f206c617267652c20757365205265636f726445706f6368546f5363616c65546f53756d003371260386eacc0ecc1dcdd500da40142a6660e8660a892131694173736574206f662073746162696c69747920706f6f6c206d757374206d6174636820694173736574206f6620636470003371e0186eb8c138c1dcdd500d8a99983a1982a2491c43445020696e707574206d757374206265206c6971756964617465640032323375e004980103d87f800032533307630730011323232323232533308001308301002149858dd69840808009840808011bad307f001307f002375a60fa00260f26ea800854ccc1d8c1b40044c8c94ccc1f0c1fc00852616375a60fa00260f26ea800854ccc1d8c1a80044c8c94ccc1f0c1fc00852616375a60fa00260f26ea800854ccc1d8c18c0044c8c94ccc1f0c1fc00852616375a60fa00260f26ea800854ccc1d8c18800454ccc1e8c1e4dd50010a4c2c2a6660ec66e1d200a00113232533307c307f002132498c19800458c1f4004c1e4dd50010a99983b19b874803000454ccc1e8c1e4dd50010a4c2c2a6660ec66e1d200e0011533307a307937540042930b0a99983b19b874804000454ccc1e8c1e4dd50010a4c2c2c60ee6ea8004cc080c138c1dcdd50099bab302c307737540b62a6660e8660a89211c53746162696c697479506f6f6c206f7574707574206d697373696e6700330353756609a60ee6ea8c134c1dcdd500b1826983b9baa07313305449011f496e636f72726563742053746162696c69747920506f6f6c204f7574707574003375e607660ee6ea8010c0c0cc1e4c0f8cc1e4c0f8cc1e4c138c1dcdd500d9983c8011983c9ba60014bd7025eb812f5c029405280a5014a06eacc1d8008c1d0004c8c8c8c8c8c8c8cdd8299983c0008991919182299840009840808019984000984080801198400098408080099840009ba83025375a609e60fc6ea8028c20804c20804004c20404004c20004004c1ecdd52611dd8799fd8799f1b0de0b6b3a7640000ffd8799f00ffd8799f00ff0000ff00130423307d0033307d330273051307b375400e00c660fa004660fa609860f66ea801ccc1f4dd419b80375a609660f66ea801d4ccc1e0010520021480012f5c06e98c94ccc1e40084ccc0b8004c10ccc1f8dd418119bad304d307c3754010660fc9810100004bd701813a40002a6660f200a266605c0026086660fc609a60f86ea8020cc1f8dd418119bad304c307c375401097ae0003100133302d3756607e60f66ea807cc108cc1f4c130c1ecdd50039983e9825983d9baa0074bd7000119b89375a60a260f46ea8009200033023303d3079375400a660506604e604866e04c0a8dd59827983c9baa006302a3756609e60f26ea8c13cc1e4dd500c1828183c9baa005304f3079375400a6604c607e660f46ea0cdc1299983a8008a410151ad720e290011bad304f30783754609e60f06ea80112f5c000466e20dd69827183b9baa33025304e307737540060029040546b5c83998111810a40046604a002609860ec6ea8008c080c0f8ccc0d0c140dd59822983a9baa059375c609860ea6ea81c4dd71826183a9baa019304a307437540302c60ec002660440266054660e802097ae032533306f306c0011323232325333077307a002149858dd6983c000983c0011bad3076001307237540062a6660de60cc002264646464a6660ee60f40042930b1bad30780013078002375a60ec00260e46ea800c58c1c0dd5001180e8038b183900098390011bad30700013070002375c60dc00260dc00460d800260d06ea80045858c1a8004c198dd50008b1806981498329baa303b306537540022c60ce00266603e00a606660c66ea817d300103d87a8000303930623754607060c46ea8004c190c184dd50008b1980b0010211bac306230633063002375860c200260ba6ea8104c17cc170dd502b8a5015333059304503d153330593056305b37540ae26464646464a6660bc60b660c06ea80044c8c8c94ccc194c1a00084c8c8c94ccc190cc11124011d496e76616c696420696e707574206265696e672076616c696461746564003022303e306737540082a6660c866088920111436f7272656374205350206f75747075740033333029008301f330690064bd70181019834981719834981719834981f18339baa00b33069303d30673754016660d26e98cc1a40092f5bded8c097ae04bd7025eb80dd5981e98339baa303d3067375400898103d87980001533306433044491264d696e747320612073696e676c652065706f6368546f5363616c65546f53756d20746f6b656e003021374c6078605660ce6ea818c54ccc190cc111240129436f727265637420736e617073686f742065706f6368546f5363616c65546f53756d206f75747075740033333029008301f330690064bd701810198349810198349817198349ba600133069303e3067375401697ae04bd7025eb80c0f0c0acc19cdd5031a60103d87a8000133044490119736e617073686f74206d6170206973206e6f7420656d707479003330643061300c0014a09445280a5014a02940dd598330011919bb030690013069306a001375860c80026464646464a6660d460da006266ec0dd3998359834000998359834800a5eb80dd30010b18358011bab3067002375660ca00264660020026eacc0a8c198dd50051129998340008a5ef6c60101a0000101a00013232323253330683232533306a3370e6eb4c1c0008dd6981f18369baa00913370e0026eb4c0f4c1b4dd50048a50375a60de60e000260d66ea8c1a80104cdd81ba63306d004002374c002266ec0dd30011ba63306d004001375660d40046eacc1a0004cc00c00cc1b0008c1a8004c0e8c190dd50040b183300099980f002181c18311baa05e4c103d8798000303830613754606e60c26ea8c190c184dd50008b1980b0010211bac306230633063002375860c200260ba6ea8104c17cc170dd502b8a50133332323222232323232325333064306130663754002264a6660ca60b860ce6ea80044c8c8c94ccc1b0c1bc0084c8c8c94ccc1acc1a0c1b4dd500089982599808198381ba93730921084d697373696e6720003307037526e6003ccc1c0dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003304e30113049009375c60e260dc6ea800454cc1b0cc040cc1c0dd49b98491084d697373696e6720003307037526e6003ccc1c0dd49b9849010d20757067726164652070617468004bd70249001632533306b3062306d3754002298103d87a8000130353307037526eb8c1b8c8cdd81839000983918398009bac3071306e375400297ae0330213756608660da6ea80088cdc79bae306d00100653330693066306b3754002264646464a6660e260e800426493198338009191bae3072002375c60e00022c6eacc1c8004c1c8008dd6983800098361baa001163013302f306b3754608260d66ea800458c1b4004ccc09401402130103d8798000375c60d660d06ea800458c0f8c19cdd5181f18339baa303d3067375460d460ce6ea800458cc070dd618348020241bab3068306930693069002375860ce00260ce00260c46ea800888dcc99191998008008022441002225333065002100113233300400430690035333062305f371a00426e600044cdc500119b8a00537300026e64dd718338011b98001300100122533305f00114bd70099830182e9830800998010011831000a490d53746162696c697479506f6f6c003033305c375408460be60c060c060c060c060c060c060b86ea8160c004004894ccc1740045200013003330020023060001370090011299982b1825182c1baa0011305c305937540022a660ae9201134e6f7420616e20696e6c696e6520646174756d001622325333057305430593754002260ba60b46ea800454cc16124117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533305d00114c0103d87a80001323232533305c3375e00c60bc0062604c660c200297ae0133005005002305e0023061002305f00130113305b0024bd7011180f9982d1ba8337006eb4c0bcc160dd50011bad302f3058375400297ae02301d33058375066e08005208080a0f6f4acdbe01b4bd7011180e9982c1ba8337026eb4c0b4c158dd50011bad302d3056375400297ae02325333052304f001132325333058305b002149858dd7182c800982a9baa00215333052304900115333056305537540042930b0b18299baa00122301b33056375066e0ccdc11bad302b305437540046eb4c0acc150dd5000a41010141ede959b7c03697ae022301a33055375066e0ccdc11bad302a30533754004904040507b7a566df00d9bad302a3053375400297ae022330210023017001233300f001488100488100222533304e533304e304b305037546600a006466ebcc14400400c5288a501323300100100422533305400114bd6f7b63009982a9919299982919baf00100613376000200a200460a600260ac0026600400460ae002266008006660a666ec00080052f5bded8c044646600200200644a6660a400220062660a660a80026600400460aa00244646600200200644a6660a20022980103d87a800013232533304f30050021301933054374e660a860a2004660a860a400497ae04bd70099802002000982a8011829800918279828182818281828182818281828182818280009119198008008019129998278008a6103d87a800013232533304d3375e604e60a06ea80080144c05ccc1480092f5c026600800800260a600460a2002600698101a000374a90011ba548010dd79ba630213756602c608c6ea80a8dd7813911191980b80211801180f98249baa0015333044304130463754002246600c6eacc078c120dd50008018918029998039bab301e304837540026eb8c07cc120dd50019bae301e304837540066e212000223038333003002375c603660886ea8004dd7180d18221baa0012223253330423039304437540022900009bad30483045375400264a666084607260886ea8004530103d87a80001323300100137566092608c6ea8008894ccc120004530103d87a8000132323253330473371e00e6eb8c12400c4c044cc130dd4000a5eb804cc014014008dd698248011826001182500099198008008021129998238008a6103d87a8000132323253330463371e00e6eb8c12000c4c040cc12cdd3000a5eb804cc014014008dd59824001182580118248009119998018012450048810000122225333040303d001100413333300f0040033232002323300100100222533304700114984c94ccc120004526132325333046304330483754660466eb8c120c130010dd71824001099802802998258010008a99823a49326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016304c002304a001304a00133045337606ea4008dd4000a5eb7bdb180888c94ccc110c048004530103d87a80001300e33049374c00297ae033333013001005004222325333047304400114c103d87a8000130113304c375000297ae03370000200404003a4444464660020026602600c601200a44a66608c00229404c94ccc10cc94ccc110cdd7980598239baa001007132533304900114a22a66609260980022646464a666090604e6eb8c13800c54ccc120c09c00454ccc120c114c128dd50048a9998241807001099b89002482026fb808528098070010a5014a06eb8c134c138008dd69826182698268009bac304b00114a060226601a6eacc074c11cdd500098078030a50304900214a226600600600260920026e2520002304030413041001253330393036303b3754002264466ebcc054c0f8dd5180a981f1baa001002303f303c3754002264466ebcc054c0f8dd5000801181f981e1baa00122323330010010030022225333040002100113233300400430440033333300c002375c607e0026eacc100004888c94ccc104c03c004530103d87a80001300b33046374c00297ae03233300100100300222253330470021001132333004004304b00333333014002375c608c0026eb4c11c004888c94ccc120c1140045300103d87a8000130123304d375000297ae033700004002042609200403460840046e9520002323300100100222533303c00114bd6f7b6300991981f19bb037526eb8c0ec004dd319198008009bab303d00222533303f00114bd6f7b6300991982099bb037526eb8c0f8004dd418041bad303f0013300300330430023041001330030033040002303e001370290001191980080080111299981d0008a5eb804c8ccc888c8cc00400400c894ccc100004400c4c8cc108dd3998211ba90063304237526eb8c0fc004cc108dd41bad30400014bd7019801801982200118210009bae30390013756607400266006006607c00460780024a66606e002294452811111191980080080311299981e00089981e99bb0375200c6e980152f5bded8c0264646464a66607860306600e01400426608266ec0dd48051ba60090051533303c3371e014004264a66607a6074607e6ea80044cc108cdd81ba900b304330403754002008200866601001401200226608266ec0dd48011ba6001330060060033756607c0066eb8c0f0008c100008c0f800488888c8cc004004018894ccc0ec0044cc0f0cdd81ba9006375000a97adef6c60132323232533303b30173300700a002133040337606ea4028dd40048028a99981d99b8f00a002132533303c3039303e375400226608266ec0dd48059821181f9baa001004100433300800a009001133040337606ea4008dd4000998030030019bad303d003375c6076004607e004607a0024466006004466ebcc030c0d4dd51806181a9baa300b3035375400200444646600200200644a66606c002297ae0132325333034300500213303900233004004001133004004001303a00230380012303430353035303530350012303330343034303400123300248000004894ccc0b0cdc40008010801080091818181898189818981898189818981898189818981880091998021bae3003302c37540026eb8c008c0b0dd5000a40044605c605e0024605a002444a666050604a002297adef6c6013232330010014bd6f7b63011299981780089981819bb0375200c6e9800d2f5bded8c0264646464a66605e60166601801400426606866ec0dd48051ba60070051533302f3371e01400426606866ec0dd48051ba6007003133034337606ea4008dd3000998030030019bab3031003375c605e00460660046062002646600200297adef6c6022533302e00113302f337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0b8c028cc02c0200084cc0cccdd81ba9008375000e00a2a66605c66e3c0200084cc0cccdd81ba9008375000e00626606666ec0dd48011ba800133006006003375a60600066eb8c0b8008c0c8008c0c0004dd7a6103d879800022533302533720004002298103d8798000153330253371e0040022980103d87a800014c103d87b80002323300100100222533302900114bd6f7b63009919191929998149804001080189981719bb037520046e98004cc01801800cdd598158019bae3029002302d002302b001371e911002253330223330220014a094454cc08c0084004400488cc010dd6180198121baa002001230253026302630263026302630263026302600122323300100100322533302500114a0264a66604466e3cdd718140010020a511330030030013028001301e37540166042603c6ea800458c080c084008c07c004c06cdd50008a4c26cac600200a464a66602e602800226464a66603a60400042649318060008b180f000980d1baa00215333017300e00113232533301d3020002132498c01c00458c078004c068dd50010a99980b98058008a99980d980d1baa00214985854ccc05cc01000454ccc06cc068dd50010a4c2c2a66602e60060022a66603660346ea800852616153330173370e90050008a99980d980d1baa00214985858c060dd50009b8748020dc3a400c4a6660266020602a6ea80044c8c8c8c94ccc06cc0780084c926533301730143019375400626464a66603a60400042930b1bae301e001301a37540062c2c6eb4c070004c070008c068004c058dd50008b192999808980700089919299980b980d00109924c60160022c603000260286ea803c54ccc044c0200044c8c94ccc05cc0680084c92630050011630180013014375401e2a666022600a00226464a66602e60340042649318020008b180c000980a1baa00f163012375401c4a666020601a60246ea80044c8c8c8c94ccc060c06c0084c9263300e00323230123019002300e301700116375c603200260320046eacc05c004c04cdd50008b12999807980618089baa00113232323232323232533301b301e00213232498c94ccc064c0580044c8c94ccc07cc0880084c926300e001163020001301c37540062a66603260200022a66603a60386ea800c5261616301a375400460240062c60380026038004603400260340046eb8c060004c060008dd7180b00098091baa00116232533300f300c00115333013301237540042930b0a9998079803000899191919299980b980d00109924c60100022c603000260300046eb4c058004c048dd50010a999807980180089919299980a980c00109924c600c0022c602c00260246ea800858c040dd50009b874801094ccc030c024c038dd5000899191919299980a180b8010991924c64a666024601e00226464a66603060360042649319299980a980900089919299980d980f00109924c601a0022c603800260306ea800854ccc054c0300044c8c8c8c8c8c94ccc07cc08800852616375a604000260400046eb4c078004c078008dd6980e000980c1baa00216301637540022c6032002602a6ea800c54ccc048c02400454ccc058c054dd50018a4c2c2c60266ea8008c01800c58c054004c054008c04c004c03cdd50008b11929998061804800899192999809180a8010a4c2c6eb8c04c004c03cdd50010a9998061801800899192999809180a8010a4c2c6eb8c04c004c03cdd50010b18069baa001370e900112999804980318059baa00113232323232325333013301600213232498cc0280088c8c038c054008c028c04c004c02800c58dd5980a000980a001180900098090011bae3010001300c37540022c4a666010600a60146ea80044c8c8c8c94ccc040c04c00852616375a602200260220046eb4c03c004c02cdd50008b1119198008008019129998070008a4c264660060066024004600660200024a66600c600660106ea80044c8c8c8c8c8c8c8c8c8c94ccc050c05c0084c8c8c926300e007300d008300c00916375a602a002602a0046eb4c04c004c04c008c044004c044008c03c004c03c008c034004c024dd50008b12999802980118039baa00113232533300b300e002149858dd6980600098041baa00116370e90002b9a5738aae7555cf2ab9f5740ae855d11"
1361
+ };
1362
+ var mkStabilityPoolValidatorFromSP = (params) => {
1363
+ return {
1364
+ type: stabilityPoolValidator.type,
1365
+ script: (0, import_lucid15.applyParamsToScript)(stabilityPoolValidator.cborHex, [
1366
+ castStabilityPoolParams({
1367
+ assetSymbol: params.assetSymbol.unCurrencySymbol,
1368
+ stabilityPoolToken: fromSystemParamsAsset(params.stabilityPoolToken),
1369
+ snapshotEpochToScaleToSumToken: fromSystemParamsAsset(
1370
+ params.snapshotEpochToScaleToSumToken
1371
+ ),
1372
+ accountToken: fromSystemParamsAsset(params.accountToken),
1373
+ cdpToken: fromSystemParamsAsset(params.cdpToken),
1374
+ iAssetAuthToken: fromSystemParamsAsset(params.iAssetAuthToken),
1375
+ versionRecordToken: fromSystemParamsAsset(params.versionRecordToken),
1376
+ collectorValHash: params.collectorValHash,
1377
+ govNFT: fromSystemParamsAsset(params.govNFT),
1378
+ accountCreateFeeLovelaces: BigInt(params.accountCreateFeeLovelaces),
1379
+ accountAdjustmentFeeLovelaces: BigInt(
1380
+ params.accountAdjustmentFeeLovelaces
1381
+ ),
1382
+ requestCollateralLovelaces: BigInt(params.requestCollateralLovelaces)
1383
+ })
1384
+ ])
1385
+ };
1033
1386
  };
1034
1387
 
1035
- // src/scripts/interest-oracle-validator.ts
1036
- var _interestOracleValidator = {
1388
+ // src/helpers/stability-pool-helpers.ts
1389
+ var newScaleMultiplier = 1000000000n;
1390
+ function getSumFromEpochToScaleToSum(e2s2s, epoch, scale) {
1391
+ for (const [key, value] of e2s2s.entries()) {
1392
+ if (key.epoch === epoch && key.scale === scale) {
1393
+ return value;
1394
+ }
1395
+ }
1396
+ return void 0;
1397
+ }
1398
+ function setSumInEpochToScaleToSum(e2s2s, epoch, scale, sum) {
1399
+ const map = /* @__PURE__ */ new Map();
1400
+ for (const [key, value] of e2s2s.entries()) {
1401
+ if (!(key.epoch === epoch && key.scale === scale)) {
1402
+ map.set(key, value);
1403
+ }
1404
+ }
1405
+ map.set({ epoch, scale }, sum);
1406
+ return map;
1407
+ }
1408
+ function getAccountReward(account, e2s2s) {
1409
+ const s1 = getSumFromEpochToScaleToSum(e2s2s, account.epoch, account.scale);
1410
+ if (!s1) throw new Error("No scale found for epoch and scale");
1411
+ const s2 = getSumFromEpochToScaleToSum(e2s2s, account.epoch, account.scale + 1n) ?? s1;
1412
+ const a1 = spSub(s1, account.sumVal);
1413
+ const a2 = spDiv(spSub(s2, s1), mkSPInteger(newScaleMultiplier));
1414
+ return spDiv(spMul(spAdd(a1, a2), account.depositVal), account.productVal);
1415
+ }
1416
+ function getAccountFund(pool, account) {
1417
+ let fund = spDiv(
1418
+ spMul(account.depositVal, pool.productVal),
1419
+ account.productVal
1420
+ );
1421
+ if (pool.epoch > account.epoch) fund = mkSPInteger(0n);
1422
+ if (pool.scale - account.scale > 1n) fund = mkSPInteger(0n);
1423
+ if (pool.scale > account.scale)
1424
+ fund = spDiv(spMul(account.depositVal, pool.productVal), {
1425
+ value: account.productVal.value * newScaleMultiplier
1426
+ });
1427
+ if (fund.value < spDiv(account.depositVal, mkSPInteger(1000000000n)).value)
1428
+ return mkSPInteger(0n);
1429
+ return fund;
1430
+ }
1431
+ function adjust(pool, account, e2s2s) {
1432
+ const newAccountSnapshot = {
1433
+ ...pool,
1434
+ depositVal: getAccountFund(pool, account)
1435
+ };
1436
+ const accountReward = fromSPInteger(getAccountReward(account, e2s2s));
1437
+ return [newAccountSnapshot, accountReward];
1438
+ }
1439
+ function findEpochToScaleToSum(snapshotEpochToScaleToSumTokenRef1, snapshotEpochToScaleToSumTokenRef2) {
1440
+ let ess1;
1441
+ try {
1442
+ ess1 = parseSnapshotEpochToScaleToSumDatum(
1443
+ snapshotEpochToScaleToSumTokenRef1.datum
1444
+ ).snapshot;
1445
+ } catch (_) {
1446
+ ess1 = parseStabilityPoolDatum(
1447
+ snapshotEpochToScaleToSumTokenRef1.datum
1448
+ ).epochToScaleToSum;
1449
+ }
1450
+ const ess1Ref = {
1451
+ utxo: snapshotEpochToScaleToSumTokenRef1,
1452
+ e2s2s: ess1
1453
+ };
1454
+ if (snapshotEpochToScaleToSumTokenRef2) {
1455
+ const ess2 = parseSnapshotEpochToScaleToSumDatum(
1456
+ snapshotEpochToScaleToSumTokenRef2.datum
1457
+ );
1458
+ const ess2Ref = {
1459
+ utxo: snapshotEpochToScaleToSumTokenRef2,
1460
+ e2s2s: ess2.snapshot
1461
+ };
1462
+ return [ess1Ref, ess2Ref];
1463
+ }
1464
+ return [ess1Ref, void 0];
1465
+ }
1466
+ function adjustmentHelper(spESTSTokenRef1, spESTSTokenRef2, pool, e2s2s, account) {
1467
+ let accumulatedEpochToScaleToSum;
1468
+ let refInputs;
1469
+ const value = getSumFromEpochToScaleToSum(
1470
+ e2s2s,
1471
+ account.epoch,
1472
+ account.scale
1473
+ );
1474
+ if (value) {
1475
+ accumulatedEpochToScaleToSum = e2s2s;
1476
+ refInputs = [];
1477
+ } else {
1478
+ const [ess1, ess2] = findEpochToScaleToSum(
1479
+ spESTSTokenRef1,
1480
+ spESTSTokenRef2
1481
+ );
1482
+ if (ess2) {
1483
+ accumulatedEpochToScaleToSum = new Map([
1484
+ ...Array.from(ess1.e2s2s.entries()),
1485
+ ...Array.from(ess2.e2s2s.entries()),
1486
+ ...Array.from(e2s2s.entries())
1487
+ ]);
1488
+ refInputs = [ess1.utxo, ess2.utxo];
1489
+ } else {
1490
+ accumulatedEpochToScaleToSum = new Map([...Array.from(ess1.e2s2s.entries()), ...Array.from(e2s2s.entries())]);
1491
+ refInputs = [ess1.utxo];
1492
+ }
1493
+ }
1494
+ const [newAccountSnapshot, accountReward] = adjust(
1495
+ pool,
1496
+ account,
1497
+ accumulatedEpochToScaleToSum
1498
+ );
1499
+ return [newAccountSnapshot, accountReward, refInputs];
1500
+ }
1501
+ function updatePoolSnapshotWithdrawalFee(withdrawalFeeAmount, newPoolDepositExcludingFee, pool) {
1502
+ const newPoolDepositVal = spAdd(
1503
+ newPoolDepositExcludingFee,
1504
+ withdrawalFeeAmount
1505
+ );
1506
+ const newPoolProduct = withdrawalFeeAmount.value === 0n ? pool.productVal : spMul(
1507
+ pool.productVal,
1508
+ spAdd(
1509
+ mkSPInteger(1n),
1510
+ spDiv(withdrawalFeeAmount, newPoolDepositExcludingFee)
1511
+ )
1512
+ );
1513
+ return [newPoolDepositVal, newPoolProduct];
1514
+ }
1515
+
1516
+ // src/helpers/indigo-helpers.ts
1517
+ function calculateFeeFromPercentage2(feePercentage, amount) {
1518
+ if (amount < 0) {
1519
+ return 0n;
1520
+ }
1521
+ return ocdDiv(ocdMul({ getOnChainInt: amount }, feePercentage), {
1522
+ getOnChainInt: 100n * OCD_DECIMAL_UNIT
1523
+ }).getOnChainInt;
1524
+ }
1525
+
1526
+ // src/contracts/stability-pool.ts
1527
+ var StabilityPoolContract = class {
1528
+ static async createAccount(asset, amount, params, lucid) {
1529
+ const [pkh, _skh] = await addrDetails(lucid);
1530
+ const minLovelaces = BigInt(
1531
+ params.stabilityPoolParams.accountCreateFeeLovelaces + params.stabilityPoolParams.requestCollateralLovelaces
1532
+ );
1533
+ const datum = {
1534
+ Account: {
1535
+ content: {
1536
+ owner: pkh.hash,
1537
+ asset: (0, import_lucid16.fromText)(asset),
1538
+ snapshot: {
1539
+ productVal: { value: 0n },
1540
+ depositVal: { value: 0n },
1541
+ sumVal: { value: 0n },
1542
+ epoch: 0n,
1543
+ scale: 0n
1544
+ },
1545
+ request: "Create"
1546
+ }
1547
+ }
1548
+ };
1549
+ return lucid.newTx().pay.ToContract(
1550
+ (0, import_lucid16.credentialToAddress)(lucid.config().network, {
1551
+ hash: (0, import_lucid16.validatorToScriptHash)(
1552
+ mkStabilityPoolValidatorFromSP(params.stabilityPoolParams)
1553
+ ),
1554
+ type: "Script"
1555
+ }),
1556
+ { kind: "inline", value: serialiseStabilityPoolDatum(datum) },
1557
+ {
1558
+ lovelace: minLovelaces,
1559
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: amount
1560
+ }
1561
+ ).addSignerKey(pkh.hash);
1562
+ }
1563
+ static async adjustAccount(asset, amount, accountUtxo, params, lucid) {
1564
+ const [pkh, _] = await addrDetails(lucid);
1565
+ const myAddress = await lucid.wallet().address();
1566
+ const stabilityPoolScriptRef = await scriptRef(
1567
+ params.scriptReferences.stabilityPoolValidatorRef,
1568
+ lucid
1569
+ );
1570
+ const request = {
1571
+ Adjust: {
1572
+ amount,
1573
+ outputAddress: addressFromBech32(myAddress)
1574
+ }
1575
+ };
1576
+ const oldAccountDatum = parseAccountDatum(
1577
+ accountUtxo.datum
1578
+ );
1579
+ const newAccountDatum = {
1580
+ ...oldAccountDatum,
1581
+ request
1582
+ };
1583
+ const redeemer = {
1584
+ RequestAction: {
1585
+ action: request
1586
+ }
1587
+ };
1588
+ return lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer(redeemer)).pay.ToContract(
1589
+ (0, import_lucid16.credentialToAddress)(lucid.config().network, {
1590
+ hash: (0, import_lucid16.validatorToScriptHash)(
1591
+ mkStabilityPoolValidatorFromSP(params.stabilityPoolParams)
1592
+ ),
1593
+ type: "Script"
1594
+ }),
1595
+ {
1596
+ kind: "inline",
1597
+ value: serialiseStabilityPoolDatum({
1598
+ Account: {
1599
+ content: newAccountDatum
1600
+ }
1601
+ })
1602
+ },
1603
+ {
1604
+ lovelace: BigInt(
1605
+ params.stabilityPoolParams.requestCollateralLovelaces + params.stabilityPoolParams.accountAdjustmentFeeLovelaces
1606
+ ),
1607
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n,
1608
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: amount
1609
+ }
1610
+ ).addSignerKey(pkh.hash);
1611
+ }
1612
+ static async closeAccount(accountUtxo, params, lucid) {
1613
+ const [pkh, _] = await addrDetails(lucid);
1614
+ const myAddress = await lucid.wallet().address();
1615
+ const stabilityPoolScriptRef = await scriptRef(
1616
+ params.scriptReferences.stabilityPoolValidatorRef,
1617
+ lucid
1618
+ );
1619
+ const request = {
1620
+ Close: {
1621
+ outputAddress: addressFromBech32(myAddress)
1622
+ }
1623
+ };
1624
+ const oldAccountDatum = parseAccountDatum(
1625
+ accountUtxo.datum
1626
+ );
1627
+ const newAccountDatum = {
1628
+ ...oldAccountDatum,
1629
+ request
1630
+ };
1631
+ const redeemer = {
1632
+ RequestAction: {
1633
+ action: request
1634
+ }
1635
+ };
1636
+ return lucid.newTx().readFrom([stabilityPoolScriptRef]).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer(redeemer)).pay.ToContract(
1637
+ (0, import_lucid16.credentialToAddress)(lucid.config().network, {
1638
+ hash: (0, import_lucid16.validatorToScriptHash)(
1639
+ mkStabilityPoolValidatorFromSP(params.stabilityPoolParams)
1640
+ ),
1641
+ type: "Script"
1642
+ }),
1643
+ {
1644
+ kind: "inline",
1645
+ value: serialiseStabilityPoolDatum({
1646
+ Account: {
1647
+ content: newAccountDatum
1648
+ }
1649
+ })
1650
+ },
1651
+ {
1652
+ lovelace: BigInt(
1653
+ params.stabilityPoolParams.requestCollateralLovelaces + params.stabilityPoolParams.accountAdjustmentFeeLovelaces
1654
+ ),
1655
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n
1656
+ }
1657
+ ).addSignerKey(pkh.hash);
1658
+ }
1659
+ static async processRequest(asset, stabilityPoolUtxo, accountUtxo, govUtxo, iAssetUtxo, newSnapshotUtxo, params, lucid) {
1660
+ const redeemer = {
1661
+ ProcessRequest: {
1662
+ requestRef: {
1663
+ txHash: { hash: accountUtxo.txHash },
1664
+ outputIndex: BigInt(accountUtxo.outputIndex)
1665
+ }
1666
+ }
1667
+ };
1668
+ const stabilityPoolScriptRef = await scriptRef(
1669
+ params.scriptReferences.stabilityPoolValidatorRef,
1670
+ lucid
1671
+ );
1672
+ const accountDatum = parseAccountDatum(accountUtxo.datum);
1673
+ const stabilityPoolDatum = parseStabilityPoolDatum(stabilityPoolUtxo.datum);
1674
+ const tx = lucid.newTx().collectFrom(
1675
+ [stabilityPoolUtxo],
1676
+ serialiseStabilityPoolRedeemer(redeemer)
1677
+ ).collectFrom([accountUtxo], serialiseStabilityPoolRedeemer(redeemer)).readFrom([iAssetUtxo, govUtxo, stabilityPoolScriptRef]);
1678
+ if (!accountDatum.request) throw new Error("Account Request is null");
1679
+ if (accountDatum.request === "Create") {
1680
+ const accountTokenScriptRef = await scriptRef(
1681
+ params.scriptReferences.authTokenPolicies.accountTokenRef,
1682
+ lucid
1683
+ );
1684
+ tx.readFrom([accountTokenScriptRef]);
1685
+ const iassetUnit = params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset);
1686
+ const reqAmount = accountUtxo.assets[iassetUnit] ?? 0n;
1687
+ const newAccountSnapshot = {
1688
+ ...stabilityPoolDatum.snapshot,
1689
+ depositVal: {
1690
+ value: spAdd(accountDatum.snapshot.depositVal, mkSPInteger(reqAmount)).value
1691
+ }
1692
+ };
1693
+ const newDeposit = spAdd(
1694
+ stabilityPoolDatum.snapshot.depositVal,
1695
+ mkSPInteger(reqAmount)
1696
+ );
1697
+ const newSum = spAdd(
1698
+ stabilityPoolDatum.snapshot.sumVal,
1699
+ spDiv(
1700
+ spMul(
1701
+ mkSPInteger(
1702
+ BigInt(params.stabilityPoolParams.accountCreateFeeLovelaces)
1703
+ ),
1704
+ stabilityPoolDatum.snapshot.productVal
1705
+ ),
1706
+ newDeposit
1707
+ )
1708
+ );
1709
+ const newStabilityPoolSnapshot = {
1710
+ ...stabilityPoolDatum.snapshot,
1711
+ depositVal: newDeposit,
1712
+ sumVal: newSum
1713
+ };
1714
+ const newEpochToScaleToSum = new Map(
1715
+ stabilityPoolDatum.epochToScaleToSum
1716
+ );
1717
+ newEpochToScaleToSum.set(
1718
+ {
1719
+ epoch: stabilityPoolDatum.snapshot.epoch,
1720
+ scale: stabilityPoolDatum.snapshot.scale
1721
+ },
1722
+ newSum
1723
+ );
1724
+ const stabilityPoolAssetToken = stabilityPoolUtxo.assets[iassetUnit] ?? 0n;
1725
+ const poolOutputValue = {
1726
+ lovelace: stabilityPoolUtxo.assets.lovelace + BigInt(params.stabilityPoolParams.accountCreateFeeLovelaces),
1727
+ [params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.stabilityPoolToken[1].unTokenName)]: 1n,
1728
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: stabilityPoolAssetToken + reqAmount
1729
+ };
1730
+ tx.mintAssets(
1731
+ {
1732
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n
1733
+ },
1734
+ import_lucid16.Data.to(new import_lucid16.Constr(0, []))
1735
+ );
1736
+ tx.pay.ToContract(
1737
+ stabilityPoolUtxo.address,
1738
+ {
1739
+ kind: "inline",
1740
+ value: serialiseStabilityPoolDatum({
1741
+ StabilityPool: {
1742
+ content: {
1743
+ ...stabilityPoolDatum,
1744
+ snapshot: newStabilityPoolSnapshot,
1745
+ epochToScaleToSum: newEpochToScaleToSum
1746
+ }
1747
+ }
1748
+ })
1749
+ },
1750
+ poolOutputValue
1751
+ );
1752
+ tx.pay.ToContract(
1753
+ stabilityPoolUtxo.address,
1754
+ {
1755
+ kind: "inline",
1756
+ value: serialiseStabilityPoolDatum({
1757
+ Account: {
1758
+ content: {
1759
+ ...accountDatum,
1760
+ snapshot: newAccountSnapshot,
1761
+ request: null
1762
+ }
1763
+ }
1764
+ })
1765
+ },
1766
+ {
1767
+ lovelace: accountUtxo.assets.lovelace - BigInt(params.stabilityPoolParams.accountCreateFeeLovelaces),
1768
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n
1769
+ }
1770
+ );
1771
+ } else if ("Adjust" in accountDatum.request) {
1772
+ const amount = accountDatum.request.Adjust.amount;
1773
+ const outputAddress = addressToBech32(
1774
+ lucid,
1775
+ accountDatum.request.Adjust.outputAddress
1776
+ );
1777
+ const myAddress = await lucid.wallet().address();
1778
+ const [updatedAccountSnapshot, reward, refInputs] = adjustmentHelper(
1779
+ stabilityPoolUtxo,
1780
+ newSnapshotUtxo,
1781
+ stabilityPoolDatum.snapshot,
1782
+ stabilityPoolDatum.epochToScaleToSum,
1783
+ accountDatum.snapshot
1784
+ );
1785
+ const govDatum = parseGovDatum(govUtxo.datum);
1786
+ const iassetDatum = parseIAssetDatum(iAssetUtxo.datum);
1787
+ const rewardLovelacesFee = calculateFeeFromPercentage2(
1788
+ govDatum.protocolParams.collateralFeePercentage,
1789
+ reward
1790
+ );
1791
+ const isDepositOrRewardWithdrawal = amount > 0n;
1792
+ const bigIntMax = (...args) => args.reduce((m, e) => e > m ? e : m);
1793
+ const balanceChange = isDepositOrRewardWithdrawal ? amount : bigIntMax(amount, fromSPInteger(accountDatum.snapshot.depositVal));
1794
+ const newAccountSnapshot = {
1795
+ ...updatedAccountSnapshot,
1796
+ depositVal: spAdd(
1797
+ updatedAccountSnapshot.depositVal,
1798
+ mkSPInteger(balanceChange)
1799
+ )
1800
+ };
1801
+ const _newPoolDepositExcludingFee = spAdd(
1802
+ stabilityPoolDatum.snapshot.depositVal,
1803
+ mkSPInteger(balanceChange)
1804
+ );
1805
+ const newPoolDepositExcludingFee = _newPoolDepositExcludingFee.value > 0n ? _newPoolDepositExcludingFee : mkSPInteger(0n);
1806
+ const withdrawalFee = isDepositOrRewardWithdrawal || newPoolDepositExcludingFee.value === 0n ? 0n : calculateFeeFromPercentage2(
1807
+ iassetDatum.stabilityPoolWithdrawalFeePercentage,
1808
+ -balanceChange
1809
+ );
1810
+ const newPoolDeposit = spAdd(
1811
+ newPoolDepositExcludingFee,
1812
+ mkSPInteger(withdrawalFee)
1813
+ );
1814
+ const newPoolProduct = withdrawalFee === 0n ? stabilityPoolDatum.snapshot.productVal : spMul(
1815
+ stabilityPoolDatum.snapshot.productVal,
1816
+ spAdd(
1817
+ mkSPInteger(1n),
1818
+ spDiv(mkSPInteger(withdrawalFee), newPoolDepositExcludingFee)
1819
+ )
1820
+ );
1821
+ const newPoolSum = spAdd(
1822
+ stabilityPoolDatum.snapshot.sumVal,
1823
+ spDiv(
1824
+ spMul(
1825
+ mkSPInteger(
1826
+ BigInt(params.stabilityPoolParams.accountAdjustmentFeeLovelaces)
1827
+ ),
1828
+ newPoolProduct
1829
+ ),
1830
+ newPoolDeposit
1831
+ )
1832
+ );
1833
+ const newPoolSnapshot = {
1834
+ ...stabilityPoolDatum.snapshot,
1835
+ depositVal: newPoolDeposit,
1836
+ sumVal: newPoolSum,
1837
+ productVal: newPoolProduct
1838
+ };
1839
+ const newEpochToScaleToSum = setSumInEpochToScaleToSum(
1840
+ stabilityPoolDatum.epochToScaleToSum,
1841
+ stabilityPoolDatum.snapshot.epoch,
1842
+ stabilityPoolDatum.snapshot.scale,
1843
+ newPoolSum
1844
+ );
1845
+ await CollectorContract.feeTx(rewardLovelacesFee, lucid, params, tx);
1846
+ tx.readFrom([govUtxo, iAssetUtxo, ...refInputs]);
1847
+ tx.pay.ToContract(
1848
+ stabilityPoolUtxo.address,
1849
+ {
1850
+ kind: "inline",
1851
+ value: serialiseStabilityPoolDatum({
1852
+ StabilityPool: {
1853
+ content: {
1854
+ ...stabilityPoolDatum,
1855
+ snapshot: newPoolSnapshot,
1856
+ epochToScaleToSum: newEpochToScaleToSum
1857
+ }
1858
+ }
1859
+ })
1860
+ },
1861
+ {
1862
+ lovelace: stabilityPoolUtxo.assets.lovelace + BigInt(params.stabilityPoolParams.accountAdjustmentFeeLovelaces) - reward,
1863
+ [params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(
1864
+ params.stabilityPoolParams.stabilityPoolToken[1].unTokenName
1865
+ )]: 1n,
1866
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: stabilityPoolUtxo.assets[params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)] + balanceChange + withdrawalFee
1867
+ }
1868
+ );
1869
+ tx.pay.ToContract(
1870
+ stabilityPoolUtxo.address,
1871
+ {
1872
+ kind: "inline",
1873
+ value: serialiseStabilityPoolDatum({
1874
+ Account: {
1875
+ content: {
1876
+ ...accountDatum,
1877
+ snapshot: newAccountSnapshot,
1878
+ request: null
1879
+ }
1880
+ }
1881
+ })
1882
+ },
1883
+ {
1884
+ lovelace: accountUtxo.assets.lovelace - BigInt(params.stabilityPoolParams.accountAdjustmentFeeLovelaces) - 2000000n,
1885
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: 1n
1886
+ }
1887
+ );
1888
+ if (myAddress !== outputAddress) {
1889
+ tx.pay.ToAddressWithData(
1890
+ outputAddress,
1891
+ {
1892
+ kind: "inline",
1893
+ value: import_lucid16.Data.to(
1894
+ {
1895
+ IndigoStabilityPoolAccountAdjustment: {
1896
+ spent_account: {
1897
+ txHash: { hash: accountUtxo.txHash },
1898
+ outputIndex: BigInt(accountUtxo.outputIndex)
1899
+ }
1900
+ }
1901
+ },
1902
+ ActionReturnDatum
1903
+ )
1904
+ },
1905
+ {
1906
+ lovelace: reward - rewardLovelacesFee + 2000000n,
1907
+ ...amount < 0n ? {
1908
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: -(amount - withdrawalFee)
1909
+ } : {}
1910
+ }
1911
+ );
1912
+ } else {
1913
+ }
1914
+ } else if ("Close" in accountDatum.request) {
1915
+ const outputAddress = addressToBech32(
1916
+ lucid,
1917
+ accountDatum.request.Close.outputAddress
1918
+ );
1919
+ const myAddress = await lucid.wallet().address();
1920
+ const [updatedAccountSnapshot, reward, refInputs] = adjustmentHelper(
1921
+ stabilityPoolUtxo,
1922
+ newSnapshotUtxo,
1923
+ stabilityPoolDatum.snapshot,
1924
+ stabilityPoolDatum.epochToScaleToSum,
1925
+ accountDatum.snapshot
1926
+ );
1927
+ const govDatum = parseGovDatum(govUtxo.datum);
1928
+ const iassetDatum = parseIAssetDatum(iAssetUtxo.datum);
1929
+ const rewardLovelacesFee = calculateFeeFromPercentage2(
1930
+ govDatum.protocolParams.collateralFeePercentage,
1931
+ reward
1932
+ );
1933
+ const fund = updatedAccountSnapshot.depositVal;
1934
+ const newPoolDepositExcludingFee = spSub(
1935
+ stabilityPoolDatum.snapshot.depositVal,
1936
+ fund
1937
+ );
1938
+ const withdrawnAmt = fund.value < 0n ? mkSPInteger(0n) : fund;
1939
+ const withdrawalFeeAmount = newPoolDepositExcludingFee.value === 0n ? 0n : calculateFeeFromPercentage2(
1940
+ iassetDatum.stabilityPoolWithdrawalFeePercentage,
1941
+ withdrawnAmt.value
1942
+ );
1943
+ const [newPoolDeposit, newPoolProduct] = updatePoolSnapshotWithdrawalFee(
1944
+ mkSPInteger(withdrawalFeeAmount),
1945
+ newPoolDepositExcludingFee,
1946
+ stabilityPoolDatum.snapshot
1947
+ );
1948
+ const newPoolSnapshot = {
1949
+ ...stabilityPoolDatum.snapshot,
1950
+ depositVal: newPoolDeposit,
1951
+ productVal: newPoolProduct
1952
+ };
1953
+ const accountTokenRef = await scriptRef(
1954
+ params.scriptReferences.authTokenPolicies.accountTokenRef,
1955
+ lucid
1956
+ );
1957
+ await CollectorContract.feeTx(rewardLovelacesFee, lucid, params, tx);
1958
+ tx.readFrom([govUtxo, iAssetUtxo, accountTokenRef, ...refInputs]);
1959
+ tx.mintAssets(
1960
+ {
1961
+ [params.stabilityPoolParams.accountToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(params.stabilityPoolParams.accountToken[1].unTokenName)]: -1n
1962
+ },
1963
+ import_lucid16.Data.to(new import_lucid16.Constr(0, []))
1964
+ );
1965
+ const assetOutputAmountForSP = stabilityPoolUtxo.assets[params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)] - fromSPInteger(withdrawnAmt) - withdrawalFeeAmount;
1966
+ tx.pay.ToContract(
1967
+ stabilityPoolUtxo.address,
1968
+ {
1969
+ kind: "inline",
1970
+ value: serialiseStabilityPoolDatum({
1971
+ StabilityPool: {
1972
+ content: {
1973
+ ...stabilityPoolDatum,
1974
+ snapshot: newPoolSnapshot
1975
+ }
1976
+ }
1977
+ })
1978
+ },
1979
+ {
1980
+ lovelace: stabilityPoolUtxo.assets.lovelace - reward,
1981
+ [params.stabilityPoolParams.stabilityPoolToken[0].unCurrencySymbol + (0, import_lucid16.fromText)(
1982
+ params.stabilityPoolParams.stabilityPoolToken[1].unTokenName
1983
+ )]: 1n,
1984
+ ...assetOutputAmountForSP > 0n ? {
1985
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: assetOutputAmountForSP
1986
+ } : {}
1987
+ }
1988
+ );
1989
+ if (myAddress !== outputAddress) {
1990
+ tx.pay.ToAddressWithData(
1991
+ outputAddress,
1992
+ {
1993
+ kind: "inline",
1994
+ value: import_lucid16.Data.to(
1995
+ {
1996
+ IndigoStabilityPoolAccountClosure: {
1997
+ closed_account: {
1998
+ txHash: { hash: accountUtxo.txHash },
1999
+ outputIndex: BigInt(accountUtxo.outputIndex)
2000
+ }
2001
+ }
2002
+ },
2003
+ ActionReturnDatum
2004
+ )
2005
+ },
2006
+ {
2007
+ lovelace: accountUtxo.assets.lovelace + reward - rewardLovelacesFee,
2008
+ [params.stabilityPoolParams.assetSymbol.unCurrencySymbol + (0, import_lucid16.fromText)(asset)]: fromSPInteger(withdrawnAmt) - withdrawalFeeAmount
2009
+ }
2010
+ );
2011
+ }
2012
+ }
2013
+ return tx;
2014
+ }
2015
+ };
2016
+
2017
+ // src/contracts/staking.ts
2018
+ var import_lucid19 = require("@lucid-evolution/lucid");
2019
+
2020
+ // src/scripts/staking-validator.ts
2021
+ var _stakingValidator = {
1037
2022
  type: "PlutusV2",
1038
2023
  description: "Generated by Aiken",
2024
+ cborHex: "591ede591edb01000032323232323232322232323232323223232323232253330103232325333013300c30153754002264646464646464646464646464646464646464646464646464646464646464a64646466606a6064042264a66606c00426464646464a6660766070607a6ea80044c8c8c8c94ccc10cc1180084c8c8c94ccc118c1240084c94ccc10ccc0992411d496e76616c696420696e707574206265696e672076616c696461746564003375e605c608c6ea8020c0b8c118dd50028a99982199813249375472616e73616374696f6e206d757374206265207369676e6564206279206f776e6572206f66207374616b696e6720706f736974696f6e003302003200e15333043330264901204d757374206d696e742065786163746c792031207374616b696e67546f6b656e003375e6e98c090dd5981198231baa032374c60386054608c6ea810854ccc10ccc0992411f496e636f7272656374205374616b696e674d616e61676572206f7574707574003333301400a004301133048302d33048302d33048375066e00dd6981718231baa00d001304a3046375401a97ae04bd701bab302a304637546054608c6ea801530103d8798000133026490120496e636f7272656374205374616b696e67506f736974696f6e206f75747075740033333014330480024bd700021808998241808198241816998241ba900e330484c101a00033048302a3046375401a97ae04bd7025eb80cc05cc070c0a8c118dd502119809980a98231baa0420014c0103d87a800014a029405280a503302137566052608a6ea8004c050c114dd50208b182380099812998078038009198139bab302830443754002605060886ea8100c030cc11000d2f5c02c608800266604200a605060806ea80f1300103d87980003027303f37546046607e6ea8004c104c0f8dd50008b198118010139bac303f304030400023758607c00260746ea8098c0f0c0e4dd501a0a50375c607660706ea80b04c94ccc0d8c0bc08854ccc0d80084c8c8c8c94ccc0e8c0dcc0f0dd500089919192999820982200109919299981f9981124811f4d7573742061646a75737420706f736974696f6e206f7220756e7374616b6500325333040303400114a22a666080606a002294452818209baa0021330224910e4d697865642076657273696f6e73003375e60526608800a66088980103d87a80004bd70181518211baa3026304237540062940c0c4004cc020c0a0c100dd50008028b182100099980f8021811181f1baa03a4c0103d87980003025303d3754604a607a6ea8c084c0f4dd51820181e9baa00116330220020263756607c607e607e607e607e607e607e607e607e607e0046eb0c0f4004c0e4dd50128a5013253232333039302f02515333039005133232323232232323232533304330403045375400226464646464a666098609e00426464646464a66609a6606092011d496e76616c696420696e707574206265696e672076616c696461746564003375e607060a06ea8028c0e0c140dd50030a999826998182491643616e206e6f74206d696e7420616e7920746f6b656e000151533304d3303049010f4e6f20494e4459207374616b657273003371090001bad30383050375401e2a66609a660609212c436f6c6c6563746f7220696e70757473206d75737420757365207468652072696768742072656465656d65720033012005232323019002325333050304d00115333054305337540042930b0a99982818248008a99982a18299baa00214985854ccc140c11800454ccc150c14cdd50010a4c2c2c60a26ea8004cc064c0e4c144dd50009bab30543055305530553055305530553055305530553051375407a2a66609a6606092126436f6c6c6563746f72206f7574707574732063616e20636f6e7461696e206f6e6c7920414441003301200323375e606a60a26ea8004dd3180c180a1bab3035305137540022a66609a660609201404661696c20746f2072657475726e207468652073616d65206e756d626572206f66205554784f7320746f2074686520636f6c6c6563746f72206164647265737300533304d3370e602000a60200062660240064602e606a60a26ea8c0e4c144dd50008a501533304d330304913e4d6f7265207468616e20393525206f66207468652064697374726962757461626c652076616c75652068617320746f206265206469737472696275746564003371000466e0c011202813303049011f496e636f7272656374205374616b696e674d616e61676572206f7574707574003333301e00c301a330520094bd70180d99829181b99829181b99829182998281baa00f33052303733052375066e00dd6981c18281baa30343050375401e66e0ccdc1000a410181519534746eb4c0e0c140dd5007a5eb812f5c097ae04bd7019299982718258010800899999812800a45003232002323300100100222533305500114984c94ccc158004526132325333054305130563754660606eb8c158c168010dd7182b0010998028029982c8010008a9982aa49326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016305a002305800130580013305333760981014000375000497adef6c60222325333052302800114c103d87a80001303c33057374c00297ae03333302900148900005222325333055305200114c103d87a80001303f3305a375000297ae03370000200405a0546eacc0d0c140dd5181a18281baa0064c103d87a800014a029405280a5014a0294052819b810030013330120014800088cdc000098099bab3034305037540046603201260686609e00a97ae03330100014800088cdc000098089bab3032304e37546064609c6ea8008cc0b40208cdd7981a18261baa3034304c3754606060986ea800401058c134004ccc0a8018c0c4c124dd5022a6103d879800030123304a304b304c304c304c304c304c3048375408897ae0302f304737546056608e6ea8004c124c118dd50008b198158010179bac3047304830480023758608c00260846ea80b8c004004894ccc1080045200013370090011980100118228009119198008008019129998218008a5113253330403004304600213300300300114a0608c0024666046002910100488100222323300100100422533304200110041330033044001330020023045001303f303c375406e29404c8c8c8c94c8ccc0f8c0cc0a84c94ccc0fc0084c8c8c8c8c8c8c94ccc118c10cc120dd50008991919192999827182880109919299982818298010992999826982518279baa00113232533305330560021323232323253330543303749011d496e76616c696420696e707574206265696e672076616c696461746564003375e607e60ae6ea8038c0fcc15cdd50058a99982a1981ba490e4d697865642076657273696f6e73003375e607e60ae6ea8034c0fcc15cdd5181f982b9baa303b305737540122a6660a86606e921295374616b696e67206d616e61676572206973206e6f7420636f6e73756d656420636f72726563746c79003232301f00230480013301f303f305737540120202a6660a86606e920126546865207472616e73616374696f6e206973206e6f74207369676e6564206279206f776e65720033031043375c607e60ae6ea805454ccc150cc0dd240120457863656564206d6178696d756d207769746864726177616c20616d6f756e74003371200266e0001005854ccc150cc0dd24011f496e636f7272656374205374616b696e674d616e61676572206f7574707574003333302501130213305900d4bd7018111982c981f1982c981f1982c9ba8337006eb4c0fcc15cdd500300b182d982b9baa0064bd7025eb80cc0a0dd5981d982b9baa303b30573754012605200698103d879800015333054330374911643616e206e6f74206d696e7420616e7920746f6b656e0001c13303749120496e636f7272656374205374616b696e67506f736974696f6e206f7574707574003333302501130213305900d4bd7018111982c98109982c981f1982c981f982b9baa01533059374c004660b2607660ae6ea80192f5c097ae04bd70198141bab303b30573754607660ae6ea802ccc090c098c15cdd502980b26103d87a800014a029405280a5014a02940528191980080080111299982c8008a40002664464a6660b066e2000400840084004dd6982e982d1baa305a002305b00133002002305c001330173756607260aa6ea804cc058c154dd502099980b9811982a1baa0123038305437540060026605e6eacc0dcc14cdd5181b98299baa00a30223053375409e60940022c60a800260a06ea800458c04cc078c13cdd5181998279baa00116305100133302e0093035304d375409298103d879800016304f00133302c007302f304b375408e98103d87980003032304a3754605c60946ea8004c130c124dd50008b198170020191bab304a304b304b304b304b304b304b304b00237586092002609260920046eb0c11c004c10cdd5017982298211baa03d14a06eb4c110c104dd501a8a99981f18190150a99981f00089991911919191919192999823982218249baa001132323232533304f30520021323253330513054002132533304e304b3050375400226464a6660a860ae004264646464a6660a86606e9211d496e76616c696420696e707574206265696e672076616c696461746564003375e607e60ae6ea8034c0fcc15cdd50050a99982a1981ba490e4d697865642076657273696f6e73003375e607e60ae6ea8030c0fcc15cdd5181f982b9baa303b305737540102a6660a86606e921295374616b696e67206d616e61676572206973206e6f7420636f6e73756d656420636f72726563746c79003232301f00230480013301f303f3057375401001e2a6660a86606e920126546865207472616e73616374696f6e206973206e6f74207369676e6564206279206f776e65720033031043375c607e60ae6ea805054ccc150cc0dd24011b43616e206e6f7420756e7374616b65206c6f636b65642066756e64003051301500115333054330374901184d757374206275726e2031207374616b696e67546f6b656e003375e6e98c0d4dd5981a182b9baa043374c6052605a607660ae6ea814c4cc0dd24011f496e636f7272656374205374616b696e674d616e61676572206f7574707574003333302501030213305900c4bd7018111982c981f1982c981f1982c9ba8337026eb4c0fcc15cdd5002801982d982b9baa0054bd7025eb80cc0a0dd5981d982b9baa303b30573754010605200498103d879800014a029405280a5014a02940cc060dd5981d182b1baa013301730563754084666030604860aa6ea8048c0e4c154dd5001800998181bab303830543754607060a86ea8028c08cc150dd502818258008b182a80098289baa001163014301f30503754606860a06ea800458c148004ccc0bc024c0d8c138dd502526103d879800016305000133302d0073030304c375409098103d87980003033304b3754605e60966ea8004c134c128dd50008b198178020199bab304b304c304c304c304c304c304c304c00237586094002609460940046eb0c120004c110dd501818008009129998220008a4000266e012002330020023047001304430413754078294054ccc0f8cdc3a40140542a66607c002264646464a66608c60920042a6660846604a9201094d75737420766f7465003232533304430413046375400429445281929998221820800899192999825182680109924c64a66608e60880022a66609660946ea8008526161533304730400011533304b304a37540042930b0b18241baa00116304b001304737540042a666088607a002264646464a666098609e004264932999824182298251baa001132323232533305030530021324994ccc130c124c138dd5001899192999829182a8010a4c2c6eb8c14c004c13cdd50018b0b1bad30510013051002304f001304b37540022c2c609a002609a0046eb4c12c004c11cdd50010b18229baa0013300d302d3045375400200626604a9201124d757374206d696e74206e6f20746f6b656e0000a14a02c608e0026660486eb0c118008c118c11cc11cc11cc10cdd501fa6103d87980003756608a608c608c608c608c608c608c608c608c608c00260826ea80b45280999919191119191919192999824182298251baa00113253330493042304b37540022646464a6660a060a60042646464a66609e609860a26ea80044cc0c8cc03ccc150dd49b984901084d697373696e6720003305437526e60038cc150dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003302d30103030009375c60aa60a46ea800454cc140cc03ccc150dd49b98491084d697373696e6720003305437526e60038cc150dd49b9849010d20757067726164652070617468004bd70249001632533304f304830513754002298103d87a8000130393305437526eb8c148c8cdd8182b000982b182b8009bac30553052375400297ae032330010013756606c60a46ea800c894ccc1500045300103d87a80001323253330523371e6eb8c1500080244c0f0cc15cdd39982b982a0011982b982a80125eb812f5c026600800800260b000460ac002a66609a6094609e6ea80044c8c8c8c94ccc154c1600084c9263304b001232375c60ac0046eb8c15000458dd5982b000982b0011bad3054001305037540022c6026603c609e6ea8c0ccc13cdd50008b1828800999817002804260103d8798000375c609e60986ea800458c0ccc12cdd5181998259baa302f304b3754609c60966ea800458cc0c0dd6182680201a1bab304c304d304d304d002375860960026096002608c6ea80c888dcc9919199800800802244100222533304a0021001132333004004304e00353330473044371a00426e600044cdc500119b8a00537300026e64dd718260011b98001300100122533304400114bd7009982298211823000998010011823800a49075374616b696e6700301e3041375407a606c607e6ea80ec8c10cc110c110c110c110c110c110c11000488c94ccc0f8c0dcc100dd500089919198008008029129998228008a5eb7bdb1804c8c94ccc10ccdc40029bad3049304a30463754608c004266090004660080080022660080080026092004608e0026eb4c110c104dd50008b181418201baa302830403754002444600e66e0ccdc119b81375a605060806ea8008dd6981418201baa0030014820302a32a68e894ccc0e8c0c0c0f0dd500089820181e9baa001153303b491134e6f7420616e20696e6c696e6520646174756d00163375e98101a000374c60326eacc060c0ecdd50139baf4c0103d87a8000233301148900488100001223253330383035303a37540022607c60766ea800454cc0e5240117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533303e00114c0103d87a80001323232533303d3375e00c607e0062604e6608400297ae0133005005002303f0023042002304000130043303c0024bd701818981b1baa032374a90011ba54801088cc060008c01800488ccc030dd7180e981a9baa002375c6032606a6ea800800488888c8cc004004cc068018c020014894ccc0e8004528099299981b99299981c19baf300a303b375400200e264a66607a002294454ccc0f4c1000044c8c8c94ccc0f0c078dd718210018a99981e180f0008a99981e181c981f1baa0091533303c337129000001099b89002482026fb808528099b89480000085280a50375c608260840046eb4c100c104c104004dd6181f8008a5032330010013300d3756604060786ea8008c03801c894ccc0f800452f5c0264666444646600200200644a66608800220062646608c6e9ccc118dd4803198231ba9375c60860026608c6ea0dd69822000a5eb80cc00c00cc120008c118004dd7181e8009bab303e001330030033042002304000114a0607a00429444cc00c00c004c0f40048c0d4c0d8c0d800494ccc0b8c0acc0c0dd5000899119baf301b30333754603660666ea8004008c0d0c0c4dd5000899119baf301b30333754002004606860626ea800488c8ccc00400400c0088894ccc0d400840044c8ccc010010c0e400cccccc024008dd7181a0009bab3035001222325333036300c00114c103d87a8000130203303b374c00297ae032333001001003002222533303c0021001132333004004304000333333011002375c60760026eb4c0f0004888c94ccc0f4c0e80045300103d87a80001302733042375000297ae03370000400202a607c00401c606e0044646600200200444a666064002297adef6c6013233034337606ea4dd718188009ba632330010013756606600444a66606a002297adef6c6013233037337606ea4dd7181a0009ba83370290001bad3035001330030033039002303700133003003303600230340012533302f00114a2294088888c8cc004004018894ccc0d00044cc0d4cdd81ba9006374c00a97adef6c601323232325333034300f3300700a002133039337606ea4028dd30048028a99981a19b8f00a002132533303530323037375400226607466ec0dd4805981d981c1baa001004100433300800a009001133039337606ea4008dd3000998030030019bab3036003375c60680046070004606c00244444646600200200c44a66606600226606866ec0dd48031ba80054bd6f7b630099191919299981998071980380500109981c19bb037520146ea002401454ccc0cccdc7805001099299981a1818981b1baa001133039337606ea402cc0e8c0dcdd5000802080219980400500480089981c19bb037520046ea0004cc01801800cdd6981a8019bae3033002303700230350012333002375c602660566ea8004dd7180798159baa001480088894ccc0a4c09800452f5bded8c0264646600200297adef6c60225333030001133031337606ea4018dd3001a5eb7bdb1804c8c8c8c94ccc0c0c02ccc0300280084cc0d4cdd81ba900a374c00e00a2a66606066e3c0280084cc0d4cdd81ba900a374c00e00626606a66ec0dd48011ba600133006006003375660640066eb8c0c0008c0d0008c0c8004c8cc0040052f5bded8c044a66605e00226606066ec0dd48021ba80034bd6f7b630099191919299981798051980580400109981a19bb037520106ea001c01454ccc0bccdc780400109981a19bb037520106ea001c00c4cc0d0cdd81ba900237500026600c00c0066eb4c0c400cdd71817801181980118188009baf4c0103d879800022533302633720004002298103d8798000153330263371e0040022980103d87a800014c103d87b80002233003375860566058605860586058605860586058605860506ea800800488c8cc00400400c894ccc0a8004528099299981399b8f375c605a00400829444cc00c00c004c0b400488ccc02c008dd7180718131baa001375c6014604c6ea80048c09cc0a0c0a0c0a0c0a00048c8cc004004008894ccc09800452f5bded8c0264646464a66604c6010004200626605666ec0dd48011ba600133006006003375660500066eb8c098008c0a8008c0a0004dc7a450022533301f33301f0014a094454cc08000840044004888c8cc0140108c008c020c090dd5000a99980f980e18109baa00112330063756600e60466ea800400c48cdc4240006660106eacc01cc08cdd50009bae300b302337540066eb8c01cc08cdd50019119198008008019129998118008a5eb804c8c94ccc084c0140084cc098008cc0100100044cc010010004c09c008c09400488c054ccc010008dd71803980f9baa001375c6006603e6ea80048c080c084004888c94ccc070c054c078dd50008a400026eb4c088c07cdd500099299980e180a980f1baa00114c0103d87a8000132330010013756604660406ea8008894ccc088004530103d87a8000132323253330213371e00e6eb8c08c00c4c02ccc098dd4000a5eb804cc014014008dd698118011813001181200099198008008021129998108008a6103d87a8000132323253330203371e00e6eb8c08800c4c028cc094dd3000a5eb804cc014014008dd598110011812801181180091191980080080191299980f8008a6103d87a800013232533301d3375e601060406ea80080144c01ccc0880092f5c0266008008002604600460420026e9520002301c001301637540166032602c6ea800458c060c064008c05c004c04cdd50008a4c26cac600200a464a66601e601800226464a66602a60300042930b1bae3016001301237540042a66601e60100022a66602660246ea8008526161533300f300500115333013301237540042930b0a999807980200089919299980a980c0010a4c2c6eb4c058004c048dd50010a99980798018008a99980998091baa00214985854ccc03ccdc3a40140022a66602660246ea8008526161533300f3370e90060008a99980998091baa00214985858c040dd50009b8748020dc3a400c6e1d2004325333009300600113232533300f3012002132498c01800458c040004c030dd50038a9998049801000899192999807980900109924ca6660166010601a6ea80044c8c8c8c8c8c94ccc054c0600084c8c926300e0023300b003232325333014301130163754002264646464a666038603e0042930b1bad301d001301d002375a6036002602e6ea800458c058008dd6980a0008b180b000980b0011bab30140013014002375c6024002601c6ea80045858c040004c030dd50038b18051baa006370e90011119198008008019129998070008a4c264660060066024004600660200024a66600c600660106ea80044c8c8c8c94ccc038c0440084c926300600116300f001300f002375a601a00260126ea80045894ccc014c008c01cdd500089919299980598070010a4c2c6eb4c030004c020dd50008b1b87480015cd2b9c5573aaae7955cfaba05742ae881"
2025
+ };
2026
+
2027
+ // src/types/indigo/staking.ts
2028
+ var import_lucid17 = require("@lucid-evolution/lucid");
2029
+ var import_ts_pattern4 = require("ts-pattern");
2030
+ var StakingParamsSchema = import_lucid17.Data.Object({
2031
+ stakingManagerNft: AssetClassSchema,
2032
+ stakingToken: AssetClassSchema,
2033
+ indyToken: AssetClassSchema,
2034
+ pollToken: AssetClassSchema,
2035
+ versionRecordToken: AssetClassSchema,
2036
+ collectorValHash: import_lucid17.Data.Bytes()
2037
+ });
2038
+ var StakingRedeemerSchema = import_lucid17.Data.Enum([
2039
+ import_lucid17.Data.Object({
2040
+ CreateStakingPosition: import_lucid17.Data.Object({
2041
+ creatorPkh: import_lucid17.Data.Bytes()
2042
+ })
2043
+ }),
2044
+ import_lucid17.Data.Literal("UpdateTotalStake"),
2045
+ import_lucid17.Data.Literal("Distribute"),
2046
+ import_lucid17.Data.Object({
2047
+ AdjustStakedAmount: import_lucid17.Data.Object({
2048
+ adjustAmount: import_lucid17.Data.Integer()
2049
+ })
2050
+ }),
2051
+ import_lucid17.Data.Literal("Unstake"),
2052
+ import_lucid17.Data.Literal("Lock"),
2053
+ import_lucid17.Data.Literal("UpgradeVersion")
2054
+ ]);
2055
+ var RewardSnapshotSchema = import_lucid17.Data.Object({ snapshotAda: import_lucid17.Data.Integer() });
2056
+ var StakingManagerContentSchema = import_lucid17.Data.Object({
2057
+ totalStake: import_lucid17.Data.Integer(),
2058
+ managerSnapshot: RewardSnapshotSchema
2059
+ });
2060
+ var StakingPositionContentSchema = import_lucid17.Data.Object({
2061
+ owner: import_lucid17.Data.Bytes(),
2062
+ lockedAmount: import_lucid17.Data.Map(
2063
+ import_lucid17.Data.Integer(),
2064
+ import_lucid17.Data.Tuple([import_lucid17.Data.Integer(), import_lucid17.Data.Integer()], {
2065
+ hasConstr: true
2066
+ })
2067
+ ),
2068
+ positionSnapshot: RewardSnapshotSchema
2069
+ });
2070
+ var StakingDatumSchema = import_lucid17.Data.Enum([
2071
+ import_lucid17.Data.Object({
2072
+ StakingManager: import_lucid17.Data.Object({ content: StakingManagerContentSchema })
2073
+ }),
2074
+ import_lucid17.Data.Object({
2075
+ StakingPosition: import_lucid17.Data.Object({ content: StakingPositionContentSchema })
2076
+ })
2077
+ ]);
2078
+ var StakingDatum = StakingDatumSchema;
2079
+ function parseStakingPositionDatum(datum) {
2080
+ return (0, import_ts_pattern4.match)(import_lucid17.Data.from(datum, StakingDatum)).with({ StakingPosition: { content: import_ts_pattern4.P.select() } }, (res) => res).otherwise(() => {
2081
+ throw new Error("Expected a StakingPosition datum.");
2082
+ });
2083
+ }
2084
+ function parseStakingManagerDatum(datum) {
2085
+ return (0, import_ts_pattern4.match)(import_lucid17.Data.from(datum, StakingDatum)).with({ StakingManager: { content: import_ts_pattern4.P.select() } }, (res) => res).otherwise(() => {
2086
+ throw new Error("Expected a StakingPosition datum.");
2087
+ });
2088
+ }
2089
+ function serialiseStakingDatum(d) {
2090
+ return import_lucid17.Data.to(d, StakingDatum);
2091
+ }
2092
+
2093
+ // src/helpers/staking-helpers.ts
2094
+ var import_lucid18 = require("@lucid-evolution/lucid");
2095
+ var StakingHelpers = class {
2096
+ static async findStakingManagerByOutRef(stakingManagerRef, lucid) {
2097
+ return lucid.utxosByOutRef([stakingManagerRef]).then(
2098
+ (utxos) => utxos.map((utxo) => {
2099
+ if (!utxo.datum) return void 0;
2100
+ const datum = parseStakingManagerDatum(utxo.datum);
2101
+ return { utxo, datum };
2102
+ }).find((utxo) => utxo !== void 0)
2103
+ ).then((result) => {
2104
+ if (!result)
2105
+ throw new Error(
2106
+ "Unable to locate Staking Manager by output reference."
2107
+ );
2108
+ return result;
2109
+ });
2110
+ }
2111
+ static async findStakingManager(params, lucid) {
2112
+ return lucid.utxosAtWithUnit(
2113
+ StakingContract.address(params.stakingParams, lucid),
2114
+ params.stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid18.fromText)(params.stakingParams.stakingManagerNFT[1].unTokenName)
2115
+ ).then(
2116
+ (utxos) => utxos.map((utxo) => {
2117
+ if (!utxo.datum) return void 0;
2118
+ const datum = parseStakingManagerDatum(utxo.datum);
2119
+ return { utxo, datum };
2120
+ }).find((utxo) => utxo !== void 0)
2121
+ ).then((result) => {
2122
+ if (!result)
2123
+ throw new Error(
2124
+ "Unable to locate Staking Manager by output reference."
2125
+ );
2126
+ return result;
2127
+ });
2128
+ }
2129
+ static async findStakingPositionByOutRef(stakingPositionRef, lucid) {
2130
+ return lucid.utxosByOutRef([stakingPositionRef]).then(
2131
+ (utxos) => utxos.map((utxo) => {
2132
+ if (!utxo.datum) return void 0;
2133
+ const datum = parseStakingPositionDatum(utxo.datum);
2134
+ return { utxo, datum };
2135
+ }).find((utxo) => utxo !== void 0)
2136
+ ).then((result) => {
2137
+ if (!result)
2138
+ throw new Error(
2139
+ "Unable to locate Staking Position by output reference."
2140
+ );
2141
+ return result;
2142
+ });
2143
+ }
2144
+ };
2145
+
2146
+ // src/contracts/staking.ts
2147
+ var StakingContract = class _StakingContract {
2148
+ static async openPosition(amount, params, lucid, stakingManagerRef) {
2149
+ const [pkh, _] = await addrDetails(lucid);
2150
+ const stakingManagerOut = stakingManagerRef ? await StakingHelpers.findStakingManagerByOutRef(
2151
+ stakingManagerRef,
2152
+ lucid
2153
+ ) : await StakingHelpers.findStakingManager(params, lucid);
2154
+ const stakingScriptRef = await _StakingContract.scriptRef(
2155
+ params.scriptReferences,
2156
+ lucid
2157
+ );
2158
+ const stakingTokenScriptRefUtxo = await _StakingContract.stakingTokenScriptRef(
2159
+ params.scriptReferences,
2160
+ lucid
2161
+ );
2162
+ const newStakingManagerDatum = {
2163
+ totalStake: stakingManagerOut.datum.totalStake + amount,
2164
+ managerSnapshot: {
2165
+ snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
2166
+ }
2167
+ };
2168
+ const stakingPositionDatum = {
2169
+ owner: pkh.hash,
2170
+ lockedAmount: /* @__PURE__ */ new Map([]),
2171
+ positionSnapshot: {
2172
+ snapshotAda: stakingManagerOut.datum.managerSnapshot.snapshotAda
2173
+ }
2174
+ };
2175
+ const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.stakingToken[1].unTokenName);
2176
+ const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.indyToken[1].unTokenName);
2177
+ return lucid.newTx().collectFrom([stakingManagerOut.utxo], import_lucid19.Data.to(new import_lucid19.Constr(0, [pkh.hash]))).readFrom([stakingScriptRef]).pay.ToContract(
2178
+ stakingManagerOut.utxo.address,
2179
+ {
2180
+ kind: "inline",
2181
+ value: serialiseStakingDatum({
2182
+ StakingManager: { content: newStakingManagerDatum }
2183
+ })
2184
+ },
2185
+ stakingManagerOut.utxo.assets
2186
+ ).readFrom([stakingTokenScriptRefUtxo]).mintAssets(
2187
+ {
2188
+ [stakingToken]: 1n
2189
+ },
2190
+ import_lucid19.Data.void()
2191
+ ).pay.ToContract(
2192
+ _StakingContract.address(params.stakingParams, lucid),
2193
+ {
2194
+ kind: "inline",
2195
+ value: serialiseStakingDatum({
2196
+ StakingPosition: { content: stakingPositionDatum }
2197
+ })
2198
+ },
2199
+ {
2200
+ [stakingToken]: 1n,
2201
+ [indyToken]: amount
2202
+ }
2203
+ ).addSignerKey(pkh.hash);
2204
+ }
2205
+ static async adjustPosition(stakingPositionRef, amount, params, lucid, stakingManagerRef) {
2206
+ const [pkh, _] = await addrDetails(lucid);
2207
+ const now = Date.now();
2208
+ const stakingPositionOut = await StakingHelpers.findStakingPositionByOutRef(
2209
+ stakingPositionRef,
2210
+ lucid
2211
+ );
2212
+ const stakingManagerOut = stakingManagerRef ? await StakingHelpers.findStakingManagerByOutRef(
2213
+ stakingManagerRef,
2214
+ lucid
2215
+ ) : await StakingHelpers.findStakingManager(params, lucid);
2216
+ const stakingScriptRef = await _StakingContract.scriptRef(
2217
+ params.scriptReferences,
2218
+ lucid
2219
+ );
2220
+ const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.stakingToken[1].unTokenName);
2221
+ const stakingManagerToken = params.stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.stakingManagerNFT[1].unTokenName);
2222
+ const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.indyToken[1].unTokenName);
2223
+ const existingIndyAmount = stakingPositionOut.utxo.assets[indyToken] ?? 0n;
2224
+ const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
2225
+ const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
2226
+ const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / (1000000n * 1000000n);
2227
+ const newLockedAmount = /* @__PURE__ */ new Map();
2228
+ for (const [key, value] of stakingPositionOut.datum.lockedAmount) {
2229
+ if (value[1] > now) {
2230
+ newLockedAmount.set(key, [value[0], value[1]]);
2231
+ }
2232
+ }
2233
+ return lucid.newTx().validFrom(Date.now()).readFrom([stakingScriptRef]).collectFrom([stakingPositionOut.utxo], import_lucid19.Data.to(new import_lucid19.Constr(3, [amount]))).collectFrom([stakingManagerOut.utxo], import_lucid19.Data.to(new import_lucid19.Constr(1, []))).pay.ToContract(
2234
+ stakingManagerOut.utxo.address,
2235
+ {
2236
+ kind: "inline",
2237
+ value: serialiseStakingDatum({
2238
+ StakingManager: {
2239
+ content: {
2240
+ ...stakingManagerOut.datum,
2241
+ totalStake: stakingManagerOut.datum.totalStake + amount
2242
+ }
2243
+ }
2244
+ })
2245
+ },
2246
+ {
2247
+ lovelace: stakingManagerOut.utxo.assets.lovelace - adaReward,
2248
+ [stakingManagerToken]: 1n
2249
+ }
2250
+ ).pay.ToContract(
2251
+ stakingPositionOut.utxo.address,
2252
+ {
2253
+ kind: "inline",
2254
+ value: serialiseStakingDatum({
2255
+ StakingPosition: {
2256
+ content: {
2257
+ ...stakingPositionOut.datum,
2258
+ lockedAmount: newLockedAmount
2259
+ }
2260
+ }
2261
+ })
2262
+ },
2263
+ {
2264
+ [stakingToken]: 1n,
2265
+ [indyToken]: stakingPositionOut.utxo.assets[indyToken] + amount
2266
+ }
2267
+ ).addSignerKey(pkh.hash);
2268
+ }
2269
+ static async closePosition(stakingPositionRef, params, lucid, stakingManagerRef) {
2270
+ const [pkh, _] = await addrDetails(lucid);
2271
+ const stakingPositionOut = await StakingHelpers.findStakingPositionByOutRef(
2272
+ stakingPositionRef,
2273
+ lucid
2274
+ );
2275
+ const stakingManagerOut = stakingManagerRef ? await StakingHelpers.findStakingManagerByOutRef(
2276
+ stakingManagerRef,
2277
+ lucid
2278
+ ) : await StakingHelpers.findStakingManager(params, lucid);
2279
+ const stakingScriptRef = await _StakingContract.scriptRef(
2280
+ params.scriptReferences,
2281
+ lucid
2282
+ );
2283
+ const stakingTokenScriptRefUtxo = await _StakingContract.stakingTokenScriptRef(
2284
+ params.scriptReferences,
2285
+ lucid
2286
+ );
2287
+ const stakingToken = params.stakingParams.stakingToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.stakingToken[1].unTokenName);
2288
+ const stakingManagerToken = params.stakingParams.stakingManagerNFT[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.stakingManagerNFT[1].unTokenName);
2289
+ const indyToken = params.stakingParams.indyToken[0].unCurrencySymbol + (0, import_lucid19.fromText)(params.stakingParams.indyToken[1].unTokenName);
2290
+ const existingIndyAmount = stakingPositionOut.utxo.assets[indyToken] ?? 0n;
2291
+ const currentSnapshotAda = stakingManagerOut.datum.managerSnapshot.snapshotAda;
2292
+ const oldSnapshotAda = stakingPositionOut.datum.positionSnapshot.snapshotAda;
2293
+ const adaReward = (currentSnapshotAda - oldSnapshotAda) * existingIndyAmount / (1000000n * 1000000n);
2294
+ return lucid.newTx().validFrom(Date.now()).readFrom([stakingScriptRef]).readFrom([stakingTokenScriptRefUtxo]).collectFrom([stakingPositionOut.utxo], import_lucid19.Data.to(new import_lucid19.Constr(4, []))).collectFrom([stakingManagerOut.utxo], import_lucid19.Data.to(new import_lucid19.Constr(1, []))).pay.ToContract(
2295
+ stakingManagerOut.utxo.address,
2296
+ {
2297
+ kind: "inline",
2298
+ value: serialiseStakingDatum({
2299
+ StakingManager: {
2300
+ content: {
2301
+ ...stakingManagerOut.datum,
2302
+ totalStake: stakingManagerOut.datum.totalStake - existingIndyAmount
2303
+ }
2304
+ }
2305
+ })
2306
+ },
2307
+ {
2308
+ lovelace: stakingManagerOut.utxo.assets.lovelace - adaReward,
2309
+ [stakingManagerToken]: 1n
2310
+ }
2311
+ ).mintAssets(
2312
+ {
2313
+ [stakingToken]: -1n
2314
+ },
2315
+ import_lucid19.Data.void()
2316
+ ).addSignerKey(pkh.hash);
2317
+ }
2318
+ // Staking Validator
2319
+ static validator(params) {
2320
+ return {
2321
+ type: "PlutusV2",
2322
+ script: (0, import_lucid19.applyParamsToScript)(_stakingValidator.cborHex, [
2323
+ new import_lucid19.Constr(0, [
2324
+ new import_lucid19.Constr(0, [
2325
+ params.stakingManagerNFT[0].unCurrencySymbol,
2326
+ (0, import_lucid19.fromText)(params.stakingManagerNFT[1].unTokenName)
2327
+ ]),
2328
+ new import_lucid19.Constr(0, [
2329
+ params.stakingToken[0].unCurrencySymbol,
2330
+ (0, import_lucid19.fromText)(params.stakingToken[1].unTokenName)
2331
+ ]),
2332
+ new import_lucid19.Constr(0, [
2333
+ params.indyToken[0].unCurrencySymbol,
2334
+ (0, import_lucid19.fromText)(params.indyToken[1].unTokenName)
2335
+ ]),
2336
+ new import_lucid19.Constr(0, [
2337
+ params.pollToken[0].unCurrencySymbol,
2338
+ (0, import_lucid19.fromText)(params.pollToken[1].unTokenName)
2339
+ ]),
2340
+ new import_lucid19.Constr(0, [
2341
+ params.versionRecordToken[0].unCurrencySymbol,
2342
+ (0, import_lucid19.fromText)(params.versionRecordToken[1].unTokenName)
2343
+ ]),
2344
+ params.collectorValHash
2345
+ ])
2346
+ ])
2347
+ };
2348
+ }
2349
+ static validatorHash(params) {
2350
+ return (0, import_lucid19.validatorToScriptHash)(_StakingContract.validator(params));
2351
+ }
2352
+ static address(params, lucid) {
2353
+ const network = lucid.config().network;
2354
+ if (!network) {
2355
+ throw new Error("Network configuration is undefined");
2356
+ }
2357
+ return (0, import_lucid19.validatorToAddress)(network, _StakingContract.validator(params));
2358
+ }
2359
+ static async scriptRef(params, lucid) {
2360
+ return scriptRef(params.stakingValidatorRef, lucid);
2361
+ }
2362
+ static async stakingTokenScriptRef(params, lucid) {
2363
+ return scriptRef(params.authTokenPolicies.stakingTokenRef, lucid);
2364
+ }
2365
+ };
2366
+
2367
+ // src/contracts/interest-oracle.ts
2368
+ var import_lucid25 = require("@lucid-evolution/lucid");
2369
+
2370
+ // src/contracts/one-shot.ts
2371
+ var import_lucid22 = require("@lucid-evolution/lucid");
2372
+
2373
+ // src/scripts/one-shot-policy.ts
2374
+ var import_lucid21 = require("@lucid-evolution/lucid");
2375
+
2376
+ // src/types/one-shot.ts
2377
+ var import_lucid20 = require("@lucid-evolution/lucid");
2378
+ var OneShotParamsSchema = import_lucid20.Data.Object({
2379
+ referenceOutRef: import_lucid20.Data.Object({
2380
+ txHash: import_lucid20.Data.Bytes(),
2381
+ outputIdx: import_lucid20.Data.Integer()
2382
+ }),
2383
+ mintAmounts: import_lucid20.Data.Array(
2384
+ import_lucid20.Data.Object({
2385
+ /// Use hex encoded string
2386
+ tokenName: import_lucid20.Data.Bytes(),
2387
+ amount: import_lucid20.Data.Integer()
2388
+ })
2389
+ )
2390
+ });
2391
+ var OneShotParams = OneShotParamsSchema;
2392
+ function castOneShotParams(params) {
2393
+ return import_lucid20.Data.castTo(params, OneShotParams);
2394
+ }
2395
+
2396
+ // src/scripts/one-shot-policy.ts
2397
+ var oneShotPolicyData = {
2398
+ type: "PlutusV3",
2399
+ cborHex: "590426010100229800aba4aba2aba1aba0aab9faab9eaab9dab9a4888888896600264653001300800198041804800cdc3a400130080024888966002600460106ea800e33001375c601860126ea800eb300130023008375400915980098049baa0048a4d16402916401d374a90002444b30013005300b37546466446600400400244b30010018a60103d87a80008992cc004cdd7980998081baa0010048980299809000a5eb8226600600660280048070c0480050101bac3010300d375400a601e60186ea804e2b3001332259800800c52844ca600264b30013009300f37540031375a602060266eacc04cc040dd5000c5200040386024003375e6024602600337560049112cc0040062b3001300200589805801c52820208992cc004cdd79809000a610140008acc004cdc38021bad301330163756602600313003374c602e00514a0808a2b3001300c00489801803452820224044602a0028098653001001801c88cc04c008cc04cdd3000a5eb810011112cc00400a266002980103d87a80004bd6f7b63044ca60026eb8c0440066eacc048006602c0069112cc004cdc8a441000038acc004cdc7a4410000389980298051980b9ba60024bd70000c4cc015300103d87a8000006404d19800803c006446600e0046603266ec0dd48029ba6004001401c8098602800480922942294229410131bab300f3010301030103010300c37540086e98c8ca600200337586004601c6ea805697adef6c604004444b30010028800c66002007301400299914c004c0040066eb8c054c048dd50014dd6980318091baa002488966002601c00310068991919800800804112cc00400626603466ec0dd48079ba60034bd6f7b63044ca60026eb8c0600066eacc064006603a0049112cc004cdc8009801c4cc078cdd81ba9013374c00e00b15980099b8f0130038992cc004c058c070dd5000c4cc07ccdd81ba90143020301d37540020051002406c64b300159800800c528c528203c8a6103d87a8000898091980f9ba60014bd70203632330010010032259800800c4cc080cdd81ba900b375001497adef6c608994c004dd7180f000cdd6980f800cc08c0092225980099b9000f00389981219bb0375201e6ea00380162b30013371e01e00713259800980e18111baa00189981299bb03752020604c60466ea800400a20048108c966002603800314c103d87a80008980c198129ba80014bd7020423370000401d133024337606ea400cdd400119803003000a04040803021001407d13301e337606ea400cdd300119803003000a0344068301b0014064646400460080026602e66ec0dd48011ba80014bd6f7b63020261809801112cc00400629344c966002003149a264b3001337206eb8c04cc05c00cdd71809800c4cc010010cc058004c06000a2c8090c058005014180b000a026400c80888c040c04400629462c80522c805116401c300800130033754013149a26cac8009"
2400
+ };
2401
+ function mkOneShotPolicy(params) {
2402
+ return {
2403
+ type: oneShotPolicyData.type,
2404
+ script: (0, import_lucid21.applyParamsToScript)(oneShotPolicyData.cborHex, [
2405
+ castOneShotParams(params)
2406
+ ])
2407
+ };
2408
+ }
2409
+
2410
+ // src/contracts/one-shot.ts
2411
+ var import_Array = require("fp-ts/lib/Array");
2412
+ async function oneShotMintTx(lucid, params) {
2413
+ const oneShotPolicy = mkOneShotPolicy(params);
2414
+ const policyId = (0, import_lucid22.mintingPolicyToId)(oneShotPolicy);
2415
+ const refUtxo = matchSingle(
2416
+ await lucid.utxosByOutRef([
2417
+ {
2418
+ txHash: params.referenceOutRef.txHash,
2419
+ outputIndex: Number(params.referenceOutRef.outputIdx)
2420
+ }
2421
+ ]),
2422
+ (_) => {
2423
+ throw new Error("Cannot find the reference UTXO for one-shot.");
2424
+ }
2425
+ );
2426
+ return [
2427
+ lucid.newTx().collectFrom([refUtxo]).mintAssets(
2428
+ (0, import_Array.reduce)(
2429
+ {},
2430
+ (acc, entry) => (0, import_lucid22.addAssets)(acc, {
2431
+ [(0, import_lucid22.toUnit)(policyId, entry.tokenName)]: entry.amount
2432
+ })
2433
+ )(params.mintAmounts),
2434
+ import_lucid22.Data.to(new import_lucid22.Constr(0, []))
2435
+ ).attach.MintingPolicy(oneShotPolicy),
2436
+ policyId
2437
+ ];
2438
+ }
2439
+ async function runOneShotMintTx(lucid, params) {
2440
+ const [tx, policyId] = await oneShotMintTx(lucid, params);
2441
+ const txHash = await tx.complete().then((tx2) => tx2.sign.withWallet().complete()).then((tx2) => tx2.submit());
2442
+ await lucid.awaitTx(txHash);
2443
+ return policyId;
2444
+ }
2445
+
2446
+ // src/scripts/interest-oracle-validator.ts
2447
+ var import_lucid23 = require("@lucid-evolution/lucid");
2448
+ var interestOracleValidator = {
2449
+ type: "PlutusV2",
1039
2450
  cborHex: "590a3f590a3c0100003232323232323232223232322322533300932323253323300d3001300f375400426464646464a666024601e60286ea80044c8c8c8c94ccc058cc005241205458206973206e6f74207369676e6564206279206f7261636c65206f776e6572003232330010013758603c603e603e603e603e603e603e603e603e60366ea8038894ccc074004528099299980d19b8f375c604000400829444cc00c00c004c080004dd71801980c9baa01515332330173300249115496e636f72726563742074782076616c6964697479003232323232533301c32533301d300500114a22a66603a60220022944528180f1baa33003300d301f3754004601a603e6ea80044c94ccc074c0680045288a99980e98088008a5114a0603c6ea8cc00cc024c07cdd50011804980f9baa00114a06008601666040601666040600a660406ea0cdc09bad3008301e375402a6eb4c030c078dd500d25eb80cc080ccc06d28a60103d87a80004c0103d87980004bd70198101805998101802998101ba8337006eb4c020c078dd500a9bad300c301e375403497ae03302033301b4a298103d87a80004c0103d87980004bd7025eb80c00cc080c084c084c084c084c084c084c084c074dd50081119299980e180c8008a99980e180c980f1baa00214c103d87a800014c103d87980001533301c30040011533301c3004301e3754004298103d87a800014c103d87b800013232533301e3012001132533301f33710006002298103d87980001533301f337100020062980103d87b800014c103d87a8000375a604860426ea801054ccc078c06c004530103d87b800014c103d8798000301f37540066eb4c088c07cdd5001980e9baa002370e9002118041980e99299980c9806980d9baa001132533301a32533301f301e0011533301b300f301d00114a22a6660366030603a00229405858dd51803980e9baa300b301d3754006260086603e6ea00052f5c0260086603e6ea0cdc0000a400497ae0375a603e60386ea80044004c024c06cdd51804980d9baa0013301d325333019300d301b3754002264a66603464a66603e603c0022a666036601e603a002294454ccc06cc060c0740045280b0b1baa3007301d3754600e603a6ea800c4c010cc07cdd4000a5eb804c010cc07cdd419b80001480052f5c06eb4c07cc070dd500088009804980d9baa3005301b375400297ae01325333018330034912643757272656e742074696d652068617320746f206265203e3d206c6173745f736574746c656400337126eb4c004c06cdd500b1bad3005301b37540242a66466032660089212b496e74657265737420726174652068617320746f20626520696e2072616e6765205b30252c20313030255d0053330193001375a601460386ea8c028c070dd5009899b89375a601460386ea8c028c070dd500999b82480092080897a14a026600892120496e746572657374206f7261636c65206f757470757420696e636f72726563740033332222323300100132323300100101222533302500114bd7009919299981198028010998140011980200200089980200200098148011813800a99980f180d98101baa00413223375e602260466ea8c044c08cdd5000801181218109baa00413223375e602260466ea8004008c090c084dd50021129998118008a5013253330203253330213375e601460486ea80040184c94ccc0980045288a99981318148008991919299981299b8f375c605600691100153330253371e00291010015333025302230273754980103d87a800015333025300d00213371200490404df7010a501300d00214a02940dd7181518158011bad3029302a302a001375860500022940c8cc004004c8ccc004004dd5980818131baa003323300100100822533302900114bd6f7b6300991981599bb037526eb8c0a0004dd319198008009bab302a00222533302c00114bd6f7b6300991981719bb037526eb8c0ac004dd419b8148000dd69816000998018019818001181700099801801981680118158009112999814801080089919980200218168019991191980080080291299981700089981799bb037520086e9800d2f5bded8c0264646464a66605c66ebccc05402000930103d8798000133033337606ea4020dd30038028a99981719b8f008002132533302f302c3031375400226606866ec0dd4804981a98191baa001004100432533302f533303300114a229405300103d87a80001301f33034374c00297ae0323330010010080022225333035002100113233300400430390033322323300100100522533303a00113303b337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc0e8cdd799810804001260103d879800013303f337606ea4020dd40038028a99981d19b8f008002132533303b3038303d375400226608066ec0dd48049820981f1baa001004100432533303b303800114c103d87a80001302b33040375000297ae03370000e00226607e66ec0dd48011ba800133006006003375a60780066eb8c0e8008c0f8008c0f0004dd7181a0009bad30350013037002133033337606ea4008dd3000998030030019bab3030003375c605c004606400460600026eb8c0a0004dd5981480098158011129998138008a5eb804c8ccc888c8cc00400400c894ccc0b4004400c4c8cc0bcdd3998179ba90063302f37526eb8c0b0004cc0bcdd41bad302d0014bd7019801801981880118178009bae30260013756604e00266006006605600460520022940c098008528899801801800981300091299980d99b9000200114c103d87980001533301b3371e0040022980103d87a800014c103d87b800030033301e30093301e0053301e4c0103d87a80004bd7025eb80cdd2a40086603c60126603c6ea0cdc01bad300a301c375402e64a66603466e20dd69801980e9baa01800113370666e0ccdc119b82337020026eb4c00cc074dd500c1bad300b301d3754600e603a6ea8061208080a0f6f4acdbe01b48202c227efa8052080897a153301b491254d75737420686f6c643a206e6f77203e206c61737420696e746572657374207570646174650016375a600c60386ea804ccc078c028c070dd50099980f1803180e1baa0134bd7025eb80dd59803180e1baa3006301c375400e6e25200014a029408c078c07cc07c004dd2a4004294052811299980b99980b800a504a22a6603000420022002600a602e6ea8c014c05cdd51800980b9baa0022301a301b0013018301537540022c6644646600200200644a666032002298103d87a80001323253330173375e601060346ea80080144c01ccc0700092f5c0266008008002603a00460360026eb0c05c010c05cc050dd50031ba5480008c058004dd6180a180a980a80098081baa003370e90010b18089809001180800098061baa00114984d9594ccc01cc010c024dd50008991919192999807980900109924c600e0062c6eb4c040004c040008c038004c028dd50008b2999802980118039baa0031323232323232533300f3012002132498c01c00c58dd698080009808001180700098070011bad300c001300837540062c4a66600a6004600e6ea80044c8c94ccc02cc03800852616375a601800260106ea800458dc3a4000ae695ce2ab9d5573caae7d5d02ba157441"
1040
2451
  };
2452
+ function mkInterestOracleValidator(params) {
2453
+ return {
2454
+ type: interestOracleValidator.type,
2455
+ script: (0, import_lucid23.applyParamsToScript)(interestOracleValidator.cborHex, [
2456
+ castInterestOracleParams(params)
2457
+ ])
2458
+ };
2459
+ }
2460
+
2461
+ // src/helpers/value-helpers.ts
2462
+ var import_lucid24 = require("@lucid-evolution/lucid");
2463
+ function mkLovelacesOf(amount) {
2464
+ return { lovelace: amount };
2465
+ }
2466
+ function assetClassToUnit(ac) {
2467
+ return (0, import_lucid24.toUnit)(ac.currencySymbol, ac.tokenName);
2468
+ }
2469
+ function mkAssetsOf(assetClass, amount) {
2470
+ return {
2471
+ [assetClassToUnit(assetClass)]: amount
2472
+ };
2473
+ }
2474
+
2475
+ // tests/queries/interest-oracle-queries.ts
2476
+ async function findInterestOracle(lucid, interestNft) {
2477
+ const interestUtxo = await lucid.utxoByUnit(assetClassToUnit(interestNft));
2478
+ if (!interestUtxo.datum) throw new Error("No interest oracle utxo found");
2479
+ return [interestUtxo, parseInterestOracleDatum(interestUtxo.datum)];
2480
+ }
2481
+
2482
+ // src/contracts/interest-oracle.ts
2483
+ var InterestOracleContract = class {
2484
+ static async startInterestOracle(initialUnitaryInterest, initialInterestRate, initialLastInterestUpdate, oracleParams, lucid, withScriptRef = false, refOutRef, interestTokenName) {
2485
+ const tokenName = interestTokenName ?? "INTEREST_ORACLE";
2486
+ if (!refOutRef) {
2487
+ refOutRef = (await lucid.wallet().getUtxos())[0];
2488
+ }
2489
+ const [tx, policyId] = await oneShotMintTx(lucid, {
2490
+ referenceOutRef: {
2491
+ txHash: refOutRef.txHash,
2492
+ outputIdx: BigInt(refOutRef.outputIndex)
2493
+ },
2494
+ mintAmounts: [
2495
+ {
2496
+ tokenName: (0, import_lucid25.fromText)(tokenName),
2497
+ amount: 1n
2498
+ }
2499
+ ]
2500
+ });
2501
+ const validator = mkInterestOracleValidator(oracleParams);
2502
+ tx.pay.ToContract(
2503
+ (0, import_lucid25.validatorToAddress)(lucid.config().network, validator),
2504
+ {
2505
+ kind: "inline",
2506
+ value: serialiseInterestOracleDatum({
2507
+ unitaryInterest: initialUnitaryInterest,
2508
+ interestRate: {
2509
+ getOnChainInt: initialInterestRate
2510
+ },
2511
+ lastUpdated: initialLastInterestUpdate
2512
+ })
2513
+ },
2514
+ {
2515
+ lovelace: 2500000n,
2516
+ [(0, import_lucid25.toUnit)(policyId, (0, import_lucid25.fromText)(tokenName))]: 1n
2517
+ }
2518
+ );
2519
+ if (withScriptRef) {
2520
+ tx.pay.ToAddressWithData(
2521
+ (0, import_lucid25.validatorToAddress)(lucid.config().network, validator),
2522
+ void 0,
2523
+ void 0,
2524
+ validator
2525
+ );
2526
+ }
2527
+ return [
2528
+ tx,
2529
+ {
2530
+ currencySymbol: policyId,
2531
+ tokenName: (0, import_lucid25.fromText)(tokenName)
2532
+ }
2533
+ ];
2534
+ }
2535
+ static async feedInterestOracle(params, newInterestRate, lucid, assetClass, utxo, scriptRef2) {
2536
+ if (!assetClass && !utxo)
2537
+ throw new Error("Either interest oracle nft or utxo must be provided");
2538
+ if (assetClass && !utxo) {
2539
+ const [ioUtxo, _datum] = await findInterestOracle(lucid, assetClass);
2540
+ utxo = ioUtxo;
2541
+ }
2542
+ const now = BigInt(Date.now());
2543
+ const tx = lucid.newTx();
2544
+ const datum = parseInterestOracleDatum(utxo.datum);
2545
+ if (scriptRef2) {
2546
+ tx.readFrom([scriptRef2]);
2547
+ } else {
2548
+ tx.attach.Script(mkInterestOracleValidator(params));
2549
+ }
2550
+ tx.collectFrom(
2551
+ [utxo],
2552
+ serialiseFeedInterestOracleRedeemer({
2553
+ newInterestRate: {
2554
+ getOnChainInt: newInterestRate
2555
+ },
2556
+ currentTime: now
2557
+ })
2558
+ );
2559
+ tx.pay.ToContract(
2560
+ utxo.address,
2561
+ {
2562
+ kind: "inline",
2563
+ value: serialiseInterestOracleDatum({
2564
+ unitaryInterest: datum.unitaryInterest + calculateUnitaryInterestSinceOracleLastUpdated(now, datum),
2565
+ interestRate: {
2566
+ getOnChainInt: newInterestRate
2567
+ },
2568
+ lastUpdated: now
2569
+ })
2570
+ },
2571
+ utxo.assets
2572
+ );
2573
+ tx.validFrom(Number(now) - ONE_SECOND);
2574
+ tx.validTo(Number(now + params.biasTime) - ONE_SECOND);
2575
+ tx.addSignerKey(params.owner);
2576
+ return tx;
2577
+ }
2578
+ };
2579
+
2580
+ // src/scripts/cdp-creator-validator.ts
2581
+ var import_lucid26 = require("@lucid-evolution/lucid");
2582
+ var cdpCreatorValidator = {
2583
+ type: "PlutusV2",
2584
+ description: "",
2585
+ cborHex: "591a6c591a6901000032323232323232322232322323225333009323232533300c3006300e37540022646464646464646464646464646464646464a66603c603660406ea80644c8c8c8ccccc8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c88888c8c8c8c8c8c94ccc0f8c0ecc100dd50008991919192999821181e18221baa00213232533304433034490115496e636f72726563742074782076616c69646974790032325333046325333047302d00114a22a66608e6082002294452818241baa3301d303930493754004607260926ea80044c94ccc11cc1100045288a99982398208008a5114a060906ea8cc074c0c4c124dd5001181898249baa00114a06034606e66094606e660946036660946ea0cdc08071bad30163048375408897ae03304a3330454a298103d87a80004c0103d87980004bd7019825181b99825180d998251ba83370001c6eb4c058c120dd502225eb80cc128ccc11528a6103d87a80004c0103d87980004bd7025eb80c064c058c11cdd501d0a9998221981a24811754582069736e74207369676e6564206279206f776e657200330283758602a608e6ea80e804054ccc110cc0d124011543445043726561746f724e4654206d697373696e67003302e3756605e608e6ea8c0bcc11cdd5003181b98239baa04315333044330344912043445043726561746f72206f757470757420646f6573206e6f74206d617463680033333014008301a330490054bd70260107d87b9fd87980ff00301330373047375408698103d87a80001533304433034491174d696e7465642076616c756520697320696e76616c6964003375e6e98c0c8dd5981898239baa03a374c66660306026604e608e6ea810cdd7181798239baa043375c606e608e6ea800803c54ccc110cc0d1240115434450206f757470757420697320696e76616c69640033333014008303633049301a33049304a304b304b304b304b304b3047375408697ae04bd7019ba548010cc124c0d8cc124c0d8cc124c0d8cc124dd480825eb80cc124c0dcc11cdd5001198249ba800f33049303633049375001a660926ea0cdc01bad303730473754002a66608866e20dd6981398239baa00100d13370666e0ccdc119b823370201a6eb4c09cc11cdd50009bad303730473754605e608e6ea8005208080a0f6f4acdbe01b48202c227efa8052080897a15330454901254d75737420686f6c643a206e6f77203e206c61737420696e7465726573742075706461746500164bd7025eb812f5c097ae033012301330273047375408601c980103d87980001325332330463303649115556e646572636f6c6c61746572697a65642043445000337126eb4c0e4c124dd51980c9980c981998249baa00430383304b3750600202297ae03039304937540046eb4c0e4c124dd51980c981c198259ba830010104bd70181c198259ba833704906400a410112f497ae01533304633036491164e6f6e706f736974697665206d696e74656420616d7400302e011153330463303649012e4d7573742070726f76696465206d6f7265207468616e206d696e436f6c6c61746572616c496e4c6f76656c61636500337126eb4c060c124dd50228080a9998231981b249174f7261636c652063616e2774206265206578706972656400333046325333047304130493754002266e24dd6981918251baa003375a609a60946ea800454cc121240124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e67650016303930493754606260926ea8c060c124dd501e2504a226606c9201194d757374207061792064656274206d696e74696e67206665650033322232533304a3032002132533304b3232302c00232533304d304a00115333051305037540042930b0a99982698238008a99982898281baa00214985854ccc134c0cc00454ccc144c140dd50010a4c2c2c609c6ea8004c94ccc130c124c138dd50008982918279baa001153304d49117436f756c64206e6f742066696e642072656465656d6572001632323300100100722533305200114c0103d87a8000132323253330513375e00c60a600626086660ac00297ae0133005005002305300230560023054001302133050303e304e375400297ae013333301b00f302133050303d33050002330504c103d87a80004bd7025eb8130107d87b9fd87980ff00330193756606c609c6ea8c0d8c138dd5000801a60103d879800014a064a66609e0022a66098921284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400161533304f305200113051001153304c4901284d757374207370656e64203120696e7075742066726f6d20636f6c6c6563746f722073637269707400163303301123375e607c609c6ea8c0f8c138dd5181b18271baa00100214a2603e6609c6ea40092f5c06eacc130c134c134c134c134c134c134c134c134c134c124dd501e1bae30133049375408a6644a66609066e2400520001480004dd6981d98259baa303a3304d375066e0cc00cdd6981d98259baa3301b303a3304d375000297ae0002375a607660966ea8c0e8cc134dd419b8248320052080897a4bd7025eb80c04cc124dd50021bad303930493754660326070660966ea00452f5c0607260926ea80085280a5014a06e092080897a14a064a66608a6084608e6ea800454cc11924012543616e6e6f74206f70656e206120434450206f6620612064656c69737465642061737365740016132320025333046304330483754002264646464a66609c60a20042649318118018b1bad304f001304f002304d001304937540022c6054605060906ea8c0c0c120dd51929998250008a99823a492145787065637465642065786163746c79206f6e65206f7261636c6520696e70757400161533304a304d0011304c001153304749012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001633302c00a304b30483754609660906ea8005300103d8798000302f3047375400429405280a5014a0294052819190012999822182098231baa0011323232323232533304e3051002132498c08c00c58dd698278009827801182680098268011bad304b001304737540022c6050604c608c6ea8c0b8c118dd51929998240008a99822a492a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001615333048304b0011304a001153304549012a45787065637465642065786163746c79206f6e6520696e746572657374206f7261636c6520696e707574001633302a008302630463754002980103d87980003048304537540042c64a666084607e00226464a6660906096004264932999822182098231baa001132323232323232325333050305300213232498c94ccc138c12c0044c8c8c8c94ccc158c16400852616375a60ae00260ae0046eb4c154004c144dd50018a9998271824000899191919299982b182c8010a4c2c6eb4c15c004c15c008dd6982a80098289baa00316304f3754004604800e2c60a200260a20046eb4c13c004c13c008dd718268009826801182580098239baa00116163049001304537540042a666084607800226464a6660906096004264932999822182098231baa001132323232323232323232323232323232323232323232323232323232533306430670021323232323232323232323232498c10c030c10c03cc108040c104044c100048c0fc04cc0f8050c0f4054c0f0058c0ec05cc0f4060c94ccc184c1780044c8c94ccc19cc1a80084c926303c001163068001306437540342a6660c260b600226464a6660ce60d4004264932999831983018329baa001132325333069306c002132498c10400458c1a8004c198dd50008b0b183400098321baa01a16306237540322c60ca00260ca00464a6660c460c20022a6660bc60b060c0002294454ccc178c16cc1800045280b0b1baa3063001306300230610013061002305f001305f002305d001305d002305b001305b0023059001305900230570013057002305500130550023053001305300230510013051002304f001304f002304d001304d002375c6096002608e6ea80045858c124004c114dd50010b18219baa0013025302330433754605660866ea8c94ccc11400454cc10924012145787065637465642065786163746c79206f6e652069617373657420696e707574001615333045304800113047001153304249012145787065637465642065786163746c79206f6e652069617373657420696e707574001633302700530463047304730473043375407e980103d8798000303230423754605460846ea8004c110c104dd50008b198170020189bac304230430023758608200260820046eb0c0fc004c0ecdd50171181d181d981d981d981d981d981d800911999804001244100488100001233225333034302e4800052f5bded8c0264646600200297adef6c6022533303b00113303c337606ea4014dd3001a5eb7bdb1804c8c8c8c94ccc0ecc068cc0540240084cc100cdd81ba9009374c00e00a2a66607666e3c0240084cc100cdd81ba9009374c00e00626608066ec0dd48011ba6001330060060033756607a0066eb8c0ec008c0fc008c0f4004c8cc0040052f5bded8c044a66607400226607666ec0dd4801a610101004bd6f7b630099191919299981d180c9980a00380109981f99bb0375200e9810101000051533303a3371e00e00426607e66ec0dd4803a6101010000313303f337606ea4008dd4000998030030019bad303c003375c6074004607c00460780026eb8c094c0d4dd50009bae301d303537540024444464660020026603e00ca66606c606660706ea80144c88cdd79815981d9baa302b303b3754002004607860726ea80144c88cdd79815981d9baa001002303c3039375400a44a66607600229404c94ccc0e0c94ccc0e4cdd7980e181e1baa001007132533303e00114a22a66607c60820022646464a66607a60586eb8c10c00c54ccc0f4c0b000454ccc0f4c0e8c0fcdd50048a99981e99b89480000084cdc48012410137dc0429404cdc4a400000429405281bae30423043002375a6082608460840026eb0c1000045281919800800991998008009bab3026303e3754006646600200201244a666082002297adef6c6013233043337606ea4dd718200009ba632330010013756608400444a666088002297adef6c6013233046337606ea4dd718218009ba83370290001bad3044001330030033048002304600133003003304500230430012225333041002100113233300400430450033333301b002375c60800026eacc104004888c94ccc108c0740045300103d87a80001303433047374c00297ae03233300100100300222253330480021001132333004004304c00333333023002375c608e0026eb4c120004888c94ccc124c1180045300103d87a80001303b3304e375000297ae03370000400203e6094004030608600444a66607e002297ae01323332223233001001003225333045001100313233047374e6608e6ea4018cc11cdd49bae30440013304737506eb4c1140052f5c0660060066092004608e0026eb8c0f8004dd5981f80099801801982180118208008a50303e00214a2266006006002607c0024606c606e606e606e606e606e606e606e606e0024606a606c606c606c606c606c606c606c002446042660686ea0cdc199b82375a604460646ea8008dd6981118191baa0014820225e92f5c04444a666060605a002200826666601a0080066464004646600200200444a66606e002293099299981c0008a4c26464a66606c606660706ea8cc040dd7181c181e0021bae30380021330050053303b0020011533037491326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016303c002303a001303a00133035337606ea4008dd4000a5eb7bdb180888c94ccc0d0c03c004530103d87a80001302633039374c00297ae033333011001005004222325333037303400114c103d87a8000130293303c375000297ae03370000200401a0144603c6606264a66605a604e605e6ea80044c94ccc0b8c94ccc0ccc0c800454ccc0bcc0a4c0c40045288a999817981618188008a5016163754603260626ea8c084c0c4dd500189802198199ba80014bd7009802198199ba833700002900125eb80dd6981998181baa0011001301f302f3754603e605e6ea8004cc0c4c94ccc0b4c09cc0bcdd5000899299981719299981998190008a999817981498188008a511533302f302c303100114a02c2c6ea8c064c0c4dd5180c98189baa0031300433033375000297ae01300433033375066e0000520014bd701bad3033303037540022002603e605e6ea8c05cc0bcdd5000a5eb80dd2a40044464a66605860520022a6660586052605c6ea8008530103d87a800014c103d87980001533302c30120011533302c3012302e3754004298103d87a800014c103d87b800013232533302e3028001132533302f33710006002298103d87980001533302f337100020062980103d87b800014c103d87a8000375a606860626ea801054ccc0b8c0ac004530103d87b800014c103d8798000302f37540066eb4c0c8c0bcdd500198169baa002232533302a30270011323253330303033002149858dd7181880098169baa0021533302a30240011533302e302d37540042930b0b18159baa001253330283025302a375400226464a66605c60620042930b1bad302f001302b37540022c44a66605066e40008004530103d8798000153330283371e0040022980103d87a800014c103d87b80002533302a00114a2294094ccc094c088c09cdd5000899191919299981698180010a4c2c6eb8c0b8004c0b8008dd7181600098141baa0011622222323300100100622533302e00113302f337606ea4018dd3002a5eb7bdb1804c8c8c8c94ccc0b8c034cc01c0280084cc0cccdd81ba900a374c01200a2a66605c66e3c0280084c94ccc0bcc0b0c0c4dd500089981a19bb03752016606a60646ea80040104010ccc0200280240044cc0cccdd81ba9002374c0026600c00c0066eacc0c000cdd718170011819001181800091111191980080080311299981680089981719bb0375200c6ea00152f5bded8c0264646464a66605a60186600e01400426606466ec0dd48051ba80090051533302d3371e014004264a66605c605660606ea80044cc0cccdd81ba900b303430313754002008200866601001401200226606466ec0dd48011ba800133006006003375a605e0066eb8c0b4008c0c4008c0bc004dd7a6103d8798000375c604e0066eb4c09c008dd698138009bad302730280013027001302600130213754032266646464446464646464a666050604a60546ea80044c94ccc0a4c08cc0acdd500089919192999818181980109919192999817981618189baa00113301f3300f3303437526e61241084d697373696e6720003303437526e60038cc0d0dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd7024900330133010301d009375c606a60646ea800454cc0c0cc03ccc0d0dd49b98491084d697373696e6720003303437526e60038cc0d0dd49b9849010d20757067726164652070617468004bd70249001632533302f302930313754002298103d87a8000130213303437526eb8c0c8c8cdd8181b000981b181b8009bac30353032375400297ae032330010013756603460646ea800c894ccc0d00045300103d87a80001323253330323371e6eb8c0d00080244c090cc0dcdd39981b981a0011981b981a80125eb812f5c02660080080026070004606c002a66605a6054605e6ea80044c8c8c8c94ccc0d4c0e00084c926323300100100222533303700114984c8cc00c00cc0ec008c8c8dd7181c0011bae30360013039001163756606c002606c0046eb4c0d0004c0c0dd50008b1808980798179baa3017302f37540022c606200266602200a01098103d8798000375c605e60586ea800458c06cc0acdd5180d98159baa3013302b3754605c60566ea800458cc060dd6181680200d9bab302c302d302d302d002375860560026056002604c6ea806488dcc9919199800800802244100222533302a0021001132333004004302e00353330273024371a00426e600044cdc500119b8a00537300026e64dd718160011b98001300100122533302400114bd7009981298111813000998010011813800a490a43445043726561746f7200300b3021375403a46048604a604a00244646600200200644a66604800229404c94ccc084cdc79bae302700200414a2266006006002604e0024a6660386004603c6ea80044c088c07cdd50008a9980ea481134e6f7420616e20696e6c696e6520646174756d0016370e9002111191980300211801180498109baa001533301c3019301e3754002246600e6eacc020c080dd50008018918029998049bab3008302037540026eb8c040c080dd50019bae3008302037540066e21200022323300100100322533301f00114bd7009919299980e980280109981100119802002000899802002000981180118108009118091998020011bae300b301b37540026eb8c00cc06cdd50009180e180e80091119299980c1809180d1baa0011480004dd6980f180d9baa0013253330183012301a37540022980103d87a8000132330010013756603e60386ea8008894ccc078004530103d87a80001323232533301d3371e00e6eb8c07c00c4c03ccc088dd4000a5eb804cc014014008dd6980f80118110011810000991980080080211299980e8008a6103d87a80001323232533301c3371e00e6eb8c07800c4c038cc084dd3000a5eb804cc014014008dd5980f0011810801180f8009180d180d980d980d980d8009191980080080111299980c8008a5eb7bdb1804c8c8c8c94ccc064c020008400c4cc078cdd81ba9002374c0026600c00c0066eacc06c00cdd7180c801180e801180d8009b8f4881002253330123330120014a094454cc04c0084004400488c8cc00400400c894ccc05c0045300103d87a80001323253330153375e601060306ea80080144c01ccc0680092f5c0266008008002603600460320026e952000230140013012300f37540022c60226024004602000260186ea80045261365632533300830050011323232323232323253330143017002149858dd6980a800980a8011bad30130013013002375a602200260220046eb8c03c004c02cdd50018a99980418010008a99980618059baa00314985858c024dd50011b8748008c94ccc014c008c01c00454ccc024c020004526161637540046e1d20005734ae7155ceaab9e5573eae815d0aba21"
2586
+ };
2587
+ var mkCDPCreatorValidator = (params) => {
2588
+ return {
2589
+ type: cdpCreatorValidator.type,
2590
+ script: (0, import_lucid26.applyParamsToScript)(cdpCreatorValidator.cborHex, [
2591
+ castCDPCreatorParams(params)
2592
+ ])
2593
+ };
2594
+ };
2595
+ var mkCDPCreatorValidatorFromSP = (params) => {
2596
+ return {
2597
+ type: cdpCreatorValidator.type,
2598
+ script: (0, import_lucid26.applyParamsToScript)(cdpCreatorValidator.cborHex, [
2599
+ castCDPCreatorParams({
2600
+ cdpCreatorNft: fromSystemParamsAsset(params.cdpCreatorNft),
2601
+ cdpAssetCs: params.cdpAssetCs.unCurrencySymbol,
2602
+ cdpAuthTk: fromSystemParamsAsset(params.cdpAuthTk),
2603
+ iAssetAuthTk: fromSystemParamsAsset(params.iAssetAuthTk),
2604
+ versionRecordToken: fromSystemParamsAsset(params.versionRecordToken),
2605
+ cdpScriptHash: params.cdpScriptHash,
2606
+ collectorValHash: params.collectorValHash,
2607
+ minCollateralInLovelace: BigInt(params.minCollateralInLovelace),
2608
+ biasTime: BigInt(params.biasTime)
2609
+ })
2610
+ ])
2611
+ };
2612
+ };
2613
+
2614
+ // src/scripts/poll-shard-validator.ts
2615
+ var import_lucid28 = require("@lucid-evolution/lucid");
2616
+
2617
+ // src/types/indigo/poll-shard.ts
2618
+ var import_lucid27 = require("@lucid-evolution/lucid");
2619
+ var PollShardParamsSchema = import_lucid27.Data.Object({
2620
+ pollToken: AssetClassSchema,
2621
+ stakingToken: AssetClassSchema,
2622
+ indyAsset: AssetClassSchema,
2623
+ stakingValHash: import_lucid27.Data.Bytes()
2624
+ });
2625
+ var PollShardParams = PollShardParamsSchema;
2626
+ function castPollShardParams(params) {
2627
+ return import_lucid27.Data.castTo(params, PollShardParams);
2628
+ }
2629
+
2630
+ // src/scripts/poll-shard-validator.ts
2631
+ var pollShardValidatorData = {
2632
+ type: "PlutusV2",
2633
+ description: "Generated by Aiken",
2634
+ cborHex: "59166859166501000032323232323232322232323232322322533300b323232533300e300830103754002264a66601e601260226ea80344c8c8c8c8c8c8c8c8c8c94c8ccc068c054c070dd50090999191919191919191911919299981518168010991919299981698180010992999815181218161baa00113232533303030330021323232533302f3301f4911d496e76616c696420696e707574206265696e672076616c696461746564003375e042602e60646ea802854ccc0bccc07d2401225468652070726f706f73616c206578636565647320766f74696e6720706572696f64003322325333032302c30343754002264a66606664a666070606e0022a666068605c606c002294454ccc0d0c0bcc0d80045280b0b1baa301c303637546038606c6ea80104cdc4000801899b89001003375a6070606a6ea8004528180c981a1baa301a30343754004602060646ea808cdd6980898191baa0201533302f3301f49011c54686520706f6c6c206f757470757420697320696e636f7272656374003333300e3758602260646ea808cc074cc0d00252f5c0602c66068603a6606864603e6606a606c0026606a64a666062605860666ea80384c080cc0d8dd419b80375a603260686ea800400cc0e0c0d0dd5000898101981b181b981a1baa00133036375066e00dd6980d181a1baa0010034bd70180c98199baa021303730370013032375404097ae04bd701bab301830323754603060646ea8029300103d87980001533302f3301f4910e4d697865642076657273696f6e73003375e602e60646ea8c05cc0c8dd5180c18191baa007301d33034301a3032375405c97ae01533302f3301f49127546865207472616e73616374696f6e206d757374206265207369676e6564206279206f776e6572003232330010013758606e6070607060706070607060706070607060686ea8094894ccc0d8004528099299981999b8f375c607200400829444cc00c00c004c0e4004dd7180b98191baa0041533302f3301f4911a5573657220766f74656420666f7220706f6c6c206265666f72650033302f3300d002375a602e60646ea8081282511533302f3301f491124d757374206d696e74206e6f20746f6b656e003375e6e98c8cc004004dd5981b181b981b981b981b98199baa02422533303500114bd6f7b630099191919299981a980a801080189981d19bb037520046e98004cc01801800cdd5981b8019bae3035002303900230370014c0101a0001533302f3301f491245374616b696e67506f736974696f6e206d757374207570646174652070726f7065726c79003333300e3758602260646ea808cc074cc0d0c078cc0d0c074cc0d0c068c0c8dd501725eb80cc0d130103d87a80004bd7025eb80c058cc0d0c074cc0d0c8c07ccc0d4c0d8004cc0d4dd319912999819198080028010991980080080311299981c0008a5eb7bdb1804cc0e4c8c94ccc0d8cdc3800803099bb0375000200a20046eb4c0dc004c0e8004cc008008c0ec0044c8c8cc00400401c894ccc0e4004400c4cc0e8c0ec004cc008008c0f0004cc0dccdd81ba80020014bd6f7b6301bad301830333754042603e6606a6ea0008cc0d4c048c0ccdd5010a5eb80c0dcc0dc004c0c8dd500225eb812f5c06eacc060c0c8dd5180c18191baa0074c0103d87a800013301f4901275374616b696e6720506f736974696f6e206d75737420757365204c6f636b2072656465656d65720032323375e004980103d87e8000325333031302c001132325333037303a002149858dd7181c000981a1baa00215333031302b00115333035303437540042930b0a99981898168008a99981a981a1baa00214985854ccc0c4cdc3a400c00226464a66606e60740042930b1bad3038001303437540042a66606266e1d200800115333035303437540042930b0a99981899b874802800454ccc0d4c0d0dd50010a4c2c2a66606266e1d200c00115333035303437540042930b0b18191baa0013301c30173032375400e6eacc06cc0c8dd50118a5014a029405280a5014a02940528199119980a8011bae3018303337540026eb8c064c0ccdd50009bab301730313754602e60626ea8018c040c0c4dd501699192999817981498189baa001132323300100100422533303600114bd6f7b63009919299981a19b88005375a60746076606e6ea8c0dc0084cc0e4008cc0100100044cc010010004c0e8008c0e0004dd6981a98191baa00116301630313754602c60626ea8c03cc0c4dd50111bab301630303754004a666058604e605c6ea80044c8c8c8c8c8c94ccc0d8c0e40084c8c9265333033302e3035375400426464a66607260780042930b1bad303a001303637540042c6605e00646464a66606a6060606e6ea80044c8c8c8c94ccc0f4c10000852616375a607c002607c0046eb4c0f0004c0e0dd50008b181b8011bad303500116303700130370023756606a002606a0046eb8c0cc004c0bcdd50008b0b181880098169baa0011632533302a3026302c375400226060605a6ea800454cc0ad241134e6f7420616e20696e6c696e6520646174756d0016300b302c3754602460586ea800458c0b8004ccc028dd6180798151baa01b3010302a375404c98103d8798000300e30293754601e60526ea800458c0ac004ccc01cdd6180618139baa018300c3027375404698103d8798000225333024301f30263754646600200200644a666054002298103d87a80001323253330283370e6eb4c0a80080144c05ccc0b4dd399816981500119816981580125eb812f5c0266008008002605c00460580022944528111111980819805002a999813181098141baa00413223375e602060566ea8c040c0acdd5000801181618149baa00413223375e602060566ea8004008c0b0c0a4dd50021299981399baf3009302a3754002008264a666058002294454ccc0b0c0bc0044c8c8c94ccc0acc02cdd718188018a99981598058008a999815981318169baa0061533302b337129000001099b89002482026fb808528099b89480000085280a50375c606060620046eb4c0bcc0c0c0c0004dd618170008a503233001001323330010013756602460586ea800cc8cc004004018894ccc0bc00452f5bded8c02646606266ec0dd49bae302e001374c64660020026eacc0c0008894ccc0c800452f5bded8c02646606866ec0dd49bae3031001375066e052000375a606400266006006606c00460680026600600660660046062002444a66605e004200226466600800860660066644646600200200a44a66606800226606a66ec0dd48021ba60034bd6f7b630099191919299981a19baf3301a0080024c0103d8798000133039337606ea4020dd30038028a99981a19b8f008002132533303530303037375400226607466ec0dd4804981d981c1baa0010041004325333035533303900114a229405300103d87a8000130243303a374c00297ae032333001001008002222533303b0021001132333004004303f00333223233001001005225333040001133041337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc100cdd799813004001260103d8798000133045337606ea4020dd40038028a99982019b8f0080021325333041303c3043375400226608c66ec0dd4804982398221baa0010041004325333041303c00114c103d87a80001303033046375000297ae03370000e00226608a66ec0dd48011ba800133006006003375a60840066eb8c100008c110008c108004dd7181d0009bad303b001303d002133039337606ea4008dd3000998030030019bab3036003375c60680046070004606c0026eb8c0b8004dd5981780098188011129998168008a5eb804c8ccc888c8cc00400400c894ccc0cc004400c4c8cc0d4dd39981a9ba90063303537526eb8c0c8004cc0d4dd41bad30330014bd7019801801981b801181a8009bae302c0013756605a002660060066062004605e0022940dc7a441002302630273027302730273027302730270012302530263026001222323300500423002300b30253754002a666040603660446ea800448c06cccc018dd5980518121baa001375c601260486ea800cdd7180518121baa003123371090001998031bab300a302437540026eb8c024c090dd50019bae300a3024375400644646600200200644a666048002297ae01323253330223005002133027002330040040011330040040013028002302600122232533301f3019302137540022900009bad30253022375400264a66603e603260426ea80045300103d87a8000132330010013756604c60466ea8008894ccc094004530103d87a8000132323253330243371e00e6eb8c09800c4c04ccc0a4dd4000a5eb804cc014014008dd698130011814801181380099198008008021129998120008a6103d87a8000132323253330233371e00e6eb8c09400c4c048cc0a0dd3000a5eb804cc014014008dd598128011814001181300091299980e19b9000200114c0103d87980001533301c3371e0040022980103d87a800014c103d87b80003020301d375402426466446601a9213953686f756c642063616c6c206120506f6c6c4d616e6167657220696e7075742077697468204d657267655368617264732072656465656d6572003232533301f3375e004600c660486ea00112f5c02660126eb0c01cc088dd50099299981019baf004300830233754002266ebcc020c08cdd5180498119baa001300b30233754022294052819299980f980d00089919299981298140010a4c2c6eb4c098004c088dd50010a99980f980c80089919299981298140010a4c2c6eb4c098004c088dd50010a99980f980d80089919299981298140010a4c2c6eb4c098004c088dd50010b18101baa0013300a0013756601260406ea8044dd6981080098109811000980e9baa012374a90021180f8009180f180f80091191980080080191299980f0008a50132533301b3004302100214a2266006006002604200246038603a603a603a002460366038603860386038603860386038603860380024464a66602c602260306ea80044c070c064dd50008a9980ba48117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533301c00114c0103d87a80001323232533301b3375e00c603a006260146604000297ae0133005005002301d0023020002301e00130033301a0024bd701ba548008dd2a400044a666024666024002941288a9980980108008800980a98091baa00d14a0602860226ea800458c04cc050008c048004c038dd50008a4c26cac64a666014600a00226464a66602060260042649319299980698040008a99980898081baa00214985854ccc034c01c00454ccc044c040dd50010a4c2c2c601c6ea800458c044004c034dd50010a99980518020008991919192999809180a80109924ca66601c601260206ea80044c8c8c8c94ccc058c0640084c9265333012300d3014375400626464a66603060360042930b1bae3019001301537540062c2c6eb4c05c004c05c008c054004c044dd50008b0b180980098098011bad3011001300d37540042c60166ea8004c8c8c8c8c8c8c94ccc038c0240044c8c94ccc050c05c0084c9265333010300b3012375400226464646464646464646464646464646464646464646464646464a66605c606200426464649318100099929998161813800899192999819181a80109924ca66605c605260606ea80044c8c8c8c94ccc0d8c0e40084c8c9263303000225333034302f303637540022646464646464a66607c60820042930b1bad303f001303f002375c607a002607a0046eb8c0ec004c0dcdd50008b18148018b1bac303700130370023035001303137540022c2c6066002605e6ea805454ccc0b0c09800454ccc0c0c0bcdd500a8a4c2c2c605a6ea8050c94ccc0acc0980044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc11cc1280084c8c8c8c8c8c8c8c8c8c8c926304200b304100c304000d303f00e303e00f303d010303c011303b012303a013303c0143039015163048001304800230460013046002304400130440023042001304200230400013040002303e001303e002303c001303c002303a001303a002303800130380023036001303600230340013034002375c6064002605c6ea805854ccc0acc0940044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc11cc1280084c8c8c8c8c8c8c8c8c8c8c926304200b304100c304000d303f00e303e00f303d010303c011303b012303a013303c014325333044303f00113232533304a304d002132498c0ec00458c12c004c11cdd500b0a999822181f000899192999825182680109924c60780022c6096002608e6ea805858c114dd500a8b1824000982400118230009823001182200098220011821000982100118200009820001181f000981f001181e000981e001181d000981d001181c000981c001181b000981b001181a000981a0011bae3032001302e375402c2a666056604e00226464a6660626068004264932999816981418179baa0011323232323232323232323232323232323232323253330453048002132498c0d802c58dd6982300098230011bad30440013044002375a608400260840046eb4c100004c100008dd6981f000981f001181e000981e0011bad303a001303a002375a607000260700046eb4c0d8004c0d8008dd6981a00098181baa00116163032001302e375402c2a66605666e1d200600113232533303130340021324994ccc0b4c0a0c0bcdd5000899191919299981a981c00109924c6605c00246464a666068605e606c6ea80044c8c94ccc0e8c0f400852616375c6076002606e6ea800458c0d8008dd7181a0008b1bab30360013036002375a606800260606ea80045858c0c8004c0b8dd500b0a99981599b87480200044c8c94ccc0c4c0d000852616375c6064002605c6ea805858c0b0dd500a8b1bad302f001302f002375a605a002605a0046eb4c0ac004c0ac008dd6981480098148011bad30270013027002375a604a002604a0046eb4c08c004c08c008dd698108009810801180f800980f801180e800980e801180d800980d8011bae30190013019002375a602e00260266ea80045858c054004c044dd50060a999807180400089919299980a180b80109924ca666020601660246ea80044c8c8c8c8c8c8c8c94ccc070c07c0084c8c9263010002300c00516301d001301d002375a60360026036004603200260320046eb4c05c004c04cdd50008b0b180a80098089baa00c16300f37540164a66601a6010601e6ea80044c8c8c8c94ccc054c06000852616375a602c002602c0046eb4c050004c040dd50008b12999806180398071baa0011323253330123015002149858dd6980980098079baa001162533300b3006300d375400226464a66602260280042649318028008b180900098071baa001162533300a3005300c3754002264646464a666024602a0042646493192999808180580089919299980b180c80109924c64a666026601c00226464a66603260380042649318070008b180d000980b1baa00215333013300d0011323232323232533301d3020002149858dd6980f000980f0011bad301c001301c002375a6034002602c6ea800858c050dd50008b180b80098099baa00315333010300a00115333014301337540062930b0b18089baa002300700316301300130130023011001300d37540022c4a666012600860166ea80044c8c8c8c94ccc044c05000852616375c602400260240046eb8c040004c030dd50008b1192999804980200089919299980798090010a4c2c6eb8c040004c030dd50010a999804980180089919299980798090010a4c2c6eb8c040004c030dd50010b18051baa001370e90011b8748000dc3a400844646600200200644a66601600229309919801801980780118019806800ab9a5738aae7555cf2ab9f5740ae855d11"
2635
+ };
2636
+ var mkPollShardValidator = (params) => {
2637
+ return {
2638
+ type: pollShardValidatorData.type,
2639
+ script: (0, import_lucid28.applyParamsToScript)(pollShardValidatorData.cborHex, [
2640
+ castPollShardParams(params)
2641
+ ])
2642
+ };
2643
+ };
2644
+ var mkPollShardValidatorFromSP = (params) => {
2645
+ return {
2646
+ type: pollShardValidatorData.type,
2647
+ script: (0, import_lucid28.applyParamsToScript)(pollShardValidatorData.cborHex, [
2648
+ castPollShardParams({
2649
+ pollToken: fromSystemParamsAsset(params.pollToken),
2650
+ stakingToken: fromSystemParamsAsset(params.stakingToken),
2651
+ indyAsset: fromSystemParamsAsset(params.indyAsset),
2652
+ stakingValHash: params.stakingValHash
2653
+ })
2654
+ ])
2655
+ };
2656
+ };
2657
+
2658
+ // src/scripts/poll-manager-validator.ts
2659
+ var import_lucid30 = require("@lucid-evolution/lucid");
2660
+
2661
+ // src/types/indigo/poll-manager.ts
2662
+ var import_lucid29 = require("@lucid-evolution/lucid");
2663
+ var PollManagerParamsSchema = import_lucid29.Data.Object({
2664
+ govNFT: AssetClassSchema,
2665
+ pollToken: AssetClassSchema,
2666
+ upgradeToken: AssetClassSchema,
2667
+ indyAsset: AssetClassSchema,
2668
+ govExecuteValHash: import_lucid29.Data.Bytes(),
2669
+ pBiasTime: import_lucid29.Data.Integer(),
2670
+ shardValHash: import_lucid29.Data.Bytes(),
2671
+ treasuryValHash: import_lucid29.Data.Bytes(),
2672
+ initialIndyDistribution: import_lucid29.Data.Integer()
2673
+ });
2674
+ var PollManagerParams = PollManagerParamsSchema;
2675
+ function castPollManagerParams(params) {
2676
+ return import_lucid29.Data.castTo(params, PollManagerParams);
2677
+ }
2678
+
2679
+ // src/scripts/poll-manager-validator.ts
2680
+ var pollManagerValidatorData = {
2681
+ type: "PlutusV2",
2682
+ description: "Generated by Aiken",
2683
+ cborHex: "59166859166501000032323232323232322232323232322322533300b323232533300e300830103754002264a66601e601260226ea80344c8c8c8c8c8c8c8c8c8c94c8ccc068c054c070dd50090999191919191919191911919299981518168010991919299981698180010992999815181218161baa00113232533303030330021323232533302f3301f4911d496e76616c696420696e707574206265696e672076616c696461746564003375e042602e60646ea802854ccc0bccc07d2401225468652070726f706f73616c206578636565647320766f74696e6720706572696f64003322325333032302c30343754002264a66606664a666070606e0022a666068605c606c002294454ccc0d0c0bcc0d80045280b0b1baa301c303637546038606c6ea80104cdc4000801899b89001003375a6070606a6ea8004528180c981a1baa301a30343754004602060646ea808cdd6980898191baa0201533302f3301f49011c54686520706f6c6c206f757470757420697320696e636f7272656374003333300e3758602260646ea808cc074cc0d00252f5c0602c66068603a6606864603e6606a606c0026606a64a666062605860666ea80384c080cc0d8dd419b80375a603260686ea800400cc0e0c0d0dd5000898101981b181b981a1baa00133036375066e00dd6980d181a1baa0010034bd70180c98199baa021303730370013032375404097ae04bd701bab301830323754603060646ea8029300103d87980001533302f3301f4910e4d697865642076657273696f6e73003375e602e60646ea8c05cc0c8dd5180c18191baa007301d33034301a3032375405c97ae01533302f3301f49127546865207472616e73616374696f6e206d757374206265207369676e6564206279206f776e6572003232330010013758606e6070607060706070607060706070607060686ea8094894ccc0d8004528099299981999b8f375c607200400829444cc00c00c004c0e4004dd7180b98191baa0041533302f3301f4911a5573657220766f74656420666f7220706f6c6c206265666f72650033302f3300d002375a602e60646ea8081282511533302f3301f491124d757374206d696e74206e6f20746f6b656e003375e6e98c8cc004004dd5981b181b981b981b981b98199baa02422533303500114bd6f7b630099191919299981a980a801080189981d19bb037520046e98004cc01801800cdd5981b8019bae3035002303900230370014c0101a0001533302f3301f491245374616b696e67506f736974696f6e206d757374207570646174652070726f7065726c79003333300e3758602260646ea808cc074cc0d0c078cc0d0c074cc0d0c068c0c8dd501725eb80cc0d130103d87a80004bd7025eb80c058cc0d0c074cc0d0c8c07ccc0d4c0d8004cc0d4dd319912999819198080028010991980080080311299981c0008a5eb7bdb1804cc0e4c8c94ccc0d8cdc3800803099bb0375000200a20046eb4c0dc004c0e8004cc008008c0ec0044c8c8cc00400401c894ccc0e4004400c4cc0e8c0ec004cc008008c0f0004cc0dccdd81ba80020014bd6f7b6301bad301830333754042603e6606a6ea0008cc0d4c048c0ccdd5010a5eb80c0dcc0dc004c0c8dd500225eb812f5c06eacc060c0c8dd5180c18191baa0074c0103d87a800013301f4901275374616b696e6720506f736974696f6e206d75737420757365204c6f636b2072656465656d65720032323375e004980103d87e8000325333031302c001132325333037303a002149858dd7181c000981a1baa00215333031302b00115333035303437540042930b0a99981898168008a99981a981a1baa00214985854ccc0c4cdc3a400c00226464a66606e60740042930b1bad3038001303437540042a66606266e1d200800115333035303437540042930b0a99981899b874802800454ccc0d4c0d0dd50010a4c2c2a66606266e1d200c00115333035303437540042930b0b18191baa0013301c30173032375400e6eacc06cc0c8dd50118a5014a029405280a5014a02940528199119980a8011bae3018303337540026eb8c064c0ccdd50009bab301730313754602e60626ea8018c040c0c4dd501699192999817981498189baa001132323300100100422533303600114bd6f7b63009919299981a19b88005375a60746076606e6ea8c0dc0084cc0e4008cc0100100044cc010010004c0e8008c0e0004dd6981a98191baa00116301630313754602c60626ea8c03cc0c4dd50111bab301630303754004a666058604e605c6ea80044c8c8c8c8c8c94ccc0d8c0e40084c8c9265333033302e3035375400426464a66607260780042930b1bad303a001303637540042c6605e00646464a66606a6060606e6ea80044c8c8c8c94ccc0f4c10000852616375a607c002607c0046eb4c0f0004c0e0dd50008b181b8011bad303500116303700130370023756606a002606a0046eb8c0cc004c0bcdd50008b0b181880098169baa0011632533302a3026302c375400226060605a6ea800454cc0ad241134e6f7420616e20696e6c696e6520646174756d0016300b302c3754602460586ea800458c0b8004ccc028dd6180798151baa01b3010302a375404c98103d8798000300e30293754601e60526ea800458c0ac004ccc01cdd6180618139baa018300c3027375404698103d8798000225333024301f30263754646600200200644a666054002298103d87a80001323253330283370e6eb4c0a80080144c05ccc0b4dd399816981500119816981580125eb812f5c0266008008002605c00460580022944528111111980819805002a999813181098141baa00413223375e602060566ea8c040c0acdd5000801181618149baa00413223375e602060566ea8004008c0b0c0a4dd50021299981399baf3009302a3754002008264a666058002294454ccc0b0c0bc0044c8c8c94ccc0acc02cdd718188018a99981598058008a999815981318169baa0061533302b337129000001099b89002482026fb808528099b89480000085280a50375c606060620046eb4c0bcc0c0c0c0004dd618170008a503233001001323330010013756602460586ea800cc8cc004004018894ccc0bc00452f5bded8c02646606266ec0dd49bae302e001374c64660020026eacc0c0008894ccc0c800452f5bded8c02646606866ec0dd49bae3031001375066e052000375a606400266006006606c00460680026600600660660046062002444a66605e004200226466600800860660066644646600200200a44a66606800226606a66ec0dd48021ba60034bd6f7b630099191919299981a19baf3301a0080024c0103d8798000133039337606ea4020dd30038028a99981a19b8f008002132533303530303037375400226607466ec0dd4804981d981c1baa0010041004325333035533303900114a229405300103d87a8000130243303a374c00297ae032333001001008002222533303b0021001132333004004303f00333223233001001005225333040001133041337606ea4010dd4001a5eb7bdb1804c8c8c8c94ccc100cdd799813004001260103d8798000133045337606ea4020dd40038028a99982019b8f0080021325333041303c3043375400226608c66ec0dd4804982398221baa0010041004325333041303c00114c103d87a80001303033046375000297ae03370000e00226608a66ec0dd48011ba800133006006003375a60840066eb8c100008c110008c108004dd7181d0009bad303b001303d002133039337606ea4008dd3000998030030019bab3036003375c60680046070004606c0026eb8c0b8004dd5981780098188011129998168008a5eb804c8ccc888c8cc00400400c894ccc0cc004400c4c8cc0d4dd39981a9ba90063303537526eb8c0c8004cc0d4dd41bad30330014bd7019801801981b801181a8009bae302c0013756605a002660060066062004605e0022940dc7a441002302630273027302730273027302730270012302530263026001222323300500423002300b30253754002a666040603660446ea800448c06cccc018dd5980518121baa001375c601260486ea800cdd7180518121baa003123371090001998031bab300a302437540026eb8c024c090dd50019bae300a3024375400644646600200200644a666048002297ae01323253330223005002133027002330040040011330040040013028002302600122232533301f3019302137540022900009bad30253022375400264a66603e603260426ea80045300103d87a8000132330010013756604c60466ea8008894ccc094004530103d87a8000132323253330243371e00e6eb8c09800c4c04ccc0a4dd4000a5eb804cc014014008dd698130011814801181380099198008008021129998120008a6103d87a8000132323253330233371e00e6eb8c09400c4c048cc0a0dd3000a5eb804cc014014008dd598128011814001181300091299980e19b9000200114c0103d87980001533301c3371e0040022980103d87a800014c103d87b80003020301d375402426466446601a9213953686f756c642063616c6c206120506f6c6c4d616e6167657220696e7075742077697468204d657267655368617264732072656465656d6572003232533301f3375e004600c660486ea00112f5c02660126eb0c01cc088dd50099299981019baf004300830233754002266ebcc020c08cdd5180498119baa001300b30233754022294052819299980f980d00089919299981298140010a4c2c6eb4c098004c088dd50010a99980f980c80089919299981298140010a4c2c6eb4c098004c088dd50010a99980f980d80089919299981298140010a4c2c6eb4c098004c088dd50010b18101baa0013300a0013756601260406ea8044dd6981080098109811000980e9baa012374a90021180f8009180f180f80091191980080080191299980f0008a50132533301b3004302100214a2266006006002604200246038603a603a603a002460366038603860386038603860386038603860380024464a66602c602260306ea80044c070c064dd50008a9980ba48117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533301c00114c0103d87a80001323232533301b3375e00c603a006260146604000297ae0133005005002301d0023020002301e00130033301a0024bd701ba548008dd2a400044a666024666024002941288a9980980108008800980a98091baa00d14a0602860226ea800458c04cc050008c048004c038dd50008a4c26cac64a666014600a00226464a66602060260042649319299980698040008a99980898081baa00214985854ccc034c01c00454ccc044c040dd50010a4c2c2c601c6ea800458c044004c034dd50010a99980518020008991919192999809180a80109924ca66601c601260206ea80044c8c8c8c94ccc058c0640084c9265333012300d3014375400626464a66603060360042930b1bae3019001301537540062c2c6eb4c05c004c05c008c054004c044dd50008b0b180980098098011bad3011001300d37540042c60166ea8004c8c8c8c8c8c8c94ccc038c0240044c8c94ccc050c05c0084c9265333010300b3012375400226464646464646464646464646464646464646464646464646464a66605c606200426464649318100099929998161813800899192999819181a80109924ca66605c605260606ea80044c8c8c8c94ccc0d8c0e40084c8c9263303000225333034302f303637540022646464646464a66607c60820042930b1bad303f001303f002375c607a002607a0046eb8c0ec004c0dcdd50008b18148018b1bac303700130370023035001303137540022c2c6066002605e6ea805454ccc0b0c09800454ccc0c0c0bcdd500a8a4c2c2c605a6ea8050c94ccc0acc0980044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc11cc1280084c8c8c8c8c8c8c8c8c8c8c926304200b304100c304000d303f00e303e00f303d010303c011303b012303a013303c0143039015163048001304800230460013046002304400130440023042001304200230400013040002303e001303e002303c001303c002303a001303a002303800130380023036001303600230340013034002375c6064002605c6ea805854ccc0acc0940044c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc11cc1280084c8c8c8c8c8c8c8c8c8c8c926304200b304100c304000d303f00e303e00f303d010303c011303b012303a013303c014325333044303f00113232533304a304d002132498c0ec00458c12c004c11cdd500b0a999822181f000899192999825182680109924c60780022c6096002608e6ea805858c114dd500a8b1824000982400118230009823001182200098220011821000982100118200009820001181f000981f001181e000981e001181d000981d001181c000981c001181b000981b001181a000981a0011bae3032001302e375402c2a666056604e00226464a6660626068004264932999816981418179baa0011323232323232323232323232323232323232323253330453048002132498c0d802c58dd6982300098230011bad30440013044002375a608400260840046eb4c100004c100008dd6981f000981f001181e000981e0011bad303a001303a002375a607000260700046eb4c0d8004c0d8008dd6981a00098181baa00116163032001302e375402c2a66605666e1d200600113232533303130340021324994ccc0b4c0a0c0bcdd5000899191919299981a981c00109924c6605c00246464a666068605e606c6ea80044c8c94ccc0e8c0f400852616375c6076002606e6ea800458c0d8008dd7181a0008b1bab30360013036002375a606800260606ea80045858c0c8004c0b8dd500b0a99981599b87480200044c8c94ccc0c4c0d000852616375c6064002605c6ea805858c0b0dd500a8b1bad302f001302f002375a605a002605a0046eb4c0ac004c0ac008dd6981480098148011bad30270013027002375a604a002604a0046eb4c08c004c08c008dd698108009810801180f800980f801180e800980e801180d800980d8011bae30190013019002375a602e00260266ea80045858c054004c044dd50060a999807180400089919299980a180b80109924ca666020601660246ea80044c8c8c8c8c8c8c8c94ccc070c07c0084c8c9263010002300c00516301d001301d002375a60360026036004603200260320046eb4c05c004c04cdd50008b0b180a80098089baa00c16300f37540164a66601a6010601e6ea80044c8c8c8c94ccc054c06000852616375a602c002602c0046eb4c050004c040dd50008b12999806180398071baa0011323253330123015002149858dd6980980098079baa001162533300b3006300d375400226464a66602260280042649318028008b180900098071baa001162533300a3005300c3754002264646464a666024602a0042646493192999808180580089919299980b180c80109924c64a666026601c00226464a66603260380042649318070008b180d000980b1baa00215333013300d0011323232323232533301d3020002149858dd6980f000980f0011bad301c001301c002375a6034002602c6ea800858c050dd50008b180b80098099baa00315333010300a00115333014301337540062930b0b18089baa002300700316301300130130023011001300d37540022c4a666012600860166ea80044c8c8c8c94ccc044c05000852616375c602400260240046eb8c040004c030dd50008b1192999804980200089919299980798090010a4c2c6eb8c040004c030dd50010a999804980180089919299980798090010a4c2c6eb8c040004c030dd50010b18051baa001370e90011b8748000dc3a400844646600200200644a66601600229309919801801980780118019806800ab9a5738aae7555cf2ab9f5740ae855d11"
2684
+ };
2685
+ var mkPollManagerValidator = (params) => {
2686
+ return {
2687
+ type: pollManagerValidatorData.type,
2688
+ script: (0, import_lucid30.applyParamsToScript)(pollManagerValidatorData.cborHex, [
2689
+ castPollManagerParams(params)
2690
+ ])
2691
+ };
2692
+ };
2693
+ var mkPollManagerValidatorFromSP = (params) => {
2694
+ return {
2695
+ type: pollManagerValidatorData.type,
2696
+ script: (0, import_lucid30.applyParamsToScript)(pollManagerValidatorData.cborHex, [
2697
+ castPollManagerParams({
2698
+ govNFT: fromSystemParamsAsset(params.govNFT),
2699
+ pollToken: fromSystemParamsAsset(params.pollToken),
2700
+ upgradeToken: fromSystemParamsAsset(params.upgradeToken),
2701
+ indyAsset: fromSystemParamsAsset(params.indyAsset),
2702
+ govExecuteValHash: params.govExecuteValHash,
2703
+ pBiasTime: BigInt(params.pBiasTime),
2704
+ shardValHash: params.shardsValHash,
2705
+ treasuryValHash: params.treasuryValHash,
2706
+ initialIndyDistribution: BigInt(params.initialIndyDistribution)
2707
+ })
2708
+ ])
2709
+ };
2710
+ };
2711
+
2712
+ // src/types/indigo/execute.ts
2713
+ var import_lucid31 = require("@lucid-evolution/lucid");
2714
+ var ExecuteParamsSchema = import_lucid31.Data.Object({
2715
+ govNFT: AssetClassSchema,
2716
+ upgradeToken: AssetClassSchema,
2717
+ iAssetToken: AssetClassSchema,
2718
+ stabilityPoolToken: AssetClassSchema,
2719
+ versionRecordToken: AssetClassSchema,
2720
+ cdpValHash: import_lucid31.Data.Bytes(),
2721
+ sPoolValHash: import_lucid31.Data.Bytes(),
2722
+ versionRegistryValHash: import_lucid31.Data.Bytes(),
2723
+ treasuryValHash: import_lucid31.Data.Bytes(),
2724
+ indyAsset: AssetClassSchema
2725
+ });
2726
+ var ExecuteParams = ExecuteParamsSchema;
2727
+ function castExecuteParams(params) {
2728
+ return import_lucid31.Data.castTo(params, ExecuteParams);
2729
+ }
2730
+
2731
+ // src/types/indigo/lrp.ts
2732
+ var import_lucid32 = require("@lucid-evolution/lucid");
2733
+ var LRPParamsSchema = import_lucid32.Data.Object({
2734
+ versionRecordToken: AssetClassSchema,
2735
+ iassetNft: AssetClassSchema,
2736
+ iassetPolicyId: import_lucid32.Data.Bytes(),
2737
+ minRedemptionLovelacesAmt: import_lucid32.Data.Integer()
2738
+ });
2739
+ var LRPParams = LRPParamsSchema;
2740
+ var LRPDatumSchema = import_lucid32.Data.Object({
2741
+ owner: import_lucid32.Data.Bytes(),
2742
+ iasset: import_lucid32.Data.Bytes(),
2743
+ maxPrice: OnChainDecimalSchema,
2744
+ lovelacesToSpend: import_lucid32.Data.Integer()
2745
+ });
2746
+ var LRPDatum = LRPDatumSchema;
2747
+ var LRPRedeemerSchema = import_lucid32.Data.Enum([
2748
+ import_lucid32.Data.Object({ Redeem: import_lucid32.Data.Object({ continuingOutputIdx: import_lucid32.Data.Integer() }) }),
2749
+ import_lucid32.Data.Object({
2750
+ RedeemAuxiliary: import_lucid32.Data.Object({
2751
+ continuingOutputIdx: import_lucid32.Data.Integer(),
2752
+ mainRedeemOutRef: OutputReferenceSchema,
2753
+ asset: import_lucid32.Data.Bytes(),
2754
+ assetPrice: OnChainDecimalSchema,
2755
+ redemptionReimbursementPercentage: OnChainDecimalSchema
2756
+ })
2757
+ }),
2758
+ import_lucid32.Data.Literal("Cancel"),
2759
+ import_lucid32.Data.Literal("UpgradeVersion")
2760
+ ]);
2761
+ var LRPRedeemer = LRPRedeemerSchema;
2762
+ function parseLrpDatum(datum) {
2763
+ return import_lucid32.Data.from(datum, LRPDatum);
2764
+ }
2765
+ function serialiseLrpDatum(datum) {
2766
+ return import_lucid32.Data.to(datum, LRPDatum);
2767
+ }
2768
+ function serialiseLrpRedeemer(redeemer) {
2769
+ return import_lucid32.Data.to(redeemer, LRPRedeemer);
2770
+ }
2771
+ function castLrpParams(params) {
2772
+ return import_lucid32.Data.castTo(params, LRPParams);
2773
+ }
2774
+
2775
+ // src/contracts/lrp.ts
2776
+ var import_lucid34 = require("@lucid-evolution/lucid");
2777
+ var import_ts_pattern5 = require("ts-pattern");
2778
+ var import_Array2 = require("fp-ts/lib/Array");
2779
+ var import_Array3 = require("fp-ts/lib/Array");
2780
+
2781
+ // src/helpers/price-oracle-helpers.ts
2782
+ var import_lucid33 = require("@lucid-evolution/lucid");
2783
+ function oracleExpirationAwareValidity(currentSlot, biasTime, oracleExpiration, network) {
2784
+ const validateFrom = (0, import_lucid33.slotToUnixTime)(network, currentSlot - 1);
2785
+ const defaultValidateTo = validateFrom + biasTime;
2786
+ const cappedValidateTo = (0, import_lucid33.slotToUnixTime)(
2787
+ network,
2788
+ (0, import_lucid33.unixTimeToSlot)(network, oracleExpiration) - 1
2789
+ );
2790
+ const isOracleActuallyExpired = cappedValidateTo <= validateFrom;
2791
+ return {
2792
+ validFrom: validateFrom,
2793
+ validTo: isOracleActuallyExpired ? defaultValidateTo : Math.min(defaultValidateTo, cappedValidateTo)
2794
+ };
2795
+ }
2796
+
2797
+ // src/contracts/lrp.ts
2798
+ var MIN_UTXO_COLLATERAL_AMT = 2000000n;
2799
+ async function openLrp(assetTokenName, lovelacesAmt, maxPrice, lucid, lrpScriptHash, network, lrpStakeCredential) {
2800
+ const [ownPkh, _] = await addrDetails(lucid);
2801
+ const newDatum = {
2802
+ owner: ownPkh.hash,
2803
+ iasset: assetTokenName,
2804
+ maxPrice,
2805
+ lovelacesToSpend: lovelacesAmt
2806
+ };
2807
+ return lucid.newTx().pay.ToContract(
2808
+ createScriptAddress(network, lrpScriptHash, lrpStakeCredential),
2809
+ {
2810
+ kind: "inline",
2811
+ value: serialiseLrpDatum(newDatum)
2812
+ },
2813
+ { lovelace: lovelacesAmt + MIN_UTXO_COLLATERAL_AMT }
2814
+ );
2815
+ }
2816
+ async function cancelLrp(lrpOutRef, lrpRefScriptOutRef, lucid) {
2817
+ const ownAddr = await lucid.wallet().address();
2818
+ const lrpScriptRefUtxo = matchSingle(
2819
+ await lucid.utxosByOutRef([lrpRefScriptOutRef]),
2820
+ (_) => new Error("Expected a single LRP Ref Script UTXO")
2821
+ );
2822
+ const lrpUtxo = matchSingle(
2823
+ await lucid.utxosByOutRef([lrpOutRef]),
2824
+ (_) => new Error("Expected a single LRP UTXO.")
2825
+ );
2826
+ return lucid.newTx().readFrom([lrpScriptRefUtxo]).collectFrom([lrpUtxo], serialiseLrpRedeemer("Cancel")).addSigner(ownAddr);
2827
+ }
2828
+ async function redeemLrp(redemptionLrpsData, lrpRefScriptOutRef, priceOracleOutRef, iassetOutRef, lucid, lrpParams, priceOracleParams, network) {
2829
+ const lrpScriptRefUtxo = matchSingle(
2830
+ await lucid.utxosByOutRef([lrpRefScriptOutRef]),
2831
+ (_2) => new Error("Expected a single LRP Ref Script UTXO")
2832
+ );
2833
+ const priceOracleUtxo = matchSingle(
2834
+ await lucid.utxosByOutRef([priceOracleOutRef]),
2835
+ (_2) => new Error("Expected a single price oracle UTXO")
2836
+ );
2837
+ const iassetUtxo = matchSingle(
2838
+ await lucid.utxosByOutRef([iassetOutRef]),
2839
+ (_2) => new Error("Expected a single IAsset UTXO")
2840
+ );
2841
+ const iassetDatum = parseIAssetDatum(getInlineDatumOrThrow(iassetUtxo));
2842
+ const [lrpsToRedeemOutRefs, lrpRedemptionIAssetAmt] = (0, import_Array2.unzip)(redemptionLrpsData);
2843
+ const priceOracleDatum = parsePriceOracleDatum(
2844
+ getInlineDatumOrThrow(priceOracleUtxo)
2845
+ );
2846
+ const redemptionLrps = await lucid.utxosByOutRef(lrpsToRedeemOutRefs).then((val) => (0, import_Array2.zip)(val, lrpRedemptionIAssetAmt));
2847
+ const [[mainLrpUtxo, mainLrpRedemptionIAssetAmt], _] = (0, import_ts_pattern5.match)(redemptionLrps).with(
2848
+ [import_ts_pattern5.P._, ...import_ts_pattern5.P.array()],
2849
+ ([[firstLrp, firstLrpIAssetAmt], ...rest]) => [[firstLrp, firstLrpIAssetAmt], rest]
2850
+ ).otherwise(() => {
2851
+ throw new Error("Expects at least 1 UTXO to redeem.");
2852
+ });
2853
+ const mainLrpDatum = parseLrpDatum(getInlineDatumOrThrow(mainLrpUtxo));
2854
+ const tx = (0, import_Array3.reduceWithIndex)(
2855
+ lucid.newTx(),
2856
+ (idx, acc, [lrpUtxo, redeemIAssetAmt]) => {
2857
+ const lovelacesForRedemption = ocdMul(
2858
+ {
2859
+ getOnChainInt: mainLrpRedemptionIAssetAmt
2860
+ },
2861
+ priceOracleDatum.price
2862
+ ).getOnChainInt;
2863
+ const reimburstmentLovelaces = calculateFeeFromPercentage2(
2864
+ iassetDatum.redemptionReimbursementPercentage,
2865
+ lovelacesForRedemption
2866
+ );
2867
+ const lrpDatum = parseLrpDatum(getInlineDatumOrThrow(lrpUtxo));
2868
+ return acc.collectFrom(
2869
+ [lrpUtxo],
2870
+ serialiseLrpRedeemer(
2871
+ idx === 0 ? { Redeem: { continuingOutputIdx: 0n } } : {
2872
+ RedeemAuxiliary: {
2873
+ continuingOutputIdx: BigInt(idx),
2874
+ mainRedeemOutRef: {
2875
+ txHash: { hash: mainLrpUtxo.txHash },
2876
+ outputIndex: BigInt(mainLrpUtxo.outputIndex)
2877
+ },
2878
+ asset: mainLrpDatum.iasset,
2879
+ assetPrice: priceOracleDatum.price,
2880
+ redemptionReimbursementPercentage: iassetDatum.redemptionReimbursementPercentage
2881
+ }
2882
+ }
2883
+ )
2884
+ ).pay.ToContract(
2885
+ lrpUtxo.address,
2886
+ {
2887
+ kind: "inline",
2888
+ value: serialiseLrpDatum({
2889
+ ...lrpDatum,
2890
+ lovelacesToSpend: lrpDatum.lovelacesToSpend - lovelacesForRedemption
2891
+ })
2892
+ },
2893
+ (0, import_lucid34.addAssets)(
2894
+ lrpUtxo.assets,
2895
+ mkLovelacesOf(-(lovelacesForRedemption - reimburstmentLovelaces)),
2896
+ mkAssetsOf(
2897
+ {
2898
+ currencySymbol: lrpParams.iassetPolicyId,
2899
+ tokenName: mainLrpDatum.iasset
2900
+ },
2901
+ redeemIAssetAmt
2902
+ )
2903
+ )
2904
+ );
2905
+ }
2906
+ )(redemptionLrps);
2907
+ const txValidity = oracleExpirationAwareValidity(
2908
+ lucid.currentSlot(),
2909
+ Number(priceOracleParams.biasTime),
2910
+ Number(priceOracleDatum.expiration),
2911
+ network
2912
+ );
2913
+ return lucid.newTx().validTo(txValidity.validTo).readFrom([lrpScriptRefUtxo]).readFrom([iassetUtxo, priceOracleUtxo]).compose(tx);
2914
+ }
2915
+
2916
+ // src/scripts/lrp-validator.ts
2917
+ var import_lucid35 = require("@lucid-evolution/lucid");
2918
+ var lrpValidatorData = {
2919
+ type: "PlutusV2",
2920
+ description: "Generated by Aiken",
2921
+ cborHex: "5917845917810100003232323232323232322223232323232322533300b323232533300e3008301137540022646464646464646464646464646464646464646464646464646464a666052604a0342646464646464646464646464a666074607a004264a66606c606060726ea80044c8c94ccc0f4c1000084c8c8c8c94ccc0f0c0e0c0fcdd50008991919299981f981d98211baa00113253330403302249110496e636f727265637420694173736574003371e6eb8c0acc110dd50049bae30253044375407c264a666082666444646604e921124861766520746f207573652072656465656d005333045301f3048375460906466600200203697bdb180103d87980000101a000222533304d002100113330030033050002323232533304b3375e606c609e6ea8c0d8c13cdd5181818279baa00300a1323232533304e304a001132533304f533304f00614a2266609e94528251153305149012343616e20757365206f6e6c7920612073696e676c652052656465656d20706572205478001613376066609e94530103d87a80004c0103d8798000374c6601600a0026eb4c154c148dd50018a99982718240008991919191919299982a299982a19982a19b8f375c60b6008024941288a51153330543330543375e004036941288a5113330543375e022002941288a9982b2492452656465656d417578207573657320696e636f727265637420617373657420737461747300161337606660a801698103d87a80004c0103d8798000374c6602001400a60b460b600460b200260b200260b060b00046eb4c158004c148dd50018a998282492d4578706563746564206f6e6c792052656465656d2072656465656d65727320666f72204c525020696e7075747300163050375400460880026604c606c609e6ea800c0644010dd59827001981198261baa304c002304f00214a2266608a9452825122323300100100322533304d00113304e337606ea000ccc125264c0103d87980004bd6f7b6300991919192999826181e299982619b8800700214c103d87980001533304c3371000400e2980103d87b800014c103d87a8000133052337606ea001ccc135264c103d87980000051533304c3370e00e004264a66609a609260a06ea80044cc14ccdd81ba80083304e32498c150c144dd5000a60103d8798000004100453304e49126436f6e74696e75696e67206f75747075747320646f75626c6520736174697366616374696f6e0016133052337606ea0008cc134005300103d87980003300600600332498c13c00cdd6982680118288011827800981618229baa004375c6058608a6ea8028c004c114dd50050999999981082000280100201f804180098229baa00a14a0460906092609260926092609260926092609260920022940c118c10cdd50008b1980e00780a981418209baa302230413754002608660806ea800458cc0600400b4c0580e0c94ccc0e8c0d8c0f4dd500089820981f1baa001132533303b32533303c3036303f3754002266e24dd6981098201baa002375a608660806ea800454cc0f924124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e676500163026303f37546040607e6ea802854cc0f52401174f7261636c652063616e27742062652065787069726564001613026303f37540026464004a666076606e607c6ea80044c8c8c8c94ccc110c11c0084c926303a00316375a608a002608a0046086002607e6ea800458c048c078c0f8dd5180f981f1baa325333040001153303d49012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001615333040304300113042001153303d49012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001633301300d3041303e37546082607c6ea8005300103d8798000301e303d375400464a666072606a60786ea80084c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc168c1740084c8c8c8c8c8c8c8c8c8c8c8c926325333061305d001132325333068306b002149858dd7183480098329baa00d15333061305b001153330663065375401a2930b0b18319baa00c305a00f30590103058011305701230560133055014305401530530163052017301e018325333056305200113232533305d3060002132498c14c00458c178004c168dd500d0a99982b182800089919299982e983000109924ca6660b060a860b66ea80044c8c94ccc17cc1880084c9263022001163060001305c37540022c2c60bc00260b46ea806858c160dd500c8b182d800982d80119299982c182b8008a9998299826982b0008a5115333053304f305600114a02c2c6ea8c164004c164008c15c004c15c008c154004c154008c14c004c14c008c144004c144008c13c004c13c008c134004c134008c12c004c12c008c124004c124008c11c004c11c008c114004c114008c10c004c10c008dd71820800981e9baa00216253330393035303c3754002264646464a666084608a0042930b1bae30430013043002375c6082002607a6ea80045858c0f8004c0e8dd50008b1806980c981c9baa301a303937540022c607600266601800c6030606e6ea80c9300103d879800037566072607460740046070002607060706070607060700046eb0c0d8004c0d8008dd6181a000981a0011bac3032001302e375403c6eb4c0c0c0b4dd50130a999814981180d099191919191919191919191919191919299981c981a981e1baa0011323232533303c3038303f375400226464a66607c607460826ea80044c8c94ccc114c1200084c94ccc104c0f4c110dd500089929998211981224810c57726f6e6720696173736574003371e0286eb8c09cc118dd50200a999821198122491e52656465656d207574786f2066726f6d2077726f6e672061646472657373003375e605a608c6ea8c0b4c118dd5181398231baa006302d30463754010266666660440820120020100800240222940528182418229baa001163301e00b01616375a608c00260846ea800458cc06004401cc10cc100dd50008b1980c0040079812981f1baa301f303e37540026080607a6ea800458cc0540140a8c04c0d4dd5981e981f181f181f181f181f181f181f0011bac303c001303c303c00237586074002606c6ea8098c0e0c0e4008c0dc004c0dc008dd7181a800981a801181980098198011bad3031001302d375404c264a66605460460362646601a92011754582069736e74207369676e6564206279206f776e657200330023758606460666066606660666066606660666066605e6ea807cdd7180b18179baa02930060281333232322232323232325333034303030373754002264a66606a605e60706ea80044c8c8c94ccc0f4c1000084c8c8c94ccc0ecc0dcc0f8dd500089980e99807998209ba937309201084d697373696e6720003304137526e60038cc104dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003301230103302400948900375c6084607e6ea800454cc0f4cc03ccc104dd49b98491084d697373696e6720003304137526e60038cc104dd49b9849010d20757067726164652070617468004bd70249001632533303b3035303e3754002298103d87a8000130233304137526eb8c0fcc8cdd81821800982198220009bac3042303f375400297ae0323300100137566040607e6ea800c894ccc1040045300103d87a800013232533303e3371e6eb8c1040080244c098cc110dd399822182080119822182100125eb812f5c0266008008002608a0046086002a666072606a60786ea80044c8c8c8c94ccc108c1140084c926323300100100222533304400114984c8cc00c00cc120008c8c8dd718228011bae30430013046001163756608600260860046eb4c104004c0f4dd50008b1808180e181e1baa301d303c37540022c607c00266601e00a01098103d8798000375c607860726ea800458c07cc0e0dd5180f981c1baa301930383754607660706ea800458cc040dd6181d0020129bab3039303a303a303a00237586070002607000260666ea808c88dcc991919980080080224410022253330370021001132333004004303b0035333033302f371a00426e600044cdc500119b8a00537300026e64dd7181c8011b98001300100122533303100114bd700998191817981980099801001181a000a49034c5250003015302e375405244646600200200644a66606400229404c94ccc0b8cdc79bae303500200414a2266006006002606a0024a666052604460586ea80044c0c0c0b4dd50008a99815a481134e6f7420616e20696e6c696e6520646174756d0016222323301500423002301130303754002a666054604c605a6ea800448c094ccc044dd5980818179baa001375c602c605e6ea800cdd7180818179baa00312300533301137566020605e6ea8004dd7180b18179baa003375c6020605e6ea800cdc4240004464a666050604860566ea80044c0bcc0b0dd50008a99815248117436f756c64206e6f742066696e642072656465656d6572001632323300100100322533302f00114c0103d87a80001323232533302d3375e00c60600062602a6606600297ae01330050050023030002303300230310013374a90011981680125eb8094ccc094c084c0a0dd5000899191919191919192999819181a80109924c60500062c6eb4c0cc004c0cc008c0c4004c0c4008dd7181780098178011bae302d001302937540022c44646600200200644a6660580022980103d87a80001323253330293375e6028605a6ea80080144c044cc0bc0092f5c02660080080026060004605c0026002002444a6660520042980103d87a800013232533302630220031300e3302c0024bd70099980280280099b8000348004c0b400cc0ac0088888888c8c8c94ccc0a8cc03124011e48617320746f2072656465656d206174206c6561737420746865206d696e00337126eb4c02cc0b8dd50050010a99981519806249124d617820707269636520657863656564656400337126eb4c054c0b8dd50029bad3015302e3754601c605c6ea801854ccc0a8cc0312411b52656465656d696e67206d6f7265207468616e20616c6c6f77656400337120046eb4c02cc0b8dd500309980624811757726f6e6720636f6e74696e75696e67206f75747075740033332222323300100133019005533302f302b30323754008264466ebcc070c0d4dd5180e181a9baa001002303630333754008264466ebcc070c0d4dd5000801181b18199baa00422533303500114a0264a66606264a66606466ebcc058c0d8dd5000803099299981c0008a5115333038303b001132323253330363371e6eb8c0f400d22100153330363371e00291010015333036303230393754980103d87a800015333036337129000001099b89002482026fb808528099b89480000085280a50375c6078607a0046eb4c0ecc0f0c0f0004dd6181d0008a503233001001323330010013756603260706ea800cc8cc004004020894ccc0ec00452f5bded8c02646607a66ec0dd49bae303a001374c64660020026eacc0f0008894ccc0f800452f5bded8c02646608066ec0dd49bae303d001375066e052000375a607c002660060066084004608000266006006607e004607a002444a6660760042002264666008008607e0066666604a0046eb8c0e8004dd5981d80091119299981d98140008a60103d87a80001302333041374c00297ae0323330010010030022225333042002100113233300400430460033333302d002375c60820026eb4c108004888c94ccc108c0f80045300103d87a80001302a33048375000297ae0337000040020546088004046607a00444a666072002297ae0132333222323300100100322533303f001100313233041374e660826ea4018cc104dd49bae303e0013304137506eb4c0fc0052f5c066006006608600460820026eb8c0e0004dd5981c80099801801981e801181d8008a50303800214a226600600600260700026606001097ae03374a900119818003a5eb80cdd2a400866060646460286606460660046606460660026606460666068002660646ea0cdc09bad300d3030375401000897ae03033001302e375400c97ae033330113333011330133756601e605c6ea8c03cc0b8dd5004a44100488100488100001375c601c605c6ea8028dd7180798171baa00600314a0294052819b803370266601e6eacc038c0b4dd5180718169baa00848810048810000153330293371200290000a400026eb4c050c0b4dd51808998179ba83370666e08dd6980a18169baa3300c30113302f375000297ae00034820225e8dd6980a18169baa30113302f375066e0920c8014820225e92f5c097ae0375a602660586ea8cc02cc040cc0b8dd4000a5eb8000ccdc09998069bab300c302b375400a6eb8c02cc0acdd50039bae300c302b375400666601a6eacc030c0acdd5180618159baa006375c601660566ea801cdd7180618159baa003230273028302830280012253330203330200014a094454cc0880084004400488c01ccc094dd419b83337046eb4c028c08cdd50011bad300a30233754002904044bd25eb808c090c094c0940048c08cc090004888c94ccc078c060c084dd50008a400026eb4c094c088dd500099299980f180c18109baa00114c103d87a8000132330010013756604c60466ea8008894ccc094004530103d87a8000132323253330233371e00e6eb8c09800c4c02ccc0a4dd4000a5eb804cc014014008dd698130011814801181380099198008008021129998120008a6103d87a8000132323253330223371e00e6eb8c09400c4c028cc0a0dd3000a5eb804cc014014008dd59812801181400118130009111299980e980c8008802099999805802001991900119198008008011129998128008a4c264a66604c002293099192999811980f98131baa3300f375c604c60540086eb8c0980084cc014014cc0a400800454cc0952401326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016302a0023028001302800133023337606ea4008dd4000a5eb7bdb180888c94ccc084c038004530103d87a80001300933027374c00297ae03333300f001005004222325333024302000114c103d87a80001300c3302a375000297ae0337000020040180126e95200022323300100100322533302000114bd6f7b630099191919299980f99b8f0070021003133025337606ea4008dd3000998030030019bab3022003375c60400046048004604400244646600200200644a66603e002297ae013232533301c300500213302200233004004001133004004001302300230210012301d001225333016337200040022980103d8798000153330163371e0040022980103d87a800014c103d87b80002533301900114a2294088888c8cc004004018894ccc0780044cc07ccdd81ba9006374c00a97adef6c60132323232533301d300d3300700a002133023337606ea4028dd30048028a99980e99b8f00a002132533301e301a3021375400226604866ec0dd4805981298111baa001004100433300800a009001133023337606ea4008dd3000998030030019bab3020003375c603c0046044004604000244444646600200200c44a66603a00226603c66ec0dd48031ba80054bd6f7b630099191919299980e18061980380500109981119bb037520146ea002401454ccc070cdc7805001099299980e980c98101baa001133023337606ea402cc090c084dd5000802080219980400500480089981119bb037520046ea0004cc01801800cdd6980f8019bae301d0023021002301f001375e98103d879800030123754018602a60246ea800458c050c054008c04c004c03cdd50008a4c26cac600200c464a666014600c00226464a66602260280042930b1bad3012001300e37540042a6660146008002264646464646464646464a666032603800426464649318088019808002299980a1808180b9baa007132323232533301d30200021324994ccc060c050c06cdd500189919299980f98110010a4c2c6eb8c080004c070dd50018b0b1bad301e001301e002301c0013018375400e2c2c60340026034004603000260300046eb8c058004c058008c050004c050008dd6980900098071baa0021533300a30030011533300f300e37540042930b0a99980519b874801800454ccc03cc038dd50010a4c2c2c60186ea8004dc3a40086e1d20022533300630023009375400226464a66601a60200042930b1bad300e001300a37540022c6e1d20005734ae6d5ce2ab9d5573caae7d5d02ba15745"
2922
+ };
2923
+ var mkLrpValidator = (params) => {
2924
+ return {
2925
+ type: lrpValidatorData.type,
2926
+ script: (0, import_lucid35.applyParamsToScript)(lrpValidatorData.cborHex, [
2927
+ castLrpParams(params)
2928
+ ])
2929
+ };
2930
+ };
2931
+
2932
+ // src/helpers/helper-txs.ts
2933
+ var import_lucid36 = require("@lucid-evolution/lucid");
2934
+
2935
+ // src/scripts/always-fail-validator.ts
2936
+ var alwaysFailValidator = {
2937
+ type: "PlutusV2",
2938
+ script: "587f010000323232323232232253330044a029309b2b19299980199b874800000454ccc018c014dd50010a4c2c2a66600666e1d2002001132325333008300a002149858dd7180400098029baa002153330033370e900200089919299980418050010a4c2c6010002600a6ea800858c00cdd5000ab9a5573aaae7955cfaba157441"
2939
+ };
2940
+
2941
+ // src/helpers/helper-txs.ts
2942
+ async function runCreateScriptRefTx(lucid, scriptRefValidator, network) {
2943
+ const scriptAddr = (0, import_lucid36.validatorToAddress)(network, alwaysFailValidator);
2944
+ const txHash = await lucid.newTx().pay.ToAddressWithData(scriptAddr, void 0, {}, scriptRefValidator).complete().then((tx) => tx.sign.withWallet().complete()).then((tx) => tx.submit());
2945
+ await lucid.awaitTx(txHash);
2946
+ return { txHash, outputIndex: 0 };
2947
+ }
1041
2948
  // Annotate the CommonJS export names for ESM import in node:
1042
2949
  0 && (module.exports = {
2950
+ AccountAction,
2951
+ AccountActionSchema,
2952
+ AccountContent,
2953
+ AccountContentSchema,
2954
+ ActionReturnDatum,
2955
+ ActionReturnDatumSchema,
2956
+ Address,
2957
+ AddressSchema,
2958
+ AssetClassSchema,
2959
+ CDPContentSchema,
1043
2960
  CDPContract,
1044
- CDPCreatorContract,
1045
- CDPHelpers,
2961
+ CDPDatumSchema,
2962
+ CDPFeesSchema,
1046
2963
  CollectorContract,
2964
+ Credential,
2965
+ CredentialSchema,
2966
+ EpochToScaleToSum,
2967
+ EpochToScaleToSumSchema,
2968
+ ExecuteParams,
2969
+ FeedInterestOracleRedeemerSchema,
1047
2970
  GovContract,
2971
+ GovParams,
2972
+ IAssetContentSchema,
1048
2973
  IAssetHelpers,
1049
2974
  InterestOracleContract,
1050
- PriceOracleContract,
2975
+ InterestOracleDatumSchema,
2976
+ InterestOracleParamsSchema,
2977
+ LRPDatumSchema,
2978
+ LRPParamsSchema,
2979
+ LRPRedeemerSchema,
2980
+ ONE_SECOND,
2981
+ OracleAssetNftSchema,
2982
+ OutputReferenceSchema,
2983
+ PollManagerParams,
2984
+ PollShardParams,
2985
+ PriceOracleDatumSchema,
2986
+ PriceOracleParamsSchema,
2987
+ SPInteger,
2988
+ SPIntegerSchema,
2989
+ SnapshotEpochToScaleToSumContent,
2990
+ SnapshotEpochToScaleToSumContentSchema,
2991
+ StabilityPoolContent,
2992
+ StabilityPoolContentSchema,
2993
+ StabilityPoolContract,
2994
+ StabilityPoolDatum,
2995
+ StabilityPoolDatumSchema,
2996
+ StabilityPoolParams,
2997
+ StabilityPoolRedeemer,
2998
+ StabilityPoolRedeemerSchema,
2999
+ StabilityPoolSnapshot,
3000
+ StakingContract,
1051
3001
  TreasuryContract,
1052
- _cdpCreatorValidator,
3002
+ VerificationKeyHashSchema,
1053
3003
  _cdpValidator,
1054
3004
  _collectorValidator,
1055
- _interestOracleValidator,
1056
3005
  _treasuryValidator,
1057
3006
  addrDetails,
3007
+ addressFromBech32,
3008
+ addressToBech32,
1058
3009
  balance,
1059
3010
  calculateFeeFromPercentage,
3011
+ cancelLrp,
3012
+ castExecuteParams,
3013
+ castGovParams,
3014
+ castInterestOracleParams,
3015
+ castLrpParams,
3016
+ castPollManagerParams,
3017
+ castPollShardParams,
3018
+ castPriceOracleParams,
3019
+ castStabilityPoolParams,
3020
+ cdpCreatorValidator,
3021
+ createScriptAddress,
3022
+ fromSPInteger,
3023
+ fromSystemParamsAsset,
3024
+ getInlineDatumOrThrow,
1060
3025
  getRandomElement,
1061
3026
  loadSystemParamsFromFile,
1062
3027
  loadSystemParamsFromUrl,
3028
+ matchSingle,
3029
+ mkCDPCreatorValidator,
3030
+ mkCDPCreatorValidatorFromSP,
3031
+ mkInterestOracleValidator,
3032
+ mkLrpValidator,
3033
+ mkPollManagerValidator,
3034
+ mkPollManagerValidatorFromSP,
3035
+ mkPollShardValidator,
3036
+ mkPollShardValidatorFromSP,
3037
+ mkSPInteger,
1063
3038
  oneDay,
1064
3039
  oneHour,
3040
+ oneShotMintTx,
1065
3041
  oneYear,
1066
- scriptRef
3042
+ openLrp,
3043
+ parseAccountDatum,
3044
+ parseCDPDatum,
3045
+ parseGovDatum,
3046
+ parseIAssetDatum,
3047
+ parseInterestOracleDatum,
3048
+ parseLrpDatum,
3049
+ parsePriceOracleDatum,
3050
+ parseSnapshotEpochToScaleToSumDatum,
3051
+ parseStabilityPoolDatum,
3052
+ redeemLrp,
3053
+ runCreateScriptRefTx,
3054
+ runOneShotMintTx,
3055
+ scriptRef,
3056
+ serialiseCDPDatum,
3057
+ serialiseFeedInterestOracleRedeemer,
3058
+ serialiseGovDatum,
3059
+ serialiseIAssetDatum,
3060
+ serialiseInterestOracleDatum,
3061
+ serialiseLrpDatum,
3062
+ serialiseLrpRedeemer,
3063
+ serialisePriceOracleDatum,
3064
+ serialiseStabilityPoolDatum,
3065
+ serialiseStabilityPoolRedeemer,
3066
+ spAdd,
3067
+ spDiv,
3068
+ spMul,
3069
+ spSub,
3070
+ toSystemParamsAsset
1067
3071
  });