reimplement abracadabra's adapter

This commit is contained in:
0xmDreamy
2023-08-14 13:33:06 +02:00
parent 6bb94e4ef6
commit 24a480b0f3
9 changed files with 1484 additions and 294 deletions

14
package-lock.json generated
View File

@@ -11,7 +11,7 @@
"@acala-network/api": "^3.0.2",
"@connext/nxtp-contracts": "0.0.94",
"@connext/nxtp-utils": "0.0.94",
"@defillama/sdk": "^4.0.25",
"@defillama/sdk": "^4.0.44",
"@makerdao/multicall": "^0.12.0",
"@polkadot/api": "^6.7.1",
"@port.finance/port-sdk": "^0.1.42",
@@ -2010,9 +2010,9 @@
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
},
"node_modules/@defillama/sdk": {
"version": "4.0.25",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.25.tgz",
"integrity": "sha512-5dQ4I5xVRk1FAD2qJetBp+84gPMGil5lSCS3okuVEHiU/p2uSDghDj+S0eiZYSm1xAzDniklerHuoHQs6MlqAg==",
"version": "4.0.44",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.44.tgz",
"integrity": "sha512-sy68JfCaS6e1EOnFpndATtlZf8IN1c86pC0Hyh7bLkKzURJtbo8YT3kyebp1OkLu2Rbl82W47pRnyQwKXab7aw==",
"dependencies": {
"@supercharge/promise-pool": "^2.1.0",
"ethers": "^5.4.5",
@@ -36810,9 +36810,9 @@
}
},
"@defillama/sdk": {
"version": "4.0.25",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.25.tgz",
"integrity": "sha512-5dQ4I5xVRk1FAD2qJetBp+84gPMGil5lSCS3okuVEHiU/p2uSDghDj+S0eiZYSm1xAzDniklerHuoHQs6MlqAg==",
"version": "4.0.44",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.44.tgz",
"integrity": "sha512-sy68JfCaS6e1EOnFpndATtlZf8IN1c86pC0Hyh7bLkKzURJtbo8YT3kyebp1OkLu2Rbl82W47pRnyQwKXab7aw==",
"requires": {
"@supercharge/promise-pool": "^2.1.0",
"ethers": "^5.4.5",

View File

@@ -52,7 +52,7 @@
"@acala-network/api": "^3.0.2",
"@connext/nxtp-contracts": "0.0.94",
"@connext/nxtp-utils": "0.0.94",
"@defillama/sdk": "^4.0.25",
"@defillama/sdk": "^4.0.44",
"@makerdao/multicall": "^0.12.0",
"@polkadot/api": "^6.7.1",
"@port.finance/port-sdk": "^0.1.42",

View File

@@ -12,7 +12,7 @@
"@acala-network/api": "^4.0.0",
"@connext/nxtp-contracts": "^0.1.17",
"@connext/nxtp-utils": "^0.1.17",
"@defillama/sdk": "^4.0.14",
"@defillama/sdk": "^4.0.44",
"@makerdao/multicall": "^0.12.0",
"@polkadot/api": "^7.0.0",
"@port.finance/port-sdk": "0.1.42",
@@ -491,13 +491,14 @@
}
},
"node_modules/@defillama/sdk": {
"version": "4.0.14",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.14.tgz",
"integrity": "sha512-otbgUwSxi9EfIfDvGxLI2vyEFJsOD6No6/Nf1dJ0VHVFQ/9qqwJ8LW2qNNxVVVegjfQtMux5j4SjDfXaVeZjqw==",
"version": "4.0.44",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.44.tgz",
"integrity": "sha512-sy68JfCaS6e1EOnFpndATtlZf8IN1c86pC0Hyh7bLkKzURJtbo8YT3kyebp1OkLu2Rbl82W47pRnyQwKXab7aw==",
"dependencies": {
"@supercharge/promise-pool": "^2.1.0",
"ethers": "^5.4.5",
"node-fetch": "^2.6.7"
"node-fetch": "^2.6.7",
"tron-format-address": "^0.1.11"
}
},
"node_modules/@eslint/eslintrc": {
@@ -16546,6 +16547,11 @@
"resolved": "https://registry.npmjs.org/traverse-chain/-/traverse-chain-0.1.0.tgz",
"integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE="
},
"node_modules/tron-format-address": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/tron-format-address/-/tron-format-address-0.1.11.tgz",
"integrity": "sha512-Jx2i3R1yXrEMQsfc2jueAI71ivnySzdeva6SiSM/pddwj8TK7PVABSP6s/iYcTRI63GxJEgGMmOJXNNKoBmbQw=="
},
"node_modules/tronweb": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/tronweb/-/tronweb-3.2.7.tgz",
@@ -18377,13 +18383,14 @@
}
},
"@defillama/sdk": {
"version": "4.0.14",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.14.tgz",
"integrity": "sha512-otbgUwSxi9EfIfDvGxLI2vyEFJsOD6No6/Nf1dJ0VHVFQ/9qqwJ8LW2qNNxVVVegjfQtMux5j4SjDfXaVeZjqw==",
"version": "4.0.44",
"resolved": "https://registry.npmjs.org/@defillama/sdk/-/sdk-4.0.44.tgz",
"integrity": "sha512-sy68JfCaS6e1EOnFpndATtlZf8IN1c86pC0Hyh7bLkKzURJtbo8YT3kyebp1OkLu2Rbl82W47pRnyQwKXab7aw==",
"requires": {
"@supercharge/promise-pool": "^2.1.0",
"ethers": "^5.4.5",
"node-fetch": "2.6.7"
"node-fetch": "2.6.7",
"tron-format-address": "^0.1.11"
}
},
"@eslint/eslintrc": {
@@ -30801,6 +30808,11 @@
"resolved": "https://registry.npmjs.org/traverse-chain/-/traverse-chain-0.1.0.tgz",
"integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE="
},
"tron-format-address": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/tron-format-address/-/tron-format-address-0.1.11.tgz",
"integrity": "sha512-Jx2i3R1yXrEMQsfc2jueAI71ivnySzdeva6SiSM/pddwj8TK7PVABSP6s/iYcTRI63GxJEgGMmOJXNNKoBmbQw=="
},
"tronweb": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/tronweb/-/tronweb-3.2.7.tgz",

View File

@@ -13,7 +13,7 @@
"@acala-network/api": "^4.0.0",
"@connext/nxtp-contracts": "^0.1.17",
"@connext/nxtp-utils": "^0.1.17",
"@defillama/sdk": "^4.0.14",
"@defillama/sdk": "^4.0.44",
"@makerdao/multicall": "^0.12.0",
"@polkadot/api": "^7.0.0",
"@port.finance/port-sdk": "0.1.42",

View File

@@ -130,5 +130,6 @@
"ethpow",
"aptos",
"comdex",
"polygon_zkevm"
]
"polygon_zkevm",
"base"
]

View File

@@ -0,0 +1,675 @@
export const BENTOBOX_ABI = [
{
inputs: [
{ internalType: "contract IERC20", name: "wethToken_", type: "address" },
],
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "masterContract",
type: "address",
},
{ indexed: false, internalType: "bytes", name: "data", type: "bytes" },
{
indexed: true,
internalType: "address",
name: "cloneAddress",
type: "address",
},
],
name: "LogDeploy",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "share",
type: "uint256",
},
],
name: "LogDeposit",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "borrower",
type: "address",
},
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "feeAmount",
type: "uint256",
},
{
indexed: true,
internalType: "address",
name: "receiver",
type: "address",
},
],
name: "LogFlashLoan",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "protocol",
type: "address",
},
],
name: "LogRegisterProtocol",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "masterContract",
type: "address",
},
{ indexed: true, internalType: "address", name: "user", type: "address" },
{ indexed: false, internalType: "bool", name: "approved", type: "bool" },
],
name: "LogSetMasterContractApproval",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "LogStrategyDivest",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "LogStrategyInvest",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "LogStrategyLoss",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
],
name: "LogStrategyProfit",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: true,
internalType: "contract IStrategy",
name: "strategy",
type: "address",
},
],
name: "LogStrategyQueued",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: true,
internalType: "contract IStrategy",
name: "strategy",
type: "address",
},
],
name: "LogStrategySet",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "targetPercentage",
type: "uint256",
},
],
name: "LogStrategyTargetPercentage",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "share",
type: "uint256",
},
],
name: "LogTransfer",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "masterContract",
type: "address",
},
{ indexed: false, internalType: "bool", name: "approved", type: "bool" },
],
name: "LogWhiteListMasterContract",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "contract IERC20",
name: "token",
type: "address",
},
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "share",
type: "uint256",
},
],
name: "LogWithdraw",
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",
},
{
inputs: [],
name: "DOMAIN_SEPARATOR",
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "", type: "address" },
{ internalType: "address", name: "", type: "address" },
],
name: "balanceOf",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "bytes[]", name: "calls", type: "bytes[]" },
{ internalType: "bool", name: "revertOnFail", type: "bool" },
],
name: "batch",
outputs: [
{ internalType: "bool[]", name: "successes", type: "bool[]" },
{ internalType: "bytes[]", name: "results", type: "bytes[]" },
],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
internalType: "contract IBatchFlashBorrower",
name: "borrower",
type: "address",
},
{ internalType: "address[]", name: "receivers", type: "address[]" },
{ internalType: "contract IERC20[]", name: "tokens", type: "address[]" },
{ internalType: "uint256[]", name: "amounts", type: "uint256[]" },
{ internalType: "bytes", name: "data", type: "bytes" },
],
name: "batchFlashLoan",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "claimOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "masterContract", type: "address" },
{ internalType: "bytes", name: "data", type: "bytes" },
{ internalType: "bool", name: "useCreate2", type: "bool" },
],
name: "deploy",
outputs: [
{ internalType: "address", name: "cloneAddress", type: "address" },
],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token_", type: "address" },
{ internalType: "address", name: "from", type: "address" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
name: "deposit",
outputs: [
{ internalType: "uint256", name: "amountOut", type: "uint256" },
{ internalType: "uint256", name: "shareOut", type: "uint256" },
],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
internalType: "contract IFlashBorrower",
name: "borrower",
type: "address",
},
{ internalType: "address", name: "receiver", type: "address" },
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "bytes", name: "data", type: "bytes" },
],
name: "flashLoan",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "bool", name: "balance", type: "bool" },
{ internalType: "uint256", name: "maxChangeAmount", type: "uint256" },
],
name: "harvest",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "", type: "address" },
{ internalType: "address", name: "", type: "address" },
],
name: "masterContractApproved",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "masterContractOf",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "nonces",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "pendingOwner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
name: "pendingStrategy",
outputs: [
{ internalType: "contract IStrategy", name: "", type: "address" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "address", name: "from", type: "address" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "uint256", name: "deadline", type: "uint256" },
{ internalType: "uint8", name: "v", type: "uint8" },
{ internalType: "bytes32", name: "r", type: "bytes32" },
{ internalType: "bytes32", name: "s", type: "bytes32" },
],
name: "permitToken",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "registerProtocol",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "user", type: "address" },
{ internalType: "address", name: "masterContract", type: "address" },
{ internalType: "bool", name: "approved", type: "bool" },
{ internalType: "uint8", name: "v", type: "uint8" },
{ internalType: "bytes32", name: "r", type: "bytes32" },
{ internalType: "bytes32", name: "s", type: "bytes32" },
],
name: "setMasterContractApproval",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{
internalType: "contract IStrategy",
name: "newStrategy",
type: "address",
},
],
name: "setStrategy",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "uint64", name: "targetPercentage_", type: "uint64" },
],
name: "setStrategyTargetPercentage",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
name: "strategy",
outputs: [
{ internalType: "contract IStrategy", name: "", type: "address" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
name: "strategyData",
outputs: [
{ internalType: "uint64", name: "strategyStartDate", type: "uint64" },
{ internalType: "uint64", name: "targetPercentage", type: "uint64" },
{ internalType: "uint128", name: "balance", type: "uint128" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "uint256", name: "share", type: "uint256" },
{ internalType: "bool", name: "roundUp", type: "bool" },
],
name: "toAmount",
outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "bool", name: "roundUp", type: "bool" },
],
name: "toShare",
outputs: [{ internalType: "uint256", name: "share", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
name: "totals",
outputs: [
{ internalType: "uint128", name: "elastic", type: "uint128" },
{ internalType: "uint128", name: "base", type: "uint128" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "address", name: "from", type: "address" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
name: "transfer",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token", type: "address" },
{ internalType: "address", name: "from", type: "address" },
{ internalType: "address[]", name: "tos", type: "address[]" },
{ internalType: "uint256[]", name: "shares", type: "uint256[]" },
],
name: "transferMultiple",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "newOwner", type: "address" },
{ internalType: "bool", name: "direct", type: "bool" },
{ internalType: "bool", name: "renounce", type: "bool" },
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "masterContract", type: "address" },
{ internalType: "bool", name: "approved", type: "bool" },
],
name: "whitelistMasterContract",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "whitelistedMasterContracts",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "contract IERC20", name: "token_", type: "address" },
{ internalType: "address", name: "from", type: "address" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
name: "withdraw",
outputs: [
{ internalType: "uint256", name: "amountOut", type: "uint256" },
{ internalType: "uint256", name: "shareOut", type: "uint256" },
],
stateMutability: "nonpayable",
type: "function",
},
{ stateMutability: "payable", type: "receive" },
] as const;

View File

@@ -0,0 +1,416 @@
export const CAULDRON_V1_ABI = [
{
inputs: [
{
internalType: "contract IBentoBoxV1",
name: "bentoBox_",
type: "address",
},
{
internalType: "contract IERC20",
name: "magicInternetMoney_",
type: "address",
},
],
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint128",
name: "accruedAmount",
type: "uint128",
},
],
name: "LogAccrue",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "share",
type: "uint256",
},
],
name: "LogAddCollateral",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "part",
type: "uint256",
},
],
name: "LogBorrow",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "uint256",
name: "rate",
type: "uint256",
},
],
name: "LogExchangeRate",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "newFeeTo",
type: "address",
},
],
name: "LogFeeTo",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "share",
type: "uint256",
},
],
name: "LogRemoveCollateral",
type: "event",
},
{
anonymous: false,
inputs: [
{ indexed: true, internalType: "address", name: "from", type: "address" },
{ indexed: true, internalType: "address", name: "to", type: "address" },
{
indexed: false,
internalType: "uint256",
name: "amount",
type: "uint256",
},
{
indexed: false,
internalType: "uint256",
name: "part",
type: "uint256",
},
],
name: "LogRepay",
type: "event",
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "feeTo",
type: "address",
},
{
indexed: false,
internalType: "uint256",
name: "feesEarnedFraction",
type: "uint256",
},
],
name: "LogWithdrawFees",
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",
},
{
inputs: [],
name: "accrue",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "accrueInfo",
outputs: [
{ internalType: "uint64", name: "lastAccrued", type: "uint64" },
{ internalType: "uint128", name: "feesEarned", type: "uint128" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "to", type: "address" },
{ internalType: "bool", name: "skim", type: "bool" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
name: "addCollateral",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "bentoBox",
outputs: [
{ internalType: "contract IBentoBoxV1", name: "", type: "address" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "amount", type: "uint256" },
],
name: "borrow",
outputs: [
{ internalType: "uint256", name: "part", type: "uint256" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "claimOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "collateral",
outputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "uint8[]", name: "actions", type: "uint8[]" },
{ internalType: "uint256[]", name: "values", type: "uint256[]" },
{ internalType: "bytes[]", name: "datas", type: "bytes[]" },
],
name: "cook",
outputs: [
{ internalType: "uint256", name: "value1", type: "uint256" },
{ internalType: "uint256", name: "value2", type: "uint256" },
],
stateMutability: "payable",
type: "function",
},
{
inputs: [],
name: "exchangeRate",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "feeTo",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
name: "init",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{ internalType: "address[]", name: "users", type: "address[]" },
{ internalType: "uint256[]", name: "maxBorrowParts", type: "uint256[]" },
{ internalType: "address", name: "to", type: "address" },
{ internalType: "contract ISwapper", name: "swapper", type: "address" },
],
name: "liquidate",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "magicInternetMoney",
outputs: [{ internalType: "contract IERC20", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "masterContract",
outputs: [
{ internalType: "contract CauldronLowRiskV1", name: "", type: "address" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "oracle",
outputs: [{ internalType: "contract IOracle", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "oracleData",
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "pendingOwner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
name: "reduceSupply",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "to", type: "address" },
{ internalType: "uint256", name: "share", type: "uint256" },
],
name: "removeCollateral",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "to", type: "address" },
{ internalType: "bool", name: "skim", type: "bool" },
{ internalType: "uint256", name: "part", type: "uint256" },
],
name: "repay",
outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "address", name: "newFeeTo", type: "address" }],
name: "setFeeTo",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "totalBorrow",
outputs: [
{ internalType: "uint128", name: "elastic", type: "uint128" },
{ internalType: "uint128", name: "base", type: "uint128" },
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "totalCollateralShare",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [
{ internalType: "address", name: "newOwner", type: "address" },
{ internalType: "bool", name: "direct", type: "bool" },
{ internalType: "bool", name: "renounce", type: "bool" },
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "updateExchangeRate",
outputs: [
{ internalType: "bool", name: "updated", type: "bool" },
{ internalType: "uint256", name: "rate", type: "uint256" },
],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "userBorrowPart",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "userCollateralShare",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "withdrawFees",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
] as const;

View File

@@ -1,302 +1,392 @@
const sdk = require("@defillama/sdk");
import { sumMultipleBalanceFunctions, sumSingleBalance } from "../helper/generalUtil";
import {
bridgedSupply,
bridgedSupplySubtractReserve,
} from "../helper/getSupply";
import { sumSingleBalance } from "../helper/generalUtil";
import {
Balances,
ChainBlocks,
PeggedIssuanceAdapter,
Balances,
} from "../peggedAsset.type";
import { BENTOBOX_ABI } from "./abis/bentobox";
import { CAULDRON_V1_ABI } from "./abis/cauldron-v1";
type Address = `0x${string}`;
type ChainContract = {
address: Address;
cauldrons?: Address[];
reserves?: Address[];
bentoboxes?: Address[];
};
type ChainContracts = {
[chain: string]: {
[contract: string]: string[];
};
[chain: string]: ChainContract;
};
const chainContracts: ChainContracts = {
ethereum: {
issued: ["0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3"],
reserves: [
"0x30b9de623c209a42ba8d5ca76384ead740be9529", // new cauldron
"0xf5bce5077908a1b7370b9ae04adc565ebd643966", // bentobox
"0xd96f48665a1410c0cd669a88898eca36b9fc2cce", // degenbox
"0x5f0dee98360d8200b20812e174d139a1a633edd2", // multisig
"0x439a5f0f5E8d149DDA9a0Ca367D4a8e4D6f83C10", // hold 73m
],
multichain: ["0xbbc4a8d076f4b1888fec42581b6fc58d242cf2d5"], // multichain bridge contract, has significant amount more than is minted on other chains
},
polygon: {
bridgedFromETH: ["0x49a0400587A7F65072c87c4910449fDcC5c47242"], // multichain/abracadabra
},
const ethereumChainContract: ChainContract = {
address: "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3",
cauldrons: [
"0x7ce7d9ed62b9a6c5ace1c6ec9aeb115fa3064757",
"0x7b7473a76d6ae86ce19f7352a1e89f6c9dc39020",
"0xf179fe36a36b32a4644587b8cdee7a23af98ed37",
"0x05500e2ee779329698df35760bedcaac046e7c27",
"0x003d5a75d284824af736df51933be522de9eed0f",
"0x98a84eff6e008c5ed0289655ccdca899bcb6b99f",
"0xebfde87310dc22404d918058faa4d56dc4e93f0a",
"0x0bca8ebcb26502b013493bf8fe53aa2b1ed401c1",
"0x920d9bd936da4eafb5e25c6bdc9f6cb528953f9f",
"0x4eaed76c3a388f4a841e9c765560bbe7b3e4b3a0",
"0x252dcf1b621cc53bc22c256255d2be5c8c32eae4",
"0x35a0dd182e4bca59d5931eae13d0a2332fa30321",
"0xc1879bf24917ebe531fbaa20b0d05da027b592ce",
"0x9617b633ef905860d919b88e1d9d9a6191795341",
"0xcfc571f3203756319c231d3bc643cee807e74636",
"0x3410297d89dcdaf4072b805efc1ef701bb3dd9bf",
"0x257101f20cb7243e2c7129773ed5dbbcef8b34e0",
"0x390db10e65b5ab920c19149c919d970ad9d18a41",
"0x5ec47ee69bede0b6c2a2fc0d9d094df16c192498",
"0xd31e19a0574dbf09310c3b06f3416661b4dc7324",
"0xc6b2b3fe7c3d7a6f823d9106e22e66660709001e",
"0x53375add9d2dfe19398ed65baaeffe622760a9a6",
"0x8227965a7f42956549afaec319f4e444aa438df5",
"0x207763511da879a900973a5e092382117c3c1588",
"0x85f60d3ea4e86af43c9d4e9cc9095281fc25c405",
"0x7259e152103756e1616a77ae982353c3751a6a90",
"0x692887e8877c6dd31593cda44c382db5b289b684",
"0x7d8df3e4d06b0e19960c19ee673c0823beb90815",
"0x1062eb452f8c7a94276437ec1f4aaca9b1495b72",
"0x59e9082e068ddb27fc5ef1690f9a9f22b32e573f",
"0x6cbafee1fab76ca5b5e144c43b3b50d42b7c8c8f",
"0x551a7cff4de931f32893c928bbc3d25bf1fc5147",
"0x6ff9061bb8f97d948942cef376d98b51fa38b91f",
"0xbb02a884621fb8f5bfd263a67f58b65df5b090f3",
"0xc319eea1e792577c319723b5e60a15da3857e7da",
"0xffbf4892822e0d552cff317f65e1ee7b5d3d9ae6",
"0x806e16ec797c69afa8590a55723ce4cc1b54050e",
"0x6371efe5cd6e3d2d7c477935b7669401143b7985",
"0xbc36fde44a7fd8f545d459452ef9539d7a14dd63",
],
reserves: [
"0x30b9de623c209a42ba8d5ca76384ead740be9529", // CauldronOwner
],
bentoboxes: [
"0xf5bce5077908a1b7370b9ae04adc565ebd643966", // BentoBox
"0xd96f48665a1410c0cd669a88898eca36b9fc2cce", // DegenBox
],
};
const bridgedChainContracts: ChainContracts = {
optimism: {
bridgedFromETH: ["0xB153FB3d196A8eB25522705560ac152eeEc57901"], //
reserves: ["0xa93C81f564579381116ee3E007C9fCFd2EBa1723"] //degenbox
},
avax: {
bridgedFromETH: ["0x130966628846BFd36ff31a822705796e8cb8C18D"], // multichain/abracadabra
reserves: [
"0xae64a325027c3c14cf6abc7818aa3b9c07f5c799", // new gnosis
"0x27c215c8b6e39f54c42ac04eb651211e9a566090", // multisig
"0xae4d3a42e46399827bd094b4426e2f79cca543ca", // gnosis
"0xf4f46382c2be1603dc817551ff9a7b333ed1d18f", // bentobox
"0x1fc83f75499b7620d53757f0b01e2ae626aae530", // degenbox
],
},
arbitrum: {
bridgedFromETH: ["0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a"], // multichain/abracadabra
reserves: [
"0x74c764d41b77dbbb4fe771dab1939b00b146894a", // bentobox
"0xf46bb6dda9709c49efb918201d97f6474eac5aea", // multisig
"0x27807dd7adf218e1f4d885d54ed51c70efb9de50", // holds 20m
"0x7C8FeF8eA9b1fE46A7689bfb8149341C90431D38", // degenbox
],
},
fantom: {
bridgedFromETH: ["0x82f0b8b456c1a451378467398982d4834b6829c1"], // multichain/abracadabra
reserves: [
"0xb4ad8b57bd6963912c80fcbb6baea99988543c1c", // multisig
"0xf5bce5077908a1b7370b9ae04adc565ebd643966", // bentobox
"0x74a0bca2eeedf8883cb91e37e9ff49430f20a616", // degenbox
address: "0xb153fb3d196a8eb25522705560ac152eeec57901",
cauldrons: ["0x68f498c230015254aff0e1eb6f85da558dff2362"],
bentoboxes: [
"0xa93c81f564579381116ee3e007c9fcfd2eba1723", // DegenBox
],
},
bsc: {
bridgedFromETH: ["0xfe19f0b51438fd612f6fd59c1dbb3ea319f433ba"], // multichain/abracadabra
reserves: [
"0x090185f2135308bad17527004364ebcc2d37e5f6", // degenbox
"0x9d9bc38bf4a128530ea45a7d27d0ccb9c2ebfaf6", // multisig
address: "0xfe19f0b51438fd612f6fd59c1dbb3ea319f433ba",
cauldrons: [
"0xf8049467f3a9d50176f4816b20cddd9bb8a93319",
"0x692cf15f80415d83e8c0e139cabcda67fcc12c90",
],
bentoboxes: [
"0x090185f2135308bad17527004364ebcc2d37e5f6", // DegenBox
],
},
polygon: {
address: "0x49a0400587a7f65072c87c4910449fdcc5c47242",
},
fantom: {
address: "0x82f0b8b456c1a451378467398982d4834b6829c1",
cauldrons: [
"0x7208d9f9398d7b02c5c22c334c2a7a3a98c0a45d",
"0x4fdffa59bf8dda3f4d5b38f260eab8bfac6d7bc1",
"0x8e45af6743422e488afacdad842ce75a09eaed34",
"0xd4357d43545f793101b592bacab89943dc89d11b",
"0xed745b045f9495b8bfc7b58eea8e0d0597884e12",
"0xa3fc1b4b7f06c2391f7ad7d4795c1cd28a59917e",
],
bentoboxes: [
"0xf5bce5077908a1b7370b9ae04adc565ebd643966", // BentoBox
"0x74a0bca2eeedf8883cb91e37e9ff49430f20a616", // DegenBox
],
},
moonriver: {
bridgedFromETH: ["0x0cae51e1032e8461f4806e26332c030e34de3adb"], // multichain
reserves: ["0xd4a7febd52efda82d6f8ace24908ae0aa5b4f956"], // multisig
},
boba: {
bridgedFromETH: ["0x218c3c3D49d0E7B37aff0D8bB079de36Ae61A4c0"], // multichain
},
metis: {
bridgedFromETH: ["0x44Dd7C98885cD3086E723B8554a90c9cC4089C4C"], // multichain
},
solana: {
bridgedFromETH: [
"HRQke5DKdDo3jV7wnomyiM8AA3EzkVnxMDdo2FQ5XUe1", // wormhole, 0 supply?
"CYEFQXzQM6E5P8ZrXgS7XMSwU3CiqHMMyACX4zuaA2Z4", // allbridge, no longer available in bridge?
address: "0x0cae51e1032e8461f4806e26332c030e34de3adb",
reserves: [
"0x8e534c5d52c921dbd6debc56503cf0e2dce6d534", // CauldronOwner
],
},
terra: {
bridgedFromETH: ["terra15a9dr3a2a2lj5fclrw35xxg9yuxg0d908wpf2y"], // wormhole
arbitrum: {
address: "0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a",
cauldrons: [
"0xc89958b03a55b5de2221acb25b58b89a000215e6",
"0x5698135ca439f21a57bddbe8b582c62f090406d5",
"0x726413d7402ff180609d0ebc79506df8633701b1",
],
reserves: [
"0x27807dd7adf218e1f4d885d54ed51c70efb9de50", // ODM
],
bentoboxes: [
"0x74c764d41b77dbbb4fe771dab1939b00b146894a", // BentoBox
"0x7c8fef8ea9b1fe46a7689bfb8149341c90431d38", // DegenBox
],
},
avax: {
address: "0x130966628846bfd36ff31a822705796e8cb8c18d",
cauldrons: [
"0x3cfed0439ab822530b1ffbd19536d897ef30d2a2",
"0x56984f04d2d04b2f63403f0ebedd3487716ba49d",
"0x3b63f81ad1fc724e44330b4cf5b5b6e355ad964b",
"0x95cce62c3ecd9a33090bbf8a9eac50b699b54210",
"0x35fa7a723b3b39f15623ff1eb26d8701e7d6bb21",
"0x0a1e6a80e93e62bd0d3d3bfcf4c362c40fb1cf3d",
"0x2450bf8e625e98e14884355205af6f97e3e68d07",
"0xacc6821d0f368b02d223158f8ada4824da9f28e3",
"0x3cf232f346934b949b99797d225bb72734731990", // Limone AVAX/USDC
],
bentoboxes: [
"0xf4f46382c2be1603dc817551ff9a7b333ed1d18f", // BentoBox
"0x1fc83f75499b7620d53757f0b01e2ae626aae530", // DegenBox
"0xd825d06061fdc0585e4373f0a3f01a8c02b0e6a4", // Limone
],
},
kava: {
address: "0x471ee749ba270eb4c1165b5ad95e614947f6fceb",
reserves: [
"0x844fed6dd9eb143e6302e937c795c3f0ec47a7c7", // CauldronOwner
],
},
base: {
address: "0x4a3a6dd60a34bb2aba60d73b4c88315e9ceb6a3d",
},
};
async function chainMinted(chain: string, decimals: number) {
async function chainReleased(
chain: string,
address: Address,
decimals: number,
bridged: boolean
) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
for (let issued of chainContracts[chain].issued) {
const totalSupply = (
await sdk.api.abi.call({
abi: "erc20:totalSupply",
target: issued,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
"issued",
false
);
}
const balances: Balances = {};
const totalSupply = (
await sdk.api.abi.call({
abi: "erc20:totalSupply",
target: address,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(
balances,
"peggedUSD",
totalSupply / 10 ** decimals,
bridged ? address : "issued",
bridged,
bridged ? undefined : "issued"
);
return balances;
};
}
async function chainUnreleased(
chain: string,
{ address, cauldrons, reserves, bentoboxes }: ChainContract,
decimals: number,
target: string,
reserves: string[]
bridged: boolean
) {
return async function (
const balancesFunction = async (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
) => {
const ownerPromise = ownerOf(address, chain, _chainBlocks);
const [
ownerBalance,
ownerBentoboxBalances,
cauldronBalances,
reserveBalances,
] = await Promise.all([
ownerPromise.then(
async (owner) =>
(
await sdk.api.erc20.balanceOf({
target: address,
owner,
block: _chainBlocks?.[chain],
chain: chain,
})
).output
),
ownerPromise.then((owner) =>
Promise.all(
(bentoboxes ?? []).map((bentobox) =>
bentoboxBalanceAmountOf(
bentobox,
address,
owner,
true,
chain,
_chainBlocks
)
)
)
),
Promise.all(
(cauldrons ?? []).map((cauldron) =>
balanceOfCauldron(chain, cauldron, address, _chainBlocks)
)
),
Promise.all(
(reserves ?? []).map(
async (reserve) =>
(
await sdk.api.erc20.balanceOf({
target: address,
owner: reserve,
block: _chainBlocks?.[chain],
chain: chain,
})
).output
)
),
]);
for (let reserve of reserves) {
const balance = (
await sdk.api.erc20.balanceOf({
target: target,
owner: reserve,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", balance / 10 ** decimals);
}
let balances: Balances = {};
[
ownerBalance,
...ownerBentoboxBalances,
...cauldronBalances,
...reserveBalances,
].forEach((balance) => {
sumSingleBalance(
balances,
"peggedUSD",
balance / 10 ** decimals,
bridged ? address : "issued",
bridged,
bridged ? undefined : "issued"
);
});
return balances;
};
return balancesFunction;
}
async function ethereumUnreleased(
async function ownerOf(
target: Address,
chain: string,
decimals: number,
reserves: string[]
) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;
chainBlocks?: ChainBlocks
): Promise<Address> {
const owner = (
await sdk.api.abi.call({
abi: {
inputs: [],
name: "owner",
outputs: [
{
internalType: "address",
name: "",
type: "address",
},
],
stateMutability: "view",
type: "function",
},
target: target,
block: chainBlocks?.[chain],
chain: chain,
})
).output;
let bridgedTotalFunction = await sumMultipleBalanceFunctions(
[
bridgedSupply("polygon", 18, chainContracts.polygon.bridgedFromETH),
bridgedSupplySubtractReserve("avax", 18, [
chainContracts.avax.bridgedFromETH[0],
chainContracts.avax.reserves,
]),
bridgedSupplySubtractReserve("arbitrum", 18, [
chainContracts.arbitrum.bridgedFromETH[0],
chainContracts.arbitrum.reserves,
]),
bridgedSupplySubtractReserve("fantom", 18, [
chainContracts.fantom.bridgedFromETH[0],
chainContracts.fantom.reserves,
]),
bridgedSupplySubtractReserve("bsc", 18, [
chainContracts.bsc.bridgedFromETH[0],
chainContracts.bsc.reserves,
]),
bridgedSupplySubtractReserve("moonriver", 18, [
chainContracts.moonriver.bridgedFromETH[0],
chainContracts.moonriver.reserves,
]),
bridgedSupply("boba", 18, chainContracts.boba.bridgedFromETH),
bridgedSupply("metis", 18, chainContracts.metis.bridgedFromETH),
],
"peggedUSD"
);
balances = await bridgedTotalFunction(_timestamp, _ethBlock, _chainBlocks);
balances["peggedUSD"] = -balances["peggedUSD"];
for (let reserve of reserves) {
const balance = (
await sdk.api.erc20.balanceOf({
target: chainContracts.ethereum.issued[0],
owner: reserve,
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", balance / 10 ** decimals);
}
const bridged = (
await sdk.api.erc20.balanceOf({
target: chainContracts.ethereum.issued[0],
owner: chainContracts.ethereum.multichain[0],
block: _chainBlocks?.[chain],
chain: chain,
})
).output;
sumSingleBalance(balances, "peggedUSD", bridged / 10 ** decimals);
return balances;
};
return owner;
}
async function bentoboxBalanceAmountOf(
bentoboxAddress: Address,
token: Address,
accountAddress: Address,
roundUp: boolean,
chain: string,
chainBlocks?: ChainBlocks
): Promise<number> {
const shares = (
await sdk.api.abi.call({
abi: BENTOBOX_ABI.find(
(abi) => abi.type === "function" && abi.name === "balanceOf"
),
target: bentoboxAddress,
params: [token, accountAddress],
block: chainBlocks?.[chain],
chain: chain,
})
).output;
const amount = (
await sdk.api.abi.call({
abi: BENTOBOX_ABI.find(
(abi) => abi.type === "function" && abi.name === "toAmount"
),
target: bentoboxAddress,
params: [token, shares, roundUp],
block: chainBlocks?.[chain],
chain: chain,
})
).output;
return amount;
}
async function balanceOfCauldron(
chain: string,
cauldronAddress: Address,
token: Address,
chainBlocks?: ChainBlocks
): Promise<number> {
const bentoboxAddress = (
await sdk.api.abi.call({
abi: CAULDRON_V1_ABI.find(
(abi) => abi.type === "function" && abi.name === "bentoBox"
),
target: cauldronAddress,
block: chainBlocks?.[chain],
chain: chain,
})
).output;
return bentoboxBalanceAmountOf(
bentoboxAddress,
token,
cauldronAddress,
true,
chain
);
}
const bridgedAdapter: PeggedIssuanceAdapter = Object.fromEntries(
Object.entries(bridgedChainContracts).map(([chain, chainContract]) => [
chain,
{
minted: async () => ({}),
ethereum: chainReleased(chain, chainContract.address, 18, true),
unreleased: chainUnreleased(chain, chainContract, 18, true),
},
])
);
const adapter: PeggedIssuanceAdapter = {
ethereum: {
minted: chainMinted("ethereum", 18),
unreleased: ethereumUnreleased(
"ethereum",
18,
chainContracts.ethereum.reserves
),
minted: chainReleased("ethereum", ethereumChainContract.address, 18, false),
unreleased: chainUnreleased("ethereum", ethereumChainContract, 18, false),
},
polygon: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupply(
"polygon",
18,
chainContracts.polygon.bridgedFromETH
),
},
avalanche: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupplySubtractReserve("avax", 18, [
chainContracts.avax.bridgedFromETH[0],
chainContracts.avax.reserves,
]),
},
arbitrum: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupplySubtractReserve("arbitrum", 18, [
chainContracts.arbitrum.bridgedFromETH[0],
chainContracts.arbitrum.reserves,
]),
},
fantom: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupplySubtractReserve("fantom", 18, [
chainContracts.fantom.bridgedFromETH[0],
chainContracts.fantom.reserves,
]),
},
bsc: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupplySubtractReserve("bsc", 18, [
chainContracts.bsc.bridgedFromETH[0],
chainContracts.bsc.reserves,
]),
},
moonriver: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupplySubtractReserve("moonriver", 18, [
chainContracts.moonriver.bridgedFromETH[0],
chainContracts.moonriver.reserves,
]),
},
boba: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupply("boba", 18, chainContracts.boba.bridgedFromETH),
},
metis: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupply("metis", 18, chainContracts.metis.bridgedFromETH),
},
optimism: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: bridgedSupply("optimism", 18, chainContracts.optimism.bridgedFromETH),
},
/* This appears not to be accessible anymore, so not adding it.
terra: {
minted: async () => ({}),
unreleased: async () => ({}),
ethereum: terraSupply(chainContracts.terra.bridgedFromETH, 8),
},
*/
...bridgedAdapter,
};
export default adapter;

View File

@@ -123,18 +123,10 @@ export default {
bridge: "multichain",
sourceChain: formattedSourceChains.terra,
},
"0x44Dd7C98885cD3086E723B8554a90c9cC4089C4C": {
bridge: "multichain",
sourceChain: formattedSourceChains.eth,
},
"0x218c3c3D49d0E7B37aff0D8bB079de36Ae61A4c0": {
bridge: "multichain",
sourceChain: formattedSourceChains.bsc,
},
"0x0cae51e1032e8461f4806e26332c030e34de3adb": {
bridge: "multichain",
sourceChain: formattedSourceChains.eth,
},
FR87nWEUxVgerFGhZM8Y4AggKGLnaXswr1Pd8wZ4kZcp: {
bridge: "multichain",
sourceChain: formattedSourceChains.eth,
@@ -503,14 +495,6 @@ export default {
bridge: "wormhole",
sourceChain: formattedSourceChains.terra,
},
Terra15a9dr3a2a2lj5fclrw35xxg9yuxg0d908wpf2y: {
bridge: "wormhole",
sourceChain: formattedSourceChains.eth,
},
HRQke5DKdDo3jV7wnomyiM8AA3EzkVnxMDdo2FQ5XUe1: {
bridge: "wormhole",
sourceChain: formattedSourceChains.eth,
},
"0x362233F1eF554Ca08555Ca191b4887c2C3132834": {
bridge: "wormhole",
sourceChain: formattedSourceChains.eth,
@@ -843,10 +827,6 @@ export default {
bridge: "allbridge",
sourceChain: formattedSourceChains.ftm,
},
CYEFQXzQM6E5P8ZrXgS7XMSwU3CiqHMMyACX4zuaA2Z4: {
bridge: "allbridge",
sourceChain: formattedSourceChains.eth,
},
A96PoNcxa9LMxcF9HhKAfA1p3M1dGbubPMWf19gHAkgJ: {
bridge: "allbridge",
sourceChain: formattedSourceChains.terra,
@@ -1403,15 +1383,15 @@ export default {
bridge: "aztec",
sourceChain: formattedSourceChains.eth,
},
"0x49a0400587A7F65072c87c4910449fDcC5c47242": {
"0xb153fb3d196a8eb25522705560ac152eeec57901": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0x130966628846BFd36ff31a822705796e8cb8C18D": {
"0xfe19f0b51438fd612f6fd59c1dbb3ea319f433ba": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a": {
"0x49a0400587a7f65072c87c4910449fdcc5c47242": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
@@ -1419,7 +1399,23 @@ export default {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0xfe19f0b51438fd612f6fd59c1dbb3ea319f433ba": {
"0x0cae51e1032e8461f4806e26332c030e34de3adb": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0x130966628846bfd36ff31a822705796e8cb8c18d": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0x471ee749ba270eb4c1165b5ad95e614947f6fceb": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},
"0x4a3a6dd60a34bb2aba60d73b4c88315e9ceb6a3d": {
bridge: "abracadabra",
sourceChain: formattedSourceChains.eth,
},