PWN Vault

1. Summary

Loan contracts in the PWN Protocol inherit the PWNVault.sol contract for transferring and managing assets. This is not a standalone contract.

3. Contract details

  • PWNVault.sol is written in Solidity version 0.8.16

Features

  • Transferring assets

  • Set Vault allowance for an asset

Inherited contracts, implemented Interfaces and ERCs

Functions

_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.Assetasset - The transferred asset (see MultiToken)

  • address indexedorigin

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.Assetasset - The transferred asset (see MultiToken)

  • address indexedbeneficiary

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.Assetasset - The transferred asset (see MultiToken)

  • address indexedorigin

  • address indexedbeneficiary

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.Assetasset - The transferred asset (see MultiToken)

  • address indexedorigin

  • bytes memorybeneficiary

Implementation

function _permit(MultiToken.Asset memory asset, address origin, bytes memory permit) internal {
    if (permit.length > 0)
        asset.permit(origin, address(this), permit);
}

Events

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.Assetasset - The transferred asset (see MultiToken)

  • address indexedorigin

VaultPush

VaultPush event is emitted when a transfer happens from the vault to the beneficiary.

This event has two parameters:

  • MultiToken.Assetasset - The transferred asset (see MultiToken)

  • address indexedbeneficiary

VaultPushFrom

VaultPushFrom event is emitted when a transfer happens from the origin to the beneficiary.

This event has three parameters:

  • MultiToken.Assetasset - The transferred asset (see MultiToken)

  • address indexedorigin

  • address indexedbeneficiary

Last updated