Aave V4 Giver and Taker Position Manager write wrappers, plus Taker allowances.
V4 has no Pool. Supply and repay go through the Giver Position Manager
(:v4_giver_position_manager); borrow and withdraw go through the Taker
(:v4_taker_position_manager). Reserves are addressed by a Spoke-scoped
reserve_id (from Onchain.Aave.V4.Spoke), not by asset address.
Every *OnBehalfOf and allowance-gated entrypoint takes the position owner
as an explicit required argument. The wrappers never default the owner to
the signer address. approve_borrow/5 and approve_withdraw/5 have no
owner argument because the on-chain functions grant allowance from
msg.sender.
Error Format
| Source | Error Shape |
|---|---|
Onchain.Address.validate/1 | {:error, {:invalid_address, input}} |
| Amount / reserve id | {:error, {:invalid_amount, input}}, {:error, {:invalid_reserve_id, input}} |
Onchain.Aave.Contracts.address/2 | {:error, {:unsupported_network, network}}, {:error, {:unknown_contract, key}} |
| Taker allowance reverts | {:error, {:insufficient_borrow_allowance, allowance, required}}, {:error, {:insufficient_withdraw_allowance, allowance, required}} |
Onchain.ABI.encode_call/2 | {:error, {:encode_error, reason}} |
Onchain.Contract.call/5 | {:error, {:rpc_error, map}}, {:error, {:decode_error, reason}} |
Onchain.Signer.send_transaction/3 | {:error, {:missing_option, ...}}, {:error, {:sign_error, ...}}, etc. |
Functions
| Function | Purpose |
|---|---|
supply/5 | Giver supplyOnBehalfOf |
repay/5 | Giver repayOnBehalfOf |
borrow/5 | Taker borrowOnBehalfOf |
withdraw/5 | Taker withdrawOnBehalfOf |
approve_borrow/5 | Taker approveBorrow |
approve_withdraw/5 | Taker approveWithdraw |
renounce_borrow_allowance/4 | Taker renounceBorrowAllowance |
renounce_withdraw_allowance/4 | Taker renounceWithdrawAllowance |
borrow_allowance/5 | Taker borrowAllowance |
withdraw_allowance/5 | Taker withdrawAllowance |
decode_revert/1 | Decode Taker allowance custom-error revert data |
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
decode_revert | 1 | Decode Taker InsufficientBorrow/WithdrawAllowance custom-error revert data. | revert_data: value |
withdraw_allowance | 5 | Read the Taker withdraw allowance a spender holds from a position owner. | spoke: value, reserve_id: value, owner: value, spender: value, opts: value |
borrow_allowance | 5 | Read the Taker borrow allowance a spender holds from a position owner. | spoke: value, reserve_id: value, owner: value, spender: value, opts: value |
renounce_withdraw_allowance | 4 | Renounce the Taker withdraw allowance granted by a position owner. | spoke: value, reserve_id: value, owner: value, opts: value |
renounce_borrow_allowance | 4 | Renounce the Taker borrow allowance granted by a position owner. | spoke: value, reserve_id: value, owner: value, opts: value |
approve_withdraw | 5 | Grant a spender Taker withdraw allowance from the signer (msg.sender) position. | spoke: value, reserve_id: value, spender: value, amount: value, opts: value |
approve_borrow | 5 | Grant a spender Taker borrow allowance from the signer (msg.sender) position. | spoke: value, reserve_id: value, spender: value, amount: value, opts: value |
withdraw | 5 | Withdraw from a Spoke reserve on behalf of a position owner via the Taker. | spoke: value, reserve_id: value, amount: value, on_behalf_of: value, opts: value |
borrow | 5 | Borrow from a Spoke reserve on behalf of a position owner via the Taker. | spoke: value, reserve_id: value, amount: value, on_behalf_of: value, opts: value |
repay | 5 | Repay a Spoke reserve debt on behalf of a position owner via the Giver. | spoke: value, reserve_id: value, amount: value, on_behalf_of: value, opts: value |
supply | 5 | Supply underlying to a Spoke reserve on behalf of a position owner via the Giver. | spoke: value, reserve_id: value, amount: value, on_behalf_of: value, opts: value |
Summary
Functions
Grant a spender Taker borrow allowance from the signer (msg.sender) position.
Grant a spender Taker withdraw allowance from the signer (msg.sender) position.
Borrow from a Spoke reserve on behalf of a position owner via the Taker.
Read the Taker borrow allowance a spender holds from a position owner.
Decode Taker InsufficientBorrow/WithdrawAllowance custom-error revert data.
Renounce the Taker borrow allowance granted by a position owner.
Renounce the Taker withdraw allowance granted by a position owner.
Repay a Spoke reserve debt on behalf of a position owner via the Giver.
Supply underlying to a Spoke reserve on behalf of a position owner via the Giver.
Withdraw from a Spoke reserve on behalf of a position owner via the Taker.
Read the Taker withdraw allowance a spender holds from a position owner.
Types
Functions
@spec approve_borrow( address(), non_neg_integer(), address(), non_neg_integer(), keyword() ) :: result(String.t())
Grant a spender Taker borrow allowance from the signer (msg.sender) position.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)spender- Address receiving (or holding) the Taker allowance (value)amount- Allowance amount;type(uint256).maxis infinite (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Allowance amount; `type(uint256).max` is infinite",
kind: :value
},
spender: %{
description: "Address receiving (or holding) the Taker allowance",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec approve_withdraw( address(), non_neg_integer(), address(), non_neg_integer(), keyword() ) :: result(String.t())
Grant a spender Taker withdraw allowance from the signer (msg.sender) position.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)spender- Address receiving (or holding) the Taker allowance (value)amount- Allowance amount;type(uint256).maxis infinite (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Allowance amount; `type(uint256).max` is infinite",
kind: :value
},
spender: %{
description: "Address receiving (or holding) the Taker allowance",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec borrow(address(), non_neg_integer(), non_neg_integer(), address(), keyword()) :: result(String.t())
Borrow from a Spoke reserve on behalf of a position owner via the Taker.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)amount- Raw integer amount in underlying token units (value)on_behalf_of- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Raw integer amount in underlying token units",
kind: :value
},
on_behalf_of: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec borrow_allowance(address(), non_neg_integer(), address(), address(), keyword()) :: result(non_neg_integer())
Read the Taker borrow allowance a spender holds from a position owner.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)owner- Position owner. Required; never defaulted to the signer (value)spender- Address receiving (or holding) the Taker allowance (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Current borrow allowance ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
owner: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
spender: %{
description: "Address receiving (or holding) the Taker allowance",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Current borrow allowance"
}
}
@spec decode_revert(String.t() | binary()) :: {:error, {:insufficient_borrow_allowance, non_neg_integer(), non_neg_integer()}} | {:error, {:insufficient_withdraw_allowance, non_neg_integer(), non_neg_integer()}} | {:error, {:unknown_revert, term()}}
Decode Taker InsufficientBorrow/WithdrawAllowance custom-error revert data.
Parameters
revert_data- 0x-prefixed hex or raw revert bytes (4-byte selector + ABI args) (value)
Returns
Tagged allowance error with (allowance, required), or unknown_revert ({:error, {:insufficient_borrow_allowance | :insufficient_withdraw_allowance, non_neg_integer(), non_neg_integer()}} | {:error, {:unknown_revert, term()}})
# descripex:contract
%{
params: %{
revert_data: %{
description: "0x-prefixed hex or raw revert bytes (4-byte selector + ABI args)",
kind: :value
}
},
returns: %{
type: "{:error, {:insufficient_borrow_allowance | :insufficient_withdraw_allowance, non_neg_integer(), non_neg_integer()}} | {:error, {:unknown_revert, term()}}",
description: "Tagged allowance error with (allowance, required), or unknown_revert"
}
}
@spec renounce_borrow_allowance(address(), non_neg_integer(), address(), keyword()) :: result(String.t())
Renounce the Taker borrow allowance granted by a position owner.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)owner- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
owner: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec renounce_withdraw_allowance(address(), non_neg_integer(), address(), keyword()) :: result(String.t())
Renounce the Taker withdraw allowance granted by a position owner.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)owner- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
owner: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec repay(address(), non_neg_integer(), non_neg_integer(), address(), keyword()) :: result(String.t())
Repay a Spoke reserve debt on behalf of a position owner via the Giver.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)amount- Raw integer amount in underlying token units (value)on_behalf_of- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Raw integer amount in underlying token units",
kind: :value
},
on_behalf_of: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec supply(address(), non_neg_integer(), non_neg_integer(), address(), keyword()) :: result(String.t())
Supply underlying to a Spoke reserve on behalf of a position owner via the Giver.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)amount- Raw integer amount in underlying token units (value)on_behalf_of- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Raw integer amount in underlying token units",
kind: :value
},
on_behalf_of: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec withdraw(address(), non_neg_integer(), non_neg_integer(), address(), keyword()) :: result(String.t())
Withdraw from a Spoke reserve on behalf of a position owner via the Taker.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)amount- Raw integer amount in underlying token units (value)on_behalf_of- Position owner. Required; never defaulted to the signer (value)opts- Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit (value)
Returns
Transaction hash hex string ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
description: "Required: :private_key, :nonce, :chain_id, :rpc_url. Optional: :network (default :ethereum), :gas_limit",
kind: :value
},
amount: %{
description: "Raw integer amount in underlying token units",
kind: :value
},
on_behalf_of: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Transaction hash hex string"
}
}
@spec withdraw_allowance( address(), non_neg_integer(), address(), address(), keyword() ) :: result(non_neg_integer())
Read the Taker withdraw allowance a spender holds from a position owner.
Parameters
spoke- Spoke contract address as 0x hex string or 20-byte binary (value)reserve_id- Spoke-local reserve identifier (not an asset address) (value)owner- Position owner. Required; never defaulted to the signer (value)spender- Address receiving (or holding) the Taker allowance (value)opts- Options: :network (default :ethereum), :rpc_url, :timeout, :block (default:[], value)
Returns
Current withdraw allowance ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
owner: %{
description: "Position owner. Required; never defaulted to the signer",
kind: :value
},
opts: %{
default: [],
description: "Options: :network (default :ethereum), :rpc_url, :timeout, :block",
kind: :value
},
spender: %{
description: "Address receiving (or holding) the Taker allowance",
kind: :value
},
spoke: %{
description: "Spoke contract address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{
description: "Spoke-local reserve identifier (not an asset address)",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Current withdraw allowance"
}
}