Loan contracts in the PWN Protocol inherit the PWNVault.sol contract for transferring and managing assets. This is not a standalone contract.
Inherited contracts, implemented Interfaces and ERCs
_pull
Overview
Takes a supplied asset and pulls it into the vault from the origin.
This function assumes a prior token approval was made to the vault address.
This function takes two arguments supplied by the caller:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
Implementation
function _pull(MultiToken.Asset memory asset, address origin) internal {
uint256 originalBalance = asset.balanceOf(address(this));
asset.transferAssetFrom(origin, address(this));
_checkTransfer(asset, originalBalance, address(this));
emit VaultPull(asset, origin);
}
_push
Overview
Pushes a supplied asset from the vault to the beneficiary.
This function takes two arguments supplied by the caller:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
address indexed
beneficiary
Implementation
function _push(MultiToken.Asset memory asset, address beneficiary) internal {
uint256 originalBalance = asset.balanceOf(beneficiary);
asset.safeTransferAssetFrom(address(this), beneficiary);
_checkTransfer(asset, originalBalance, beneficiary);
emit VaultPush(asset, beneficiary);
}
_pushFrom
Overview
Pushes a supplied asset from the origin to the beneficiary.
This function assumes a prior token approval was made to the vault address.
This function takes three arguments supplied by the caller:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
address indexed
beneficiary
Implementation
function _pushFrom(MultiToken.Asset memory asset, address origin, address beneficiary) internal {
uint256 originalBalance = asset.balanceOf(beneficiary);
asset.safeTransferAssetFrom(origin, beneficiary);
_checkTransfer(asset, originalBalance, beneficiary);
emit VaultPushFrom(asset, origin, beneficiary);
}
_permit
Overview
Uses signed permit data to set the vault allowance for an asset.
This function takes three arguments supplied by the caller:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
Implementation
function _permit(MultiToken.Asset memory asset, address origin, bytes memory permit) internal {
if (permit.length > 0)
asset.permit(origin, address(this), permit);
}
The PWN Vault contract defines one event and no custom errors.
event VaultPull(MultiToken.Asset asset, address indexed origin);
event VaultPush(MultiToken.Asset asset, address indexed beneficiary);
event VaultPushFrom(MultiToken.Asset asset, address indexed origin, address indexed beneficiary);
VaultPull
VaultPull event is emitted when a transfer happens from the origin
to the vault.
This event has two parameters:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
VaultPush
VaultPush event is emitted when a transfer happens from the vault to the beneficiary
.
This event has two parameters:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
address indexed
beneficiary
VaultPushFrom
VaultPushFrom event is emitted when a transfer happens from the origin
to the beneficiary
.
This event has three parameters:
MultiToken.Asset
asset
- The transferred asset (see MultiToken)
address indexed
beneficiary