diff --git a/abis/PendleMarketV3.ts b/abis/PendleMarketV3.ts deleted file mode 100644 index d325dbe..0000000 --- a/abis/PendleMarketV3.ts +++ /dev/null @@ -1,453 +0,0 @@ -const PendleMarketV3Abi = [ - { - inputs: [ - { internalType: "address", name: "_PT", type: "address" }, - { internalType: "int256", name: "_scalarRoot", type: "int256" }, - { internalType: "int256", name: "_initialAnchor", type: "int256" }, - { internalType: "uint80", name: "_lnFeeRateRoot", type: "uint80" }, - { internalType: "address", name: "_vePendle", type: "address" }, - { internalType: "address", name: "_gaugeController", type: "address" }, - ], - stateMutability: "nonpayable", - type: "constructor", - }, - { - inputs: [{ internalType: "int256", name: "exchangeRate", type: "int256" }], - name: "MarketExchangeRateBelowOne", - type: "error", - }, - { inputs: [], name: "MarketExpired", type: "error" }, - { - inputs: [ - { internalType: "int256", name: "currentAmount", type: "int256" }, - { internalType: "int256", name: "requiredAmount", type: "int256" }, - ], - name: "MarketInsufficientPtForTrade", - type: "error", - }, - { - inputs: [ - { internalType: "uint256", name: "actualBalance", type: "uint256" }, - { internalType: "uint256", name: "requiredBalance", type: "uint256" }, - ], - name: "MarketInsufficientPtReceived", - type: "error", - }, - { - inputs: [ - { internalType: "uint256", name: "actualBalance", type: "uint256" }, - { internalType: "uint256", name: "requiredBalance", type: "uint256" }, - ], - name: "MarketInsufficientSyReceived", - type: "error", - }, - { inputs: [], name: "MarketProportionMustNotEqualOne", type: "error" }, - { - inputs: [ - { internalType: "int256", name: "proportion", type: "int256" }, - { internalType: "int256", name: "maxProportion", type: "int256" }, - ], - name: "MarketProportionTooHigh", - type: "error", - }, - { - inputs: [{ internalType: "int256", name: "rateScalar", type: "int256" }], - name: "MarketRateScalarBelowZero", - type: "error", - }, - { - inputs: [{ internalType: "int256", name: "scalarRoot", type: "int256" }], - name: "MarketScalarRootBelowZero", - type: "error", - }, - { inputs: [], name: "MarketZeroAmountsInput", type: "error" }, - { inputs: [], name: "MarketZeroAmountsOutput", type: "error" }, - { inputs: [], name: "MarketZeroLnImpliedRate", type: "error" }, - { - inputs: [ - { internalType: "int256", name: "totalPt", type: "int256" }, - { internalType: "int256", name: "totalAsset", type: "int256" }, - ], - name: "MarketZeroTotalPtOrTotalAsset", - type: "error", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "owner", type: "address" }, - { indexed: true, internalType: "address", name: "spender", type: "address" }, - { indexed: false, internalType: "uint256", name: "value", type: "uint256" }, - ], - name: "Approval", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "receiverSy", type: "address" }, - { indexed: true, internalType: "address", name: "receiverPt", type: "address" }, - { indexed: false, internalType: "uint256", name: "netLpBurned", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "netSyOut", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "netPtOut", type: "uint256" }, - ], - name: "Burn", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: false, internalType: "uint16", name: "observationCardinalityNextOld", type: "uint16" }, - { indexed: false, internalType: "uint16", name: "observationCardinalityNextNew", type: "uint16" }, - ], - name: "IncreaseObservationCardinalityNext", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "receiver", type: "address" }, - { indexed: false, internalType: "uint256", name: "netLpMinted", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "netSyUsed", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "netPtUsed", type: "uint256" }, - ], - name: "Mint", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "user", type: "address" }, - { indexed: false, internalType: "uint256[]", name: "rewardsOut", type: "uint256[]" }, - ], - name: "RedeemRewards", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "caller", type: "address" }, - { indexed: true, internalType: "address", name: "receiver", type: "address" }, - { indexed: false, internalType: "int256", name: "netPtOut", type: "int256" }, - { indexed: false, internalType: "int256", name: "netSyOut", type: "int256" }, - { indexed: false, internalType: "uint256", name: "netSyFee", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "netSyToReserve", type: "uint256" }, - ], - name: "Swap", - 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: "value", type: "uint256" }, - ], - name: "Transfer", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "uint256", name: "timestamp", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "lnLastImpliedRate", type: "uint256" }, - ], - name: "UpdateImpliedRate", - type: "event", - }, - { - inputs: [], - name: "_storage", - outputs: [ - { internalType: "int128", name: "totalPt", type: "int128" }, - { internalType: "int128", name: "totalSy", type: "int128" }, - { internalType: "uint96", name: "lastLnImpliedRate", type: "uint96" }, - { internalType: "uint16", name: "observationIndex", type: "uint16" }, - { internalType: "uint16", name: "observationCardinality", type: "uint16" }, - { internalType: "uint16", name: "observationCardinalityNext", type: "uint16" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "activeBalance", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "owner", type: "address" }, - { internalType: "address", name: "spender", type: "address" }, - ], - name: "allowance", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "spender", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "approve", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "account", type: "address" }], - name: "balanceOf", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "receiverSy", type: "address" }, - { internalType: "address", name: "receiverPt", type: "address" }, - { internalType: "uint256", name: "netLpToBurn", type: "uint256" }, - ], - name: "burn", - outputs: [ - { internalType: "uint256", name: "netSyOut", type: "uint256" }, - { internalType: "uint256", name: "netPtOut", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [{ internalType: "uint8", name: "", type: "uint8" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "expiry", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "factory", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getNonOverrideLnFeeRateRoot", - outputs: [{ internalType: "uint80", name: "", type: "uint80" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getRewardTokens", - outputs: [{ internalType: "address[]", name: "", type: "address[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "uint16", name: "cardinalityNext", type: "uint16" }], - name: "increaseObservationsCardinalityNext", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "isExpired", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "lastRewardBlock", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "receiver", type: "address" }, - { internalType: "uint256", name: "netSyDesired", type: "uint256" }, - { internalType: "uint256", name: "netPtDesired", type: "uint256" }, - ], - name: "mint", - outputs: [ - { internalType: "uint256", name: "netLpOut", type: "uint256" }, - { internalType: "uint256", name: "netSyUsed", type: "uint256" }, - { internalType: "uint256", name: "netPtUsed", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "name", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "uint256", name: "", type: "uint256" }], - name: "observations", - outputs: [ - { internalType: "uint32", name: "blockTimestamp", type: "uint32" }, - { internalType: "uint216", name: "lnImpliedRateCumulative", type: "uint216" }, - { internalType: "bool", name: "initialized", type: "bool" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "uint32[]", name: "secondsAgos", type: "uint32[]" }], - name: "observe", - outputs: [{ internalType: "uint216[]", name: "lnImpliedRateCumulative", type: "uint216[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "router", type: "address" }], - name: "readState", - outputs: [ - { - components: [ - { internalType: "int256", name: "totalPt", type: "int256" }, - { internalType: "int256", name: "totalSy", type: "int256" }, - { internalType: "int256", name: "totalLp", type: "int256" }, - { internalType: "address", name: "treasury", type: "address" }, - { internalType: "int256", name: "scalarRoot", type: "int256" }, - { internalType: "uint256", name: "expiry", type: "uint256" }, - { internalType: "uint256", name: "lnFeeRateRoot", type: "uint256" }, - { internalType: "uint256", name: "reserveFeePercent", type: "uint256" }, - { internalType: "uint256", name: "lastLnImpliedRate", type: "uint256" }, - ], - internalType: "struct MarketState", - name: "market", - type: "tuple", - }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "readTokens", - outputs: [ - { internalType: "contract IStandardizedYield", name: "_SY", type: "address" }, - { internalType: "contract IPPrincipalToken", name: "_PT", type: "address" }, - { internalType: "contract IPYieldToken", name: "_YT", type: "address" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "user", type: "address" }], - name: "redeemRewards", - outputs: [{ internalType: "uint256[]", name: "", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "rewardState", - outputs: [ - { internalType: "uint128", name: "index", type: "uint128" }, - { internalType: "uint128", name: "lastBalance", type: "uint128" }, - ], - stateMutability: "view", - type: "function", - }, - { inputs: [], name: "skim", outputs: [], stateMutability: "nonpayable", type: "function" }, - { - inputs: [ - { internalType: "address", name: "receiver", type: "address" }, - { internalType: "uint256", name: "exactPtIn", type: "uint256" }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "swapExactPtForSy", - outputs: [ - { internalType: "uint256", name: "netSyOut", type: "uint256" }, - { internalType: "uint256", name: "netSyFee", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "receiver", type: "address" }, - { internalType: "uint256", name: "exactPtOut", type: "uint256" }, - { internalType: "bytes", name: "data", type: "bytes" }, - ], - name: "swapSyForExactPt", - outputs: [ - { internalType: "uint256", name: "netSyIn", type: "uint256" }, - { internalType: "uint256", name: "netSyFee", type: "uint256" }, - ], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "symbol", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalActiveSupply", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalSupply", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "transfer", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "from", type: "address" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "", type: "address" }, - { internalType: "address", name: "", type: "address" }, - ], - name: "userReward", - outputs: [ - { internalType: "uint128", name: "index", type: "uint128" }, - { internalType: "uint128", name: "accrued", type: "uint128" }, - ], - stateMutability: "view", - type: "function", - }, -] as const; - -export default PendleMarketV3Abi; \ No newline at end of file diff --git a/abis/PendleSy.ts b/abis/PendleSy.ts deleted file mode 100644 index 76f9578..0000000 --- a/abis/PendleSy.ts +++ /dev/null @@ -1,406 +0,0 @@ -const PendleSyAbi = [ - { inputs: [], stateMutability: "nonpayable", type: "constructor" }, - { - inputs: [ - { internalType: "uint256", name: "actualSharesOut", type: "uint256" }, - { internalType: "uint256", name: "requiredSharesOut", type: "uint256" }, - ], - name: "SYInsufficientSharesOut", - type: "error", - }, - { - inputs: [ - { internalType: "uint256", name: "actualTokenOut", type: "uint256" }, - { internalType: "uint256", name: "requiredTokenOut", type: "uint256" }, - ], - name: "SYInsufficientTokenOut", - type: "error", - }, - { inputs: [{ internalType: "address", name: "token", type: "address" }], name: "SYInvalidTokenIn", type: "error" }, - { inputs: [{ internalType: "address", name: "token", type: "address" }], name: "SYInvalidTokenOut", type: "error" }, - { inputs: [], name: "SYZeroDeposit", type: "error" }, - { inputs: [], name: "SYZeroRedeem", type: "error" }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "owner", type: "address" }, - { indexed: true, internalType: "address", name: "spender", type: "address" }, - { indexed: false, internalType: "uint256", name: "value", type: "uint256" }, - ], - name: "Approval", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "user", type: "address" }, - { indexed: false, internalType: "address[]", name: "rewardTokens", type: "address[]" }, - { indexed: false, internalType: "uint256[]", name: "rewardAmounts", type: "uint256[]" }, - ], - name: "ClaimRewards", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "caller", type: "address" }, - { indexed: true, internalType: "address", name: "receiver", type: "address" }, - { indexed: true, internalType: "address", name: "tokenIn", type: "address" }, - { indexed: false, internalType: "uint256", name: "amountDeposited", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "amountSyOut", type: "uint256" }, - ], - name: "Deposit", - type: "event", - }, - { anonymous: false, inputs: [], name: "EIP712DomainChanged", type: "event" }, - { - anonymous: false, - inputs: [{ indexed: false, internalType: "uint8", name: "version", type: "uint8" }], - name: "Initialized", - 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: false, internalType: "address", name: "account", type: "address" }], - name: "Paused", - type: "event", - }, - { - anonymous: false, - inputs: [ - { indexed: true, internalType: "address", name: "caller", type: "address" }, - { indexed: true, internalType: "address", name: "receiver", type: "address" }, - { indexed: true, internalType: "address", name: "tokenOut", type: "address" }, - { indexed: false, internalType: "uint256", name: "amountSyToRedeem", type: "uint256" }, - { indexed: false, internalType: "uint256", name: "amountTokenOut", type: "uint256" }, - ], - name: "Redeem", - 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: "value", type: "uint256" }, - ], - name: "Transfer", - type: "event", - }, - { - anonymous: false, - inputs: [{ indexed: false, internalType: "address", name: "account", type: "address" }], - name: "Unpaused", - type: "event", - }, - { - inputs: [], - name: "DOMAIN_SEPARATOR", - outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "accruedRewards", - outputs: [{ internalType: "uint256[]", name: "rewardAmounts", type: "uint256[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "owner", type: "address" }, - { internalType: "address", name: "spender", type: "address" }, - ], - name: "allowance", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "spender", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "approve", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "assetInfo", - outputs: [ - { internalType: "enum IStandardizedYield.AssetType", name: "assetType", type: "uint8" }, - { internalType: "address", name: "assetAddress", type: "address" }, - { internalType: "uint8", name: "assetDecimals", type: "uint8" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "account", type: "address" }], - name: "balanceOf", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { inputs: [], name: "claimOwnership", outputs: [], stateMutability: "nonpayable", type: "function" }, - { - inputs: [{ internalType: "address", name: "", type: "address" }], - name: "claimRewards", - outputs: [{ internalType: "uint256[]", name: "rewardAmounts", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "decimals", - outputs: [{ internalType: "uint8", name: "", type: "uint8" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "receiver", type: "address" }, - { internalType: "address", name: "tokenIn", type: "address" }, - { internalType: "uint256", name: "amountTokenToDeposit", type: "uint256" }, - { internalType: "uint256", name: "minSharesOut", type: "uint256" }, - ], - name: "deposit", - outputs: [{ internalType: "uint256", name: "amountSharesOut", type: "uint256" }], - stateMutability: "payable", - type: "function", - }, - { - inputs: [], - name: "eip712Domain", - outputs: [ - { internalType: "bytes1", name: "fields", type: "bytes1" }, - { internalType: "string", name: "name", type: "string" }, - { internalType: "string", name: "version", type: "string" }, - { internalType: "uint256", name: "chainId", type: "uint256" }, - { internalType: "address", name: "verifyingContract", type: "address" }, - { internalType: "bytes32", name: "salt", type: "bytes32" }, - { internalType: "uint256[]", name: "extensions", type: "uint256[]" }, - ], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "exchangeRate", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getRewardTokens", - outputs: [{ internalType: "address[]", name: "rewardTokens", type: "address[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getTokensIn", - outputs: [{ internalType: "address[]", name: "res", type: "address[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "getTokensOut", - outputs: [{ internalType: "address[]", name: "res", type: "address[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "string", name: "_name", type: "string" }, - { internalType: "string", name: "_symbol", type: "string" }, - ], - name: "initialize", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "token", type: "address" }], - name: "isValidTokenIn", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "token", type: "address" }], - name: "isValidTokenOut", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "name", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [{ internalType: "address", name: "owner", 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: "pause", outputs: [], stateMutability: "nonpayable", type: "function" }, - { - inputs: [], - name: "paused", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "pendingOwner", - outputs: [{ internalType: "address", name: "", type: "address" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "owner", type: "address" }, - { internalType: "address", name: "spender", type: "address" }, - { internalType: "uint256", name: "value", 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: "permit", - outputs: [], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "tokenIn", type: "address" }, - { internalType: "uint256", name: "amountTokenToDeposit", type: "uint256" }, - ], - name: "previewDeposit", - outputs: [{ internalType: "uint256", name: "amountSharesOut", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "tokenOut", type: "address" }, - { internalType: "uint256", name: "amountSharesToRedeem", type: "uint256" }, - ], - name: "previewRedeem", - outputs: [{ internalType: "uint256", name: "amountTokenOut", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "receiver", type: "address" }, - { internalType: "uint256", name: "amountSharesToRedeem", type: "uint256" }, - { internalType: "address", name: "tokenOut", type: "address" }, - { internalType: "uint256", name: "minTokenOut", type: "uint256" }, - { internalType: "bool", name: "burnFromInternalBalance", type: "bool" }, - ], - name: "redeem", - outputs: [{ internalType: "uint256", name: "amountTokenOut", type: "uint256" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "rewardIndexesCurrent", - outputs: [{ internalType: "uint256[]", name: "indexes", type: "uint256[]" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [], - name: "rewardIndexesStored", - outputs: [{ internalType: "uint256[]", name: "indexes", type: "uint256[]" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "symbol", - outputs: [{ internalType: "string", name: "", type: "string" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [], - name: "totalSupply", - outputs: [{ internalType: "uint256", name: "", type: "uint256" }], - stateMutability: "view", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "transfer", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - stateMutability: "nonpayable", - type: "function", - }, - { - inputs: [ - { internalType: "address", name: "from", type: "address" }, - { internalType: "address", name: "to", type: "address" }, - { internalType: "uint256", name: "amount", type: "uint256" }, - ], - name: "transferFrom", - outputs: [{ internalType: "bool", name: "", type: "bool" }], - 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: [], name: "unpause", outputs: [], stateMutability: "nonpayable", type: "function" }, - { - inputs: [], - name: "yieldToken", - outputs: [{ internalType: "address", name: "yieldToken", type: "address" }], - stateMutability: "view", - type: "function", - }, - { stateMutability: "payable", type: "receive" }, -]; - -export default PendleSyAbi; \ No newline at end of file diff --git a/src/services/routing/getSwapParams.ts b/src/services/routing/getSwapParams.ts index 0fa7419..b3a44bb 100644 --- a/src/services/routing/getSwapParams.ts +++ b/src/services/routing/getSwapParams.ts @@ -17,6 +17,8 @@ import { getBalmyQuote, prepareBalmySwapCalldata } from "./balmy"; import { CHAIN_ID } from "../../constants/chain"; import { CONTRACT_ADDRESSES } from "../../constants/contracts"; +export const NoQuotesError = new Error('No quotes found'); + const logger = createComponentLogger('getRebalanceSwapParams'); export const getRebalanceSwapParams = async ( @@ -93,7 +95,7 @@ export const getDexSwapParams = async ( ]); if (!balmyQuote && !uniswapV2Quote && !uniswapV3Route && !fluidDexRoute && !pendleQuote) { - throw new Error('No quotes found'); + throw NoQuotesError; } // Find the best route by comparing all three options diff --git a/src/services/routing/pendle.ts b/src/services/routing/pendle.ts index c1a1e7f..f4fdabe 100644 --- a/src/services/routing/pendle.ts +++ b/src/services/routing/pendle.ts @@ -6,10 +6,7 @@ import { Call, GetPendleSwapQuoteInput, GetPendleSwapQuoteOutput, StakeType, Get import { getPendleStaticRouterContract } from "../../utils/contractHelpers"; import { getDexSwapParams } from "./getSwapParams"; import PendleRouterAbi from "../../../abis/PendleRouter"; -import PendleMarketV3Abi from "../../../abis/PendleMarketV3"; -import PendleSyAbi from "../../../abis/PendleSy"; import { getTokenDecimals } from "../../utils/tokens"; -import { publicClient } from "../../utils/transactionHelpers"; import { getDexSlippageAdjustedAmount } from "../../utils/math"; import { DEX_SLIPPAGE_BPS } from "../../constants/values"; @@ -22,8 +19,6 @@ const PT_TO_PENDLE_MARKET = new Map([ ], ]); -const PENDLE_MARKET_TO_YIELD_TOKEN = new Map(); - export const getPendleSwapQuote = async ( args: GetPendleSwapQuoteInput, logger: ComponentLogger @@ -66,8 +61,6 @@ const getPendleSwapExactPtForTokenQuote = async ( return null; } - PENDLE_MARKET_TO_YIELD_TOKEN.set(market, yieldToken); - const isToTokenYieldToken = isAddressEqual(toAsset, yieldToken); const ptDecimals = (await getTokenDecimals([pt]))[pt]; @@ -149,26 +142,8 @@ const getPendleSwapExactTokenForPtQuote = async ( logger.dexQuoteError({ pt }, "No Pendle market found for PT"); return null; } - - let yieldToken = PENDLE_MARKET_TO_YIELD_TOKEN.get(getAddress(market)); - if (!yieldToken) { - try { - const [syToken,,] = await publicClient.readContract({ - address: market, - abi: PendleMarketV3Abi, - functionName: "readTokens", - }); - yieldToken = (await publicClient.readContract({ - address: syToken, - abi: PendleSyAbi, - functionName: "yieldToken", - })) as Address; - PENDLE_MARKET_TO_YIELD_TOKEN.set(market, yieldToken); - } catch (error) { - logger.error({ error, pt, market }, "Error getting Pendle yield token"); - throw error; - } - } + const staticRouter = getPendleStaticRouterContract(); + const [yieldToken, , yieldTokenRate] = await staticRouter.read.getYieldTokenAndPtRate([market]); const isFromTokenYieldToken = isAddressEqual(getAddress(fromAsset), getAddress(yieldToken)); @@ -196,17 +171,19 @@ const getPendleSwapExactTokenForPtQuote = async ( underlyingAmountInForPt = underlyingSwapData.minAmountOut; } - const staticRouter = getPendleStaticRouterContract(); - const pendleSlippage = DEX_SLIPPAGE_BPS * 100000000000000n; - const result = await staticRouter.read.swapExactTokenForPtStaticAndGenerateApproxParams([ - market, - yieldToken, - underlyingAmountInForPt, - pendleSlippage, - ]); - const guessPtOut = result[5]; - - const approxParams = guessPtOut; + const ptDecimals = (await getTokenDecimals([pt]))[pt]; + const ptAmountOut = (underlyingAmountInForPt * 10n ** BigInt(ptDecimals)) / yieldTokenRate; + const ptAmountOutWithSlippageDown = getDexSlippageAdjustedAmount(ptAmountOut); + const ptAmountOutWithSlippageUp = ptAmountOut * (10000n + DEX_SLIPPAGE_BPS) / 10000n; + + const approxParams = { + guessMin: ptAmountOutWithSlippageDown, + guessMax: ptAmountOutWithSlippageUp, + guessOffchain: ptAmountOut, + maxIteration: 256n, + eps: DEX_SLIPPAGE_BPS * 100000000000000n, + }; + const tokenInput = createTokenInputSimple(yieldToken, underlyingAmountInForPt); const emptyLimit = createEmptyLimitOrderData(); const calldata = encodeFunctionData({ @@ -223,8 +200,8 @@ const getPendleSwapExactTokenForPtQuote = async ( }); return { - amountOut: guessPtOut.guessOffchain, - minAmountOut: guessPtOut.guessMin, + amountOut: ptAmountOut, + minAmountOut: ptAmountOutWithSlippageDown, pendleSwapData: { amountIn: underlyingAmountInForPt, assetIn: yieldToken, diff --git a/src/subscribers/auctionCreated.ts b/src/subscribers/auctionCreated.ts index f69ca79..bad0df6 100644 --- a/src/subscribers/auctionCreated.ts +++ b/src/subscribers/auctionCreated.ts @@ -39,7 +39,7 @@ import { getLeverageTokenRebalanceAdapter, leverageManagerContract, } from "../utils/contractHelpers"; -import { getRebalanceSwapParams } from "../services/routing/getSwapParams"; +import { getRebalanceSwapParams, NoQuotesError } from "../services/routing/getSwapParams"; import { GetRebalanceSwapParamsOutput, LeverageToken, LogLevel, RebalanceType, StakeType } from "../types"; import { readJsonArrayFromFile } from "../utils/fileHelpers"; import { tenderlySimulateTransaction } from "../utils/tenderly"; @@ -244,17 +244,26 @@ export const handleAuctionCreatedEvent = async ( continue; } - const swapParams = await getRebalanceSwapParams({ - leverageToken, - stakeType, - receiver: CONTRACT_ADDRESSES[CHAIN_ID].DUTCH_AUCTION_REBALANCER, - assetIn, - assetOut, - takeAmount, - requiredAmountIn, - collateralAsset, - debtAsset, - }); + let swapParams: GetRebalanceSwapParamsOutput; + try { + swapParams = await getRebalanceSwapParams({ + leverageToken, + stakeType, + receiver: CONTRACT_ADDRESSES[CHAIN_ID].DUTCH_AUCTION_REBALANCER, + assetIn, + assetOut, + takeAmount, + requiredAmountIn, + collateralAsset, + debtAsset, + }); + } catch (error) { + if (error === NoQuotesError) { + handleAuctionLogger.error({ leverageToken }, "No quotes found, skipping step"); + continue; + } + throw error; + } if (!swapParams.isProfitable) { handleAuctionLogger.debug({