@indigo-labs/indigo-sdk 0.5.5 → 0.5.6

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 (204) hide show
  1. package/package.json +11 -1
  2. package/.claude/settings.local.json +0 -7
  3. package/.github/workflows/ci.yml +0 -66
  4. package/.husky/pre-commit +0 -1
  5. package/.nvmrc +0 -1
  6. package/.prettierignore +0 -1
  7. package/.prettierrc +0 -6
  8. package/eslint.config.mjs +0 -42
  9. package/scripts/bench.sh +0 -62
  10. package/scripts/run-repeat.sh +0 -22
  11. package/src/contracts/cdp/helpers.ts +0 -173
  12. package/src/contracts/cdp/scripts.ts +0 -70
  13. package/src/contracts/cdp/transactions.ts +0 -1584
  14. package/src/contracts/cdp/types-new.ts +0 -277
  15. package/src/contracts/cdp/types.ts +0 -43
  16. package/src/contracts/cdp-creator/queries.ts +0 -30
  17. package/src/contracts/cdp-creator/scripts.ts +0 -45
  18. package/src/contracts/cdp-creator/types-new.ts +0 -50
  19. package/src/contracts/cdp-creator/types.ts +0 -24
  20. package/src/contracts/collector/scripts.ts +0 -32
  21. package/src/contracts/collector/transactions.ts +0 -50
  22. package/src/contracts/collector/types-new.ts +0 -17
  23. package/src/contracts/execute/scripts.ts +0 -57
  24. package/src/contracts/execute/types-new.ts +0 -44
  25. package/src/contracts/execute/types.ts +0 -24
  26. package/src/contracts/gov/helpers.ts +0 -351
  27. package/src/contracts/gov/scripts.ts +0 -41
  28. package/src/contracts/gov/transactions.ts +0 -1607
  29. package/src/contracts/gov/types-new.ts +0 -268
  30. package/src/contracts/gov/types.ts +0 -22
  31. package/src/contracts/iasset/helpers.ts +0 -170
  32. package/src/contracts/iasset/queries.ts +0 -102
  33. package/src/contracts/iasset/scripts.ts +0 -38
  34. package/src/contracts/iasset/types.ts +0 -154
  35. package/src/contracts/initialize/actions.ts +0 -789
  36. package/src/contracts/initialize/helpers.ts +0 -616
  37. package/src/contracts/initialize/types.ts +0 -116
  38. package/src/contracts/interest-collection/helpers.ts +0 -19
  39. package/src/contracts/interest-collection/queries.ts +0 -66
  40. package/src/contracts/interest-collection/scripts.ts +0 -44
  41. package/src/contracts/interest-collection/transactions.ts +0 -433
  42. package/src/contracts/interest-collection/types-new.ts +0 -50
  43. package/src/contracts/interest-collection/types.ts +0 -26
  44. package/src/contracts/interest-oracle/helpers.ts +0 -61
  45. package/src/contracts/interest-oracle/scripts.ts +0 -18
  46. package/src/contracts/interest-oracle/transactions.ts +0 -151
  47. package/src/contracts/interest-oracle/types-new.ts +0 -32
  48. package/src/contracts/interest-oracle/types.ts +0 -16
  49. package/src/contracts/one-shot/scripts.ts +0 -12
  50. package/src/contracts/one-shot/transactions.ts +0 -66
  51. package/src/contracts/one-shot/types.ts +0 -22
  52. package/src/contracts/poll/helpers.ts +0 -37
  53. package/src/contracts/poll/scripts.ts +0 -71
  54. package/src/contracts/poll/types-poll-manager.ts +0 -20
  55. package/src/contracts/poll/types-poll-new.ts +0 -196
  56. package/src/contracts/poll/types-poll-shard.ts +0 -16
  57. package/src/contracts/price-oracle/helpers.ts +0 -30
  58. package/src/contracts/price-oracle/scripts.ts +0 -18
  59. package/src/contracts/price-oracle/transactions.ts +0 -115
  60. package/src/contracts/price-oracle/types-new.ts +0 -50
  61. package/src/contracts/price-oracle/types.ts +0 -16
  62. package/src/contracts/pyth-feed/helpers.ts +0 -82
  63. package/src/contracts/pyth-feed/scripts.ts +0 -15
  64. package/src/contracts/pyth-feed/types.ts +0 -181
  65. package/src/contracts/rob/helpers.ts +0 -666
  66. package/src/contracts/rob/scripts.ts +0 -35
  67. package/src/contracts/rob/transactions.ts +0 -423
  68. package/src/contracts/rob/types-new.ts +0 -128
  69. package/src/contracts/rob/types.ts +0 -16
  70. package/src/contracts/rob-leverage/helpers.ts +0 -422
  71. package/src/contracts/rob-leverage/transactions.ts +0 -368
  72. package/src/contracts/stability-pool/helpers.ts +0 -798
  73. package/src/contracts/stability-pool/queries.ts +0 -132
  74. package/src/contracts/stability-pool/scripts.ts +0 -51
  75. package/src/contracts/stability-pool/transactions.ts +0 -921
  76. package/src/contracts/stability-pool/types-new.ts +0 -385
  77. package/src/contracts/stability-pool/types.ts +0 -25
  78. package/src/contracts/stableswap/helpers.ts +0 -507
  79. package/src/contracts/stableswap/scripts.ts +0 -37
  80. package/src/contracts/stableswap/transactions.ts +0 -475
  81. package/src/contracts/stableswap/types-new.ts +0 -131
  82. package/src/contracts/stableswap/types.ts +0 -17
  83. package/src/contracts/staking/helpers.ts +0 -136
  84. package/src/contracts/staking/scripts.ts +0 -41
  85. package/src/contracts/staking/transactions.ts +0 -349
  86. package/src/contracts/staking/types-new.ts +0 -137
  87. package/src/contracts/staking/types.ts +0 -17
  88. package/src/contracts/treasury/helpers.ts +0 -21
  89. package/src/contracts/treasury/queries.ts +0 -100
  90. package/src/contracts/treasury/scripts.ts +0 -27
  91. package/src/contracts/treasury/transactions.ts +0 -334
  92. package/src/contracts/treasury/types-new.ts +0 -69
  93. package/src/contracts/treasury/types.ts +0 -14
  94. package/src/contracts/version-registry/scripts.ts +0 -29
  95. package/src/contracts/version-registry/types-new.ts +0 -18
  96. package/src/contracts/version-registry/types.ts +0 -17
  97. package/src/index.ts +0 -99
  98. package/src/scripts/always-fail-validator.ts +0 -7
  99. package/src/scripts/auth-token-policy.ts +0 -24
  100. package/src/scripts/iasset-policy.ts +0 -23
  101. package/src/types/evolution-schema-options.ts +0 -16
  102. package/src/types/generic.ts +0 -52
  103. package/src/types/multisig.ts +0 -48
  104. package/src/types/on-chain-decimal.ts +0 -57
  105. package/src/types/rational.ts +0 -76
  106. package/src/types/system-params.ts +0 -463
  107. package/src/utils/array-utils.ts +0 -108
  108. package/src/utils/bigint-utils.ts +0 -35
  109. package/src/utils/helper-txs.ts +0 -31
  110. package/src/utils/indigo-helpers.ts +0 -17
  111. package/src/utils/lucid-utils.ts +0 -125
  112. package/src/utils/oracle-helpers.ts +0 -62
  113. package/src/utils/pyth/decode.ts +0 -223
  114. package/src/utils/pyth/encode.ts +0 -262
  115. package/src/utils/pyth/index.ts +0 -14
  116. package/src/utils/pyth/types.ts +0 -87
  117. package/src/utils/time-helpers.ts +0 -4
  118. package/src/utils/utils.ts +0 -25
  119. package/src/validators/always-succeed-validator.ts +0 -6
  120. package/src/validators/cdp-creator-validator.ts +0 -7
  121. package/src/validators/cdp-redeem-validator.ts +0 -7
  122. package/src/validators/cdp-validator.ts +0 -7
  123. package/src/validators/collector-validator.ts +0 -7
  124. package/src/validators/execute-validator.ts +0 -7
  125. package/src/validators/governance-validator.ts +0 -7
  126. package/src/validators/iasset-validator.ts +0 -7
  127. package/src/validators/interest-collection-validator.ts +0 -7
  128. package/src/validators/interest-oracle-validator.ts +0 -7
  129. package/src/validators/one-shot-policy.ts +0 -7
  130. package/src/validators/poll-manager-validator.ts +0 -7
  131. package/src/validators/poll-shard-validator.ts +0 -7
  132. package/src/validators/price-oracle-validator.ts +0 -7
  133. package/src/validators/pyth-feed-validator.ts +0 -7
  134. package/src/validators/rob-validator.ts +0 -7
  135. package/src/validators/stability-pool-validator.ts +0 -7
  136. package/src/validators/stableswap-validator.ts +0 -7
  137. package/src/validators/staking-validator.ts +0 -7
  138. package/src/validators/treasury-validator.ts +0 -7
  139. package/src/validators/version-record-policy.ts +0 -7
  140. package/src/validators/version-registry-validator.ts +0 -7
  141. package/tests/always-succeed/script.ts +0 -7
  142. package/tests/array-utils.test.ts +0 -92
  143. package/tests/bigint-utils.test.ts +0 -41
  144. package/tests/cdp/actions.ts +0 -680
  145. package/tests/cdp/cdp-helpers.ts +0 -55
  146. package/tests/cdp/cdp-queries.ts +0 -423
  147. package/tests/cdp/cdp.test.ts +0 -6730
  148. package/tests/cdp/transactions-mutated.ts +0 -1733
  149. package/tests/data/system-params.json +0 -1155
  150. package/tests/datums.test.ts +0 -302
  151. package/tests/endpoints/initialize.ts +0 -78
  152. package/tests/endpoints/interest-collector.ts +0 -37
  153. package/tests/endpoints/treasury.ts +0 -70
  154. package/tests/gov/actions.ts +0 -381
  155. package/tests/gov/gov.test.ts +0 -5147
  156. package/tests/gov/governance-queries.ts +0 -37
  157. package/tests/hash-checks.test.ts +0 -112
  158. package/tests/indigo-test-helpers.ts +0 -99
  159. package/tests/initialize.test.ts +0 -79
  160. package/tests/interest-calculations.test.ts +0 -120
  161. package/tests/interest-collection/interest-collection.test.ts +0 -843
  162. package/tests/interest-collection/transactions-mutated.ts +0 -260
  163. package/tests/interest-oracle.test.ts +0 -93
  164. package/tests/mock/assets-mock.ts +0 -243
  165. package/tests/mock/protocol-params-mock.ts +0 -21
  166. package/tests/price-oracle/actions.ts +0 -161
  167. package/tests/price-oracle/price-oracle-queries.ts +0 -12
  168. package/tests/price-oracle/price-oracle.test.ts +0 -228
  169. package/tests/price-oracle/transactions-mutated.ts +0 -59
  170. package/tests/pyth/endpoints.ts +0 -96
  171. package/tests/pyth/helpers.ts +0 -37
  172. package/tests/pyth/pyth-encoding.test.ts +0 -376
  173. package/tests/pyth/pyth-feeds.test.ts +0 -943
  174. package/tests/pyth/pyth-indigo.test.ts +0 -505
  175. package/tests/pyth/pyth.test.ts +0 -299
  176. package/tests/queries/collector-queries.ts +0 -27
  177. package/tests/queries/execute-queries.ts +0 -47
  178. package/tests/queries/iasset-queries.ts +0 -149
  179. package/tests/queries/interest-oracle-queries.ts +0 -12
  180. package/tests/queries/poll-queries.ts +0 -97
  181. package/tests/queries/staking-queries.ts +0 -54
  182. package/tests/rob/actions.ts +0 -56
  183. package/tests/rob/rob-leverage.test.ts +0 -2555
  184. package/tests/rob/rob-queries.ts +0 -95
  185. package/tests/rob/rob.test.ts +0 -3677
  186. package/tests/rob/transactions-mutated.ts +0 -844
  187. package/tests/script-size.test.ts +0 -240
  188. package/tests/setup.ts +0 -135
  189. package/tests/stability-pool/actions.ts +0 -229
  190. package/tests/stability-pool.test.ts +0 -6491
  191. package/tests/stableswap/stableswap-actions.ts +0 -83
  192. package/tests/stableswap/stableswap-queries.ts +0 -98
  193. package/tests/stableswap/stableswap.test.ts +0 -4471
  194. package/tests/stableswap/transactions-mutated.ts +0 -348
  195. package/tests/staking.test.ts +0 -172
  196. package/tests/test-helpers.ts +0 -94
  197. package/tests/treasury/actions.ts +0 -67
  198. package/tests/treasury/treasury.test.ts +0 -320
  199. package/tests/utils/asserts.ts +0 -87
  200. package/tests/utils/benchmark-utils.ts +0 -130
  201. package/tests/utils/index.ts +0 -168
  202. package/tsconfig.build.json +0 -4
  203. package/tsconfig.json +0 -27
  204. package/vitest.config.ts +0 -11
@@ -1,24 +0,0 @@
1
- import { Data } from '@lucid-evolution/lucid';
2
- import { AssetClassSchema } from '../../types/generic';
3
-
4
- const ExecuteParamsSchema = Data.Object({
5
- govNFT: AssetClassSchema,
6
- upgradeToken: AssetClassSchema,
7
- iAssetToken: AssetClassSchema,
8
- collateralAssetToken: AssetClassSchema,
9
- stabilityPoolToken: AssetClassSchema,
10
- cdpCreatorToken: AssetClassSchema,
11
- cdpToken: AssetClassSchema,
12
- versionRecordToken: AssetClassSchema,
13
- iassetValHash: Data.Bytes(),
14
- cdpValHash: Data.Bytes(),
15
- sPoolValHash: Data.Bytes(),
16
- versionRegistryValHash: Data.Bytes(),
17
- treasuryValHash: Data.Bytes(),
18
- });
19
- export type ExecuteParams = Data.Static<typeof ExecuteParamsSchema>;
20
- export const ExecuteParams = ExecuteParamsSchema as unknown as ExecuteParams;
21
-
22
- export function castExecuteParams(params: ExecuteParams): Data {
23
- return Data.castTo(params, ExecuteParams);
24
- }
@@ -1,351 +0,0 @@
1
- import { pipe } from 'fp-ts/lib/function';
2
- import {
3
- array as A,
4
- option as O,
5
- string as S,
6
- ord as Ord,
7
- function as F,
8
- } from 'fp-ts';
9
- import {
10
- addAssets,
11
- Assets,
12
- LucidEvolution,
13
- OutRef,
14
- toHex,
15
- toText,
16
- UTxO,
17
- } from '@lucid-evolution/lucid';
18
- import { matchSingle } from '../../utils/utils';
19
- import { getInlineDatumOrThrow } from '../../utils/lucid-utils';
20
- import {
21
- AddCollateralAsssetContent,
22
- ProposeAssetContent,
23
- TreasuryWithdrawal,
24
- TreasuryWithdrawalItem,
25
- } from './types-new';
26
- import { AssetClass, mkAssetsOf } from '@3rd-eye-labs/cardano-offchain-common';
27
- import {
28
- CollateralAssetContent,
29
- CollateralAssetOutput,
30
- IAssetContent,
31
- IAssetOutput,
32
- parseCollateralAssetDatumOrThrow,
33
- parseIAssetDatumOrThrow,
34
- } from '../iasset/types';
35
- import { getAssetClassComparisonStr, ParsedOutput } from '../../types/generic';
36
-
37
- export function proposalDeposit(
38
- baseDeposit: bigint,
39
- activeProposals: bigint,
40
- ): bigint {
41
- return baseDeposit * 2n ** activeProposals;
42
- }
43
-
44
- export function createValueFromWithdrawal(w: TreasuryWithdrawal): Assets {
45
- return A.reduce<TreasuryWithdrawalItem, Assets>({}, (acc, item) =>
46
- addAssets(
47
- acc,
48
- mkAssetsOf(
49
- {
50
- currencySymbol: item.currencySymbol,
51
- tokenName: item.tokenName,
52
- },
53
- item.amount,
54
- ),
55
- ),
56
- )([...w.value]);
57
- }
58
-
59
- /**
60
- * A generic solution for iassets and collateral assets chain.
61
- */
62
- async function findRelativeAssetForInsertion<
63
- T extends Uint8Array<ArrayBufferLike> | AssetClass,
64
- K,
65
- >(
66
- newAsset: T,
67
- allIAssetOrefs: OutRef[],
68
- lucid: LucidEvolution,
69
- assetOrd: Ord.Ord<T>,
70
- getComparisonAsset: (datum: K) => T,
71
- parseDatum: (utxo: UTxO) => K,
72
- ): Promise<O.Option<ParsedOutput<K>>> {
73
- const parsedUtxos = await Promise.all(
74
- allIAssetOrefs.map(async (oref) => {
75
- const utxo = matchSingle(
76
- await lucid.utxosByOutRef([oref]),
77
- (_) => new Error('Expected a single UTXO'),
78
- );
79
-
80
- const datum = parseDatum(utxo);
81
-
82
- return { datum: datum, utxo: utxo };
83
- }),
84
- );
85
-
86
- // The iasset just before the new token name based on assets ordering
87
- return pipe(
88
- parsedUtxos,
89
- // Sort by the asset names
90
- A.sort(
91
- Ord.contramap<T, ParsedOutput<K>>((a) => getComparisonAsset(a.datum))(
92
- assetOrd,
93
- ),
94
- ),
95
- // split head and tail
96
- A.foldLeft(
97
- () => O.none,
98
- (head, rest) =>
99
- O.some<[ParsedOutput<K>, ParsedOutput<K>[]]>([head, rest]),
100
- ),
101
- // find the preceding iasset for the new token name
102
- O.flatMap(([firstIAsset, rest]) =>
103
- O.some(
104
- A.reduce<ParsedOutput<K>, ParsedOutput<K>>(
105
- firstIAsset,
106
- (acc, iasset) => {
107
- const isGreater =
108
- assetOrd.compare(getComparisonAsset(iasset.datum), newAsset) ===
109
- -1;
110
-
111
- // When the new asset is greater, stop searching for the reference.
112
- return isGreater ? iasset : acc;
113
- },
114
- )(rest),
115
- ),
116
- ),
117
- );
118
- }
119
-
120
- /**
121
- * Find the IAsset that should be a preceding one for the new IAsset token name.
122
- * In case there are no iassets, none should be returned.
123
- */
124
- export async function findRelativeIAssetForInsertion(
125
- newIAssetTokenName: Uint8Array<ArrayBufferLike>,
126
- allIAssetOrefs: OutRef[],
127
- lucid: LucidEvolution,
128
- ): Promise<O.Option<IAssetOutput>> {
129
- return findRelativeAssetForInsertion(
130
- newIAssetTokenName,
131
- allIAssetOrefs,
132
- lucid,
133
- Ord.contramap<string, Uint8Array<ArrayBufferLike>>((x) => toText(toHex(x)))(
134
- S.Ord,
135
- ),
136
- (d) => d.assetName,
137
- (utxo) => parseIAssetDatumOrThrow(getInlineDatumOrThrow(utxo)),
138
- );
139
- }
140
-
141
- /**
142
- * Find collateral asset that should be a preceding one for the new Collateral asset.
143
- * In case there are no collateral assets, none should be returned.
144
- */
145
- export async function findRelativeCollateralAssetForInsertion(
146
- newCollateralAsset: AssetClass,
147
- allCollateralAssetOrefs: OutRef[],
148
- lucid: LucidEvolution,
149
- ): Promise<O.Option<CollateralAssetOutput>> {
150
- return findRelativeAssetForInsertion(
151
- newCollateralAsset,
152
- allCollateralAssetOrefs,
153
- lucid,
154
- Ord.contramap<string, AssetClass>((x) => getAssetClassComparisonStr(x))(
155
- S.Ord,
156
- ),
157
- (d) => d.collateralAsset,
158
- (utxo) => parseCollateralAssetDatumOrThrow(getInlineDatumOrThrow(utxo)),
159
- );
160
- }
161
-
162
- /**
163
- * A generic solution for iassets and collateral assets chain.
164
- */
165
- async function findFirstAsset<
166
- T extends Uint8Array<ArrayBufferLike> | AssetClass,
167
- K,
168
- >(
169
- allIAssetOrefs: OutRef[],
170
- lucid: LucidEvolution,
171
- assetOrd: Ord.Ord<T>,
172
- getComparisonAsset: (datum: K) => T,
173
- parseDatum: (utxo: UTxO) => K,
174
- ): Promise<O.Option<ParsedOutput<K>>> {
175
- const parsedUtxos = await Promise.all(
176
- allIAssetOrefs.map(async (oref) => {
177
- const utxo = matchSingle(
178
- await lucid.utxosByOutRef([oref]),
179
- (_) => new Error('Expected a single UTXO'),
180
- );
181
-
182
- const datum = parseDatum(utxo);
183
-
184
- return { datum: datum, utxo: utxo };
185
- }),
186
- );
187
-
188
- // The iasset just before the new token name based on assets ordering
189
- return pipe(
190
- parsedUtxos,
191
- // Sort by the asset names
192
- A.sort(
193
- Ord.contramap<T, ParsedOutput<K>>((a) => getComparisonAsset(a.datum))(
194
- assetOrd,
195
- ),
196
- ),
197
- A.head,
198
- );
199
- }
200
-
201
- /**
202
- * Find the collateral asset that is first in the distributed list.
203
- * In case there are no collateral assets, none should be returned.
204
- */
205
- export async function findFirstCollateralAsset(
206
- allCollateralAssetOrefs: OutRef[],
207
- lucid: LucidEvolution,
208
- ): Promise<O.Option<CollateralAssetOutput>> {
209
- return findFirstAsset(
210
- allCollateralAssetOrefs,
211
- lucid,
212
- Ord.contramap<string, AssetClass>((x) => getAssetClassComparisonStr(x))(
213
- S.Ord,
214
- ),
215
- (d) => d.collateralAsset,
216
- (utxo) => parseCollateralAssetDatumOrThrow(getInlineDatumOrThrow(utxo)),
217
- );
218
- }
219
-
220
- type IAssetCreationDatumHelperReturnType = {
221
- newIAsset: IAssetContent;
222
- newReferencedIAsset: O.Option<IAssetContent>;
223
- };
224
-
225
- export function iassetCreationDatumHelper(
226
- proposeAssetContent: ProposeAssetContent,
227
- referencedIAsset: O.Option<IAssetContent>,
228
- ): IAssetCreationDatumHelperReturnType {
229
- const newContent: IAssetContent = {
230
- assetName: proposeAssetContent.asset,
231
- collateralAssetsCount: 0n,
232
- debtMintingFeeRatio: proposeAssetContent.debtMintingFeeRatio,
233
- liquidationProcessingFeeRatio:
234
- proposeAssetContent.liquidationProcessingFeeRatio,
235
- stabilityPoolWithdrawalFeeRatio:
236
- proposeAssetContent.stabilityPoolWithdrawalFeeRatio,
237
- redemptionReimbursementRatio:
238
- proposeAssetContent.redemptionReimbursementRatio,
239
- redemptionProcessingFeeRatio:
240
- proposeAssetContent.redemptionProcessingFeeRatio,
241
- firstIAsset: true,
242
- nextIAsset: null,
243
- };
244
-
245
- return F.pipe(
246
- referencedIAsset,
247
- O.match<IAssetContent, IAssetCreationDatumHelperReturnType>(
248
- () => ({
249
- newIAsset: newContent,
250
- newReferencedIAsset: O.none,
251
- }),
252
- (referencedIA) => {
253
- if (
254
- toText(toHex(proposeAssetContent.asset)) <
255
- toText(toHex(referencedIA.assetName))
256
- ) {
257
- return {
258
- newIAsset: {
259
- ...newContent,
260
- firstIAsset: true,
261
- nextIAsset: referencedIA.assetName,
262
- },
263
- newReferencedIAsset: O.some({
264
- ...referencedIA,
265
- firstIAsset: false,
266
- }),
267
- };
268
- } else {
269
- return {
270
- newIAsset: {
271
- ...newContent,
272
- firstIAsset: false,
273
- nextIAsset: referencedIA.nextIAsset,
274
- },
275
- newReferencedIAsset: O.some({
276
- ...referencedIA,
277
- nextIAsset: proposeAssetContent.asset,
278
- }),
279
- };
280
- }
281
- },
282
- ),
283
- );
284
- }
285
-
286
- type CollateralAssetCreationDatumHelperReturnType = {
287
- newCollateralAsset: CollateralAssetContent;
288
- newReferencedCollateralAsset: O.Option<CollateralAssetContent>;
289
- };
290
-
291
- export function collateralAssetCreationDatumHelper(
292
- addAssetContent: AddCollateralAsssetContent,
293
- referencedCollateralAsset: O.Option<CollateralAssetContent>,
294
- ): CollateralAssetCreationDatumHelperReturnType {
295
- const newContent: CollateralAssetContent = {
296
- iasset: addAssetContent.correspondingIAsset,
297
- collateralAsset: addAssetContent.collateralAsset,
298
- extraDecimals: addAssetContent.assetExtraDecimals,
299
- priceInfo: addAssetContent.assetPriceInfo,
300
- interestOracleNft: addAssetContent.interestOracleNft,
301
- redemptionRatio: addAssetContent.redemptionRatio,
302
- maintenanceRatio: addAssetContent.maintenanceRatio,
303
- liquidationRatio: addAssetContent.liquidationRatio,
304
- minCollateralAmt: addAssetContent.minCollateralAmt,
305
- firstCollateralAsset: true,
306
- nextCollateralAsset: null,
307
- };
308
-
309
- return F.pipe(
310
- referencedCollateralAsset,
311
- O.match<
312
- CollateralAssetContent,
313
- CollateralAssetCreationDatumHelperReturnType
314
- >(
315
- () => ({
316
- newCollateralAsset: newContent,
317
- newReferencedCollateralAsset: O.none,
318
- }),
319
- (referencedCA) => {
320
- if (
321
- getAssetClassComparisonStr(addAssetContent.collateralAsset) <
322
- getAssetClassComparisonStr(referencedCA.collateralAsset)
323
- ) {
324
- return {
325
- newCollateralAsset: {
326
- ...newContent,
327
- firstCollateralAsset: true,
328
- nextCollateralAsset: referencedCA.collateralAsset,
329
- },
330
- newReferencedCollateralAsset: O.some({
331
- ...referencedCA,
332
- firstCollateralAsset: false,
333
- }),
334
- };
335
- } else {
336
- return {
337
- newCollateralAsset: {
338
- ...newContent,
339
- firstCollateralAsset: false,
340
- nextCollateralAsset: referencedCA.nextCollateralAsset,
341
- },
342
- newReferencedCollateralAsset: O.some({
343
- ...referencedCA,
344
- nextCollateralAsset: addAssetContent.collateralAsset,
345
- }),
346
- };
347
- }
348
- },
349
- ),
350
- );
351
- }
@@ -1,41 +0,0 @@
1
- import { applyParamsToScript, SpendingValidator } from '@lucid-evolution/lucid';
2
- import { castGovParams, GovParams } from './types';
3
- import {
4
- GovParamsSP,
5
- fromSystemParamsAssetLucid,
6
- } from '../../types/system-params';
7
- import { _governanceValidator } from '../../validators/governance-validator';
8
-
9
- export const mkGovValidator = (params: GovParams): SpendingValidator => {
10
- return {
11
- type: 'PlutusV3',
12
- script: applyParamsToScript(_governanceValidator.cborHex, [
13
- castGovParams(params),
14
- ]),
15
- };
16
- };
17
-
18
- export const mkGovValidatorFromSP = (
19
- params: GovParamsSP,
20
- ): SpendingValidator => {
21
- return {
22
- type: 'PlutusV3',
23
- script: applyParamsToScript(_governanceValidator.cborHex, [
24
- castGovParams({
25
- gBiasTime: BigInt(params.gBiasTime),
26
- govNFT: fromSystemParamsAssetLucid(params.govNFT),
27
- pollToken: fromSystemParamsAssetLucid(params.pollToken),
28
- upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
29
- indyAsset: fromSystemParamsAssetLucid(params.indyAsset),
30
- versionRecordToken: fromSystemParamsAssetLucid(
31
- params.versionRecordToken,
32
- ),
33
- iassetSymbol: params.iassetSymbol.unCurrencySymbol,
34
- iassetValHash: params.iassetValHash,
35
- pollManagerValHash: params.pollManagerValHash,
36
- daoIdentityToken: fromSystemParamsAssetLucid(params.daoIdentityToken),
37
- iAssetAuthToken: fromSystemParamsAssetLucid(params.iAssetAuthToken),
38
- }),
39
- ]),
40
- };
41
- };