@ape.swap/bonds-sdk 1.0.356 → 1.0.357
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 +11 -20
- package/dist/components/YourBonds/YourBonds.js +61 -43
- package/dist/components/YourBonds/fetchBillsUser.d.ts +3 -3
- package/dist/components/YourBonds/fetchBillsUser.js +4 -4
- package/dist/config/abi/erc20.json +117 -0
- package/dist/config/abi/price-getter-linea.json +1448 -0
- package/dist/config/abi/price-getter.json +1309 -0
- package/dist/enum/abis.d.ts +80 -0
- package/dist/enum/abis.js +1 -0
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.d.ts +17 -0
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +205 -0
- package/dist/state/bills/cleanBillsData.d.ts +5 -0
- package/dist/state/bills/cleanBillsData.js +41 -0
- package/dist/state/bills/fetchBills.d.ts +4 -0
- package/dist/state/bills/fetchBills.js +61 -0
- package/dist/state/bills/fetchBillsCalls.d.ts +4 -0
- package/dist/state/bills/fetchBillsCalls.js +27 -0
- package/dist/state/bills/fetchBillsUser.d.ts +15 -0
- package/dist/state/bills/fetchBillsUser.js +171 -0
- package/dist/state/bills/getBillNftData.d.ts +9 -0
- package/dist/state/bills/getBillNftData.js +109 -0
- package/dist/state/bills/hooks.d.ts +4 -0
- package/dist/state/bills/hooks.js +142 -0
- package/dist/state/bills/index.d.ts +48 -0
- package/dist/state/bills/index.js +293 -0
- package/dist/state/bills/types.d.ts +168 -0
- package/dist/state/bills/types.js +1 -0
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.d.ts +4 -0
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.js +68 -0
- package/dist/state/tokenPrices/getAllTokenPrices.d.ts +5 -0
- package/dist/state/tokenPrices/getAllTokenPrices.js +288 -0
- package/dist/state/tokenPrices/useTokenPricesNew.d.ts +11 -0
- package/dist/state/tokenPrices/useTokenPricesNew.js +72 -0
- package/dist/types/dexFactories.d.ts +11 -0
- package/dist/types/dexFactories.js +2 -0
- package/dist/types/yourbonds.d.ts +68 -1
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
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
|
+
})[];
|
|
@@ -0,0 +1 @@
|
|
|
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" }];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ChainId, Token as Token_ApeSwapLists } from '../../enum/apeswaplists';
|
|
2
|
+
type TokenRecord = {
|
|
3
|
+
[k: string]: Token_ApeSwapLists;
|
|
4
|
+
};
|
|
5
|
+
export declare function getTokenPricesV2FromPriceGetter(tokensToCall: TokenRecord, chain: ChainId, lpTokens?: boolean): Promise<any>;
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook to get price getter data.
|
|
8
|
+
*
|
|
9
|
+
* @param tokens - Tokens to build tx data for.
|
|
10
|
+
* @param supportedChainId - The chain ID.
|
|
11
|
+
* @returns The token price calls.
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePriceGetterData(tokensToCall: TokenRecord, // replace 'any' with the actual type
|
|
14
|
+
supportedChainId: ChainId, lpTokens: boolean): (string | number | undefined)[][];
|
|
15
|
+
export declare function getPriceGetterCallData(tokensToCall: TokenRecord, // replace 'any' with the actual type
|
|
16
|
+
supportedChainId: ChainId, lpTokens: boolean): (string | number | undefined)[][];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,205 @@
|
|
|
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 { ZERO_ADDRESS } from '../../config/constants/misc';
|
|
38
|
+
import { useMemo } from 'react';
|
|
39
|
+
import multicall from '../../utils/multicall';
|
|
40
|
+
import { PRICE_GETTER_ADDRESSES } from '../../config/constants/addresses';
|
|
41
|
+
import PRICE_GETTER_ABI from '../../config/abi/price-getter.json';
|
|
42
|
+
import PRICE_GETTER_ABI_LINEA from '../../config/abi/price-getter-linea.json';
|
|
43
|
+
import { ChainId, Protocols } from '../../enum/apeswaplists';
|
|
44
|
+
import { defaultDexFactories, dexFactories } from '../../types/dexFactories';
|
|
45
|
+
export function getTokenPricesV2FromPriceGetter(tokensToCall, chain, lpTokens) {
|
|
46
|
+
if (lpTokens === void 0) { lpTokens = false; }
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var tokenCalls, calls, tokenResults;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
tokenCalls = getPriceGetterCallData(tokensToCall, chain, lpTokens);
|
|
53
|
+
calls = tokenCalls.map(function (t) { return ({
|
|
54
|
+
address: PRICE_GETTER_ADDRESSES[chain],
|
|
55
|
+
name: lpTokens ? 'getLPPriceFromFactory' : 'getPriceFromFactory',
|
|
56
|
+
params: t,
|
|
57
|
+
}); });
|
|
58
|
+
return [4 /*yield*/, multicall(+chain, [ChainId.LINEA, ChainId.LIGHTLINK, ChainId.IOTA, ChainId.BASE].includes(chain)
|
|
59
|
+
? PRICE_GETTER_ABI_LINEA
|
|
60
|
+
: PRICE_GETTER_ABI, calls)];
|
|
61
|
+
case 1:
|
|
62
|
+
tokenResults = _a.sent();
|
|
63
|
+
return [2 /*return*/, tokenResults];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Custom hook to get price getter data.
|
|
70
|
+
*
|
|
71
|
+
* @param tokens - Tokens to build tx data for.
|
|
72
|
+
* @param supportedChainId - The chain ID.
|
|
73
|
+
* @returns The token price calls.
|
|
74
|
+
*/
|
|
75
|
+
export function usePriceGetterData(tokensToCall, // replace 'any' with the actual type
|
|
76
|
+
supportedChainId, lpTokens) {
|
|
77
|
+
return useMemo(function () {
|
|
78
|
+
return Object.values(tokensToCall).map(function (token) {
|
|
79
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
80
|
+
var liquidityDex = (_a = token.liquidityDex) === null || _a === void 0 ? void 0 : _a[supportedChainId];
|
|
81
|
+
var dexFactory;
|
|
82
|
+
var protocol = 2;
|
|
83
|
+
var factoryV2 = (_c = (_b = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _b === void 0 ? void 0 : _b[2]) !== null && _c !== void 0 ? _c : ZERO_ADDRESS;
|
|
84
|
+
var factoryV3 = (_e = (_d = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _d === void 0 ? void 0 : _d[3]) !== null && _e !== void 0 ? _e : ZERO_ADDRESS;
|
|
85
|
+
var factoryAlgebra = (_g = (_f = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _f === void 0 ? void 0 : _f[4]) !== null && _g !== void 0 ? _g : ZERO_ADDRESS;
|
|
86
|
+
var factorySolidly = (_j = (_h = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _h === void 0 ? void 0 : _h[7]) !== null && _j !== void 0 ? _j : ZERO_ADDRESS;
|
|
87
|
+
if (liquidityDex) {
|
|
88
|
+
dexFactory = (_k = dexFactories[supportedChainId]) === null || _k === void 0 ? void 0 : _k[liquidityDex];
|
|
89
|
+
protocol = (_l = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.protocol) !== null && _l !== void 0 ? _l : Protocols.V2;
|
|
90
|
+
switch (protocol) {
|
|
91
|
+
case Protocols.V2:
|
|
92
|
+
factoryV2 = (_m = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _m !== void 0 ? _m : factoryV2;
|
|
93
|
+
break;
|
|
94
|
+
case Protocols.V3:
|
|
95
|
+
factoryV3 = (_o = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _o !== void 0 ? _o : factoryV3;
|
|
96
|
+
break;
|
|
97
|
+
case Protocols.Algebra:
|
|
98
|
+
factoryAlgebra = (_p = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _p !== void 0 ? _p : factoryAlgebra;
|
|
99
|
+
break;
|
|
100
|
+
case Protocols.Solidly:
|
|
101
|
+
factorySolidly = (_q = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _q !== void 0 ? _q : factorySolidly;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
var errMsg = "No default dex factory found for retrieving price. For Protocol: ".concat(protocol, ".");
|
|
106
|
+
switch (protocol) {
|
|
107
|
+
case Protocols.Both:
|
|
108
|
+
if (factoryV2 === ZERO_ADDRESS || factoryV3 === ZERO_ADDRESS) {
|
|
109
|
+
throw new Error(errMsg);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
case Protocols.V2:
|
|
113
|
+
if (factoryV2 === ZERO_ADDRESS) {
|
|
114
|
+
throw new Error(errMsg);
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case Protocols.V3:
|
|
118
|
+
if (factoryV3 === ZERO_ADDRESS) {
|
|
119
|
+
throw new Error(errMsg);
|
|
120
|
+
}
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
// Not sure if this is the best way to handle this. It requires all tokens to be either LP or not
|
|
124
|
+
if (lpTokens && protocol == Protocols.Algebra) {
|
|
125
|
+
protocol = Protocols.Gamma;
|
|
126
|
+
}
|
|
127
|
+
if (lpTokens && protocol == Protocols.V3) {
|
|
128
|
+
protocol = Protocols.Steer;
|
|
129
|
+
}
|
|
130
|
+
return [token.address[supportedChainId], protocol, factoryV2, factoryV3, factoryAlgebra, factorySolidly];
|
|
131
|
+
});
|
|
132
|
+
}, [tokensToCall, supportedChainId, lpTokens]);
|
|
133
|
+
}
|
|
134
|
+
export function getPriceGetterCallData(tokensToCall, // replace 'any' with the actual type
|
|
135
|
+
supportedChainId, lpTokens) {
|
|
136
|
+
return Object.values(tokensToCall).map(function (token) {
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
138
|
+
var liquidityDex = (_a = token.liquidityDex) === null || _a === void 0 ? void 0 : _a[supportedChainId];
|
|
139
|
+
var dexFactory;
|
|
140
|
+
var protocol = 2;
|
|
141
|
+
var factoryV2 = (_c = (_b = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _b === void 0 ? void 0 : _b[2]) !== null && _c !== void 0 ? _c : ZERO_ADDRESS;
|
|
142
|
+
var factoryV3 = (_e = (_d = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _d === void 0 ? void 0 : _d[3]) !== null && _e !== void 0 ? _e : ZERO_ADDRESS;
|
|
143
|
+
var factoryAlgebra = (_g = (_f = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _f === void 0 ? void 0 : _f[4]) !== null && _g !== void 0 ? _g : ZERO_ADDRESS;
|
|
144
|
+
var factorySolidly = (_j = (_h = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _h === void 0 ? void 0 : _h[7]) !== null && _j !== void 0 ? _j : ZERO_ADDRESS;
|
|
145
|
+
var factoryXFAI = (_l = (_k = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _k === void 0 ? void 0 : _k[8]) !== null && _l !== void 0 ? _l : ZERO_ADDRESS;
|
|
146
|
+
if (liquidityDex) {
|
|
147
|
+
dexFactory = (_m = dexFactories[supportedChainId]) === null || _m === void 0 ? void 0 : _m[liquidityDex];
|
|
148
|
+
protocol = (_o = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.protocol) !== null && _o !== void 0 ? _o : Protocols.V2;
|
|
149
|
+
switch (protocol) {
|
|
150
|
+
case Protocols.V2:
|
|
151
|
+
factoryV2 = (_p = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _p !== void 0 ? _p : factoryV2;
|
|
152
|
+
break;
|
|
153
|
+
case Protocols.V3:
|
|
154
|
+
factoryV3 = (_q = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _q !== void 0 ? _q : factoryV3;
|
|
155
|
+
break;
|
|
156
|
+
case Protocols.Algebra:
|
|
157
|
+
factoryAlgebra = (_r = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _r !== void 0 ? _r : factoryAlgebra;
|
|
158
|
+
break;
|
|
159
|
+
case Protocols.Solidly:
|
|
160
|
+
factorySolidly = (_s = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _s !== void 0 ? _s : factorySolidly;
|
|
161
|
+
break;
|
|
162
|
+
case Protocols.XFAI:
|
|
163
|
+
factoryXFAI = (_t = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _t !== void 0 ? _t : factoryXFAI;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
var errMsg = "No default dex factory found for retrieving price. For Protocol: ".concat(protocol, ".");
|
|
167
|
+
switch (protocol) {
|
|
168
|
+
case Protocols.Both:
|
|
169
|
+
if (factoryV2 === ZERO_ADDRESS || factoryV3 === ZERO_ADDRESS) {
|
|
170
|
+
throw new Error(errMsg);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
case Protocols.V2:
|
|
174
|
+
if (factoryV2 === ZERO_ADDRESS) {
|
|
175
|
+
throw new Error(errMsg);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
case Protocols.V3:
|
|
179
|
+
if (factoryV3 === ZERO_ADDRESS) {
|
|
180
|
+
throw new Error(errMsg);
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
// TODO: Not sure if this is the best way to handle this. It requires all tokens to be either LP or not
|
|
185
|
+
if (lpTokens && protocol == Protocols.Algebra) {
|
|
186
|
+
protocol = Protocols.Gamma;
|
|
187
|
+
}
|
|
188
|
+
if (lpTokens && protocol == Protocols.V3) {
|
|
189
|
+
protocol = Protocols.Steer;
|
|
190
|
+
}
|
|
191
|
+
if ([ChainId.LINEA, ChainId.LIGHTLINK, ChainId.IOTA, ChainId.BASE].includes(supportedChainId) && !token.lpToken) {
|
|
192
|
+
return [
|
|
193
|
+
token.address[supportedChainId],
|
|
194
|
+
protocol,
|
|
195
|
+
factoryV2,
|
|
196
|
+
factoryV3,
|
|
197
|
+
factoryAlgebra,
|
|
198
|
+
factorySolidly,
|
|
199
|
+
factoryXFAI,
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
else
|
|
203
|
+
return [token.address[supportedChainId], protocol, factoryV2, factoryV3, factoryAlgebra, factorySolidly];
|
|
204
|
+
});
|
|
205
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
@@ -0,0 +1,41 @@
|
|
|
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;
|
|
@@ -0,0 +1,4 @@
|
|
|
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;
|
|
@@ -0,0 +1,61 @@
|
|
|
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;
|
|
@@ -0,0 +1,27 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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[]>;
|