All contracts are forked from the PieDao deployment on the Ethereum Mainnet, with some minor changes that allow them to function on Polygon.
These changes are detailed below.
In order to understand the smart contract setup and query the nests correctly, you will have to familiarize yourself with the Diamond Standard architecture, with which these contracts were built https://eips.ethereum.org/EIPS/eip-2535.
Contract Changes
The original contracts deployed by PieDao can be found here:
https://docs.piedao.org/technical/deployed-smart-contracts
The contracts were ported as-is from the PieDaos implementation on Main net with a few exceptions: On the Polygon network, the Aave protocol requires the sender to state the address where the amTokens or underlying tokens should be sent when depositing or withdrawing. This required small changes in the following contracts:
ILendingLogic.sol
The contracts listed above do not have any access to the funds that are held by the nest. Worst case scenario, errors in these contracts would result in the user minting a wrong amount of a nest or the user would fail to mint the nest.
LendingManger.sol
Changing the LendingManager requires increased vigilance, as it has direct access to the Nests funds. This is the only change made to the LendingManager:
The basket address is the address of the nest that the LendingManager is assigned to.
The "Recipe" contract is used to swap the user's wETH for the index assets and lend them in a specific protocol when needed. As the recipe does not have access to any funds deposited in the index, we felt like more liberties could be made adjusting the code. The following is a change that allows us to take an entry fee that is exchanged for Polly and then burned:
Originally the recipe always looks at Uniswap and SushiSwap to identify the best price. The new Recipe does not check the prices and only trades on SushiSwap.