@indigo-labs/indigo-sdk 0.1.21 → 0.1.22

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 (135) hide show
  1. package/.github/workflows/ci.yml +3 -8
  2. package/.github/workflows/test.yml +44 -0
  3. package/dist/index.d.mts +670 -1291
  4. package/dist/index.d.ts +670 -1291
  5. package/dist/index.js +2235 -4669
  6. package/dist/index.mjs +2216 -4618
  7. package/eslint.config.mjs +1 -7
  8. package/package.json +4 -9
  9. package/src/contracts/cdp.ts +746 -0
  10. package/src/contracts/collector.ts +98 -0
  11. package/src/contracts/gov.ts +1 -0
  12. package/src/contracts/interest-oracle.ts +149 -0
  13. package/src/contracts/{lrp/transactions.ts → lrp.ts} +14 -14
  14. package/src/contracts/{one-shot/transactions.ts → one-shot.ts} +3 -3
  15. package/src/contracts/stability-pool.ts +690 -0
  16. package/src/contracts/staking.ts +348 -0
  17. package/src/contracts/treasury.ts +112 -0
  18. package/src/helpers/asset-helpers.ts +57 -0
  19. package/src/{utils → helpers}/helper-txs.ts +0 -1
  20. package/src/{utils/utils.ts → helpers/helpers.ts} +10 -0
  21. package/src/{contracts/interest-oracle/helpers.ts → helpers/interest-oracle.ts} +9 -37
  22. package/src/{contracts/stability-pool/helpers.ts → helpers/stability-pool-helpers.ts} +6 -110
  23. package/src/helpers/staking-helpers.ts +94 -0
  24. package/src/helpers/time-helpers.ts +4 -0
  25. package/src/{utils → helpers}/value-helpers.ts +0 -10
  26. package/src/index.ts +33 -38
  27. package/src/{validators → scripts}/cdp-creator-validator.ts +50 -4
  28. package/src/{validators → scripts}/cdp-validator.ts +5 -3
  29. package/src/{validators → scripts}/collector-validator.ts +3 -2
  30. package/src/scripts/execute-validator.ts +52 -0
  31. package/src/{validators/governance-validator.ts → scripts/gov-validator.ts} +40 -3
  32. package/src/{validators → scripts}/interest-oracle-validator.ts +20 -4
  33. package/src/scripts/lrp-validator.ts +40 -0
  34. package/src/{contracts/one-shot/scripts.ts → scripts/one-shot-policy.ts} +1 -1
  35. package/src/scripts/poll-manager-validator.ts +52 -0
  36. package/src/{validators → scripts}/poll-shard-validator.ts +43 -3
  37. package/src/{contracts/price-oracle/scripts.ts → scripts/price-oracle-validator.ts} +4 -1
  38. package/src/{validators → scripts}/stability-pool-validator.ts +57 -4
  39. package/src/{validators → scripts}/staking-validator.ts +3 -2
  40. package/src/{validators → scripts}/treasury-validator.ts +3 -2
  41. package/src/{validators → scripts}/version-record-policy.ts +23 -4
  42. package/src/{validators/execute-validator.ts → scripts/version-registry.ts} +11 -3
  43. package/src/types/generic.ts +60 -78
  44. package/src/{contracts/cdp-creator/types.ts → types/indigo/cdp-creator.ts} +4 -6
  45. package/src/types/indigo/cdp.ts +88 -0
  46. package/src/types/indigo/execute.ts +21 -0
  47. package/src/types/indigo/gov.ts +51 -0
  48. package/src/{contracts/interest-oracle/types.ts → types/indigo/interest-oracle.ts} +1 -1
  49. package/src/{contracts/lrp/types.ts → types/indigo/lrp.ts} +2 -2
  50. package/src/types/indigo/poll-manager.ts +21 -0
  51. package/src/types/indigo/poll-shard.ts +16 -0
  52. package/src/{contracts/price-oracle/types.ts → types/indigo/price-oracle.ts} +4 -16
  53. package/src/types/indigo/stability-pool.ts +233 -0
  54. package/src/types/indigo/staking.ts +99 -0
  55. package/src/{contracts/version-registry/types.ts → types/indigo/version-record.ts} +1 -1
  56. package/src/types/on-chain-decimal.ts +0 -22
  57. package/src/types/system-params.ts +11 -22
  58. package/tests/datums.test.ts +108 -125
  59. package/tests/endpoints/initialize.ts +338 -240
  60. package/tests/hash-checks.test.ts +21 -26
  61. package/tests/indigo-test-helpers.ts +55 -1
  62. package/tests/initialize.test.ts +5 -10
  63. package/tests/interest-calculations.test.ts +18 -18
  64. package/tests/interest-oracle.test.ts +18 -20
  65. package/tests/lrp.test.ts +65 -191
  66. package/tests/queries/governance-queries.ts +16 -19
  67. package/tests/queries/iasset-queries.ts +23 -46
  68. package/tests/queries/interest-oracle-queries.ts +6 -3
  69. package/tests/queries/lrp-queries.ts +2 -2
  70. package/tests/queries/price-oracle-queries.ts +22 -5
  71. package/tests/queries/stability-pool-queries.ts +8 -10
  72. package/tests/queries/staking-queries.ts +19 -28
  73. package/tests/stability-pool.test.ts +71 -186
  74. package/tests/staking.test.ts +23 -30
  75. package/tests/test-helpers.ts +2 -11
  76. package/tsconfig.json +1 -3
  77. package/vitest.config.ts +1 -1
  78. package/src/contracts/cdp/helpers.ts +0 -167
  79. package/src/contracts/cdp/scripts.ts +0 -33
  80. package/src/contracts/cdp/transactions.ts +0 -1310
  81. package/src/contracts/cdp/types.ts +0 -161
  82. package/src/contracts/cdp-creator/scripts.ts +0 -39
  83. package/src/contracts/collector/scripts.ts +0 -32
  84. package/src/contracts/collector/transactions.ts +0 -44
  85. package/src/contracts/execute/scripts.ts +0 -48
  86. package/src/contracts/execute/types.ts +0 -57
  87. package/src/contracts/gov/helpers.ts +0 -157
  88. package/src/contracts/gov/scripts.ts +0 -34
  89. package/src/contracts/gov/transactions.ts +0 -1224
  90. package/src/contracts/gov/types-new.ts +0 -115
  91. package/src/contracts/gov/types.ts +0 -89
  92. package/src/contracts/interest-oracle/scripts.ts +0 -18
  93. package/src/contracts/interest-oracle/transactions.ts +0 -149
  94. package/src/contracts/lrp/scripts.ts +0 -27
  95. package/src/contracts/poll/helpers.ts +0 -55
  96. package/src/contracts/poll/scripts.ts +0 -72
  97. package/src/contracts/poll/types-poll-manager.ts +0 -38
  98. package/src/contracts/poll/types-poll-shard.ts +0 -38
  99. package/src/contracts/poll/types-poll.ts +0 -88
  100. package/src/contracts/price-oracle/transactions.ts +0 -112
  101. package/src/contracts/stability-pool/scripts.ts +0 -46
  102. package/src/contracts/stability-pool/transactions.ts +0 -660
  103. package/src/contracts/stability-pool/types-new.ts +0 -208
  104. package/src/contracts/stability-pool/types.ts +0 -42
  105. package/src/contracts/staking/helpers.ts +0 -116
  106. package/src/contracts/staking/scripts.ts +0 -41
  107. package/src/contracts/staking/transactions.ts +0 -268
  108. package/src/contracts/staking/types-new.ts +0 -81
  109. package/src/contracts/staking/types.ts +0 -41
  110. package/src/contracts/treasury/scripts.ts +0 -37
  111. package/src/contracts/treasury/transactions.ts +0 -44
  112. package/src/contracts/treasury/types.ts +0 -55
  113. package/src/contracts/version-registry/scripts.ts +0 -29
  114. package/src/contracts/version-registry/types-new.ts +0 -19
  115. package/src/contracts/vesting/helpers.ts +0 -267
  116. package/src/types/evolution-schema-options.ts +0 -16
  117. package/src/utils/bigint-utils.ts +0 -7
  118. package/src/utils/time-helpers.ts +0 -4
  119. package/src/validators/lrp-validator.ts +0 -7
  120. package/src/validators/poll-manager-validator.ts +0 -7
  121. package/src/validators/version-registry-validator.ts +0 -7
  122. package/tests/cdp.test.ts +0 -1565
  123. package/tests/gov.test.ts +0 -1874
  124. package/tests/mock/assets-mock.ts +0 -59
  125. package/tests/queries/cdp-queries.ts +0 -144
  126. package/tests/queries/collector-queries.ts +0 -26
  127. package/tests/queries/execute-queries.ts +0 -46
  128. package/tests/queries/poll-queries.ts +0 -97
  129. package/tests/queries/treasury-queries.ts +0 -19
  130. package/tests/utils/asserts.ts +0 -13
  131. package/tests/utils/index.ts +0 -50
  132. /package/src/{utils → helpers}/indigo-helpers.ts +0 -0
  133. /package/src/{utils → helpers}/lucid-utils.ts +0 -0
  134. /package/src/{contracts/price-oracle/helpers.ts → helpers/price-oracle-helpers.ts} +0 -0
  135. /package/src/{contracts/one-shot/types.ts → types/one-shot.ts} +0 -0
@@ -1,81 +0,0 @@
1
- import { Core as EvoCore } from '@evolution-sdk/evolution';
2
- import { option as O, function as F } from 'fp-ts';
3
- import { match, P } from 'ts-pattern';
4
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
5
-
6
- const StakingPosLockedAmtSchema = EvoCore.TSchema.Map(
7
- EvoCore.TSchema.Integer,
8
- EvoCore.TSchema.Struct({
9
- voteAmt: EvoCore.TSchema.Integer,
10
- votingEnd: EvoCore.TSchema.Integer,
11
- }),
12
- );
13
-
14
- export type StakingPosLockedAmt = typeof StakingPosLockedAmtSchema.Type;
15
-
16
- const RewardSnapshotSchema = EvoCore.TSchema.Struct({
17
- snapshotAda: EvoCore.TSchema.Integer,
18
- });
19
-
20
- const StakingPositionSchema = EvoCore.TSchema.Struct({
21
- owner: EvoCore.TSchema.ByteArray,
22
- lockedAmount: StakingPosLockedAmtSchema,
23
- positionSnapshot: RewardSnapshotSchema,
24
- });
25
- export type StakingPosition = typeof StakingPositionSchema.Type;
26
-
27
- const StakingManagerSchema = EvoCore.TSchema.Struct({
28
- totalStake: EvoCore.TSchema.Integer,
29
- managerSnapshot: RewardSnapshotSchema,
30
- });
31
- export type StakingManager = typeof StakingManagerSchema.Type;
32
-
33
- const StakingDatumSchema = EvoCore.TSchema.Union(
34
- StakingManagerSchema,
35
- StakingPositionSchema,
36
- );
37
- type StakingDatum = typeof StakingDatumSchema.Type;
38
-
39
- export function parseStakingPosition(datum: string): O.Option<StakingPosition> {
40
- try {
41
- return match(
42
- EvoCore.Data.withSchema(
43
- StakingDatumSchema,
44
- DEFAULT_SCHEMA_OPTIONS,
45
- ).fromCBORHex(datum),
46
- )
47
- .with({ owner: P.any }, (res) => O.some(res))
48
- .otherwise(() => O.none);
49
- } catch (_) {
50
- return O.none;
51
- }
52
- }
53
-
54
- export function parseStakingPositionOrThrow(datum: string): StakingPosition {
55
- return F.pipe(
56
- parseStakingPosition(datum),
57
- O.match(() => {
58
- throw new Error('Expected a StakingPosition datum.');
59
- }, F.identity),
60
- );
61
- }
62
-
63
- export function parseStakingManagerDatum(datum: string): StakingManager {
64
- return match(
65
- EvoCore.Data.withSchema(
66
- StakingDatumSchema,
67
- DEFAULT_SCHEMA_OPTIONS,
68
- ).fromCBORHex(datum),
69
- )
70
- .with({ totalStake: P.any }, (res) => res)
71
- .otherwise(() => {
72
- throw new Error('Expected a StakingPosition datum.');
73
- });
74
- }
75
-
76
- export function serialiseStakingDatum(d: StakingDatum): string {
77
- return EvoCore.Data.withSchema(
78
- StakingDatumSchema,
79
- DEFAULT_SCHEMA_OPTIONS,
80
- ).toCBORHex(d);
81
- }
@@ -1,41 +0,0 @@
1
- import { Data, Redeemer } from '@lucid-evolution/lucid';
2
- import { AssetClassSchema } from '../../types/generic';
3
-
4
- const StakingParamsSchema = Data.Object({
5
- stakingManagerNft: AssetClassSchema,
6
- stakingToken: AssetClassSchema,
7
- indyToken: AssetClassSchema,
8
- pollToken: AssetClassSchema,
9
- versionRecordToken: AssetClassSchema,
10
- collectorValHash: Data.Bytes(),
11
- });
12
- type StakingParams = Data.Static<typeof StakingParamsSchema>;
13
- const StakingParams = StakingParamsSchema as unknown as StakingParams;
14
-
15
- const StakingRedeemerSchema = Data.Enum([
16
- Data.Object({
17
- CreateStakingPosition: Data.Object({
18
- creatorPkh: Data.Bytes(),
19
- }),
20
- }),
21
- Data.Literal('UpdateTotalStake'),
22
- Data.Literal('Distribute'),
23
- Data.Object({
24
- AdjustStakedAmount: Data.Object({
25
- adjustAmount: Data.Integer(),
26
- }),
27
- }),
28
- Data.Literal('Unstake'),
29
- Data.Literal('Lock'),
30
- Data.Literal('UpgradeVersion'),
31
- ]);
32
- export type StakingRedeemer = Data.Static<typeof StakingRedeemerSchema>;
33
- const StakingRedeemer = StakingRedeemerSchema as unknown as StakingRedeemer;
34
-
35
- export function serialiseStakingRedeemer(redeemer: StakingRedeemer): Redeemer {
36
- return Data.to<StakingRedeemer>(redeemer, StakingRedeemer);
37
- }
38
-
39
- export function castStakingParams(params: StakingParams): Data {
40
- return Data.castTo(params, StakingParams);
41
- }
@@ -1,37 +0,0 @@
1
- import {
2
- applyParamsToScript,
3
- Constr,
4
- fromText,
5
- SpendingValidator,
6
- } from '@lucid-evolution/lucid';
7
- import { TreasuryParamsSP } from '../../types/system-params';
8
- import { _treasuryValidator } from '../../validators/treasury-validator';
9
-
10
- export const mkTreasuryValidatorFromSP = (
11
- params: TreasuryParamsSP,
12
- ): SpendingValidator => {
13
- return {
14
- type: 'PlutusV2',
15
- script: applyParamsToScript(_treasuryValidator.cborHex, [
16
- new Constr(0, [
17
- new Constr(0, [
18
- params.upgradeToken[0].unCurrencySymbol,
19
- fromText(params.upgradeToken[1].unTokenName),
20
- ]),
21
- new Constr(0, [
22
- params.versionRecordToken[0].unCurrencySymbol,
23
- fromText(params.versionRecordToken[1].unTokenName),
24
- ]),
25
- params.treasuryUtxosStakeCredential
26
- ? new Constr(0, [
27
- new Constr(0, [
28
- new Constr(1, [
29
- params.treasuryUtxosStakeCredential.contents.contents,
30
- ]),
31
- ]),
32
- ])
33
- : new Constr(1, []),
34
- ]),
35
- ]),
36
- };
37
- };
@@ -1,44 +0,0 @@
1
- import {
2
- addAssets,
3
- Data,
4
- LucidEvolution,
5
- OutRef,
6
- TxBuilder,
7
- } from '@lucid-evolution/lucid';
8
- import {
9
- fromSystemParamsScriptRef,
10
- SystemParams,
11
- } from '../../types/system-params';
12
- import { matchSingle } from '../../utils/utils';
13
- import { mkLovelacesOf } from '../../utils/value-helpers';
14
- import { serialiseTreasuryRedeemer } from './types';
15
-
16
- export async function treasuryFeeTx(
17
- fee: bigint,
18
- lucid: LucidEvolution,
19
- sysParams: SystemParams,
20
- tx: TxBuilder,
21
- treasuryOref: OutRef,
22
- ): Promise<void> {
23
- const treasuryUtxo = matchSingle(
24
- await lucid.utxosByOutRef([treasuryOref]),
25
- (_) => new Error('Expected a single treasury UTXO'),
26
- );
27
-
28
- const treasuryRefScriptUtxo = matchSingle(
29
- await lucid.utxosByOutRef([
30
- fromSystemParamsScriptRef(
31
- sysParams.scriptReferences.treasuryValidatorRef,
32
- ),
33
- ]),
34
- (_) => new Error('Expected a single treasury Ref Script UTXO'),
35
- );
36
-
37
- tx.readFrom([treasuryRefScriptUtxo])
38
- .collectFrom([treasuryUtxo], serialiseTreasuryRedeemer('CollectAda'))
39
- .pay.ToContract(
40
- treasuryUtxo.address,
41
- { kind: 'inline', value: Data.void() },
42
- addAssets(treasuryUtxo.assets, mkLovelacesOf(fee)),
43
- );
44
- }
@@ -1,55 +0,0 @@
1
- import { Data, Datum, Redeemer } from '@lucid-evolution/lucid';
2
- import {
3
- AssetClassSchema,
4
- OutputReferenceSchema,
5
- StakeCredentialSchema,
6
- } from '../../types/generic';
7
-
8
- export const TreasuryParamsSchema = Data.Object({
9
- upgradeToken: AssetClassSchema,
10
- versionRecordToken: AssetClassSchema,
11
- treasuryUtxosStakeCredential: Data.Nullable(StakeCredentialSchema),
12
- });
13
- export type TreasuryParams = Data.Static<typeof TreasuryParamsSchema>;
14
- export const TreasuryParams = TreasuryParamsSchema as unknown as TreasuryParams;
15
-
16
- const TreasuryRedeemerSchema = Data.Enum([
17
- Data.Literal('Withdraw'),
18
- Data.Literal('PrepareWithdraw'),
19
- Data.Literal('Split'),
20
- Data.Literal('Merge'),
21
- Data.Literal('CollectAda'),
22
- Data.Literal('UpgradeVersion'),
23
- ]);
24
- export type TreasuryRedeemer = Data.Static<typeof TreasuryRedeemerSchema>;
25
- const TreasuryRedeemer = TreasuryRedeemerSchema as unknown as TreasuryRedeemer;
26
-
27
- const WithdrawalOutputDatumSchema = Data.Tuple([
28
- Data.Bytes(),
29
- OutputReferenceSchema,
30
- ]);
31
- export type WithdrawalOutputDatum = Data.Static<
32
- typeof WithdrawalOutputDatumSchema
33
- >;
34
- const WithdrawalOutputDatum =
35
- WithdrawalOutputDatumSchema as unknown as WithdrawalOutputDatum;
36
-
37
- export function serialiseWithdrawalOutputDatum(
38
- d: WithdrawalOutputDatum,
39
- ): Datum {
40
- return Data.to<WithdrawalOutputDatum>(d, WithdrawalOutputDatum);
41
- }
42
-
43
- export function serialiseTreasuryRedeemer(
44
- redeemer: TreasuryRedeemer,
45
- ): Redeemer {
46
- return Data.to<TreasuryRedeemer>(redeemer, TreasuryRedeemer);
47
- }
48
-
49
- export function serialiseTreasuryDatum(): Datum {
50
- return Data.void();
51
- }
52
-
53
- export function castTreasuryParams(params: TreasuryParams): Data {
54
- return Data.castTo(params, TreasuryParams);
55
- }
@@ -1,29 +0,0 @@
1
- import {
2
- applyParamsToScript,
3
- MintingPolicy,
4
- SpendingValidator,
5
- } from '@lucid-evolution/lucid';
6
- import {
7
- castVersionRecordTokenParams,
8
- VersionRecordTokenParams,
9
- } from './types';
10
- import { _versionRecordTokenPolicy } from '../../validators/version-record-policy';
11
- import { _versionRegistryValidator } from '../../validators/version-registry-validator';
12
-
13
- export function mkVersionRecordTokenPolicy(
14
- params: VersionRecordTokenParams,
15
- ): MintingPolicy {
16
- return {
17
- type: 'PlutusV2',
18
- script: applyParamsToScript(_versionRecordTokenPolicy.cborHex, [
19
- castVersionRecordTokenParams(params),
20
- ]),
21
- };
22
- }
23
-
24
- export const mkVersionRegistryValidator = (): SpendingValidator => {
25
- return {
26
- type: 'PlutusV2',
27
- script: _versionRegistryValidator.cborHex,
28
- };
29
- };
@@ -1,19 +0,0 @@
1
- import { Core as EvoCore } from '@evolution-sdk/evolution';
2
- import { DEFAULT_SCHEMA_OPTIONS } from '../../types/evolution-schema-options';
3
-
4
- const VersionRecordDatumSchema = EvoCore.TSchema.Struct({
5
- upgradeId: EvoCore.TSchema.Integer,
6
- /// Underlying representation of the following mapping: ValidatorHash -> UpgradePath
7
- upgradePaths: EvoCore.TSchema.Map(
8
- EvoCore.TSchema.ByteArray,
9
- EvoCore.TSchema.ByteArray,
10
- ),
11
- });
12
- export type VersionRecordDatum = typeof VersionRecordDatumSchema.Type;
13
-
14
- export function serialiseVersionRecordDatum(d: VersionRecordDatum): string {
15
- return EvoCore.Data.withSchema(
16
- VersionRecordDatumSchema,
17
- DEFAULT_SCHEMA_OPTIONS,
18
- ).toCBORHex(d);
19
- }
@@ -1,267 +0,0 @@
1
- import { match, P } from 'ts-pattern';
2
- import { ONE_DAY } from '../../utils/time-helpers';
3
- import { OCD_DECIMAL_UNIT } from '../../types/on-chain-decimal';
4
- import { array as A } from 'fp-ts';
5
- import { bigintMax, bigintMin } from '../../utils/bigint-utils';
6
-
7
- type Schedule = {
8
- vestedAtTime: bigint;
9
- unlockAmt: bigint;
10
- };
11
-
12
- type VestingSchedule = {
13
- maxUnlockable: bigint;
14
- schedule: Schedule[];
15
- };
16
-
17
- const teamVestingSchedule: Schedule[] = [
18
- {
19
- vestedAtTime: 1669067100000n,
20
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
21
- },
22
- {
23
- vestedAtTime: 1672523100000n,
24
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
25
- },
26
- {
27
- vestedAtTime: 1675201500000n,
28
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
29
- },
30
- {
31
- vestedAtTime: 1677620700000n,
32
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
33
- },
34
- {
35
- vestedAtTime: 1680299100000n,
36
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
37
- },
38
- {
39
- vestedAtTime: 1682891100000n,
40
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
41
- },
42
- {
43
- vestedAtTime: 1685569500000n,
44
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
45
- },
46
- {
47
- vestedAtTime: 1688161500000n,
48
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
49
- },
50
- {
51
- vestedAtTime: 1690839900000n,
52
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
53
- },
54
- {
55
- vestedAtTime: 1693518300000n,
56
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
57
- },
58
- {
59
- vestedAtTime: 1696110300000n,
60
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
61
- },
62
- {
63
- vestedAtTime: 1698788700000n,
64
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
65
- },
66
- {
67
- vestedAtTime: 1701380700000n,
68
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
69
- },
70
- {
71
- vestedAtTime: 1704059100000n,
72
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
73
- },
74
- {
75
- vestedAtTime: 1706737500000n,
76
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
77
- },
78
- {
79
- vestedAtTime: 1709243100000n,
80
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
81
- },
82
- {
83
- vestedAtTime: 1711921500000n,
84
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
85
- },
86
- {
87
- vestedAtTime: 1714513500000n,
88
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
89
- },
90
- {
91
- vestedAtTime: 1717191900000n,
92
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
93
- },
94
- {
95
- vestedAtTime: 1719783900000n,
96
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
97
- },
98
- {
99
- vestedAtTime: 1722462300000n,
100
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
101
- },
102
- {
103
- vestedAtTime: 1725140700000n,
104
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
105
- },
106
- {
107
- vestedAtTime: 1727732700000n,
108
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
109
- },
110
- {
111
- vestedAtTime: 1730411100000n,
112
- unlockAmt: 328_125n * OCD_DECIMAL_UNIT,
113
- },
114
- ];
115
-
116
- const spDistributionSchedule: VestingSchedule = {
117
- maxUnlockable: 14_000_000n * OCD_DECIMAL_UNIT,
118
- schedule: [
119
- {
120
- vestedAtTime: 1669931100000n,
121
- unlockAmt: 28_768n * OCD_DECIMAL_UNIT,
122
- },
123
- {
124
- vestedAtTime: 1701467100000n,
125
- unlockAmt: 33_562n * OCD_DECIMAL_UNIT,
126
- },
127
- {
128
- vestedAtTime: 1727387100000n,
129
- unlockAmt: 33_561n * OCD_DECIMAL_UNIT,
130
- },
131
- {
132
- vestedAtTime: 1733003100000n,
133
- unlockAmt: 38_356n * OCD_DECIMAL_UNIT,
134
- },
135
- {
136
- vestedAtTime: 1764539100000n,
137
- unlockAmt: 43_150n * OCD_DECIMAL_UNIT,
138
- },
139
- {
140
- vestedAtTime: 1796075100000n,
141
- unlockAmt: 47_945n * OCD_DECIMAL_UNIT,
142
- },
143
- ],
144
- };
145
-
146
- const liqDistributionSchedule: VestingSchedule = {
147
- maxUnlockable: 5_250_000n * OCD_DECIMAL_UNIT,
148
- schedule: [
149
- {
150
- vestedAtTime: 1671659100000n,
151
- unlockAmt: 4_795n * OCD_DECIMAL_UNIT,
152
- },
153
- {
154
- vestedAtTime: 1703195100000n,
155
- unlockAmt: 9_590n * OCD_DECIMAL_UNIT,
156
- },
157
- {
158
- vestedAtTime: 1728683100000n,
159
- unlockAmt: 9_589n * OCD_DECIMAL_UNIT,
160
- },
161
- {
162
- vestedAtTime: 1734731100000n,
163
- unlockAmt: 14_383n * OCD_DECIMAL_UNIT,
164
- },
165
- {
166
- vestedAtTime: 1766267100000n,
167
- unlockAmt: 19_178n * OCD_DECIMAL_UNIT,
168
- },
169
- {
170
- vestedAtTime: 1797803100000n,
171
- unlockAmt: 23_972n * OCD_DECIMAL_UNIT,
172
- },
173
- ],
174
- };
175
-
176
- const govDistributionSchedule: VestingSchedule = {
177
- maxUnlockable: 1_750_000n * OCD_DECIMAL_UNIT,
178
- schedule: [
179
- {
180
- vestedAtTime: 1670363100000n,
181
- unlockAmt: 2_398n * OCD_DECIMAL_UNIT,
182
- },
183
- {
184
- vestedAtTime: 1701899100000n,
185
- unlockAmt: 3_596n * OCD_DECIMAL_UNIT,
186
- },
187
- {
188
- vestedAtTime: 1733435100000n,
189
- unlockAmt: 4_795n * OCD_DECIMAL_UNIT,
190
- },
191
- {
192
- vestedAtTime: 1752443100000n,
193
- unlockAmt: 4_794n * OCD_DECIMAL_UNIT,
194
- },
195
- {
196
- vestedAtTime: 1764971100000n,
197
- unlockAmt: 5_993n * OCD_DECIMAL_UNIT,
198
- },
199
- {
200
- vestedAtTime: 1796507100000n,
201
- unlockAmt: 7_191n * OCD_DECIMAL_UNIT,
202
- },
203
- ],
204
- };
205
-
206
- export function calculateTotalVestedTeam(currentTime: bigint): bigint {
207
- return A.reduce<Schedule, bigint>(0n, (acc, schedule) => {
208
- if (currentTime >= schedule.vestedAtTime) {
209
- return acc + schedule.unlockAmt;
210
- } else {
211
- return acc;
212
- }
213
- })(teamVestingSchedule);
214
- }
215
-
216
- function calculateVestedPerEpoch(
217
- schedule: VestingSchedule,
218
- currentTime: bigint,
219
- ): bigint {
220
- const vestingFreq = 5n * ONE_DAY;
221
-
222
- function go(sched: Schedule[]): bigint {
223
- return (
224
- match(sched)
225
- .returnType<bigint>()
226
- .with([], () => 0n)
227
- // If the current time is earlier than the first vesting period,
228
- // the vested INDY is zero.
229
- // Otherwise, the vested INDY increases by the given amount every epoch
230
- // after the given date.
231
- // The + 1 indicates that the first vest happens from the given date
232
- // (as opposed to having to wait for an epoch to complete)
233
- .with([P.select()], (sched) =>
234
- bigintMax(
235
- 0n,
236
- ((currentTime - sched.vestedAtTime) / vestingFreq + 1n) *
237
- sched.unlockAmt,
238
- ),
239
- )
240
- // If the current time is past the first period in the schedule,
241
- // at least all INDY from the first period is vested, and can proceed
242
- // to compute the vested amount for remaining periods.
243
- .with([P._, P._, ...P.array()], ([sched1, sched2, ...rest]) =>
244
- currentTime >= sched2.vestedAtTime
245
- ? ((sched2.vestedAtTime - sched1.vestedAtTime) / vestingFreq) *
246
- sched1.unlockAmt +
247
- go([sched2, ...rest])
248
- : bigintMax(
249
- 0n,
250
- ((currentTime - sched1.vestedAtTime) / vestingFreq + 1n) *
251
- sched1.unlockAmt,
252
- ),
253
- )
254
- .run()
255
- );
256
- }
257
-
258
- return bigintMin(schedule.maxUnlockable, go(schedule.schedule));
259
- }
260
-
261
- export function calculateTotalVestedRewards(currentTime: bigint): bigint {
262
- return (
263
- calculateVestedPerEpoch(spDistributionSchedule, currentTime) +
264
- calculateVestedPerEpoch(govDistributionSchedule, currentTime) +
265
- calculateVestedPerEpoch(liqDistributionSchedule, currentTime)
266
- );
267
- }
@@ -1,16 +0,0 @@
1
- import { CodecOptions } from '@evolution-sdk/evolution/core/CBOR';
2
-
3
- /**
4
- * This is related to our on-chain codebase for aiken v1.0.26-alpha
5
- */
6
- export const DEFAULT_SCHEMA_OPTIONS = {
7
- mode: 'custom',
8
- useIndefiniteArrays: true,
9
- // This is important to match aiken's Map encoding.
10
- useIndefiniteMaps: false,
11
- useDefiniteForEmpty: true,
12
- sortMapKeys: false,
13
- useMinimalEncoding: true,
14
- mapsAsObjects: false,
15
- encodeMapAsPairs: false,
16
- } as const satisfies CodecOptions;
@@ -1,7 +0,0 @@
1
- export function bigintMax(a: bigint, b: bigint): bigint {
2
- return a > b ? a : b;
3
- }
4
-
5
- export function bigintMin(a: bigint, b: bigint): bigint {
6
- return a < b ? a : b;
7
- }
@@ -1,4 +0,0 @@
1
- export const ONE_SECOND: number = 1_000;
2
- export const ONE_HOUR: bigint = 3_600_000n;
3
- export const ONE_DAY: bigint = 86_400_000n;
4
- export const ONE_YEAR: bigint = 31_536_000_000n;
@@ -1,7 +0,0 @@
1
- // Automatically generated by the sdk-export.sh script in aiken smart contracts repository
2
- export const _lrpValidator = {
3
- type: 'PlutusScriptV2',
4
- description: 'Generated by Aiken',
5
- cborHex:
6
- '5916fb5916f80100003232323232323232322223232323232322533300b323232533300e30083011375400226464646464646464646464646464646464646464646464646464a66605060480322646464646464646464646464a6660726078004264a66606a605e60706ea80044c8c94ccc0f0c0fc0084c8c8c8c94ccc0ecc0dcc0f8dd50008991919299981f181d18209baa001132533303f3302149110496e636f727265637420694173736574003371e6eb8c0a8c10cdd50049bae30243043375407a264a6660806664446464944c8ccc00400406d2f5bded8c0444a66609800420022666006006609e00464a66609066ebcc0ccc130dd5181998261baa302d304c37540020102646464a666096608e00226601000a6eb4c148c13cdd50018a999825982280089919191919192999828a99982899982899b8f375c60b0008020941288a51153330513330513375e004032941288a5113330513375e01e002941288a99829a4812452656465656d417578207573657320696e636f7272656374206173736574207374617473001613300e00b005305730580023056001305600130553055002375a60a6002609e6ea800c54cc1352412d4578706563746564206f6e6c792052656465656d2072656465656d65727320666f72204c525020696e707574730016304d3754004608200266046606660986ea800405c4008c13800888c8cc00400400c894ccc1300044cc134cdd81ba800333048499300103d87980004bd6f7b6300991919192999825981da99982599b8800700214c103d87980001533304b3371000400e2980103d87b800014c103d87a8000133051337606ea001ccc131264c103d87980000051533304b3370e00e004264a6660986090609e6ea80044cc148cdd81ba80083304d32498c14cc140dd5000a60103d8798000004100453304d49126436f6e74696e75696e67206f75747075747320646f75626c6520736174697366616374696f6e0016133051337606ea0008cc130005300103d87980003300600600332498c13800cdd6982600118280011827000981598221baa004375c605660886ea8028c004c110dd50050999999981001f80280100201f004180098221baa00a14a04608e6090609060906090609060906090609060900022940c114c108dd50008b1980d80780a981398201baa3021304037540026084607e6ea800458cc05c0400b0c0540dcc94ccc0e4c0d4c0f0dd500089820181e9baa001132533303a32533303b3035303e3754002266e24dd69810181f9baa002375a6084607e6ea800454cc0f524124496e636f7272656374207472616e73616374696f6e2076616c69646974792072616e676500163025303e3754603e607c6ea802854cc0f12401174f7261636c652063616e27742062652065787069726564001613025303e37540026464004a666074606c607a6ea80044c8c8c8c94ccc10cc1180084c926303900316375a608800260880046084002607c6ea800458c048c074c0f4dd5180f181e9baa32533303f001153303c49012145787065637465642065786163746c79206f6e65206f7261636c6520696e70757400161533303f304200113041001153303c49012145787065637465642065786163746c79206f6e65206f7261636c6520696e707574001633301300d3040303d37546080607a6ea8005300103d8798000301d303c375400464a666070606860766ea80084c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c8c94ccc164c1700084c8c8c8c8c8c8c8c8c8c8c8c926325333060305c001132325333067306a002149858dd7183400098321baa00d15333060305a001153330653064375401a2930b0b18311baa00c305900f30580103057011305601230550133054014305301530520163051017301e018325333055305100113232533305c305f002132498c14800458c174004c164dd500d0a99982a982780089919299982e182f80109924ca6660ae60a660b46ea80044c8c94ccc178c1840084c926302200116305f001305b37540022c2c60ba00260b26ea806858c15cdd500c8b182d000982d00119299982b982b0008a9998291826182a8008a5115333052304e305500114a02c2c6ea8c160004c160008c158004c158008c150004c150008c148004c148008c140004c140008c138004c138008c130004c130008c128004c128008c120004c120008c118004c118008c110004c110008c108004c108008dd71820000981e1baa00216253330383034303b3754002264646464a66608260880042930b1bae30420013042002375c608000260786ea80045858c0f4004c0e4dd50008b1806980c181c1baa3019303837540022c607400266601800c602e606c6ea80c5300103d87980003756607060726072004606e002606e606e606e606e606e0046eb0c0d4004c0d4008dd6181980098198011bac3031001302d375403a6eb4c0bcc0b0dd50128a999814181100c899191919191919191919191919191919299981c181a181d9baa0011323232533303b3037303e375400226464a66607a607260806ea80044c8c94ccc110c11c0084c94ccc100c0f0c10cdd5000899299982099811a4810c57726f6e6720696173736574003371e0286eb8c098c114dd501f8a99982099811a491e52656465656d207574786f2066726f6d2077726f6e672061646472657373003375e6058608a6ea8c0b0c114dd5181318229baa006302c304537540102666666604208001200201007e0240222940528182398221baa001163301d00b01616375a608a00260826ea800458cc05c04401cc108c0fcdd50008b1980b8040079812181e9baa301e303d3754002607e60786ea800458cc0500140a4c0480d0dd5981e181e981e981e981e981e981e981e8011bac303b001303b303b00237586072002606a6ea8094c0dcc0e0008c0d8004c0d8008dd7181a000981a001181900098190011bad3030001302c375404a264a66605260440342646601892011754582069736e74207369676e6564206279206f776e657200330023758606260646064606460646064606460646064605c6ea8078dd7180a98171baa02830050271333232322232323232325333033302f30363754002264a666068605c606e6ea80044c8c8c94ccc0f0c0fc0084c8c8c94ccc0e8c0d8c0f4dd500089980e19807998201ba937309201084d697373696e6720003304037526e60038cc100dd49b984901172075706772616465206d696e74696e6720706f6c696379004bd70249003301230103302300948900375c6082607c6ea800454cc0f0cc03ccc100dd49b98491084d697373696e6720003304037526e60038cc100dd49b9849010d20757067726164652070617468004bd70249001632533303a3034303d3754002298103d87a8000130223304037526eb8c0f8c8cdd81821000982118218009bac3041303e375400297ae032330010013756603e607c6ea800c894ccc1000045300103d87a800013232533303d3371e6eb8c1000080244c094cc10cdd399821982000119821982080125eb812f5c026600800800260880046084002a666070606860766ea80044c8c8c8c94ccc104c1100084c926323300100100222533304300114984c8cc00c00cc11c008c8c8dd718220011bae30420013045001163756608400260840046eb4c100004c0f0dd50008b1808180d981d9baa301c303b37540022c607a00266601e00a01098103d8798000375c607660706ea800458c078c0dcdd5180f181b9baa3018303737546074606e6ea800458cc03cdd6181c8020121bab30383039303930390023758606e002606e00260646ea808888dcc991919980080080224410022253330360021001132333004004303a0035333032302e371a00426e600044cdc500119b8a00537300026e64dd7181c0011b98001300100122533303000114bd7009981898171819000998010011819800a49034c5250003014302d375405044646600200200644a66606200229404c94ccc0b4cdc79bae303400200414a226600600600260680024a666050604260566ea80044c0bcc0b0dd50008a998152481134e6f7420616e20696e6c696e6520646174756d00162223233014004230023010302f3754002a666052604a60586ea800448c090ccc040dd5980798171baa001375c602a605c6ea800cdd7180798171baa003123371090001998081bab300f302e37540026eb8c054c0b8dd50019bae300f302e37540064464a666050604860566ea80044c0bcc0b0dd50008a9981524917436f756c64206e6f742066696e642072656465656d6572001632323300100100322533302f00114c0103d87a80001323232533302d3375e00c60600062602a6606600297ae01330050050023030002303300230310013374a90011981680125eb8094ccc094c084c0a0dd5000899191919191919192999819181a80109924c60500062c6eb4c0cc004c0cc008c0c4004c0c4008dd7181780098178011bae302d001302937540022c44646600200200644a6660580022980103d87a80001323253330293375e6028605a6ea80080144c044cc0bc0092f5c02660080080026060004605c0026002002444a6660520042980103d87a800013232533302630220031300e3302c0024bd70099980280280099b8000348004c0b400cc0ac0088888888c8c8c94ccc0a8cc03124011e48617320746f2072656465656d206174206c6561737420746865206d696e00337126eb4c02cc0b8dd50050010a99981519806249124d617820707269636520657863656564656400337126eb4c054c0b8dd50029bad3015302e3754601c605c6ea801854ccc0a8cc0312411b52656465656d696e67206d6f7265207468616e20616c6c6f77656400337120046eb4c02cc0b8dd50030a999815198062490d4e6f2073637269707420726566003375e6016605c6ea8021300103d87a800013300c49011757726f6e6720636f6e74696e75696e67206f75747075740033332222323300100133019005533302f302b30323754008264466ebcc070c0d4dd5180e181a9baa001002303630333754008264466ebcc070c0d4dd5000801181b18199baa00422533303500114a0264a66606264a66606466ebcc058c0d8dd5000803099299981c0008a5115333038303b001132323253330363371e6eb8c0f400d22100153330363371e00291010015333036303230393754980103d87a800015333036337129000001099b89002482026fb808528099b89480000085280a50375c6078607a0046eb4c0ecc0f0c0f0004dd6181d0008a503233001001323330010013756603260706ea800cc8cc004004020894ccc0ec00452f5bded8c02646607a66ec0dd49bae303a001374c64660020026eacc0f0008894ccc0f800452f5bded8c02646608066ec0dd49bae303d001375066e052000375a607c002660060066084004608000266006006607e004607a002444a6660760042002264666008008607e0066666604a0046eb8c0e8004dd5981d80091119299981d98140008a60103d87a80001302333041374c00297ae0323330010010030022225333042002100113233300400430460033333302d002375c60820026eb4c108004888c94ccc108c0f80045300103d87a80001302a33048375000297ae0337000040020546088004046607a00444a666072002297ae0132333222323300100100322533303f001100313233041374e660826ea4018cc104dd49bae303e0013304137506eb4c0fc0052f5c066006006608600460820026eb8c0e0004dd5981c80099801801981e801181d8008a50303800214a226600600600260700026606001097ae03374a900119818003a5eb80cdd2a400866060646460286606460660046606460660026606460666068002660646ea0cdc09bad300d3030375401000897ae03033001302e375400c97ae033330113333011330133756601e605c6ea8c03cc0b8dd5004a44100488100488100001375c601c605c6ea8028dd7180798171baa00600314a029405280a503370066e04ccc03cdd5980718169baa300e302d375401091010048810000153330293371200290000a400026eb4c050c0b4dd51808998179ba83370666e08dd6980a18169baa3300c30113302f375000297ae00034820225e8dd6980a18169baa30113302f375066e0920c8014820225e92f5c097ae0375a602660586ea8cc02cc040cc0b8dd4000a5eb8000ccdc09998069bab300c302b375400a6eb8c02cc0acdd50039bae300c302b375400666601a6eacc030c0acdd5180618159baa006375c601660566ea801cdd7180618159baa003230273028302830280012253330203330200014a094454cc0880084004400488c01ccc094dd419b83337046eb4c028c08cdd50011bad300a30233754002904044bd25eb808c090c094c0940048c08cc090004888c94ccc078c060c084dd50008a400026eb4c094c088dd500099299980f180c18109baa00114c103d87a8000132330010013756604c60466ea8008894ccc094004530103d87a8000132323253330233371e00e6eb8c09800c4c02ccc0a4dd4000a5eb804cc014014008dd698130011814801181380099198008008021129998120008a6103d87a8000132323253330223371e00e6eb8c09400c4c028cc0a0dd3000a5eb804cc014014008dd59812801181400118130009111299980e980c8008802099999805802001991900119198008008011129998128008a4c264a66604c002293099192999811980f98131baa3300f375c604c60540086eb8c0980084cc014014cc0a400800454cc0952401326b65797320696e206173736f63696174697665206c697374206172656e277420696e20617363656e64696e67206f726465720016302a0023028001302800133023337606ea4008dd4000a5eb7bdb180888c94ccc084c038004530103d87a80001300933027374c00297ae03333300f001005004222325333024302000114c103d87a80001300c3302a375000297ae0337000020040180126e95200022323300100100322533302000114bd6f7b630099191919299980f99b8f0070021003133025337606ea4008dd3000998030030019bab3022003375c60400046048004604400244646600200200644a66603e002297ae013232533301c300500213302200233004004001133004004001302300230210012301d001225333016337200040022980103d8798000153330163371e0040022980103d87a800014c103d87b80002533301900114a2294088888c8cc004004018894ccc0780044cc07ccdd81ba9006374c00a97adef6c60132323232533301d300d3300700a002133023337606ea4028dd30048028a99980e99b8f00a002132533301e301a3021375400226604866ec0dd4805981298111baa001004100433300800a009001133023337606ea4008dd3000998030030019bab3020003375c603c0046044004604000244444646600200200c44a66603a00226603c66ec0dd48031ba80054bd6f7b630099191919299980e18061980380500109981119bb037520146ea002401454ccc070cdc7805001099299980e980c98101baa001133023337606ea402cc090c084dd5000802080219980400500480089981119bb037520046ea0004cc01801800cdd6980f8019bae301d0023021002301f001375e98103d879800030123754018602a60246ea800458c050c054008c04c004c03cdd50008a4c26cac600200c464a666014600c00226464a66602260280042930b1bad3012001300e37540042a6660146008002264646464646464646464a666032603800426464649318088019808002299980a1808180b9baa007132323232533301d30200021324994ccc060c050c06cdd500189919299980f98110010a4c2c6eb8c080004c070dd50018b0b1bad301e001301e002301c0013018375400e2c2c60340026034004603000260300046eb8c058004c058008c050004c050008dd6980900098071baa0021533300a30030011533300f300e37540042930b0a99980519b874801800454ccc03cc038dd50010a4c2c2c60186ea8004dc3a40086e1d20022533300630023009375400226464a66601a60200042930b1bad300e001300a37540022c6e1d20005734ae6d5ce2ab9d5573caae7d5d02ba15745',
7
- };