@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,277 +0,0 @@
1
- import { TSchema, Data } from '@evolution-sdk/evolution';
2
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
3
- import { option as O, function as F } from 'fp-ts';
4
- import {
5
- AssetClassSchema,
6
- OutputReferenceSchema,
7
- } from '@3rd-eye-labs/cardano-offchain-common';
8
- import { match, P } from 'ts-pattern';
9
- import { RationalSchema } from '../../types/rational';
10
- import { OracleIdxSchema } from '../price-oracle/types-new';
11
-
12
- // const CdpParamsSchema = Core.TSchema.Struct({
13
- // cdp_auth_token: EvoCommon.AssetClassSchema,
14
- // cdp_asset_symbol: Core.TSchema.ByteArray,
15
- // iasset_auth_token: EvoCommon.AssetClassSchema,
16
- // stability_pool_auth_token: EvoCommon.AssetClassSchema,
17
- // version_record_token: EvoCommon.AssetClassSchema,
18
- // upgrade_token: EvoCommon.AssetClassSchema,
19
- // collector_val_hash: Core.TSchema.ByteArray,
20
- // sp_val_hash: Core.TSchema.ByteArray,
21
- // gov_nft: EvoCommon.AssetClassSchema,
22
- // min_collateral_in_lovelace: Core.TSchema.Integer,
23
- // partial_redemption_extra_fee_lovelace: Core.TSchema.Integer,
24
- // bias_time: Core.TSchema.Integer,
25
- // treasury_val_hash: Core.TSchema.ByteArray,
26
- // });
27
-
28
- // export type CdpParams = typeof CdpParamsSchema.Type;
29
-
30
- const CdpRedeemerSchema = TSchema.Union(
31
- TSchema.Struct(
32
- {
33
- AdjustCdp: TSchema.Struct(
34
- {
35
- currentTime: TSchema.Integer,
36
- debtAdjustment: TSchema.Integer,
37
- collateralAdjustment: TSchema.Integer,
38
- priceOracleIdx: OracleIdxSchema,
39
- },
40
- { flatFields: true },
41
- ),
42
- },
43
- { flatInUnion: true },
44
- ),
45
- TSchema.Struct(
46
- {
47
- CloseCdp: TSchema.Struct(
48
- {
49
- currentTime: TSchema.Integer,
50
- },
51
- { flatFields: true },
52
- ),
53
- },
54
- { flatInUnion: true },
55
- ),
56
- TSchema.Literal('RedeemCdp', { flatInUnion: true }),
57
- TSchema.Struct(
58
- {
59
- FreezeCdp: TSchema.Struct(
60
- {
61
- currentTime: TSchema.Integer,
62
- priceOracleIdx: OracleIdxSchema,
63
- },
64
- { flatFields: true },
65
- ),
66
- },
67
- { flatInUnion: true },
68
- ),
69
- TSchema.Literal('MergeCdps', { flatInUnion: true }),
70
- TSchema.Struct(
71
- {
72
- MergeAuxiliary: TSchema.Struct(
73
- {
74
- mainMergeUtxo: OutputReferenceSchema,
75
- },
76
- { flatFields: true },
77
- ),
78
- },
79
- { flatInUnion: true },
80
- ),
81
- TSchema.Literal('Liquidate', { flatInUnion: true }),
82
- TSchema.Struct(
83
- {
84
- SettleInterest: TSchema.Struct(
85
- {
86
- interestCollectorInputIndex: TSchema.Integer,
87
- },
88
- { flatFields: true },
89
- ),
90
- },
91
- { flatInUnion: true },
92
- ),
93
- TSchema.Struct(
94
- {
95
- Stableswap: TSchema.Struct(
96
- {
97
- forwardingInputIndex: TSchema.Integer,
98
- },
99
- { flatFields: true },
100
- ),
101
- },
102
- { flatInUnion: true },
103
- ),
104
- TSchema.Literal('UpgradeVersion', { flatInUnion: true }),
105
- );
106
-
107
- export type CdpRedeemer = typeof CdpRedeemerSchema.Type;
108
-
109
- const RedeemCdpWithdrawalRedeemerSchema = TSchema.Struct({
110
- cdpOutReference: OutputReferenceSchema,
111
- currentTime: TSchema.Integer,
112
- priceOracleIdx: OracleIdxSchema,
113
- });
114
-
115
- export type RedeemCdpWithdrawalRedeemer =
116
- typeof RedeemCdpWithdrawalRedeemerSchema.Type;
117
-
118
- const CDPFeesSchema = TSchema.Union(
119
- TSchema.Struct(
120
- {
121
- ActiveCDPInterestTracking: TSchema.Struct(
122
- {
123
- lastSettled: TSchema.Integer,
124
- unitaryInterestSnapshot: TSchema.Integer,
125
- },
126
- { flatFields: true },
127
- ),
128
- },
129
- { flatInUnion: true },
130
- ),
131
- TSchema.Struct(
132
- {
133
- FrozenCDPAccumulatedFees: TSchema.Struct(
134
- {
135
- iassetInterest: TSchema.Integer,
136
- collateralTreasury: TSchema.Integer,
137
- },
138
- { flatFields: true },
139
- ),
140
- },
141
- { flatInUnion: true },
142
- ),
143
- );
144
-
145
- const CDPContentSchema = TSchema.Struct({
146
- cdpOwner: TSchema.NullOr(TSchema.ByteArray),
147
- iasset: TSchema.ByteArray,
148
- collateralAsset: AssetClassSchema,
149
- mintedAmt: TSchema.Integer,
150
- cdpFees: CDPFeesSchema,
151
- });
152
-
153
- export type CDPContent = typeof CDPContentSchema.Type;
154
-
155
- const StableswapPoolContentSchema = TSchema.Struct({
156
- /** Use the HEX encoding */
157
- iasset: TSchema.ByteArray,
158
- collateralAsset: AssetClassSchema,
159
- collateralToIassetRatio: RationalSchema,
160
- mintingFeeRatio: RationalSchema,
161
- redemptionFeeRatio: RationalSchema,
162
- mintingEnabled: TSchema.Boolean,
163
- redemptionEnabled: TSchema.Boolean,
164
- feeManager: TSchema.NullOr(TSchema.ByteArray),
165
- minMintOrderAmount: TSchema.Integer,
166
- minRedemptionOrderAmount: TSchema.Integer,
167
- stableswapValHash: TSchema.ByteArray,
168
- });
169
-
170
- export type StableswapPoolContent = typeof StableswapPoolContentSchema.Type;
171
-
172
- const CDPDatumSchema = TSchema.Union(
173
- TSchema.Struct({ CDP: CDPContentSchema }, { flatInUnion: true }),
174
- TSchema.Struct(
175
- { StableswapPool: StableswapPoolContentSchema },
176
- { flatInUnion: true },
177
- ),
178
- );
179
- export type CDPDatum = typeof CDPDatumSchema.Type;
180
-
181
- export function serialiseCdpRedeemer(r: CdpRedeemer): string {
182
- return Data.withSchema(CdpRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex(
183
- r,
184
- );
185
- }
186
-
187
- export function parseCdpRedeemer(datum: string): O.Option<CdpRedeemer> {
188
- try {
189
- return O.some(
190
- Data.withSchema(CdpRedeemerSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
191
- datum,
192
- ),
193
- );
194
- } catch (_) {
195
- return O.none;
196
- }
197
- }
198
-
199
- export function parseCdpRedeemerOrThrow(datum: string): CdpRedeemer {
200
- return F.pipe(
201
- parseCdpRedeemer(datum),
202
- O.match(() => {
203
- throw new Error('Expected a cdp redeemer.');
204
- }, F.identity),
205
- );
206
- }
207
-
208
- export function serialiseRedeemCdpWithdrawalRedeemer(
209
- r: RedeemCdpWithdrawalRedeemer,
210
- ): string {
211
- return Data.withSchema(
212
- RedeemCdpWithdrawalRedeemerSchema,
213
- DEFAULT_SCHEMA_OPTIONS,
214
- ).toCBORHex(r);
215
- }
216
-
217
- export function serialiseCdpDatum(d: CDPContent): string {
218
- return Data.withSchema(CDPDatumSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex({
219
- CDP: d,
220
- });
221
- }
222
-
223
- export function serialiseStableswapPoolDatum(d: StableswapPoolContent): string {
224
- return Data.withSchema(CDPDatumSchema, DEFAULT_SCHEMA_OPTIONS).toCBORHex({
225
- StableswapPool: d,
226
- });
227
- }
228
-
229
- export function parseCdpDatum(datum: string): O.Option<CDPContent> {
230
- try {
231
- return match(
232
- Data.withSchema(CDPDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
233
- datum,
234
- ),
235
- )
236
- .with({ CDP: P.select() }, (res) => O.some(res))
237
- .otherwise(() => O.none);
238
- } catch (_) {
239
- return O.none;
240
- }
241
- }
242
-
243
- export function parseCdpDatumOrThrow(datum: string): CDPContent {
244
- return F.pipe(
245
- parseCdpDatum(datum),
246
- O.match(() => {
247
- throw new Error('Expected a CDP datum.');
248
- }, F.identity),
249
- );
250
- }
251
-
252
- export function parseStableswapPoolDatum(
253
- datum: string,
254
- ): O.Option<StableswapPoolContent> {
255
- try {
256
- return match(
257
- Data.withSchema(CDPDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
258
- datum,
259
- ),
260
- )
261
- .with({ StableswapPool: P.select() }, (res) => O.some(res))
262
- .otherwise(() => O.none);
263
- } catch (_) {
264
- return O.none;
265
- }
266
- }
267
-
268
- export function parseStableswapPoolDatumOrThrow(
269
- datum: string,
270
- ): StableswapPoolContent {
271
- return F.pipe(
272
- parseStableswapPoolDatum(datum),
273
- O.match(() => {
274
- throw new Error('Expected a stableswap pool datum.');
275
- }, F.identity),
276
- );
277
- }
@@ -1,43 +0,0 @@
1
- import { Data } from '@lucid-evolution/lucid';
2
- import { AssetClassSchema } from '../../types/generic';
3
-
4
- const CdpParamsSchema = Data.Object({
5
- cdp_auth_token: AssetClassSchema,
6
- cdp_asset_symbol: Data.Bytes(),
7
- iasset_auth_token: AssetClassSchema,
8
- collateral_asset_auth_token: AssetClassSchema,
9
- stability_pool_auth_token: AssetClassSchema,
10
- upgrade_token: AssetClassSchema,
11
- version_record_token: AssetClassSchema,
12
- interest_collector_val_hash: Data.Bytes(),
13
- sp_val_hash: Data.Bytes(),
14
- iasset_val_hash: Data.Bytes(),
15
- treasury_val_hash: Data.Bytes(),
16
- cdp_redeem_val_hash: Data.Bytes(),
17
- bias_time: Data.Integer(),
18
- });
19
- export type CdpParams = Data.Static<typeof CdpParamsSchema>;
20
- const CdpParams = CdpParamsSchema as unknown as CdpParams;
21
-
22
- export function castCdpParams(params: CdpParams): Data {
23
- return Data.castTo(params, CdpParams);
24
- }
25
-
26
- const CdpRedeemParamsSchema = Data.Object({
27
- cdp_auth_token: AssetClassSchema,
28
- cdp_asset_symbol: Data.Bytes(),
29
- iasset_auth_token: AssetClassSchema,
30
- collateral_asset_auth_token: AssetClassSchema,
31
- interest_collector_val_hash: Data.Bytes(),
32
- iasset_val_hash: Data.Bytes(),
33
- treasury_val_hash: Data.Bytes(),
34
- gov_nft: AssetClassSchema,
35
- partial_redemption_extra_fee_lovelace: Data.Integer(),
36
- bias_time: Data.Integer(),
37
- });
38
- export type CdpRedeemParams = Data.Static<typeof CdpRedeemParamsSchema>;
39
- const CdpRedeemParams = CdpRedeemParamsSchema as unknown as CdpRedeemParams;
40
-
41
- export function castCdpRedeemParams(params: CdpRedeemParams): Data {
42
- return Data.castTo(params, CdpRedeemParams);
43
- }
@@ -1,30 +0,0 @@
1
- import {
2
- assetClassToUnit,
3
- getRandomElement,
4
- } from '@3rd-eye-labs/cardano-offchain-common';
5
- import { LucidEvolution, UTxO } from '@lucid-evolution/lucid';
6
- import { option as O, function as F } from 'fp-ts';
7
- import { createScriptAddress } from '../../utils/lucid-utils';
8
- import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
9
-
10
- export async function findRandomCdpCreator(
11
- lucid: LucidEvolution,
12
- sysParams: SystemParams,
13
- ): Promise<UTxO> {
14
- const cdpCreatorUtxos = await lucid.utxosAtWithUnit(
15
- createScriptAddress(
16
- lucid.config().network!,
17
- sysParams.validatorHashes.cdpCreatorHash,
18
- ),
19
- assetClassToUnit(
20
- fromSystemParamsAsset(sysParams.cdpCreatorParams.cdpCreatorNft),
21
- ),
22
- );
23
-
24
- return F.pipe(
25
- O.fromNullable(getRandomElement(cdpCreatorUtxos)),
26
- O.match(() => {
27
- throw new Error('Expected some cdp creator UTXOs.');
28
- }, F.identity),
29
- );
30
- }
@@ -1,45 +0,0 @@
1
- import { applyParamsToScript, SpendingValidator } from '@lucid-evolution/lucid';
2
- import { castCDPCreatorParams, CDPCreatorParams } from './types';
3
- import {
4
- CDPCreatorParamsSP,
5
- fromSystemParamsAssetLucid,
6
- } from '../../types/system-params';
7
- import { _cdpCreatorValidator } from '../../validators/cdp-creator-validator';
8
-
9
- export const mkCDPCreatorValidator = (
10
- params: CDPCreatorParams,
11
- ): SpendingValidator => {
12
- return {
13
- type: 'PlutusV3',
14
- script: applyParamsToScript(_cdpCreatorValidator.cborHex, [
15
- castCDPCreatorParams(params),
16
- ]),
17
- };
18
- };
19
-
20
- export const mkCDPCreatorValidatorFromSP = (
21
- params: CDPCreatorParamsSP,
22
- ): SpendingValidator => {
23
- return {
24
- type: 'PlutusV3',
25
- script: applyParamsToScript(_cdpCreatorValidator.cborHex, [
26
- castCDPCreatorParams({
27
- cdpCreatorNft: fromSystemParamsAssetLucid(params.cdpCreatorNft),
28
- cdpAssetCs: params.cdpAssetCs.unCurrencySymbol,
29
- cdpAuthTk: fromSystemParamsAssetLucid(params.cdpAuthTk),
30
- iAssetAuthTk: fromSystemParamsAssetLucid(params.iAssetAuthTk),
31
- collateralAssetAuthTk: fromSystemParamsAssetLucid(
32
- params.collateralAssetAuthTk,
33
- ),
34
- upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
35
- versionRecordToken: fromSystemParamsAssetLucid(
36
- params.versionRecordToken,
37
- ),
38
- iassetValHash: params.iassetValHash,
39
- cdpScriptHash: params.cdpScriptHash,
40
- treasuryValHash: params.treasuryValHash,
41
- biasTime: BigInt(params.biasTime),
42
- }),
43
- ]),
44
- };
45
- };
@@ -1,50 +0,0 @@
1
- import { TSchema, Data } from '@evolution-sdk/evolution';
2
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
3
- import { OutputReferenceSchema } from '@3rd-eye-labs/cardano-offchain-common';
4
- import { OracleIdxSchema } from '../price-oracle/types-new';
5
-
6
- const CDPCreatorDatumSchema = TSchema.Struct({
7
- creatorInputOref: OutputReferenceSchema,
8
- });
9
-
10
- const CreateCDPContentSchema = TSchema.Struct({
11
- cdpOwner: TSchema.ByteArray,
12
- minted: TSchema.Integer,
13
- collateralAmt: TSchema.Integer,
14
- currentTime: TSchema.Integer,
15
- creatorInputIdx: TSchema.Integer,
16
- creatorOutputIdx: TSchema.Integer,
17
- cdpOutputIdx: TSchema.Integer,
18
- iassetRefInputIdx: TSchema.Integer,
19
- collateralAssetRefInputIdx: TSchema.Integer,
20
- interestOracleRefInputIdx: TSchema.Integer,
21
- priceOracleIdx: OracleIdxSchema,
22
- });
23
-
24
- const CDPCreatorRedeemerSchema = TSchema.Union(
25
- TSchema.Struct(
26
- {
27
- CreateCDP: CreateCDPContentSchema,
28
- },
29
- { flatInUnion: true },
30
- ),
31
- TSchema.Literal('CreateStableswapPool', { flatInUnion: true }),
32
- TSchema.Literal('UpgradeCreatorVersion', { flatInUnion: true }),
33
- );
34
- export type CDPCreatorRedeemer = typeof CDPCreatorRedeemerSchema.Type;
35
-
36
- export function serialiseCDPCreatorDatum(
37
- r: typeof CDPCreatorDatumSchema.Type,
38
- ): string {
39
- return Data.withSchema(
40
- CDPCreatorDatumSchema,
41
- DEFAULT_SCHEMA_OPTIONS,
42
- ).toCBORHex(r);
43
- }
44
-
45
- export function serialiseCDPCreatorRedeemer(r: CDPCreatorRedeemer): string {
46
- return Data.withSchema(
47
- CDPCreatorRedeemerSchema,
48
- DEFAULT_SCHEMA_OPTIONS,
49
- ).toCBORHex(r);
50
- }
@@ -1,24 +0,0 @@
1
- import { Data } from '@lucid-evolution/lucid';
2
- import { AssetClassSchema } from '../../types/generic';
3
-
4
- const CDPCreatorParamsSchema = Data.Object({
5
- cdpCreatorNft: AssetClassSchema,
6
- cdpAssetCs: Data.Bytes(),
7
- cdpAuthTk: AssetClassSchema,
8
- iAssetAuthTk: AssetClassSchema,
9
- collateralAssetAuthTk: AssetClassSchema,
10
- upgradeToken: AssetClassSchema,
11
- versionRecordToken: AssetClassSchema,
12
- cdpScriptHash: Data.Bytes(),
13
- treasuryValHash: Data.Bytes(),
14
- iassetValHash: Data.Bytes(),
15
- biasTime: Data.Integer(),
16
- });
17
-
18
- export type CDPCreatorParams = Data.Static<typeof CDPCreatorParamsSchema>;
19
- export const CDPCreatorParams =
20
- CDPCreatorParamsSchema as unknown as CDPCreatorParams;
21
-
22
- export function castCDPCreatorParams(params: CDPCreatorParams): Data {
23
- return Data.castTo(params, CDPCreatorParams);
24
- }
@@ -1,32 +0,0 @@
1
- import {
2
- applyParamsToScript,
3
- Constr,
4
- fromText,
5
- SpendingValidator,
6
- } from '@lucid-evolution/lucid';
7
- import { CollectorParamsSP } from '../../types/system-params';
8
- import { _collectorValidator } from '../../validators/collector-validator';
9
-
10
- export const mkCollectorValidatorFromSP = (
11
- params: CollectorParamsSP,
12
- ): SpendingValidator => {
13
- return {
14
- type: 'PlutusV3',
15
- script: applyParamsToScript(_collectorValidator.cborHex, [
16
- new Constr(0, [
17
- new Constr(0, [
18
- params.stakingManagerNFT[0].unCurrencySymbol,
19
- fromText(params.stakingManagerNFT[1].unTokenName),
20
- ]),
21
- new Constr(0, [
22
- params.stakingToken[0].unCurrencySymbol,
23
- fromText(params.stakingToken[1].unTokenName),
24
- ]),
25
- new Constr(0, [
26
- params.versionRecordToken[0].unCurrencySymbol,
27
- fromText(params.versionRecordToken[1].unTokenName),
28
- ]),
29
- ]),
30
- ]),
31
- };
32
- };
@@ -1,50 +0,0 @@
1
- import {
2
- addAssets,
3
- Data,
4
- LucidEvolution,
5
- OutRef,
6
- TxBuilder,
7
- UTxO,
8
- } from '@lucid-evolution/lucid';
9
- import {
10
- fromSystemParamsScriptRef,
11
- SystemParams,
12
- } from '../../types/system-params';
13
- import { matchSingle } from '../../utils/utils';
14
- import { serialiseCollectorRedeemer } from './types-new';
15
- import { mkLovelacesOf } from '@3rd-eye-labs/cardano-offchain-common';
16
-
17
- /**
18
- * Returns the collector ref script UTXO that was added to ref inputs.
19
- *
20
- * No need to return the TxBuilder since it's stateful object.
21
- */
22
- export async function collectorFeeTx(
23
- fee: bigint,
24
- lucid: LucidEvolution,
25
- params: SystemParams,
26
- tx: TxBuilder,
27
- collectorOref: OutRef,
28
- ): Promise<UTxO> {
29
- const collectorUtxo: UTxO = matchSingle(
30
- await lucid.utxosByOutRef([collectorOref]),
31
- (_) => new Error('Expected a single collector UTXO'),
32
- );
33
-
34
- const collectorRefScriptUtxo = matchSingle(
35
- await lucid.utxosByOutRef([
36
- fromSystemParamsScriptRef(params.scriptReferences.collectorValidatorRef),
37
- ]),
38
- (_) => new Error('Expected a single collector Ref Script UTXO'),
39
- );
40
-
41
- tx.collectFrom([collectorUtxo], serialiseCollectorRedeemer('Collect'))
42
- .pay.ToContract(
43
- collectorUtxo.address,
44
- { kind: 'inline', value: Data.void() },
45
- addAssets(collectorUtxo.assets, mkLovelacesOf(fee)),
46
- )
47
- .readFrom([collectorRefScriptUtxo]);
48
-
49
- return collectorRefScriptUtxo;
50
- }
@@ -1,17 +0,0 @@
1
- import { TSchema, Data } from '@evolution-sdk/evolution';
2
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
3
-
4
- export const CollectorRedeemerSchema = TSchema.Union(
5
- TSchema.Literal('Collect', { flatInUnion: true }),
6
- TSchema.Literal('DistributeToStakers', { flatInUnion: true }),
7
- TSchema.Literal('UpgradeVersion', { flatInUnion: true }),
8
- );
9
-
10
- export type CollectorRedeemer = typeof CollectorRedeemerSchema.Type;
11
-
12
- export function serialiseCollectorRedeemer(r: CollectorRedeemer): string {
13
- return Data.withSchema(
14
- CollectorRedeemerSchema,
15
- DEFAULT_SCHEMA_OPTIONS,
16
- ).toCBORHex(r);
17
- }
@@ -1,57 +0,0 @@
1
- import {
2
- applyParamsToScript,
3
- applySingleCborEncoding,
4
- SpendingValidator,
5
- } from '@lucid-evolution/lucid';
6
- import { castExecuteParams, ExecuteParams } from './types';
7
- import {
8
- ExecuteParamsSP,
9
- fromSystemParamsAssetLucid,
10
- } from '../../types/system-params';
11
- import { _executeValidator } from '../../validators/execute-validator';
12
-
13
- export const mkExecuteValidator = (
14
- params: ExecuteParams,
15
- ): SpendingValidator => {
16
- return {
17
- type: 'PlutusV3',
18
- script: applySingleCborEncoding(
19
- applyParamsToScript(_executeValidator.cborHex, [
20
- castExecuteParams(params),
21
- ]),
22
- ),
23
- };
24
- };
25
-
26
- export const mkExecuteValidatorFromSP = (
27
- params: ExecuteParamsSP,
28
- ): SpendingValidator => {
29
- return {
30
- type: 'PlutusV3',
31
- script: applySingleCborEncoding(
32
- applyParamsToScript(_executeValidator.cborHex, [
33
- castExecuteParams({
34
- govNFT: fromSystemParamsAssetLucid(params.govNFT),
35
- upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
36
- iAssetToken: fromSystemParamsAssetLucid(params.iAssetToken),
37
- collateralAssetToken: fromSystemParamsAssetLucid(
38
- params.collateralAssetToken,
39
- ),
40
- stabilityPoolToken: fromSystemParamsAssetLucid(
41
- params.stabilityPoolToken,
42
- ),
43
- cdpCreatorToken: fromSystemParamsAssetLucid(params.cdpCreatorToken),
44
- cdpToken: fromSystemParamsAssetLucid(params.cdpToken),
45
- versionRecordToken: fromSystemParamsAssetLucid(
46
- params.versionRecordToken,
47
- ),
48
- iassetValHash: params.iassetValHash,
49
- cdpValHash: params.cdpValHash,
50
- sPoolValHash: params.sPoolValHash,
51
- versionRegistryValHash: params.versionRegistryValHash,
52
- treasuryValHash: params.treasuryValHash,
53
- }),
54
- ]),
55
- ),
56
- };
57
- };
@@ -1,44 +0,0 @@
1
- import { option as O, function as F } from 'fp-ts';
2
- import { TSchema, Data } from '@evolution-sdk/evolution';
3
- import {
4
- ProposalContentSchema,
5
- TreasuryWithdrawalSchema,
6
- } from '../gov/types-new';
7
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
8
-
9
- const ExecuteDatumSchema = TSchema.Struct({
10
- id: TSchema.Integer,
11
- content: ProposalContentSchema,
12
- passedTime: TSchema.Integer,
13
- votingEndTime: TSchema.Integer,
14
- protocolVersion: TSchema.Integer,
15
- /// Value proposed to be withdrawn from the treasury as part of the proposal.
16
- treasuryWithdrawal: TSchema.NullOr(TreasuryWithdrawalSchema),
17
- });
18
-
19
- export type ExecuteDatum = typeof ExecuteDatumSchema.Type;
20
-
21
- export function serialiseExecuteDatum(d: ExecuteDatum): string {
22
- return Data.withSchema(ExecuteDatumSchema).toCBORHex(d);
23
- }
24
-
25
- export function parseExecuteDatum(datum: string): O.Option<ExecuteDatum> {
26
- try {
27
- return O.some(
28
- Data.withSchema(ExecuteDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
29
- datum,
30
- ),
31
- );
32
- } catch (_) {
33
- return O.none;
34
- }
35
- }
36
-
37
- export function parseExecuteDatumOrThrow(datum: string): ExecuteDatum {
38
- return F.pipe(
39
- parseExecuteDatum(datum),
40
- O.match(() => {
41
- throw new Error('Expected an Execute datum.');
42
- }, F.identity),
43
- );
44
- }