@ape.swap/bonds-sdk 1.0.358 → 1.0.361
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/dist/components/BondModal/BondModal.js +17 -64
- package/dist/components/BondModal/helper.d.ts +9 -0
- package/dist/components/BondModal/helper.js +53 -0
- package/dist/components/YourBonds/YourBonds.js +6 -45
- package/dist/components/YourBondsModal/YourBondsModal.js +56 -44
- package/dist/scss/YourBondsModal.scss +7 -6
- package/package.json +1 -1
- package/dist/enum/abis.d.ts +0 -80
- package/dist/enum/abis.js +0 -1
- package/dist/state/bills/cleanBillsData.d.ts +0 -5
- package/dist/state/bills/cleanBillsData.js +0 -41
- package/dist/state/bills/fetchBills.d.ts +0 -4
- package/dist/state/bills/fetchBills.js +0 -61
- package/dist/state/bills/fetchBillsCalls.d.ts +0 -4
- package/dist/state/bills/fetchBillsCalls.js +0 -27
- package/dist/state/bills/fetchBillsUser.d.ts +0 -15
- package/dist/state/bills/fetchBillsUser.js +0 -171
- package/dist/state/bills/getBillNftData.d.ts +0 -9
- package/dist/state/bills/getBillNftData.js +0 -109
- package/dist/state/bills/hooks.d.ts +0 -4
- package/dist/state/bills/hooks.js +0 -142
- package/dist/state/bills/index.d.ts +0 -48
- package/dist/state/bills/index.js +0 -293
- package/dist/state/bills/types.d.ts +0 -168
- package/dist/state/bills/types.js +0 -1
package/dist/enum/abis.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export declare const BondAbi: ({
|
|
2
|
-
anonymous: boolean;
|
|
3
|
-
inputs: ({
|
|
4
|
-
components: {
|
|
5
|
-
internalType: string;
|
|
6
|
-
name: string;
|
|
7
|
-
type: string;
|
|
8
|
-
}[];
|
|
9
|
-
indexed: boolean;
|
|
10
|
-
internalType: string;
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
} | {
|
|
14
|
-
indexed: boolean;
|
|
15
|
-
internalType: string;
|
|
16
|
-
name: string;
|
|
17
|
-
type: string;
|
|
18
|
-
components?: undefined;
|
|
19
|
-
})[];
|
|
20
|
-
name: string;
|
|
21
|
-
type: string;
|
|
22
|
-
outputs?: undefined;
|
|
23
|
-
stateMutability?: undefined;
|
|
24
|
-
} | {
|
|
25
|
-
inputs: {
|
|
26
|
-
internalType: string;
|
|
27
|
-
name: string;
|
|
28
|
-
type: string;
|
|
29
|
-
}[];
|
|
30
|
-
name: string;
|
|
31
|
-
outputs: {
|
|
32
|
-
internalType: string;
|
|
33
|
-
name: string;
|
|
34
|
-
type: string;
|
|
35
|
-
}[];
|
|
36
|
-
stateMutability: string;
|
|
37
|
-
type: string;
|
|
38
|
-
anonymous?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
inputs: {
|
|
41
|
-
internalType: string;
|
|
42
|
-
name: string;
|
|
43
|
-
type: string;
|
|
44
|
-
}[];
|
|
45
|
-
name: string;
|
|
46
|
-
outputs: {
|
|
47
|
-
components: {
|
|
48
|
-
internalType: string;
|
|
49
|
-
name: string;
|
|
50
|
-
type: string;
|
|
51
|
-
}[];
|
|
52
|
-
internalType: string;
|
|
53
|
-
name: string;
|
|
54
|
-
type: string;
|
|
55
|
-
}[];
|
|
56
|
-
stateMutability: string;
|
|
57
|
-
type: string;
|
|
58
|
-
anonymous?: undefined;
|
|
59
|
-
} | {
|
|
60
|
-
inputs: ({
|
|
61
|
-
internalType: string;
|
|
62
|
-
name: string;
|
|
63
|
-
type: string;
|
|
64
|
-
components?: undefined;
|
|
65
|
-
} | {
|
|
66
|
-
components: {
|
|
67
|
-
internalType: string;
|
|
68
|
-
name: string;
|
|
69
|
-
type: string;
|
|
70
|
-
}[];
|
|
71
|
-
internalType: string;
|
|
72
|
-
name: string;
|
|
73
|
-
type: string;
|
|
74
|
-
})[];
|
|
75
|
-
name: string;
|
|
76
|
-
outputs: never[];
|
|
77
|
-
stateMutability: string;
|
|
78
|
-
type: string;
|
|
79
|
-
anonymous?: undefined;
|
|
80
|
-
})[];
|
package/dist/enum/abis.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var BondAbi = [{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }, { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "payout", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "remaining", "type": "uint256" }], "name": "BillClaimed", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "deposit", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "payout", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "expires", "type": "uint256" }, { "indexed": true, "internalType": "uint256", "name": "billId", "type": "uint256" }], "name": "BillCreated", "type": "event" }, { "anonymous": false, "inputs": [{ "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "indexed": false, "internalType": "struct ICustomBill.BillTerms", "name": "billTerms", "type": "tuple" }, { "indexed": false, "internalType": "uint256", "name": "lastDecay", "type": "uint256" }], "name": "BillInitialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "internalPrice", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "debtRatio", "type": "uint256" }], "name": "BillPriceChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "payoutToken", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amountAdded", "type": "uint256" }], "name": "BillRefilled", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "initialBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "newBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "adjustment", "type": "uint256" }], "name": "ControlVariableAdjustment", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "newFeeTo", "type": "address" }], "name": "FeeToChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], "name": "Initialized", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "newMaxTotalPayout", "type": "uint256" }], "name": "MaxTotalPayoutChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" }], "name": "RoleAdminChanged", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleGranted", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], "name": "RoleRevoked", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "currentBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "increment", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "targetBCV", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "buffer", "type": "uint256" }], "name": "SetAdjustment", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "indexed": false, "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }], "name": "SetFees", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "pendingOwner", "type": "address" }], "name": "SetPendingOwner", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "enum CustomBill.PARAMETER", "name": "parameter", "type": "uint8" }, { "indexed": false, "internalType": "uint256", "name": "input", "type": "uint256" }], "name": "TermsSet", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "approvedAccount", "type": "address" }, { "indexed": false, "internalType": "bool", "name": "approved", "type": "bool" }], "name": "UpdateClaimApproval", "type": "event" }, { "inputs": [], "name": "DAO", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "DEFAULT_ADMIN_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "MAX_FEE", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "REFILL_ROLE", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "adjustment", "outputs": [{ "internalType": "uint256", "name": "rate", "type": "uint256" }, { "internalType": "uint256", "name": "target", "type": "uint256" }, { "internalType": "uint256", "name": "buffer", "type": "uint256" }, { "internalType": "uint256", "name": "lastAdjustmentTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "allIssuedBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_billIds", "type": "uint256[]" }], "name": "batchClaim", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_billIds", "type": "uint256[]" }], "name": "batchRedeem", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "billInfo", "outputs": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }, { "internalType": "uint256", "name": "payoutClaimed", "type": "uint256" }, { "internalType": "uint256", "name": "vesting", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "vestingStartTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "lastClaimTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "truePricePaid", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "billNft", "outputs": [{ "internalType": "contract IBillNft", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "billPrice", "outputs": [{ "internalType": "uint256", "name": "price_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_feeTo", "type": "address" }], "name": "changeFeeTo", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "claim", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "claimablePayout", "outputs": [{ "internalType": "uint256", "name": "claimablePayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "currentDebt", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "currentFee", "outputs": [{ "internalType": "uint256", "name": "currentFee_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "customTreasury", "outputs": [{ "internalType": "contract ICustomTreasury", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "debtDecay", "outputs": [{ "internalType": "uint256", "name": "decay_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "debtRatio", "outputs": [{ "internalType": "uint256", "name": "debtRatio_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_amount", "type": "uint256" }, { "internalType": "uint256", "name": "_maxPrice", "type": "uint256" }, { "internalType": "address", "name": "_depositor", "type": "address" }], "name": "deposit", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "feeInPayout", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "feeTiers", "outputs": [{ "internalType": "uint256", "name": "tierCeilings", "type": "uint256" }, { "internalType": "uint256", "name": "fees", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "feeTo", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], "name": "getBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }, { "internalType": "uint256", "name": "start", "type": "uint256" }, { "internalType": "uint256", "name": "end", "type": "uint256" }], "name": "getBillIdsInRange", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "billId", "type": "uint256" }], "name": "getBillInfo", "outputs": [{ "components": [{ "internalType": "uint256", "name": "payout", "type": "uint256" }, { "internalType": "uint256", "name": "payoutClaimed", "type": "uint256" }, { "internalType": "uint256", "name": "vesting", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "vestingStartTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "lastClaimTimestamp", "type": "uint256" }, { "internalType": "uint256", "name": "truePricePaid", "type": "uint256" }], "internalType": "struct ICustomBill.Bill", "name": "", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getFeeTierLength", "outputs": [{ "internalType": "uint256", "name": "tierLength_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "getMaxTotalPayout", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleAdmin", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "uint256", "name": "index", "type": "uint256" }], "name": "getRoleMember", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], "name": "getRoleMemberCount", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "grantRefillRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "grantRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "hasRole", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "contract ICustomTreasury", "name": "_customTreasury", "type": "address" }, { "components": [{ "internalType": "address", "name": "payoutToken", "type": "address" }, { "internalType": "address", "name": "principalToken", "type": "address" }, { "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "contract IVestingCurve", "name": "vestingCurve", "type": "address" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "bool", "name": "feeInPayout", "type": "bool" }], "internalType": "struct ICustomBill.BillCreationDetails", "name": "_billCreationDetails", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "internalType": "struct ICustomBill.BillTerms", "name": "_billTerms", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "feeTo", "type": "address" }, { "internalType": "address", "name": "DAO", "type": "address" }, { "internalType": "address", "name": "billNft", "type": "address" }], "internalType": "struct ICustomBill.BillAccounts", "name": "_billAccounts", "type": "tuple" }, { "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "contract ICustomTreasury", "name": "_customTreasury", "type": "address" }, { "components": [{ "internalType": "address", "name": "payoutToken", "type": "address" }, { "internalType": "address", "name": "principalToken", "type": "address" }, { "internalType": "address", "name": "initialOwner", "type": "address" }, { "internalType": "contract IVestingCurve", "name": "vestingCurve", "type": "address" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "bool", "name": "feeInPayout", "type": "bool" }], "internalType": "struct ICustomBill.BillCreationDetails", "name": "_billCreationDetails", "type": "tuple" }, { "components": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "internalType": "struct ICustomBill.BillTerms", "name": "_billTerms", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "feeTo", "type": "address" }, { "internalType": "address", "name": "DAO", "type": "address" }, { "internalType": "address", "name": "billNft", "type": "address" }], "internalType": "struct ICustomBill.BillAccounts", "name": "_billAccounts", "type": "tuple" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "lastDecay", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "maxPayout", "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": "uint256", "name": "_amount", "type": "uint256" }], "name": "payoutFor", "outputs": [{ "internalType": "uint256", "name": "_payout", "type": "uint256" }, { "internalType": "uint256", "name": "_fee", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "payoutToken", "outputs": [{ "internalType": "contract IERC20MetadataUpgradeable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "pendingOwner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "pendingPayout", "outputs": [{ "internalType": "uint256", "name": "pendingPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "pendingVesting", "outputs": [{ "internalType": "uint256", "name": "pendingVesting_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "principalToken", "outputs": [{ "internalType": "contract IERC20MetadataUpgradeable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "redeem", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }], "name": "redeemerApproved", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_refillAmount", "type": "uint256" }], "name": "refillPayoutToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "renounceRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "_billRefillers", "type": "address[]" }], "name": "revokeRefillRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }, { "internalType": "address", "name": "account", "type": "address" }], "name": "revokeRole", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_rate", "type": "uint256" }, { "internalType": "uint256", "name": "_target", "type": "uint256" }, { "internalType": "uint256", "name": "_buffer", "type": "uint256" }], "name": "setAdjustment", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "enum CustomBill.PARAMETER", "name": "_parameter", "type": "uint8" }, { "internalType": "uint256", "name": "_input", "type": "uint256" }], "name": "setBillTerms", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "approvedAccount", "type": "address" }, { "internalType": "bool", "name": "approved", "type": "bool" }], "name": "setClaimApproval", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "fees", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "tierCeilings", "type": "uint256[]" }], "name": "setFeeTiers", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_maxTotalPayout", "type": "uint256" }], "name": "setMaxTotalPayout", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newPendingOwner", "type": "address" }], "name": "setPendingOwner", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], "name": "supportsInterface", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "terms", "outputs": [{ "internalType": "uint256", "name": "controlVariable", "type": "uint256" }, { "internalType": "uint256", "name": "vestingTerm", "type": "uint256" }, { "internalType": "uint256", "name": "minimumPrice", "type": "uint256" }, { "internalType": "uint256", "name": "maxPayout", "type": "uint256" }, { "internalType": "uint256", "name": "maxDebt", "type": "uint256" }, { "internalType": "uint256", "name": "maxTotalPayout", "type": "uint256" }, { "internalType": "uint256", "name": "initialDebt", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalDebt", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalPayoutGiven", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalPrincipalBilled", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "transferOwnership", "outputs": [], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "trueBillPrice", "outputs": [{ "internalType": "uint256", "name": "price_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "userBillIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }, { "internalType": "uint256", "name": "_timestamp", "type": "uint256" }], "name": "vestedPayoutAtTime", "outputs": [{ "internalType": "uint256", "name": "vestedPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "vestingCurve", "outputs": [{ "internalType": "contract IVestingCurve", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "vestingPayout", "outputs": [{ "internalType": "uint256", "name": "vestingPayout_", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_billId", "type": "uint256" }], "name": "vestingPeriod", "outputs": [{ "internalType": "uint256", "name": "vestingStart_", "type": "uint256" }, { "internalType": "uint256", "name": "vestingEnd_", "type": "uint256" }], "stateMutability": "view", "type": "function" }];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../../enum/apeswaplists';
|
|
2
|
-
import { CleanedBondsState } from '../../types/bonds';
|
|
3
|
-
import { TokenPrices } from '../tokenPrices/useTokenPricesNew';
|
|
4
|
-
declare const cleanBillsData: (billIds: number[], chunkedBills: any[], tokenPrices: TokenPrices[], chainId: ChainId, bills: CleanedBondsState[]) => CleanedBondsState[];
|
|
5
|
-
export default cleanBillsData;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { getBalanceNumber } from '../../utils/getBalanceNumber';
|
|
13
|
-
import BigNumber from 'bignumber.js';
|
|
14
|
-
var cleanBillsData = function (billIds, chunkedBills, tokenPrices, chainId, bills) {
|
|
15
|
-
var data = chunkedBills === null || chunkedBills === void 0 ? void 0 : chunkedBills.map(function (chunk, index) {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
-
var billFromState = bills === null || bills === void 0 ? void 0 : bills.find(function (bill) { return (bill === null || bill === void 0 ? void 0 : bill.index) === billIds[index]; });
|
|
18
|
-
var lpPrice = (_a = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find(function (tokenPrice) {
|
|
19
|
-
var _a;
|
|
20
|
-
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (billFromState === null || billFromState === void 0 ? void 0 : billFromState.principalToken.toLowerCase()) &&
|
|
21
|
-
tokenPrice.chainId === chainId;
|
|
22
|
-
})) === null || _a === void 0 ? void 0 : _a.price;
|
|
23
|
-
var earnTokenPrice = (_b = tokenPrices === null || tokenPrices === void 0 ? void 0 : tokenPrices.find(function (tokenPrice) {
|
|
24
|
-
var _a;
|
|
25
|
-
return ((_a = tokenPrice.address) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === (billFromState === null || billFromState === void 0 ? void 0 : billFromState.payoutToken.toLowerCase()) &&
|
|
26
|
-
tokenPrice.chainId === chainId;
|
|
27
|
-
})) === null || _b === void 0 ? void 0 : _b.price;
|
|
28
|
-
var trueBillPrice = chunk[0], totalPayoutGiven = chunk[1], terms = chunk[2], maxTotalPayout = chunk[3];
|
|
29
|
-
var vestingTerm = terms[1], maxPayout = terms[3];
|
|
30
|
-
var priceUsd = lpPrice && trueBillPrice && getBalanceNumber(trueBillPrice === null || trueBillPrice === void 0 ? void 0 : trueBillPrice.toString()) * lpPrice;
|
|
31
|
-
var discount = earnTokenPrice && priceUsd && ((earnTokenPrice - priceUsd) / earnTokenPrice) * 100;
|
|
32
|
-
var tokensRemaining = new BigNumber(maxTotalPayout !== null && maxTotalPayout !== void 0 ? maxTotalPayout : '0')
|
|
33
|
-
.minus(new BigNumber(totalPayoutGiven))
|
|
34
|
-
.div(new BigNumber(10).pow((_c = billFromState === null || billFromState === void 0 ? void 0 : billFromState.payoutTokenDecimals) !== null && _c !== void 0 ? _c : 18))
|
|
35
|
-
.toString();
|
|
36
|
-
var cleanedData = __assign(__assign({}, billFromState), { discount: discount, principalTokenPrice: lpPrice === null || lpPrice === void 0 ? void 0 : lpPrice.toString(), payoutTokenPrice: earnTokenPrice === null || earnTokenPrice === void 0 ? void 0 : earnTokenPrice.toString(), tokensRemaining: tokensRemaining, maxTotalPayout: maxTotalPayout === null || maxTotalPayout === void 0 ? void 0 : maxTotalPayout.toString(), trueBillPrice: trueBillPrice === null || trueBillPrice === void 0 ? void 0 : trueBillPrice.toString(), maxPayout: maxPayout === null || maxPayout === void 0 ? void 0 : maxPayout.toString(), totalPayoutGiven: totalPayoutGiven === null || totalPayoutGiven === void 0 ? void 0 : totalPayoutGiven.toString(), vestingTerm: vestingTerm.toNumber() });
|
|
37
|
-
return cleanedData;
|
|
38
|
-
});
|
|
39
|
-
return data;
|
|
40
|
-
};
|
|
41
|
-
export default cleanBillsData;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { TokenPrices } from '../tokenPrices/useTokenPricesNew';
|
|
2
|
-
import { CleanedBondsState } from '../../types/bonds';
|
|
3
|
-
declare const fetchBills: (chainId: number, tokenPrices: TokenPrices[], bills: CleanedBondsState[]) => Promise<CleanedBondsState[]>;
|
|
4
|
-
export default fetchBills;
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import billsABI from '../../config/abi/bond.json';
|
|
38
|
-
import { chunk } from 'lodash';
|
|
39
|
-
import fetchBillsCalls from './fetchBillsCalls';
|
|
40
|
-
import cleanBillsData from './cleanBillsData';
|
|
41
|
-
import multicall from '../../utils/multicall';
|
|
42
|
-
var fetchBills = function (chainId, tokenPrices, bills) { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var billIds, billCalls, vals, chunkSize, chunkedBills;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
billIds = [];
|
|
48
|
-
billCalls = bills.flatMap(function (bill) {
|
|
49
|
-
billIds.push(bill.index);
|
|
50
|
-
return fetchBillsCalls(bill);
|
|
51
|
-
});
|
|
52
|
-
return [4 /*yield*/, multicall(chainId, billsABI, billCalls)];
|
|
53
|
-
case 1:
|
|
54
|
-
vals = _a.sent();
|
|
55
|
-
chunkSize = (vals === null || vals === void 0 ? void 0 : vals.length) / (bills === null || bills === void 0 ? void 0 : bills.length);
|
|
56
|
-
chunkedBills = chunk(vals, chunkSize);
|
|
57
|
-
return [2 /*return*/, cleanBillsData(billIds, chunkedBills, tokenPrices, chainId, bills)];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}); };
|
|
61
|
-
export default fetchBills;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { BillVersion } from '../../enum/apeswaplists';
|
|
2
|
-
var fetchBillsCalls = function (bill) {
|
|
3
|
-
var standardCalls = [
|
|
4
|
-
// Get bill price with LP fees
|
|
5
|
-
{
|
|
6
|
-
address: bill.contractAddress,
|
|
7
|
-
name: 'trueBillPrice',
|
|
8
|
-
},
|
|
9
|
-
// Get bill debt ratio
|
|
10
|
-
{
|
|
11
|
-
address: bill.contractAddress,
|
|
12
|
-
name: 'totalPayoutGiven',
|
|
13
|
-
},
|
|
14
|
-
// Terms
|
|
15
|
-
// (1) controlVariable (2) vestingTerm (3) minimumPrice (4) maxPayout (5) maxDebt
|
|
16
|
-
{
|
|
17
|
-
address: bill.contractAddress,
|
|
18
|
-
name: 'terms',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
address: bill.contractAddress,
|
|
22
|
-
name: bill.billVersion !== BillVersion.V1 ? 'getMaxTotalPayout' : 'maxTotalPayout',
|
|
23
|
-
},
|
|
24
|
-
];
|
|
25
|
-
return standardCalls;
|
|
26
|
-
};
|
|
27
|
-
export default fetchBillsCalls;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Bills, CleanedBondsState, UserBill } from '../../types/bonds';
|
|
2
|
-
import { ChainId } from '../../enum/apeswaplists';
|
|
3
|
-
/**
|
|
4
|
-
* Fetches user-owned bill NFT data for a given set of owned bills data, chain ID, and bills.
|
|
5
|
-
* @param ownedBillsData An array of objects containing the ID, bill NFT address, and contract address of the owned bills.
|
|
6
|
-
* @param chainId The ID of the blockchain network.
|
|
7
|
-
* @param bills An array of objects containing the contract address and user-owned bill NFT data.
|
|
8
|
-
* @returns An array of objects containing the ID and data of the user-owned bill NFTs.
|
|
9
|
-
*/
|
|
10
|
-
export declare const fetchUserOwnedBillNftData: (ownedBillsData: {
|
|
11
|
-
id: string;
|
|
12
|
-
billNftAddress: string;
|
|
13
|
-
contractAddress: string;
|
|
14
|
-
}[], chainId: ChainId, bills: (CleanedBondsState | Bills)[]) => Promise<any[]>;
|
|
15
|
-
export declare const fetchUserOwnedBills: (chainId: ChainId, account: string, bills: CleanedBondsState[]) => Promise<UserBill[]>;
|
|
@@ -1,171 +0,0 @@
|
|
|
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import billAbi from '../../config/abi/bond.json';
|
|
38
|
-
import BigNumber from 'bignumber.js';
|
|
39
|
-
import { getBillNftBatchData } from './getBillNftData';
|
|
40
|
-
import multicall from '../../utils/multicall';
|
|
41
|
-
import { BillVersion } from '../../enum/apeswaplists';
|
|
42
|
-
/**
|
|
43
|
-
* Fetches user-owned bill NFT data for a given set of owned bills data, chain ID, and bills.
|
|
44
|
-
* @param ownedBillsData An array of objects containing the ID, bill NFT address, and contract address of the owned bills.
|
|
45
|
-
* @param chainId The ID of the blockchain network.
|
|
46
|
-
* @param bills An array of objects containing the contract address and user-owned bill NFT data.
|
|
47
|
-
* @returns An array of objects containing the ID and data of the user-owned bill NFTs.
|
|
48
|
-
*/
|
|
49
|
-
export var fetchUserOwnedBillNftData = function (ownedBillsData, chainId, bills) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
-
var billsToFetch, billsFetched, groupedBillsToFetch, groupedBillsToFetchArray, billNftData, billNftDataFlat, result;
|
|
51
|
-
return __generator(this, function (_a) {
|
|
52
|
-
switch (_a.label) {
|
|
53
|
-
case 0:
|
|
54
|
-
billsToFetch = [];
|
|
55
|
-
billsFetched = [];
|
|
56
|
-
// Loop through each owned bill and check if it exists in the bills array
|
|
57
|
-
ownedBillsData === null || ownedBillsData === void 0 ? void 0 : ownedBillsData.forEach(function (_a) {
|
|
58
|
-
var _b, _c;
|
|
59
|
-
var id = _a.id, billNftAddress = _a.billNftAddress, contractAddress = _a.contractAddress;
|
|
60
|
-
var bill = (_c = (_b = bills
|
|
61
|
-
.find(function (b) { return b.contractAddress[chainId] === contractAddress; })) === null || _b === void 0 ? void 0 : _b.userOwnedBillsNftData) === null || _c === void 0 ? void 0 : _c.find(function (u) { return +u.tokenId === +id; });
|
|
62
|
-
// If the bill exists in the bills array, add it to the billsFetched array
|
|
63
|
-
if (bill) {
|
|
64
|
-
billsFetched.push({ id: id, data: bill });
|
|
65
|
-
}
|
|
66
|
-
// If the bill doesn't exist in the bills array, add it to the billsToFetch array
|
|
67
|
-
billsToFetch.push({ id: id, billNftAddress: billNftAddress, chainId: chainId });
|
|
68
|
-
});
|
|
69
|
-
groupedBillsToFetch = billsToFetch === null || billsToFetch === void 0 ? void 0 : billsToFetch.reduce(function (acc, bill) {
|
|
70
|
-
var key = "".concat(bill === null || bill === void 0 ? void 0 : bill.billNftAddress, "-").concat(bill === null || bill === void 0 ? void 0 : bill.chainId);
|
|
71
|
-
if (!acc[key]) {
|
|
72
|
-
acc[key] = {
|
|
73
|
-
billNftAddress: bill === null || bill === void 0 ? void 0 : bill.billNftAddress,
|
|
74
|
-
chainId: bill === null || bill === void 0 ? void 0 : bill.chainId,
|
|
75
|
-
ids: [],
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
acc[key].ids.push(bill === null || bill === void 0 ? void 0 : bill.id);
|
|
79
|
-
return acc;
|
|
80
|
-
}, {});
|
|
81
|
-
groupedBillsToFetchArray = Object.values(groupedBillsToFetch);
|
|
82
|
-
return [4 /*yield*/, Promise.all(groupedBillsToFetchArray.map(function (_a) {
|
|
83
|
-
var billNftAddress = _a.billNftAddress, chainId = _a.chainId, ids = _a.ids;
|
|
84
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
-
return __generator(this, function (_b) {
|
|
86
|
-
return [2 /*return*/, getBillNftBatchData(ids, billNftAddress, chainId)];
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}))
|
|
90
|
-
// Flatten the resulting array of arrays into a single array
|
|
91
|
-
];
|
|
92
|
-
case 1:
|
|
93
|
-
billNftData = _a.sent();
|
|
94
|
-
billNftDataFlat = billNftData.flat();
|
|
95
|
-
result = billsFetched.concat(billNftDataFlat.map(function (data) { return ({ id: data.tokenId, data: data }); }));
|
|
96
|
-
return [2 /*return*/, result];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}); };
|
|
100
|
-
export var fetchUserOwnedBills = function (chainId, account, bills) { return __awaiter(void 0, void 0, void 0, function () {
|
|
101
|
-
var billIdCalls, billIds, billsPendingRewardCall, billDataCalls, billVersions, billData, pendingRewardsCall, result, i, billDataPos, data;
|
|
102
|
-
var _a, _b, _c, _d, _e;
|
|
103
|
-
return __generator(this, function (_f) {
|
|
104
|
-
switch (_f.label) {
|
|
105
|
-
case 0:
|
|
106
|
-
billIdCalls = bills.map(function (b) { return ({
|
|
107
|
-
address: b.contractAddress,
|
|
108
|
-
name: 'getBillIds',
|
|
109
|
-
params: [account],
|
|
110
|
-
}); });
|
|
111
|
-
return [4 /*yield*/, multicall(chainId, billAbi, billIdCalls, true, 15)];
|
|
112
|
-
case 1:
|
|
113
|
-
billIds = _f.sent();
|
|
114
|
-
billsPendingRewardCall = [];
|
|
115
|
-
billDataCalls = [];
|
|
116
|
-
billVersions = [];
|
|
117
|
-
billIds.forEach(function (idArray, index) {
|
|
118
|
-
return idArray[0].forEach(function (id) {
|
|
119
|
-
return id.gt(0) &&
|
|
120
|
-
(billDataCalls.push({
|
|
121
|
-
address: bills[index].contractAddress,
|
|
122
|
-
name: bills[index].billVersion !== BillVersion.V1 ? 'getBillInfo' : 'billInfo',
|
|
123
|
-
params: [id],
|
|
124
|
-
}),
|
|
125
|
-
billDataCalls.push({ address: bills[index].contractAddress, name: 'billNft' }),
|
|
126
|
-
billsPendingRewardCall.push({
|
|
127
|
-
address: bills[index].contractAddress,
|
|
128
|
-
name: bills[index].billVersion !== BillVersion.V1 ? 'claimablePayout' : 'pendingPayoutFor',
|
|
129
|
-
params: [id],
|
|
130
|
-
}),
|
|
131
|
-
billVersions.push(bills[index].billVersion));
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
return [4 /*yield*/, multicall(chainId, billAbi, billDataCalls, true, 150)];
|
|
135
|
-
case 2:
|
|
136
|
-
billData = _f.sent();
|
|
137
|
-
return [4 /*yield*/, multicall(chainId, billAbi, billsPendingRewardCall)];
|
|
138
|
-
case 3:
|
|
139
|
-
pendingRewardsCall = _f.sent();
|
|
140
|
-
result = [];
|
|
141
|
-
for (i = 0; i < billsPendingRewardCall.length; i++) {
|
|
142
|
-
billDataPos = i === 0 ? 0 : i * 2;
|
|
143
|
-
data = billVersions[i] !== BillVersion.V1
|
|
144
|
-
? {
|
|
145
|
-
address: billsPendingRewardCall[i].address,
|
|
146
|
-
id: billsPendingRewardCall[i].params[0].toString(),
|
|
147
|
-
payout: new BigNumber((_a = billData[billDataPos][0]) === null || _a === void 0 ? void 0 : _a.payout.toString())
|
|
148
|
-
.minus((_b = billData[billDataPos][0]) === null || _b === void 0 ? void 0 : _b.payoutClaimed.toString())
|
|
149
|
-
.toString(),
|
|
150
|
-
billNftAddress: billData[billDataPos + 1][0].toString(),
|
|
151
|
-
vesting: (_c = billData[billDataPos][0]) === null || _c === void 0 ? void 0 : _c.vesting.toString(),
|
|
152
|
-
lastBlockTimestamp: (_d = billData[billDataPos][0]) === null || _d === void 0 ? void 0 : _d.lastClaimTimestamp.toString(),
|
|
153
|
-
truePricePaid: (_e = billData[billDataPos][0]) === null || _e === void 0 ? void 0 : _e.truePricePaid.toString(),
|
|
154
|
-
pendingRewards: pendingRewardsCall[i][0].toString(),
|
|
155
|
-
}
|
|
156
|
-
: {
|
|
157
|
-
address: billsPendingRewardCall[i].address,
|
|
158
|
-
id: billsPendingRewardCall[i].params[0].toString(),
|
|
159
|
-
payout: billData[billDataPos][0].toString(),
|
|
160
|
-
billNftAddress: billData[billDataPos + 1][0].toString(),
|
|
161
|
-
vesting: billData[billDataPos][1].toString(),
|
|
162
|
-
lastBlockTimestamp: billData[billDataPos][2].toString(),
|
|
163
|
-
truePricePaid: billData[billDataPos][3].toString(),
|
|
164
|
-
pendingRewards: pendingRewardsCall[i][0].toString(),
|
|
165
|
-
};
|
|
166
|
-
result.push(data);
|
|
167
|
-
}
|
|
168
|
-
return [2 /*return*/, result];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
}); };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const getBillNftData: (billNftId: string, billNftAddress: string, chainId: number) => Promise<any>;
|
|
2
|
-
/**
|
|
3
|
-
* Retrieves batch data for a list of bill NFT IDs from the API.
|
|
4
|
-
* @param billNftIds - An array of bill NFT IDs to retrieve data for.
|
|
5
|
-
* @param billNftAddress - The address of the bill NFT contract.
|
|
6
|
-
* @param chainId - The ID of the blockchain network to retrieve data from.
|
|
7
|
-
* @returns A Promise that resolves to the batch data for the specified bill NFT IDs, or null if an error occurs.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getBillNftBatchData: (billNftIds: string[], billNftAddress: string, chainId: number) => Promise<any>;
|