@indigo-labs/indigo-sdk 0.5.5 → 0.5.7
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -3
- package/dist/index.mjs +5 -3
- 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 -99
- 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 -76
- 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,268 +0,0 @@
|
|
|
1
|
-
import { TSchema, Data } from '@evolution-sdk/evolution';
|
|
2
|
-
import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
|
|
3
|
-
import {
|
|
4
|
-
AddressSchema,
|
|
5
|
-
AssetClassSchema,
|
|
6
|
-
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
7
|
-
import { option as O, function as F } from 'fp-ts';
|
|
8
|
-
import { IAssetPriceInfoSchema } from '../iasset/types';
|
|
9
|
-
import { MultisigSchema } from '../../types/multisig';
|
|
10
|
-
import { RationalSchema } from '../../types/rational';
|
|
11
|
-
|
|
12
|
-
export const ProtocolParamsSchema = TSchema.Struct({
|
|
13
|
-
proposalDeposit: TSchema.Integer,
|
|
14
|
-
votingPeriod: TSchema.Integer,
|
|
15
|
-
effectiveDelay: TSchema.Integer,
|
|
16
|
-
expirationPeriod: TSchema.Integer,
|
|
17
|
-
proposingPeriod: TSchema.Integer,
|
|
18
|
-
totalShards: TSchema.Integer,
|
|
19
|
-
minimumQuorum: TSchema.Integer,
|
|
20
|
-
maxTreasuryLovelaceSpend: TSchema.Integer,
|
|
21
|
-
maxTreasuryIndySpend: TSchema.Integer,
|
|
22
|
-
cdpRedemptionRequiredSignature: TSchema.NullOr(TSchema.ByteArray),
|
|
23
|
-
electorate: TSchema.Integer,
|
|
24
|
-
foundationMultisig: MultisigSchema,
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type ProtocolParams = typeof ProtocolParamsSchema.Type;
|
|
28
|
-
|
|
29
|
-
const UpgradePathSchema = TSchema.Struct({
|
|
30
|
-
upgradeSymbol: TSchema.ByteArray,
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const UpgradePathsSchema = TSchema.Struct({
|
|
34
|
-
upgradeId: TSchema.Integer,
|
|
35
|
-
/// Underlying representation of the following mapping: ValidatorHash -> UpgradePath
|
|
36
|
-
upgradePaths: TSchema.Array(
|
|
37
|
-
TSchema.Tuple([TSchema.ByteArray, UpgradePathSchema]),
|
|
38
|
-
),
|
|
39
|
-
});
|
|
40
|
-
export type UpgradePaths = typeof UpgradePathsSchema.Type;
|
|
41
|
-
|
|
42
|
-
const ProposeIAssetContentSchema = TSchema.Struct({
|
|
43
|
-
asset: TSchema.ByteArray,
|
|
44
|
-
debtMintingFeeRatio: RationalSchema,
|
|
45
|
-
liquidationProcessingFeeRatio: RationalSchema,
|
|
46
|
-
stabilityPoolWithdrawalFeeRatio: RationalSchema,
|
|
47
|
-
redemptionReimbursementRatio: RationalSchema,
|
|
48
|
-
redemptionProcessingFeeRatio: RationalSchema,
|
|
49
|
-
});
|
|
50
|
-
export type ProposeAssetContent = typeof ProposeIAssetContentSchema.Type;
|
|
51
|
-
|
|
52
|
-
const ModifyIAssetContentSchema = TSchema.Struct({
|
|
53
|
-
asset: TSchema.ByteArray,
|
|
54
|
-
newDebtMintingFeeRatio: RationalSchema,
|
|
55
|
-
newLiquidationProcessingFeeRatio: RationalSchema,
|
|
56
|
-
newStabilityPoolWithdrawalFeeRatio: RationalSchema,
|
|
57
|
-
newRedemptionReimbursementRatio: RationalSchema,
|
|
58
|
-
newRedemptionProcessingFeeRatio: RationalSchema,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const AddCollateralAssetContentSchema = TSchema.Struct({
|
|
62
|
-
correspondingIAsset: TSchema.ByteArray,
|
|
63
|
-
collateralAsset: AssetClassSchema,
|
|
64
|
-
assetExtraDecimals: TSchema.Integer,
|
|
65
|
-
assetPriceInfo: IAssetPriceInfoSchema,
|
|
66
|
-
interestOracleNft: AssetClassSchema,
|
|
67
|
-
redemptionRatio: RationalSchema,
|
|
68
|
-
maintenanceRatio: RationalSchema,
|
|
69
|
-
liquidationRatio: RationalSchema,
|
|
70
|
-
minCollateralAmt: TSchema.Integer,
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
export type AddCollateralAsssetContent =
|
|
74
|
-
typeof AddCollateralAssetContentSchema.Type;
|
|
75
|
-
|
|
76
|
-
const UpdateCollateralAssetContentSchema = TSchema.Struct({
|
|
77
|
-
correspondingIAsset: TSchema.ByteArray,
|
|
78
|
-
collateralAsset: AssetClassSchema,
|
|
79
|
-
newAssetExtraDecimals: TSchema.Integer,
|
|
80
|
-
newAssetPriceInfo: IAssetPriceInfoSchema,
|
|
81
|
-
newInterestOracleNft: AssetClassSchema,
|
|
82
|
-
newRedemptionRatio: RationalSchema,
|
|
83
|
-
newMaintenanceRatio: RationalSchema,
|
|
84
|
-
newLiquidationRatio: RationalSchema,
|
|
85
|
-
newMinCollateralAmt: TSchema.Integer,
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
const ProposeStableswapPoolContentSchema = TSchema.Struct({
|
|
89
|
-
iasset: TSchema.ByteArray,
|
|
90
|
-
collateralAsset: AssetClassSchema,
|
|
91
|
-
collateralToIassetRatio: RationalSchema,
|
|
92
|
-
mintingFeeRatio: RationalSchema,
|
|
93
|
-
redemptionFeeRatio: RationalSchema,
|
|
94
|
-
feeManager: TSchema.NullOr(TSchema.ByteArray),
|
|
95
|
-
minMintingAmount: TSchema.Integer,
|
|
96
|
-
minRedemptionAmount: TSchema.Integer,
|
|
97
|
-
stableswapValHash: TSchema.ByteArray,
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
export type ProposeStableswapPoolContent =
|
|
101
|
-
typeof ProposeStableswapPoolContentSchema.Type;
|
|
102
|
-
|
|
103
|
-
const ModifyStableswapPoolContentSchema = TSchema.Struct({
|
|
104
|
-
iasset: TSchema.ByteArray,
|
|
105
|
-
collateralAsset: AssetClassSchema,
|
|
106
|
-
newCollateralToIassetRatio: RationalSchema,
|
|
107
|
-
newMintingFeeRatio: RationalSchema,
|
|
108
|
-
newRedemptionFeeRatio: RationalSchema,
|
|
109
|
-
newMintingEnabled: TSchema.Boolean,
|
|
110
|
-
newRedemptionEnabled: TSchema.Boolean,
|
|
111
|
-
newFeeManager: TSchema.NullOr(TSchema.ByteArray),
|
|
112
|
-
newMinMintingAmount: TSchema.Integer,
|
|
113
|
-
newMinRedemptionAmount: TSchema.Integer,
|
|
114
|
-
newStableswapValHash: TSchema.ByteArray,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
export type ModifyStableswapPoolContent =
|
|
118
|
-
typeof ModifyStableswapPoolContentSchema.Type;
|
|
119
|
-
|
|
120
|
-
export const ProposalContentSchema = TSchema.Union(
|
|
121
|
-
TSchema.Struct(
|
|
122
|
-
{
|
|
123
|
-
ProposeIAsset: ProposeIAssetContentSchema,
|
|
124
|
-
},
|
|
125
|
-
{ flatInUnion: true },
|
|
126
|
-
),
|
|
127
|
-
TSchema.Struct(
|
|
128
|
-
{
|
|
129
|
-
ModifyIAsset: ModifyIAssetContentSchema,
|
|
130
|
-
},
|
|
131
|
-
{ flatInUnion: true },
|
|
132
|
-
),
|
|
133
|
-
TSchema.Struct(
|
|
134
|
-
{
|
|
135
|
-
AddCollateralAsset: AddCollateralAssetContentSchema,
|
|
136
|
-
},
|
|
137
|
-
{ flatInUnion: true },
|
|
138
|
-
),
|
|
139
|
-
TSchema.Struct(
|
|
140
|
-
{
|
|
141
|
-
UpdateCollateralAsset: UpdateCollateralAssetContentSchema,
|
|
142
|
-
},
|
|
143
|
-
{ flatInUnion: true },
|
|
144
|
-
),
|
|
145
|
-
TSchema.Struct(
|
|
146
|
-
{
|
|
147
|
-
ProposeStableswapPool: ProposeStableswapPoolContentSchema,
|
|
148
|
-
},
|
|
149
|
-
{ flatInUnion: true },
|
|
150
|
-
),
|
|
151
|
-
TSchema.Struct(
|
|
152
|
-
{
|
|
153
|
-
ModifyStableswapPool: ModifyStableswapPoolContentSchema,
|
|
154
|
-
},
|
|
155
|
-
{ flatInUnion: true },
|
|
156
|
-
),
|
|
157
|
-
TSchema.Struct(
|
|
158
|
-
{
|
|
159
|
-
ModifyProtocolParams: TSchema.Struct(
|
|
160
|
-
{
|
|
161
|
-
newParams: ProtocolParamsSchema,
|
|
162
|
-
},
|
|
163
|
-
{ flatFields: true },
|
|
164
|
-
),
|
|
165
|
-
},
|
|
166
|
-
{ flatInUnion: true },
|
|
167
|
-
),
|
|
168
|
-
TSchema.Struct(
|
|
169
|
-
{
|
|
170
|
-
UpgradeProtocol: TSchema.Struct(
|
|
171
|
-
{
|
|
172
|
-
content: UpgradePathsSchema,
|
|
173
|
-
},
|
|
174
|
-
{ flatFields: true },
|
|
175
|
-
),
|
|
176
|
-
},
|
|
177
|
-
{ flatInUnion: true },
|
|
178
|
-
),
|
|
179
|
-
TSchema.Struct(
|
|
180
|
-
{
|
|
181
|
-
TextProposal: TSchema.ByteArray,
|
|
182
|
-
},
|
|
183
|
-
{ flatInUnion: true },
|
|
184
|
-
),
|
|
185
|
-
);
|
|
186
|
-
export type ProposalContent = typeof ProposalContentSchema.Type;
|
|
187
|
-
|
|
188
|
-
const TreasuryWithdrawalItemSchema = TSchema.Struct({
|
|
189
|
-
currencySymbol: TSchema.ByteArray,
|
|
190
|
-
tokenName: TSchema.ByteArray,
|
|
191
|
-
amount: TSchema.Integer,
|
|
192
|
-
});
|
|
193
|
-
export type TreasuryWithdrawalItem = typeof TreasuryWithdrawalItemSchema.Type;
|
|
194
|
-
|
|
195
|
-
export const TreasuryWithdrawalSchema = TSchema.Struct({
|
|
196
|
-
destination: AddressSchema,
|
|
197
|
-
value: TSchema.Array(TreasuryWithdrawalItemSchema),
|
|
198
|
-
});
|
|
199
|
-
export type TreasuryWithdrawal = typeof TreasuryWithdrawalSchema.Type;
|
|
200
|
-
|
|
201
|
-
const GovRedeemerSchema = TSchema.Union(
|
|
202
|
-
TSchema.Struct(
|
|
203
|
-
{
|
|
204
|
-
CreatePoll: TSchema.Struct(
|
|
205
|
-
{
|
|
206
|
-
currentTime: TSchema.Integer,
|
|
207
|
-
proposalOwner: TSchema.ByteArray,
|
|
208
|
-
content: ProposalContentSchema,
|
|
209
|
-
treasuryWithdrawal: TSchema.NullOr(TreasuryWithdrawalSchema),
|
|
210
|
-
},
|
|
211
|
-
{ flatFields: true },
|
|
212
|
-
),
|
|
213
|
-
},
|
|
214
|
-
{ flatInUnion: true },
|
|
215
|
-
),
|
|
216
|
-
TSchema.Struct(
|
|
217
|
-
{
|
|
218
|
-
WitnessEndPoll: TSchema.Struct(
|
|
219
|
-
{
|
|
220
|
-
currentTime: TSchema.Integer,
|
|
221
|
-
},
|
|
222
|
-
{ flatFields: true },
|
|
223
|
-
),
|
|
224
|
-
},
|
|
225
|
-
{ flatInUnion: true },
|
|
226
|
-
),
|
|
227
|
-
TSchema.Literal('UpgradeGov', { flatInUnion: true }),
|
|
228
|
-
TSchema.Literal('UpgradeVersion', { flatInUnion: true }),
|
|
229
|
-
);
|
|
230
|
-
export type GovRedeemer = typeof GovRedeemerSchema.Type;
|
|
231
|
-
|
|
232
|
-
const GovDatumSchema = TSchema.Struct({
|
|
233
|
-
currentProposal: TSchema.Integer,
|
|
234
|
-
protocolParams: ProtocolParamsSchema,
|
|
235
|
-
currentVersion: TSchema.Integer,
|
|
236
|
-
iassetsCount: TSchema.Integer,
|
|
237
|
-
activeProposals: TSchema.Integer,
|
|
238
|
-
});
|
|
239
|
-
export type GovDatum = typeof GovDatumSchema.Type;
|
|
240
|
-
|
|
241
|
-
export function serialiseGovRedeemer(r: GovRedeemer): string {
|
|
242
|
-
return Data.withSchema(GovRedeemerSchema).toCBORHex(r);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
export function serialiseGovDatum(d: GovDatum): string {
|
|
246
|
-
return Data.withSchema(GovDatumSchema).toCBORHex(d);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export function parseGovDatum(datum: string): O.Option<GovDatum> {
|
|
250
|
-
try {
|
|
251
|
-
return O.some(
|
|
252
|
-
Data.withSchema(GovDatumSchema, DEFAULT_SCHEMA_OPTIONS).fromCBORHex(
|
|
253
|
-
datum,
|
|
254
|
-
),
|
|
255
|
-
);
|
|
256
|
-
} catch (_) {
|
|
257
|
-
return O.none;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
export function parseGovDatumOrThrow(datum: string): GovDatum {
|
|
262
|
-
return F.pipe(
|
|
263
|
-
parseGovDatum(datum),
|
|
264
|
-
O.match(() => {
|
|
265
|
-
throw new Error('Expected a Gov datum.');
|
|
266
|
-
}, F.identity),
|
|
267
|
-
);
|
|
268
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Data } from '@lucid-evolution/lucid';
|
|
2
|
-
import { AssetClassSchema } from '../../types/generic';
|
|
3
|
-
|
|
4
|
-
const GovParamsSchema = Data.Object({
|
|
5
|
-
govNFT: AssetClassSchema,
|
|
6
|
-
pollToken: AssetClassSchema,
|
|
7
|
-
upgradeToken: AssetClassSchema,
|
|
8
|
-
indyAsset: AssetClassSchema,
|
|
9
|
-
versionRecordToken: AssetClassSchema,
|
|
10
|
-
iassetSymbol: Data.Bytes(),
|
|
11
|
-
pollManagerValHash: Data.Bytes(),
|
|
12
|
-
iassetValHash: Data.Bytes(),
|
|
13
|
-
gBiasTime: Data.Integer(),
|
|
14
|
-
daoIdentityToken: AssetClassSchema,
|
|
15
|
-
iAssetAuthToken: AssetClassSchema,
|
|
16
|
-
});
|
|
17
|
-
export type GovParams = Data.Static<typeof GovParamsSchema>;
|
|
18
|
-
export const GovParams = GovParamsSchema as unknown as GovParams;
|
|
19
|
-
|
|
20
|
-
export function castGovParams(params: GovParams): Data {
|
|
21
|
-
return Data.castTo(params, GovParams);
|
|
22
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
credentialToRewardAddress,
|
|
3
|
-
Data,
|
|
4
|
-
fromHex,
|
|
5
|
-
LucidEvolution,
|
|
6
|
-
OutRef,
|
|
7
|
-
scriptHashToCredential,
|
|
8
|
-
toHex,
|
|
9
|
-
TxBuilder,
|
|
10
|
-
UTxO,
|
|
11
|
-
} from '@lucid-evolution/lucid';
|
|
12
|
-
import { IAssetPriceInfo } from './types';
|
|
13
|
-
import { matchSingle } from '../../utils/utils';
|
|
14
|
-
import { parsePriceOracleDatum } from '../price-oracle/types-new';
|
|
15
|
-
import { getInlineDatumOrThrow } from '../../utils/lucid-utils';
|
|
16
|
-
import { oracleExpirationAwareValidity } from '../price-oracle/helpers';
|
|
17
|
-
import {
|
|
18
|
-
fromSysParamsDerivedPythPrice,
|
|
19
|
-
fromSystemParamsScriptRef,
|
|
20
|
-
getPythFeedConfig,
|
|
21
|
-
PythConfig,
|
|
22
|
-
} from '../../types/system-params';
|
|
23
|
-
import {
|
|
24
|
-
parsePythStateDatum,
|
|
25
|
-
serialisePythFeedRedeemer,
|
|
26
|
-
serialisePythUpdatesRedeemer,
|
|
27
|
-
} from '../pyth-feed/types';
|
|
28
|
-
import { match, P } from 'ts-pattern';
|
|
29
|
-
import { derivePythPrice } from '../pyth-feed/helpers';
|
|
30
|
-
import { AssetClass } from '@3rd-eye-labs/cardano-offchain-common';
|
|
31
|
-
import * as Core from '@evolution-sdk/evolution';
|
|
32
|
-
import { decodePriceUpdate, decodePythMessage } from '../../utils/pyth';
|
|
33
|
-
|
|
34
|
-
export const MAX_COLLATERAL_ASSETS_COUNT_PER_IASSET = 9;
|
|
35
|
-
|
|
36
|
-
type Interval = {
|
|
37
|
-
validFrom: number;
|
|
38
|
-
validTo: number;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export function attachOracle(
|
|
42
|
-
iasset: Uint8Array<ArrayBufferLike>,
|
|
43
|
-
collateralAsset: AssetClass,
|
|
44
|
-
priceInfo: IAssetPriceInfo,
|
|
45
|
-
priceOracleOref: OutRef | undefined,
|
|
46
|
-
pythStateOref: OutRef | undefined,
|
|
47
|
-
pythMessage: string | undefined,
|
|
48
|
-
pythConfig: PythConfig,
|
|
49
|
-
biasTime: bigint,
|
|
50
|
-
lucid: LucidEvolution,
|
|
51
|
-
tx: TxBuilder,
|
|
52
|
-
): Promise<{ interval: Interval; referenceInputs: UTxO[] }> {
|
|
53
|
-
return match(priceInfo)
|
|
54
|
-
.returnType<Promise<{ interval: Interval; referenceInputs: UTxO[] }>>()
|
|
55
|
-
.with({ Delisted: P.any }, () => {
|
|
56
|
-
const currentTime = BigInt(lucid.slotToUnixTime(lucid.currentSlot()));
|
|
57
|
-
|
|
58
|
-
// We want to make sure the transaction is valid within the bias time for interest tracking AND Pyth
|
|
59
|
-
// For validFrom, we take the higher of the two bias times
|
|
60
|
-
const validFrom = Number(currentTime - BigInt(biasTime / 2n));
|
|
61
|
-
// For validTo, we take the lower of the two bias times
|
|
62
|
-
const validTo = Number(currentTime + BigInt(biasTime / 2n));
|
|
63
|
-
|
|
64
|
-
return Promise.resolve({
|
|
65
|
-
interval: {
|
|
66
|
-
validFrom,
|
|
67
|
-
validTo,
|
|
68
|
-
},
|
|
69
|
-
referenceInputs: [],
|
|
70
|
-
});
|
|
71
|
-
})
|
|
72
|
-
.with({ OracleNft: P.any }, async () => {
|
|
73
|
-
if (!priceOracleOref) throw new Error('Missing price oracle');
|
|
74
|
-
|
|
75
|
-
const priceOracleUtxo = matchSingle<UTxO>(
|
|
76
|
-
await lucid.utxosByOutRef([priceOracleOref]),
|
|
77
|
-
(_) => new Error('Expected a single price oracle UTXO'),
|
|
78
|
-
);
|
|
79
|
-
const priceOracleDatum = parsePriceOracleDatum(
|
|
80
|
-
getInlineDatumOrThrow(priceOracleUtxo),
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
interval: oracleExpirationAwareValidity(
|
|
85
|
-
lucid,
|
|
86
|
-
Number(biasTime),
|
|
87
|
-
Number(priceOracleDatum.expirationTime),
|
|
88
|
-
),
|
|
89
|
-
referenceInputs: [priceOracleUtxo],
|
|
90
|
-
};
|
|
91
|
-
})
|
|
92
|
-
.with(
|
|
93
|
-
{ DeferredValidation: { feedValHash: P.select() } },
|
|
94
|
-
async (feedValHash) => {
|
|
95
|
-
if (priceOracleOref) throw new Error('Cannot pass price oracle oref');
|
|
96
|
-
if (!pythMessage) throw new Error('Missing Pyth message');
|
|
97
|
-
if (!pythStateOref) throw new Error('Missing pyth state out ref');
|
|
98
|
-
|
|
99
|
-
const pythStateUtxo = matchSingle(
|
|
100
|
-
await lucid.utxosByOutRef([pythStateOref]),
|
|
101
|
-
(_) => new Error('Expected a single pyth state UTXO'),
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const pythStateDatum = parsePythStateDatum(
|
|
105
|
-
getInlineDatumOrThrow(pythStateUtxo),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const pythFeedCfg = getPythFeedConfig(
|
|
109
|
-
pythConfig,
|
|
110
|
-
iasset,
|
|
111
|
-
collateralAsset,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
// Lookup PFV Validator
|
|
115
|
-
const pfvScriptRefUtxo = matchSingle(
|
|
116
|
-
await lucid.utxosByOutRef([
|
|
117
|
-
fromSystemParamsScriptRef(pythFeedCfg.pythFeedValScriptRef),
|
|
118
|
-
]),
|
|
119
|
-
(_) =>
|
|
120
|
-
new Error('Expected a single pyth feed validator Ref Script UTXO'),
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
const derivedPythPrice = fromSysParamsDerivedPythPrice(
|
|
124
|
-
pythFeedCfg.params.config,
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
const price = derivePythPrice(derivedPythPrice, pythMessage);
|
|
128
|
-
|
|
129
|
-
const decodedMessage = decodePythMessage(fromHex(pythMessage));
|
|
130
|
-
const pricePayload = decodePriceUpdate(decodedMessage.payload);
|
|
131
|
-
const pythTimestamp = Number(pricePayload.timestampUs) / 1_000;
|
|
132
|
-
|
|
133
|
-
tx.withdraw(
|
|
134
|
-
credentialToRewardAddress(
|
|
135
|
-
lucid.config().network!,
|
|
136
|
-
scriptHashToCredential(toHex(pythStateDatum.withdraw_script)),
|
|
137
|
-
),
|
|
138
|
-
0n,
|
|
139
|
-
serialisePythUpdatesRedeemer([fromHex(pythMessage)]),
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
tx.withdraw(
|
|
143
|
-
credentialToRewardAddress(
|
|
144
|
-
lucid.config().network!,
|
|
145
|
-
scriptHashToCredential(toHex(feedValHash)),
|
|
146
|
-
),
|
|
147
|
-
0n,
|
|
148
|
-
serialisePythFeedRedeemer({
|
|
149
|
-
price: price,
|
|
150
|
-
auxiliaryData: Core.Data.fromCBORHex(Data.void()),
|
|
151
|
-
}),
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
// 5 minutes - 20 seconds
|
|
155
|
-
const pythMaxDelay = 280 * 1000;
|
|
156
|
-
|
|
157
|
-
const validFrom = Number(pythTimestamp);
|
|
158
|
-
const validTo = Number(pythTimestamp + pythMaxDelay);
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
interval: {
|
|
162
|
-
validFrom: validFrom,
|
|
163
|
-
validTo: validTo,
|
|
164
|
-
},
|
|
165
|
-
referenceInputs: [pythStateUtxo, pfvScriptRefUtxo],
|
|
166
|
-
};
|
|
167
|
-
},
|
|
168
|
-
)
|
|
169
|
-
.exhaustive();
|
|
170
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { LucidEvolution, toHex } from '@lucid-evolution/lucid';
|
|
2
|
-
import { fromSystemParamsAsset, SystemParams } from '../../types/system-params';
|
|
3
|
-
import {
|
|
4
|
-
AssetClass,
|
|
5
|
-
assetClassToUnit,
|
|
6
|
-
isSameAssetClass,
|
|
7
|
-
matchSingle,
|
|
8
|
-
} from '@3rd-eye-labs/cardano-offchain-common';
|
|
9
|
-
import {
|
|
10
|
-
CollateralAssetOutput,
|
|
11
|
-
IAssetOutput,
|
|
12
|
-
parseCollateralAssetDatum,
|
|
13
|
-
parseIAssetDatum,
|
|
14
|
-
} from './types';
|
|
15
|
-
import { createScriptAddress } from '../../utils/lucid-utils';
|
|
16
|
-
import { option as O, array as A, function as F } from 'fp-ts';
|
|
17
|
-
|
|
18
|
-
export async function findIAsset(
|
|
19
|
-
lucid: LucidEvolution,
|
|
20
|
-
sysParams: SystemParams,
|
|
21
|
-
/**
|
|
22
|
-
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
23
|
-
*/
|
|
24
|
-
iassetName: Uint8Array<ArrayBufferLike>,
|
|
25
|
-
): Promise<IAssetOutput> {
|
|
26
|
-
const iassetUtxos = await lucid.utxosAtWithUnit(
|
|
27
|
-
createScriptAddress(
|
|
28
|
-
lucid.config().network!,
|
|
29
|
-
sysParams.validatorHashes.iassetHash,
|
|
30
|
-
),
|
|
31
|
-
assetClassToUnit(
|
|
32
|
-
fromSystemParamsAsset(sysParams.cdpParams.iAssetAuthToken),
|
|
33
|
-
),
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
return matchSingle(
|
|
37
|
-
F.pipe(
|
|
38
|
-
iassetUtxos.map((utxo) =>
|
|
39
|
-
F.pipe(
|
|
40
|
-
O.fromNullable(utxo.datum),
|
|
41
|
-
O.flatMap(parseIAssetDatum),
|
|
42
|
-
O.flatMap((datum) => {
|
|
43
|
-
if (toHex(datum.assetName) === toHex(iassetName)) {
|
|
44
|
-
return O.some({ utxo, datum: datum });
|
|
45
|
-
} else {
|
|
46
|
-
return O.none;
|
|
47
|
-
}
|
|
48
|
-
}),
|
|
49
|
-
),
|
|
50
|
-
),
|
|
51
|
-
A.compact,
|
|
52
|
-
),
|
|
53
|
-
(res) =>
|
|
54
|
-
new Error('Expected a single IAsset UTXO.: ' + JSON.stringify(res)),
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export async function findCollateralAsset(
|
|
59
|
-
lucid: LucidEvolution,
|
|
60
|
-
sysParams: SystemParams,
|
|
61
|
-
/**
|
|
62
|
-
* For conversion from hex use the `fromHex` function from lucid-evolution.
|
|
63
|
-
*/
|
|
64
|
-
iassetName: Uint8Array<ArrayBufferLike>,
|
|
65
|
-
collateralAsset: AssetClass,
|
|
66
|
-
): Promise<CollateralAssetOutput> {
|
|
67
|
-
const collateralAssetUtxos = await lucid.utxosAtWithUnit(
|
|
68
|
-
createScriptAddress(
|
|
69
|
-
lucid.config().network!,
|
|
70
|
-
sysParams.validatorHashes.iassetHash,
|
|
71
|
-
),
|
|
72
|
-
assetClassToUnit(
|
|
73
|
-
fromSystemParamsAsset(sysParams.cdpParams.collateralAssetAuthToken),
|
|
74
|
-
),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return matchSingle(
|
|
78
|
-
F.pipe(
|
|
79
|
-
collateralAssetUtxos.map((utxo) =>
|
|
80
|
-
F.pipe(
|
|
81
|
-
O.fromNullable(utxo.datum),
|
|
82
|
-
O.flatMap(parseCollateralAssetDatum),
|
|
83
|
-
O.flatMap((datum) => {
|
|
84
|
-
if (
|
|
85
|
-
isSameAssetClass(datum.collateralAsset, collateralAsset) &&
|
|
86
|
-
toHex(iassetName) === toHex(datum.iasset)
|
|
87
|
-
) {
|
|
88
|
-
return O.some({ utxo, datum: datum });
|
|
89
|
-
} else {
|
|
90
|
-
return O.none;
|
|
91
|
-
}
|
|
92
|
-
}),
|
|
93
|
-
),
|
|
94
|
-
),
|
|
95
|
-
A.compact,
|
|
96
|
-
),
|
|
97
|
-
(res) =>
|
|
98
|
-
new Error(
|
|
99
|
-
'Expected a single Collateral Asset UTXO.: ' + JSON.stringify(res),
|
|
100
|
-
),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { applyParamsToScript, SpendingValidator } from '@lucid-evolution/lucid';
|
|
2
|
-
import {
|
|
3
|
-
fromSystemParamsAssetLucid,
|
|
4
|
-
IAssetParamsSP,
|
|
5
|
-
} from '../../types/system-params';
|
|
6
|
-
import { _cdpValidator } from '../../validators/cdp-validator';
|
|
7
|
-
import { _iassetValidator } from '../../validators/iasset-validator';
|
|
8
|
-
|
|
9
|
-
import { Data } from '@lucid-evolution/lucid';
|
|
10
|
-
import { AssetClassSchema } from '../../types/generic';
|
|
11
|
-
|
|
12
|
-
const IAssetScriptParamsSchema = Data.Object({
|
|
13
|
-
upgradeToken: AssetClassSchema,
|
|
14
|
-
versionRecordToken: AssetClassSchema,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export type IAssetScriptParams = Data.Static<typeof IAssetScriptParamsSchema>;
|
|
18
|
-
export const IAssetScriptParams =
|
|
19
|
-
IAssetScriptParamsSchema as unknown as IAssetScriptParams;
|
|
20
|
-
|
|
21
|
-
export const mkIAssetValidatorFromSP = (
|
|
22
|
-
params: IAssetParamsSP,
|
|
23
|
-
): SpendingValidator => {
|
|
24
|
-
return {
|
|
25
|
-
type: 'PlutusV3',
|
|
26
|
-
script: applyParamsToScript(_iassetValidator.cborHex, [
|
|
27
|
-
Data.castTo(
|
|
28
|
-
{
|
|
29
|
-
upgradeToken: fromSystemParamsAssetLucid(params.upgradeToken),
|
|
30
|
-
versionRecordToken: fromSystemParamsAssetLucid(
|
|
31
|
-
params.versionRecordToken,
|
|
32
|
-
),
|
|
33
|
-
},
|
|
34
|
-
IAssetScriptParams,
|
|
35
|
-
),
|
|
36
|
-
]),
|
|
37
|
-
};
|
|
38
|
-
};
|