@indigo-labs/indigo-sdk 0.1.0
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/.nvmrc +1 -0
- package/.prettierrc +6 -0
- package/README.md +21 -0
- package/babel.config.cjs +13 -0
- package/dist/contracts/cdp-creator.d.ts +9 -0
- package/dist/contracts/cdp-creator.js +58 -0
- package/dist/contracts/cdp.d.ts +22 -0
- package/dist/contracts/cdp.js +542 -0
- package/dist/contracts/collector.d.ts +9 -0
- package/dist/contracts/collector.js +52 -0
- package/dist/contracts/gov.d.ts +5 -0
- package/dist/contracts/gov.js +50 -0
- package/dist/contracts/interest-oracle.d.ts +8 -0
- package/dist/contracts/interest-oracle.js +39 -0
- package/dist/contracts/price-oracle.d.ts +5 -0
- package/dist/contracts/price-oracle.js +18 -0
- package/dist/contracts/treasury.d.ts +9 -0
- package/dist/contracts/treasury.js +56 -0
- package/dist/helpers/asset-helpers.d.ts +11 -0
- package/dist/helpers/asset-helpers.js +23 -0
- package/dist/helpers/cdp-helpers.d.ts +5 -0
- package/dist/helpers/cdp-helpers.js +5 -0
- package/dist/helpers/helpers.d.ts +4 -0
- package/dist/helpers/helpers.js +14 -0
- package/dist/helpers/lucid-utils.d.ts +6 -0
- package/dist/helpers/lucid-utils.js +18 -0
- package/dist/helpers/time-helpers.d.ts +3 -0
- package/dist/helpers/time-helpers.js +3 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/scripts/cdp-creator-validator.d.ts +6 -0
- package/dist/scripts/cdp-creator-validator.js +6 -0
- package/dist/scripts/cdp-validator.d.ts +6 -0
- package/dist/scripts/cdp-validator.js +6 -0
- package/dist/scripts/collector-validator.d.ts +6 -0
- package/dist/scripts/collector-validator.js +5 -0
- package/dist/scripts/interest-oracle-validator.d.ts +6 -0
- package/dist/scripts/interest-oracle-validator.js +5 -0
- package/dist/scripts/treasury-validator.d.ts +6 -0
- package/dist/scripts/treasury-validator.js +5 -0
- package/dist/types/generic.d.ts +10 -0
- package/dist/types/generic.js +1 -0
- package/dist/types/indigo/cdp.d.ts +37 -0
- package/dist/types/indigo/cdp.js +1 -0
- package/dist/types/indigo/gov.d.ts +20 -0
- package/dist/types/indigo/gov.js +1 -0
- package/dist/types/indigo/interest-oracle.d.ts +5 -0
- package/dist/types/indigo/interest-oracle.js +1 -0
- package/dist/types/indigo/price-oracle.d.ts +4 -0
- package/dist/types/indigo/price-oracle.js +1 -0
- package/dist/types/system-params.d.ts +217 -0
- package/dist/types/system-params.js +1 -0
- package/jest.config.js +13 -0
- package/package.json +46 -0
- package/src/contracts/cdp-creator.ts +86 -0
- package/src/contracts/cdp.ts +892 -0
- package/src/contracts/collector.ts +91 -0
- package/src/contracts/gov.ts +58 -0
- package/src/contracts/interest-oracle.ts +49 -0
- package/src/contracts/price-oracle.ts +24 -0
- package/src/contracts/treasury.ts +95 -0
- package/src/helpers/asset-helpers.ts +28 -0
- package/src/helpers/cdp-helpers.ts +9 -0
- package/src/helpers/helpers.ts +17 -0
- package/src/helpers/lucid-utils.ts +24 -0
- package/src/helpers/time-helpers.ts +3 -0
- package/src/index.ts +23 -0
- package/src/scripts/cdp-creator-validator.ts +9 -0
- package/src/scripts/cdp-validator.ts +9 -0
- package/src/scripts/collector-validator.ts +8 -0
- package/src/scripts/interest-oracle-validator.ts +8 -0
- package/src/scripts/treasury-validator.ts +8 -0
- package/src/types/generic.ts +13 -0
- package/src/types/indigo/cdp.ts +33 -0
- package/src/types/indigo/gov.ts +21 -0
- package/src/types/indigo/interest-oracle.ts +5 -0
- package/src/types/indigo/price-oracle.ts +4 -0
- package/src/types/system-params.ts +228 -0
- package/tests/data/system-params.json +989 -0
- package/tests/datums.test.ts +51 -0
- package/tests/hash-checks.test.ts +17 -0
- package/tests/interest-calculations.test.ts +143 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AssetClass, OnChainDecimal } from "../generic";
|
|
2
|
+
|
|
3
|
+
export type ActiveCDPInterestTracking = { type: 'ActiveCDPInterestTracking', last_settled: bigint, unitary_interest_snapshot: bigint }
|
|
4
|
+
export type FrozenCDPAccumulatedFees = { type: 'FrozenCDPAccumulatedFees', lovelaces_treasury: bigint, lovelaces_indy_stakers: bigint }
|
|
5
|
+
export type CDPFees = ActiveCDPInterestTracking | FrozenCDPAccumulatedFees;
|
|
6
|
+
|
|
7
|
+
export type CDP = {
|
|
8
|
+
type: 'CDP',
|
|
9
|
+
owner: string | undefined,
|
|
10
|
+
asset: string,
|
|
11
|
+
mintedAmount: bigint,
|
|
12
|
+
fees: CDPFees
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type IAsset = {
|
|
16
|
+
type: 'IAsset';
|
|
17
|
+
name: string;
|
|
18
|
+
price: OnChainDecimal | AssetClass;
|
|
19
|
+
interestOracle: AssetClass;
|
|
20
|
+
redemptionRatioPercentage: OnChainDecimal;
|
|
21
|
+
maintenanceRatioPercentage: OnChainDecimal;
|
|
22
|
+
liquidationRatioPercentage: OnChainDecimal;
|
|
23
|
+
debtMintingFeePercentage: OnChainDecimal;
|
|
24
|
+
liquidationProcessingFeePercentage: OnChainDecimal;
|
|
25
|
+
stabilityPoolWithdrawalFeePercentage: OnChainDecimal;
|
|
26
|
+
redemptionReimbursementPercentage: OnChainDecimal;
|
|
27
|
+
redemptionProcessingFeePercentage: OnChainDecimal;
|
|
28
|
+
interestCollectorPortionPercentage: OnChainDecimal;
|
|
29
|
+
firstAsset: boolean;
|
|
30
|
+
nextAsset?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type CDPDatum = CDP | IAsset;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type ProtocolParams = {
|
|
2
|
+
proposalDeposit: bigint,
|
|
3
|
+
votingPeriod: bigint,
|
|
4
|
+
effectiveDelay: bigint,
|
|
5
|
+
expirationPeriod: bigint,
|
|
6
|
+
collateralFeePercentage: bigint,
|
|
7
|
+
proposingPeriod: bigint,
|
|
8
|
+
totalShards: bigint,
|
|
9
|
+
minimumQuorum: bigint,
|
|
10
|
+
maxTreasuryLovelaceSpend: bigint,
|
|
11
|
+
maxTreasuryIndySpend: bigint,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type GovDatum = {
|
|
15
|
+
currentProposal: bigint,
|
|
16
|
+
protocolParams: ProtocolParams,
|
|
17
|
+
currentVersion: bigint,
|
|
18
|
+
iassetsCount: bigint,
|
|
19
|
+
activeProposals: bigint,
|
|
20
|
+
treasuryIndyWithdrawnAmt: bigint,
|
|
21
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { AssetClass, CurrencySymbol } from "./generic";
|
|
2
|
+
|
|
3
|
+
export interface SystemParams {
|
|
4
|
+
versionRecordParams: VersionRecordParams;
|
|
5
|
+
validatorHashes: ValidatorHashes;
|
|
6
|
+
treasuryParams: TreasuryParams;
|
|
7
|
+
startTime: StartTime;
|
|
8
|
+
stakingParams: StakingParams;
|
|
9
|
+
stabilityPoolParams: StabilityPoolParams;
|
|
10
|
+
scriptReferences: ScriptReferences;
|
|
11
|
+
pollShardParams: PollShardParams;
|
|
12
|
+
pollManagerParams: PollManagerParams;
|
|
13
|
+
indyToken: AssetClass;
|
|
14
|
+
govParams: GovParams;
|
|
15
|
+
executeParams: ExecuteParams;
|
|
16
|
+
distributionParams: DistributionParams;
|
|
17
|
+
collectorParams: CollectorParams;
|
|
18
|
+
cdpParams: CdpParams;
|
|
19
|
+
cdpCreatorParams: CdpCreatorParams;
|
|
20
|
+
}
|
|
21
|
+
export type ValidatorHashes = {
|
|
22
|
+
versionRegistryHash: string;
|
|
23
|
+
treasuryHash: string;
|
|
24
|
+
stakingHash: string;
|
|
25
|
+
stabilityPoolHash: string;
|
|
26
|
+
pollShardHash: string;
|
|
27
|
+
pollManagerHash: string;
|
|
28
|
+
govHash: string;
|
|
29
|
+
executeHash: string;
|
|
30
|
+
collectorHash: string;
|
|
31
|
+
cdpHash: string;
|
|
32
|
+
cdpCreatorHash: string;
|
|
33
|
+
};
|
|
34
|
+
export interface AddressCredential {
|
|
35
|
+
tag: string;
|
|
36
|
+
contents: PubKeyHash;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ScriptCredential {
|
|
40
|
+
tag: string;
|
|
41
|
+
contents: {
|
|
42
|
+
tag:string;
|
|
43
|
+
contents:string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface PubKeyHash {
|
|
47
|
+
getPubKeyHash: string;
|
|
48
|
+
}
|
|
49
|
+
export interface VersionRecordParams {
|
|
50
|
+
upgradeToken: AssetClass;
|
|
51
|
+
}
|
|
52
|
+
export interface TreasuryParams {
|
|
53
|
+
upgradeToken: AssetClass;
|
|
54
|
+
versionRecordToken: AssetClass;
|
|
55
|
+
treasuryUtxosStakeCredential?: ScriptCredential;
|
|
56
|
+
}
|
|
57
|
+
export interface StartTime {
|
|
58
|
+
slot: number;
|
|
59
|
+
blockHeader: string;
|
|
60
|
+
}
|
|
61
|
+
export interface StakingParams {
|
|
62
|
+
versionRecordToken: AssetClass;
|
|
63
|
+
stakingToken: AssetClass;
|
|
64
|
+
stakingManagerNFT: AssetClass;
|
|
65
|
+
pollToken: AssetClass;
|
|
66
|
+
indyToken: AssetClass;
|
|
67
|
+
collectorValHash: string;
|
|
68
|
+
}
|
|
69
|
+
export interface StabilityPoolParams {
|
|
70
|
+
versionRecordToken: AssetClass;
|
|
71
|
+
stabilityPoolToken: AssetClass;
|
|
72
|
+
snapshotEpochToScaleToSumToken: AssetClass;
|
|
73
|
+
requestCollateralLovelaces: number;
|
|
74
|
+
iAssetAuthToken: AssetClass;
|
|
75
|
+
govNFT: AssetClass;
|
|
76
|
+
collectorValHash: string;
|
|
77
|
+
cdpToken: AssetClass;
|
|
78
|
+
assetSymbol: CurrencySymbol;
|
|
79
|
+
accountToken: AssetClass;
|
|
80
|
+
accountCreateFeeLovelaces: number;
|
|
81
|
+
accountAdjustmentFeeLovelaces: number;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface ScriptReferences {
|
|
85
|
+
vestingValidatorRef: ScriptReference;
|
|
86
|
+
versionRegistryValidatorRef: ScriptReference;
|
|
87
|
+
versionRecordTokenPolicyRef: ScriptReference;
|
|
88
|
+
treasuryValidatorRef: ScriptReference;
|
|
89
|
+
stakingValidatorRef: ScriptReference;
|
|
90
|
+
stabilityPoolValidatorRef: ScriptReference;
|
|
91
|
+
pollShardValidatorRef: ScriptReference;
|
|
92
|
+
pollManagerValidatorRef: ScriptReference;
|
|
93
|
+
liquidityValidatorRef: ScriptReference;
|
|
94
|
+
iAssetTokenPolicyRef: ScriptReference;
|
|
95
|
+
governanceValidatorRef: ScriptReference;
|
|
96
|
+
executeValidatorRef: ScriptReference;
|
|
97
|
+
collectorValidatorRef: ScriptReference;
|
|
98
|
+
cdpValidatorRef: ScriptReference;
|
|
99
|
+
cdpCreatorValidatorRef: ScriptReference;
|
|
100
|
+
authTokenPolicies: AuthTokenPolicies;
|
|
101
|
+
}
|
|
102
|
+
export interface Output {
|
|
103
|
+
scriptRef: ScriptRef;
|
|
104
|
+
output: ScriptOutput;
|
|
105
|
+
}
|
|
106
|
+
export interface ScriptRef {
|
|
107
|
+
tag: string;
|
|
108
|
+
contents?: string[] | null;
|
|
109
|
+
}
|
|
110
|
+
export interface ScriptOutput {
|
|
111
|
+
referenceScript: string;
|
|
112
|
+
datum: AddressCredentialOrDatum;
|
|
113
|
+
amount: Amount;
|
|
114
|
+
address: Address;
|
|
115
|
+
}
|
|
116
|
+
export interface AddressCredentialOrDatum {
|
|
117
|
+
tag: string;
|
|
118
|
+
contents: string;
|
|
119
|
+
}
|
|
120
|
+
export interface Amount {
|
|
121
|
+
getValue?:
|
|
122
|
+
| ((CurrencySymbol | ((number)[] | null)[] | null)[] | null)[]
|
|
123
|
+
| null;
|
|
124
|
+
}
|
|
125
|
+
export interface Address {
|
|
126
|
+
addressStakingCredential?: null;
|
|
127
|
+
addressCredential: AddressCredentialOrDatum;
|
|
128
|
+
}
|
|
129
|
+
export interface Input {
|
|
130
|
+
transactionId: string;
|
|
131
|
+
index: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface ScriptReference {
|
|
135
|
+
output: Output;
|
|
136
|
+
input: Input;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface AuthTokenPolicies {
|
|
140
|
+
upgradeTokenRef: ScriptReference;
|
|
141
|
+
stakingTokenRef: ScriptReference;
|
|
142
|
+
stabilityPoolTokenRef: ScriptReference;
|
|
143
|
+
snapshotEpochToScaleToSumTokenRef: ScriptReference;
|
|
144
|
+
pollManagerTokenRef: ScriptReference;
|
|
145
|
+
iAssetTokenRef: ScriptReference;
|
|
146
|
+
cdpAuthTokenRef: ScriptReference;
|
|
147
|
+
accountTokenRef: ScriptReference;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface PollShardParams {
|
|
151
|
+
stakingValHash: string;
|
|
152
|
+
stakingToken: AssetClass;
|
|
153
|
+
pollToken: AssetClass;
|
|
154
|
+
indyAsset: AssetClass;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface PollManagerParams {
|
|
158
|
+
upgradeToken: AssetClass;
|
|
159
|
+
treasuryValHash: string;
|
|
160
|
+
shardsValHash: string;
|
|
161
|
+
pollToken: AssetClass;
|
|
162
|
+
pBiasTime: number;
|
|
163
|
+
initialIndyDistribution: number;
|
|
164
|
+
indyAsset: AssetClass;
|
|
165
|
+
govNFT: AssetClass;
|
|
166
|
+
govExecuteValHash: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface GovParams {
|
|
170
|
+
versionRecordToken: AssetClass;
|
|
171
|
+
upgradeToken: AssetClass;
|
|
172
|
+
pollToken: AssetClass;
|
|
173
|
+
pollManagerValHash: string;
|
|
174
|
+
indyAsset: AssetClass;
|
|
175
|
+
iAssetAuthToken: AssetClass;
|
|
176
|
+
govNFT: AssetClass;
|
|
177
|
+
gBiasTime: number;
|
|
178
|
+
daoIdentityToken: AssetClass;
|
|
179
|
+
}
|
|
180
|
+
export interface ExecuteParams {
|
|
181
|
+
versionRegistryValHash: string;
|
|
182
|
+
versionRecordToken: AssetClass;
|
|
183
|
+
upgradeToken: AssetClass;
|
|
184
|
+
treasuryValHash: string;
|
|
185
|
+
stabilityPoolToken: AssetClass;
|
|
186
|
+
sPoolValHash: string;
|
|
187
|
+
maxInterestPeriods: number;
|
|
188
|
+
iAssetToken: AssetClass;
|
|
189
|
+
govNFT: AssetClass;
|
|
190
|
+
cdpValHash: string;
|
|
191
|
+
}
|
|
192
|
+
export interface DistributionParams {
|
|
193
|
+
treasuryIndyAmount: number;
|
|
194
|
+
totalINDYSupply: number;
|
|
195
|
+
initialIndyDistribution: number;
|
|
196
|
+
}
|
|
197
|
+
export interface CollectorParams {
|
|
198
|
+
versionRecordToken: AssetClass;
|
|
199
|
+
stakingToken: AssetClass;
|
|
200
|
+
stakingManagerNFT: AssetClass;
|
|
201
|
+
}
|
|
202
|
+
export interface CdpParams {
|
|
203
|
+
versionRecordToken: AssetClass;
|
|
204
|
+
upgradeToken: AssetClass;
|
|
205
|
+
treasuryValHash: string;
|
|
206
|
+
stabilityPoolAuthToken: AssetClass;
|
|
207
|
+
spValHash: string;
|
|
208
|
+
partialRedemptionExtraFeeLovelace: number;
|
|
209
|
+
minCollateralInLovelace: number;
|
|
210
|
+
iAssetAuthToken: AssetClass;
|
|
211
|
+
govNFT: AssetClass;
|
|
212
|
+
collectorValHash: string;
|
|
213
|
+
cdpAuthToken: AssetClass;
|
|
214
|
+
cdpAssetSymbol: CurrencySymbol;
|
|
215
|
+
biasTime: number;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export interface CdpCreatorParams {
|
|
219
|
+
versionRecordToken: AssetClass;
|
|
220
|
+
minCollateralInLovelace: number;
|
|
221
|
+
iAssetAuthTk: AssetClass;
|
|
222
|
+
collectorValHash: string;
|
|
223
|
+
cdpScriptHash: string;
|
|
224
|
+
cdpCreatorNft: AssetClass;
|
|
225
|
+
cdpAuthTk: AssetClass;
|
|
226
|
+
cdpAssetCs: CurrencySymbol;
|
|
227
|
+
biasTime: number;
|
|
228
|
+
}
|