@indigo-labs/indigo-sdk 0.1.2 → 0.1.4

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 (40) hide show
  1. package/README.md +52 -7
  2. package/dist/index.d.mts +1064 -182
  3. package/dist/index.d.ts +1064 -182
  4. package/dist/index.js +2565 -561
  5. package/dist/index.mjs +2546 -593
  6. package/package.json +64 -43
  7. package/.nvmrc +0 -1
  8. package/.prettierrc +0 -6
  9. package/babel.config.cjs +0 -13
  10. package/examples/sample-cdp.ts +0 -43
  11. package/jest.config.js +0 -13
  12. package/src/contracts/cdp-creator.ts +0 -86
  13. package/src/contracts/cdp.ts +0 -892
  14. package/src/contracts/collector.ts +0 -91
  15. package/src/contracts/gov.ts +0 -58
  16. package/src/contracts/interest-oracle.ts +0 -49
  17. package/src/contracts/price-oracle.ts +0 -24
  18. package/src/contracts/treasury.ts +0 -95
  19. package/src/helpers/asset-helpers.ts +0 -28
  20. package/src/helpers/cdp-helpers.ts +0 -9
  21. package/src/helpers/helpers.ts +0 -17
  22. package/src/helpers/lucid-utils.ts +0 -24
  23. package/src/helpers/time-helpers.ts +0 -3
  24. package/src/index.ts +0 -23
  25. package/src/scripts/cdp-creator-validator.ts +0 -9
  26. package/src/scripts/cdp-validator.ts +0 -9
  27. package/src/scripts/collector-validator.ts +0 -8
  28. package/src/scripts/interest-oracle-validator.ts +0 -8
  29. package/src/scripts/treasury-validator.ts +0 -8
  30. package/src/types/generic.ts +0 -13
  31. package/src/types/indigo/cdp.ts +0 -33
  32. package/src/types/indigo/gov.ts +0 -21
  33. package/src/types/indigo/interest-oracle.ts +0 -5
  34. package/src/types/indigo/price-oracle.ts +0 -4
  35. package/src/types/system-params.ts +0 -228
  36. package/tests/data/system-params.json +0 -989
  37. package/tests/datums.test.ts +0 -51
  38. package/tests/hash-checks.test.ts +0 -17
  39. package/tests/interest-calculations.test.ts +0 -143
  40. package/tsconfig.json +0 -35
package/package.json CHANGED
@@ -1,45 +1,66 @@
1
1
  {
2
- "name": "@indigo-labs/indigo-sdk",
3
- "version": "0.1.2",
4
- "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
10
- "test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js",
11
- "lint": "eslint .",
12
- "lint:fix": "eslint . --fix",
13
- "prettier": "prettier --ignore-path .gitignore --write \"./src/**/*.+(js|ts|json)\"",
14
- "prettier:fix": "prettier --write src",
15
- "example": "tsup ./examples/sample-cdp.ts --format esm,cjs --dts --clean && node ./dist/sample-cdp.js"
16
- },
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/IndigoProtocol/indigo-sdk.git"
20
- },
21
- "keywords": [
22
- "indigo",
23
- "sdk",
24
- "typescript",
25
- "lucid-evolution",
26
- "cdp"
2
+ "name": "@indigo-labs/indigo-sdk",
3
+ "version": "0.1.4",
4
+ "description": "Indigo SDK for interacting with Indigo endpoints via lucid-evolution",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean --tsconfig tsconfig.build.json",
13
+ "lint": "npx eslint .",
14
+ "lint:fix": "npx eslint --fix .",
15
+ "repack": "pnpm run build && pnpm pack",
16
+ "format": "npx prettier --write src/ tests/",
17
+ "format:check": "npx prettier --check src/ tests/",
18
+ "test": "vitest run",
19
+ "prepare": "husky",
20
+ "lint-staged": "lint-staged"
21
+ },
22
+ "lint-staged": {
23
+ "*.{js,ts,jsx,tsx}": [
24
+ "prettier --write",
25
+ "eslint --fix"
27
26
  ],
28
- "author": "3rd Eye Labs",
29
- "license": "MIT",
30
- "dependencies": {
31
- "@lucid-evolution/lucid": "^0.4.22",
32
- "babel-jest": "^29.5.0"
33
- },
34
- "devDependencies": {
35
- "@babel/core": "^7.21.4",
36
- "@babel/preset-env": "^7.21.4",
37
- "@babel/preset-typescript": "^7.21.4",
38
- "@types/jest": "^29.5.0",
39
- "jest": "^29.5.0",
40
- "ts-jest": "^29.1.0",
41
- "ts-node": "^10.9.1",
42
- "tsup": "^8.3.6",
43
- "typescript": "^5.0.3"
44
- }
45
- }
27
+ "*.{json,md,yml,yaml}": [
28
+ "prettier --write"
29
+ ]
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/IndigoProtocol/indigo-sdk.git"
34
+ },
35
+ "keywords": [
36
+ "indigo",
37
+ "sdk",
38
+ "typescript",
39
+ "lucid-evolution",
40
+ "cdp"
41
+ ],
42
+ "author": "3rd Eye Labs",
43
+ "license": "MIT",
44
+ "dependencies": {
45
+ "@lucid-evolution/experimental": "^0.0.9",
46
+ "@lucid-evolution/lucid": "^0.4.29",
47
+ "dotenv": "^16.5.0",
48
+ "fp-ts": "^2.16.10",
49
+ "ts-pattern": "^5.8.0"
50
+ },
51
+ "devDependencies": {
52
+ "@babel/core": "^7.21.4",
53
+ "@babel/preset-env": "^7.21.4",
54
+ "@babel/preset-typescript": "^7.21.4",
55
+ "@eslint/js": "^9.32.0",
56
+ "@types/node": "^24.3.0",
57
+ "eslint": "^9.32.0",
58
+ "husky": "^9.1.7",
59
+ "lint-staged": "^16.1.5",
60
+ "prettier": "^3.6.2",
61
+ "tsup": "^8.3.6",
62
+ "typescript": "^5.9.2",
63
+ "typescript-eslint": "^8.39.0",
64
+ "vitest": "3.2.4"
65
+ }
66
+ }
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v18.19.1
package/.prettierrc DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "singleQuote": true,
3
- "trailingComma": "all",
4
- "tabWidth": 2,
5
- "semi": true
6
- }
package/babel.config.cjs DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-typescript",
12
- ]
13
- };
@@ -1,43 +0,0 @@
1
- import { Blockfrost, Lucid, OutRef } from "@lucid-evolution/lucid";
2
- import { balance, CDPContract, loadSystemParamsFromUrl } from "../src";
3
-
4
- async function main() {
5
- const lucid = await Lucid(
6
- new Blockfrost(
7
- 'https://cardano-mainnet.blockfrost.io/api/v0',
8
- 'mainnetpb1Y1PczllObhmQKFMO6wm3la39p70k5'
9
- ),
10
- 'Mainnet'
11
- );
12
-
13
- lucid.selectWallet.fromSeed('helmet coconut robot path message library verb lobster rigid taxi recall ribbon vacuum uniform horse thumb praise sibling wise frown cattle settle century sad');
14
-
15
- const systemParams = await loadSystemParamsFromUrl('https://config.indigoprotocol.io/mainnet/mainnet-system-params-v21.json')
16
- const address = await lucid.wallet().address();
17
- const utxos = await lucid.wallet().getUtxos();
18
- const walletBalance = balance(utxos);
19
-
20
- console.log('Wallet Address', address);
21
- console.log('Wallet Balance', walletBalance);
22
-
23
- // const cdpOutRef: OutRef = {txHash: '70b09ded453b6122688d3cd51e2c75a007f2d801d1104eae734d8f5314b2b393', outputIndex: 0};
24
-
25
- const cdpTx = await CDPContract.openPosition('iUSD', 10_000_000n, 7_820_000n, systemParams, lucid);
26
- const cdpBTx = await cdpTx.complete();
27
- const cdpBsTx = await cdpBTx.sign.withWallet().complete();
28
-
29
- console.log(cdpBsTx.toCBOR());
30
- // const cdpTx = await CDPContract.openPosition(
31
- // 'iUSD',
32
- // 10_000_000n,
33
- // 1_000_000n,
34
- // systemParams,
35
- // lucid
36
- // );
37
- // const cdpBTx = await cdpTx.complete()
38
- // const cdpBsTx = await cdpBTx.sign.withWallet().complete()
39
-
40
- // console.log(cdpBsTx.toCBOR());
41
- }
42
-
43
- main();
package/jest.config.js DELETED
@@ -1,13 +0,0 @@
1
- module.exports = {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "targets": {
7
- "node": "current"
8
- }
9
- }
10
- ],
11
- "@babel/preset-typescript",
12
- ]
13
- };
@@ -1,86 +0,0 @@
1
- import {
2
- Address,
3
- applyParamsToScript,
4
- Constr,
5
- Credential,
6
- Data,
7
- fromText,
8
- LucidEvolution,
9
- SpendingValidator,
10
- UTxO,
11
- validatorToAddress,
12
- validatorToScriptHash,
13
- } from '@lucid-evolution/lucid';
14
- import { _cdpCreatorValidator } from '../scripts/cdp-creator-validator';
15
- import { CdpCreatorParams, ScriptReferences } from '../types/system-params';
16
- import { scriptRef } from '../helpers/lucid-utils';
17
-
18
- export class CDPCreatorContract {
19
- static address(params: CdpCreatorParams, lucid: LucidEvolution): Address {
20
- const network = lucid.config().network;
21
- if (!network) {
22
- throw new Error('Network configuration is undefined');
23
- }
24
- return validatorToAddress(network, CDPCreatorContract.validator(params));
25
- }
26
-
27
- static validator(params: CdpCreatorParams): SpendingValidator {
28
- return {
29
- type: 'PlutusV2',
30
- script: applyParamsToScript(_cdpCreatorValidator.cborHex, [
31
- new Constr(0, [
32
- new Constr(0, [
33
- params.cdpCreatorNft[0].unCurrencySymbol,
34
- fromText(params.cdpCreatorNft[1].unTokenName),
35
- ]),
36
- params.cdpAssetCs.unCurrencySymbol,
37
- new Constr(0, [
38
- params.cdpAuthTk[0].unCurrencySymbol,
39
- fromText(params.cdpAuthTk[1].unTokenName),
40
- ]),
41
- new Constr(0, [
42
- params.iAssetAuthTk[0].unCurrencySymbol,
43
- fromText(params.iAssetAuthTk[1].unTokenName),
44
- ]),
45
- new Constr(0, [
46
- params.versionRecordToken[0].unCurrencySymbol,
47
- fromText(params.versionRecordToken[1].unTokenName),
48
- ]),
49
- params.cdpScriptHash,
50
- params.collectorValHash,
51
- BigInt(params.minCollateralInLovelace),
52
- BigInt(params.biasTime),
53
- ]),
54
- ]),
55
- };
56
- }
57
-
58
- static validatorHash(
59
- params: CdpCreatorParams
60
- ): string {
61
- return validatorToScriptHash(CDPCreatorContract.validator(params));
62
- }
63
-
64
- static redeemer(
65
- hash: Credential,
66
- mintedAmount: bigint,
67
- collateralAmount: bigint,
68
- currentTime: bigint,
69
- ): Data {
70
- if (hash.type !== 'Key') throw new Error('Cannot support script hash.');
71
-
72
- return new Constr<Data>(0, [
73
- hash.hash,
74
- BigInt(mintedAmount),
75
- BigInt(collateralAmount),
76
- currentTime
77
- ]);
78
- }
79
-
80
- static scriptRef(
81
- params: ScriptReferences,
82
- lucid: LucidEvolution,
83
- ): Promise<UTxO> {
84
- return scriptRef(params.cdpCreatorValidatorRef, lucid);
85
- }
86
- }