@indigo-labs/indigo-sdk 0.5.4 → 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.
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +17 -0
- package/dist/index.mjs +15 -0
- package/package.json +11 -1
- package/.claude/settings.local.json +0 -7
- package/.github/workflows/ci.yml +0 -66
- package/.husky/pre-commit +0 -1
- package/.nvmrc +0 -1
- package/.prettierignore +0 -1
- package/.prettierrc +0 -6
- package/eslint.config.mjs +0 -42
- package/scripts/bench.sh +0 -62
- package/scripts/run-repeat.sh +0 -22
- package/src/contracts/cdp/helpers.ts +0 -173
- package/src/contracts/cdp/scripts.ts +0 -70
- package/src/contracts/cdp/transactions.ts +0 -1584
- package/src/contracts/cdp/types-new.ts +0 -277
- package/src/contracts/cdp/types.ts +0 -43
- package/src/contracts/cdp-creator/queries.ts +0 -30
- package/src/contracts/cdp-creator/scripts.ts +0 -45
- package/src/contracts/cdp-creator/types-new.ts +0 -50
- package/src/contracts/cdp-creator/types.ts +0 -24
- package/src/contracts/collector/scripts.ts +0 -32
- package/src/contracts/collector/transactions.ts +0 -50
- package/src/contracts/collector/types-new.ts +0 -17
- package/src/contracts/execute/scripts.ts +0 -57
- package/src/contracts/execute/types-new.ts +0 -44
- package/src/contracts/execute/types.ts +0 -24
- package/src/contracts/gov/helpers.ts +0 -351
- package/src/contracts/gov/scripts.ts +0 -41
- package/src/contracts/gov/transactions.ts +0 -1607
- package/src/contracts/gov/types-new.ts +0 -268
- package/src/contracts/gov/types.ts +0 -22
- package/src/contracts/iasset/helpers.ts +0 -170
- package/src/contracts/iasset/queries.ts +0 -102
- package/src/contracts/iasset/scripts.ts +0 -38
- package/src/contracts/iasset/types.ts +0 -154
- package/src/contracts/initialize/actions.ts +0 -789
- package/src/contracts/initialize/helpers.ts +0 -616
- package/src/contracts/initialize/types.ts +0 -116
- package/src/contracts/interest-collection/helpers.ts +0 -19
- package/src/contracts/interest-collection/queries.ts +0 -66
- package/src/contracts/interest-collection/scripts.ts +0 -44
- package/src/contracts/interest-collection/transactions.ts +0 -433
- package/src/contracts/interest-collection/types-new.ts +0 -50
- package/src/contracts/interest-collection/types.ts +0 -26
- package/src/contracts/interest-oracle/helpers.ts +0 -61
- package/src/contracts/interest-oracle/scripts.ts +0 -18
- package/src/contracts/interest-oracle/transactions.ts +0 -151
- package/src/contracts/interest-oracle/types-new.ts +0 -32
- package/src/contracts/interest-oracle/types.ts +0 -16
- package/src/contracts/one-shot/scripts.ts +0 -12
- package/src/contracts/one-shot/transactions.ts +0 -66
- package/src/contracts/one-shot/types.ts +0 -22
- package/src/contracts/poll/helpers.ts +0 -37
- package/src/contracts/poll/scripts.ts +0 -71
- package/src/contracts/poll/types-poll-manager.ts +0 -20
- package/src/contracts/poll/types-poll-new.ts +0 -196
- package/src/contracts/poll/types-poll-shard.ts +0 -16
- package/src/contracts/price-oracle/helpers.ts +0 -30
- package/src/contracts/price-oracle/scripts.ts +0 -18
- package/src/contracts/price-oracle/transactions.ts +0 -115
- package/src/contracts/price-oracle/types-new.ts +0 -50
- package/src/contracts/price-oracle/types.ts +0 -16
- package/src/contracts/pyth-feed/helpers.ts +0 -82
- package/src/contracts/pyth-feed/scripts.ts +0 -15
- package/src/contracts/pyth-feed/types.ts +0 -181
- package/src/contracts/rob/helpers.ts +0 -666
- package/src/contracts/rob/scripts.ts +0 -35
- package/src/contracts/rob/transactions.ts +0 -423
- package/src/contracts/rob/types-new.ts +0 -128
- package/src/contracts/rob/types.ts +0 -16
- package/src/contracts/rob-leverage/helpers.ts +0 -422
- package/src/contracts/rob-leverage/transactions.ts +0 -368
- package/src/contracts/stability-pool/helpers.ts +0 -798
- package/src/contracts/stability-pool/queries.ts +0 -132
- package/src/contracts/stability-pool/scripts.ts +0 -51
- package/src/contracts/stability-pool/transactions.ts +0 -921
- package/src/contracts/stability-pool/types-new.ts +0 -385
- package/src/contracts/stability-pool/types.ts +0 -25
- package/src/contracts/stableswap/helpers.ts +0 -507
- package/src/contracts/stableswap/scripts.ts +0 -37
- package/src/contracts/stableswap/transactions.ts +0 -475
- package/src/contracts/stableswap/types-new.ts +0 -131
- package/src/contracts/stableswap/types.ts +0 -17
- package/src/contracts/staking/helpers.ts +0 -136
- package/src/contracts/staking/scripts.ts +0 -41
- package/src/contracts/staking/transactions.ts +0 -349
- package/src/contracts/staking/types-new.ts +0 -137
- package/src/contracts/staking/types.ts +0 -17
- package/src/contracts/treasury/helpers.ts +0 -21
- package/src/contracts/treasury/queries.ts +0 -100
- package/src/contracts/treasury/scripts.ts +0 -27
- package/src/contracts/treasury/transactions.ts +0 -334
- package/src/contracts/treasury/types-new.ts +0 -69
- package/src/contracts/treasury/types.ts +0 -14
- package/src/contracts/version-registry/scripts.ts +0 -29
- package/src/contracts/version-registry/types-new.ts +0 -18
- package/src/contracts/version-registry/types.ts +0 -17
- package/src/index.ts +0 -93
- package/src/scripts/always-fail-validator.ts +0 -7
- package/src/scripts/auth-token-policy.ts +0 -24
- package/src/scripts/iasset-policy.ts +0 -23
- package/src/types/evolution-schema-options.ts +0 -16
- package/src/types/generic.ts +0 -52
- package/src/types/multisig.ts +0 -48
- package/src/types/on-chain-decimal.ts +0 -57
- package/src/types/rational.ts +0 -61
- package/src/types/system-params.ts +0 -463
- package/src/utils/array-utils.ts +0 -108
- package/src/utils/bigint-utils.ts +0 -35
- package/src/utils/helper-txs.ts +0 -31
- package/src/utils/indigo-helpers.ts +0 -17
- package/src/utils/lucid-utils.ts +0 -125
- package/src/utils/oracle-helpers.ts +0 -62
- package/src/utils/pyth/decode.ts +0 -223
- package/src/utils/pyth/encode.ts +0 -262
- package/src/utils/pyth/index.ts +0 -14
- package/src/utils/pyth/types.ts +0 -87
- package/src/utils/time-helpers.ts +0 -4
- package/src/utils/utils.ts +0 -25
- package/src/validators/always-succeed-validator.ts +0 -6
- package/src/validators/cdp-creator-validator.ts +0 -7
- package/src/validators/cdp-redeem-validator.ts +0 -7
- package/src/validators/cdp-validator.ts +0 -7
- package/src/validators/collector-validator.ts +0 -7
- package/src/validators/execute-validator.ts +0 -7
- package/src/validators/governance-validator.ts +0 -7
- package/src/validators/iasset-validator.ts +0 -7
- package/src/validators/interest-collection-validator.ts +0 -7
- package/src/validators/interest-oracle-validator.ts +0 -7
- package/src/validators/one-shot-policy.ts +0 -7
- package/src/validators/poll-manager-validator.ts +0 -7
- package/src/validators/poll-shard-validator.ts +0 -7
- package/src/validators/price-oracle-validator.ts +0 -7
- package/src/validators/pyth-feed-validator.ts +0 -7
- package/src/validators/rob-validator.ts +0 -7
- package/src/validators/stability-pool-validator.ts +0 -7
- package/src/validators/stableswap-validator.ts +0 -7
- package/src/validators/staking-validator.ts +0 -7
- package/src/validators/treasury-validator.ts +0 -7
- package/src/validators/version-record-policy.ts +0 -7
- package/src/validators/version-registry-validator.ts +0 -7
- package/tests/always-succeed/script.ts +0 -7
- package/tests/array-utils.test.ts +0 -92
- package/tests/bigint-utils.test.ts +0 -41
- package/tests/cdp/actions.ts +0 -680
- package/tests/cdp/cdp-helpers.ts +0 -55
- package/tests/cdp/cdp-queries.ts +0 -423
- package/tests/cdp/cdp.test.ts +0 -6730
- package/tests/cdp/transactions-mutated.ts +0 -1733
- package/tests/data/system-params.json +0 -1155
- package/tests/datums.test.ts +0 -302
- package/tests/endpoints/initialize.ts +0 -78
- package/tests/endpoints/interest-collector.ts +0 -37
- package/tests/endpoints/treasury.ts +0 -70
- package/tests/gov/actions.ts +0 -381
- package/tests/gov/gov.test.ts +0 -5147
- package/tests/gov/governance-queries.ts +0 -37
- package/tests/hash-checks.test.ts +0 -112
- package/tests/indigo-test-helpers.ts +0 -99
- package/tests/initialize.test.ts +0 -79
- package/tests/interest-calculations.test.ts +0 -120
- package/tests/interest-collection/interest-collection.test.ts +0 -843
- package/tests/interest-collection/transactions-mutated.ts +0 -260
- package/tests/interest-oracle.test.ts +0 -93
- package/tests/mock/assets-mock.ts +0 -243
- package/tests/mock/protocol-params-mock.ts +0 -21
- package/tests/price-oracle/actions.ts +0 -161
- package/tests/price-oracle/price-oracle-queries.ts +0 -12
- package/tests/price-oracle/price-oracle.test.ts +0 -228
- package/tests/price-oracle/transactions-mutated.ts +0 -59
- package/tests/pyth/endpoints.ts +0 -96
- package/tests/pyth/helpers.ts +0 -37
- package/tests/pyth/pyth-encoding.test.ts +0 -376
- package/tests/pyth/pyth-feeds.test.ts +0 -943
- package/tests/pyth/pyth-indigo.test.ts +0 -505
- package/tests/pyth/pyth.test.ts +0 -299
- package/tests/queries/collector-queries.ts +0 -27
- package/tests/queries/execute-queries.ts +0 -47
- package/tests/queries/iasset-queries.ts +0 -149
- package/tests/queries/interest-oracle-queries.ts +0 -12
- package/tests/queries/poll-queries.ts +0 -97
- package/tests/queries/staking-queries.ts +0 -54
- package/tests/rob/actions.ts +0 -56
- package/tests/rob/rob-leverage.test.ts +0 -2555
- package/tests/rob/rob-queries.ts +0 -95
- package/tests/rob/rob.test.ts +0 -3677
- package/tests/rob/transactions-mutated.ts +0 -844
- package/tests/script-size.test.ts +0 -240
- package/tests/setup.ts +0 -135
- package/tests/stability-pool/actions.ts +0 -229
- package/tests/stability-pool.test.ts +0 -6491
- package/tests/stableswap/stableswap-actions.ts +0 -83
- package/tests/stableswap/stableswap-queries.ts +0 -98
- package/tests/stableswap/stableswap.test.ts +0 -4471
- package/tests/stableswap/transactions-mutated.ts +0 -348
- package/tests/staking.test.ts +0 -172
- package/tests/test-helpers.ts +0 -94
- package/tests/treasury/actions.ts +0 -67
- package/tests/treasury/treasury.test.ts +0 -320
- package/tests/utils/asserts.ts +0 -87
- package/tests/utils/benchmark-utils.ts +0 -130
- package/tests/utils/index.ts +0 -168
- package/tsconfig.build.json +0 -4
- package/tsconfig.json +0 -27
- package/vitest.config.ts +0 -11
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
import { TSchema, Data } from '@evolution-sdk/evolution';
|
|
2
|
-
import { match, P } from 'ts-pattern';
|
|
3
|
-
import { option as O, function as F } from 'fp-ts';
|
|
4
|
-
|
|
5
|
-
import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
|
|
6
|
-
import {
|
|
7
|
-
AddressSchema,
|
|
8
|
-
AssetClassSchema,
|
|
9
|
-
OutputReferenceSchema,
|
|
10
|
-
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
11
|
-
import {
|
|
12
|
-
divideOnChainCompatible,
|
|
13
|
-
zeroNegatives,
|
|
14
|
-
} from '../../utils/bigint-utils';
|
|
15
|
-
|
|
16
|
-
export const SPIntegerSchema = TSchema.Struct({
|
|
17
|
-
value: TSchema.Integer,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export type SPInteger = typeof SPIntegerSchema.Type;
|
|
21
|
-
|
|
22
|
-
const AccountActionSchema = TSchema.Union(
|
|
23
|
-
TSchema.Literal('Create', { flatInUnion: true }),
|
|
24
|
-
TSchema.Struct(
|
|
25
|
-
{
|
|
26
|
-
Adjust: TSchema.Struct(
|
|
27
|
-
{
|
|
28
|
-
amount: TSchema.Integer,
|
|
29
|
-
outputAddress: AddressSchema,
|
|
30
|
-
},
|
|
31
|
-
{ flatFields: true },
|
|
32
|
-
),
|
|
33
|
-
},
|
|
34
|
-
{ flatInUnion: true },
|
|
35
|
-
),
|
|
36
|
-
TSchema.Struct(
|
|
37
|
-
{
|
|
38
|
-
Close: TSchema.Struct(
|
|
39
|
-
{ outputAddress: AddressSchema, maxTxFee: TSchema.Integer },
|
|
40
|
-
{ flatFields: true },
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
|
-
{ flatInUnion: true },
|
|
44
|
-
),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
export type AccountAction = typeof AccountActionSchema.Type;
|
|
48
|
-
|
|
49
|
-
const SumSnapshotSchema = TSchema.Struct({
|
|
50
|
-
sumVal: SPIntegerSchema,
|
|
51
|
-
isLastInEpoch: TSchema.Boolean,
|
|
52
|
-
isFirstSnapshot: TSchema.Boolean,
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export type SumSnapshot = typeof SumSnapshotSchema.Type;
|
|
56
|
-
|
|
57
|
-
const EpochToScaleKeySchema = TSchema.Struct({
|
|
58
|
-
epoch: TSchema.Integer,
|
|
59
|
-
scale: TSchema.Integer,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export type EpochToScaleKey = typeof EpochToScaleKeySchema.Type;
|
|
63
|
-
|
|
64
|
-
const EpochToScaleToSumEntrySchema = TSchema.Tuple([
|
|
65
|
-
EpochToScaleKeySchema,
|
|
66
|
-
SumSnapshotSchema,
|
|
67
|
-
]);
|
|
68
|
-
|
|
69
|
-
export type EpochToScaleToSumEntry = typeof EpochToScaleToSumEntrySchema.Type;
|
|
70
|
-
|
|
71
|
-
const StateSnapshotSchema = TSchema.Struct({
|
|
72
|
-
productVal: SPIntegerSchema,
|
|
73
|
-
depositVal: SPIntegerSchema,
|
|
74
|
-
epoch: TSchema.Integer,
|
|
75
|
-
scale: TSchema.Integer,
|
|
76
|
-
});
|
|
77
|
-
export type StateSnapshot = typeof StateSnapshotSchema.Type;
|
|
78
|
-
|
|
79
|
-
const AssetSnapshotSchema = TSchema.Struct({
|
|
80
|
-
currentSumVal: SPIntegerSchema,
|
|
81
|
-
epoch2scale2sum: TSchema.Array(EpochToScaleToSumEntrySchema),
|
|
82
|
-
});
|
|
83
|
-
export type AssetSnapshot = typeof AssetSnapshotSchema.Type;
|
|
84
|
-
|
|
85
|
-
const AssetStateSchema = TSchema.Tuple([AssetClassSchema, AssetSnapshotSchema]);
|
|
86
|
-
export type AssetState = typeof AssetStateSchema.Type;
|
|
87
|
-
|
|
88
|
-
export const StabilityPoolContentSchema = TSchema.Struct({
|
|
89
|
-
iasset: TSchema.ByteArray,
|
|
90
|
-
state: StateSnapshotSchema,
|
|
91
|
-
assetStates: TSchema.Array(AssetStateSchema),
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
export type StabilityPoolContent = typeof StabilityPoolContentSchema.Type;
|
|
95
|
-
|
|
96
|
-
export const AccountContentSchema = TSchema.Struct({
|
|
97
|
-
owner: TSchema.ByteArray,
|
|
98
|
-
iasset: TSchema.ByteArray,
|
|
99
|
-
state: StateSnapshotSchema,
|
|
100
|
-
assetSums: TSchema.Array(TSchema.Tuple([AssetClassSchema, SPIntegerSchema])),
|
|
101
|
-
request: TSchema.NullOr(AccountActionSchema),
|
|
102
|
-
lastRequestProcessingTime: TSchema.Integer,
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export type AccountContent = typeof AccountContentSchema.Type;
|
|
106
|
-
|
|
107
|
-
export const SnapshotEpochToScaleToSumContentSchema = TSchema.Struct({
|
|
108
|
-
snapshot: TSchema.Array(EpochToScaleToSumEntrySchema),
|
|
109
|
-
iasset: TSchema.ByteArray,
|
|
110
|
-
collateralAsset: AssetClassSchema,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
export type SnapshotEpochToScaleToSumContent =
|
|
114
|
-
typeof SnapshotEpochToScaleToSumContentSchema.Type;
|
|
115
|
-
|
|
116
|
-
export const StabilityPoolDatumSchema = TSchema.Union(
|
|
117
|
-
TSchema.Struct(
|
|
118
|
-
{ StabilityPool: StabilityPoolContentSchema },
|
|
119
|
-
{ flatInUnion: true },
|
|
120
|
-
),
|
|
121
|
-
TSchema.Struct({ Account: AccountContentSchema }, { flatInUnion: true }),
|
|
122
|
-
TSchema.Struct(
|
|
123
|
-
{ SnapshotEpochToScaleToSum: SnapshotEpochToScaleToSumContentSchema },
|
|
124
|
-
{ flatInUnion: true },
|
|
125
|
-
),
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const E2S2SIndexSchema = TSchema.Union(
|
|
129
|
-
TSchema.Struct(
|
|
130
|
-
{ StabilityPoolListIdx: TSchema.Integer },
|
|
131
|
-
{ flatInUnion: true },
|
|
132
|
-
),
|
|
133
|
-
TSchema.Struct(
|
|
134
|
-
{
|
|
135
|
-
RefInputIdx: TSchema.Struct(
|
|
136
|
-
{
|
|
137
|
-
refInputIdx: TSchema.Integer,
|
|
138
|
-
snapshotListIdx: TSchema.Integer,
|
|
139
|
-
},
|
|
140
|
-
{ flatFields: true },
|
|
141
|
-
),
|
|
142
|
-
},
|
|
143
|
-
{ flatInUnion: true },
|
|
144
|
-
),
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
export type E2S2SIndex = typeof E2S2SIndexSchema.Type;
|
|
148
|
-
|
|
149
|
-
const E2S2SIndicesPerAssetSchema = TSchema.Array(
|
|
150
|
-
TSchema.Tuple([E2S2SIndexSchema, TSchema.NullOr(E2S2SIndexSchema)]),
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
export type E2S2SIndicesPerAsset = typeof E2S2SIndicesPerAssetSchema.Type;
|
|
154
|
-
|
|
155
|
-
const ProcessRequestAccountContentSchema = TSchema.Struct(
|
|
156
|
-
{
|
|
157
|
-
poolInputIdx: TSchema.Integer,
|
|
158
|
-
accountInputIdx: TSchema.Integer,
|
|
159
|
-
e2s2sIdxs: E2S2SIndicesPerAssetSchema,
|
|
160
|
-
currentTime: TSchema.Integer,
|
|
161
|
-
},
|
|
162
|
-
{ flatFields: true },
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
export type ProcessRequestAccountContent =
|
|
166
|
-
typeof ProcessRequestAccountContentSchema.Type;
|
|
167
|
-
|
|
168
|
-
export const StabilityPoolRedeemerSchema = TSchema.Union(
|
|
169
|
-
TSchema.Struct({ RequestAction: AccountActionSchema }, { flatInUnion: true }),
|
|
170
|
-
TSchema.Struct(
|
|
171
|
-
{
|
|
172
|
-
ProcessRequestPool: TSchema.Struct(
|
|
173
|
-
{
|
|
174
|
-
poolInputIdx: TSchema.Integer,
|
|
175
|
-
accountInputIdx: TSchema.Integer,
|
|
176
|
-
},
|
|
177
|
-
{ flatFields: true },
|
|
178
|
-
),
|
|
179
|
-
},
|
|
180
|
-
{ flatInUnion: true },
|
|
181
|
-
),
|
|
182
|
-
TSchema.Struct(
|
|
183
|
-
{
|
|
184
|
-
ProcessRequestAccount: ProcessRequestAccountContentSchema,
|
|
185
|
-
},
|
|
186
|
-
{ flatInUnion: true },
|
|
187
|
-
),
|
|
188
|
-
TSchema.Literal('AnnulRequest', { flatInUnion: true }),
|
|
189
|
-
TSchema.Struct(
|
|
190
|
-
{
|
|
191
|
-
LiquidateCDP: TSchema.Struct(
|
|
192
|
-
{
|
|
193
|
-
cdpIdx: TSchema.Integer,
|
|
194
|
-
},
|
|
195
|
-
{ flatFields: true },
|
|
196
|
-
),
|
|
197
|
-
},
|
|
198
|
-
{ flatInUnion: true },
|
|
199
|
-
),
|
|
200
|
-
TSchema.Literal('RecordEpochToScaleToSum', { flatInUnion: true }),
|
|
201
|
-
TSchema.Literal('UpgradeVersion', { flatInUnion: true }),
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
export type StabilityPoolRedeemer = typeof StabilityPoolRedeemerSchema.Type;
|
|
205
|
-
|
|
206
|
-
const ActionReturnDatumSchema = TSchema.Union(
|
|
207
|
-
TSchema.Struct(
|
|
208
|
-
{
|
|
209
|
-
IndigoStabilityPoolAccountAdjustment: OutputReferenceSchema,
|
|
210
|
-
},
|
|
211
|
-
{ flatInUnion: true },
|
|
212
|
-
),
|
|
213
|
-
TSchema.Struct(
|
|
214
|
-
{
|
|
215
|
-
IndigoStabilityPoolAccountClosure: OutputReferenceSchema,
|
|
216
|
-
},
|
|
217
|
-
{ flatInUnion: true },
|
|
218
|
-
),
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
export type ActionReturnDatum = typeof ActionReturnDatumSchema.Type;
|
|
222
|
-
|
|
223
|
-
export function serialiseActionReturnDatum(d: ActionReturnDatum): string {
|
|
224
|
-
return Data.withSchema(
|
|
225
|
-
ActionReturnDatumSchema,
|
|
226
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
227
|
-
).toCBORHex(d);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export function serialiseStabilityPoolRedeemer(
|
|
231
|
-
r: StabilityPoolRedeemer,
|
|
232
|
-
): string {
|
|
233
|
-
return Data.withSchema(
|
|
234
|
-
StabilityPoolRedeemerSchema,
|
|
235
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
236
|
-
).toCBORHex(r);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function parseStabilityPoolRedeemer(
|
|
240
|
-
datum: string,
|
|
241
|
-
): O.Option<StabilityPoolRedeemer> {
|
|
242
|
-
try {
|
|
243
|
-
return O.some(
|
|
244
|
-
Data.withSchema(
|
|
245
|
-
StabilityPoolRedeemerSchema,
|
|
246
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
247
|
-
).fromCBORHex(datum),
|
|
248
|
-
);
|
|
249
|
-
} catch (_) {
|
|
250
|
-
return O.none;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export function parseStabilityPoolRedeemerOrThrow(
|
|
255
|
-
datum: string,
|
|
256
|
-
): StabilityPoolRedeemer {
|
|
257
|
-
return F.pipe(
|
|
258
|
-
parseStabilityPoolRedeemer(datum),
|
|
259
|
-
O.match(() => {
|
|
260
|
-
throw new Error('Expected a StabilityPoolRedeemer datum.');
|
|
261
|
-
}, F.identity),
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
export function serialiseStabilityPoolDatum(
|
|
266
|
-
d: typeof StabilityPoolDatumSchema.Type,
|
|
267
|
-
/**
|
|
268
|
-
* This is necessary to change only in case of execute propose asset.
|
|
269
|
-
*/
|
|
270
|
-
useIndefiniteMaps: boolean = false,
|
|
271
|
-
): string {
|
|
272
|
-
return Data.withSchema(StabilityPoolDatumSchema, {
|
|
273
|
-
...DEFAULT_SCHEMA_OPTIONS,
|
|
274
|
-
useIndefiniteMaps: useIndefiniteMaps,
|
|
275
|
-
}).toCBORHex(d);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
export function parseStabilityPoolDatum(
|
|
279
|
-
datum: string,
|
|
280
|
-
): O.Option<StabilityPoolContent> {
|
|
281
|
-
try {
|
|
282
|
-
return match(
|
|
283
|
-
Data.withSchema(
|
|
284
|
-
StabilityPoolDatumSchema,
|
|
285
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
286
|
-
).fromCBORHex(datum),
|
|
287
|
-
)
|
|
288
|
-
.with({ StabilityPool: P.select() }, (res) => O.some(res))
|
|
289
|
-
.otherwise(() => O.none);
|
|
290
|
-
} catch (_) {
|
|
291
|
-
return O.none;
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
export function parseStabilityPoolDatumOrThrow(
|
|
295
|
-
datum: string,
|
|
296
|
-
): StabilityPoolContent {
|
|
297
|
-
return F.pipe(
|
|
298
|
-
parseStabilityPoolDatum(datum),
|
|
299
|
-
O.match(() => {
|
|
300
|
-
throw new Error('Expected stability pool datum.');
|
|
301
|
-
}, F.identity),
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
export function parseAccountDatum(datum: string): O.Option<AccountContent> {
|
|
306
|
-
try {
|
|
307
|
-
return match(
|
|
308
|
-
Data.withSchema(
|
|
309
|
-
StabilityPoolDatumSchema,
|
|
310
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
311
|
-
).fromCBORHex(datum),
|
|
312
|
-
)
|
|
313
|
-
.with({ Account: P.select() }, (res) => O.some(res))
|
|
314
|
-
.otherwise(() => O.none);
|
|
315
|
-
} catch (_) {
|
|
316
|
-
return O.none;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
export function parseAccountDatumOrThrow(datum: string): AccountContent {
|
|
320
|
-
return F.pipe(
|
|
321
|
-
parseAccountDatum(datum),
|
|
322
|
-
O.match(() => {
|
|
323
|
-
throw new Error('Expected account datum.');
|
|
324
|
-
}, F.identity),
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
export function parseSnapshotEpochToScaleToSumDatum(
|
|
329
|
-
datum: string,
|
|
330
|
-
): O.Option<SnapshotEpochToScaleToSumContent> {
|
|
331
|
-
try {
|
|
332
|
-
return match(
|
|
333
|
-
Data.withSchema(
|
|
334
|
-
StabilityPoolDatumSchema,
|
|
335
|
-
DEFAULT_SCHEMA_OPTIONS,
|
|
336
|
-
).fromCBORHex(datum),
|
|
337
|
-
)
|
|
338
|
-
.with({ SnapshotEpochToScaleToSum: P.select() }, (res) => O.some(res))
|
|
339
|
-
.otherwise(() => O.none);
|
|
340
|
-
} catch (_) {
|
|
341
|
-
return O.none;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function parseSnapshotEpochToScaleToSumDatumOrThrow(
|
|
346
|
-
datum: string,
|
|
347
|
-
): SnapshotEpochToScaleToSumContent {
|
|
348
|
-
return F.pipe(
|
|
349
|
-
parseSnapshotEpochToScaleToSumDatum(datum),
|
|
350
|
-
O.match(() => {
|
|
351
|
-
throw new Error('Expected snapshot e2s2s datum.');
|
|
352
|
-
}, F.identity),
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
/** SP Integer */
|
|
357
|
-
const spPrecision: bigint = 1_000_000_000_000_000_000n;
|
|
358
|
-
|
|
359
|
-
export function mkSPInteger(value: bigint): SPInteger {
|
|
360
|
-
return { value: value * spPrecision };
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
export function fromSPInteger(value: SPInteger): bigint {
|
|
364
|
-
return divideOnChainCompatible(value.value, spPrecision);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
export function spAdd(a: SPInteger, b: SPInteger): SPInteger {
|
|
368
|
-
return { value: a.value + b.value };
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export function spSub(a: SPInteger, b: SPInteger): SPInteger {
|
|
372
|
-
return { value: a.value - b.value };
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export function spMul(a: SPInteger, b: SPInteger): SPInteger {
|
|
376
|
-
return { value: divideOnChainCompatible(a.value * b.value, spPrecision) };
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
export function spDiv(a: SPInteger, b: SPInteger): SPInteger {
|
|
380
|
-
return { value: divideOnChainCompatible(a.value * spPrecision, b.value) };
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
export function spZeroNegatives(a: SPInteger): SPInteger {
|
|
384
|
-
return { value: zeroNegatives(a.value) };
|
|
385
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Data } from '@lucid-evolution/lucid';
|
|
2
|
-
import { AssetClassSchema, StakeCredentialSchema } from '../../types/generic';
|
|
3
|
-
|
|
4
|
-
/** SP Parameters */
|
|
5
|
-
const StabilityPoolParamsSchema = Data.Object({
|
|
6
|
-
assetSymbol: Data.Bytes(),
|
|
7
|
-
stabilityPoolToken: AssetClassSchema,
|
|
8
|
-
snapshotEpochToScaleToSumToken: AssetClassSchema,
|
|
9
|
-
accountToken: AssetClassSchema,
|
|
10
|
-
cdpToken: AssetClassSchema,
|
|
11
|
-
iAssetAuthToken: AssetClassSchema,
|
|
12
|
-
versionRecordToken: AssetClassSchema,
|
|
13
|
-
iassetValHash: Data.Bytes(),
|
|
14
|
-
accountCreateFeeLovelaces: Data.Integer(),
|
|
15
|
-
accountProcessingCooldownMs: Data.Integer(),
|
|
16
|
-
accountProcessingBiasMs: Data.Integer(),
|
|
17
|
-
stakeCredential: Data.Nullable(StakeCredentialSchema),
|
|
18
|
-
});
|
|
19
|
-
export type StabilityPoolParams = Data.Static<typeof StabilityPoolParamsSchema>;
|
|
20
|
-
export const StabilityPoolParams =
|
|
21
|
-
StabilityPoolParamsSchema as unknown as StabilityPoolParams;
|
|
22
|
-
|
|
23
|
-
export function castStabilityPoolParams(params: StabilityPoolParams): Data {
|
|
24
|
-
return Data.castTo(params, StabilityPoolParams);
|
|
25
|
-
}
|