@indigo-labs/indigo-sdk 0.1.7 → 0.1.8
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/.github/workflows/ci.yml +62 -0
- package/.github/workflows/test.yml +44 -0
- package/.husky/pre-commit +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc +6 -0
- package/dist/index.d.mts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +15 -0
- package/dist/index.mjs +14 -0
- package/eslint.config.mjs +36 -0
- package/package.json +2 -5
- package/src/contracts/cdp.ts +741 -0
- package/src/contracts/collector.ts +98 -0
- package/src/contracts/gov.ts +1 -0
- package/src/contracts/interest-oracle.ts +149 -0
- package/src/contracts/lrp.ts +315 -0
- package/src/contracts/one-shot.ts +67 -0
- package/src/contracts/stability-pool.ts +684 -0
- package/src/contracts/staking.ts +348 -0
- package/src/contracts/treasury.ts +112 -0
- package/src/helpers/asset-helpers.ts +57 -0
- package/src/helpers/helper-txs.ts +30 -0
- package/src/helpers/helpers.ts +38 -0
- package/src/helpers/indigo-helpers.ts +19 -0
- package/src/helpers/interest-oracle.ts +57 -0
- package/src/helpers/lucid-utils.ts +70 -0
- package/src/helpers/price-oracle-helpers.ts +36 -0
- package/src/helpers/stability-pool-helpers.ts +207 -0
- package/src/helpers/staking-helpers.ts +94 -0
- package/src/helpers/time-helpers.ts +4 -0
- package/src/helpers/value-helpers.ts +27 -0
- package/src/index.ts +34 -0
- package/src/scripts/always-fail-validator.ts +7 -0
- package/src/scripts/auth-token-policy.ts +23 -0
- package/src/scripts/cdp-creator-validator.ts +53 -0
- package/src/scripts/cdp-validator.ts +9 -0
- package/src/scripts/collector-validator.ts +8 -0
- package/src/scripts/execute-validator.ts +52 -0
- package/src/scripts/gov-validator.ts +44 -0
- package/src/scripts/iasset-policy.ts +22 -0
- package/src/scripts/interest-oracle-validator.ts +23 -0
- package/src/scripts/lrp-validator.ts +40 -0
- package/src/scripts/one-shot-policy.ts +62 -0
- package/src/scripts/poll-manager-validator.ts +52 -0
- package/src/scripts/poll-shard-validator.ts +47 -0
- package/src/scripts/price-oracle-validator.ts +26 -0
- package/src/scripts/stability-pool-validator.ts +60 -0
- package/src/scripts/staking-validator.ts +8 -0
- package/src/scripts/treasury-validator.ts +8 -0
- package/src/scripts/version-record-policy.ts +26 -0
- package/src/scripts/version-registry.ts +15 -0
- package/src/types/generic.ts +106 -0
- package/src/types/indigo/cdp-creator.ts +46 -0
- package/src/types/indigo/cdp.ts +88 -0
- package/src/types/indigo/execute.ts +21 -0
- package/src/types/indigo/gov.ts +51 -0
- package/src/types/indigo/interest-oracle.ts +55 -0
- package/src/types/indigo/lrp.ts +59 -0
- package/src/types/indigo/poll-manager.ts +21 -0
- package/src/types/indigo/poll-shard.ts +16 -0
- package/src/types/indigo/price-oracle.ts +38 -0
- package/src/types/indigo/stability-pool.ts +233 -0
- package/src/types/indigo/staking.ts +99 -0
- package/src/types/indigo/version-record.ts +17 -0
- package/src/types/on-chain-decimal.ts +23 -0
- package/src/types/one-shot.ts +22 -0
- package/src/types/system-params.ts +256 -0
- package/tests/data/system-params.json +1012 -0
- package/tests/datums.test.ts +286 -0
- package/tests/endpoints/initialize.ts +1013 -0
- package/tests/hash-checks.test.ts +80 -0
- package/tests/indigo-test-helpers.ts +115 -0
- package/tests/initialize.test.ts +27 -0
- package/tests/interest-calculations.test.ts +120 -0
- package/tests/interest-oracle.test.ts +90 -0
- package/tests/lrp.test.ts +777 -0
- package/tests/queries/governance-queries.ts +31 -0
- package/tests/queries/iasset-queries.ts +39 -0
- package/tests/queries/interest-oracle-queries.ts +13 -0
- package/tests/queries/lrp-queries.ts +39 -0
- package/tests/queries/price-oracle-queries.ts +27 -0
- package/tests/queries/stability-pool-queries.ts +75 -0
- package/tests/queries/staking-queries.ts +43 -0
- package/tests/stability-pool.test.ts +364 -0
- package/tests/staking.test.ts +105 -0
- package/tests/test-helpers.ts +38 -0
- package/tsconfig.build.json +4 -0
- package/tsconfig.json +17 -0
- package/vitest.config.ts +9 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { fromText, toText } from '@lucid-evolution/lucid';
|
|
2
|
+
import { AssetClass, CurrencySymbol, TokenName } from './generic';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AssetClassSP used in System Params
|
|
6
|
+
*/
|
|
7
|
+
export type AssetClassSP = [CurrencySymbol, TokenName];
|
|
8
|
+
|
|
9
|
+
export interface SystemParams {
|
|
10
|
+
versionRecordParams: VersionRecordParams;
|
|
11
|
+
validatorHashes: ValidatorHashes;
|
|
12
|
+
treasuryParams: TreasuryParams;
|
|
13
|
+
startTime: StartTime;
|
|
14
|
+
stakingParams: StakingParams;
|
|
15
|
+
stabilityPoolParams: StabilityPoolParamsSP;
|
|
16
|
+
scriptReferences: ScriptReferences;
|
|
17
|
+
pollShardParams: PollShardParamsSP;
|
|
18
|
+
pollManagerParams: PollManagerParamsSP;
|
|
19
|
+
lrpParams: LrpParamsSP;
|
|
20
|
+
indyToken: AssetClassSP;
|
|
21
|
+
govParams: GovParamsSP;
|
|
22
|
+
executeParams: ExecuteParamsSP;
|
|
23
|
+
distributionParams: DistributionParams;
|
|
24
|
+
collectorParams: CollectorParams;
|
|
25
|
+
cdpParams: CdpParams;
|
|
26
|
+
cdpCreatorParams: CDPCreatorParamsSP;
|
|
27
|
+
}
|
|
28
|
+
export type ValidatorHashes = {
|
|
29
|
+
versionRegistryHash: string;
|
|
30
|
+
treasuryHash: string;
|
|
31
|
+
stakingHash: string;
|
|
32
|
+
stabilityPoolHash: string;
|
|
33
|
+
pollShardHash: string;
|
|
34
|
+
pollManagerHash: string;
|
|
35
|
+
lrpHash: string;
|
|
36
|
+
govHash: string;
|
|
37
|
+
executeHash: string;
|
|
38
|
+
collectorHash: string;
|
|
39
|
+
cdpHash: string;
|
|
40
|
+
cdpCreatorHash: string;
|
|
41
|
+
};
|
|
42
|
+
export interface AddressCredential {
|
|
43
|
+
tag: string;
|
|
44
|
+
contents: PubKeyHash;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ScriptCredential {
|
|
48
|
+
tag: string;
|
|
49
|
+
contents: {
|
|
50
|
+
tag: string;
|
|
51
|
+
contents: string;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export interface PubKeyHash {
|
|
55
|
+
getPubKeyHash: string;
|
|
56
|
+
}
|
|
57
|
+
export interface VersionRecordParams {
|
|
58
|
+
upgradeToken: AssetClassSP;
|
|
59
|
+
}
|
|
60
|
+
export interface TreasuryParams {
|
|
61
|
+
upgradeToken: AssetClassSP;
|
|
62
|
+
versionRecordToken: AssetClassSP;
|
|
63
|
+
treasuryUtxosStakeCredential?: ScriptCredential;
|
|
64
|
+
}
|
|
65
|
+
export interface StartTime {
|
|
66
|
+
slot: number;
|
|
67
|
+
blockHeader: string;
|
|
68
|
+
}
|
|
69
|
+
export interface StakingParams {
|
|
70
|
+
versionRecordToken: AssetClassSP;
|
|
71
|
+
stakingToken: AssetClassSP;
|
|
72
|
+
stakingManagerNFT: AssetClassSP;
|
|
73
|
+
pollToken: AssetClassSP;
|
|
74
|
+
indyToken: AssetClassSP;
|
|
75
|
+
collectorValHash: string;
|
|
76
|
+
}
|
|
77
|
+
export interface StabilityPoolParamsSP {
|
|
78
|
+
versionRecordToken: AssetClassSP;
|
|
79
|
+
stabilityPoolToken: AssetClassSP;
|
|
80
|
+
snapshotEpochToScaleToSumToken: AssetClassSP;
|
|
81
|
+
requestCollateralLovelaces: number;
|
|
82
|
+
iAssetAuthToken: AssetClassSP;
|
|
83
|
+
govNFT: AssetClassSP;
|
|
84
|
+
collectorValHash: string;
|
|
85
|
+
cdpToken: AssetClassSP;
|
|
86
|
+
assetSymbol: CurrencySymbol;
|
|
87
|
+
accountToken: AssetClassSP;
|
|
88
|
+
accountCreateFeeLovelaces: number;
|
|
89
|
+
accountAdjustmentFeeLovelaces: number;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ScriptReferences {
|
|
93
|
+
vestingValidatorRef: ScriptReference;
|
|
94
|
+
versionRegistryValidatorRef: ScriptReference;
|
|
95
|
+
versionRecordTokenPolicyRef: ScriptReference;
|
|
96
|
+
treasuryValidatorRef: ScriptReference;
|
|
97
|
+
stakingValidatorRef: ScriptReference;
|
|
98
|
+
stabilityPoolValidatorRef: ScriptReference;
|
|
99
|
+
pollShardValidatorRef: ScriptReference;
|
|
100
|
+
pollManagerValidatorRef: ScriptReference;
|
|
101
|
+
lrpValidatorRef: ScriptReference;
|
|
102
|
+
liquidityValidatorRef: ScriptReference;
|
|
103
|
+
iAssetTokenPolicyRef: ScriptReference;
|
|
104
|
+
governanceValidatorRef: ScriptReference;
|
|
105
|
+
executeValidatorRef: ScriptReference;
|
|
106
|
+
collectorValidatorRef: ScriptReference;
|
|
107
|
+
cdpValidatorRef: ScriptReference;
|
|
108
|
+
cdpCreatorValidatorRef: ScriptReference;
|
|
109
|
+
authTokenPolicies: AuthTokenPolicies;
|
|
110
|
+
}
|
|
111
|
+
export interface Output {
|
|
112
|
+
scriptRef: ScriptRef;
|
|
113
|
+
output: ScriptOutput;
|
|
114
|
+
}
|
|
115
|
+
export interface ScriptRef {
|
|
116
|
+
tag: string;
|
|
117
|
+
contents?: string[] | null;
|
|
118
|
+
}
|
|
119
|
+
export interface ScriptOutput {
|
|
120
|
+
referenceScript: string;
|
|
121
|
+
datum: AddressCredentialOrDatum;
|
|
122
|
+
amount: Amount;
|
|
123
|
+
address: AddressSP;
|
|
124
|
+
}
|
|
125
|
+
export interface AddressCredentialOrDatum {
|
|
126
|
+
tag: string;
|
|
127
|
+
contents: string;
|
|
128
|
+
}
|
|
129
|
+
export interface Amount {
|
|
130
|
+
getValue?: ((CurrencySymbol | (number[] | null)[] | null)[] | null)[] | null;
|
|
131
|
+
}
|
|
132
|
+
export interface AddressSP {
|
|
133
|
+
addressStakingCredential?: null;
|
|
134
|
+
addressCredential: AddressCredentialOrDatum;
|
|
135
|
+
}
|
|
136
|
+
export interface Input {
|
|
137
|
+
transactionId: string;
|
|
138
|
+
index: number;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface ScriptReference {
|
|
142
|
+
output?: Output;
|
|
143
|
+
input: Input;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface AuthTokenPolicies {
|
|
147
|
+
upgradeTokenRef: ScriptReference;
|
|
148
|
+
stakingTokenRef: ScriptReference;
|
|
149
|
+
stabilityPoolTokenRef: ScriptReference;
|
|
150
|
+
snapshotEpochToScaleToSumTokenRef: ScriptReference;
|
|
151
|
+
pollManagerTokenRef: ScriptReference;
|
|
152
|
+
iAssetTokenRef: ScriptReference;
|
|
153
|
+
cdpAuthTokenRef: ScriptReference;
|
|
154
|
+
accountTokenRef: ScriptReference;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface LrpParamsSP {
|
|
158
|
+
versionRecordToken: AssetClassSP;
|
|
159
|
+
iassetNft: AssetClassSP;
|
|
160
|
+
iassetPolicyId: CurrencySymbol;
|
|
161
|
+
minRedemptionLovelacesAmt: bigint;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface PollShardParamsSP {
|
|
165
|
+
stakingValHash: string;
|
|
166
|
+
stakingToken: AssetClassSP;
|
|
167
|
+
pollToken: AssetClassSP;
|
|
168
|
+
indyAsset: AssetClassSP;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface PollManagerParamsSP {
|
|
172
|
+
upgradeToken: AssetClassSP;
|
|
173
|
+
treasuryValHash: string;
|
|
174
|
+
shardsValHash: string;
|
|
175
|
+
pollToken: AssetClassSP;
|
|
176
|
+
pBiasTime: bigint;
|
|
177
|
+
initialIndyDistribution: bigint;
|
|
178
|
+
indyAsset: AssetClassSP;
|
|
179
|
+
govNFT: AssetClassSP;
|
|
180
|
+
govExecuteValHash: string;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface GovParamsSP {
|
|
184
|
+
versionRecordToken: AssetClassSP;
|
|
185
|
+
upgradeToken: AssetClassSP;
|
|
186
|
+
pollToken: AssetClassSP;
|
|
187
|
+
pollManagerValHash: string;
|
|
188
|
+
indyAsset: AssetClassSP;
|
|
189
|
+
iAssetAuthToken: AssetClassSP;
|
|
190
|
+
govNFT: AssetClassSP;
|
|
191
|
+
gBiasTime: bigint;
|
|
192
|
+
daoIdentityToken: AssetClassSP;
|
|
193
|
+
}
|
|
194
|
+
export interface ExecuteParamsSP {
|
|
195
|
+
govNFT: AssetClassSP;
|
|
196
|
+
upgradeToken: AssetClassSP;
|
|
197
|
+
iAssetToken: AssetClassSP;
|
|
198
|
+
stabilityPoolToken: AssetClassSP;
|
|
199
|
+
versionRecordToken: AssetClassSP;
|
|
200
|
+
cdpValHash: string;
|
|
201
|
+
sPoolValHash: string;
|
|
202
|
+
versionRegistryValHash: string;
|
|
203
|
+
treasuryValHash: string;
|
|
204
|
+
indyAsset: AssetClassSP;
|
|
205
|
+
}
|
|
206
|
+
export interface DistributionParams {
|
|
207
|
+
treasuryIndyAmount: number;
|
|
208
|
+
totalINDYSupply: number;
|
|
209
|
+
initialIndyDistribution: number;
|
|
210
|
+
}
|
|
211
|
+
export interface CollectorParams {
|
|
212
|
+
versionRecordToken: AssetClassSP;
|
|
213
|
+
stakingToken: AssetClassSP;
|
|
214
|
+
stakingManagerNFT: AssetClassSP;
|
|
215
|
+
}
|
|
216
|
+
export interface CdpParams {
|
|
217
|
+
versionRecordToken: AssetClassSP;
|
|
218
|
+
upgradeToken: AssetClassSP;
|
|
219
|
+
treasuryValHash: string;
|
|
220
|
+
stabilityPoolAuthToken: AssetClassSP;
|
|
221
|
+
spValHash: string;
|
|
222
|
+
partialRedemptionExtraFeeLovelace: number;
|
|
223
|
+
minCollateralInLovelace: number;
|
|
224
|
+
iAssetAuthToken: AssetClassSP;
|
|
225
|
+
govNFT: AssetClassSP;
|
|
226
|
+
collectorValHash: string;
|
|
227
|
+
cdpAuthToken: AssetClassSP;
|
|
228
|
+
cdpAssetSymbol: CurrencySymbol;
|
|
229
|
+
biasTime: number;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface CDPCreatorParamsSP {
|
|
233
|
+
versionRecordToken: AssetClassSP;
|
|
234
|
+
minCollateralInLovelace: number;
|
|
235
|
+
iAssetAuthTk: AssetClassSP;
|
|
236
|
+
collectorValHash: string;
|
|
237
|
+
cdpScriptHash: string;
|
|
238
|
+
cdpCreatorNft: AssetClassSP;
|
|
239
|
+
cdpAuthTk: AssetClassSP;
|
|
240
|
+
cdpAssetCs: CurrencySymbol;
|
|
241
|
+
biasTime: bigint;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export function toSystemParamsAsset(asset: AssetClass): AssetClassSP {
|
|
245
|
+
return [
|
|
246
|
+
{ unCurrencySymbol: asset.currencySymbol },
|
|
247
|
+
{ unTokenName: toText(asset.tokenName) },
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function fromSystemParamsAsset(asset: AssetClassSP): AssetClass {
|
|
252
|
+
return {
|
|
253
|
+
currencySymbol: asset[0].unCurrencySymbol,
|
|
254
|
+
tokenName: fromText(asset[1].unTokenName),
|
|
255
|
+
};
|
|
256
|
+
}
|