@defisaver/positions-sdk 0.0.5 → 0.0.7
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/cjs/aaveV2/index.d.ts +2 -2
- package/cjs/aaveV2/index.js +5 -3
- package/cjs/aaveV3/index.js +1 -1
- package/cjs/chickenBonds/index.js +2 -1
- package/cjs/compoundV3/index.d.ts +2 -2
- package/cjs/compoundV3/index.js +8 -5
- package/cjs/config/contracts.d.ts +144 -0
- package/cjs/config/contracts.js +18 -0
- package/cjs/contracts.d.ts +3 -0
- package/cjs/contracts.js +4 -1
- package/cjs/helpers/aaveHelpers/index.js +14 -2
- package/cjs/helpers/chickenBondsHelpers/index.d.ts +1 -0
- package/cjs/helpers/chickenBondsHelpers/index.js +14 -1
- package/cjs/helpers/compoundHelpers/index.d.ts +2 -2
- package/cjs/helpers/compoundHelpers/index.js +5 -4
- package/cjs/morphoAaveV2/index.d.ts +2 -2
- package/cjs/morphoAaveV2/index.js +5 -3
- package/cjs/services/priceService.d.ts +4 -0
- package/cjs/services/priceService.js +36 -0
- package/cjs/types/chickenBonds.d.ts +1 -0
- package/cjs/types/contracts/generated/COMPPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/COMPPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/ETHPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/ETHPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/USDCPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/USDCPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +3 -0
- package/esm/aaveV2/index.d.ts +2 -2
- package/esm/aaveV2/index.js +5 -3
- package/esm/aaveV3/index.js +1 -1
- package/esm/chickenBonds/index.js +3 -2
- package/esm/compoundV3/index.d.ts +2 -2
- package/esm/compoundV3/index.js +8 -5
- package/esm/config/contracts.d.ts +144 -0
- package/esm/config/contracts.js +18 -0
- package/esm/contracts.d.ts +3 -0
- package/esm/contracts.js +3 -0
- package/esm/helpers/aaveHelpers/index.js +14 -2
- package/esm/helpers/chickenBondsHelpers/index.d.ts +1 -0
- package/esm/helpers/chickenBondsHelpers/index.js +12 -0
- package/esm/helpers/compoundHelpers/index.d.ts +2 -2
- package/esm/helpers/compoundHelpers/index.js +5 -4
- package/esm/morphoAaveV2/index.d.ts +2 -2
- package/esm/morphoAaveV2/index.js +5 -3
- package/esm/services/priceService.d.ts +4 -0
- package/esm/services/priceService.js +27 -0
- package/esm/types/chickenBonds.d.ts +1 -0
- package/esm/types/contracts/generated/COMPPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/COMPPriceFeed.js +4 -0
- package/esm/types/contracts/generated/ETHPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/ETHPriceFeed.js +4 -0
- package/esm/types/contracts/generated/USDCPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/USDCPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +3 -0
- package/package.json +1 -1
- package/src/aaveV2/index.ts +5 -3
- package/src/aaveV3/index.ts +1 -0
- package/src/chickenBonds/index.ts +3 -2
- package/src/compoundV3/index.ts +8 -5
- package/src/config/contracts.js +18 -0
- package/src/contracts.ts +5 -1
- package/src/helpers/aaveHelpers/index.ts +16 -2
- package/src/helpers/chickenBondsHelpers/index.ts +11 -0
- package/src/helpers/compoundHelpers/index.ts +7 -4
- package/src/morphoAaveV2/index.ts +5 -3
- package/src/services/priceService.ts +22 -0
- package/src/types/chickenBonds.ts +1 -0
- package/src/types/contracts/generated/COMPPriceFeed.ts +202 -0
- package/src/types/contracts/generated/ETHPriceFeed.ts +202 -0
- package/src/types/contracts/generated/USDCPriceFeed.ts +202 -0
- package/src/types/contracts/generated/index.ts +3 -0
- package/yarn-error.log +64 -0
|
@@ -3060,3 +3060,147 @@ export namespace ChickenBondsManager {
|
|
|
3060
3060
|
};
|
|
3061
3061
|
export { networks_57 as networks };
|
|
3062
3062
|
}
|
|
3063
|
+
export namespace COMPPriceFeed {
|
|
3064
|
+
let abi_58: ({
|
|
3065
|
+
inputs: {
|
|
3066
|
+
internalType: string;
|
|
3067
|
+
name: string;
|
|
3068
|
+
type: string;
|
|
3069
|
+
}[];
|
|
3070
|
+
stateMutability: string;
|
|
3071
|
+
type: string;
|
|
3072
|
+
anonymous?: undefined;
|
|
3073
|
+
name?: undefined;
|
|
3074
|
+
outputs?: undefined;
|
|
3075
|
+
} | {
|
|
3076
|
+
anonymous: boolean;
|
|
3077
|
+
inputs: {
|
|
3078
|
+
indexed: boolean;
|
|
3079
|
+
internalType: string;
|
|
3080
|
+
name: string;
|
|
3081
|
+
type: string;
|
|
3082
|
+
}[];
|
|
3083
|
+
name: string;
|
|
3084
|
+
type: string;
|
|
3085
|
+
stateMutability?: undefined;
|
|
3086
|
+
outputs?: undefined;
|
|
3087
|
+
} | {
|
|
3088
|
+
inputs: {
|
|
3089
|
+
internalType: string;
|
|
3090
|
+
name: string;
|
|
3091
|
+
type: string;
|
|
3092
|
+
}[];
|
|
3093
|
+
name: string;
|
|
3094
|
+
outputs: {
|
|
3095
|
+
internalType: string;
|
|
3096
|
+
name: string;
|
|
3097
|
+
type: string;
|
|
3098
|
+
}[];
|
|
3099
|
+
stateMutability: string;
|
|
3100
|
+
type: string;
|
|
3101
|
+
anonymous?: undefined;
|
|
3102
|
+
})[];
|
|
3103
|
+
export { abi_58 as abi };
|
|
3104
|
+
let networks_58: {
|
|
3105
|
+
"1": {
|
|
3106
|
+
address: string;
|
|
3107
|
+
};
|
|
3108
|
+
};
|
|
3109
|
+
export { networks_58 as networks };
|
|
3110
|
+
}
|
|
3111
|
+
export namespace ETHPriceFeed {
|
|
3112
|
+
let abi_59: ({
|
|
3113
|
+
inputs: {
|
|
3114
|
+
internalType: string;
|
|
3115
|
+
name: string;
|
|
3116
|
+
type: string;
|
|
3117
|
+
}[];
|
|
3118
|
+
stateMutability: string;
|
|
3119
|
+
type: string;
|
|
3120
|
+
anonymous?: undefined;
|
|
3121
|
+
name?: undefined;
|
|
3122
|
+
outputs?: undefined;
|
|
3123
|
+
} | {
|
|
3124
|
+
anonymous: boolean;
|
|
3125
|
+
inputs: {
|
|
3126
|
+
indexed: boolean;
|
|
3127
|
+
internalType: string;
|
|
3128
|
+
name: string;
|
|
3129
|
+
type: string;
|
|
3130
|
+
}[];
|
|
3131
|
+
name: string;
|
|
3132
|
+
type: string;
|
|
3133
|
+
stateMutability?: undefined;
|
|
3134
|
+
outputs?: undefined;
|
|
3135
|
+
} | {
|
|
3136
|
+
inputs: {
|
|
3137
|
+
internalType: string;
|
|
3138
|
+
name: string;
|
|
3139
|
+
type: string;
|
|
3140
|
+
}[];
|
|
3141
|
+
name: string;
|
|
3142
|
+
outputs: {
|
|
3143
|
+
internalType: string;
|
|
3144
|
+
name: string;
|
|
3145
|
+
type: string;
|
|
3146
|
+
}[];
|
|
3147
|
+
stateMutability: string;
|
|
3148
|
+
type: string;
|
|
3149
|
+
anonymous?: undefined;
|
|
3150
|
+
})[];
|
|
3151
|
+
export { abi_59 as abi };
|
|
3152
|
+
let networks_59: {
|
|
3153
|
+
"1": {
|
|
3154
|
+
address: string;
|
|
3155
|
+
};
|
|
3156
|
+
};
|
|
3157
|
+
export { networks_59 as networks };
|
|
3158
|
+
}
|
|
3159
|
+
export namespace USDCPriceFeed {
|
|
3160
|
+
let abi_60: ({
|
|
3161
|
+
inputs: {
|
|
3162
|
+
internalType: string;
|
|
3163
|
+
name: string;
|
|
3164
|
+
type: string;
|
|
3165
|
+
}[];
|
|
3166
|
+
stateMutability: string;
|
|
3167
|
+
type: string;
|
|
3168
|
+
anonymous?: undefined;
|
|
3169
|
+
name?: undefined;
|
|
3170
|
+
outputs?: undefined;
|
|
3171
|
+
} | {
|
|
3172
|
+
anonymous: boolean;
|
|
3173
|
+
inputs: {
|
|
3174
|
+
indexed: boolean;
|
|
3175
|
+
internalType: string;
|
|
3176
|
+
name: string;
|
|
3177
|
+
type: string;
|
|
3178
|
+
}[];
|
|
3179
|
+
name: string;
|
|
3180
|
+
type: string;
|
|
3181
|
+
stateMutability?: undefined;
|
|
3182
|
+
outputs?: undefined;
|
|
3183
|
+
} | {
|
|
3184
|
+
inputs: {
|
|
3185
|
+
internalType: string;
|
|
3186
|
+
name: string;
|
|
3187
|
+
type: string;
|
|
3188
|
+
}[];
|
|
3189
|
+
name: string;
|
|
3190
|
+
outputs: {
|
|
3191
|
+
internalType: string;
|
|
3192
|
+
name: string;
|
|
3193
|
+
type: string;
|
|
3194
|
+
}[];
|
|
3195
|
+
stateMutability: string;
|
|
3196
|
+
type: string;
|
|
3197
|
+
anonymous?: undefined;
|
|
3198
|
+
})[];
|
|
3199
|
+
export { abi_60 as abi };
|
|
3200
|
+
let networks_60: {
|
|
3201
|
+
"1": {
|
|
3202
|
+
address: string;
|
|
3203
|
+
};
|
|
3204
|
+
};
|
|
3205
|
+
export { networks_60 as networks };
|
|
3206
|
+
}
|
package/esm/config/contracts.js
CHANGED
|
@@ -597,5 +597,23 @@ module.exports = {
|
|
|
597
597
|
"networks": {
|
|
598
598
|
"1": { "address": "0x57619FE9C539f890b19c61812226F9703ce37137" }
|
|
599
599
|
}
|
|
600
|
+
},
|
|
601
|
+
"COMPPriceFeed": {
|
|
602
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }, { "internalType": "address", "name": "_accessController", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "int256", "name": "current", "type": "int256" }, { "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "updatedAt", "type": "uint256" }], "name": "AnswerUpdated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "startedBy", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "startedAt", "type": "uint256" }], "name": "NewRound", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferRequested", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "accessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "aggregator", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "confirmAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address payable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "name": "phaseAggregators", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "phaseId", "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "proposeAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proposedAggregator", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "proposedGetRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "proposedLatestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_accessController", "type": "address" }], "name": "setController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
603
|
+
"networks": {
|
|
604
|
+
"1": { "address": "0xdbd020CAeF83eFd542f4De03e3cF0C28A4428bd5" }
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
"ETHPriceFeed": {
|
|
608
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }, { "internalType": "address", "name": "_accessController", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "int256", "name": "current", "type": "int256" }, { "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "updatedAt", "type": "uint256" }], "name": "AnswerUpdated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "startedBy", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "startedAt", "type": "uint256" }], "name": "NewRound", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferRequested", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "accessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "aggregator", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "confirmAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address payable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "name": "phaseAggregators", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "phaseId", "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "proposeAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proposedAggregator", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "proposedGetRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "proposedLatestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_accessController", "type": "address" }], "name": "setController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
609
|
+
"networks": {
|
|
610
|
+
"1": { "address": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" }
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
"USDCPriceFeed": {
|
|
614
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }, { "internalType": "address", "name": "_accessController", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "int256", "name": "current", "type": "int256" }, { "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "updatedAt", "type": "uint256" }], "name": "AnswerUpdated", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "roundId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "startedBy", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "startedAt", "type": "uint256" }], "name": "NewRound", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferRequested", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "accessController", "outputs": [{ "internalType": "contract AccessControllerInterface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "aggregator", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "confirmAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "decimals", "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "description", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_roundId", "type": "uint256" }], "name": "getTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestAnswer", "outputs": [{ "internalType": "int256", "name": "", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRound", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "latestTimestamp", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "name": "phaseAggregators", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "phaseId", "outputs": [{ "internalType": "uint16", "name": "", "type": "uint16" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_aggregator", "type": "address" }], "name": "proposeAggregator", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "proposedAggregator", "outputs": [{ "internalType": "contract AggregatorV2V3Interface", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "proposedGetRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "proposedLatestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_accessController", "type": "address" }], "name": "setController", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_to", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "version", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
615
|
+
"networks": {
|
|
616
|
+
"1": { "address": "0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6" }
|
|
617
|
+
}
|
|
600
618
|
}
|
|
601
619
|
};
|
package/esm/contracts.d.ts
CHANGED
|
@@ -39,3 +39,6 @@ export declare const McdJugContract: (web3: Web3, network: NetworkNumber, block?
|
|
|
39
39
|
export declare const McdVatContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.McdVat;
|
|
40
40
|
export declare const ChickenBondsViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ChickenBondsView;
|
|
41
41
|
export declare const ChickenBondsManagerContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ChickenBondsManager;
|
|
42
|
+
export declare const ETHPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ETHPriceFeed;
|
|
43
|
+
export declare const COMPPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.COMPPriceFeed;
|
|
44
|
+
export declare const USDCPriceFeedContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.USDCPriceFeed;
|
package/esm/contracts.js
CHANGED
|
@@ -54,3 +54,6 @@ export const McdJugContract = createContractFromConfigFunc('McdJug');
|
|
|
54
54
|
export const McdVatContract = createContractFromConfigFunc('McdVat');
|
|
55
55
|
export const ChickenBondsViewContract = createContractFromConfigFunc('ChickenBondsView');
|
|
56
56
|
export const ChickenBondsManagerContract = createContractFromConfigFunc('ChickenBondsManager');
|
|
57
|
+
export const ETHPriceFeedContract = createContractFromConfigFunc('ETHPriceFeed');
|
|
58
|
+
export const COMPPriceFeedContract = createContractFromConfigFunc('COMPPriceFeed');
|
|
59
|
+
export const USDCPriceFeedContract = createContractFromConfigFunc('USDCPriceFeed');
|
|
@@ -61,8 +61,20 @@ export const aaveAnyGetAggregatedPositionData = (_a) => {
|
|
|
61
61
|
const payload = {};
|
|
62
62
|
payload.suppliedUsd = getAssetsTotal(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
|
|
63
63
|
payload.suppliedCollateralUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
|
|
64
|
-
payload.borrowLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd }) =>
|
|
65
|
-
|
|
64
|
+
payload.borrowLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd }) => {
|
|
65
|
+
const suppliedUsdAmount = isMorphoAaveV3(data)
|
|
66
|
+
// Morpho has a slightly different method for calculating health ratio than underlying pool (To account for potential errors in rounding)
|
|
67
|
+
? new Dec(suppliedUsd).minus(new Dec(suppliedUsd).div(100).times(0.1)).toString()
|
|
68
|
+
: suppliedUsd;
|
|
69
|
+
return new Dec(suppliedUsdAmount).mul(aaveAnyGetEmodeMutableProps(data, symbol).collateralFactor);
|
|
70
|
+
});
|
|
71
|
+
payload.liquidationLimitUsd = getAssetsTotal(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ symbol, suppliedUsd }) => {
|
|
72
|
+
const suppliedUsdAmount = isMorphoAaveV3(data)
|
|
73
|
+
// Morpho has a slightly different method for calculating health ratio than underlying pool (To account for potential errors in rounding)
|
|
74
|
+
? new Dec(suppliedUsd).minus(new Dec(suppliedUsd).div(100).times(0.1)).toString()
|
|
75
|
+
: suppliedUsd;
|
|
76
|
+
return new Dec(suppliedUsdAmount).mul(aaveAnyGetEmodeMutableProps(data, symbol).liquidationRatio);
|
|
77
|
+
});
|
|
66
78
|
payload.borrowedUsd = getAssetsTotal(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
|
|
67
79
|
const leftToBorrowUsd = new Dec(payload.borrowLimitUsd).sub(payload.borrowedUsd);
|
|
68
80
|
payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export declare const calcCBondsBLUSDFloorPrice: (bLUSDSupply: string, totalReserveLUSD: string) => string;
|
|
2
2
|
export declare const calcAverageBondAgeMs: (totalWeightedStartTimes: string, totalPendingLusd: string) => number;
|
|
3
|
+
export declare const decodeTokenURIToSvg: (tokenURI: string) => string;
|
|
@@ -9,3 +9,15 @@ export const calcAverageBondAgeMs = (totalWeightedStartTimes, totalPendingLusd)
|
|
|
9
9
|
.toNumber();
|
|
10
10
|
return Date.now() - averageStartTimeMs;
|
|
11
11
|
};
|
|
12
|
+
export const decodeTokenURIToSvg = (tokenURI) => {
|
|
13
|
+
var _a;
|
|
14
|
+
try {
|
|
15
|
+
const dataStartIndex = tokenURI.indexOf('base64,') + 'base64,'.length;
|
|
16
|
+
const json = atob(tokenURI.slice(dataStartIndex));
|
|
17
|
+
return (_a = JSON.parse(json)) === null || _a === void 0 ? void 0 : _a.image;
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
console.error(e);
|
|
21
|
+
return 'Error parsing NFT image';
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseAdditionalAssetData, CompoundAggregatedPositionData, CompoundMarketData, CompoundV2AssetsData, CompoundV2UsedAssets, CompoundV3AssetData, CompoundV3AssetsData, CompoundV3UsedAssets } from '../../types';
|
|
2
2
|
import { NetworkNumber } from '../../types/common';
|
|
3
|
-
export declare const formatMarketData: (data: any, network: NetworkNumber) => CompoundV3AssetData;
|
|
4
|
-
export declare const formatBaseData: (data: any, network: NetworkNumber) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
3
|
+
export declare const formatMarketData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData;
|
|
4
|
+
export declare const formatBaseData: (data: any, network: NetworkNumber, baseAssetPrice: string) => CompoundV3AssetData & BaseAdditionalAssetData;
|
|
5
5
|
export declare const getIncentiveApys: (baseData: CompoundV3AssetData & BaseAdditionalAssetData, compPrice: string) => {
|
|
6
6
|
incentiveSupplyApy: string;
|
|
7
7
|
incentiveBorrowApy: string;
|
|
@@ -16,13 +16,14 @@ import { getEthAmountForDecimals, handleWbtcLegacy, wethToEth } from '../../serv
|
|
|
16
16
|
import { SECONDS_PER_YEAR } from '../../constants';
|
|
17
17
|
import { aprToApy, calcLeverageLiqPrice, calculateBorrowingAssetLimit, getAssetsTotal, isLeveragedPos, } from '../../moneymarket';
|
|
18
18
|
import { calculateNetApy } from '../../staking';
|
|
19
|
-
export const formatMarketData = (data, network) => {
|
|
19
|
+
export const formatMarketData = (data, network, baseAssetPrice) => {
|
|
20
20
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
21
21
|
const isWETH = assetInfo.symbol === 'WETH';
|
|
22
|
-
|
|
22
|
+
const price = getEthAmountForDecimals(data.price, 8);
|
|
23
|
+
return (Object.assign(Object.assign({}, data), { priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: new Dec(price).mul(baseAssetPrice).toString(), collateralFactor: getEthAmountForDecimals(data.borrowCollateralFactor, 18), liquidationRatio: getEthAmountForDecimals(data.liquidateCollateralFactor, 18), supplyCap: getEthAmountForDecimals(data.supplyCap, assetInfo.decimals), totalSupply: getEthAmountForDecimals(data.totalSupply, assetInfo.decimals), symbol: isWETH ? 'ETH' : assetInfo.symbol, supplyRate: '0', borrowRate: '0', canBeBorrowed: false, canBeSupplied: true }));
|
|
23
24
|
};
|
|
24
25
|
// TODO: maybe not hardcode decimals
|
|
25
|
-
export const formatBaseData = (data, network) => {
|
|
26
|
+
export const formatBaseData = (data, network, baseAssetPrice) => {
|
|
26
27
|
const assetInfo = getAssetInfoByAddress(data.tokenAddr, network);
|
|
27
28
|
const totalSupply = getEthAmountForDecimals(new Dec(data.totalSupply).mul(data.supplyIndex).toString(), 15 + assetInfo.decimals);
|
|
28
29
|
const totalBorrow = getEthAmountForDecimals(new Dec(data.totalBorrow).mul(data.borrowIndex).toString(), 15 + assetInfo.decimals);
|
|
@@ -30,7 +31,7 @@ export const formatBaseData = (data, network) => {
|
|
|
30
31
|
.toString()), borrowRate: aprToApy(new Dec(data.borrowRate).div(1e18).mul(SECONDS_PER_YEAR).mul(100)
|
|
31
32
|
.toString()), utilization: getEthAmountForDecimals(data.utilization, 16), // utilization is totalSupply/totalBorrow in 1e18, but we need % so when we mul with 100 it's 16 decimals
|
|
32
33
|
totalSupply,
|
|
33
|
-
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol),
|
|
34
|
+
totalBorrow, marketLiquidity: new Dec(totalSupply).minus(totalBorrow).toString(), symbol: wethToEth(assetInfo.symbol), priceInBaseAsset: getEthAmountForDecimals(data.price, 8), price: baseAssetPrice, collateralFactor: '0', liquidationRatio: '0', canBeBorrowed: true, canBeSupplied: true, supplyCap: '0', rewardSupplySpeed: getEthAmountForDecimals(data.baseTrackingSupplyRewardsSpeed, 15), rewardBorrowSpeed: getEthAmountForDecimals(data.baseTrackingBorrowRewardsSpeed, 15), minDebt: getEthAmountForDecimals(data.baseBorrowMin, assetInfo.decimals), isBase: true }));
|
|
34
35
|
};
|
|
35
36
|
export const getIncentiveApys = (baseData, compPrice) => {
|
|
36
37
|
const incentiveSupplyApy = aprToApy((100 * SECONDS_PER_YEAR * +baseData.rewardSupplySpeed * +compPrice) / +baseData.price / +baseData.totalSupply).toString();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { Blockish, EthAddress, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
3
|
import { MorphoAaveV2AssetsData, MorphoAaveV2MarketData, MorphoAaveV2PositionData } from '../types';
|
|
4
|
-
export declare const getMorphoAaveV2MarketsData: (web3: Web3, network: NetworkNumber,
|
|
4
|
+
export declare const getMorphoAaveV2MarketsData: (web3: Web3, network: NetworkNumber, mainnetWeb3: Web3) => Promise<MorphoAaveV2MarketData>;
|
|
5
5
|
export declare const getMorphoAaveV2AccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, address: EthAddress) => Promise<PositionBalances>;
|
|
6
6
|
export declare const getMorphoAaveV2AccountData: (web3: Web3, network: NetworkNumber, address: string, assetsData: MorphoAaveV2AssetsData) => Promise<MorphoAaveV2PositionData>;
|
|
7
|
-
export declare const getMorphoAaveV2FullPositionData: (web3: Web3, network: NetworkNumber, address: string,
|
|
7
|
+
export declare const getMorphoAaveV2FullPositionData: (web3: Web3, network: NetworkNumber, address: string, mainnetWeb3: Web3) => Promise<MorphoAaveV2PositionData>;
|
|
@@ -16,7 +16,9 @@ import { AaveVersions, } from '../types';
|
|
|
16
16
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
17
17
|
import { EMPTY_AAVE_DATA } from '../aaveV3';
|
|
18
18
|
import { aaveAnyGetAggregatedPositionData } from '../helpers/aaveHelpers';
|
|
19
|
-
|
|
19
|
+
import { getEthPrice } from '../services/priceService';
|
|
20
|
+
export const getMorphoAaveV2MarketsData = (web3, network, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const ethPrice = yield getEthPrice(mainnetWeb3);
|
|
20
22
|
const morphoAaveV2ViewContract = MorphoAaveV2ViewContract(web3, network);
|
|
21
23
|
const [contractData, morphoRewardsRes] = yield Promise.allSettled([
|
|
22
24
|
morphoAaveV2ViewContract.methods.getAllMarketsInfo().call(),
|
|
@@ -192,8 +194,8 @@ export const getMorphoAaveV2AccountData = (web3, network, address, assetsData) =
|
|
|
192
194
|
});
|
|
193
195
|
return payload;
|
|
194
196
|
});
|
|
195
|
-
export const getMorphoAaveV2FullPositionData = (web3, network, address,
|
|
196
|
-
const marketData = yield getMorphoAaveV2MarketsData(web3, network,
|
|
197
|
+
export const getMorphoAaveV2FullPositionData = (web3, network, address, mainnetWeb3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
198
|
+
const marketData = yield getMorphoAaveV2MarketsData(web3, network, mainnetWeb3);
|
|
197
199
|
const positionData = yield getMorphoAaveV2AccountData(web3, network, address, marketData.assetsData);
|
|
198
200
|
return positionData;
|
|
199
201
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import Dec from 'decimal.js';
|
|
11
|
+
import { COMPPriceFeedContract, ETHPriceFeedContract, USDCPriceFeedContract } from '../contracts';
|
|
12
|
+
import { NetworkNumber } from '../types/common';
|
|
13
|
+
export const getEthPrice = (web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const contract = ETHPriceFeedContract(web3, NetworkNumber.Eth);
|
|
15
|
+
const price = yield contract.methods.latestAnswer().call();
|
|
16
|
+
return new Dec(price).div(1e8).toString();
|
|
17
|
+
});
|
|
18
|
+
export const getUSDCPrice = (web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
const contract = USDCPriceFeedContract(web3, NetworkNumber.Eth);
|
|
20
|
+
const price = yield contract.methods.latestAnswer().call();
|
|
21
|
+
return new Dec(price).div(1e8).toString();
|
|
22
|
+
});
|
|
23
|
+
export const getCompPrice = (web3) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const contract = COMPPriceFeedContract(web3, NetworkNumber.Eth);
|
|
25
|
+
const price = yield contract.methods.latestAnswer().call();
|
|
26
|
+
return new Dec(price).div(1e8).toString();
|
|
27
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type BN from "bn.js";
|
|
3
|
+
import type { ContractOptions } from "web3-eth-contract";
|
|
4
|
+
import type { EventLog } from "web3-core";
|
|
5
|
+
import type { EventEmitter } from "events";
|
|
6
|
+
import type { Callback, NonPayableTransactionObject, BlockType, ContractEventLog, BaseContract } from "./types";
|
|
7
|
+
export interface EventOptions {
|
|
8
|
+
filter?: object;
|
|
9
|
+
fromBlock?: BlockType;
|
|
10
|
+
topics?: string[];
|
|
11
|
+
}
|
|
12
|
+
export type AnswerUpdated = ContractEventLog<{
|
|
13
|
+
current: string;
|
|
14
|
+
roundId: string;
|
|
15
|
+
updatedAt: string;
|
|
16
|
+
0: string;
|
|
17
|
+
1: string;
|
|
18
|
+
2: string;
|
|
19
|
+
}>;
|
|
20
|
+
export type NewRound = ContractEventLog<{
|
|
21
|
+
roundId: string;
|
|
22
|
+
startedBy: string;
|
|
23
|
+
startedAt: string;
|
|
24
|
+
0: string;
|
|
25
|
+
1: string;
|
|
26
|
+
2: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type OwnershipTransferRequested = ContractEventLog<{
|
|
29
|
+
from: string;
|
|
30
|
+
to: string;
|
|
31
|
+
0: string;
|
|
32
|
+
1: string;
|
|
33
|
+
}>;
|
|
34
|
+
export type OwnershipTransferred = ContractEventLog<{
|
|
35
|
+
from: string;
|
|
36
|
+
to: string;
|
|
37
|
+
0: string;
|
|
38
|
+
1: string;
|
|
39
|
+
}>;
|
|
40
|
+
export interface COMPPriceFeed extends BaseContract {
|
|
41
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): COMPPriceFeed;
|
|
42
|
+
clone(): COMPPriceFeed;
|
|
43
|
+
methods: {
|
|
44
|
+
acceptOwnership(): NonPayableTransactionObject<void>;
|
|
45
|
+
accessController(): NonPayableTransactionObject<string>;
|
|
46
|
+
aggregator(): NonPayableTransactionObject<string>;
|
|
47
|
+
confirmAggregator(_aggregator: string): NonPayableTransactionObject<void>;
|
|
48
|
+
decimals(): NonPayableTransactionObject<string>;
|
|
49
|
+
description(): NonPayableTransactionObject<string>;
|
|
50
|
+
getAnswer(_roundId: number | string | BN): NonPayableTransactionObject<string>;
|
|
51
|
+
getRoundData(_roundId: number | string | BN): NonPayableTransactionObject<[
|
|
52
|
+
string,
|
|
53
|
+
string,
|
|
54
|
+
string,
|
|
55
|
+
string,
|
|
56
|
+
string
|
|
57
|
+
] & {
|
|
58
|
+
roundId: string;
|
|
59
|
+
answer: string;
|
|
60
|
+
startedAt: string;
|
|
61
|
+
updatedAt: string;
|
|
62
|
+
answeredInRound: string;
|
|
63
|
+
}>;
|
|
64
|
+
getTimestamp(_roundId: number | string | BN): NonPayableTransactionObject<string>;
|
|
65
|
+
latestAnswer(): NonPayableTransactionObject<string>;
|
|
66
|
+
latestRound(): NonPayableTransactionObject<string>;
|
|
67
|
+
latestRoundData(): NonPayableTransactionObject<[
|
|
68
|
+
string,
|
|
69
|
+
string,
|
|
70
|
+
string,
|
|
71
|
+
string,
|
|
72
|
+
string
|
|
73
|
+
] & {
|
|
74
|
+
roundId: string;
|
|
75
|
+
answer: string;
|
|
76
|
+
startedAt: string;
|
|
77
|
+
updatedAt: string;
|
|
78
|
+
answeredInRound: string;
|
|
79
|
+
}>;
|
|
80
|
+
latestTimestamp(): NonPayableTransactionObject<string>;
|
|
81
|
+
owner(): NonPayableTransactionObject<string>;
|
|
82
|
+
phaseAggregators(arg0: number | string | BN): NonPayableTransactionObject<string>;
|
|
83
|
+
phaseId(): NonPayableTransactionObject<string>;
|
|
84
|
+
proposeAggregator(_aggregator: string): NonPayableTransactionObject<void>;
|
|
85
|
+
proposedAggregator(): NonPayableTransactionObject<string>;
|
|
86
|
+
proposedGetRoundData(_roundId: number | string | BN): NonPayableTransactionObject<[
|
|
87
|
+
string,
|
|
88
|
+
string,
|
|
89
|
+
string,
|
|
90
|
+
string,
|
|
91
|
+
string
|
|
92
|
+
] & {
|
|
93
|
+
roundId: string;
|
|
94
|
+
answer: string;
|
|
95
|
+
startedAt: string;
|
|
96
|
+
updatedAt: string;
|
|
97
|
+
answeredInRound: string;
|
|
98
|
+
}>;
|
|
99
|
+
proposedLatestRoundData(): NonPayableTransactionObject<[
|
|
100
|
+
string,
|
|
101
|
+
string,
|
|
102
|
+
string,
|
|
103
|
+
string,
|
|
104
|
+
string
|
|
105
|
+
] & {
|
|
106
|
+
roundId: string;
|
|
107
|
+
answer: string;
|
|
108
|
+
startedAt: string;
|
|
109
|
+
updatedAt: string;
|
|
110
|
+
answeredInRound: string;
|
|
111
|
+
}>;
|
|
112
|
+
setController(_accessController: string): NonPayableTransactionObject<void>;
|
|
113
|
+
transferOwnership(_to: string): NonPayableTransactionObject<void>;
|
|
114
|
+
version(): NonPayableTransactionObject<string>;
|
|
115
|
+
};
|
|
116
|
+
events: {
|
|
117
|
+
AnswerUpdated(cb?: Callback<AnswerUpdated>): EventEmitter;
|
|
118
|
+
AnswerUpdated(options?: EventOptions, cb?: Callback<AnswerUpdated>): EventEmitter;
|
|
119
|
+
NewRound(cb?: Callback<NewRound>): EventEmitter;
|
|
120
|
+
NewRound(options?: EventOptions, cb?: Callback<NewRound>): EventEmitter;
|
|
121
|
+
OwnershipTransferRequested(cb?: Callback<OwnershipTransferRequested>): EventEmitter;
|
|
122
|
+
OwnershipTransferRequested(options?: EventOptions, cb?: Callback<OwnershipTransferRequested>): EventEmitter;
|
|
123
|
+
OwnershipTransferred(cb?: Callback<OwnershipTransferred>): EventEmitter;
|
|
124
|
+
OwnershipTransferred(options?: EventOptions, cb?: Callback<OwnershipTransferred>): EventEmitter;
|
|
125
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
126
|
+
};
|
|
127
|
+
once(event: "AnswerUpdated", cb: Callback<AnswerUpdated>): void;
|
|
128
|
+
once(event: "AnswerUpdated", options: EventOptions, cb: Callback<AnswerUpdated>): void;
|
|
129
|
+
once(event: "NewRound", cb: Callback<NewRound>): void;
|
|
130
|
+
once(event: "NewRound", options: EventOptions, cb: Callback<NewRound>): void;
|
|
131
|
+
once(event: "OwnershipTransferRequested", cb: Callback<OwnershipTransferRequested>): void;
|
|
132
|
+
once(event: "OwnershipTransferRequested", options: EventOptions, cb: Callback<OwnershipTransferRequested>): void;
|
|
133
|
+
once(event: "OwnershipTransferred", cb: Callback<OwnershipTransferred>): void;
|
|
134
|
+
once(event: "OwnershipTransferred", options: EventOptions, cb: Callback<OwnershipTransferred>): void;
|
|
135
|
+
}
|