@mento-protocol/mento-sdk 2.0.0-beta.7 → 2.0.0-beta.9
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/README.md +177 -0
- package/dist/abis/broker.d.ts.map +1 -1
- package/dist/abis/broker.js +7 -0
- package/dist/abis/broker.js.map +1 -1
- package/dist/abis/index.d.ts +1 -0
- package/dist/abis/index.d.ts.map +1 -1
- package/dist/abis/index.js +1 -0
- package/dist/abis/index.js.map +1 -1
- package/dist/adapters/implementations/ethersAdapter.d.ts +5 -1
- package/dist/adapters/implementations/ethersAdapter.d.ts.map +1 -1
- package/dist/adapters/implementations/ethersAdapter.js +73 -0
- package/dist/adapters/implementations/ethersAdapter.js.map +1 -1
- package/dist/adapters/implementations/ethersV5Adapter.d.ts +5 -1
- package/dist/adapters/implementations/ethersV5Adapter.d.ts.map +1 -1
- package/dist/adapters/implementations/ethersV5Adapter.js +73 -0
- package/dist/adapters/implementations/ethersV5Adapter.js.map +1 -1
- package/dist/adapters/implementations/viemAdapter.d.ts +12 -3
- package/dist/adapters/implementations/viemAdapter.d.ts.map +1 -1
- package/dist/adapters/implementations/viemAdapter.js +101 -1
- package/dist/adapters/implementations/viemAdapter.js.map +1 -1
- package/dist/adapters/proxies/ethersAdapterProxy.d.ts +2 -1
- package/dist/adapters/proxies/ethersAdapterProxy.d.ts.map +1 -1
- package/dist/adapters/proxies/ethersAdapterProxy.js +7 -0
- package/dist/adapters/proxies/ethersAdapterProxy.js.map +1 -1
- package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts +2 -1
- package/dist/adapters/proxies/ethersV5AdapterProxy.d.ts.map +1 -1
- package/dist/adapters/proxies/ethersV5AdapterProxy.js +7 -0
- package/dist/adapters/proxies/ethersV5AdapterProxy.js.map +1 -1
- package/dist/adapters/proxies/viemAdapterProxy.d.ts +7 -3
- package/dist/adapters/proxies/viemAdapterProxy.d.ts.map +1 -1
- package/dist/adapters/proxies/viemAdapterProxy.js +11 -4
- package/dist/adapters/proxies/viemAdapterProxy.js.map +1 -1
- package/dist/constants/aaveConfig.d.ts +7 -0
- package/dist/constants/aaveConfig.d.ts.map +1 -0
- package/dist/constants/aaveConfig.js +22 -0
- package/dist/constants/aaveConfig.js.map +1 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/mentoAddresses.d.ts +1 -0
- package/dist/constants/mentoAddresses.d.ts.map +1 -1
- package/dist/constants/mentoAddresses.js +1 -0
- package/dist/constants/mentoAddresses.js.map +1 -1
- package/dist/index.d.ts +66 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +75 -3
- package/dist/index.js.map +1 -1
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/stableTokenService.d.ts.map +1 -1
- package/dist/services/stableTokenService.js +2 -1
- package/dist/services/stableTokenService.js.map +1 -1
- package/dist/services/supply/ISupplyCalculator.d.ts +10 -0
- package/dist/services/supply/ISupplyCalculator.d.ts.map +1 -1
- package/dist/services/supply/aaveSupplyCalculator.d.ts +21 -0
- package/dist/services/supply/aaveSupplyCalculator.d.ts.map +1 -0
- package/dist/services/supply/aaveSupplyCalculator.js +46 -0
- package/dist/services/supply/aaveSupplyCalculator.js.map +1 -0
- package/dist/services/supply/calculatorFactory.d.ts +8 -0
- package/dist/services/supply/calculatorFactory.d.ts.map +1 -0
- package/dist/services/supply/calculatorFactory.js +3 -0
- package/dist/services/supply/calculatorFactory.js.map +1 -0
- package/dist/services/supply/defaultCalculatorFactory.d.ts +9 -0
- package/dist/services/supply/defaultCalculatorFactory.d.ts.map +1 -0
- package/dist/services/supply/defaultCalculatorFactory.js +23 -0
- package/dist/services/supply/defaultCalculatorFactory.js.map +1 -0
- package/dist/services/supply/index.d.ts +4 -1
- package/dist/services/supply/index.d.ts.map +1 -1
- package/dist/services/supply/index.js +4 -1
- package/dist/services/supply/index.js.map +1 -1
- package/dist/services/supply/{UniV3SupplyCalculator.d.ts → uniV3SupplyCalculator.d.ts} +1 -1
- package/dist/services/supply/{UniV3SupplyCalculator.d.ts.map → uniV3SupplyCalculator.d.ts.map} +1 -1
- package/dist/services/supply/{UniV3SupplyCalculator.js → uniV3SupplyCalculator.js} +1 -1
- package/dist/services/supply/{UniV3SupplyCalculator.js.map → uniV3SupplyCalculator.js.map} +1 -1
- package/dist/services/supplyAdjustmentService.d.ts +4 -2
- package/dist/services/supplyAdjustmentService.d.ts.map +1 -1
- package/dist/services/supplyAdjustmentService.js +19 -8
- package/dist/services/supplyAdjustmentService.js.map +1 -1
- package/dist/services/swapService.d.ts +70 -0
- package/dist/services/swapService.d.ts.map +1 -0
- package/dist/services/swapService.js +134 -0
- package/dist/services/swapService.js.map +1 -0
- package/dist/types/provider.d.ts +18 -0
- package/dist/types/provider.d.ts.map +1 -1
- package/dist/types/token.d.ts +8 -1
- package/dist/types/token.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethersAdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersAdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ethersAdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersAdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAe;gBAEtB,QAAQ,EAAE,gBAAgB;YAIxB,UAAU;IAWlB,YAAY,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAUjE,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUlG,UAAU;CASjB"}
|
|
@@ -59,6 +59,13 @@ class EthersAdapterProxy {
|
|
|
59
59
|
}
|
|
60
60
|
return this.adapter.readContract(...args);
|
|
61
61
|
}
|
|
62
|
+
async writeContract(...args) {
|
|
63
|
+
await this.initPromise;
|
|
64
|
+
if (!this.adapter) {
|
|
65
|
+
throw new Error('Adapter not initialized. Are you missing ethers v6 dependency?');
|
|
66
|
+
}
|
|
67
|
+
return this.adapter.writeContract(...args);
|
|
68
|
+
}
|
|
62
69
|
async getChainId() {
|
|
63
70
|
await this.initPromise;
|
|
64
71
|
if (!this.adapter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethersAdapterProxy.js","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersAdapterProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,kBAAkB;IAI7B,YAAY,QAA0B;QAH9B,YAAO,GAA2B,IAAI,CAAA;QAI5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC9C,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAA0B;QACjD,IAAI,CAAC;YACH,MAAM,EAAE,aAAa,EAAE,GAAG,wDAAa,kCAAkC,GAAC,CAAA;YAC1E,IAAI,CAAC,OAAO,GAAG,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAA;QAC5C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAA;QACH,CAAC;IACH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AAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAG,IAAkD;QACvE,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;IAClC,CAAC;CACF;AAhDD,gDAgDC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ProviderAdapter } from '../../types';
|
|
1
|
+
import { ProviderAdapter, TransactionResponse } from '../../types';
|
|
2
2
|
import type { providers as EthersV5Providers } from 'ethers-v5';
|
|
3
3
|
/**
|
|
4
4
|
* Proxy class that implements lazy loading for ethers v5 provider adapter.
|
|
@@ -20,6 +20,7 @@ export declare class EthersV5AdapterProxy implements ProviderAdapter {
|
|
|
20
20
|
constructor(provider: EthersV5Providers.Provider);
|
|
21
21
|
private initialize;
|
|
22
22
|
readContract(...args: Parameters<ProviderAdapter['readContract']>): Promise<unknown>;
|
|
23
|
+
writeContract(...args: Parameters<ProviderAdapter['writeContract']>): Promise<TransactionResponse>;
|
|
23
24
|
getChainId(): Promise<number>;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=ethersV5AdapterProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethersV5AdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersV5AdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"ethersV5AdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersV5AdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAE/D;;;;;;;;;;;;;GAaG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAe;gBAEtB,QAAQ,EAAE,iBAAiB,CAAC,QAAQ;YAIlC,UAAU;IAalB,YAAY,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAUjE,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUlG,UAAU;CASjB"}
|
|
@@ -59,6 +59,13 @@ class EthersV5AdapterProxy {
|
|
|
59
59
|
}
|
|
60
60
|
return this.adapter.readContract(...args);
|
|
61
61
|
}
|
|
62
|
+
async writeContract(...args) {
|
|
63
|
+
await this.initPromise;
|
|
64
|
+
if (!this.adapter) {
|
|
65
|
+
throw new Error('Adapter not initialized. Are you missing ethers v5 dependency?');
|
|
66
|
+
}
|
|
67
|
+
return this.adapter.writeContract(...args);
|
|
68
|
+
}
|
|
62
69
|
async getChainId() {
|
|
63
70
|
await this.initPromise;
|
|
64
71
|
if (!this.adapter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethersV5AdapterProxy.js","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersV5AdapterProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,oBAAoB;IAI/B,YAAY,QAAoC;QAHxC,YAAO,GAA2B,IAAI,CAAA;QAI5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;IAC9C,CAAC;IAEO,KAAK,CAAC,UAAU,CAAC,QAAoC;QAC3D,IAAI,CAAC;YACH,MAAM,EAAE,eAAe,EAAE,GAAG,wDAC1B,oCAAoC,GACrC,CAAA;YACD,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,QAAQ,CAAC,CAAA;QAC9C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,GAAG,IAAiD;QACrE,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;IAClC,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"ethersV5AdapterProxy.js","sourceRoot":"","sources":["../../../src/adapters/proxies/ethersV5AdapterProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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,UAAU,EAAE,CAAA;IAClC,CAAC;CACF;AAlDD,oDAkDC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PublicClient } from 'viem';
|
|
2
|
-
import { ProviderAdapter } from '../../types';
|
|
1
|
+
import type { PublicClient, WalletClient, Account } from 'viem';
|
|
2
|
+
import { ProviderAdapter, TransactionResponse } from '../../types';
|
|
3
3
|
/**
|
|
4
4
|
* Proxy class that implements lazy loading for viem provider adapter.
|
|
5
5
|
*
|
|
@@ -17,9 +17,13 @@ import { ProviderAdapter } from '../../types';
|
|
|
17
17
|
export declare class ViemAdapterProxy implements ProviderAdapter {
|
|
18
18
|
private adapter;
|
|
19
19
|
private initPromise;
|
|
20
|
-
constructor(client: PublicClient
|
|
20
|
+
constructor(client: PublicClient, walletClientConfig?: {
|
|
21
|
+
walletClient: WalletClient;
|
|
22
|
+
account: Account;
|
|
23
|
+
});
|
|
21
24
|
private initialize;
|
|
22
25
|
readContract(...args: Parameters<ProviderAdapter['readContract']>): Promise<unknown>;
|
|
26
|
+
writeContract(...args: Parameters<ProviderAdapter['writeContract']>): Promise<TransactionResponse>;
|
|
23
27
|
getChainId(): Promise<number>;
|
|
24
28
|
}
|
|
25
29
|
//# sourceMappingURL=viemAdapterProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viemAdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/viemAdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"viemAdapterProxy.d.ts","sourceRoot":"","sources":["../../../src/adapters/proxies/viemAdapterProxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAElE;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAiB,YAAW,eAAe;IACtD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,WAAW,CAAe;gBAGhC,MAAM,EAAE,YAAY,EACpB,kBAAkB,CAAC,EAAE;QAAE,YAAY,EAAE,YAAY,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE;YAKzD,UAAU;IAclB,YAAY,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAUjE,aAAa,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAUlG,UAAU;CASjB"}
|
|
@@ -39,14 +39,14 @@ exports.ViemAdapterProxy = void 0;
|
|
|
39
39
|
* ./adapters/proxies/README.md
|
|
40
40
|
*/
|
|
41
41
|
class ViemAdapterProxy {
|
|
42
|
-
constructor(client) {
|
|
42
|
+
constructor(client, walletClientConfig) {
|
|
43
43
|
this.adapter = null;
|
|
44
|
-
this.initPromise = this.initialize(client);
|
|
44
|
+
this.initPromise = this.initialize(client, walletClientConfig);
|
|
45
45
|
}
|
|
46
|
-
async initialize(client) {
|
|
46
|
+
async initialize(client, walletClientConfig) {
|
|
47
47
|
try {
|
|
48
48
|
const { ViemAdapter } = await Promise.resolve().then(() => __importStar(require('../implementations/viemAdapter')));
|
|
49
|
-
this.adapter = new ViemAdapter(client);
|
|
49
|
+
this.adapter = new ViemAdapter(client, walletClientConfig);
|
|
50
50
|
}
|
|
51
51
|
catch (error) {
|
|
52
52
|
throw new Error('viem is not installed. Please install viem to use this adapter');
|
|
@@ -59,6 +59,13 @@ class ViemAdapterProxy {
|
|
|
59
59
|
}
|
|
60
60
|
return this.adapter.readContract(...args);
|
|
61
61
|
}
|
|
62
|
+
async writeContract(...args) {
|
|
63
|
+
await this.initPromise;
|
|
64
|
+
if (!this.adapter) {
|
|
65
|
+
throw new Error('Adapter not initialized. Are you missing viem dependency?');
|
|
66
|
+
}
|
|
67
|
+
return this.adapter.writeContract(...args);
|
|
68
|
+
}
|
|
62
69
|
async getChainId() {
|
|
63
70
|
await this.initPromise;
|
|
64
71
|
if (!this.adapter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viemAdapterProxy.js","sourceRoot":"","sources":["../../../src/adapters/proxies/viemAdapterProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,gBAAgB;IAI3B,
|
|
1
|
+
{"version":3,"file":"viemAdapterProxy.js","sourceRoot":"","sources":["../../../src/adapters/proxies/viemAdapterProxy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;;GAaG;AACH,MAAa,gBAAgB;IAI3B,YACE,MAAoB,EACpB,kBAAqE;QAL/D,YAAO,GAA2B,IAAI,CAAA;QAO5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;IAChE,CAAC;IAEO,KAAK,CAAC,UAAU,CACtB,MAAoB,EACpB,kBAAqE;QAErE,IAAI,CAAC;YACH,MAAM,EAAE,WAAW,EAAE,GAAG,wDAAa,gCAAgC,GAAC,CAAA;YACtE,IAAI,CAAC,OAAO,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,GAAG,IAAiD;QACrE,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,CAAA;IAC3C,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,GAAG,IAAkD;QACvE,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,IAAI,CAAC,WAAW,CAAA;QACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAA;IAClC,CAAC;CACF;AAtDD,4CAsDC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps original tokens to their corresponding AAVE aToken addresses on different chains.
|
|
3
|
+
* When tokens are supplied to AAVE, they are wrapped into aTokens that represent the
|
|
4
|
+
* deposit position.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AAVE_TOKEN_MAPPINGS: Record<number, Record<string, string>>;
|
|
7
|
+
//# sourceMappingURL=aaveConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aaveConfig.d.ts","sourceRoot":"","sources":["../../src/constants/aaveConfig.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAe7D,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AAVE_TOKEN_MAPPINGS = void 0;
|
|
4
|
+
const chainId_1 = require("./chainId");
|
|
5
|
+
/**
|
|
6
|
+
* Maps original tokens to their corresponding AAVE aToken addresses on different chains.
|
|
7
|
+
* When tokens are supplied to AAVE, they are wrapped into aTokens that represent the
|
|
8
|
+
* deposit position.
|
|
9
|
+
*/
|
|
10
|
+
exports.AAVE_TOKEN_MAPPINGS = {
|
|
11
|
+
[chainId_1.ChainId.CELO]: {
|
|
12
|
+
// cUSD -> aCelcUSD
|
|
13
|
+
'0x765DE816845861e75A25fCA122bb6898B8B1282a': '0xBba98352628B0B0c4b40583F593fFCb630935a45',
|
|
14
|
+
// cEUR -> aCelcEUR
|
|
15
|
+
'0xD8763CBa276a3738E6DE85b4b3bF5FDed6D6cA73': '0x34c02571094e08E935B8cf8dC10F1Ad6795f1f81',
|
|
16
|
+
// USDT -> aCelUSDT
|
|
17
|
+
'0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e': '0xDeE98402A302e4D707fB9bf2bac66fAEEc31e8Df',
|
|
18
|
+
// CELO -> aCelCELO
|
|
19
|
+
'0x471EcE3750Da237f93B8E339c536989b8978a438': '0xC3e77dC389537Db1EEc7C33B95Cf3beECA71A209',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=aaveConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aaveConfig.js","sourceRoot":"","sources":["../../src/constants/aaveConfig.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAEnC;;;;GAIG;AACU,QAAA,mBAAmB,GAA2C;IACzE,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE;QACd,mBAAmB;QACnB,4CAA4C,EAC1C,4CAA4C;QAC9C,mBAAmB;QACnB,4CAA4C,EAC1C,4CAA4C;QAC9C,mBAAmB;QACnB,4CAA4C,EAC1C,4CAA4C;QAC9C,mBAAmB;QACnB,4CAA4C,EAC1C,4CAA4C;KAC/C;CACO,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA"}
|
package/dist/constants/index.js
CHANGED
|
@@ -21,4 +21,5 @@ __exportStar(require("./contractNames"), exports);
|
|
|
21
21
|
__exportStar(require("./stableTokenMetadata"), exports);
|
|
22
22
|
__exportStar(require("./protocolAddresses"), exports);
|
|
23
23
|
__exportStar(require("./mentoAddresses"), exports);
|
|
24
|
+
__exportStar(require("./aaveConfig"), exports);
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,4CAAyB;AACzB,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,sDAAmC;AACnC,mDAAgC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,4CAAyB;AACzB,kDAA+B;AAC/B,kDAA+B;AAC/B,wDAAqC;AACrC,sDAAmC;AACnC,mDAAgC;AAChC,+CAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentoAddresses.d.ts","sourceRoot":"","sources":["../../src/constants/mentoAddresses.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"mentoAddresses.d.ts","sourceRoot":"","sources":["../../src/constants/mentoAddresses.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;CAGlB,CAAA"}
|
|
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MENTO_ADDRESSES = void 0;
|
|
4
4
|
exports.MENTO_ADDRESSES = {
|
|
5
5
|
PROTOCOL_MULTISIG: '0x87647780180b8f55980c7d3ffefe08a9b29e9ae1',
|
|
6
|
+
OPERATIONAL_WALLET: '0xDA7BFEF937F0944551a24b4C68B054bfA7127570',
|
|
6
7
|
};
|
|
7
8
|
//# sourceMappingURL=mentoAddresses.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mentoAddresses.js","sourceRoot":"","sources":["../../src/constants/mentoAddresses.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,iBAAiB,EAAE,4CAA4C;
|
|
1
|
+
{"version":3,"file":"mentoAddresses.js","sourceRoot":"","sources":["../../src/constants/mentoAddresses.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,iBAAiB,EAAE,4CAA4C;IAC/D,kBAAkB,EAAE,4CAA4C;CACxD,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { PublicClient } from 'viem';
|
|
1
|
+
import type { PublicClient, WalletClient, Account } from 'viem';
|
|
2
2
|
import type { Provider as EthersV6Provider } from 'ethers';
|
|
3
3
|
import type { providers as EthersV5Providers } from 'ethers-v5';
|
|
4
|
-
import { CollateralAsset, ContractAddresses, StableToken } from './types';
|
|
4
|
+
import { CollateralAsset, ContractAddresses, StableToken, TransactionResponse, ContractWriteOptions } from './types';
|
|
5
5
|
export type SupportedProvider = EthersV6Provider | PublicClient | EthersV5Providers.Provider;
|
|
6
6
|
export interface MentoConfig {
|
|
7
7
|
/** Provider can be one of:
|
|
@@ -10,6 +10,11 @@ export interface MentoConfig {
|
|
|
10
10
|
* - Viem PublicClient (from 'viem')
|
|
11
11
|
*/
|
|
12
12
|
provider: SupportedProvider;
|
|
13
|
+
/** Optional configuration for Viem wallet client (required for write operations with Viem) */
|
|
14
|
+
viemAdapterConfig?: {
|
|
15
|
+
walletClient: WalletClient;
|
|
16
|
+
account: Account;
|
|
17
|
+
};
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* @class Mento
|
|
@@ -43,6 +48,7 @@ export declare class Mento {
|
|
|
43
48
|
private provider;
|
|
44
49
|
private stableTokenService;
|
|
45
50
|
private collateralAssetService;
|
|
51
|
+
private swapService;
|
|
46
52
|
private constructor();
|
|
47
53
|
static create(config: MentoConfig): Promise<Mento>;
|
|
48
54
|
getStableTokens(): Promise<StableToken[]>;
|
|
@@ -57,6 +63,64 @@ export declare class Mento {
|
|
|
57
63
|
* @returns The contract address
|
|
58
64
|
*/
|
|
59
65
|
getContractAddress(contractName: keyof ContractAddresses): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Swap a specified amount of collateral token for stable token.
|
|
68
|
+
*
|
|
69
|
+
* @param tokenIn The address of the input token (collateral token)
|
|
70
|
+
* @param tokenOut The address of the output token (stable token)
|
|
71
|
+
* @param amountIn The amount of input token to swap
|
|
72
|
+
* @param minAmountOut The minimum amount of output token to receive (for slippage protection)
|
|
73
|
+
* @param options Optional parameters for the transaction (gas settings)
|
|
74
|
+
* @returns A transaction response object
|
|
75
|
+
*/
|
|
76
|
+
swapIn(tokenIn: string, tokenOut: string, amountIn: string, minAmountOut: string, options?: Omit<ContractWriteOptions, 'address' | 'abi' | 'functionName' | 'args'>): Promise<TransactionResponse>;
|
|
77
|
+
/**
|
|
78
|
+
* Swap collateral token for a specified amount of stable token.
|
|
79
|
+
*
|
|
80
|
+
* @param tokenIn The address of the input token (collateral token)
|
|
81
|
+
* @param tokenOut The address of the output token (stable token)
|
|
82
|
+
* @param amountOut The exact amount of output token to receive
|
|
83
|
+
* @param maxAmountIn The maximum amount of input token to spend (for slippage protection)
|
|
84
|
+
* @param options Optional parameters for the transaction (gas settings)
|
|
85
|
+
* @returns A transaction response object
|
|
86
|
+
*/
|
|
87
|
+
swapOut(tokenIn: string, tokenOut: string, amountOut: string, maxAmountIn: string, options?: Omit<ContractWriteOptions, 'address' | 'abi' | 'functionName' | 'args'>): Promise<TransactionResponse>;
|
|
88
|
+
/**
|
|
89
|
+
* Calculate the amount of output token that would be received for a given input amount.
|
|
90
|
+
*
|
|
91
|
+
* @param tokenIn The address of the input token
|
|
92
|
+
* @param tokenOut The address of the output token
|
|
93
|
+
* @param amountIn The amount of input token
|
|
94
|
+
* @returns The expected amount of output token as a string
|
|
95
|
+
*/
|
|
96
|
+
getAmountOut(tokenIn: string, tokenOut: string, amountIn: string): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Calculate the amount of input token required to receive a given output amount.
|
|
99
|
+
*
|
|
100
|
+
* @param tokenIn The address of the input token
|
|
101
|
+
* @param tokenOut The address of the output token
|
|
102
|
+
* @param amountOut The desired amount of output token
|
|
103
|
+
* @returns The required amount of input token as a string
|
|
104
|
+
*/
|
|
105
|
+
getAmountIn(tokenIn: string, tokenOut: string, amountOut: string): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Estimate the gas needed for a swap transaction.
|
|
108
|
+
*
|
|
109
|
+
* @param methodName The method to call ('swapIn' or 'swapOut')
|
|
110
|
+
* @param args The arguments for the method
|
|
111
|
+
* @returns The estimated gas as a string
|
|
112
|
+
*/
|
|
113
|
+
estimateGas(methodName: 'swapIn' | 'swapOut', args: [string, string, string, string]): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Calculate the price impact of a swap as a percentage.
|
|
116
|
+
*
|
|
117
|
+
* @param tokenIn The address of the input token
|
|
118
|
+
* @param tokenOut The address of the output token
|
|
119
|
+
* @param amountIn The amount of input token
|
|
120
|
+
* @param amountOut The expected amount of output token
|
|
121
|
+
* @returns The price impact as a percentage string (e.g., "0.5" for 0.5%)
|
|
122
|
+
*/
|
|
123
|
+
calculatePriceImpact(tokenIn: string, tokenOut: string, amountIn: string, amountOut: string): Promise<string>;
|
|
60
124
|
}
|
|
61
125
|
export * from './constants';
|
|
62
126
|
export * from './types';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC/D,OAAO,KAAK,EAAE,QAAQ,IAAI,gBAAgB,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAG/D,OAAO,EACL,eAAe,EACf,iBAAiB,EAEjB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAKhB,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,CAAC,QAAQ,CAAA;AAE9B,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,QAAQ,EAAE,iBAAiB,CAAA;IAE3B,8FAA8F;IAC9F,iBAAiB,CAAC,EAAE;QAClB,YAAY,EAAE,YAAY,CAAA;QAC1B,OAAO,EAAE,OAAO,CAAA;KACjB,CAAA;CACF;AAgCD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,KAA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ACtB,UAAU,EAAE,QAAQ,GAAG,SAAS,EAChC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACrC,OAAO,CAAC,MAAM,CAAC;IAIlB;;;;;;;;OAQG;IACU,oBAAoB,CAC/B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC;CAGnB;AAED,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,QAAQ,CAAA;AACtB,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -66,10 +66,11 @@ function isViemProvider(provider) {
|
|
|
66
66
|
* const collateralAssets = await mento.getCollateralAssets();
|
|
67
67
|
*/
|
|
68
68
|
class Mento {
|
|
69
|
-
constructor(provider, stableTokenService, collateralAssetService) {
|
|
69
|
+
constructor(provider, stableTokenService, collateralAssetService, swapService) {
|
|
70
70
|
this.provider = provider;
|
|
71
71
|
this.stableTokenService = stableTokenService;
|
|
72
72
|
this.collateralAssetService = collateralAssetService;
|
|
73
|
+
this.swapService = swapService;
|
|
73
74
|
}
|
|
74
75
|
static async create(config) {
|
|
75
76
|
if (!config.provider) {
|
|
@@ -83,14 +84,15 @@ class Mento {
|
|
|
83
84
|
provider = new adapters_1.EthersAdapter(config.provider);
|
|
84
85
|
}
|
|
85
86
|
else if (isViemProvider(config.provider)) {
|
|
86
|
-
provider = new adapters_1.ViemAdapter(config.provider);
|
|
87
|
+
provider = new adapters_1.ViemAdapter(config.provider, config.viemAdapterConfig);
|
|
87
88
|
}
|
|
88
89
|
else {
|
|
89
90
|
throw new Error('Unsupported provider type');
|
|
90
91
|
}
|
|
91
92
|
const stableTokenService = new services_1.StableTokenService(provider);
|
|
92
93
|
const collateralAssetService = new services_1.CollateralAssetService(provider);
|
|
93
|
-
|
|
94
|
+
const swapService = new services_1.SwapService(provider);
|
|
95
|
+
return new Mento(provider, stableTokenService, collateralAssetService, swapService);
|
|
94
96
|
}
|
|
95
97
|
async getStableTokens() {
|
|
96
98
|
return this.stableTokenService.getStableTokens();
|
|
@@ -111,6 +113,76 @@ class Mento {
|
|
|
111
113
|
const chainId = (await this.provider.getChainId());
|
|
112
114
|
return addresses_1.addresses[chainId][contractName];
|
|
113
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Swap a specified amount of collateral token for stable token.
|
|
118
|
+
*
|
|
119
|
+
* @param tokenIn The address of the input token (collateral token)
|
|
120
|
+
* @param tokenOut The address of the output token (stable token)
|
|
121
|
+
* @param amountIn The amount of input token to swap
|
|
122
|
+
* @param minAmountOut The minimum amount of output token to receive (for slippage protection)
|
|
123
|
+
* @param options Optional parameters for the transaction (gas settings)
|
|
124
|
+
* @returns A transaction response object
|
|
125
|
+
*/
|
|
126
|
+
async swapIn(tokenIn, tokenOut, amountIn, minAmountOut, options = {}) {
|
|
127
|
+
return this.swapService.swapIn(tokenIn, tokenOut, amountIn, minAmountOut, options);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Swap collateral token for a specified amount of stable token.
|
|
131
|
+
*
|
|
132
|
+
* @param tokenIn The address of the input token (collateral token)
|
|
133
|
+
* @param tokenOut The address of the output token (stable token)
|
|
134
|
+
* @param amountOut The exact amount of output token to receive
|
|
135
|
+
* @param maxAmountIn The maximum amount of input token to spend (for slippage protection)
|
|
136
|
+
* @param options Optional parameters for the transaction (gas settings)
|
|
137
|
+
* @returns A transaction response object
|
|
138
|
+
*/
|
|
139
|
+
async swapOut(tokenIn, tokenOut, amountOut, maxAmountIn, options = {}) {
|
|
140
|
+
return this.swapService.swapOut(tokenIn, tokenOut, amountOut, maxAmountIn, options);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Calculate the amount of output token that would be received for a given input amount.
|
|
144
|
+
*
|
|
145
|
+
* @param tokenIn The address of the input token
|
|
146
|
+
* @param tokenOut The address of the output token
|
|
147
|
+
* @param amountIn The amount of input token
|
|
148
|
+
* @returns The expected amount of output token as a string
|
|
149
|
+
*/
|
|
150
|
+
async getAmountOut(tokenIn, tokenOut, amountIn) {
|
|
151
|
+
return this.swapService.getAmountOut(tokenIn, tokenOut, amountIn);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Calculate the amount of input token required to receive a given output amount.
|
|
155
|
+
*
|
|
156
|
+
* @param tokenIn The address of the input token
|
|
157
|
+
* @param tokenOut The address of the output token
|
|
158
|
+
* @param amountOut The desired amount of output token
|
|
159
|
+
* @returns The required amount of input token as a string
|
|
160
|
+
*/
|
|
161
|
+
async getAmountIn(tokenIn, tokenOut, amountOut) {
|
|
162
|
+
return this.swapService.getAmountIn(tokenIn, tokenOut, amountOut);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Estimate the gas needed for a swap transaction.
|
|
166
|
+
*
|
|
167
|
+
* @param methodName The method to call ('swapIn' or 'swapOut')
|
|
168
|
+
* @param args The arguments for the method
|
|
169
|
+
* @returns The estimated gas as a string
|
|
170
|
+
*/
|
|
171
|
+
async estimateGas(methodName, args) {
|
|
172
|
+
return this.swapService.estimateGas(methodName, args);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Calculate the price impact of a swap as a percentage.
|
|
176
|
+
*
|
|
177
|
+
* @param tokenIn The address of the input token
|
|
178
|
+
* @param tokenOut The address of the output token
|
|
179
|
+
* @param amountIn The amount of input token
|
|
180
|
+
* @param amountOut The expected amount of output token
|
|
181
|
+
* @returns The price impact as a percentage string (e.g., "0.5" for 0.5%)
|
|
182
|
+
*/
|
|
183
|
+
async calculatePriceImpact(tokenIn, tokenOut, amountIn, amountOut) {
|
|
184
|
+
return this.swapService.calculatePriceImpact(tokenIn, tokenOut, amountIn, amountOut);
|
|
185
|
+
}
|
|
114
186
|
}
|
|
115
187
|
exports.Mento = Mento;
|
|
116
188
|
__exportStar(require("./constants"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,yCAAwE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAIA,yCAAwE;AASxE,yCAAoF;AAEpF,qDAAiD;AAsBjD,+CAA+C;AAC/C,SAAS,kBAAkB,CACzB,QAA2B;IAE3B,0DAA0D;IAC1D,OAAO,CACL,YAAY,IAAI,QAAQ;QACxB,UAAU,IAAI,QAAQ;QACtB,gCAAgC;QAChC,WAAW,IAAI,QAAQ,CACxB,CAAA;AACH,CAAC;AAED,+CAA+C;AAC/C,SAAS,kBAAkB,CACzB,QAA2B;IAE3B,0DAA0D;IAC1D,OAAO,CACL,YAAY,IAAI,QAAQ;QACxB,sBAAsB;QACtB,sBAAsB,IAAI,QAAQ,CACnC,CAAA;AACH,CAAC;AAED,0CAA0C;AAC1C,SAAS,cAAc,CAAC,QAA2B;IACjD,OAAO,CAAC,CAAC,YAAY,IAAI,QAAQ,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAa,KAAK;IAMhB,YACE,QAAyB,EACzB,kBAAsC,EACtC,sBAA8C,EAC9C,WAAwB;QAExB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAC5C,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAA;QACpD,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;IAChC,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAmB;QAC5C,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,8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AAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;IACtF,CAAC;CACF;AAhKD,sBAgKC;AAED,8CAA2B;AAC3B,0CAAuB;AACvB,6CAA0B;AAC1B,6CAA0B;AAC1B,yCAAsB;AACtB,0CAAuB"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA"}
|
package/dist/services/index.js
CHANGED
|
@@ -18,5 +18,6 @@ __exportStar(require("./collateralAssetService"), exports);
|
|
|
18
18
|
__exportStar(require("./stableTokenService"), exports);
|
|
19
19
|
__exportStar(require("./supplyAdjustmentService"), exports);
|
|
20
20
|
__exportStar(require("./tokenMetadataService"), exports);
|
|
21
|
+
__exportStar(require("./swapService"), exports);
|
|
21
22
|
__exportStar(require("./supply"), exports);
|
|
22
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,uDAAoC;AACpC,4DAAyC;AACzC,yDAAsC;AACtC,2CAAwB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2DAAwC;AACxC,uDAAoC;AACpC,4DAAyC;AACzC,yDAAsC;AACtC,gDAA6B;AAC7B,2CAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stableTokenService.d.ts","sourceRoot":"","sources":["../../src/services/stableTokenService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"stableTokenService.d.ts","sourceRoot":"","sources":["../../src/services/stableTokenService.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAKvD,qBAAa,kBAAkB;IAIjB,OAAO,CAAC,QAAQ;IAH5B,OAAO,CAAC,oBAAoB,CAAsB;IAClD,OAAO,CAAC,uBAAuB,CAAyB;gBAEpC,QAAQ,EAAE,eAAe;IAQvC,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;CAiChD"}
|
|
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StableTokenService = void 0;
|
|
4
4
|
const abis_1 = require("../abis");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
|
+
const supply_1 = require("./supply");
|
|
6
7
|
const supplyAdjustmentService_1 = require("./supplyAdjustmentService");
|
|
7
8
|
const tokenMetadataService_1 = require("./tokenMetadataService");
|
|
8
9
|
class StableTokenService {
|
|
9
10
|
constructor(provider) {
|
|
10
11
|
this.provider = provider;
|
|
11
12
|
this.tokenMetadataService = new tokenMetadataService_1.TokenMetadataService(provider);
|
|
12
|
-
this.supplyAdjustmentService = new supplyAdjustmentService_1.SupplyAdjustmentService(provider);
|
|
13
|
+
this.supplyAdjustmentService = new supplyAdjustmentService_1.SupplyAdjustmentService(provider, new supply_1.DefaultCalculatorFactory());
|
|
13
14
|
}
|
|
14
15
|
async getStableTokens() {
|
|
15
16
|
const chainId = await this.provider.getChainId();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stableTokenService.js","sourceRoot":"","sources":["../../src/services/stableTokenService.ts"],"names":[],"mappings":";;;AAAA,kCAAqC;AACrC,4CAA0D;AAE1D,uEAAmE;AACnE,iEAA6D;AAE7D,MAAa,kBAAkB;IAI7B,YAAoB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;QAC3C,IAAI,CAAC,oBAAoB,GAAG,IAAI,2CAAoB,CAAC,QAAQ,CAAC,CAAA;QAC9D,IAAI,CAAC,uBAAuB,GAAG,IAAI,iDAAuB,
|
|
1
|
+
{"version":3,"file":"stableTokenService.js","sourceRoot":"","sources":["../../src/services/stableTokenService.ts"],"names":[],"mappings":";;;AAAA,kCAAqC;AACrC,4CAA0D;AAE1D,qCAAmD;AACnD,uEAAmE;AACnE,iEAA6D;AAE7D,MAAa,kBAAkB;IAI7B,YAAoB,QAAyB;QAAzB,aAAQ,GAAR,QAAQ,CAAiB;QAC3C,IAAI,CAAC,oBAAoB,GAAG,IAAI,2CAAoB,CAAC,QAAQ,CAAC,CAAA;QAC9D,IAAI,CAAC,uBAAuB,GAAG,IAAI,iDAAuB,CACxD,QAAQ,EACR,IAAI,iCAAwB,EAAE,CAC/B,CAAA;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAA;QAChD,MAAM,cAAc,GAAG,IAAA,8BAAkB,EAAC,OAAO,EAAE,mBAAO,CAAC,CAAA;QAE3D,MAAM,cAAc,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YACvD,OAAO,EAAE,cAAc;YACvB,GAAG,EAAE,kBAAW;YAChB,YAAY,EAAE,WAAW;SAC1B,CAAC,CAAa,CAAA;QAEf,MAAM,MAAM,GAAkB,EAAE,CAAA;QAEhC,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;YACrC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAA;YAC1E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAChE,OAAO,CACR,CAAA;YAED,MAAM,KAAK,GAAG;gBACZ,OAAO;gBACP,GAAG,QAAQ;gBACX,WAAW;aACZ,CAAA;YAED,MAAM,cAAc,GAClB,MAAM,IAAI,CAAC,uBAAuB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;YAE7D,KAAK,CAAC,WAAW,GAAG,cAAc,CAAA;YAClC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACpB,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AA7CD,gDA6CC"}
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for calculating non-circulating token supply.
|
|
3
|
+
*
|
|
4
|
+
* Determines the amount of tokens that should be excluded from total supply
|
|
5
|
+
* calculations because they are pre-minted or otherwise not available for
|
|
6
|
+
* trading (e.g., locked, reserved, or in protocol-owned positions).
|
|
7
|
+
*
|
|
8
|
+
* @param tokenAddress - The address of the token.
|
|
9
|
+
* @returns The amount to subtract from total supply.
|
|
10
|
+
*/
|
|
1
11
|
export interface ISupplyCalculator {
|
|
2
12
|
getAmount(tokenAddress: string): Promise<bigint>;
|
|
3
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ISupplyCalculator.d.ts","sourceRoot":"","sources":["../../../src/services/supply/ISupplyCalculator.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACjD"}
|
|
1
|
+
{"version":3,"file":"ISupplyCalculator.d.ts","sourceRoot":"","sources":["../../../src/services/supply/ISupplyCalculator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CACjD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ISupplyCalculator } from './ISupplyCalculator';
|
|
2
|
+
import { ProviderAdapter } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Calculates the amount of tokens supplied to AAVE protocol.
|
|
5
|
+
*
|
|
6
|
+
* When tokens are supplied to AAVE, the protocol mints corresponding "aTokens"
|
|
7
|
+
* as receipt tokens. The balance of the aTokens represents the total
|
|
8
|
+
* amount of the original token supplied to the protocol.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AAVESupplyCalculator implements ISupplyCalculator {
|
|
11
|
+
private readonly provider;
|
|
12
|
+
private holderAddresses;
|
|
13
|
+
constructor(provider: ProviderAdapter, holderAddresses: string[]);
|
|
14
|
+
/**
|
|
15
|
+
* Gets the balance of the corresponding aToken for the specified token address that is held by the holder addresses.
|
|
16
|
+
* @param tokenAddress - The address of the token to get the balance for.
|
|
17
|
+
* @returns The balance of the corresponding aToken.
|
|
18
|
+
*/
|
|
19
|
+
getAmount(tokenAddress: string): Promise<bigint>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=aaveSupplyCalculator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aaveSupplyCalculator.d.ts","sourceRoot":"","sources":["../../../src/services/supply/aaveSupplyCalculator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI7C;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAG1D,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,eAAe;gBADN,QAAQ,EAAE,eAAe,EAClC,eAAe,EAAE,MAAM,EAAE;IAGnC;;;;OAIG;IACG,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA2BvD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AAVESupplyCalculator = void 0;
|
|
4
|
+
const abis_1 = require("../../abis");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
/**
|
|
7
|
+
* Calculates the amount of tokens supplied to AAVE protocol.
|
|
8
|
+
*
|
|
9
|
+
* When tokens are supplied to AAVE, the protocol mints corresponding "aTokens"
|
|
10
|
+
* as receipt tokens. The balance of the aTokens represents the total
|
|
11
|
+
* amount of the original token supplied to the protocol.
|
|
12
|
+
*/
|
|
13
|
+
class AAVESupplyCalculator {
|
|
14
|
+
constructor(provider, holderAddresses) {
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
this.holderAddresses = holderAddresses;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Gets the balance of the corresponding aToken for the specified token address that is held by the holder addresses.
|
|
20
|
+
* @param tokenAddress - The address of the token to get the balance for.
|
|
21
|
+
* @returns The balance of the corresponding aToken.
|
|
22
|
+
*/
|
|
23
|
+
async getAmount(tokenAddress) {
|
|
24
|
+
const chainId = await this.provider.getChainId();
|
|
25
|
+
const chainMappings = constants_1.AAVE_TOKEN_MAPPINGS[chainId];
|
|
26
|
+
if (!chainMappings) {
|
|
27
|
+
return 0n; // No mappings for this chain, return 0
|
|
28
|
+
}
|
|
29
|
+
const aTokenAddress = chainMappings[tokenAddress];
|
|
30
|
+
if (!aTokenAddress) {
|
|
31
|
+
return 0n; // No aToken mapping for this token, return 0
|
|
32
|
+
}
|
|
33
|
+
const balances = await Promise.all(this.holderAddresses.map(async (holderAddress) => {
|
|
34
|
+
const balance = (await this.provider.readContract({
|
|
35
|
+
address: aTokenAddress,
|
|
36
|
+
abi: abis_1.ERC20_ABI,
|
|
37
|
+
functionName: 'balanceOf',
|
|
38
|
+
args: [holderAddress],
|
|
39
|
+
}));
|
|
40
|
+
return balance;
|
|
41
|
+
}));
|
|
42
|
+
return balances.reduce((acc, balance) => acc + balance, 0n);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.AAVESupplyCalculator = AAVESupplyCalculator;
|
|
46
|
+
//# sourceMappingURL=aaveSupplyCalculator.js.map
|