@paraswap/dex-lib 2.50.6 → 2.50.7-sdai

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 (64) hide show
  1. package/build/abi/maker-psm/pot.json +322 -0
  2. package/build/abi/{wombat/pool.json → sdai/SavingsDai.abi.json} +289 -701
  3. package/build/config.js +5 -2
  4. package/build/config.js.map +1 -1
  5. package/build/dex/dexalot/config.js +7 -0
  6. package/build/dex/dexalot/config.js.map +1 -1
  7. package/build/dex/index.js +2 -0
  8. package/build/dex/index.js.map +1 -1
  9. package/build/dex/sdai/config.d.ts +11 -0
  10. package/build/dex/sdai/config.js +24 -0
  11. package/build/dex/sdai/config.js.map +1 -0
  12. package/build/dex/sdai/constants.d.ts +2 -0
  13. package/build/dex/sdai/constants.js +6 -0
  14. package/build/dex/sdai/constants.js.map +1 -0
  15. package/build/dex/sdai/scripts/validate-state.js +102 -0
  16. package/build/dex/sdai/scripts/validate-state.js.map +1 -0
  17. package/build/dex/sdai/sdai-pool.d.ts +16 -0
  18. package/build/dex/sdai/sdai-pool.js +85 -0
  19. package/build/dex/sdai/sdai-pool.js.map +1 -0
  20. package/build/dex/sdai/sdai.d.ts +51 -0
  21. package/build/dex/sdai/sdai.js +172 -0
  22. package/build/dex/sdai/sdai.js.map +1 -0
  23. package/build/dex/sdai/types.d.ts +21 -0
  24. package/build/dex/sdai/types.js +11 -0
  25. package/build/dex/sdai/types.js.map +1 -0
  26. package/build/dex/sdai/utils.d.ts +4 -0
  27. package/build/dex/sdai/utils.js +39 -0
  28. package/build/dex/sdai/utils.js.map +1 -0
  29. package/package.json +1 -1
  30. package/src/abi/maker-psm/pot.json +322 -0
  31. package/src/abi/sdai/SavingsDai.abi.json +877 -0
  32. package/src/config.ts +5 -2
  33. package/src/dex/dexalot/config.ts +7 -0
  34. package/src/dex/dexalot/dexalot-e2e.test.ts +23 -1
  35. package/src/dex/dexalot/dexalot-integration.test.ts +121 -0
  36. package/src/dex/index.ts +2 -0
  37. package/src/dex/sdai/config.ts +28 -0
  38. package/src/dex/sdai/constants.ts +2 -0
  39. package/src/dex/sdai/scripts/validate-state.ts +144 -0
  40. package/src/dex/sdai/sdai-e2e.test.ts +96 -0
  41. package/src/dex/sdai/sdai-events.test.ts +105 -0
  42. package/src/dex/sdai/sdai-integration.test.ts +148 -0
  43. package/src/dex/sdai/sdai-pool.ts +113 -0
  44. package/src/dex/sdai/sdai.ts +233 -0
  45. package/src/dex/sdai/types.ts +23 -0
  46. package/src/dex/sdai/utils.ts +48 -0
  47. package/tests/constants-e2e.ts +2 -2
  48. package/.vscode/launch.json +0 -53
  49. package/.vscode/settings.json +0 -2
  50. package/.vscode/tasks.json +0 -15
  51. package/build/abi/uniswap-v3/AlienBaseV3Router.abi.json +0 -52
  52. package/build/dex/aave-v2/tokens-avalanche.json +0 -44
  53. package/build/dex/aave-v2/tokens-mainnet.json +0 -188
  54. package/build/dex/aave-v2/tokens-polygon.json +0 -44
  55. package/build/dex/solidly-v3/scripts/check-event-pool-event.js +0 -53
  56. package/build/dex/solidly-v3/scripts/check-event-pool-event.js.map +0 -1
  57. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.d.ts +0 -17
  58. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js +0 -64
  59. package/build/dex/uniswap-v3/forks/alien-base-v3/alien-base-v3.js.map +0 -1
  60. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.d.ts +0 -17
  61. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js +0 -79
  62. package/build/dex/uniswap-v3/forks/alien-v3/alien-v3.js.map +0 -1
  63. package/main-config.ts +0 -4484
  64. /package/build/dex/{solidly-v3/scripts/check-event-pool-event.d.ts → sdai/scripts/validate-state.d.ts} +0 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SDai = void 0;
30
+ const simple_exchange_1 = require("../simple-exchange");
31
+ const types_1 = require("./types");
32
+ const constants_1 = require("../../constants");
33
+ const utils_1 = require("../../utils");
34
+ const config_1 = require("./config");
35
+ const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
36
+ const pot_json_1 = __importDefault(require("../../abi/maker-psm/pot.json"));
37
+ const SavingsDai_abi_json_1 = __importDefault(require("../../abi/sdai/SavingsDai.abi.json"));
38
+ const utils_2 = require("ethers/lib/utils");
39
+ const sdai_pool_1 = require("./sdai-pool");
40
+ const bigint_constants_1 = require("../../bigint-constants");
41
+ const constants_2 = require("./constants");
42
+ class SDai extends simple_exchange_1.SimpleExchange {
43
+ constructor(network, dexKey, dexHelper, daiAddress = config_1.SDaiConfig[dexKey][network].daiAddress, sdaiAddress = config_1.SDaiConfig[dexKey][network].sdaiAddress, potAddress = config_1.SDaiConfig[dexKey][network].potAddress, adapters = config_1.Adapters[network] || {}, sdaiInterface = new utils_2.Interface(SavingsDai_abi_json_1.default), potInterface = new utils_2.Interface(pot_json_1.default)) {
44
+ super(dexHelper, dexKey);
45
+ this.network = network;
46
+ this.dexHelper = dexHelper;
47
+ this.daiAddress = daiAddress;
48
+ this.sdaiAddress = sdaiAddress;
49
+ this.potAddress = potAddress;
50
+ this.adapters = adapters;
51
+ this.sdaiInterface = sdaiInterface;
52
+ this.potInterface = potInterface;
53
+ this.hasConstantPriceLargeAmounts = true;
54
+ this.isFeeOnTransferSupported = false;
55
+ this.logger = dexHelper.getLogger(dexKey);
56
+ this.eventPool = new sdai_pool_1.SDaiEventPool(this.dexKey, dexHelper, this.potAddress, this.potInterface, this.logger);
57
+ }
58
+ getAdapters(side) {
59
+ return this.adapters[side] || null;
60
+ }
61
+ isSDai(tokenAddress) {
62
+ return this.sdaiAddress.toLowerCase() === tokenAddress.toLowerCase();
63
+ }
64
+ isDai(tokenAddress) {
65
+ return this.daiAddress.toLowerCase() === tokenAddress.toLowerCase();
66
+ }
67
+ isAppropriatePair(srcToken, destToken) {
68
+ return ((this.isDai(srcToken.address) && this.isSDai(destToken.address)) ||
69
+ (this.isDai(destToken.address) && this.isSDai(srcToken.address)));
70
+ }
71
+ async initializePricing(blockNumber) {
72
+ await this.eventPool.initialize(blockNumber);
73
+ }
74
+ async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
75
+ return this.isAppropriatePair(srcToken, destToken)
76
+ ? [`${this.dexKey}_${this.sdaiAddress}`]
77
+ : [];
78
+ }
79
+ async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools) {
80
+ if (!this.isAppropriatePair(srcToken, destToken))
81
+ return null;
82
+ if (!this.eventPool.getState(blockNumber))
83
+ return null;
84
+ if (side === constants_1.SwapSide.SELL) {
85
+ const calcSellFn = (blockNumber, amountIn) => this.isDai(srcToken.address)
86
+ ? this.eventPool.convertToSDai(amountIn, blockNumber)
87
+ : this.eventPool.convertToDai(amountIn, blockNumber);
88
+ return [
89
+ {
90
+ prices: amounts.map(amount => calcSellFn(blockNumber, amount)),
91
+ unit: calcSellFn(blockNumber, bigint_constants_1.BI_POWS[18]),
92
+ gasCost: constants_2.SDAI_DEPOSIT_GAS_COST,
93
+ exchange: this.dexKey,
94
+ data: { exchange: `${this.sdaiAddress}` },
95
+ poolAddresses: [`${this.sdaiAddress}`],
96
+ },
97
+ ];
98
+ }
99
+ else {
100
+ const calcBuyFn = (blockNumber, amountIn) => this.isDai(srcToken.address)
101
+ ? this.eventPool.convertToDai(amountIn, blockNumber)
102
+ : this.eventPool.convertToSDai(amountIn, blockNumber);
103
+ return [
104
+ {
105
+ prices: amounts.map(amount => calcBuyFn(blockNumber, amount)),
106
+ unit: calcBuyFn(blockNumber, bigint_constants_1.BI_POWS[18]),
107
+ gasCost: constants_2.SDAI_REDEEM_GAS_COST,
108
+ exchange: this.dexKey,
109
+ data: { exchange: `${this.sdaiAddress}` },
110
+ poolAddresses: [`${this.sdaiAddress}`],
111
+ },
112
+ ];
113
+ }
114
+ }
115
+ // Returns estimated gas cost of calldata for this DEX in multiSwap
116
+ getCalldataGasCost(poolPrices) {
117
+ return CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
118
+ }
119
+ async getTopPoolsForToken(tokenAddress, limit) {
120
+ if (!this.isDai(tokenAddress) && !this.isSDai(tokenAddress))
121
+ return [];
122
+ return [
123
+ {
124
+ exchange: this.dexKey,
125
+ address: this.sdaiAddress,
126
+ connectorTokens: [
127
+ {
128
+ decimals: 18,
129
+ address: this.isDai(tokenAddress)
130
+ ? this.sdaiAddress
131
+ : this.daiAddress,
132
+ },
133
+ ],
134
+ liquidityUSD: 1000000000, // Just returning a big number so this DEX will be preferred
135
+ },
136
+ ];
137
+ }
138
+ async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data, side) {
139
+ const isSell = side === constants_1.SwapSide.SELL;
140
+ const { exchange } = data;
141
+ let swapData;
142
+ if (this.isDai(srcToken)) {
143
+ swapData = this.sdaiInterface.encodeFunctionData(isSell ? types_1.SDaiFunctions.deposit : types_1.SDaiFunctions.mint, [isSell ? srcAmount : destAmount, this.augustusAddress]);
144
+ }
145
+ else {
146
+ swapData = this.sdaiInterface.encodeFunctionData(isSell ? types_1.SDaiFunctions.redeem : types_1.SDaiFunctions.withdraw, [
147
+ isSell ? srcAmount : destAmount,
148
+ this.augustusAddress,
149
+ this.augustusAddress,
150
+ ]);
151
+ }
152
+ return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, exchange);
153
+ }
154
+ getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
155
+ const { exchange } = data;
156
+ const payload = this.abiCoder.encodeParameter({
157
+ ParentStruct: {
158
+ toStaked: 'bool',
159
+ },
160
+ }, {
161
+ toStaked: this.isDai(srcToken),
162
+ });
163
+ return {
164
+ targetExchange: exchange,
165
+ payload,
166
+ networkFee: '0',
167
+ };
168
+ }
169
+ }
170
+ exports.SDai = SDai;
171
+ SDai.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SDaiConfig);
172
+ //# sourceMappingURL=sdai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdai.js","sourceRoot":"","sources":["../../../src/dex/sdai/sdai.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wDAAoD;AAEpD,mCAA8D;AAC9D,+CAAoD;AACpD,uCAAoD;AACpD,qCAAgD;AAYhD,2EAA6D;AAC7D,4EAAkD;AAClD,6FAA+D;AAC/D,4CAA6C;AAC7C,2CAA4C;AAC5C,6DAAiD;AACjD,2CAA0E;AAE1E,MAAa,IAAK,SAAQ,gCAAc;IAUtC,YACY,OAAgB,EAC1B,MAAc,EACJ,SAAqB,EAEtB,aAAqB,mBAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAC3D,cAAsB,mBAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC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CAAC,CAAC,qBAAa,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAa,CAAC,QAAQ,EACtD;gBACE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU;gBAC/B,IAAI,CAAC,eAAe;gBACpB,IAAI,CAAC,eAAe;aACrB,CACF,CAAC;SACH;QAED,OAAO,IAAI,CAAC,qCAAqC,CAC/C,QAAQ,EACR,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,eAAe,CACb,QAAgB,EAChB,SAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,IAAc,EACd,IAAc;QAEd,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAE1B,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,eAAe,CAC3C;YACE,YAAY,EAAE;gBACZ,QAAQ,EAAE,MAAM;aACjB;SACF,EACD;YACE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;SAC/B,CACF,CAAC;QAEF,OAAO;YACL,cAAc,EAAE,QAAQ;YACxB,OAAO;YACP,UAAU,EAAE,GAAG;SAChB,CAAC;IACJ,CAAC;;AA9MH,oBA+MC;AA3Me,uBAAkB,GAC9B,IAAA,6BAAqB,EAAC,mBAAU,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Address } from '../../types';
2
+ export declare type SDaiData = {
3
+ exchange: Address;
4
+ };
5
+ export declare type SDaiParams = {
6
+ sdaiAddress: Address;
7
+ daiAddress: Address;
8
+ potAddress: Address;
9
+ };
10
+ export declare enum SDaiFunctions {
11
+ deposit = "deposit",
12
+ redeem = "redeem",
13
+ withdraw = "withdraw",
14
+ mint = "mint"
15
+ }
16
+ export declare type SDaiPoolState = {
17
+ rho: string;
18
+ chi: string;
19
+ dsr: string;
20
+ live: boolean;
21
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SDaiFunctions = void 0;
4
+ var SDaiFunctions;
5
+ (function (SDaiFunctions) {
6
+ SDaiFunctions["deposit"] = "deposit";
7
+ SDaiFunctions["redeem"] = "redeem";
8
+ SDaiFunctions["withdraw"] = "withdraw";
9
+ SDaiFunctions["mint"] = "mint";
10
+ })(SDaiFunctions = exports.SDaiFunctions || (exports.SDaiFunctions = {}));
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/dex/sdai/types.ts"],"names":[],"mappings":";;;AAUA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,8BAAa,CAAA;AACf,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB"}
@@ -0,0 +1,4 @@
1
+ import { Contract } from 'web3-eth-contract';
2
+ import { SDaiPoolState } from './types';
3
+ import { Interface } from '@ethersproject/abi';
4
+ export declare function getOnChainState(multiContract: Contract, potAddress: string, potInterface: Interface, blockNumber: number | 'latest'): Promise<SDaiPoolState>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOnChainState = void 0;
4
+ const abi_1 = require("@ethersproject/abi");
5
+ const coder = new abi_1.AbiCoder();
6
+ // - `dsr`: the Dai Savings Rate
7
+ // - `chi`: the Rate Accumulator
8
+ // - `rho`: time of last drip
9
+ async function getOnChainState(multiContract, potAddress, potInterface, blockNumber) {
10
+ const data = await multiContract.methods
11
+ .aggregate([
12
+ {
13
+ target: potAddress,
14
+ callData: potInterface.encodeFunctionData('dsr', []),
15
+ },
16
+ {
17
+ target: potAddress,
18
+ callData: potInterface.encodeFunctionData('chi', []),
19
+ },
20
+ {
21
+ target: potAddress,
22
+ callData: potInterface.encodeFunctionData('rho', []),
23
+ },
24
+ {
25
+ target: potAddress,
26
+ callData: potInterface.encodeFunctionData('live', []),
27
+ },
28
+ ])
29
+ .call({}, blockNumber);
30
+ const [dsr, chi, rho, live] = data.returnData.map(item => coder.decode(['uint256'], item)[0].toString());
31
+ return {
32
+ live: !!live,
33
+ dsr,
34
+ chi,
35
+ rho,
36
+ };
37
+ }
38
+ exports.getOnChainState = getOnChainState;
39
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/dex/sdai/utils.ts"],"names":[],"mappings":";;;AAEA,4CAAyD;AAGzD,MAAM,KAAK,GAAG,IAAI,cAAQ,EAAE,CAAC;AAE7B,gCAAgC;AAChC,gCAAgC;AAChC,6BAA6B;AACtB,KAAK,UAAU,eAAe,CACnC,aAAuB,EACvB,UAAkB,EAClB,YAAuB,EACvB,WAA8B;IAE9B,MAAM,IAAI,GAA0B,MAAM,aAAa,CAAC,OAAO;SAC5D,SAAS,CAAC;QACT;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAAK,EAAE,EAAE,CAAC;SACrD;QACD;YACE,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,YAAY,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,CAAC;SACtD;KACF,CAAC;SACD,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;IAEzB,MAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CACvD,KAAK,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAC9C,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,GAAG;QACH,GAAG;QACH,GAAG;KACJ,CAAC;AACJ,CAAC;AArCD,0CAqCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraswap/dex-lib",
3
- "version": "2.50.6",
3
+ "version": "2.50.7-sdai",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "repository": "https://github.com/paraswap/paraswap-dex-lib",
@@ -0,0 +1,322 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "vat_",
7
+ "type": "address"
8
+ }
9
+ ],
10
+ "payable": false,
11
+ "stateMutability": "nonpayable",
12
+ "type": "constructor"
13
+ },
14
+ {
15
+ "anonymous": true,
16
+ "inputs": [
17
+ {
18
+ "indexed": true,
19
+ "internalType": "bytes4",
20
+ "name": "sig",
21
+ "type": "bytes4"
22
+ },
23
+ {
24
+ "indexed": true,
25
+ "internalType": "address",
26
+ "name": "usr",
27
+ "type": "address"
28
+ },
29
+ {
30
+ "indexed": true,
31
+ "internalType": "bytes32",
32
+ "name": "arg1",
33
+ "type": "bytes32"
34
+ },
35
+ {
36
+ "indexed": true,
37
+ "internalType": "bytes32",
38
+ "name": "arg2",
39
+ "type": "bytes32"
40
+ },
41
+ {
42
+ "indexed": false,
43
+ "internalType": "bytes",
44
+ "name": "data",
45
+ "type": "bytes"
46
+ }
47
+ ],
48
+ "name": "LogNote",
49
+ "type": "event"
50
+ },
51
+ {
52
+ "constant": true,
53
+ "inputs": [],
54
+ "name": "Pie",
55
+ "outputs": [
56
+ {
57
+ "internalType": "uint256",
58
+ "name": "",
59
+ "type": "uint256"
60
+ }
61
+ ],
62
+ "payable": false,
63
+ "stateMutability": "view",
64
+ "type": "function"
65
+ },
66
+ {
67
+ "constant": false,
68
+ "inputs": [],
69
+ "name": "cage",
70
+ "outputs": [],
71
+ "payable": false,
72
+ "stateMutability": "nonpayable",
73
+ "type": "function"
74
+ },
75
+ {
76
+ "constant": true,
77
+ "inputs": [],
78
+ "name": "chi",
79
+ "outputs": [
80
+ {
81
+ "internalType": "uint256",
82
+ "name": "",
83
+ "type": "uint256"
84
+ }
85
+ ],
86
+ "payable": false,
87
+ "stateMutability": "view",
88
+ "type": "function"
89
+ },
90
+ {
91
+ "constant": false,
92
+ "inputs": [
93
+ {
94
+ "internalType": "address",
95
+ "name": "guy",
96
+ "type": "address"
97
+ }
98
+ ],
99
+ "name": "deny",
100
+ "outputs": [],
101
+ "payable": false,
102
+ "stateMutability": "nonpayable",
103
+ "type": "function"
104
+ },
105
+ {
106
+ "constant": false,
107
+ "inputs": [],
108
+ "name": "drip",
109
+ "outputs": [
110
+ {
111
+ "internalType": "uint256",
112
+ "name": "tmp",
113
+ "type": "uint256"
114
+ }
115
+ ],
116
+ "payable": false,
117
+ "stateMutability": "nonpayable",
118
+ "type": "function"
119
+ },
120
+ {
121
+ "constant": true,
122
+ "inputs": [],
123
+ "name": "dsr",
124
+ "outputs": [
125
+ {
126
+ "internalType": "uint256",
127
+ "name": "",
128
+ "type": "uint256"
129
+ }
130
+ ],
131
+ "payable": false,
132
+ "stateMutability": "view",
133
+ "type": "function"
134
+ },
135
+ {
136
+ "constant": false,
137
+ "inputs": [
138
+ {
139
+ "internalType": "uint256",
140
+ "name": "wad",
141
+ "type": "uint256"
142
+ }
143
+ ],
144
+ "name": "exit",
145
+ "outputs": [],
146
+ "payable": false,
147
+ "stateMutability": "nonpayable",
148
+ "type": "function"
149
+ },
150
+ {
151
+ "constant": false,
152
+ "inputs": [
153
+ {
154
+ "internalType": "bytes32",
155
+ "name": "what",
156
+ "type": "bytes32"
157
+ },
158
+ {
159
+ "internalType": "uint256",
160
+ "name": "data",
161
+ "type": "uint256"
162
+ }
163
+ ],
164
+ "name": "file",
165
+ "outputs": [],
166
+ "payable": false,
167
+ "stateMutability": "nonpayable",
168
+ "type": "function"
169
+ },
170
+ {
171
+ "constant": false,
172
+ "inputs": [
173
+ {
174
+ "internalType": "bytes32",
175
+ "name": "what",
176
+ "type": "bytes32"
177
+ },
178
+ {
179
+ "internalType": "address",
180
+ "name": "addr",
181
+ "type": "address"
182
+ }
183
+ ],
184
+ "name": "file",
185
+ "outputs": [],
186
+ "payable": false,
187
+ "stateMutability": "nonpayable",
188
+ "type": "function"
189
+ },
190
+ {
191
+ "constant": false,
192
+ "inputs": [
193
+ {
194
+ "internalType": "uint256",
195
+ "name": "wad",
196
+ "type": "uint256"
197
+ }
198
+ ],
199
+ "name": "join",
200
+ "outputs": [],
201
+ "payable": false,
202
+ "stateMutability": "nonpayable",
203
+ "type": "function"
204
+ },
205
+ {
206
+ "constant": true,
207
+ "inputs": [],
208
+ "name": "live",
209
+ "outputs": [
210
+ {
211
+ "internalType": "uint256",
212
+ "name": "",
213
+ "type": "uint256"
214
+ }
215
+ ],
216
+ "payable": false,
217
+ "stateMutability": "view",
218
+ "type": "function"
219
+ },
220
+ {
221
+ "constant": true,
222
+ "inputs": [
223
+ {
224
+ "internalType": "address",
225
+ "name": "",
226
+ "type": "address"
227
+ }
228
+ ],
229
+ "name": "pie",
230
+ "outputs": [
231
+ {
232
+ "internalType": "uint256",
233
+ "name": "",
234
+ "type": "uint256"
235
+ }
236
+ ],
237
+ "payable": false,
238
+ "stateMutability": "view",
239
+ "type": "function"
240
+ },
241
+ {
242
+ "constant": false,
243
+ "inputs": [
244
+ {
245
+ "internalType": "address",
246
+ "name": "guy",
247
+ "type": "address"
248
+ }
249
+ ],
250
+ "name": "rely",
251
+ "outputs": [],
252
+ "payable": false,
253
+ "stateMutability": "nonpayable",
254
+ "type": "function"
255
+ },
256
+ {
257
+ "constant": true,
258
+ "inputs": [],
259
+ "name": "rho",
260
+ "outputs": [
261
+ {
262
+ "internalType": "uint256",
263
+ "name": "",
264
+ "type": "uint256"
265
+ }
266
+ ],
267
+ "payable": false,
268
+ "stateMutability": "view",
269
+ "type": "function"
270
+ },
271
+ {
272
+ "constant": true,
273
+ "inputs": [],
274
+ "name": "vat",
275
+ "outputs": [
276
+ {
277
+ "internalType": "contract VatLike",
278
+ "name": "",
279
+ "type": "address"
280
+ }
281
+ ],
282
+ "payable": false,
283
+ "stateMutability": "view",
284
+ "type": "function"
285
+ },
286
+ {
287
+ "constant": true,
288
+ "inputs": [],
289
+ "name": "vow",
290
+ "outputs": [
291
+ {
292
+ "internalType": "address",
293
+ "name": "",
294
+ "type": "address"
295
+ }
296
+ ],
297
+ "payable": false,
298
+ "stateMutability": "view",
299
+ "type": "function"
300
+ },
301
+ {
302
+ "constant": true,
303
+ "inputs": [
304
+ {
305
+ "internalType": "address",
306
+ "name": "",
307
+ "type": "address"
308
+ }
309
+ ],
310
+ "name": "wards",
311
+ "outputs": [
312
+ {
313
+ "internalType": "uint256",
314
+ "name": "",
315
+ "type": "uint256"
316
+ }
317
+ ],
318
+ "payable": false,
319
+ "stateMutability": "view",
320
+ "type": "function"
321
+ }
322
+ ]