curvance 1.0.13 → 1.0.15

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 (47) hide show
  1. package/README.md +2 -0
  2. package/dist/abis/ProtocolReader.json +54 -10
  3. package/dist/abis/RedstoneCoreAdaptor.json +798 -0
  4. package/dist/chains/index.d.ts +0 -37
  5. package/dist/chains/index.d.ts.map +1 -1
  6. package/dist/chains/index.js +1 -2
  7. package/dist/chains/index.js.map +1 -1
  8. package/dist/chains/monad-testnet.json +65 -101
  9. package/dist/classes/CToken.d.ts +34 -17
  10. package/dist/classes/CToken.d.ts.map +1 -1
  11. package/dist/classes/CToken.js +86 -44
  12. package/dist/classes/CToken.js.map +1 -1
  13. package/dist/classes/ERC20.d.ts +5 -5
  14. package/dist/classes/ERC20.d.ts.map +1 -1
  15. package/dist/classes/ERC20.js +4 -4
  16. package/dist/classes/ERC20.js.map +1 -1
  17. package/dist/classes/Faucet.d.ts +4 -4
  18. package/dist/classes/Faucet.d.ts.map +1 -1
  19. package/dist/classes/Faucet.js +11 -6
  20. package/dist/classes/Faucet.js.map +1 -1
  21. package/dist/classes/Market.d.ts +47 -7
  22. package/dist/classes/Market.d.ts.map +1 -1
  23. package/dist/classes/Market.js +109 -16
  24. package/dist/classes/Market.js.map +1 -1
  25. package/dist/classes/OracleManager.d.ts +3 -3
  26. package/dist/classes/OracleManager.d.ts.map +1 -1
  27. package/dist/classes/OracleManager.js +4 -4
  28. package/dist/classes/OracleManager.js.map +1 -1
  29. package/dist/classes/ProtocolReader.d.ts +20 -10
  30. package/dist/classes/ProtocolReader.d.ts.map +1 -1
  31. package/dist/classes/ProtocolReader.js +23 -12
  32. package/dist/classes/ProtocolReader.js.map +1 -1
  33. package/dist/classes/Redstone.d.ts +14 -0
  34. package/dist/classes/Redstone.d.ts.map +1 -0
  35. package/dist/classes/Redstone.js +57 -0
  36. package/dist/classes/Redstone.js.map +1 -0
  37. package/dist/helpers.d.ts +34 -49
  38. package/dist/helpers.d.ts.map +1 -1
  39. package/dist/helpers.js +104 -18
  40. package/dist/helpers.js.map +1 -1
  41. package/dist/setup.d.ts +5 -3
  42. package/dist/setup.d.ts.map +1 -1
  43. package/dist/setup.js +16 -8
  44. package/dist/setup.js.map +1 -1
  45. package/dist/types.d.ts +4 -1
  46. package/dist/types.d.ts.map +1 -1
  47. package/package.json +5 -3
package/dist/helpers.d.ts CHANGED
@@ -1,19 +1,27 @@
1
- import { JsonRpcSigner, Wallet } from "ethers";
2
- import { BorrowableCToken, CToken } from "./classes/CToken";
3
1
  import { Contract } from "ethers";
4
2
  import { Decimal } from "decimal.js";
5
- import { address } from "./types";
3
+ import { address, curvance_provider, curvance_signer } from "./types";
6
4
  import { chains } from "./chains";
5
+ export type ChainRpcPrefix = keyof typeof chains;
6
+ export declare const BPS: bigint;
7
+ export declare const BPS_SQUARED: bigint;
7
8
  export declare const WAD: bigint;
9
+ export declare const WAD_BPS: bigint;
10
+ export declare const RAY: bigint;
11
+ export declare const WAD_SQUARED: bigint;
12
+ export declare const WAD_CUBED_BPS_OFFSET: bigint;
8
13
  export declare const WAD_DECIMAL: Decimal;
9
- export declare enum AdaptorTypes {
10
- CHAINLINK = 1,
11
- REDSTONE_CORE = 2,
12
- REDSTONE_CLASSIC = 3,
13
- MOCK = 1337
14
- }
15
- export declare function contractSetup<I>(signer: JsonRpcSigner | Wallet, contractAddress: address, abi: any): Contract & I;
16
- export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
14
+ export declare const SECONDS_PER_YEAR = 31536000n;
15
+ export declare const SECONDS_PER_MONTH = 2592000n;
16
+ export declare const SECONDS_PER_WEEK = 604800n;
17
+ export declare const SECONDS_PER_DAY = 86400n;
18
+ export declare const UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
19
+ export declare const EMPTY_ADDRESS: address;
20
+ export declare function toDecimal(value: bigint, decimals: bigint): Decimal;
21
+ export declare function toBigInt(value: number, decimals: bigint): bigint;
22
+ export declare function validateProviderAsSigner(provider: curvance_provider): curvance_signer;
23
+ export declare function contractSetup<I>(provider: curvance_provider, contractAddress: address, abi: any): Contract & I;
24
+ export declare function getContractAddresses(chain: ChainRpcPrefix): {
17
25
  CentralRegistry: string;
18
26
  OracleManager: string;
19
27
  ChainlinkAdaptor: string;
@@ -33,10 +41,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
33
41
  "Test WBTC / Test USDC": {
34
42
  address: string;
35
43
  isMarket: boolean;
36
- plugins: {
37
- simplePositionManager: string;
38
- simpleZapper: string;
39
- };
40
44
  "WBTC-DynamicIRM": string;
41
45
  tokens: {
42
46
  WBTC: string;
@@ -47,10 +51,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
47
51
  "Test LUSD / Test SWETH": {
48
52
  address: string;
49
53
  isMarket: boolean;
50
- plugins: {
51
- simplePositionManager: string;
52
- simpleZapper: string;
53
- };
54
54
  "LUSD-DynamicIRM": string;
55
55
  tokens: {
56
56
  LUSD: string;
@@ -60,10 +60,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
60
60
  "Test mUSD / Test mETH": {
61
61
  address: string;
62
62
  isMarket: boolean;
63
- plugins: {
64
- simplePositionManager: string;
65
- simpleZapper: string;
66
- };
67
63
  tokens: {
68
64
  mUSD: string;
69
65
  mETH: string;
@@ -73,10 +69,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
73
69
  "Test DAI / Test mkUSD": {
74
70
  address: string;
75
71
  isMarket: boolean;
76
- plugins: {
77
- simplePositionManager: string;
78
- simpleZapper: string;
79
- };
80
72
  "DAI-DynamicIRM": string;
81
73
  tokens: {
82
74
  DAI: string;
@@ -97,11 +89,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
97
89
  "Apriori (aprMON) / wMON": {
98
90
  address: string;
99
91
  isMarket: boolean;
100
- plugins: {
101
- simplePositionManager: string;
102
- simpleZapper: string;
103
- vaultZapper: string;
104
- };
105
92
  "aprMON-DynamicIRM": string;
106
93
  tokens: {
107
94
  aprMON: string;
@@ -112,11 +99,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
112
99
  "Fastlane (shMON) / wMON": {
113
100
  address: string;
114
101
  isMarket: boolean;
115
- plugins: {
116
- simplePositionManager: string;
117
- simpleZapper: string;
118
- vaultZapper: string;
119
- };
120
102
  "shMON-DynamicIRM": string;
121
103
  tokens: {
122
104
  shMON: string;
@@ -127,11 +109,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
127
109
  "Magma (gMON) / wMON": {
128
110
  address: string;
129
111
  isMarket: boolean;
130
- plugins: {
131
- simplePositionManager: string;
132
- simpleZapper: string;
133
- vaultZapper: string;
134
- };
135
112
  "gMON-DynamicIRM": string;
136
113
  tokens: {
137
114
  gMON: string;
@@ -142,11 +119,6 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
142
119
  "Kintsu (sMON) / wMON": {
143
120
  address: string;
144
121
  isMarket: boolean;
145
- plugins: {
146
- simplePositionManager: string;
147
- simpleZapper: string;
148
- vaultZapper: string;
149
- };
150
122
  "sMON-DynamicIRM": string;
151
123
  tokens: {
152
124
  sMON: string;
@@ -156,6 +128,19 @@ export declare function getContractAddresses(chain: ChainRpcPrefix): never[] | {
156
128
  };
157
129
  ProtocolReader: string;
158
130
  };
159
- export declare function handleTransactionWithOracles<T>(exec_func: Function, token: CToken | BorrowableCToken, adaptor: AdaptorTypes): Promise<T>;
160
- export type ChainRpcPrefix = keyof typeof chains;
131
+ /**
132
+ * Wraps a contract instance so all write actions automatically add a gas buffer.
133
+ *
134
+ * How it works:
135
+ * 1. Creates a proxy around the contract
136
+ * 2. Intercepts all function calls
137
+ * 3. For contract methods that support it, estimates gas usage
138
+ * 4. Adds the specified buffer percentage to the gas limit
139
+ * 5. Calls the original method with the buffered gas limit
140
+ *
141
+ * @param contract The ethers contract instance to wrap
142
+ * @param bufferPercent The percentage buffer to add (default 20%)
143
+ * @returns The same contract but with automatic gas buffering
144
+ */
145
+ export declare function contractWithGasBuffer<T extends object>(contract: T, bufferPercent?: number): T;
161
146
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,GAAG,QAAqB,CAAC;AACtC,eAAO,MAAM,WAAW,SAAmB,CAAC;AAE5C,oBAAY,YAAY;IACpB,SAAS,IAAI;IACb,aAAa,IAAI;IACjB,gBAAgB,IAAI;IACpB,IAAI,OAAO;CACd;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,QAAQ,GAAG,CAAC,CAMjH;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQzD;AAED,wBAAgB,4BAA4B,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,gBAAgB,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxI;A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BAAiB,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,GAAG,QAAQ,GAAG,CAAC,CAM9G;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQzD;AA8CD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,aAAa,SAAK,GAAG,CAAC,CAoB1F"}
package/dist/helpers.js CHANGED
@@ -1,27 +1,48 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdaptorTypes = exports.WAD_DECIMAL = exports.WAD = void 0;
3
+ exports.EMPTY_ADDRESS = exports.UINT256_MAX = exports.SECONDS_PER_DAY = exports.SECONDS_PER_WEEK = exports.SECONDS_PER_MONTH = exports.SECONDS_PER_YEAR = exports.WAD_DECIMAL = exports.WAD_CUBED_BPS_OFFSET = exports.WAD_SQUARED = exports.RAY = exports.WAD_BPS = exports.WAD = exports.BPS_SQUARED = exports.BPS = void 0;
4
+ exports.toDecimal = toDecimal;
5
+ exports.toBigInt = toBigInt;
6
+ exports.validateProviderAsSigner = validateProviderAsSigner;
4
7
  exports.contractSetup = contractSetup;
5
8
  exports.getContractAddresses = getContractAddresses;
6
- exports.handleTransactionWithOracles = handleTransactionWithOracles;
9
+ exports.contractWithGasBuffer = contractWithGasBuffer;
7
10
  const ethers_1 = require("ethers");
8
11
  const decimal_js_1 = require("decimal.js");
9
12
  const chains_1 = require("./chains");
10
- exports.WAD = BigInt(10n ** 18n);
13
+ exports.BPS = BigInt(1e4);
14
+ exports.BPS_SQUARED = BigInt(1e8);
15
+ exports.WAD = BigInt(1e18);
16
+ exports.WAD_BPS = BigInt(1e22);
17
+ exports.RAY = BigInt(1e27);
18
+ exports.WAD_SQUARED = BigInt(1e36);
19
+ exports.WAD_CUBED_BPS_OFFSET = BigInt(1e50);
11
20
  exports.WAD_DECIMAL = new decimal_js_1.Decimal(exports.WAD);
12
- var AdaptorTypes;
13
- (function (AdaptorTypes) {
14
- AdaptorTypes[AdaptorTypes["CHAINLINK"] = 1] = "CHAINLINK";
15
- AdaptorTypes[AdaptorTypes["REDSTONE_CORE"] = 2] = "REDSTONE_CORE";
16
- AdaptorTypes[AdaptorTypes["REDSTONE_CLASSIC"] = 3] = "REDSTONE_CLASSIC";
17
- AdaptorTypes[AdaptorTypes["MOCK"] = 1337] = "MOCK";
18
- })(AdaptorTypes || (exports.AdaptorTypes = AdaptorTypes = {}));
19
- function contractSetup(signer, contractAddress, abi) {
20
- const contract = new ethers_1.Contract(contractAddress, abi, signer);
21
+ exports.SECONDS_PER_YEAR = 31536000n;
22
+ exports.SECONDS_PER_MONTH = 2592000n;
23
+ exports.SECONDS_PER_WEEK = 604800n;
24
+ exports.SECONDS_PER_DAY = 86400n;
25
+ exports.UINT256_MAX = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
26
+ exports.EMPTY_ADDRESS = "0x0000000000000000000000000000000000000000";
27
+ function toDecimal(value, decimals) {
28
+ return new decimal_js_1.Decimal(value).div(new decimal_js_1.Decimal(10).pow(decimals));
29
+ }
30
+ function toBigInt(value, decimals) {
31
+ return (0, ethers_1.parseUnits)(value.toString(), decimals);
32
+ }
33
+ function validateProviderAsSigner(provider) {
34
+ const isSigner = "address" in provider;
35
+ if (!isSigner) {
36
+ throw new Error("Provider is not a signer, therefor this action is not available. Please connect a wallet to execute this action.");
37
+ }
38
+ return provider;
39
+ }
40
+ function contractSetup(provider, contractAddress, abi) {
41
+ const contract = new ethers_1.Contract(contractAddress, abi, provider);
21
42
  if (contract == undefined || contract == null) {
22
43
  throw new Error(`Failed to load contract at address ${contractAddress}.`);
23
44
  }
24
- return contract;
45
+ return contractWithGasBuffer(contract);
25
46
  }
26
47
  function getContractAddresses(chain) {
27
48
  const config = chains_1.chains[chain];
@@ -30,11 +51,76 @@ function getContractAddresses(chain) {
30
51
  }
31
52
  return config;
32
53
  }
33
- function handleTransactionWithOracles(exec_func, token, adaptor) {
34
- if (adaptor == AdaptorTypes.REDSTONE_CORE) {
35
- // TODO:
36
- // Handle Redstone Core specific logic
54
+ /**
55
+ * Calculates the gas limit with a buffer percentage added
56
+ * @param estimatedGas The original gas estimate from ethers
57
+ * @param bufferPercent The percentage buffer to add (e.g., 20 for 20%)
58
+ * @returns The gas limit with buffer applied
59
+ */
60
+ function calculateGasWithBuffer(estimatedGas, bufferPercent) {
61
+ return (estimatedGas * BigInt(100 + bufferPercent)) / BigInt(100);
62
+ }
63
+ /**
64
+ * Checks if a contract method supports gas estimation
65
+ * @param method The contract method to check
66
+ * @returns true if the method has an estimateGas function
67
+ */
68
+ function canEstimateGas(method) {
69
+ return typeof method?.estimateGas === 'function';
70
+ }
71
+ /**
72
+ * Attempts to estimate gas and add buffer to transaction arguments
73
+ * @param method The contract method to estimate gas for
74
+ * @param args The transaction arguments
75
+ * @param bufferPercent The gas buffer percentage
76
+ * @returns true if gas estimation was successful and added to args
77
+ */
78
+ async function tryAddGasBuffer(method, args, bufferPercent) {
79
+ if (!canEstimateGas(method)) {
80
+ return false;
81
+ }
82
+ try {
83
+ const estimatedGas = await method.estimateGas(...args);
84
+ const gasLimit = calculateGasWithBuffer(estimatedGas, bufferPercent);
85
+ // Add the gas limit as transaction overrides
86
+ args.push({ gasLimit });
87
+ return true;
37
88
  }
38
- return exec_func();
89
+ catch (error) {
90
+ // If gas estimation fails, continue without buffer
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * Wraps a contract instance so all write actions automatically add a gas buffer.
96
+ *
97
+ * How it works:
98
+ * 1. Creates a proxy around the contract
99
+ * 2. Intercepts all function calls
100
+ * 3. For contract methods that support it, estimates gas usage
101
+ * 4. Adds the specified buffer percentage to the gas limit
102
+ * 5. Calls the original method with the buffered gas limit
103
+ *
104
+ * @param contract The ethers contract instance to wrap
105
+ * @param bufferPercent The percentage buffer to add (default 20%)
106
+ * @returns The same contract but with automatic gas buffering
107
+ */
108
+ function contractWithGasBuffer(contract, bufferPercent = 10) {
109
+ return new Proxy(contract, {
110
+ get(target, methodName, receiver) {
111
+ const originalMethod = Reflect.get(target, methodName, receiver);
112
+ // Only wrap functions, skip special properties like populateTransaction
113
+ if (typeof originalMethod !== 'function' || methodName === 'populateTransaction') {
114
+ return originalMethod;
115
+ }
116
+ // Return a wrapped version of the method
117
+ return async (...args) => {
118
+ // Try to add gas buffer before calling the method
119
+ await tryAddGasBuffer(originalMethod, args, bufferPercent);
120
+ // Call the original method with potentially modified args
121
+ return originalMethod.apply(target, args);
122
+ };
123
+ }
124
+ });
39
125
  }
40
126
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAiBA,sCAMC;AAED,oDAQC;AAED,oEAOC;AAxCD,mCAAkC;AAClC,2CAAqC;AAErC,qCAAkC;AAErB,QAAA,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;AACzB,QAAA,WAAW,GAAG,IAAI,oBAAO,CAAC,WAAG,CAAC,CAAC;AAE5C,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,yDAAa,CAAA;IACb,iEAAiB,CAAA;IACjB,uEAAoB,CAAA;IACpB,kDAAW,CAAA;AACf,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED,SAAgB,aAAa,CAAI,MAA8B,EAAE,eAAwB,EAAE,GAAQ;IAC/F,MAAM,QAAQ,GAAG,IAAI,iBAAQ,CAAC,eAAe,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5D,IAAG,QAAQ,IAAI,SAAS,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,sCAAsC,eAAe,GA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C;gBAC/E,OAAO,cAAc,CAAC;YAC1B,CAAC;YAED,yCAAyC;YACzC,OAAO,KAAK,EAAE,GAAG,IAAW,EAAE,EAAE;gBAC5B,kDAAkD;gBAClD,MAAM,eAAe,CAAC,cAAc,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;gBAE3D,0DAA0D;gBAC1D,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC9C,CAAC,CAAC;QACN,CAAC;KACJ,CAAC,CAAC;AACP,CAAC"}
package/dist/setup.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { JsonRpcSigner, Wallet } from "ethers";
2
- import { ChainRpcPrefix } from "./helpers";
1
+ import { JsonRpcProvider, JsonRpcSigner, Wallet } from "ethers";
2
+ import { ChainRpcPrefix, getContractAddresses } from "./helpers";
3
3
  import { Market } from "./classes/Market";
4
4
  import { ProtocolReader } from "./classes/ProtocolReader";
5
5
  import { Faucet } from "./classes/Faucet";
6
- export declare function setupChain(chain: ChainRpcPrefix, signer: JsonRpcSigner | Wallet): Promise<{
6
+ export declare const backup_providers: Record<ChainRpcPrefix, JsonRpcProvider>;
7
+ export declare let active_contracts: ReturnType<typeof getContractAddresses>;
8
+ export declare function setupChain(chain: ChainRpcPrefix, signer: JsonRpcSigner | Wallet | JsonRpcProvider | null): Promise<{
7
9
  markets: Market[];
8
10
  faucet: Faucet;
9
11
  reader: ProtocolReader;
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAwB,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,wBAAsB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM;;;;GAoBrF"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,cAAc,EAAE,eAAe,CAEpE,CAAC;AACF,eAAO,IAAI,gBAAgB,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAErE,wBAAsB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,eAAe,GAAG,IAAI;;;;GAwB9G"}
package/dist/setup.js CHANGED
@@ -1,27 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.active_contracts = exports.backup_providers = void 0;
3
4
  exports.setupChain = setupChain;
5
+ const ethers_1 = require("ethers");
4
6
  const helpers_1 = require("./helpers");
5
7
  const Market_1 = require("./classes/Market");
6
8
  const ProtocolReader_1 = require("./classes/ProtocolReader");
7
9
  const Faucet_1 = require("./classes/Faucet");
8
10
  const OracleManager_1 = require("./classes/OracleManager");
11
+ exports.backup_providers = {
12
+ "monad-testnet": new ethers_1.JsonRpcProvider("https://rpc.ankr.com/monad_testnet")
13
+ };
9
14
  async function setupChain(chain, signer) {
10
- const chain_addresses = (0, helpers_1.getContractAddresses)(chain);
11
- if (!("ProtocolReader" in chain_addresses)) {
15
+ exports.active_contracts = (0, helpers_1.getContractAddresses)(chain);
16
+ if (signer == null) {
17
+ signer = exports.backup_providers[chain];
18
+ }
19
+ if (!("ProtocolReader" in exports.active_contracts)) {
12
20
  throw new Error(`Chain configuration for ${chain} is missing ProtocolReader address.`);
13
21
  }
14
- else if (!("Faucet" in chain_addresses)) {
22
+ else if (!("Faucet" in exports.active_contracts)) {
15
23
  throw new Error(`Chain configuration for ${chain} is missing Faucet address.`);
16
24
  }
17
- else if (!("OracleManager" in chain_addresses)) {
25
+ else if (!("OracleManager" in exports.active_contracts)) {
18
26
  throw new Error(`Chain configuration for ${chain} is missing OracleManager address.`);
19
27
  }
20
- const reader = new ProtocolReader_1.ProtocolReader(signer, chain_addresses.ProtocolReader);
21
- const faucet = new Faucet_1.Faucet(signer, chain_addresses.Faucet);
22
- const oracle_manager = new OracleManager_1.OracleManager(signer, chain_addresses.OracleManager);
28
+ const reader = new ProtocolReader_1.ProtocolReader(signer, exports.active_contracts.ProtocolReader);
29
+ const faucet = new Faucet_1.Faucet(signer, exports.active_contracts.Faucet);
30
+ const oracle_manager = new OracleManager_1.OracleManager(signer, exports.active_contracts.OracleManager);
23
31
  return {
24
- markets: await Market_1.Market.getAll(signer, reader, oracle_manager),
32
+ markets: await Market_1.Market.getAll(signer, reader, oracle_manager, exports.active_contracts),
25
33
  faucet,
26
34
  reader,
27
35
  };
package/dist/setup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":";;AAQA,gCAoBC;AA3BD,uCAAiE;AACjE,6CAA0C;AAE1C,6DAA0D;AAC1D,6CAA0C;AAC1C,2DAAwD;AAEjD,KAAK,UAAU,UAAU,CAAC,KAAqB,EAAE,MAA8B;IAClF,MAAM,eAAe,GAAG,IAAA,8BAAoB,EAAC,KAAK,CAAC,CAAC;IAEpD,IAAG,CAAC,CAAC,gBAAgB,IAAI,eAAe,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAA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C,CAAC,gBAAgB,IAAI,wBAAgB,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,qCAAqC,CAAC,CAAC;IAC3F,CAAC;SAAM,IAAI,CAAC,CAAC,QAAQ,IAAI,wBAAgB,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,6BAA6B,CAAC,CAAC;IACnF,CAAC;SAAM,IAAI,CAAC,CAAC,eAAe,IAAI,wBAAgB,CAAC,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,oCAAoC,CAAC,CAAC;IAC1F,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,+BAAc,CAAC,MAAM,EAAE,wBAAgB,CAAC,cAAyB,CAAC,CAAA;IACrF,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,MAAM,EAAE,wBAAgB,CAAC,MAAiB,CAAC,CAAC;IACtE,MAAM,cAAc,GAAG,IAAI,6BAAa,CAAC,MAAM,EAAE,wBAAgB,CAAC,aAAwB,CAAC,CAAC;IAE5F,OAAO;QACH,OAAO,EAAE,MAAM,eAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,wBAAgB,CAAC;QAC9E,MAAM;QACN,MAAM;KACT,CAAC;AACN,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { JsonRpcSigner, Wallet } from "ethers";
1
+ import Decimal from "decimal.js";
2
+ import { JsonRpcProvider, JsonRpcSigner, Wallet } from "ethers";
2
3
  export type address = `0x${string}`;
3
4
  export type bytes = `0x${string}`;
4
5
  export type uint = bigint | number;
@@ -6,5 +7,7 @@ export type uint240 = uint;
6
7
  export type uint8 = uint;
7
8
  export type uint256 = uint;
8
9
  export type uint128 = uint;
10
+ export type percentage = Decimal;
11
+ export type curvance_provider = JsonRpcSigner | Wallet | JsonRpcProvider;
9
12
  export type curvance_signer = JsonRpcSigner | Wallet;
10
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE/C,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AACpC,MAAM,MAAM,KAAK,GAAG,KAAK,MAAM,EAAE,CAAC;AAClC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAClC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC;AACzB,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhE,MAAM,MAAM,OAAO,GAAG,KAAK,MAAM,EAAE,CAAC;AACpC,MAAM,MAAM,KAAK,GAAG,KAAK,MAAM,EAAE,CAAC;AAClC,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;AAClC,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,KAAK,GAAG,IAAI,CAAC;AACzB,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,OAAO,GAAG,IAAI,CAAC;AAC3B,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC;AACjC,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,MAAM,GAAG,eAAe,CAAC;AACzE,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG,MAAM,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "curvance",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -34,10 +34,12 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@redstone-finance/sdk": "^0.9.0",
37
- "@types/node": "^24.3.0",
38
37
  "decimal.js": "^10.6.0",
38
+ "ethers": "^6.15.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^24.3.0",
39
42
  "dotenv": "^17.2.1",
40
- "ethers": "^6.15.0",
41
43
  "ts-node": "^10.9.2",
42
44
  "typescript": "^5.9.2"
43
45
  }