@defisaver/positions-sdk 0.0.4 → 0.0.5
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/chickenBonds/index.d.ts +4 -0
- package/cjs/chickenBonds/index.js +94 -1
- package/cjs/config/contracts.d.ts +36 -2
- package/cjs/config/contracts.js +7 -1
- package/cjs/contracts.d.ts +1 -0
- package/cjs/contracts.js +2 -1
- package/cjs/helpers/chickenBondsHelpers/index.d.ts +2 -0
- package/cjs/helpers/chickenBondsHelpers/index.js +19 -0
- package/cjs/helpers/index.d.ts +1 -0
- package/cjs/helpers/index.js +2 -1
- package/cjs/types/chickenBonds.d.ts +41 -0
- package/cjs/types/chickenBonds.js +13 -0
- package/cjs/types/contracts/generated/ChickenBondsManager.d.ts +28 -0
- package/cjs/types/contracts/generated/ChickenBondsManager.js +5 -0
- package/cjs/types/contracts/generated/ChickenBondsView.d.ts +68 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/esm/chickenBonds/index.d.ts +4 -0
- package/esm/chickenBonds/index.js +89 -2
- package/esm/config/contracts.d.ts +36 -2
- package/esm/config/contracts.js +7 -1
- package/esm/contracts.d.ts +1 -0
- package/esm/contracts.js +1 -0
- package/esm/helpers/chickenBondsHelpers/index.d.ts +2 -0
- package/esm/helpers/chickenBondsHelpers/index.js +11 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.js +1 -0
- package/esm/types/chickenBonds.d.ts +41 -0
- package/esm/types/chickenBonds.js +10 -0
- package/esm/types/contracts/generated/ChickenBondsManager.d.ts +28 -0
- package/esm/types/contracts/generated/ChickenBondsManager.js +4 -0
- package/esm/types/contracts/generated/ChickenBondsView.d.ts +68 -0
- package/esm/types/contracts/generated/index.d.ts +1 -0
- package/esm/types/index.d.ts +1 -0
- package/esm/types/index.js +1 -0
- package/package.json +1 -1
- package/src/chickenBonds/index.ts +103 -1
- package/src/config/contracts.js +8 -2
- package/src/contracts.ts +3 -1
- package/src/helpers/chickenBondsHelpers/index.ts +13 -0
- package/src/helpers/index.ts +2 -1
- package/src/types/chickenBonds.ts +45 -0
- package/src/types/contracts/generated/ChickenBondsManager.ts +59 -0
- package/src/types/contracts/generated/ChickenBondsView.ts +88 -0
- package/src/types/contracts/generated/index.ts +1 -0
- package/src/types/index.ts +2 -1
- package/yarn-error.log +0 -64
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { Blockish, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
+
import { BondInfoBasic, ChickenBondsSystemInfoBasic } from '../types';
|
|
3
4
|
export declare const getChickenBondsAccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, bondId: string) => Promise<PositionBalances>;
|
|
5
|
+
export declare const fetchCBondsSystemInfo: (web3: Web3, network: NetworkNumber) => Promise<ChickenBondsSystemInfoBasic>;
|
|
6
|
+
export declare const fetchCBondsForUser: (web3: Web3, network: NetworkNumber, address: string) => Promise<BondInfoBasic[]>;
|
|
7
|
+
export declare const fetchCBondForId: (web3: Web3, network: NetworkNumber, bondId: string) => Promise<BondInfoBasic>;
|
|
@@ -8,10 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getChickenBondsAccountBalances = void 0;
|
|
15
|
+
exports.fetchCBondForId = exports.fetchCBondsForUser = exports.fetchCBondsSystemInfo = exports.getChickenBondsAccountBalances = void 0;
|
|
16
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
13
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
14
18
|
const contracts_1 = require("../contracts");
|
|
19
|
+
const multicall_1 = require("../multicall");
|
|
20
|
+
const chickenBondsHelpers_1 = require("../helpers/chickenBondsHelpers");
|
|
15
21
|
const getChickenBondsAccountBalances = (web3, network, block, addressMapping, bondId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
22
|
const viewContract = (0, contracts_1.ChickenBondsViewContract)(web3, network, block);
|
|
17
23
|
const fullBondInfo = yield viewContract.methods.getBondFullInfo(bondId).call({}, block);
|
|
@@ -22,3 +28,90 @@ const getChickenBondsAccountBalances = (web3, network, block, addressMapping, bo
|
|
|
22
28
|
};
|
|
23
29
|
});
|
|
24
30
|
exports.getChickenBondsAccountBalances = getChickenBondsAccountBalances;
|
|
31
|
+
const fetchCBondsSystemInfo = (web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
|
+
const cBondsView = (0, contracts_1.ChickenBondsViewContract)(web3, network);
|
|
33
|
+
const cBondsManager = (0, contracts_1.ChickenBondsManagerContract)(web3, network);
|
|
34
|
+
const multicallData = [
|
|
35
|
+
{
|
|
36
|
+
target: cBondsView.options.address,
|
|
37
|
+
abiItem: cBondsView.options.jsonInterface.find(({ name }) => name === 'getSystemInfo'),
|
|
38
|
+
params: [],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
target: cBondsManager.options.address,
|
|
42
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'totalWeightedStartTimes'),
|
|
43
|
+
params: [],
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
target: cBondsManager.options.address,
|
|
47
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'getAcquiredLUSDInSP'),
|
|
48
|
+
params: [],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
target: cBondsManager.options.address,
|
|
52
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'getAcquiredLUSDInCurve'),
|
|
53
|
+
params: [],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
target: cBondsManager.options.address,
|
|
57
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'yTokensHeldByCBM'),
|
|
58
|
+
params: [],
|
|
59
|
+
},
|
|
60
|
+
];
|
|
61
|
+
const [{ 0: systemInfo }, { 0: totalWeightedStartTimes }, { 0: acquiredLUSDInSP }, { 0: acquiredLUSDInCurve }, { 0: yTokensHeldByCBM }] = yield (0, multicall_1.multicall)(multicallData, web3, network);
|
|
62
|
+
const payload = {
|
|
63
|
+
numPendingBonds: systemInfo.numPendingBonds,
|
|
64
|
+
numChickenInBonds: systemInfo.numChickenInBonds,
|
|
65
|
+
numChickenOutBonds: systemInfo.numChickenOutBonds,
|
|
66
|
+
accrualParameter: new decimal_js_1.default((0, tokens_1.assetAmountInEth)(systemInfo.accrualParameter)).mul(1000).toString(),
|
|
67
|
+
bLUSDSupply: (0, tokens_1.assetAmountInEth)(systemInfo.bLUSDSupply, 'bLUSD'),
|
|
68
|
+
chickenInAMMFee: (0, tokens_1.assetAmountInEth)(systemInfo.chickenInAMMFee),
|
|
69
|
+
ownedLUSDInCurve: (0, tokens_1.assetAmountInEth)(systemInfo.ownedLUSDInCurve, 'LUSD'),
|
|
70
|
+
systemBackingRatio: (0, tokens_1.assetAmountInEth)(systemInfo.systemBackingRatio),
|
|
71
|
+
ownedLUSDInSP: (0, tokens_1.assetAmountInEth)(systemInfo.ownedLUSDInSP, 'LUSD'),
|
|
72
|
+
totalPendingLUSD: (0, tokens_1.assetAmountInEth)(systemInfo.totalPendingLUSD, 'LUSD'),
|
|
73
|
+
totalPermanentLUSD: (0, tokens_1.assetAmountInEth)(systemInfo.totalPermanentLUSD, 'LUSD'),
|
|
74
|
+
totalReserveLUSD: (0, tokens_1.assetAmountInEth)(systemInfo.totalReserveLUSD, 'LUSD'),
|
|
75
|
+
targetAverageAgeMs: 1296000000,
|
|
76
|
+
totalWeightedStartTimes: (0, tokens_1.assetAmountInEth)(totalWeightedStartTimes),
|
|
77
|
+
acquiredLUSDInSP: (0, tokens_1.assetAmountInEth)(acquiredLUSDInSP, 'LUSD'),
|
|
78
|
+
acquiredLUSDInCurve: (0, tokens_1.assetAmountInEth)(acquiredLUSDInCurve, 'LUSD'),
|
|
79
|
+
yTokensHeldByCBM: (0, tokens_1.assetAmountInEth)(yTokensHeldByCBM, 'ETH'), // yTokens is 18 decimals
|
|
80
|
+
};
|
|
81
|
+
const floorPrice = (0, chickenBondsHelpers_1.calcCBondsBLUSDFloorPrice)(payload.bLUSDSupply, payload.totalReserveLUSD);
|
|
82
|
+
const averageBondAgeMs = (0, chickenBondsHelpers_1.calcAverageBondAgeMs)(payload.totalWeightedStartTimes, payload.totalPendingLUSD);
|
|
83
|
+
return Object.assign(Object.assign({}, payload), { floorPrice,
|
|
84
|
+
averageBondAgeMs });
|
|
85
|
+
});
|
|
86
|
+
exports.fetchCBondsSystemInfo = fetchCBondsSystemInfo;
|
|
87
|
+
const fetchCBondsForUser = (web3, network, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const cBondsView = (0, contracts_1.ChickenBondsViewContract)(web3, network);
|
|
89
|
+
const bonds = yield cBondsView.methods.getUsersBonds(address).call();
|
|
90
|
+
return bonds.map(({ bondID, accruedBLUSD, claimedBLUSD, endTime, lusdAmount, maxAmountBLUSD, startTime, status, tokenURI, }) => ({
|
|
91
|
+
bondId: bondID,
|
|
92
|
+
status,
|
|
93
|
+
// tokenURI: decodeTokenURIToSvg(tokenURI),
|
|
94
|
+
startTime: new Date(+startTime * 1000),
|
|
95
|
+
endTime: new Date(+endTime * 1000),
|
|
96
|
+
accruedBLUSD: (0, tokens_1.assetAmountInEth)(accruedBLUSD, 'bLUSD'),
|
|
97
|
+
claimedBLUSD: (0, tokens_1.assetAmountInEth)(claimedBLUSD, 'bLUSD'),
|
|
98
|
+
lusdAmount: (0, tokens_1.assetAmountInEth)(lusdAmount, 'LUSD'),
|
|
99
|
+
maxAmountBLUSD: (0, tokens_1.assetAmountInEth)(maxAmountBLUSD, 'bLUSD'),
|
|
100
|
+
}));
|
|
101
|
+
});
|
|
102
|
+
exports.fetchCBondsForUser = fetchCBondsForUser;
|
|
103
|
+
const fetchCBondForId = (web3, network, bondId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
104
|
+
const cBondsView = (0, contracts_1.ChickenBondsViewContract)(web3, network);
|
|
105
|
+
const bond = yield cBondsView.methods.getBondFullInfo(bondId).call();
|
|
106
|
+
return {
|
|
107
|
+
bondId,
|
|
108
|
+
status: bond.status,
|
|
109
|
+
startTime: new Date(+bond.startTime * 1000),
|
|
110
|
+
endTime: new Date(+bond.endTime * 1000),
|
|
111
|
+
accruedBLUSD: (0, tokens_1.assetAmountInEth)(bond.accruedBLUSD, 'bLUSD'),
|
|
112
|
+
claimedBLUSD: (0, tokens_1.assetAmountInEth)(bond.claimedBLUSD, 'bLUSD'),
|
|
113
|
+
lusdAmount: (0, tokens_1.assetAmountInEth)(bond.lusdAmount, 'LUSD'),
|
|
114
|
+
maxAmountBLUSD: (0, tokens_1.assetAmountInEth)(bond.maxAmountBLUSD, 'bLUSD'),
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
exports.fetchCBondForId = fetchCBondForId;
|
|
@@ -2997,7 +2997,17 @@ export namespace McdDog {
|
|
|
2997
2997
|
export { networks_55 as networks };
|
|
2998
2998
|
}
|
|
2999
2999
|
export namespace ChickenBondsView {
|
|
3000
|
-
let abi_56: {
|
|
3000
|
+
let abi_56: ({
|
|
3001
|
+
inputs: never[];
|
|
3002
|
+
name: string;
|
|
3003
|
+
outputs: {
|
|
3004
|
+
internalType: string;
|
|
3005
|
+
name: string;
|
|
3006
|
+
type: string;
|
|
3007
|
+
}[];
|
|
3008
|
+
stateMutability: string;
|
|
3009
|
+
type: string;
|
|
3010
|
+
} | {
|
|
3001
3011
|
inputs: {
|
|
3002
3012
|
internalType: string;
|
|
3003
3013
|
name: string;
|
|
@@ -3016,7 +3026,7 @@ export namespace ChickenBondsView {
|
|
|
3016
3026
|
}[];
|
|
3017
3027
|
stateMutability: string;
|
|
3018
3028
|
type: string;
|
|
3019
|
-
}[];
|
|
3029
|
+
})[];
|
|
3020
3030
|
export { abi_56 as abi };
|
|
3021
3031
|
let networks_56: {
|
|
3022
3032
|
"1": {
|
|
@@ -3026,3 +3036,27 @@ export namespace ChickenBondsView {
|
|
|
3026
3036
|
};
|
|
3027
3037
|
export { networks_56 as networks };
|
|
3028
3038
|
}
|
|
3039
|
+
export namespace ChickenBondsManager {
|
|
3040
|
+
let abi_57: {
|
|
3041
|
+
inputs: {
|
|
3042
|
+
internalType: string;
|
|
3043
|
+
name: string;
|
|
3044
|
+
type: string;
|
|
3045
|
+
}[];
|
|
3046
|
+
name: string;
|
|
3047
|
+
outputs: {
|
|
3048
|
+
internalType: string;
|
|
3049
|
+
name: string;
|
|
3050
|
+
type: string;
|
|
3051
|
+
}[];
|
|
3052
|
+
stateMutability: string;
|
|
3053
|
+
type: string;
|
|
3054
|
+
}[];
|
|
3055
|
+
export { abi_57 as abi };
|
|
3056
|
+
let networks_57: {
|
|
3057
|
+
"1": {
|
|
3058
|
+
address: string;
|
|
3059
|
+
};
|
|
3060
|
+
};
|
|
3061
|
+
export { networks_57 as networks };
|
|
3062
|
+
}
|
package/cjs/config/contracts.js
CHANGED
|
@@ -585,12 +585,18 @@ module.exports = {
|
|
|
585
585
|
}
|
|
586
586
|
},
|
|
587
587
|
"ChickenBondsView": {
|
|
588
|
-
"abi": [{ "inputs": [{ "internalType": "uint256", "name": "_bondID", "type": "uint256" }], "name": "getBondFullInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "bondID", "type": "uint256" }, { "internalType": "uint256", "name": "lusdAmount", "type": "uint256" }, { "internalType": "uint64", "name": "claimedBLUSD", "type": "uint64" }, { "internalType": "uint256", "name": "accruedBLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "maxAmountBLUSD", "type": "uint256" }, { "internalType": "uint64", "name": "startTime", "type": "uint64" }, { "internalType": "uint64", "name": "endTime", "type": "uint64" }, { "internalType": "enum IChickenBondManager.BondStatus", "name": "status", "type": "uint8" }, { "internalType": "string", "name": "tokenURI", "type": "string" }], "internalType": "struct ChickenBondsView.BondDataFull", "name": "bond", "type": "tuple" }], "stateMutability": "view", "type": "function" }],
|
|
588
|
+
"abi": [{ "inputs": [], "name": "BorrowerOperations", "outputs": [{ "internalType": "contract IBorrowerOperations", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "CBManager", "outputs": [{ "internalType": "contract IChickenBondManager", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "CollSurplusPool", "outputs": [{ "internalType": "contract ICollSurplusPool", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "HintHelpers", "outputs": [{ "internalType": "contract IHintHelpers", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "LQTYStaking", "outputs": [{ "internalType": "contract ILQTYStaking", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "LUSD_GAS_COMPENSATION", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "PriceFeed", "outputs": [{ "internalType": "contract IPriceFeed", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "SortedTroves", "outputs": [{ "internalType": "contract ISortedTroves", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "StabilityPool", "outputs": [{ "internalType": "contract IStabilityPool", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "TroveManager", "outputs": [{ "internalType": "contract ITroveManager", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_bondID", "type": "uint256" }], "name": "getBondFullInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "bondID", "type": "uint256" }, { "internalType": "uint256", "name": "lusdAmount", "type": "uint256" }, { "internalType": "uint64", "name": "claimedBLUSD", "type": "uint64" }, { "internalType": "uint256", "name": "accruedBLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "maxAmountBLUSD", "type": "uint256" }, { "internalType": "uint64", "name": "startTime", "type": "uint64" }, { "internalType": "uint64", "name": "endTime", "type": "uint64" }, { "internalType": "enum IChickenBondManager.BondStatus", "name": "status", "type": "uint8" }, { "internalType": "string", "name": "tokenURI", "type": "string" }], "internalType": "struct ChickenBondsView.BondDataFull", "name": "bond", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getSystemInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "totalPendingLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "totalReserveLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "totalPermanentLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "ownedLUSDInSP", "type": "uint256" }, { "internalType": "uint256", "name": "ownedLUSDInCurve", "type": "uint256" }, { "internalType": "uint256", "name": "systemBackingRatio", "type": "uint256" }, { "internalType": "uint256", "name": "accrualParameter", "type": "uint256" }, { "internalType": "uint256", "name": "chickenInAMMFee", "type": "uint256" }, { "internalType": "uint256", "name": "numPendingBonds", "type": "uint256" }, { "internalType": "uint256", "name": "numChickenInBonds", "type": "uint256" }, { "internalType": "uint256", "name": "numChickenOutBonds", "type": "uint256" }, { "internalType": "uint256", "name": "bLUSDSupply", "type": "uint256" }], "internalType": "struct ChickenBondsView.ChickenBondsSystemInfo", "name": "systemInfo", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_userAddr", "type": "address" }], "name": "getUsersBonds", "outputs": [{ "components": [{ "internalType": "uint256", "name": "bondID", "type": "uint256" }, { "internalType": "uint256", "name": "lusdAmount", "type": "uint256" }, { "internalType": "uint64", "name": "claimedBLUSD", "type": "uint64" }, { "internalType": "uint256", "name": "accruedBLUSD", "type": "uint256" }, { "internalType": "uint256", "name": "maxAmountBLUSD", "type": "uint256" }, { "internalType": "uint64", "name": "startTime", "type": "uint64" }, { "internalType": "uint64", "name": "endTime", "type": "uint64" }, { "internalType": "enum IChickenBondManager.BondStatus", "name": "status", "type": "uint8" }, { "internalType": "string", "name": "tokenURI", "type": "string" }], "internalType": "struct ChickenBondsView.BondDataFull[]", "name": "bonds", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }],
|
|
589
589
|
"networks": {
|
|
590
590
|
"1": {
|
|
591
591
|
"address": "0x809a93fd4a0d7d7906Ef6176f0b5518b418Da08f",
|
|
592
592
|
"createdBlock": 15739450
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
+
},
|
|
596
|
+
"ChickenBondsManager": {
|
|
597
|
+
"abi": [{ "inputs": [{ "internalType": "uint256", "name": "_bondID", "type": "uint256" }], "name": "chickenIn", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_bondID", "type": "uint256" }, { "internalType": "uint256", "name": "_minLUSD", "type": "uint256" }], "name": "chickenOut", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_lusdAmount", "type": "uint256" }], "name": "createBond", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "getAcquiredLUSDInCurve", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getAcquiredLUSDInSP", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_bLUSDToRedeem", "type": "uint256" }, { "internalType": "uint256", "name": "_minLUSDFromBAMMSPVault", "type": "uint256" }], "name": "redeem", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "totalWeightedStartTimes", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "yTokensHeldByCBM", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
598
|
+
"networks": {
|
|
599
|
+
"1": { "address": "0x57619FE9C539f890b19c61812226F9703ce37137" }
|
|
600
|
+
}
|
|
595
601
|
}
|
|
596
602
|
};
|
package/cjs/contracts.d.ts
CHANGED
|
@@ -38,3 +38,4 @@ export declare const McdDogContract: (web3: Web3, network: NetworkNumber, block?
|
|
|
38
38
|
export declare const McdJugContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.McdJug;
|
|
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
|
+
export declare const ChickenBondsManagerContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.ChickenBondsManager;
|
package/cjs/contracts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ChickenBondsViewContract = exports.McdVatContract = exports.McdJugContract = exports.McdDogContract = exports.McdSpotterContract = exports.McdViewContract = exports.LiquityActivePoolContract = exports.LiquityPriceFeedContract = exports.LiquityTroveManagerContract = exports.LiquityCollSurplusPoolContract = exports.LiquityViewContract = exports.CrvUSDFactoryContract = exports.CrvUSDViewContract = exports.SparkViewContract = exports.SparkIncentiveDataProviderContract = exports.MorphoAaveV2ViewContract = exports.PotContract = exports.ComptrollerContract = exports.CompoundLoanInfoContract = exports.AaveLoanInfoV2Contract = exports.wstETHContract = exports.CompV3ViewContract = exports.BalanceScannerContract = exports.REthContract = exports.CbEthContract = exports.LidoContract = exports.GhoTokenContract = exports.AaveIncentiveDataProviderV3Contract = exports.AaveV3ViewContract = exports.UniMulticallContract = exports.createContractWrapper = exports.getErc20Contract = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
6
|
+
exports.ChickenBondsManagerContract = exports.ChickenBondsViewContract = exports.McdVatContract = exports.McdJugContract = exports.McdDogContract = exports.McdSpotterContract = exports.McdViewContract = exports.LiquityActivePoolContract = exports.LiquityPriceFeedContract = exports.LiquityTroveManagerContract = exports.LiquityCollSurplusPoolContract = exports.LiquityViewContract = exports.CrvUSDFactoryContract = exports.CrvUSDViewContract = exports.SparkViewContract = exports.SparkIncentiveDataProviderContract = exports.MorphoAaveV2ViewContract = exports.PotContract = exports.ComptrollerContract = exports.CompoundLoanInfoContract = exports.AaveLoanInfoV2Contract = exports.wstETHContract = exports.CompV3ViewContract = exports.BalanceScannerContract = exports.REthContract = exports.CbEthContract = exports.LidoContract = exports.GhoTokenContract = exports.AaveIncentiveDataProviderV3Contract = exports.AaveV3ViewContract = exports.UniMulticallContract = exports.createContractWrapper = exports.getErc20Contract = exports.getConfigContractAbi = exports.getConfigContractAddress = void 0;
|
|
7
7
|
const contracts_1 = __importDefault(require("./config/contracts"));
|
|
8
8
|
const contractConfig = contracts_1.default;
|
|
9
9
|
const getConfigContractAddress = (name, network, block) => {
|
|
@@ -63,3 +63,4 @@ exports.McdDogContract = createContractFromConfigFunc('McdDog');
|
|
|
63
63
|
exports.McdJugContract = createContractFromConfigFunc('McdJug');
|
|
64
64
|
exports.McdVatContract = createContractFromConfigFunc('McdVat');
|
|
65
65
|
exports.ChickenBondsViewContract = createContractFromConfigFunc('ChickenBondsView');
|
|
66
|
+
exports.ChickenBondsManagerContract = createContractFromConfigFunc('ChickenBondsManager');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.calcAverageBondAgeMs = exports.calcCBondsBLUSDFloorPrice = void 0;
|
|
7
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const calcCBondsBLUSDFloorPrice = (bLUSDSupply, totalReserveLUSD) => {
|
|
9
|
+
if (new decimal_js_1.default(bLUSDSupply).eq(0))
|
|
10
|
+
return '1';
|
|
11
|
+
return new decimal_js_1.default(totalReserveLUSD).div(bLUSDSupply).toString();
|
|
12
|
+
};
|
|
13
|
+
exports.calcCBondsBLUSDFloorPrice = calcCBondsBLUSDFloorPrice;
|
|
14
|
+
const calcAverageBondAgeMs = (totalWeightedStartTimes, totalPendingLusd) => {
|
|
15
|
+
const averageStartTimeMs = new decimal_js_1.default(totalWeightedStartTimes).div(totalPendingLusd).round().mul(1000)
|
|
16
|
+
.toNumber();
|
|
17
|
+
return Date.now() - averageStartTimeMs;
|
|
18
|
+
};
|
|
19
|
+
exports.calcAverageBondAgeMs = calcAverageBondAgeMs;
|
package/cjs/helpers/index.d.ts
CHANGED
package/cjs/helpers/index.js
CHANGED
|
@@ -23,9 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
26
|
+
exports.chickenBondsHelpers = exports.makerHelpers = exports.curveUsdHelpers = exports.sparkHelpers = exports.compoundHelpers = exports.aaveHelpers = void 0;
|
|
27
27
|
exports.aaveHelpers = __importStar(require("./aaveHelpers"));
|
|
28
28
|
exports.compoundHelpers = __importStar(require("./compoundHelpers"));
|
|
29
29
|
exports.sparkHelpers = __importStar(require("./sparkHelpers"));
|
|
30
30
|
exports.curveUsdHelpers = __importStar(require("./curveUsdHelpers"));
|
|
31
31
|
exports.makerHelpers = __importStar(require("./makerHelpers"));
|
|
32
|
+
exports.chickenBondsHelpers = __importStar(require("./chickenBondsHelpers"));
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type ChickenBondsSystemInfoStructOutputStruct = {
|
|
2
|
+
totalPendingLUSD: string;
|
|
3
|
+
totalReserveLUSD: string;
|
|
4
|
+
totalPermanentLUSD: string;
|
|
5
|
+
ownedLUSDInSP: string;
|
|
6
|
+
ownedLUSDInCurve: string;
|
|
7
|
+
systemBackingRatio: string;
|
|
8
|
+
accrualParameter: string;
|
|
9
|
+
chickenInAMMFee: string;
|
|
10
|
+
numPendingBonds: string;
|
|
11
|
+
numChickenInBonds: string;
|
|
12
|
+
numChickenOutBonds: string;
|
|
13
|
+
bLUSDSupply: string;
|
|
14
|
+
};
|
|
15
|
+
export interface ChickenBondsSystemInfoBasic extends ChickenBondsSystemInfoStructOutputStruct {
|
|
16
|
+
totalWeightedStartTimes: string;
|
|
17
|
+
targetAverageAgeMs: number;
|
|
18
|
+
acquiredLUSDInSP: string;
|
|
19
|
+
acquiredLUSDInCurve: string;
|
|
20
|
+
yTokensHeldByCBM: string;
|
|
21
|
+
floorPrice: string;
|
|
22
|
+
averageBondAgeMs: number;
|
|
23
|
+
}
|
|
24
|
+
export interface BondInfoBasic {
|
|
25
|
+
bondId: string;
|
|
26
|
+
status: string;
|
|
27
|
+
startTime: Date;
|
|
28
|
+
endTime: Date;
|
|
29
|
+
accruedBLUSD: string;
|
|
30
|
+
claimedBLUSD: string;
|
|
31
|
+
lusdAmount: string;
|
|
32
|
+
maxAmountBLUSD: string;
|
|
33
|
+
}
|
|
34
|
+
export declare enum BondStatus {
|
|
35
|
+
Nonexistent = "0",
|
|
36
|
+
Active = "1",
|
|
37
|
+
ChickenedOut = "2",
|
|
38
|
+
ChickenedIn = "3",
|
|
39
|
+
BrokeEven = "4",
|
|
40
|
+
Rebondable = "5"
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BondStatus = void 0;
|
|
4
|
+
var BondStatus;
|
|
5
|
+
(function (BondStatus) {
|
|
6
|
+
// Order [0, 3] is set on contract
|
|
7
|
+
BondStatus["Nonexistent"] = "0";
|
|
8
|
+
BondStatus["Active"] = "1";
|
|
9
|
+
BondStatus["ChickenedOut"] = "2";
|
|
10
|
+
BondStatus["ChickenedIn"] = "3";
|
|
11
|
+
BondStatus["BrokeEven"] = "4";
|
|
12
|
+
BondStatus["Rebondable"] = "5";
|
|
13
|
+
})(BondStatus || (exports.BondStatus = BondStatus = {}));
|
|
@@ -0,0 +1,28 @@
|
|
|
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, BaseContract } from "./types";
|
|
7
|
+
export interface EventOptions {
|
|
8
|
+
filter?: object;
|
|
9
|
+
fromBlock?: BlockType;
|
|
10
|
+
topics?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ChickenBondsManager extends BaseContract {
|
|
13
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): ChickenBondsManager;
|
|
14
|
+
clone(): ChickenBondsManager;
|
|
15
|
+
methods: {
|
|
16
|
+
chickenIn(_bondID: number | string | BN): NonPayableTransactionObject<void>;
|
|
17
|
+
chickenOut(_bondID: number | string | BN, _minLUSD: number | string | BN): NonPayableTransactionObject<void>;
|
|
18
|
+
createBond(_lusdAmount: number | string | BN): NonPayableTransactionObject<string>;
|
|
19
|
+
getAcquiredLUSDInCurve(): NonPayableTransactionObject<string>;
|
|
20
|
+
getAcquiredLUSDInSP(): NonPayableTransactionObject<string>;
|
|
21
|
+
redeem(_bLUSDToRedeem: number | string | BN, _minLUSDFromBAMMSPVault: number | string | BN): NonPayableTransactionObject<[string, string]>;
|
|
22
|
+
totalWeightedStartTimes(): NonPayableTransactionObject<string>;
|
|
23
|
+
yTokensHeldByCBM(): NonPayableTransactionObject<string>;
|
|
24
|
+
};
|
|
25
|
+
events: {
|
|
26
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -54,12 +54,80 @@ export declare namespace ChickenBondsView {
|
|
|
54
54
|
tokenURI: string;
|
|
55
55
|
};
|
|
56
56
|
type BondDataFullStructOutput = BondDataFullStructOutputArray & BondDataFullStructOutputStruct;
|
|
57
|
+
type ChickenBondsSystemInfoStruct = [
|
|
58
|
+
number | string | BN,
|
|
59
|
+
number | string | BN,
|
|
60
|
+
number | string | BN,
|
|
61
|
+
number | string | BN,
|
|
62
|
+
number | string | BN,
|
|
63
|
+
number | string | BN,
|
|
64
|
+
number | string | BN,
|
|
65
|
+
number | string | BN,
|
|
66
|
+
number | string | BN,
|
|
67
|
+
number | string | BN,
|
|
68
|
+
number | string | BN,
|
|
69
|
+
number | string | BN
|
|
70
|
+
] | {
|
|
71
|
+
totalPendingLUSD: number | string | BN;
|
|
72
|
+
totalReserveLUSD: number | string | BN;
|
|
73
|
+
totalPermanentLUSD: number | string | BN;
|
|
74
|
+
ownedLUSDInSP: number | string | BN;
|
|
75
|
+
ownedLUSDInCurve: number | string | BN;
|
|
76
|
+
systemBackingRatio: number | string | BN;
|
|
77
|
+
accrualParameter: number | string | BN;
|
|
78
|
+
chickenInAMMFee: number | string | BN;
|
|
79
|
+
numPendingBonds: number | string | BN;
|
|
80
|
+
numChickenInBonds: number | string | BN;
|
|
81
|
+
numChickenOutBonds: number | string | BN;
|
|
82
|
+
bLUSDSupply: number | string | BN;
|
|
83
|
+
};
|
|
84
|
+
type ChickenBondsSystemInfoStructOutputArray = [
|
|
85
|
+
string,
|
|
86
|
+
string,
|
|
87
|
+
string,
|
|
88
|
+
string,
|
|
89
|
+
string,
|
|
90
|
+
string,
|
|
91
|
+
string,
|
|
92
|
+
string,
|
|
93
|
+
string,
|
|
94
|
+
string,
|
|
95
|
+
string,
|
|
96
|
+
string
|
|
97
|
+
];
|
|
98
|
+
type ChickenBondsSystemInfoStructOutputStruct = {
|
|
99
|
+
totalPendingLUSD: string;
|
|
100
|
+
totalReserveLUSD: string;
|
|
101
|
+
totalPermanentLUSD: string;
|
|
102
|
+
ownedLUSDInSP: string;
|
|
103
|
+
ownedLUSDInCurve: string;
|
|
104
|
+
systemBackingRatio: string;
|
|
105
|
+
accrualParameter: string;
|
|
106
|
+
chickenInAMMFee: string;
|
|
107
|
+
numPendingBonds: string;
|
|
108
|
+
numChickenInBonds: string;
|
|
109
|
+
numChickenOutBonds: string;
|
|
110
|
+
bLUSDSupply: string;
|
|
111
|
+
};
|
|
112
|
+
type ChickenBondsSystemInfoStructOutput = ChickenBondsSystemInfoStructOutputArray & ChickenBondsSystemInfoStructOutputStruct;
|
|
57
113
|
}
|
|
58
114
|
export interface ChickenBondsView extends BaseContract {
|
|
59
115
|
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): ChickenBondsView;
|
|
60
116
|
clone(): ChickenBondsView;
|
|
61
117
|
methods: {
|
|
118
|
+
BorrowerOperations(): NonPayableTransactionObject<string>;
|
|
119
|
+
CBManager(): NonPayableTransactionObject<string>;
|
|
120
|
+
CollSurplusPool(): NonPayableTransactionObject<string>;
|
|
121
|
+
HintHelpers(): NonPayableTransactionObject<string>;
|
|
122
|
+
LQTYStaking(): NonPayableTransactionObject<string>;
|
|
123
|
+
LUSD_GAS_COMPENSATION(): NonPayableTransactionObject<string>;
|
|
124
|
+
PriceFeed(): NonPayableTransactionObject<string>;
|
|
125
|
+
SortedTroves(): NonPayableTransactionObject<string>;
|
|
126
|
+
StabilityPool(): NonPayableTransactionObject<string>;
|
|
127
|
+
TroveManager(): NonPayableTransactionObject<string>;
|
|
62
128
|
getBondFullInfo(_bondID: number | string | BN): NonPayableTransactionObject<ChickenBondsView.BondDataFullStructOutput>;
|
|
129
|
+
getSystemInfo(): NonPayableTransactionObject<ChickenBondsView.ChickenBondsSystemInfoStructOutput>;
|
|
130
|
+
getUsersBonds(_userAddr: string): NonPayableTransactionObject<ChickenBondsView.BondDataFullStructOutput[]>;
|
|
63
131
|
};
|
|
64
132
|
events: {
|
|
65
133
|
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
@@ -8,6 +8,7 @@ export type { AaveV3ProtocolDataProvider } from "./AaveV3ProtocolDataProvider";
|
|
|
8
8
|
export type { AaveV3View } from "./AaveV3View";
|
|
9
9
|
export type { BalanceScanner } from "./BalanceScanner";
|
|
10
10
|
export type { CbEth } from "./CbEth";
|
|
11
|
+
export type { ChickenBondsManager } from "./ChickenBondsManager";
|
|
11
12
|
export type { ChickenBondsView } from "./ChickenBondsView";
|
|
12
13
|
export type { CollSurplusPool } from "./CollSurplusPool";
|
|
13
14
|
export type { CompV3ETHBulker } from "./CompV3ETHBulker";
|
package/cjs/types/index.d.ts
CHANGED
package/cjs/types/index.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { Blockish, NetworkNumber, PositionBalances } from '../types/common';
|
|
3
|
+
import { BondInfoBasic, ChickenBondsSystemInfoBasic } from '../types';
|
|
3
4
|
export declare const getChickenBondsAccountBalances: (web3: Web3, network: NetworkNumber, block: Blockish, addressMapping: boolean, bondId: string) => Promise<PositionBalances>;
|
|
5
|
+
export declare const fetchCBondsSystemInfo: (web3: Web3, network: NetworkNumber) => Promise<ChickenBondsSystemInfoBasic>;
|
|
6
|
+
export declare const fetchCBondsForUser: (web3: Web3, network: NetworkNumber, address: string) => Promise<BondInfoBasic[]>;
|
|
7
|
+
export declare const fetchCBondForId: (web3: Web3, network: NetworkNumber, bondId: string) => Promise<BondInfoBasic>;
|
|
@@ -7,8 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
10
|
+
import Dec from 'decimal.js';
|
|
11
|
+
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
|
+
import { ChickenBondsManagerContract, ChickenBondsViewContract } from '../contracts';
|
|
13
|
+
import { multicall } from '../multicall';
|
|
14
|
+
import { calcAverageBondAgeMs, calcCBondsBLUSDFloorPrice } from '../helpers/chickenBondsHelpers';
|
|
12
15
|
export const getChickenBondsAccountBalances = (web3, network, block, addressMapping, bondId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
16
|
const viewContract = ChickenBondsViewContract(web3, network, block);
|
|
14
17
|
const fullBondInfo = yield viewContract.methods.getBondFullInfo(bondId).call({}, block);
|
|
@@ -18,3 +21,87 @@ export const getChickenBondsAccountBalances = (web3, network, block, addressMapp
|
|
|
18
21
|
},
|
|
19
22
|
};
|
|
20
23
|
});
|
|
24
|
+
export const fetchCBondsSystemInfo = (web3, network) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const cBondsView = ChickenBondsViewContract(web3, network);
|
|
26
|
+
const cBondsManager = ChickenBondsManagerContract(web3, network);
|
|
27
|
+
const multicallData = [
|
|
28
|
+
{
|
|
29
|
+
target: cBondsView.options.address,
|
|
30
|
+
abiItem: cBondsView.options.jsonInterface.find(({ name }) => name === 'getSystemInfo'),
|
|
31
|
+
params: [],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
target: cBondsManager.options.address,
|
|
35
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'totalWeightedStartTimes'),
|
|
36
|
+
params: [],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
target: cBondsManager.options.address,
|
|
40
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'getAcquiredLUSDInSP'),
|
|
41
|
+
params: [],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
target: cBondsManager.options.address,
|
|
45
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'getAcquiredLUSDInCurve'),
|
|
46
|
+
params: [],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
target: cBondsManager.options.address,
|
|
50
|
+
abiItem: cBondsManager.options.jsonInterface.find(({ name }) => name === 'yTokensHeldByCBM'),
|
|
51
|
+
params: [],
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
const [{ 0: systemInfo }, { 0: totalWeightedStartTimes }, { 0: acquiredLUSDInSP }, { 0: acquiredLUSDInCurve }, { 0: yTokensHeldByCBM }] = yield multicall(multicallData, web3, network);
|
|
55
|
+
const payload = {
|
|
56
|
+
numPendingBonds: systemInfo.numPendingBonds,
|
|
57
|
+
numChickenInBonds: systemInfo.numChickenInBonds,
|
|
58
|
+
numChickenOutBonds: systemInfo.numChickenOutBonds,
|
|
59
|
+
accrualParameter: new Dec(assetAmountInEth(systemInfo.accrualParameter)).mul(1000).toString(),
|
|
60
|
+
bLUSDSupply: assetAmountInEth(systemInfo.bLUSDSupply, 'bLUSD'),
|
|
61
|
+
chickenInAMMFee: assetAmountInEth(systemInfo.chickenInAMMFee),
|
|
62
|
+
ownedLUSDInCurve: assetAmountInEth(systemInfo.ownedLUSDInCurve, 'LUSD'),
|
|
63
|
+
systemBackingRatio: assetAmountInEth(systemInfo.systemBackingRatio),
|
|
64
|
+
ownedLUSDInSP: assetAmountInEth(systemInfo.ownedLUSDInSP, 'LUSD'),
|
|
65
|
+
totalPendingLUSD: assetAmountInEth(systemInfo.totalPendingLUSD, 'LUSD'),
|
|
66
|
+
totalPermanentLUSD: assetAmountInEth(systemInfo.totalPermanentLUSD, 'LUSD'),
|
|
67
|
+
totalReserveLUSD: assetAmountInEth(systemInfo.totalReserveLUSD, 'LUSD'),
|
|
68
|
+
targetAverageAgeMs: 1296000000,
|
|
69
|
+
totalWeightedStartTimes: assetAmountInEth(totalWeightedStartTimes),
|
|
70
|
+
acquiredLUSDInSP: assetAmountInEth(acquiredLUSDInSP, 'LUSD'),
|
|
71
|
+
acquiredLUSDInCurve: assetAmountInEth(acquiredLUSDInCurve, 'LUSD'),
|
|
72
|
+
yTokensHeldByCBM: assetAmountInEth(yTokensHeldByCBM, 'ETH'), // yTokens is 18 decimals
|
|
73
|
+
};
|
|
74
|
+
const floorPrice = calcCBondsBLUSDFloorPrice(payload.bLUSDSupply, payload.totalReserveLUSD);
|
|
75
|
+
const averageBondAgeMs = calcAverageBondAgeMs(payload.totalWeightedStartTimes, payload.totalPendingLUSD);
|
|
76
|
+
return Object.assign(Object.assign({}, payload), { floorPrice,
|
|
77
|
+
averageBondAgeMs });
|
|
78
|
+
});
|
|
79
|
+
export const fetchCBondsForUser = (web3, network, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const cBondsView = ChickenBondsViewContract(web3, network);
|
|
81
|
+
const bonds = yield cBondsView.methods.getUsersBonds(address).call();
|
|
82
|
+
return bonds.map(({ bondID, accruedBLUSD, claimedBLUSD, endTime, lusdAmount, maxAmountBLUSD, startTime, status, tokenURI, }) => ({
|
|
83
|
+
bondId: bondID,
|
|
84
|
+
status,
|
|
85
|
+
// tokenURI: decodeTokenURIToSvg(tokenURI),
|
|
86
|
+
startTime: new Date(+startTime * 1000),
|
|
87
|
+
endTime: new Date(+endTime * 1000),
|
|
88
|
+
accruedBLUSD: assetAmountInEth(accruedBLUSD, 'bLUSD'),
|
|
89
|
+
claimedBLUSD: assetAmountInEth(claimedBLUSD, 'bLUSD'),
|
|
90
|
+
lusdAmount: assetAmountInEth(lusdAmount, 'LUSD'),
|
|
91
|
+
maxAmountBLUSD: assetAmountInEth(maxAmountBLUSD, 'bLUSD'),
|
|
92
|
+
}));
|
|
93
|
+
});
|
|
94
|
+
export const fetchCBondForId = (web3, network, bondId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
|
+
const cBondsView = ChickenBondsViewContract(web3, network);
|
|
96
|
+
const bond = yield cBondsView.methods.getBondFullInfo(bondId).call();
|
|
97
|
+
return {
|
|
98
|
+
bondId,
|
|
99
|
+
status: bond.status,
|
|
100
|
+
startTime: new Date(+bond.startTime * 1000),
|
|
101
|
+
endTime: new Date(+bond.endTime * 1000),
|
|
102
|
+
accruedBLUSD: assetAmountInEth(bond.accruedBLUSD, 'bLUSD'),
|
|
103
|
+
claimedBLUSD: assetAmountInEth(bond.claimedBLUSD, 'bLUSD'),
|
|
104
|
+
lusdAmount: assetAmountInEth(bond.lusdAmount, 'LUSD'),
|
|
105
|
+
maxAmountBLUSD: assetAmountInEth(bond.maxAmountBLUSD, 'bLUSD'),
|
|
106
|
+
};
|
|
107
|
+
});
|
|
@@ -2997,7 +2997,17 @@ export namespace McdDog {
|
|
|
2997
2997
|
export { networks_55 as networks };
|
|
2998
2998
|
}
|
|
2999
2999
|
export namespace ChickenBondsView {
|
|
3000
|
-
let abi_56: {
|
|
3000
|
+
let abi_56: ({
|
|
3001
|
+
inputs: never[];
|
|
3002
|
+
name: string;
|
|
3003
|
+
outputs: {
|
|
3004
|
+
internalType: string;
|
|
3005
|
+
name: string;
|
|
3006
|
+
type: string;
|
|
3007
|
+
}[];
|
|
3008
|
+
stateMutability: string;
|
|
3009
|
+
type: string;
|
|
3010
|
+
} | {
|
|
3001
3011
|
inputs: {
|
|
3002
3012
|
internalType: string;
|
|
3003
3013
|
name: string;
|
|
@@ -3016,7 +3026,7 @@ export namespace ChickenBondsView {
|
|
|
3016
3026
|
}[];
|
|
3017
3027
|
stateMutability: string;
|
|
3018
3028
|
type: string;
|
|
3019
|
-
}[];
|
|
3029
|
+
})[];
|
|
3020
3030
|
export { abi_56 as abi };
|
|
3021
3031
|
let networks_56: {
|
|
3022
3032
|
"1": {
|
|
@@ -3026,3 +3036,27 @@ export namespace ChickenBondsView {
|
|
|
3026
3036
|
};
|
|
3027
3037
|
export { networks_56 as networks };
|
|
3028
3038
|
}
|
|
3039
|
+
export namespace ChickenBondsManager {
|
|
3040
|
+
let abi_57: {
|
|
3041
|
+
inputs: {
|
|
3042
|
+
internalType: string;
|
|
3043
|
+
name: string;
|
|
3044
|
+
type: string;
|
|
3045
|
+
}[];
|
|
3046
|
+
name: string;
|
|
3047
|
+
outputs: {
|
|
3048
|
+
internalType: string;
|
|
3049
|
+
name: string;
|
|
3050
|
+
type: string;
|
|
3051
|
+
}[];
|
|
3052
|
+
stateMutability: string;
|
|
3053
|
+
type: string;
|
|
3054
|
+
}[];
|
|
3055
|
+
export { abi_57 as abi };
|
|
3056
|
+
let networks_57: {
|
|
3057
|
+
"1": {
|
|
3058
|
+
address: string;
|
|
3059
|
+
};
|
|
3060
|
+
};
|
|
3061
|
+
export { networks_57 as networks };
|
|
3062
|
+
}
|